patrickkidd / pyrtmidi Goto Github PK
View Code? Open in Web Editor NEWRealtime MIDI I/O for python.
Realtime MIDI I/O for python.
I couldn't get the first example to work, but I modified it and it achieves the objective:
import rtmidi
midiin = rtmidi.MidiIn()
midiin.ignore_types(sysex=False, timing=True, active_sense=True)
ports = range(midiin.get_port_count())
if ports:
for i in ports:
print(midiin.get_port_name(i))
print("Opening port 1!")
midiin.open_port(1)
while True:
m = midiin.get_message()
if m:
print(m)
else:
print('NO MIDI INPUT PORTS!')
I've been receiving logs from windows users that lack of the string representation of MIDI messages generated by rtmidi. I don't use windows at all, but but maybe someone here does and could confirm/investigate this ?
The doc refered to in the readme has moved to https://docs.juce.com/master/classMidiMessage.html
My code looks like:
def process_midis():
midiin1.openPort(port1)
midiout1.openPort(port1)
midiout1.openPort(port2)
...
midiin1.closePort()
midiout1.closePort()
midiout1.closePort()
and when I call it the second time I got an error
MidiInApi::setCallback: a callback function is already set!
I'm on a Mac currently running OS 10.13 (High Sierra.) There are no problems at all with installing rtmidi with python 2.7 (because of wheels...?) but no such luck for python 3.7.1. The errors hint to me that perhaps the CoreMIDI headers have changed.
Here is the full error trace. It's possibly a duplicate of the error posted by @guilbut
$ pip install rtmidi==2.3.4
Collecting rtmidi==2.3.4
Downloading https://files.pythonhosted.org/packages/80/a6/23e6fdbede1914bc1a12e3e5cdc97c3de7fccc1507126a0736dd741f0a81/rtmidi-2.3.4.tar.gz (51kB)
100% |████████████████████████████████| 61kB 1.4MB/s
Building wheels for collected packages: rtmidi
Running setup.py bdist_wheel for rtmidi ... error
Complete output from command /Users/mark/.virtualenvs/music/bin/python3 -u -c "import setuptools, tokenize;__file__='/private/var/folders/2m/xgqv_dkn2bvb_j4bf8qdky7c0000gn/T/pip-install-qvpnderi/rtmidi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /private/var/folders/2m/xgqv_dkn2bvb_j4bf8qdky7c0000gn/T/pip-wheel-equceuj7 --python-tag cp37:
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/extension.py:131: UserWarning: Unknown Extension options: 'headers'
warnings.warn(msg)
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-3.7
creating build/lib.macosx-10.9-x86_64-3.7/rtmidi
copying rtmidi/randomout.py -> build/lib.macosx-10.9-x86_64-3.7/rtmidi
copying rtmidi/collector.py -> build/lib.macosx-10.9-x86_64-3.7/rtmidi
copying rtmidi/__init__.py -> build/lib.macosx-10.9-x86_64-3.7/rtmidi
running build_ext
building 'rtmidi._rtmidi' extension
creating build/temp.macosx-10.9-x86_64-3.7
creating build/temp.macosx-10.9-x86_64-3.7/cpp_src
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -D__MACOSX_CORE__= -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c cpp_src/RtMidi.cpp -o build/temp.macosx-10.9-x86_64-3.7/cpp_src/RtMidi.o -Wno-missing-braces
In file included from /System/Library/Frameworks/CoreMIDI.framework/Headers/CoreMIDI.h:18:0,
from cpp_src/RtMidi.cpp:379:
/System/Library/Frameworks/CoreMIDI.framework/Headers/MIDIServices.h:300:2: error: expected unqualified-id before '^' token
(^MIDINotifyBlock)(const MIDINotification *message);
^
/System/Library/Frameworks/CoreMIDI.framework/Headers/MIDIServices.h:300:2: error: expected ')' before '^' token
/System/Library/Frameworks/CoreMIDI.framework/Headers/MIDIServices.h:343:2: error: expected unqualified-id before '^' token
(^MIDIReadBlock)(const MIDIPacketList *pktlist, void * __nullable srcConnRefCon);
^
/System/Library/Frameworks/CoreMIDI.framework/Headers/MIDIServices.h:343:2: error: expected ')' before '^' token
In file included from /System/Library/Frameworks/CoreMIDI.framework/Headers/CoreMIDI.h:18:0,
from cpp_src/RtMidi.cpp:379:
/System/Library/Frameworks/CoreMIDI.framework/Headers/MIDIServices.h:1154:6: error: 'MIDINotifyBlock' has not been declared
MIDINotifyBlock __nullable notifyBlock ) __OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0);
^
/System/Library/Frameworks/CoreMIDI.framework/Headers/MIDIServices.h:1240:9: error: 'MIDIReadBlock' has not been declared
MIDIReadBlock readBlock ) __OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0);
^
/System/Library/Frameworks/CoreMIDI.framework/Headers/MIDIServices.h:1643:9: error: 'MIDIReadBlock' has not been declared
MIDIReadBlock readBlock ) __OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0);
^
In file included from /usr/include/Availability.h:206:0,
from /usr/include/wchar.h:72,
from /usr/local/Cellar/gcc/4.8.2_1/lib/gcc/x86_64-apple-darwin13.2.0/4.8.2/include/c++/cwchar:44,
from /usr/local/Cellar/gcc/4.8.2_1/lib/gcc/x86_64-apple-darwin13.2.0/4.8.2/include/c++/bits/postypes.h:40,
from /usr/local/Cellar/gcc/4.8.2_1/lib/gcc/x86_64-apple-darwin13.2.0/4.8.2/include/c++/iosfwd:40,
from /usr/local/Cellar/gcc/4.8.2_1/lib/gcc/x86_64-apple-darwin13.2.0/4.8.2/include/c++/ios:38,
from /usr/local/Cellar/gcc/4.8.2_1/lib/gcc/x86_64-apple-darwin13.2.0/4.8.2/include/c++/ostream:38,
from /usr/local/Cellar/gcc/4.8.2_1/lib/gcc/x86_64-apple-darwin13.2.0/4.8.2/include/c++/iostream:39,
from cpp_src/RtMidi.h:49,
from cpp_src/RtMidi.cpp:39:
/System/Library/Frameworks/CoreServices.framework/Frameworks/FSEvents.framework/Headers/FSEvents.h:294:43: error: expected '}' before '__attribute__'
kFSEventStreamCreateFlagUseExtendedData __OSX_AVAILABLE_STARTING(__MAC_10_13, __IPHONE_11_0) = 0x00000040
^
In file included from /System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:55:0,
from cpp_src/RtMidi.cpp:381:
/System/Library/Frameworks/CoreServices.framework/Frameworks/FSEvents.framework/Headers/FSEvents.h:294:96: error: expected unqualified-id before '=' token
kFSEventStreamCreateFlagUseExtendedData __OSX_AVAILABLE_STARTING(__MAC_10_13, __IPHONE_11_0) = 0x00000040
^
In file included from /usr/include/Availability.h:206:0,
from /usr/include/wchar.h:72,
from /usr/local/Cellar/gcc/4.8.2_1/lib/gcc/x86_64-apple-darwin13.2.0/4.8.2/include/c++/cwchar:44,
from /usr/local/Cellar/gcc/4.8.2_1/lib/gcc/x86_64-apple-darwin13.2.0/4.8.2/include/c++/bits/postypes.h:40,
from /usr/local/Cellar/gcc/4.8.2_1/lib/gcc/x86_64-apple-darwin13.2.0/4.8.2/include/c++/iosfwd:40,
from /usr/local/Cellar/gcc/4.8.2_1/lib/gcc/x86_64-apple-darwin13.2.0/4.8.2/include/c++/ios:38,
from /usr/local/Cellar/gcc/4.8.2_1/lib/gcc/x86_64-apple-darwin13.2.0/4.8.2/include/c++/ostream:38,
from /usr/local/Cellar/gcc/4.8.2_1/lib/gcc/x86_64-apple-darwin13.2.0/4.8.2/include/c++/iostream:39,
from cpp_src/RtMidi.h:49,
from cpp_src/RtMidi.cpp:39:
/System/Library/Frameworks/CoreServices.framework/Frameworks/FSEvents.framework/Headers/FSEvents.h:520:41: error: expected '}' before '__attribute__'
kFSEventStreamEventFlagItemIsHardlink __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_9_0) = 0x00100000,
^
In file included from /System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:55:0,
from cpp_src/RtMidi.cpp:381:
/System/Library/Frameworks/CoreServices.framework/Frameworks/FSEvents.framework/Headers/FSEvents.h:520:93: error: expected unqualified-id before '=' token
kFSEventStreamEventFlagItemIsHardlink __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_9_0) = 0x00100000,
^
/System/Library/Frameworks/CoreServices.framework/Frameworks/FSEvents.framework/Headers/FSEvents.h:533:1: error: expected declaration before '}' token
};
^
error: command 'gcc' failed with exit status 1
----------------------------------------
Failed building wheel for rtmidi
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/mark/.virtualenvs/music/bin/python3 -u -c "import setuptools, tokenize;__file__='/private/var/folders/2m/xgqv_dkn2bvb_j4bf8qdky7c0000gn/T/pip-install-qvpnderi/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 /private/var/folders/2m/xgqv_dkn2bvb_j4bf8qdky7c0000gn/T/pip-record-m0pu_ssa/install-record.txt --single-version-externally-managed --compile --install-headers /Users/mark/.virtualenvs/music/bin/../include/site/python3.7/rtmidi:
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/extension.py:131: UserWarning: Unknown Extension options: 'headers'
warnings.warn(msg)
running install
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-3.7
creating build/lib.macosx-10.9-x86_64-3.7/rtmidi
copying rtmidi/randomout.py -> build/lib.macosx-10.9-x86_64-3.7/rtmidi
copying rtmidi/collector.py -> build/lib.macosx-10.9-x86_64-3.7/rtmidi
copying rtmidi/__init__.py -> build/lib.macosx-10.9-x86_64-3.7/rtmidi
running build_ext
building 'rtmidi._rtmidi' extension
creating build/temp.macosx-10.9-x86_64-3.7
creating build/temp.macosx-10.9-x86_64-3.7/cpp_src
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -D__MACOSX_CORE__= -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c cpp_src/RtMidi.cpp -o build/temp.macosx-10.9-x86_64-3.7/cpp_src/RtMidi.o -Wno-missing-braces
In file included from /System/Library/Frameworks/CoreMIDI.framework/Headers/CoreMIDI.h:18:0,
from cpp_src/RtMidi.cpp:379:
/System/Library/Frameworks/CoreMIDI.framework/Headers/MIDIServices.h:300:2: error: expected unqualified-id before '^' token
(^MIDINotifyBlock)(const MIDINotification *message);
^
/System/Library/Frameworks/CoreMIDI.framework/Headers/MIDIServices.h:300:2: error: expected ')' before '^' token
/System/Library/Frameworks/CoreMIDI.framework/Headers/MIDIServices.h:343:2: error: expected unqualified-id before '^' token
(^MIDIReadBlock)(const MIDIPacketList *pktlist, void * __nullable srcConnRefCon);
^
/System/Library/Frameworks/CoreMIDI.framework/Headers/MIDIServices.h:343:2: error: expected ')' before '^' token
In file included from /System/Library/Frameworks/CoreMIDI.framework/Headers/CoreMIDI.h:18:0,
from cpp_src/RtMidi.cpp:379:
/System/Library/Frameworks/CoreMIDI.framework/Headers/MIDIServices.h:1154:6: error: 'MIDINotifyBlock' has not been declared
MIDINotifyBlock __nullable notifyBlock ) __OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0);
^
/System/Library/Frameworks/CoreMIDI.framework/Headers/MIDIServices.h:1240:9: error: 'MIDIReadBlock' has not been declared
MIDIReadBlock readBlock ) __OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0);
^
/System/Library/Frameworks/CoreMIDI.framework/Headers/MIDIServices.h:1643:9: error: 'MIDIReadBlock' has not been declared
MIDIReadBlock readBlock ) __OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0);
^
In file included from /usr/include/Availability.h:206:0,
from /usr/include/wchar.h:72,
from /usr/local/Cellar/gcc/4.8.2_1/lib/gcc/x86_64-apple-darwin13.2.0/4.8.2/include/c++/cwchar:44,
from /usr/local/Cellar/gcc/4.8.2_1/lib/gcc/x86_64-apple-darwin13.2.0/4.8.2/include/c++/bits/postypes.h:40,
from /usr/local/Cellar/gcc/4.8.2_1/lib/gcc/x86_64-apple-darwin13.2.0/4.8.2/include/c++/iosfwd:40,
from /usr/local/Cellar/gcc/4.8.2_1/lib/gcc/x86_64-apple-darwin13.2.0/4.8.2/include/c++/ios:38,
from /usr/local/Cellar/gcc/4.8.2_1/lib/gcc/x86_64-apple-darwin13.2.0/4.8.2/include/c++/ostream:38,
from /usr/local/Cellar/gcc/4.8.2_1/lib/gcc/x86_64-apple-darwin13.2.0/4.8.2/include/c++/iostream:39,
from cpp_src/RtMidi.h:49,
from cpp_src/RtMidi.cpp:39:
/System/Library/Frameworks/CoreServices.framework/Frameworks/FSEvents.framework/Headers/FSEvents.h:294:43: error: expected '}' before '__attribute__'
kFSEventStreamCreateFlagUseExtendedData __OSX_AVAILABLE_STARTING(__MAC_10_13, __IPHONE_11_0) = 0x00000040
^
In file included from /System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:55:0,
from cpp_src/RtMidi.cpp:381:
/System/Library/Frameworks/CoreServices.framework/Frameworks/FSEvents.framework/Headers/FSEvents.h:294:96: error: expected unqualified-id before '=' token
kFSEventStreamCreateFlagUseExtendedData __OSX_AVAILABLE_STARTING(__MAC_10_13, __IPHONE_11_0) = 0x00000040
^
In file included from /usr/include/Availability.h:206:0,
from /usr/include/wchar.h:72,
from /usr/local/Cellar/gcc/4.8.2_1/lib/gcc/x86_64-apple-darwin13.2.0/4.8.2/include/c++/cwchar:44,
from /usr/local/Cellar/gcc/4.8.2_1/lib/gcc/x86_64-apple-darwin13.2.0/4.8.2/include/c++/bits/postypes.h:40,
from /usr/local/Cellar/gcc/4.8.2_1/lib/gcc/x86_64-apple-darwin13.2.0/4.8.2/include/c++/iosfwd:40,
from /usr/local/Cellar/gcc/4.8.2_1/lib/gcc/x86_64-apple-darwin13.2.0/4.8.2/include/c++/ios:38,
from /usr/local/Cellar/gcc/4.8.2_1/lib/gcc/x86_64-apple-darwin13.2.0/4.8.2/include/c++/ostream:38,
from /usr/local/Cellar/gcc/4.8.2_1/lib/gcc/x86_64-apple-darwin13.2.0/4.8.2/include/c++/iostream:39,
from cpp_src/RtMidi.h:49,
from cpp_src/RtMidi.cpp:39:
/System/Library/Frameworks/CoreServices.framework/Frameworks/FSEvents.framework/Headers/FSEvents.h:520:41: error: expected '}' before '__attribute__'
kFSEventStreamEventFlagItemIsHardlink __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_9_0) = 0x00100000,
^
In file included from /System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:55:0,
from cpp_src/RtMidi.cpp:381:
/System/Library/Frameworks/CoreServices.framework/Frameworks/FSEvents.framework/Headers/FSEvents.h:520:93: error: expected unqualified-id before '=' token
kFSEventStreamEventFlagItemIsHardlink __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_9_0) = 0x00100000,
^
/System/Library/Frameworks/CoreServices.framework/Frameworks/FSEvents.framework/Headers/FSEvents.h:533:1: error: expected declaration before '}' token
};
^
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/Users/mark/.virtualenvs/music/bin/python3 -u -c "import setuptools, tokenize;__file__='/private/var/folders/2m/xgqv_dkn2bvb_j4bf8qdky7c0000gn/T/pip-install-qvpnderi/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 /private/var/folders/2m/xgqv_dkn2bvb_j4bf8qdky7c0000gn/T/pip-record-m0pu_ssa/install-record.txt --single-version-externally-managed --compile --install-headers /Users/mark/.virtualenvs/music/bin/../include/site/python3.7/rtmidi" failed with error code 1 in /private/var/folders/2m/xgqv_dkn2bvb_j4bf8qdky7c0000gn/T/pip-install-qvpnderi/rtmidi/
Hi,
rtmidi.MidiMessage.noteOn() always return message for channel 1. rtmidi.MidiMessage.noteOff() is OK:
In [91]: rtmidi.MidiMessage.noteOn(10, 80, 127)
Out[91]: <NOTE ON, note: 80 (G#4), velocity: 127, channel: 1>
In [92]: m=rtmidi.MidiMessage.noteOn(10, 80, 127)
In [93]: m
Out[93]: <NOTE ON, note: 80 (G#4), velocity: 127, channel: 1>
In [94]: m.setChannel(10)
In [95]: m
Out[95]: <NOTE ON, note: 80 (G#4), velocity: 127, channel: 10>
In [96]: n=rtmidi.MidiMessage.noteOff(10,80)
In [97]: n
Out[97]: <NOTE OFF, note: 80 (G#4), channel: 10>
Hi,
Thanks you for your amazing pyrtmidi that i'm using on python 2.7 32 bit !
I would like to use it in Python 3.6 (32 and 64 bit) and on Python 2.7 64 bit, but I have some difficulties to install PyRtmidi on this python versions. "pip install rtmidi" doesn't work .
on ptyhon 2.7 64 bit , I have the error : LINK : fatal error LNK1181: cannot open input file 'python34.lib'
on python 3.6 (32 & 64 bit) i have the errors : LINK : fatal error LNK1181: cannot open input file 'winmm.lib'
I'm very sad, because if I switch to python-rtmidi or rtmidi-python I will lose your MidiMessage capability and will have to recode a lot of things.
Do you plan to release wheels ?
I tried to build it from source, but did'nt succeed.
For python 2.7 64 bit I tried :
Install Microsoft Visual C++ Compiler for Python 2.7 (https://www.microsoft.com/en-us/download/details.aspx?id=44266)
git clone https://github.com/patrickkidd/pyrtmidi
modify "pyrtmidi/septup.py"
libraries = ['winmm', 'python34'] => libraries = ['winmm', 'python27']
library_dirs = ['C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib']
=>
library_dirs = ['C:/Users/Guilbut/AppData/Local/Programs/Common/Microsoft/Visual C++ for Python/9.0/WinSDK/Lib/x64']
"python setup.py install" give me
C:....\python-2.7.13.amd64\lib
\distutils\extension.py:133: UserWarning: Unknown Extension options: 'headers'
warnings.warn(msg)
running install
running build
running build_py
creating build
creating build\lib.win-amd64-2.7
creating build\lib.win-amd64-2.7\rtmidi
copying rtmidi_init_.py -> build\lib.win-amd64-2.7\rtmidi
copying rtmidi\collector.py -> build\lib.win-amd64-2.7\rtmidi
copying rtmidi\randomout.py -> build\lib.win-amd64-2.7\rtmidi
running build_ext
building 'rtmidi._rtmidi' extension
Traceback (most recent call last):
File "setup.py", line 126, in
'Programming Language :: Python :: 3.4',
File "C:....\python-2.7.13.a
md64\lib\distutils\core.py", line 151, in setup
dist.run_commands()
File "C:....\python-2.7.13.a
md64\lib\distutils\dist.py", line 953, in run_commands
self.run_command(cmd)
File "C:....\python-2.7.13.a
md64\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "C:....\python-2.7.13.a
md64\lib\distutils\command\install.py", line 563, in run
self.run_command('build')
File "C:....\python-2.7.13.a
md64\lib\distutils\cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "C:....\python-2.7.13.a
md64\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "C:....\python-2.7.13.a
md64\lib\distutils\command\build.py", line 127, in run
self.run_command(cmd_name)
File "C:....\python-2.7.13.a
md64\lib\distutils\cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "C:....\python-2.7.13.a
md64\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "C:....\python-2.7.13.a
md64\lib\distutils\command\build_ext.py", line 340, in run
self.build_extensions()
File "C:....\python-2.7.13.a
md64\lib\distutils\command\build_ext.py", line 449, in build_extensions
self.build_extension(ext)
File "C:....\python-2.7.13.a
md64\lib\distutils\command\build_ext.py", line 499, in build_extension
depends=ext.depends)
File "C:....\python-2.7.13.a
md64\lib\distutils\msvc9compiler.py", line 473, in compile
self.initialize()
File "C:....\python-2.7.13.a
md64\lib\distutils\msvc9compiler.py", line 383, in initialize
vc_env = query_vcvarsall(VERSION, plat_spec)
File "C:....\python-2.7.13.a
md64\lib\distutils\msvc9compiler.py", line 299, in query_vcvarsall
raise ValueError(str(list(result.keys())))
ValueError: [u'path']
It tried to modify the VS90COMNTOOLS environnement var without succeed..
For python 3.6 I tried :
eh vector destructor iterator'(void *,unsigned int,unsigned int,void (__thiscall*)(void *))" (??_M@YGXPAXIIP6EX0@Z@Z) RtMidi.obj : error LNK2001: symbole externe non résolu __imp____std_exception_copy RtMidi.obj : error LNK2001: symbole externe non résolu __imp__midiInClose@4 RtMidi.obj : error LNK2001: symbole externe non résolu "void __cdecl operator delete(void *,unsigned int)" (??3@YAXPAXI@Z) RtMidi.obj : error LNK2001: symbole externe non résolu __imp____stdio_common_vfprintf RtMidi.obj : error LNK2001: symbole externe non résolu __imp__Sleep@4 MSVCRT.lib(crtdll.obj) : error LNK2001: symbole externe non résolu __imp__Sleep@4 RtMidi.obj : error LNK2001: symbole externe non résolu __imp__midiInAddBuffer@12 RtMidi.obj : error LNK2001: symbole externe non résolu __imp__midiInGetNumDevs@0 RtMidi.obj : error LNK2001: symbole externe non résolu __imp__DeleteCriticalSection@4 RtMidi.obj : error LNK2001: symbole externe non résolu __imp__midiOutShortMsg@8 RtMidi.obj : error LNK2001: symbole externe non résolu ___std_terminate RtMidi.obj : error LNK2001: symbole externe non résolu __imp__midiOutGetNumDevs@0 RtMidi.obj : error LNK2001: symbole externe non résolu __imp__midiOutLongMsg@12 RtMidi.obj : error LNK2001: symbole externe non résolu __imp__midiOutClose@4 RtMidi.obj : error LNK2001: symbole externe non résolu __imp__midiInStop@4 RtMidi.obj : error LNK2001: symbole externe non résolu __imp___invalid_parameter_noinfo_noreturn RtMidi.obj : error LNK2001: symbole externe non résolu "void __stdcall
eh vector constructor iterator'(void ,unsigned int,unsigned int,void (__thiscall)(void ),void (__thiscall)(void *))" (??_L@YThanks you very much .
Hi,
I noticed, after you close a port, you get an error when you try to reopen it. The following code reproduces this behavior.
import rtmidi
m = rtmidi.RtMidiIn()
m.openPort(0) # first call works
m.closePort()
m.openPort(0) # second call fails
I get the following error:
MidiInAlsa::openPort: ALSA error making port connection.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
rtmidi.Error: MidiInAlsa::openPort: ALSA error making port connection.
My OS is ArchLinux, pyrtmidi 2.3.4-2.
I hope I didn't miss anything, but I couldn't find any documentation on this behavior. So I decided to report it. This might also be a problem of RtMidi. But as I am not very familiar with C++, I didn't check it.
$ pip install rtmidi
...
D:\msys2-64\mingw64\bin\gcc.exe -mdll -O -Wall -DMS_WIN64 -D__WINDOWS_MM__= -DPK_WINDOWS=1 -If:\mypython\ms2mmleditor\.venv-mmlparser\include -ID:\Python38\include -ID:\Python38\include -c cpp_src\RtMidi.cpp -o build\temp.win-amd64-3.8\Release\cpp_src\rtmidi.o /EHsc
gcc: error: /EHsc: No such file or directory
error: command 'D:\\msys2-64\\mingw64\\bin\\gcc.exe' failed with exit status 1
Then I downloaded this package and modified setup.py:
$ pip download rtmidi
$ tar -xzvf rtmidi-2.3.4.tar.gz
elif OSNAME == 'Windows':
define_macros = [('__WINDOWS_MM__', ''),
('PK_WINDOWS', '1')]
# library_dirs = ['C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib']
libraries = ['winmm', 'python34']
# extra_compile_args = ['/EHsc']
(btw, I don't know why it is "python34")
$ tar -czvf rtmidi-2.3.4.tar.gz rtmidi-2.3.4
$ pip install rtmidi-2.3.4.tar.gz
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Processing f:\mypython\ms2mmleditor\rtmidi-2.3.4.tar.gz
Installing collected packages: rtmidi
Running setup.py install for rtmidi ... done
Successfully installed rtmidi-2.3.4
This time I installed successfully, but got an ImportError:
Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import rtmidi
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "F:\mypython\ms2mmlEditor\.venv-mmlparser\lib\site-packages\rtmidi\__init__.py", line 1, in <module>
from ._rtmidi import *
ImportError: DLL load failed while importing _rtmidi: 找不到指定的模块。
So I have no idea how to install pyrtmidi without MSVC.
OS: Microsoft Windows 10 Home (v10.0.18363) 64bit
Python: Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)] on win32 (Installed with exe)
$ cat "D:\Python38\Lib\distutils\distutils.cfg"
[build]
compiler=mingw32
$ gcc --version
gcc.exe (Rev1, Built by MSYS2 project) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Hey,
using: Python 3.6.3 rtmidi 2.3.2
Some notes (at least A#-1, D#-2) lead to a buffer overflow crash when passing them through midi.getMidiNoteName()
as shown in the example. The call to midi.getNoteNumber()
is working fine. Any idea what's going on there?
I am using pyrtmidi on the raspberry pi, and it doesn't seem to be able to detect the Midi inputs (I'm not using outputs for this project, so I can't speak on that).
The curious thing about it is that the C/C++ RtMidi library seems to work.
My hardware is a Raspberry Pi Model B with an EMU XMidi 1x1.
Hi:
I have a question, I'm very newbie in this informatic sound world.
This is the scenario:
I connect my Behringer UMX610 controller via USB to my computer.
I spect when I play the keyboard my script recieve the midi signal and will print into terminal using this code (from README with little changes):
midiin = rtmidi.RtMidiIn()
def print_message(midi):
if midi.isNoteOn():
print('(L9) ON: ', midi.getMidiNoteName(midi.getNoteNumber()), midi.getVelocity())
elif midi.isNoteOff():
print('(L10) OFF:', midi.getMidiNoteName(midi.getNoteNumber()))
elif midi.isController():
print('(L13) CONTROLLER', midi.getControllerNumber(), midi.getControllerValue())
ports = range(midiin.getPortCount())
if ports:
for i in ports:
print('(L19) ', midiin.getPortName(i))
print("(L20) Opening port 0!")
midiin.openPort(0, midiin.getPortName(i))
while True:
m = midiin.getMessage(250) # some timeout in ms
print('(L24) Message', m)
if m:
print_message('(L23) ',m)
else:
print('(L28) NO MIDI INPUT PORTS!')
But the output is:
(L19) Midi Through 14:0
(L19) UMX 610 24:0
(L20) Opening port 0!
(L24) Message None
(L24) Message None
.
.
.
.
I'm very thankful for any explanations about this, and any kind of documentation links in order to enlighten me about this topic.
Thankyou.
Hi!
I'd love to evaluate using pyrtmidi for a project of mine. I was wondering if it was possible for you to upload it to pypi, so that pip install pyrtmidi
would work.
Thanks, package looks great!
Hi,
I get the error message, as described on the homepage. Python2.7, ubuntu 12.4.
I'm a complete noob to Python, so I don't know how to ship around this, but it seems not to work out-of-the box with pip install rtmidi
like specified in the readme, so I open up an issue here. Seems to me that you're buiding RtMidi from CPP source here and try to link against python34.lib, which is not present on my system. Idk, is there maybe a more general solution to this, so you use the lib corresponding to the Python version actually installed?
pip install rtmidi
Collecting rtmidi
Using cached rtmidi-2.3.4.tar.gz (51 kB)
Preparing metadata (setup.py) ... done
Using legacy 'setup.py install' for rtmidi, since package 'wheel' is not installed.
Installing collected packages: rtmidi
Running setup.py install for rtmidi ... error
error: subprocess-exited-with-error× Running setup.py install for rtmidi did not run successfully.
│ exit code: 1
╰─> [41 lines of output]
C:\Users\me\AppData\Local\Programs\Python\Python310\lib\distutils\extension.py:132: UserWarning: Unknown Extension options: 'headers'
warnings.warn(msg)
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.10
creating build\lib.win-amd64-3.10\rtmidi
copying rtmidi\collector.py -> build\lib.win-amd64-3.10\rtmidi
copying rtmidi\randomout.py -> build\lib.win-amd64-3.10\rtmidi
copying rtmidi_init_.py -> build\lib.win-amd64-3.10\rtmidi
running build_ext
building 'rtmidi.rtmidi' extension
creating build\temp.win-amd64-3.10
creating build\temp.win-amd64-3.10\Release
creating build\temp.win-amd64-3.10\Release\cpp_src
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -D__WINDOWS_MM_= -DPK_WINDOWS=1 -IC:\Users\me\AppData\Local\Programs\Python\Python310\include -IC:\Users\me\AppData\Local\Programs\Python\Python310\Include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt /EHsc /Tpcpp_src\MidiMessage.cpp /Fobuild\temp.win-amd64-3.10\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.
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)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -D__WINDOWS_MM= -DPK_WINDOWS=1 -IC:\Users\me\AppData\Local\Programs\Python\Python310\include -IC:\Users\me\AppData\Local\Programs\Python\Python310\Include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt /EHsc /Tpcpp_src\PyMidiMessage.cpp /Fobuild\temp.win-amd64-3.10\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\2019\Enterprise\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -D__WINDOWS_MM__= -DPK_WINDOWS=1 -IC:\Users\me\AppData\Local\Programs\Python\Python310\include -IC:\Users\me\AppData\Local\Programs\Python\Python310\Include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt /EHsc /Tpcpp_src\RtMidi.cpp /Fobuild\temp.win-amd64-3.10\Release\cpp_src\RtMidi.obj /EHsc
RtMidi.cpp
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -D__WINDOWS_MM__= -DPK_WINDOWS=1 -IC:\Users\me\AppData\Local\Programs\Python\Python310\include -IC:\Users\me\AppData\Local\Programs\Python\Python310\Include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt /EHsc /Tpcpp_src\rtmidimodule.cpp /Fobuild\temp.win-amd64-3.10\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.
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.
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.
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.
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.
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.
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.
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.
cpp_src\rtmidimodule.cpp(97): warning C4996: 'PyEval_CallObjectWithKeywords': deprecated in 3.9
cpp_src\rtmidimodule.cpp(908): warning C4996: 'PyEval_InitThreads': deprecated in 3.9
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:C:\Program Files\Microsoft SDKs\Windows7.1\Lib /LIBPATH:C:\Users\me\AppData\Local\Programs\Python\Python310\libs /LIBPATH:C:\Users\me\AppData\Local\Programs\Python\Python310\PCbuild\amd64 /LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\ATLMFC\lib\x64 /LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\lib\x64 /LIBPATH:C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x64 /LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\ucrt\x64 /LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64 winmm.lib python34.lib /EXPORT:PyInit__rtmidi build\temp.win-amd64-3.10\Release\cpp_src\MidiMessage.obj build\temp.win-amd64-3.10\Release\cpp_src\PyMidiMessage.obj build\temp.win-amd64-3.10\Release\cpp_src\RtMidi.obj build\temp.win-amd64-3.10\Release\cpp_src\rtmidimodule.obj /OUT:build\lib.win-amd64-3.10\rtmidi_rtmidi.cp310-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.10\Release\cpp_src_rtmidi.cp310-win_amd64.lib
LINK : fatal error LNK1181: cannot open input file 'python34.lib'
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\link.exe' failed with exit code 1181
[end of output]note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure× Encountered error while trying to install package.
╰─> rtmidinote: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.