[alsa-devel] python midi wrapper

Aldrin Martoq amartoq at dcc.uchile.cl
Fri Jan 4 19:01:39 CET 2008

Hello, I need a midi/seq wrapper for Python. I've already created some
code for the sequencer API and works great! Here is my python test

#!/usr/bin/env python

import sys
import alsaaudio

print "Creating Sequencer..."
seq = alsaaudio.Seq("hw", "Python seqtest.py",
alsaaudio.SEQ_OPEN_DUPLEX, alsaaudio.SEQ_NONBLOCK)
myid = seq.get_client_id()
print "... seq:", myid, seq
print "Creating Port..."
myport = seq.create_simple_port("Processor port",
print "... port:", myport
#queue = seq.create_queue()
#print "... queue:", queue

# dump clients and ports
def dump_connection():
	print "Client/ports available:"
	for client in seq.get_client_ports():
		clientname, clientid, portlist = client
		print " client: %3d    %s" % (clientid, clientname)
		for port in portlist:
			portname, portid, connections = port
			print "   port: %3d:%-2d   +-%s" % (clientid, portid, portname)
			readconn, writeconn = connections
			for conn in readconn:
				print "     connection   to: %s" % conn
			for conn in writeconn:
				print "     connection from: %s" % conn

dump_connection() Is the front
seq.connect_ports("0:1", "%d:%d" % (myid, myport));
seq.connect_ports("24:0", "%d:%d" % (myid, myport));

while True:
	events = seq.receive_events(60000)
	for ev in events:
		print ev
		print "\t", ev.data()


I have tried to contact the mantainer of PyAlsaAudio (cwi at unispeed.dk
from the README file) for merging my code in his project, but have not
received a response so far and the date of files seems old.

Is anybody here interested in the merge? How can I put this effor in
python-alsaaudio or may I create a new project for this specific task?
Is the pyalsa project related to pyalsaaudio?


Aldrin Martoq

More information about the Alsa-devel mailing list