Skip to content

Instantly share code, notes, and snippets.

@vi
Created April 10, 2014 15:43
Show Gist options
  • Select an option

  • Save vi/10395508 to your computer and use it in GitHub Desktop.

Select an option

Save vi/10395508 to your computer and use it in GitHub Desktop.
Dump MIDI events using python-midi
# supply two command line arguments
import midi.sequencer.sequencer_alsa as S
import midi.sequencer
import sys
import select
sr = midi.sequencer.SequencerRead()
sr.subscribe_port(sys.argv[1],sys.argv[2])
p = select.poll()
sr.configure_poll(p)
while True:
#S.client_poll_descriptors(sr.client)
p.poll()
e = S.event_input(sr.client)
if not e:
sys.stdout.write(".")
continue
print "flgs={} tag={} tick={} time={} type={} note={} dur={} offvel={} vel={} chan={} pos={} skewbase={} skewval={} queue={} qpartime={}".format(
e.flags, e.tag, e.time.tick, e.time.time.tv_sec + 1e-9 * e.time.time.tv_nsec,
e.type, e.data.note.note, e.data.note.duration, e.data.note.off_velocity, e.data.note.velocity,
e.data.note.channel, e.data.queue.param.position, e.data.queue.param.skew.base, e.data.queue.param.skew.value,
e.data.queue.queue, e.data.queue.param.time.time.tv_sec + 1e-9 * e.data.queue.param.time.time.tv_nsec )
@zoobab
Copy link

zoobab commented Jan 7, 2016

What are those 2 arguments? Can you provide an example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment