[linux-audio-user] sending program change to alsa

Peter Brinkmann brinkman at math.TU-Berlin.DE
Sat Jun 18 07:41:02 EDT 2005



Atte,
> If not, could anyone point me in the right direction of some 
> documentation on how to write such a program, esp how to register as an 
> alsa-client and exactly what should be send out how for it to be program 
> change. I'd like to write in python, if possible...
I've created Python bindings for a good chunk of the ALSA sequencer.
You can find the code at
    http://www.math.tu-berlin.de/~brinkman/software/midikinesis/
The module pyseq.py contains the sequencer bindings, and applications
like midikinesis.py, midigen.py, and playtune.py should give you an
idea as to how to work with pyseq.py.

As for your specific question of how to send pgm change messages,
here's how I would do this with pyseq.py.

First version: Send event right away, without scheduling via queues.
---------------------------------------------------------------------
from pyseq import *

s=PySeq()
p=s.createOutPort()
raw_input("hook up ports, press return")

e=snd_seq_event()
e.setPgmChange(0, 8)    # channel, value
s.sendEvent(e, p)       # send event directly
---------------------------------------------------------------------

Second version: Schedule event for a specific time, via queues:
---------------------------------------------------------------------
from pyseq import *
import time

s=PySeq()
p=s.createOutPort()
raw_input("hook up ports, press return")

q=Queue(s)
q.setTempo(120, 192)    # 100 beats per minute, 192 ticks per beat
q.start()

e=snd_seq_event()
e.setPgmChange(0, 8)    # channel, value
q.postEvent(e, p, 1920) # send via queue after 1920 ticks, i.e., 5 secs

time.sleep(5.5)         # wait for event to occur
---------------------------------------------------------------------

Please let me know if you have any questions.
Best,
    Peter





More information about the Linux-audio-user mailing list