* problems howto send simple 'noteon' event with pyalsa...
@ 2008-03-13 11:58 ki.ber.kom.uni.st
2008-03-13 12:34 ` Jaroslav Kysela
0 siblings, 1 reply; 4+ messages in thread
From: ki.ber.kom.uni.st @ 2008-03-13 11:58 UTC (permalink / raw)
To: alsa-devel
e,
i was happy user of PySeq [1] and it was easy to send directly
'noteon' event.. more or less in python interactoin session:
import pyseq
seq = pyseq.PySeq()
seq.createOutPort()
event = snd_seq_event()
event.setSource(0)
event.setSubscribers()
event.setNoteOn(ch, note, velocity)
event.sendAsIs(seq)
it seems that pyalsa will go along alsa development so i tried pyalsa.. but....
i tried this:
from pyalsa import alsaseq
seq = alsaseq.Sequencer()
seq.create_simple_port("myPort", alsaseq.SEQ_PORT_TYPE_APPLICATION,
alsaseq.SEQ_PORT_CAP_SUBS_READ | alsaseq.SEQ_PORT_CAP_READ |
alsaseq.SEQ_PORT_CAP_WRITE | alsaseq.SEQ_PORT_CAP_SUBS_WRITE)
event = alsaseq.SeqEvent(alsaseq.SEQ_EVENT_NOTE)
event.set_data({'note.note' : 0x40, 'note.velocity' : 127,
'note.duration' : 1, 'note.off_velocity' : 0})
event.dest = (20, 0)
seq.output_event(event)
seq.drain_output()
after drain it says:
"SequencerError: Failed to drain output: Invalid argument"
i can connect and disconnect ports around and (20,0) is functional
port where i send events with no problems from PySeq...
any ideas? do i have to use queues to be able to send 'noteon'.. for
my purposes it seems to me that that's overkill....
thanx..
[1] http://www.sci.ccny.cuny.edu/~brinkman/software/pyseq/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: problems howto send simple 'noteon' event with pyalsa...
2008-03-13 11:58 problems howto send simple 'noteon' event with pyalsa ki.ber.kom.uni.st
@ 2008-03-13 12:34 ` Jaroslav Kysela
2008-03-13 18:07 ` Aldrin Martoq
0 siblings, 1 reply; 4+ messages in thread
From: Jaroslav Kysela @ 2008-03-13 12:34 UTC (permalink / raw)
To: ki.ber.kom.uni.st; +Cc: ALSA development
On Thu, 13 Mar 2008, ki.ber.kom.uni.st wrote:
> e,
> i was happy user of PySeq [1] and it was easy to send directly
> 'noteon' event.. more or less in python interactoin session:
> import pyseq
>
> seq = pyseq.PySeq()
> seq.createOutPort()
> event = snd_seq_event()
> event.setSource(0)
> event.setSubscribers()
> event.setNoteOn(ch, note, velocity)
> event.sendAsIs(seq)
>
> it seems that pyalsa will go along alsa development so i tried pyalsa.. but....
>
> i tried this:
>
> from pyalsa import alsaseq
>
> seq = alsaseq.Sequencer()
> seq.create_simple_port("myPort", alsaseq.SEQ_PORT_TYPE_APPLICATION,
> alsaseq.SEQ_PORT_CAP_SUBS_READ | alsaseq.SEQ_PORT_CAP_READ |
> alsaseq.SEQ_PORT_CAP_WRITE | alsaseq.SEQ_PORT_CAP_SUBS_WRITE)
>
> event = alsaseq.SeqEvent(alsaseq.SEQ_EVENT_NOTE)
> event.set_data({'note.note' : 0x40, 'note.velocity' : 127,
> 'note.duration' : 1, 'note.off_velocity' : 0})
> event.dest = (20, 0)
> seq.output_event(event)
> seq.drain_output()
>
> after drain it says:
> "SequencerError: Failed to drain output: Invalid argument"
> i can connect and disconnect ports around and (20,0) is functional
> port where i send events with no problems from PySeq...
>
> any ideas? do i have to use queues to be able to send 'noteon'.. for
> my purposes it seems to me that that's overkill....
I think that you need to create also queue. Look to pyalsa source code to
test/seqtest3.py .
Jaroslav
-----
Jaroslav Kysela <perex@perex.cz>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: problems howto send simple 'noteon' event with pyalsa...
2008-03-13 12:34 ` Jaroslav Kysela
@ 2008-03-13 18:07 ` Aldrin Martoq
2008-03-13 23:24 ` ki.ber.kom.uni.st
0 siblings, 1 reply; 4+ messages in thread
From: Aldrin Martoq @ 2008-03-13 18:07 UTC (permalink / raw)
To: Jaroslav Kysela; +Cc: ALSA development, ki.ber.kom.uni.st
Hello,
On Thu, Mar 13, 2008 at 9:34 AM, Jaroslav Kysela <perex@perex.cz> wrote:
> On Thu, 13 Mar 2008, ki.ber.kom.uni.st wrote:
> > i was happy user of PySeq [1] and it was easy to send directly
> > 'noteon' event.. more or less in python interactoin session:
> > import pyseq
> >
> > seq = pyseq.PySeq()
> > seq.createOutPort()
> > event = snd_seq_event()
> > event.setSource(0)
> > event.setSubscribers()
> > event.setNoteOn(ch, note, velocity)
> > event.sendAsIs(seq)
> >
> > it seems that pyalsa will go along alsa development so i tried pyalsa.. but....
You can send NOTEON events without a queue, but you cannot send NOTE
events without a queue. (subtle difference: note_ON_)
The following code will work; 14:0 is "midi-through" in my system... I
run aseqdump -p 14:0 on another window:
seq = alsaseq.Sequencer()
event = alsaseq.SeqEvent(alsaseq.SEQ_EVENT_NOTEON)
event.set_data({'note.note' : 0x40, 'note.velocity' : 64})
event.dest = (14, 0)
seq.output_event(event)
seq.drain_output()
> > i tried this:
> > from pyalsa import alsaseq
> > seq = alsaseq.Sequencer()
> > seq.create_simple_port("myPort", alsaseq.SEQ_PORT_TYPE_APPLICATION,
> > alsaseq.SEQ_PORT_CAP_SUBS_READ | alsaseq.SEQ_PORT_CAP_READ |
> > alsaseq.SEQ_PORT_CAP_WRITE | alsaseq.SEQ_PORT_CAP_SUBS_WRITE)
AFAIK, You don't need a port if you are sending events directly.
Now, if you subscribe and connect ports, you don't need to assign them
into the event, because a new event is created with
snd_seq_ev_set_subs called..
You can check this and other stuff with the following code:
-ini-------------
def _find_attributes(typelist):
l = []
for t in typelist:
d = t.__dict__.items()
for k, v in d:
v = "%s" % v
if v.startswith("<attribute"):
l.append(k)
l.sort()
return l
def dump_event(port, name = 'seqevent'):
print "Dumping Event ---------->"
print "%s" % port
l = _find_attributes([alsaseq.SeqEvent])
for k in l:
print "%-30.30s %s" % (name + "." + k, port.__getattribute__(k))
return
seq = alsaseq.Sequencer()
event = alsaseq.SeqEvent(alsaseq.SEQ_EVENT_NOTEON)
event.set_data({'note.note' : 0x40, 'note.velocity' : 64})
dump_event(event)
seq.output_event(event)
seq.drain_output()
-------------end--
> > event = alsaseq.SeqEvent(alsaseq.SEQ_EVENT_NOTE)
> > event.set_data({'note.note' : 0x40, 'note.velocity' : 127,
> > 'note.duration' : 1, 'note.off_velocity' : 0})
note.duration and note.off_velocity make sense only for
SEQ_EVENT_NOTE, but you need a queue... so, use SEQ_EVENT_NOTEON and
SEQ_EVENT_NOTEOFF instead....
I'm planning to move event.set_data() to attributes, like
event.note_note, event.note_velocity ... Tell me what you think!
> > event.dest = (20, 0)
> > seq.output_event(event)
> > seq.drain_output()
> >
> > after drain it says:
> > "SequencerError: Failed to drain output: Invalid argument"
Well, that's what asoundlib says... weird, don't you think?
Alsa hackers: This is a good proof that alsa-lib message errors
really, really sucks... Is there any chance to change this? I mean, if
I volunteer to improve this could be accepted? Any hints for doing
this?
[...]
> > any ideas? do i have to use queues to be able to send 'noteon'.. for
> > my purposes it seems to me that that's overkill....
Remember: python is far away of real-time so if you get weirds timings
you may reconsider using a queue anyway!
HTH,
--
Aldrin Martoq
http://aldrinvideopodcast.podshow.com/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: problems howto send simple 'noteon' event with pyalsa...
2008-03-13 18:07 ` Aldrin Martoq
@ 2008-03-13 23:24 ` ki.ber.kom.uni.st
0 siblings, 0 replies; 4+ messages in thread
From: ki.ber.kom.uni.st @ 2008-03-13 23:24 UTC (permalink / raw)
To: ALSA development
i'm happy that gnu world exists ;) aldrin thanx to remind me on that
once again...
On 3/13/08, Aldrin Martoq <amartoq@dcc.uchile.cl> wrote:
> You can send NOTEON events without a queue, but you cannot send NOTE
> events without a queue. (subtle difference: note_ON_)
clear enough...
> The following code will work;
worked as charm... many thanx...
> AFAIK, You don't need a port if you are sending events directly.
you are right.. i can send events directly... in my particular case i
like to have ports so i can connect them with other midi ports through
qjackctl or some other graphical app...
> Now, if you subscribe and connect ports, you don't need to assign them
> into the event, because a new event is created with
> snd_seq_ev_set_subs called..
i don't get this one.. what i tried till know is to create in/out
ports (it works...) and then connect them with some existing ones
using seq.connect_ports.. then if i use seq.output_event(event)
drain_output() works fine... i don't get what 'ports assigning into
the event' would be?
> You can check this and other stuff with the following code:
once more many thanx.. this was very helpful for me.. i'll keep using
pyalsa and i start to call myself happy user of pyalsa from now on ;)
> I'm planning to move event.set_data() to attributes, like
> event.note_note, event.note_velocity ... Tell me what you think!
that seems to me more clear and more consistent with event.dest and
probably some other stuff... also it looks more pythonic i would
say... even set_data() is easy to use too..
i use a lot ipython interactive shell so attributes are shown as
result of auto completion + if you would put """documentation
strings""" it will also come out with basic documentation of what is
it for and how to use it...
> Well, that's what asoundlib says... weird, don't you think?
i was pissed but as usually being the lamest in programming i had no
one but myself to blame ;)
> Remember: python is far away of real-time so if you get weirds timings
> you may reconsider using a queue anyway!
my pyalsa piece of code is part of handling gamepad events in pyqt4
loop so i thought to send events as soon as i get them from
/dev/input/js0 should be handled without any queue and trying to send
them directly.. am i right in this particular set up?
i'll try to get into queues in the later phase of my development...
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-03-13 23:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-13 11:58 problems howto send simple 'noteon' event with pyalsa ki.ber.kom.uni.st
2008-03-13 12:34 ` Jaroslav Kysela
2008-03-13 18:07 ` Aldrin Martoq
2008-03-13 23:24 ` ki.ber.kom.uni.st
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox