[alsa-devel] scheduling midi events with pyalsa and making queue to loop after few bars..
ki.ber.kom.uni.st
ki.ber at kom.uni.st
Thu Sep 18 03:44:42 CEST 2008
hm.. i would like to make simple example of scheduling few midi notes
to queue and alsaseq where the length of the loop will be one bar or
any number of ticks...
i'm kind of stuck :(
i got two midi notes triggered (event & event2) but don't know how to
play the queue again or in loop while notes which are already there
should be played in every repetition...
i'm trying to do that placing alsaseq.SEQ_EVENT_SETPOS_TICK at 0 (or
1) but it doesn't play the notes again...
my logic is to schedule the playhead of queue at the beginning after
some number of ticks and i assume that already queued notes will be
there.. i'm quite sure i'm wrong ;)
what would be good logic to do that?
do i need to leave queue alone and implement my own logic on top of
it? something like adding notes all along the timeline simulating the
repetition that way... i would like to know or to check what's the
tick of running queue.. do i do that scheduling alsaseq.SEQ_EVENT_ECHO
some place on the timeline? hm... lot's of questions... hope someone
would explain to me a bit of the alsaseq inner logic... i'm sorry i
couldn't find good documentation but testing the library inside
ipython....
here is how my session looks like (i connect "myPort" to Virtual Raw
Midi with a little help of qjackctl and monitor it with amidi -p
hw:2,0 -d):
from pyalsa import alsaseq
seqsen = alsaseq.Sequencer()
seqsen.create_simple_port("myPort", alsaseq.SEQ_PORT_TYPE_APPLICATION,
alsaseq.SEQ_PORT_CAP_SUBS_READ | alsaseq.SEQ_PORT_CAP_READ)
queue = seqsen.create_queue()
seqsen.start_queue(queue)
queue = seqsen.create_queue()
seqsen.start_queue(queue)
tempo, ppq = seqsen.queue_tempo(queue)
event = alsaseq.SeqEvent(alsaseq.SEQ_EVENT_PGMCHANGE)
event.queue = queue
event.time = 96
event.set_data({'control.value' : 127})
seqsen.output_event(event)
event2 = alsaseq.SeqEvent(alsaseq.SEQ_EVENT_PGMCHANGE)
event2.queue = queue
event2.time = 96*4
event2.set_data({'control.value' : 100})
seqsen.output_event(event2)
event3 = alsaseq.SeqEvent(alsaseq.SEQ_EVENT_SETPOS_TICK)
event3.queue = queue
event3.time = 96*5
event3.set_data({'queue.queue' : 1})
seqsen.output_event(event3)
seqsen.drain_output()
## event and event2 being sent but event3 is unnoticeable to me...
More information about the Alsa-devel
mailing list