mido

Mido - How to get midi data in realtime from different ports

空扰寡人 提交于 2020-06-01 04:43:46
问题 I have created 2 ports as input, to capture data from a keyboard and a midi surface controller (which has a bunch of sliders and knobs). Although I am not sure how to get data from both for msg1 in input_hw: if not msg1.type == "clock": print(msg1) # Play the note if the note has been triggered if msg1.type == 'note_on' or msg1.type == 'note_off' and msg1.velocity > 0: out.send(msg1) for msg in input_hw2: #avoid to print the clock message if not msg.type == "clock": print(msg) The first For

Mido - How to get midi data in realtime from different ports

≯℡__Kan透↙ 提交于 2020-06-01 04:43:39
问题 I have created 2 ports as input, to capture data from a keyboard and a midi surface controller (which has a bunch of sliders and knobs). Although I am not sure how to get data from both for msg1 in input_hw: if not msg1.type == "clock": print(msg1) # Play the note if the note has been triggered if msg1.type == 'note_on' or msg1.type == 'note_off' and msg1.velocity > 0: out.send(msg1) for msg in input_hw2: #avoid to print the clock message if not msg.type == "clock": print(msg) The first For

adding MIDI chords at specific MetaMessage time

*爱你&永不变心* 提交于 2020-04-30 08:45:11
问题 I have a MIDI file with marker as meta-messages. fname = "avm.mid" mid = MidiFile(fname) # input file of type 0 metas = [m for m in mid.tracks[0] if m.is_meta] I have stored the meta marker times in the list "chordTimes". The first maker ( chord position) does not start at 0. I make a new MIDI file: mo = MidiFile(type =1)# output file track = MidiTrack() Now I read through my list of desired chords and and add them to a new track to be added to mo. for i in range(0, len(chords)-1): chordInfo

How can I integrate Python mido and asyncio?

我只是一个虾纸丫 提交于 2019-12-08 08:03:26
问题 I have a device which does file I/O over MIDI. I have a script using Mido that downloads files but it is a mess of global variables. I want to tidy it up to use asyncio properly but I am not sure how to integrate the mido callback. I think the documentation says I should use a Future object but I am not sure how the mido callback function can obtain that object. 回答1: mido provides a callback-based API which will invoke the callback from a different thread. Your implementation of the callback

How can I integrate Python mido and asyncio?

孤街浪徒 提交于 2019-12-06 20:27:39
I have a device which does file I/O over MIDI. I have a script using Mido that downloads files but it is a mess of global variables. I want to tidy it up to use asyncio properly but I am not sure how to integrate the mido callback. I think the documentation says I should use a Future object but I am not sure how the mido callback function can obtain that object. mido provides a callback-based API which will invoke the callback from a different thread. Your implementation of the callback can communicate with asyncio by calling loop.call_soon_threadsafe . Note that you won't be able to just set