Python midi out to FruityLoops Studio
im working on a project and i want to create a virtual midi 开发者_如何学编程input with python to flstudio (fruityloops) i have googled a bit but all the modules i could find was about creating midi files which is not my issue.
so what module should i use for midi i/o with python?
Ahmet, I recommend MIDI Yoke for this. Building a virtual MIDI device driver is no easy task, and it isn't something you'll be doing with Python.
http://www.midiox.com/myoke.htm
Edit 2011: Some things have changed in the last year. I recommend using Tobias Erichsen's driver, which allows you to create virtual ports and send data to them. If you can use a DLL, you can use his driver.
The info is here: http://www.tobias-erichsen.de/rtpMIDI.html
Contact him for the API.
I was just looking to accomplish your exact task and came across the python "mido library". From this page you see:
import mido
output = mido.open_output()
output.send(mido.Message('note_on', note=60, velocity=64))
I believe this assumes that a default device is set however, so you may need to run:
names = mido.get_output_names()
print(names)
To see what midi devices are available to output too. Once you know what your device name is you can do:
output = mido.open_output(names[indexOfYourDeviceHere])
output.send(mido.Message('note_on', note=60, velocity=64))
Now, how does this interface with FL Studio? I have installed LoopBe1 Virtual Midi Driver, and so when I run the above code the LoopBe Internal Midi device shows up. Similarly, in FL Studio I have enabled the LoopBe Internal MIDI device. Thus, when your python program writes to the device FL Studio reads it as midi input!
Alas, I did have some trouble setting up mido on my windows machine and so I thought I would give you a pointer. In order to read or write to midi devices you need to have a "mido backend" installed. On linux I simply followed the instructions on their installation page to install portmidi and it worked great.
However, for windows, I was having LOTS of trouble trying to work with portmidi or the other option. I finally decided to install pygame (3rd option) for windows and then set that as my backend using:
mido.set_backed("mido.backends.pygame")
Then everything worked fine on windows. You can find pygame for windows as well as the mido installation page easily by googling. Hope this was helpful.
精彩评论