Coder Social home page Coder Social logo

spotlightkid / python-rtmidi Goto Github PK

View Code? Open in Web Editor NEW
353.0 16.0 65.0 4.74 MB

Python bindings for the cross-platform MIDI I/O library RtMidi

Home Page: https://spotlightkid.github.io/python-rtmidi/

License: Other

Shell 0.40% Python 42.86% Makefile 3.02% Cython 44.88% Meson 7.97% C 0.87%
midi rtmidi python alsa coremidi jack-midi

python-rtmidi's Introduction

Welcome to python-rtmidi!

A Python binding for the RtMidi C++ library implemented using Cython.

Latest version Project status MIT License Python versions Distribution format CI status

Overview

RtMidi is a set of C++ classes which provides a concise and simple, cross-platform API (Application Programming Interface) for realtime MIDI input / output across Linux (ALSA & JACK), macOS / OS X (CoreMIDI & JACK), and Windows (MultiMedia System) operating systems.

python-rtmidi is a Python binding for RtMidi implemented using Cython and provides a thin wrapper around the RtMidi C++ interface. The API is basically the same as the C++ one but with the naming scheme of classes, methods and parameters adapted to the Python PEP-8 conventions and requirements of the Python package naming structure. python-rtmidi supports Python 3 (3.8+).

The documentation provides installation instructions, a history of changes per release and an API reference.

See the file LICENSE.md about copyright and usage terms.

The source code repository and issue tracker are hosted on GitHub:

https://github.com/SpotlightKid/python-rtmidi.

Usage example

Here's a quick example of how to use python-rtmidi to open the first available MIDI output port and send a middle C note on MIDI channel 1:

import time
import rtmidi

midiout = rtmidi.MidiOut()
available_ports = midiout.get_ports()

if available_ports:
    midiout.open_port(0)
else:
    midiout.open_virtual_port("My virtual output")

with midiout:
    note_on = [0x90, 60, 112] # channel 1, middle C, velocity 112
    note_off = [0x80, 60, 0]
    midiout.send_message(note_on)
    time.sleep(0.5)
    midiout.send_message(note_off)
    time.sleep(0.1)

del midiout

More usage examples can be found in the examples and tests directories of the source repository.

python-rtmidi's People

Contributors

aib avatar benoit-pierre avatar brunoenten avatar dependabot[bot] avatar georgeharker avatar mauriziob avatar spotlightkid avatar tekhedd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-rtmidi's Issues

Installing without Jack

I am using ALSA midi, Jack isn't needed for me. But when installing this with pip, it wanted Jack to be installed. On my system installing libjack0 or libjack-dev would remove other packages (I don't know exactly why). After some googling I found that

pip install python-rtmidi --install-option="--no-jack"

is just the right thing. This should be included somewhere in the docs.

Installation failing on Windows

I am trying to install python-rtmidi on my Windows 10 pc without success. I'm installing through pip and i already have Jack and VS Build Tools installed. The version of Python i'm using is 3.6.5. The error report is given below.

Collecting rtmidi
  Using cached https://files.pythonhosted.org/packages/f6/71/b536355f5e42dbe62f7d858b578f87dc585713873698d0d9ea8da476a125/rtmidi-2.3.3.tar.gz
Installing collected packages: rtmidi
  Running setup.py install for rtmidi ... error
    Complete output from command c:\users\adisr\appdata\local\programs\python\python36\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\adisr\\AppData\\Local\\Temp\\pip-install-wy8bsnle\\rtmidi\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\adisr\AppData\Local\Temp\pip-record-hhx287w_\install-record.txt --single-version-externally-managed --compile:
    c:\users\adisr\appdata\local\programs\python\python36\lib\distutils\extension.py:131: UserWarning: Unknown Extension options: 'headers'
      warnings.warn(msg)
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.6
    creating build\lib.win-amd64-3.6\rtmidi
    copying rtmidi\collector.py -> build\lib.win-amd64-3.6\rtmidi
    copying rtmidi\randomout.py -> build\lib.win-amd64-3.6\rtmidi
    copying rtmidi\__init__.py -> build\lib.win-amd64-3.6\rtmidi
    running build_ext
    building 'rtmidi._rtmidi' extension
    creating build\temp.win-amd64-3.6
    creating build\temp.win-amd64-3.6\Release
    creating build\temp.win-amd64-3.6\Release\cpp_src
    C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -D__WINDOWS_MM__= -DPK_WINDOWS=1 -Ic:\users\adisr\appdata\local\programs\python\python36\include -Ic:\users\adisr\appdata\local\programs\python\python36\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\cppwinrt" /EHsc /Tpcpp_src\RtMidi.cpp /Fobuild\temp.win-amd64-3.6\Release\cpp_src\RtMidi.obj /EHsc
    RtMidi.cpp
    C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -D__WINDOWS_MM__= -DPK_WINDOWS=1 -Ic:\users\adisr\appdata\local\programs\python\python36\include -Ic:\users\adisr\appdata\local\programs\python\python36\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\cppwinrt" /EHsc /Tpcpp_src\MidiMessage.cpp /Fobuild\temp.win-amd64-3.6\Release\cpp_src\MidiMessage.obj /EHsc
    MidiMessage.cpp
    cpp_src\MidiMessage.cpp(1055): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt\stdio.h(1772): note: see declaration of 'sprintf'
    cpp_src\MidiMessage.cpp(1057): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt\stdio.h(1772): note: see declaration of 'sprintf'
    C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -D__WINDOWS_MM__= -DPK_WINDOWS=1 -Ic:\users\adisr\appdata\local\programs\python\python36\include -Ic:\users\adisr\appdata\local\programs\python\python36\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\cppwinrt" /EHsc /Tpcpp_src\PyMidiMessage.cpp /Fobuild\temp.win-amd64-3.6\Release\cpp_src\PyMidiMessage.obj /EHsc
    PyMidiMessage.cpp
    cpp_src\PyMidiMessage.cpp(72): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data
    cpp_src\PyMidiMessage.cpp(87): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data
    C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -D__WINDOWS_MM__= -DPK_WINDOWS=1 -Ic:\users\adisr\appdata\local\programs\python\python36\include -Ic:\users\adisr\appdata\local\programs\python\python36\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\cppwinrt" /EHsc /Tpcpp_src\rtmidimodule.cpp /Fobuild\temp.win-amd64-3.6\Release\cpp_src\rtmidimodule.obj /EHsc
    rtmidimodule.cpp
    cpp_src\rtmidimodule.cpp(50): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt\stdio.h(1772): note: see declaration of 'sprintf'
    cpp_src\rtmidimodule.cpp(52): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt\stdio.h(1772): note: see declaration of 'sprintf'
    cpp_src\rtmidimodule.cpp(54): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt\stdio.h(1772): note: see declaration of 'sprintf'
    cpp_src\rtmidimodule.cpp(56): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt\stdio.h(1772): note: see declaration of 'sprintf'
    cpp_src\rtmidimodule.cpp(58): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt\stdio.h(1772): note: see declaration of 'sprintf'
    cpp_src\rtmidimodule.cpp(60): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt\stdio.h(1772): note: see declaration of 'sprintf'
    cpp_src\rtmidimodule.cpp(62): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt\stdio.h(1772): note: see declaration of 'sprintf'
    cpp_src\rtmidimodule.cpp(64): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt\stdio.h(1772): note: see declaration of 'sprintf'
    C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\bin\HostX86\x64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO "/LIBPATH:C:\Program Files\Microsoft SDKs\Windows�    7.1\Lib" /LIBPATH:c:\users\adisr\appdata\local\programs\python\python36\libs /LIBPATH:c:\users\adisr\appdata\local\programs\python\python36\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\lib\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.16299.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.16299.0\um\x64" "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\lib\x86" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.16299.0\ucrt\x86" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.16299.0\um\x86" winmm.lib python34.lib /EXPORT:PyInit__rtmidi build\temp.win-amd64-3.6\Release\cpp_src\RtMidi.obj build\temp.win-amd64-3.6\Release\cpp_src\MidiMessage.obj build\temp.win-amd64-3.6\Release\cpp_src\PyMidiMessage.obj build\temp.win-amd64-3.6\Release\cpp_src\rtmidimodule.obj /OUT:build\lib.win-amd64-3.6\rtmidi\_rtmidi.cp36-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.6\Release\cpp_src\_rtmidi.cp36-win_amd64.lib
    LINK : fatal error LNK1181: cannot open input file 'python34.lib'
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.13.26128\\bin\\HostX86\\x64\\link.exe' failed with exit status 1181

    ----------------------------------------
Command "c:\users\adisr\appdata\local\programs\python\python36\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\adisr\\AppData\\Local\\Temp\\pip-install-wy8bsnle\\rtmidi\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\adisr\AppData\Local\Temp\pip-record-hhx287w_\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\adisr\AppData\Local\Temp\pip-install-wy8bsnle\rtmidi\

Can't install on Raspbian Jessie Lite

Hi SpotlightKid !

After installing Raspbian Jessie Lite and the following packages :
$ sudo apt-get install build-essential
$ sudo apt-get install libasound2-dev
$ sudo apt-get install libjack-dev
$ sudo apt-get install python-pip
$ sudo pip install python-rtmidi

The pip install python-rtmidi failed...

pi@RPI2:~ $ sudo pip install python-rtmidi
Downloading/unpacking python-rtmidi
Could not find a version that satisfies the requirement python-rtmidi (from versions: 0.3.1a, 0.4.1b, 0.4.3b1, 0.3.1a, 0.3a, 0.4.2b, 0.5b1, 0.4.3b1, 0.2a, 0.3.1a, 0.3a, 0.2a, 0.5b1, 0.4.1b, 0.1a, 0.1a, 0.4.2b, 0.5b1, 0.4.2b, 0.4b, 0.4.3b1, 0.4.1b, 0.3a, 0.4b, 0.4b)
Cleaning up...
No distributions matching the version for python-rtmidi
Storing debug log for failure in /root/.pip/pip.log

Hardware : Raspberry PI 2

Failed building wheel for python-rtmidi

python --version
Python 2.7.14 :: Anaconda, Inc.
pip --version
pip 9.0.1 from /home/shahriar/anaconda2/envs/magenta/lib/python2.7/site-packages (python 2.7)
  ----------------------------------------
  Failed building wheel for python-rtmidi
  Running setup.py clean for python-rtmidi
Failed to build python-rtmidi
Installing collected packages: python-rtmidi
  Running setup.py install for python-rtmidi ... error
    Complete output from command /home/shahriar/anaconda2/envs/magenta/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-pogXIW/python-rtmidi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-FU1hms-record/install-record.txt --single-version-externally-managed --compile:
    Warning: Extension name 'rtmidi._rtmidi' does not match fully qualified name '_rtmidi' of 'src/_rtmidi.pyx'
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-2.7
    creating build/lib.linux-x86_64-2.7/rtmidi
    copying rtmidi/__init__.py -> build/lib.linux-x86_64-2.7/rtmidi
    copying rtmidi/midiconstants.py -> build/lib.linux-x86_64-2.7/rtmidi
    copying rtmidi/release.py -> build/lib.linux-x86_64-2.7/rtmidi
    copying rtmidi/midiutil.py -> build/lib.linux-x86_64-2.7/rtmidi
    running build_ext
    building 'rtmidi._rtmidi' extension
    creating build/temp.linux-x86_64-2.7
    creating build/temp.linux-x86_64-2.7/src
    gcc -pthread -B /home/shahriar/anaconda2/envs/magenta/compiler_compat -Wl,--sysroot=/ -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -D__LINUX_ALSA__ -D__UNIX_JACK__ -Isrc -I/home/shahriar/anaconda2/envs/magenta/include/python2.7 -c src/_rtmidi.cpp -o build/temp.linux-x86_64-2.7/src/_rtmidi.o
    cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
    gcc -pthread -B /home/shahriar/anaconda2/envs/magenta/compiler_compat -Wl,--sysroot=/ -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -D__LINUX_ALSA__ -D__UNIX_JACK__ -Isrc -I/home/shahriar/anaconda2/envs/magenta/include/python2.7 -c src/RtMidi.cpp -o build/temp.linux-x86_64-2.7/src/RtMidi.o
    cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
    g++ -pthread -shared -B /home/shahriar/anaconda2/envs/magenta/compiler_compat -L/home/shahriar/anaconda2/envs/magenta/lib -Wl,-rpath=/home/shahriar/anaconda2/envs/magenta/lib -Wl,--no-as-needed -Wl,--sysroot=/ build/temp.linux-x86_64-2.7/src/_rtmidi.o build/temp.linux-x86_64-2.7/src/RtMidi.o -L/home/shahriar/anaconda2/envs/magenta/lib -lasound -ljack -lpthread -lpython2.7 -o build/lib.linux-x86_64-2.7/rtmidi/_rtmidi.so
    /home/shahriar/anaconda2/envs/magenta/compiler_compat/ld: cannot find -lasound
    /home/shahriar/anaconda2/envs/magenta/compiler_compat/ld: cannot find -ljack
    /home/shahriar/anaconda2/envs/magenta/compiler_compat/ld: cannot find -lpthread
    /home/shahriar/anaconda2/envs/magenta/compiler_compat/ld: cannot find -lm
    /home/shahriar/anaconda2/envs/magenta/compiler_compat/ld: cannot find -lpthread
    /home/shahriar/anaconda2/envs/magenta/compiler_compat/ld: cannot find -lc
    collect2: error: ld returned 1 exit status
    error: command 'g++' failed with exit status 1
    
    ----------------------------------------
Command "/home/shahriar/anaconda2/envs/magenta/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-pogXIW/python-rtmidi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-FU1hms-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-pogXIW/python-rtmidi/

midi2command.py : @lru_cache() error in Python 2.7.9

Hi SpotlightKid !

I have an error with the midi2command script

Line 123 : @lru_cache()
TypeError: < lambda > () takes exactly 1 argument (0 given)

Should I remove the lru_cache code or what can I do ?

There is no urge !

[FoxDot] AttributeError: module 'rtmidi' has no attribute 'MidiIn'

I'm trying to sync FoxDot with an external MIDI clock, but I am getting the following output:
Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/FoxDot/lib/Code/main_lib.py", line 155, in __call__ exec(self._compile(code), self.namespace) File "FoxDot", line 1, in <module> from __future__ import absolute_import, division, print_function File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/FoxDot/lib/TempoClock.py", line 445, in sync_to_midi self.midi_clock = MidiIn(port) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/FoxDot/lib/Midi.py", line 61, in __init__ AttributeError: module 'rtmidi' has no attribute 'MidiIn'

I've tried re-installing rtmidi, but I'm not sure what would be causing this problem.

import error on OSX 10.9 Symbol not found: _jack_activate

here is the error message, i installed the library with

pip install python-rtmidi

and tried to compile from source using --no-jack parameter but still have the same error

any solutions?

thanks

>>> import rtmidi
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/xcorex/.pyenv/versions/3.5.2/lib/python3.5/site-packages/python_rtmidi-1.0.0-py3.5-macosx-10.9-x86_64.egg/rtmidi/__init__.py", line 4, in <module>
    from ._rtmidi import *  # noqa
ImportError: dlopen(/Users/xcorex/.pyenv/versions/3.5.2/lib/python3.5/site-packages/python_rtmidi-1.0.0-py3.5-macosx-10.9-x86_64.egg/rtmidi/_rtmidi.cpython-35m-darwin.so, 2): Symbol not found: _jack_activate
  Referenced from: /Users/xcorex/.pyenv/versions/3.5.2/lib/python3.5/site-packages/python_rtmidi-1.0.0-py3.5-macosx-10.9-x86_64.egg/rtmidi/_rtmidi.cpython-35m-darwin.so
  Expected in: flat namespace
 in /Users/xcorex/.pyenv/versions/3.5.2/lib/python3.5/site-packages/python_rtmidi-1.0.0-py3.5-macosx-10.9-x86_64.egg/rtmidi/_rtmidi.cpython-35m-darwin.so

High latency via ALSA interface

I'm experiencing latency of several hundred milliseconds from when I press the key on my keyboard and when my midi input callback is called . I'm using VMPK to test - which shows no latency when I direct its output to other synths. Is there something I can do about this, or is this expected? How can I debug what's going on?

I'm farily new to MIDI so pardon the ignorance. I'm using the example midi input callback code.

Channel format

What are the formats of the channels? And why is it not possible to assign channels with integers?

feature request for midiconstants.py

Hi,
first of all many thx for this great python implantation of rtmidi!!

i have a small feature request to form an midi message using midiconstants.

for example CC is defined as:
CONTROLLER_CHANGE = CONTROL_CHANGE = 0xB0
1011cccc 0ccccccc 0vvvvvvv (channel, controller, value)

Which mean if you form your midi message using this constants it look like this:
control = [CONTROLLER_CHANGE, 21, 127]

this will send an CC Event with Data1 = 21 and Data2 = 127 on MIdi Channel "1".

so it is only possible, if you use the midiconstants, to send on channel 1.

my feature request is to split MESSAGE Event kind from the Midi Channel that you can form an message like this.

control = [ 8, CONTROLLER_CHANGE, 21, 127 ]
mean:
Midi Channel 8, CC Event Kind, Data 1 (21), Data 2 (127)
or:
0111 1011nnnn 0ccccccc 0vvvvvvv

in most examples here, which i read, i fond the explanation for the control message format like this:
note_on = [NOTE_ON, 60, 112] # channel 1, middle C, velocity 112
i think to call the NOTE_ON Event kind "Channel1" can produce a misunderstanding. people like me interpret the meaning of Channel as Midi Channel 1-16.

/g
wolke

#include "RtMidi.h"

Hi,
I tried to install pyhton-rtmidi on my raspi via setup.py install. Cython is also installed. However, I get following error:
Package jack was not found in the pkg-config search path. Perhaps you should add the directory containing jack.pc'
to the PKG_CONFIG_PATH environment variable
No package 'jack' found
running install
running bdist_egg
running egg_info
writing top-level names to python_rtmidi.egg-info/top_level.txt
writing dependency_links to python_rtmidi.egg-info/dependency_links.txt
writing python_rtmidi.egg-info/PKG-INFO
reading manifest file 'python_rtmidi.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'src/rtmidi/RtMidi.cpp'
warning: no files found matching 'src/rtmidi/RtMidi.h'
warning: no previously-included files found matching '.appveyor.yml'
warning: no previously-included files found matching '.travis.yml'
warning: no previously-included files found matching '.rst.in'
no previously-included directories found matching 'ci'
warning: no previously-included files matching 'pycache' found under directory '
'
warning: no previously-included files matching '.py[co]' found under directory ''
writing manifest file 'python_rtmidi.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-armv7l/egg
running install_lib
running build_py
running build_ext
building 'rtmidi.rtmidi' extension
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-6waWnr/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -D__LINUX_ALSA
_ -D__UNIX_JACK__ -Isrc/rtmidi -I/usr/include/python3.5m -c src/_rtmidi.cpp -o build/temp.linux-armv7l-3.5/src/_rtmidi.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
src/_rtmidi.cpp:650:20: fatal error: RtMidi.h: No such file or directory
#include "RtMidi.h"
^
compilation terminated.
error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
`

Any idea how to fix this?
Thanks

Port name reported as "None"

I'm on macOS Sierra 10.12.3, and running Python 2.7.11 in a virtualenv with only rtmidi 1.1.0 installed.

When I go to Audio MIDI Setup, or other applications that let me view the port names of connected MIDI devices, I see one of my devices port names listed as:

Midi Fighter 3D�̨w

Note the unicode character: http://www.fileformat.info/info/unicode/char/0328/index.htm

I've e-mailed DJTechTools, the developers of this hardware, to ask if it's intentional that there is a strange character in their firmwares reporting of the port name.

However, when I perform the following with rtmidi:

rtmidi.MidiIn().get_ports()
[u'IAC Driver Plustype_IAC', u'nanoKONTROL2 SLIDER/KNOB', u'FastTrack Pro', None, u'Midi Fighter Twister']

I see the device with the unicode character have its port name reported as "None". If I connect to this device by port index rather than by name, I can successfully receive messages from the device, so I know this is the correct port. I'm not sure if this issue is in the underlying C++ rtmidi or in the Python bindings.

midioutwrapper.py is broken

Hi

when running the midioutwrapper.py example, it fires:

traceback (most recent call last):
  File "midioutwrapper.py", line 19, in <module>
    from rtmidi.midiconstants import (ALL_NOTES_OFF, ALL_SOUND_OFF, BALANCE, BANK_SELECT_LSB,
ImportError: cannot import name 'MODULATION' from 'rtmidi.midiconstants' (C:\Program Files (x86)\Python37-32\lib\site-packages\rtmidi\midiconstants.py)

Indeed the constant: "MODULATION" isn't defined unter: midiconstants.py. I guess you mean here: "MODULATION_WHEEL"

By the way, after replacing: "MODULATION" by "MODULATION_WHEEL", i got:

Traceback (most recent call last):
  File "midioutwrapper.py", line 230, in <module>
    with mout.open_virtual_port():
  File "src\_rtmidi.pyx", line 613, in rtmidi._rtmidi.MidiBase.open_virtual_port
NotImplementedError: Virtual ports are not supported by the Windows MultiMedia API.

So, I guess you better use the following call instead:
mout, in_port = midiutil.open_midioutput()

Or at least detect if you are using windows, then call the right function.

Anyway, after having done those changes, I'm using both: midioutwrapper.py and midiin_callback.py together with the virtual ports defined by a software called Bome Translator, but the midiin_callback.py script doesn't captures anything sent by the midioutwrapper.py script. Is this perhaps a problem with the Windows MIDI implementation?

Best regards
Josef

Writing to disk and microtonal tunings

Not an issue but a question:

  1. Is it possible to write midi streams to disk as a midi file?

  2. Is there a possibility of adjusting microtonal tunings on a single note on a single track?

Problems importing rtmidi (_rtmidi.so: undefined symbol) on Ubuntu with Anaconda

Hi, firstly thanks for this wrapper!

I believe I have all of the dependencies installed, and I can pip install python-rtmidi, however when I import rtmidi I get the error below. Is this an incompatibility with Anaconda? Or am I missing something?

memo@MSA-BOX1-UBUNTU:~$ sudo apt-get install -yq build-essential libasound-dev libjack-dev
Reading package lists...
Building dependency tree...
Reading state information...
build-essential is already the newest version (12.1ubuntu2).
libasound2-dev is already the newest version (1.1.0-0ubuntu1).
libjack-dev is already the newest version (1:0.124.1+20140122git5013bed0-3build2).
0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.

memo@MSA-BOX1-UBUNTU:~$ pip install -U mido python-rtmidi
Requirement already up-to-date: mido in ./anaconda2/lib/python2.7/site-packages
Requirement already up-to-date: python-rtmidi in ./anaconda2/lib/python2.7/site-packages

memo@MSA-BOX1-UBUNTU:~$ ipython
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15) 
Type "copyright", "credits" or "license" for more information.

IPython 5.3.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import rtmidi
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-bb8660ccb28e> in <module>()
----> 1 import rtmidi

/home/memo/anaconda2/lib/python2.7/site-packages/rtmidi/__init__.py in <module>()
      2 from __future__ import absolute_import
      3 from .release import version as __version__  # noqa
----> 4 from ._rtmidi import *  # noqa
      5 from ._rtmidi import __doc__  # noqa
      6 del absolute_import

ImportError: /home/memo/anaconda2/lib/python2.7/site-packages/rtmidi/_rtmidi.so: undefined symbol: _ZTVNSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEEE

System info:

Linux MSA-BOX1-UBUNTU 4.10.0-37-generic #41~16.04.1-Ubuntu SMP Fri Oct 6 22:42:59 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

               platform : linux-64
          conda version : 4.3.18
       conda is private : False
      conda-env version : 4.3.18
    conda-build version : not installed
         python version : 2.7.13.final.0
       requests version : 2.14.2
       root environment : /home/memo/anaconda2  (writable)
    default environment : /home/memo/anaconda2
       envs directories : /home/memo/anaconda2/envs
                          /home/memo/.conda/envs
          package cache : /home/memo/anaconda2/pkgs
                          /home/memo/.conda/pkgs
           channel URLs : https://repo.continuum.io/pkgs/free/linux-64
                          https://repo.continuum.io/pkgs/free/noarch
                          https://repo.continuum.io/pkgs/r/linux-64
                          https://repo.continuum.io/pkgs/r/noarch
                          https://repo.continuum.io/pkgs/pro/linux-64
                          https://repo.continuum.io/pkgs/pro/noarch
            config file : None
           offline mode : False
             user-agent : conda/4.3.18 requests/2.14.2 CPython/2.7.13 Linux/4.10.0-37-generic debian/stretch/sid glibc/2.23    
                UID:GID : 1000:1000

Call send_message() function without time.sleep(1) after

Idk if this is the right place to ask about this, but there is quite a big delay when I send a note from a python script to ableton live, is there a way to get a fast response time? I am sending the note to a virtual port created in loopMIDI to which ableton is listening.

Status always note_on, switched velocity with note

Hello,
I have encountered two problems during working with library. I work with 2 pianos - Yamaha piaggero np-11 and Casio CTK-700 and midi/usb cable.

First, on both pianos all midi events (note_on and note_off) come with status as note_on.

Second problem appears only with working on piano with changeable velocity - sometimes fields with velocity and note are switched for few seconds.

I work on Rasbperry Pi 3 (Raspbian 8.0) and Python 3.4.2.
Thank you very much for all help and very nice implementation.

get_ports() missing

Hi,

Thanks for a great library. I tried running the sample code and it seems that get_ports() method is missing. I get this:

Traceback (most recent call last):
  File "test.py", line 5, in <module>
    available_ports = midiout.get_ports()
AttributeError: 'rtmidi_python.MidiOut' object has no attribute 'get_ports'

note iterable first argument

In the examples there are note_on and note_off lists with the channel numbers like 0x90. Why are there numbers (hex_numbers?) and not integer numbers?

1.2 breaks travis for our repo

I'm not exactly sure what the issue is, but in https://github.com/tensorflow/magenta we are seeing the following error on Travis:

Searching for python-rtmidi
Reading https://pypi.org/simple/python-rtmidi/
Downloading https://files.pythonhosted.org/packages/13/14/007a87de6b097fe0c46535d5f83f960baa16da5d33ea0020d5e9f0b6aa89/python-rtmidi-1.2.0.tar.gz#sha256=8e7a50fff1b0bab16b71e19af17dfc91aad580d46ceb0bf36307555413a44d06
Best match: python-rtmidi 1.2.0
Processing python-rtmidi-1.2.0.tar.gz
Writing /tmp/easy_install-zurz61ys/python-rtmidi-1.2.0/setup.cfg
Running python-rtmidi-1.2.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-zurz61ys/python-rtmidi-1.2.0/egg-dist-tmp-mxm7vovm
warning: no previously-included files found matching '.appveyor.yml'
warning: no previously-included files found matching '.travis.yml'
warning: no previously-included files found matching '*.rst.in'
warning: no previously-included files found matching 'deploy.sh'
warning: no previously-included files found matching '*.sh'
warning: no previously-included files matching '__pycache__' found under directory '*'
warning: no previously-included files matching '*.py[co]' found under directory '*'
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
src/rtmidi/RtMidi.cpp: In member function ‘virtual void MidiInJack::setPortName(const string&)’:
src/rtmidi/RtMidi.cpp:3152:64: error: ‘jack_port_rename’ was not declared in this scope
   jack_port_rename( data->client, data->port, portName.c_str() );
                                                                ^
src/rtmidi/RtMidi.cpp: In member function ‘virtual void MidiOutJack::setPortName(const string&)’:
src/rtmidi/RtMidi.cpp:3376:64: error: ‘jack_port_rename’ was not declared in this scope
   jack_port_rename( data->client, data->port, portName.c_str() );
                                                                ^
error: Setup script exited with error: command 'gcc' failed with exit status 1

Sample program doesn't play

I just pip installed, pasted the sample program into a python file, and ran
python3 test.py

I got:

Cannot connect to server socket err = No such file or directory
Cannot connect to server socket
jack server is not running or cannot be started

which i think are fluidsynth errors and then the program hangs.
am i missing something?

also would like to know if this is the right program to install if I want to start a process that listens for midi events and plays them realtime. i'm working on a interface that is supposed to play sound in response to events in the real world.

System Details;
Mac OS X 10.13.2
Python 3.7.2
FluidSynth 2.0.4

i don't have jack, but mac os x has coremidi so it should work still?

Can't compile for kivy/android

I'm trying to include this library for use with kivy on android but keep running in to the following error when I run the recipe:
`/bin/false -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -D__LINUX_ALSA__ -D__UNIX_JACK__ -Isrc -I/usr/include/python2.7 -c src/_rtmidi.cpp -o build/temp.linux-x86_64-2.7/src/_rtmidi.o

error: command '/bin/false' failed with exit status 1`

Any idea what this could be? Is this even a good library to use with android/ios?

data parameter of the set_callback method isn't clear

I think the documentation of the data parameter of the set_callback method should be improved. For me it wasn't clear what it does. I had to read the C++ documentation in order to know what this is about.

After reading the python documentation of set_callback:
https://spotlightkid.github.io/python-rtmidi/rtmidi.html#rtmidi.MidiIn.set_callback

which says:

and the second argument is value of the data argument passed to this function when the callback is registered.

It wasn't clear to me what this data argument was about. After reading the documentation of the C++ source code:
https://www.music.mcgill.ca/~gary/rtmidi

There it is written:

It is possible to provide a pointer to user data that can be accessed in the callback function

For me, that's much more clearer. So, I guess that data argument could be everything. Even an object instancing an own defined class, ie:
midiin.set_callback(MidiInputHandler(port_name), my_object)

Then I guess you can do things like:

class MidiInputHandler(object):
    def __init__(self, port):
        self.port = port
        self._wallclock = time.time()

    def __call__(self, event, data):
        message, deltatime = event
        self._wallclock += deltatime
        print("[%s] @%0.6f %r" % (self.port, self._wallclock, message))
        data.my_method(self.port, self._wallclock, message)

Is this the purpose of the data parameter? If so, you could even extend the midiin_callback.py example and instead of printing the message in the callback, you could define a class that does this or perhaps put some comments to that example telling that you could do that as well.

Thanks and a happy new year to you.

Best regards
Josef

Update INSTALL.rst file:

On newer Debian system you need to install the library with:

sudo pip3 install python-rtmidi

sudo pip2 install python-rtmidi

MIDI IN wrapper suggestions

Hi

Right now I'm writing a MIDI IN wrapper to define callbacks for each MIDI IN message. Something similar to what the MIDI library for Arduino does:
https://github.com/FortySevenEffects/arduino_midi_library/wiki/Using-Callbacks

So, I started doing some coding and I'm wondering if you could give me some advice. Since you are the developer of this library, you know for sure what it is needed to be done for a proper execution. You can for sure use my code if you want to write your own example.

Right now, I'm only handling NOTE ON events, but I will extend it to the other messages. Here my code:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# midiinputhandler.py
#
"""Wrap MidiIn to add convenience methods for catching common MIDI events."""

from __future__ import print_function
from rtmidi.midiconstants import (ALL_NOTES_OFF, ALL_SOUND_OFF, BALANCE,
	BANK_SELECT_LSB, BANK_SELECT_MSB,
	BREATH_CONTROLLER, CHANNEL_PRESSURE,
	CHANNEL_VOLUME, CONTROL_CHANGE,
	DATA_ENTRY_LSB, DATA_ENTRY_MSB,
	END_OF_EXCLUSIVE, EXPRESSION_CONTROLLER,
	FOOT_CONTROLLER, LOCAL_CONTROL,
	MIDI_TIME_CODE, MODULATION, NOTE_OFF,
	NOTE_ON, NRPN_LSB, NRPN_MSB, PAN, PITCH_BEND,
	POLY_PRESSURE, PROGRAM_CHANGE,
	RESET_ALL_CONTROLLERS, RPN_LSB, RPN_MSB,
	SONG_POSITION_POINTER, SONG_SELECT,
	TIMING_CLOCK)
import time

class MidiInWrapper:
	def __init__(self, midi_in, midi_out):
		"""
		Initializes the class attributes
		Parameters:
		* midi_in: MIDI IN interface to use
		* midi_out: MIDI OUT interface to use
		"""
		#I don't really know if I really need this clock for a real world use case
		self._wallclock = time.time()
		self._midi_in = midi_in
		self._midi_out = midi_out
		self._note_on_callback = None
		
		#Sets the main MIDI callback where all preprocessing will be done
		print("Setting callback")
		self._midi_in.set_callback(self)

	def __call__(self, event, data = None):
		message, deltatime = event
		self._wallclock += deltatime
		message_type = message[0] & 0xF0
		if (message_type == NOTE_ON):
			print("Note on was detected")
			self._handle_note_on(message, data)
		else:
			print("Nothing was detected")
			#Raise error here
			pass
			
	def _handle_note_on(self, message, data = None):
		"""
		Handles a NOTE ON message. By default it just sends it back
		"""
		if self._note_on_callback == None:
			print("Sending message normally")
			self._midi_out.send_message(message)
		else:
			print("Sending message through callback")
			callback, data = self._note_on_callback
			callback(message, data)
		
	def set_note_on(self, callback, data = None):
		"""
		Sets the NOTE ON callback
		Parameters:
		* callback: function that will be executed each time a NOTE ON message
		  is catched
		* data: pointer to user data that can be used inside the callback. It
		  can be litterally everything you want: an integer, an string, an
		  object, etc..
		"""
		self._note_on_callback = callback, data
		
if __name__ == '__main__':
	#Note: this section serves for demostrative purposes. In a real use case,
	#      you should define your own callback function or a class with
	#      callback methods
	
	from rtmidi.midiutil import open_midioutput, open_midiinput
	
	#You can use callback functions or a class defining your callbacks. This is
	#up to you
	
	def send_note_on(message, data):
		"""
		Callback function
		Parameters:
			* message: Contains a list with the bytes of the MIDI Message, ie:
			  [147, 60, 112] (in Hexadecimal: 93 00 64) represents a sending a
			  middle C NOTE ON with a velocity of 112 through the MIDI channel
			  4.
			* data: pointer to user data that can be used inside the callback.
			  It can be litterally everything you want: an integer, an string,
			  an object, etc.. If you don't need it, then you should change the
			  signature of the function to:
			      def send_note_on(message, data = None):
		"""
		print("Note on callback")
		data.send_message(message)
	
	class MidiCallbacks:
		"""
		Class defining the callbacks
		"""
		def __init__(self, midi_in, midi_out):
			"""
			Initializes the class attributes
			"""
			self._midi_in = midi_in
			self._midi_out = midi_out

		def send_note_on(self, message, data = None):
			"""
			Callback method for NOTE ON messages
			Parameters:
			* message: Contains a list with the bytes of the MIDI Message, ie:
			  [147, 60, 112] (in Hexadecimal: 93 00 64) represents a sending a
			  middle C NOTE ON with a velocity of 112 through the MIDI channel
			  4.
			* data: pointer to user data that can be used inside the callback.
			  It can be litterally everything you want: an integer, an string,
			  an object, etc.. On this case, I'm not using it.
			"""
			print("Note on callback")
			self._midi_out.send_message(message)
	
	print("")
	
	#Open a MIDI IN and OUT ports. Let's say you have two ports: Port01 and
	#Port02. For testing, first start this script and set the following:
	#* Input port: Port01
	#* Output port: Port02
	#Then start an application that sends and receives MIDI messages, ie: Bome
	#SendSX, there set the ports as follows:
	#* Input port: Port02
	#* Output port: Port01
	#Finally start sending MIDI messages from your MIDI application. You should
	#see the same messages in the MIDI IN and OUT. In the console there should
	#be some debug messages
	midi_out, out_port = open_midioutput(interactive = True)
	midi_in_wrapper = MidiInWrapper(midi_in, midi_out)
	
	#Uncomment this to use with a callback function
	#midi_in_wrapper.set_note_on(send_note_on, midi_out)
	
	#I preffer to use a class for my callbacks.
	#First an instance must be created
	midi_callbacks = MidiCallbacks(midi_in, midi_out)
	
	#Then each callback must be set in the MidiInWrapper object
	midi_in_wrapper.set_note_on(midi_callbacks.send_note_on)

	print("Entering main loop. Press Control-C to exit.")
	try:
		# Just wait for keyboard interrupt,
		# everything else is handled via the input callback.
		while True:
			time.sleep(1)
	except KeyboardInterrupt:
		print('')
	finally:
		print("Exit.")
		midi_in.close_port()
		midi_out.close_port()
		del midi_in
		del midi_out

Thanks in advance

Best regards
Josef

Getting additional messages after closing port under Windows

Hi

I don't know if this is also the behavior on linux, but under Windows I'm getting additional messages after closing the MIDI Out port. First I start:

python midiin_callback.py
DEBUG:rtmidi.midiutil:Creating MidiIn object.
Available MIDI ports:

[0] Bome MIDI Translator 1 0
[1] loopMIDI Port 1

Select MIDI input port (Control-C to exit): 1
INFO:rtmidi.midiutil:Opening MIDI input port #0 (Bome MIDI Translator 1 0).
Attaching MIDI input callback handler.
Entering main loop. Press Control-C to exit.

Then I run:

python midioutwrapper.py
Available MIDI ports:

[0] Microsoft GS Wavetable Synth 0
[1] Bome MIDI Translator 1 1
[2] loopMIDI Port 2

Select MIDI output port (Control-C to exit): 2
Connect to new MIDI port and then press key...

I tried both ports: Bome MIDI Translator and loopMIDI and the result is the same. I always get:

[loopMIDI Port 1] @1576058149.982414 [194, 40]
[loopMIDI Port 1] @1576058149.983414 [146, 60, 127]
[loopMIDI Port 1] @1576058150.983414 [130, 60, 0]
[loopMIDI Port 1] @1576058161.087414 [176, 123, 0]
[loopMIDI Port 1] @1576058161.087414 [176, 121, 0]
[loopMIDI Port 1] @1576058161.088414 [177, 123, 0]
[loopMIDI Port 1] @1576058161.089414 [177, 121, 0]
[loopMIDI Port 1] @1576058161.091414 [178, 123, 0]
[loopMIDI Port 1] @1576058161.092414 [178, 121, 0]
[loopMIDI Port 1] @1576058161.093414 [179, 123, 0]
[loopMIDI Port 1] @1576058161.094414 [179, 121, 0]
[loopMIDI Port 1] @1576058161.094414 [180, 123, 0]
[loopMIDI Port 1] @1576058161.095413 [180, 121, 0]
[loopMIDI Port 1] @1576058161.096413 [181, 123, 0]
[loopMIDI Port 1] @1576058161.097413 [181, 121, 0]
[loopMIDI Port 1] @1576058161.098413 [182, 123, 0]
[loopMIDI Port 1] @1576058161.098413 [182, 121, 0]
[loopMIDI Port 1] @1576058161.099413 [183, 123, 0]
[loopMIDI Port 1] @1576058161.099413 [183, 121, 0]
[loopMIDI Port 1] @1576058161.100413 [184, 123, 0]
[loopMIDI Port 1] @1576058161.104413 [184, 121, 0]
[loopMIDI Port 1] @1576058161.107413 [185, 123, 0]
[loopMIDI Port 1] @1576058161.113413 [185, 121, 0]
[loopMIDI Port 1] @1576058161.115413 [186, 123, 0]
[loopMIDI Port 1] @1576058161.115413 [186, 121, 0]
[loopMIDI Port 1] @1576058161.116413 [187, 123, 0]
[loopMIDI Port 1] @1576058161.116413 [187, 121, 0]
[loopMIDI Port 1] @1576058161.117413 [188, 123, 0]
[loopMIDI Port 1] @1576058161.117413 [188, 121, 0]
[loopMIDI Port 1] @1576058161.118413 [189, 123, 0]
[loopMIDI Port 1] @1576058161.118413 [189, 121, 0]
[loopMIDI Port 1] @1576058161.119413 [190, 123, 0]
[loopMIDI Port 1] @1576058161.119413 [190, 121, 0]
[loopMIDI Port 1] @1576058161.123413 [191, 123, 0]
[loopMIDI Port 1] @1576058161.124413 [191, 121, 0]

Is this normal? Will this also happen under Linux? Will this affect other connected MIDI devices?

As far as I see it, the first three messages are sent by: midioutwrapper.py. The other ones are message like ALL NOTES OFF, etc..

Thanks

Best regards
Josef

Broken on Python 3.7

Python 3.7 made some changes to the interpreter state that broken Cython, and a fix was added to Cython 0.27.3 (cython/cython#1955). The _rtmidi.cpp that's on PyPI was apparently compiled with an older version of Cython than that, so now you can't install python-rtmidi easily from PyPI.

python-rtmidi.get_message() doesn't return system exclusive commands

Hey there,
I'm currently trying to communicate with a device via midi. I'm sending a message to poll for the device's current configuration and it returns up to 30 bytes of data.

I can use the library to successfully send the device data but I've come across some problems trying to receive messages.

I've verified that the device is sending back data via the use of MIDI OX.
image

I've also verified that get_message() works with conventional midi devices by running the same code with an oxygen8, So this leads me to believe that get_message does not listen to sysEx commands

Here is the code that I have written so far in trying to communicate with the device

midi.zip

Installation error on OS X 10.11

I am getting the following error message when I try to install rtmidi via pip. I have tried python 3.5 and 3.6, as well as rtmidi version 2.0, 2.1 and 2.2.

  Running setup.py clean for rtmidi
Failed to build rtmidi
Installing collected packages: rtmidi
  Running setup.py install for rtmidi ... error
    Complete output from command /Users/angusturner/anaconda2/envs/py3k/bin/python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-36rcilh3/rtmidi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-7651oity-record/install-record.txt --single-version-externally-managed --compile:
    /Users/angusturner/anaconda2/envs/py3k/lib/python3.6/distutils/extension.py:131: UserWarning: Unknown Extension options: 'author', 'author_email', 'classifiers', 'description', 'keywords', 'url'
      warnings.warn(msg)
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.7-x86_64-3.6
    creating build/lib.macosx-10.7-x86_64-3.6/rtmidi
    copying rtmidi/__init__.py -> build/lib.macosx-10.7-x86_64-3.6/rtmidi
    copying rtmidi/collector.py -> build/lib.macosx-10.7-x86_64-3.6/rtmidi
    copying rtmidi/randomout.py -> build/lib.macosx-10.7-x86_64-3.6/rtmidi
    running build_ext
    building 'rtmidi._rtmidi' extension
    creating build/temp.macosx-10.7-x86_64-3.6
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/angusturner/anaconda2/envs/py3k/include -arch x86_64 -I/Users/angusturner/anaconda2/envs/py3k/include -arch x86_64 -D__MACOSX_CORE__= -I/Users/angusturner/anaconda2/envs/py3k/include/python3.6m -c RtMidi.cpp -o build/temp.macosx-10.7-x86_64-3.6/RtMidi.o
    RtMidi.cpp:235:17: error: out-of-line definition of 'setErrorCallback' does not match any declaration in 'MidiApi'
    void MidiApi :: setErrorCallback( RtMidiErrorCallback errorCallback )
                    ^~~~~~~~~~~~~~~~
    RtMidi.cpp:251:40: error: too few arguments to function call, expected 3, have 2
        errorCallback_( type, errorMessage );
        ~~~~~~~~~~~~~~                     ^
    2 errors generated.
    error: command 'gcc' failed with exit status 1```

why I get rtmidi.NoDevicesError exception?

Trying to run the basic example to receive midi notes with callback and I get the following:

rtmidi._rtmidi.NoDevicesError: No MIDI input ports found.

OS: Windows 10

any idea what can be wrong?

Closing ports on Linux

I am not sure this is because of rtmidi, but since i have been using mainly rtmidi and my Memory is completely full now after some hours of playing with midi stuff (The 8 GB memory is completely exhausted and also the Swap partition is almost full). I explicitly close all MidiIn MidiOut ports i open with close_port() method by closing the main program. Is there any possibility that the ports doesn't get closed properly?

Getting input messages

Is there an example snippet code on how to get midi messages? For example from a running qtractor MIDI-track? How is it possible to get all midi-messages being played by a running qtractor?

Midi In misses Start (250) and Clock messages (248)

Hey everyone,

midi_in.get_message() misses the start and clock messages, this is really weird.
I know they are sent by my device cause aseqdumb shows them in the terminal, however no trace of them within python..
I'm on a Rpi

All the other messages (stop, notes..) I receive with no problem.

Any idea how this can be?
Many thanks :)

use_virtual not obeyed in midiutil.open_midiinput if interactive=true

Hello,
thanks for this nice library!
The documentation for rtmidi.midiutil.open_midiport says:

If port is None or no MIDI port matching the port number or name is available, should the user be prompted on the console whether to open a virtual MIDI port (if use_virtual is True) and/or with a list of available MIDI ports and the option to choose one? Defaults to True.

So I expected midiutil.open_midiinput(use_virtual=False, interactive=True) NOT to ask if I'd like to use a virtual port, but it does anyway.

In my opinion it but be great if use_virtual could be something like None or "prompt" (then ask), otherwise it should obey use_virtual=True or use_virtual=False.

What do you think?
Best, Boris

Python3 error : ImportError: No module named 'rtmidi'

Hi SpotlightKid !

When I call any python script with python3 I have the following error

#!/usr/bin/python3
import rtmidi
from rtmidi.midiutil import open_midiport
from rtmidi.midiconstants import *
ImportError: No module named 'rtmidi'

If I call from python 2.7 it works flawless

How can I import rtmidi in python 3 ?

There is no urge !

Cannot install on Bash on Windows Subsystem

I set up Bash on Windows with the latest update in order to use rtmidi through a Linux command line without having to dual boot or use VMs.

Though I installed the Linux libraries mentioned in the Wiki, I am running into an odd problem trying to install this library specifically. Bash on Windows is emulating Ubuntu 14.04 LTE.

Any feedback you have on how to get this working would be appreciated. Thanks.

root@localhost:/etc/apt# sudo pip install rtmidi
Downloading/unpacking rtmidi
 Downloading rtmidi-2.0.tar.gz
 Running setup.py (path:/tmp/pip_build_root/rtmidi/setup.py) egg_info for package rtmidi
/usr/lib/python2.7/distutils/extension.py:133: UserWarning: Unknown Extension options: 'author', 'author_email', 'classifiers', 'description', 'keywords', 'url'
  warnings.warn(msg)

Installing collected packages: rtmidi
Running setup.py install for rtmidi
 /usr/lib/python2.7/distutils/extension.py:133: UserWarning: Unknown Extension options: 'author', 'author_email', 'classifiers', 'description', 'keywords', 'url'
  warnings.warn(msg)
 building 'rtmidi._rtmidi' extension
 x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -D__LINUX_ALSASEQ__= -I/usr/include/python2.7 -c RtMidi.cpp -o build/temp.linux-x86_64-2.7/RtMidi.o
 cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
 RtMidi.cpp:39:20: fatal error: RtMidi.h: No such file or directory
  #include "RtMidi.h"
                     ^
 compilation terminated.
 error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
 Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/rtmidi/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-TLzE00-record/install-record.txt --single-version-externally-managed --compile:
 /usr/lib/python2.7/distutils/extension.py:133: UserWarning: Unknown Extension options: 'author', 'author_email', 'classifiers', 'description', 'keywords', 'url'

warnings.warn(msg)

running install

running build

running build_py

creating build

creating build/lib.linux-x86_64-2.7

 creating build/lib.linux-x86_64-2.7/rtmidi

copying rtmidi/__init__.py -> build/lib.linux-x86_64-2.7/rtmidi

copying rtmidi/collector.py -> build/lib.linux-x86_64-2.7/rtmidi

copying rtmidi/randomout.py -> build/lib.linux-x86_64-2.7/rtmidi

running build_ext

building 'rtmidi._rtmidi' extension

creating build/temp.linux-x86_64-2.7

x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -D__LINUX_ALSASEQ__= -I/usr/include/python2.7 -c RtMidi.cpp -o build/temp.linux-x86_64-2.7/RtMidi.o

cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]

RtMidi.cpp:39:20: fatal error: RtMidi.h: No such file or directory

#include "RtMidi.h"

                ^

compilation terminated.

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

 ----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools,     tokenize;__file__='/tmp/pip_build_root/rtmidi/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-TLzE00-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/rtmidi
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
  load_entry_point('pip==1.5.4', 'console_scripts', 'pip')()
 File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 235, in main
  return command.main(cmd_args)
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 161, in main
    text = '\n'.join(complete_log)
 UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 42: ordinal not in range(128)

Question about midifilter example

Hi,
(newbie here..) I have noticed that in the "midifilter" example a thread is used to process events. Is it needed?
What happens if one doesn't use a thread?
Thanks !

issue with installing either via pip or from source.

i'm assuming this is due to changed file paths from xcode in the new os x release (mojave). i'm getting the following error when i try and install.

ianfundere@ianfunderes-mac:~/Downloads/python-rtmidi-master$ python setup.py install
Compiling src/_rtmidi.pyx because it changed.
[1/1] Cythonizing src/_rtmidi.pyx
running install
running bdist_egg
running egg_info
creating python_rtmidi.egg-info
writing top-level names to python_rtmidi.egg-info/top_level.txt
writing python_rtmidi.egg-info/PKG-INFO
writing dependency_links to python_rtmidi.egg-info/dependency_links.txt
writing manifest file 'python_rtmidi.egg-info/SOURCES.txt'
reading manifest file 'python_rtmidi.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no previously-included files found matching '*.rst.in'
warning: no previously-included files found matching 'deploy.sh'
warning: no previously-included files found matching '*.sh'
warning: no previously-included files matching '__pycache__' found under directory '*'
warning: no previously-included files matching '*.py[co]' found under directory '*'
writing manifest file 'python_rtmidi.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.6-x86_64/egg
running install_lib
running build_py
creating build
creating build/lib.macosx-10.6-x86_64-3.5
creating build/lib.macosx-10.6-x86_64-3.5/rtmidi
copying rtmidi/release.py -> build/lib.macosx-10.6-x86_64-3.5/rtmidi
copying rtmidi/midiconstants.py -> build/lib.macosx-10.6-x86_64-3.5/rtmidi
copying rtmidi/__init__.py -> build/lib.macosx-10.6-x86_64-3.5/rtmidi
copying rtmidi/midiutil.py -> build/lib.macosx-10.6-x86_64-3.5/rtmidi
running build_ext
building 'rtmidi._rtmidi' extension
creating build/temp.macosx-10.6-x86_64-3.5
creating build/temp.macosx-10.6-x86_64-3.5/src
/usr/bin/clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/anaconda3/include -arch x86_64 -I/anaconda3/include -arch x86_64 -D__UNIX_JACK__ -D__MACOSX_CORE__= -Isrc -I/anaconda3/include/python3.5m -c src/_rtmidi.cpp -o build/temp.macosx-10.6-x86_64-3.5/src/_rtmidi.o -frtti
warning: include path for stdlibc++ headers not found; pass '-std=libc++' on the
      command line to use the libc++ standard library instead
      [-Wstdlibcxx-not-found]
src/_rtmidi.cpp:624:10: fatal error: 'ios' file not found
#include "ios"
         ^~~~~
1 warning and 1 error generated.
error: command '/usr/bin/clang' failed with exit status 1

appreciate all your work.

cheers,
ian

MidiOutDummy : no functionnality

Hi,

I'm trying to write a class that receives bytes messages and send them as MIDI messages, this is my init() function :

` def init(self):

    self.midi_outs = [rtmidi.MidiOut(rtapi=rtmidi.API_UNSPECIFIED,name=("Midi out n"+str(n))) for n in range(0,7)]

    for i in range(0,7):

        self.midi_outs[i].open_virtual_port("Wi-MidiVPort"+str(i))

    print(self.midi_outs[0].get_port_count())

`

This is the output i get :
MidiOutDummy: This class provides no functionality.
And this 8 times.

What am i doing wrong/Is that a known issue ?

Custom sf2 with python-rtmidi

Hello! I was looking at pyfluidsynth and was having some issues getting the sound to play (I opened an issue there). While troubleshooting I also found this and was wondering if python-rtmidi can work with SF2 files of various instruments?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.