Skip to content

Commit 7781387

Browse files
committed
iron out midi install
1 parent 436058a commit 7781387

File tree

6 files changed

+25
-22
lines changed

6 files changed

+25
-22
lines changed

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,6 @@ console:
8585

8686
pip install jupylet
8787

88-
To install it with MIDI support type the following command instead:
89-
90-
pip install jupylet[midi]
91-
9288
If you are using Python 3.8 on Windows you also need to run following command:
9389

9490
python -m jupylet postinstall

docs/programmers_reference_guide/getting_started.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@ console:
2424
2525
pip install jupylet
2626
27-
To install it with MIDI support type the following command instead:
28-
29-
.. code-block:: bash
30-
31-
pip install jupylet[midi]
32-
3327
If you are using Python 3.8 on Windows you also need to run following command:
3428

3529
.. code-block:: bash

jupylet/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
sys.stderr.write(
4949
'WARNING: numpy was imported before jupylet. ' +
5050
'On Mac OS X you should import jupylet first to let it work around ' +
51-
'a bug in the algebra libraries used by numpy, that may cause the ' +
51+
'a bug in the algebra libraries used by numpy that may cause the ' +
5252
'program to exit.' + '\n'
5353
)
5454

jupylet/app.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,13 @@ def set_midi_sound(self, s):
264264
s (jupylet.audio.sound.Sound): The sound object to use as MIDI
265265
instrument.
266266
"""
267-
midi.set_midi_sound(s)
268-
midi.set_midi_callback(midi.simple_midi_callback)
269-
270-
self.scheduler.unschedule(midi.midi_port_handler)
271-
self.scheduler.schedule_interval(midi.midi_port_handler, 1)
267+
if midi.test_rtmidi():
268+
269+
midi.set_midi_sound(s)
270+
midi.set_midi_callback(midi.simple_midi_callback)
271+
272+
self.scheduler.unschedule(midi.midi_port_handler)
273+
self.scheduler.schedule_interval(midi.midi_port_handler, 1)
272274

273275
@property
274276
def width(self):

jupylet/audio/midi.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,13 @@
2727
#
2828
# python-rtmidi requires the following command on ubuntu:
2929
# sudo apt-get install libasound2-dev libjack-dev build-essentials
30-
# And extend setup.py with extras for midi to avoid setup crash on ubuntu.
3130
#
3231

33-
import functools
34-
import _thread
3532
import logging
3633

3734
try:
3835
import rtmidi
3936
import mido
40-
4137
except:
4238
rtmidi = None
4339
mido = None
@@ -46,6 +42,19 @@
4642
logger = logging.getLogger(__name__)
4743

4844

45+
def test_rtmidi():
46+
47+
if rtmidi:
48+
return True
49+
50+
logger.warning(
51+
'Module python-rtmidi is not installed. To install it on Ubuntu ' +
52+
'Linux run these commands:\n' +
53+
'$ sudo apt-get install libasound2-dev libjack-dev build-essentials\n' +
54+
'$ pip install python-rtmidi'
55+
)
56+
57+
4958
_port = None
5059

5160

setup.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@
3838
python_requires='>=3.6, <3.9',
3939
install_requires=[
4040
'glfw',
41+
'mido',
4142
'wget',
42-
'numpy==1.19.3 ; platform_system=="Windows"',
4343
'numpy ; platform_system!="Windows"',
44+
'numpy==1.19.3 ; platform_system=="Windows"',
4445
'PyGLM',
4546
'scipy',
4647
'pillow',
@@ -54,10 +55,11 @@
5455
'matplotlib',
5556
'sounddevice',
5657
'scikit-image',
58+
'python-rtmidi ; platform_system!="Linux"',
5759
'moderngl-window',
5860
],
5961
extras_require = {
60-
'midi': ['mido', 'python-rtmidi']
62+
'midi': ['python-rtmidi']
6163
},
6264
classifiers=[
6365
'Development Status :: 4 - Beta',

0 commit comments

Comments
 (0)