Open sniperwrb opened 4 years ago
Fantastic job, @sniperwrb !! Thank you so much. All official MIDI repos are broken and we are desperately in need of a working solution.
Here is my contribution in a form of a FluidSynth Hack for Windows and Jupiter/Google Colabs.
!pip install pretty_midi
!pip install pypianoroll
!pip install mir_eval
!apt install fluidsynth #Pip does not work for some reason. Only apt works
!pip install midi2audio
!cp /usr/share/sounds/sf2/FluidR3_GM.sf2 /content/font.sf2
import mido
import librosa
import pretty_midi
import pypianoroll
from pypianoroll import Multitrack, Track
import matplotlib
import matplotlib.pyplot as plt
import mir_eval.display
import librosa.display
%matplotlib inline
from mido import MidiFile
from midi2audio import FluidSynth
from google.colab import output, drive
from IPython.display import display, Javascript, HTML, Audio, Image
FluidSynth("/content/font.sf2", 16000).midi_to_audio('/content/output.mid', '/content/output.wav')
Audio('/content/output.wav', rate=16000)
@sniperwrb Great job! I tried your version and got some strange messages when trying to install it.
When using CMD, I didn't get any errors, per-se, but it failed to install and printed this in the CMD line:
[main 2020-12-10T19:11:28.135Z] update#setState idle
(node:19764) Electron: Loading non-context-aware native module in renderer:
...
So something about the Electron loading, and it always opened my IDE. For some reason. And also displayed this:
..../spdlog.node'. This is deprecated, see https://github.com/electron/electron/issues/18397.
[main 2020-12-10T19:11:58.137Z] update#setState checking for updates
[main 2020-12-10T19:11:58.189Z] update#setState idle
Something about VS Codes "spdlog.log".
When trying to use the Anaconda prompt, the IDE simply opens. No messages in the prompt.
Then, when I try to run the "setup.py" script from the IDE, I get this error:
Warning: could not find asoundlib.h, not including ALSA sequencer support!
UserWarning: Normalizing 'v0.2.3' to '0.2.3'
normalized_version,
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help
error: no commands supplied
I'm no expert in what you did with the "setup.py" so that's the reason I ask. Does any of this make sense to any of you? Hoping to use this package in the near future.
Best
@sniperwrb
Cloned your distro and it seemed to work fine. Ran the setup.py no apparent issues.
Not sure why I am still getting the syntax error when I try to run mididump.py
brian@brian-VirtualBox:~/python-midi$ mididump.py mary.mid
Traceback (most recent call last):
File "/usr/local/bin/mididump.py", line 4, in
@sniperwrb
Cloned your distro and it seemed to work fine. Ran the setup.py no apparent issues.
Not sure why I am still getting the syntax error when I try to run mididump.py
brian@brian-VirtualBox:~/python-midi$ mididump.py mary.mid Traceback (most recent call last): File "/usr/local/bin/mididump.py", line 4, in import('pkg_resources').run_script('midi==0.2.3', 'mididump.py') File "/home/brian/.local/lib/python3.8/site-packages/pkg_resources/init.py", line 651, in run_script self.require(requires)[0].run_script(script_name, ns) File "/home/brian/.local/lib/python3.8/site-packages/pkg_resources/init.py", line 1454, in run_script script_code = compile(script_text, script_filename, 'exec') File "/usr/local/lib/python3.8/dist-packages/midi-0.2.3-py3.8.egg/EGG-INFO/scripts/mididump.py", line 9 print "Usage: {0} ".format(sys.argv[0]) ^ SyntaxError: invalid syntax
The traceback you are showing has some python2 syntax in it.
print "Usage: {0} ".format(sys.argv[0])"
should be:
print("Usage: {0} ".format(sys.argv[0])")
Something like that
I'm getting a midi.sequencer not found error on macOS Big Sur, when running the ModuleNotFoundError: No module named 'midi.sequencer
python3 midiplay.py ../mary.mid
Traceback (most recent call last):
File "midiplay.py", line 8, in <module>
import midi.sequencer as sequencer
Was the fix made/tested for Windows only?
Ah, realised after setup.py install, it needs ALSA support!... Warning: could not find asoundlib.h, not including ALSA sequencer support!
I've been trying to get this module to work on Raspbian for hours today. This is the error I'm getting:
pi@raspberrypi:~/python-midi/scripts $ sudo python3 mididumphw.py
Traceback (most recent call last):
File "mididumphw.py", line 7, in
@RogerLevy I would recommend not to use python-midi as it is pretty much abandoned atm.
There are plenty of other great packages that can be easily substituted for python-midi, especially on Raspberry Pi due to compat issues.
Check out my tegridy-tools repo: https://github.com/asigalov61/tegridy-tools
I have collected all MIDI stuff there and there is also a separate section specifically for Raspberry Pi.
Hope this is helpful.
Please let me know what module I can use; everything else I've found doesn't include the feature I need which is time-accurate sequence playback with realtime adjustable tempo. I wrote a functioning sequencer in Python but multitrack playback and recording have unacceptable timing issues so I'm looking for a way to hook into ALSA. Recording timing is solved (maybe) by using python-rtmidi but I haven't done extensive testing yet.
@RogerLevy Yes, I was gonna recommend rtmidi so def. check it out.
There is also note-seq by Google, mido, pretty_midi, and a few others...But it seems that your case is more on the sequencer side and you probably need a custom solution, so if I were you, I would use one of the popular modules I mentioned above to build upon myself.
Or you can search GitHub for code/solutions that fit your needs. from my experience, GitHub has everything, you just need to look and also be wiling to do some work as its most likely going to be code snippets.
I am sorry I can't be of more help in your case. I thought you just need a capable MIDI processor, not a sequencer.
Hope this makes sense
Here is my repo: https://github.com/sniperwrb/python-midi
I just deleted the raised errors in setup.py configure_platform(), and then installed the original package on Linux python 3.6, and replaced the source files in Windows with the newly generated files in linux. Then I could "python setup.py install" and enjoy it.