Skip to contentSkip to conversation

direct midi event dispatching

DISCUSSION Gilles Dégottex 2 participants 7 messages May 24, 2004

lore
Share & tools
lore
#0 lore raw

Hi all,

I'm trying to dispatch midi event directly without queue. I did every thing I read in the alsa doc (for
me: /usr/share/doc/libalsa2-docs-1.0.2/seq.html)

but when I flush the output, I got an error: "Invalid argument" (when calling snd_seq_drain_output)

Meet the same problem ? Got a solution ? Any idea ?

Thanks,
Gilles

-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click

#1 lore raw
Quoted 6 lines · Gilles Dégottex

I'm trying to dispatch midi event directly without queue. I did every thing I read in the alsa doc (for
me: /usr/share/doc/libalsa2-docs-1.0.2/seq.html)

but when I flush the output, I got an error: "Invalid argument" (when calling snd_seq_drain_output)

This may indicate that some of the event's fields have invalid values.

What does your code to initialize the event structure look like?

Regards,
Clemens

-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id149&alloc_id�66&op=click

#2 lore raw
Quoted 11 lines · you
Quoted 6 lines · Gilles Dégottex

I'm trying to dispatch midi event directly without queue. I did every thing I read in the alsa doc (for
me: /usr/share/doc/libalsa2-docs-1.0.2/seq.html)

but when I flush the output, I got an error: "Invalid argument" (when calling snd_seq_drain_output)

This may indicate that some of the event's fields have invalid values.

What does your code to initialize the event structure look like?

Here is my code:

    snd_seq_event_t ev;
    snd_seq_ev_clear(&ev);
    snd_seq_ev_set_source(&ev, g_port);
    snd_seq_ev_set_subs(&ev);
    snd_seq_ev_set_direct(&ev);
    ev.type = SND_SEQ_EVENT_NOTE;
    ev.flags = SND_SEQ_EVENT_LENGTH_FIXED|SND_SEQ_PRIORITY_NORMAL;
    ev.tag = 'a';
    ev.data.note.channel = 1;
    ev.data.note.note = n;
    ev.data.note.velocity = 64;
    ev.data.note.off_velocity = 64;
    ev.data.note.duration = 1000;

P.S. Thanks for your fast answer ! :)

-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id149&alloc_id�66&op=click

#3 lore raw
Quoted 5 lines · Gilles Dégottex
Quoted 1 line
Quoted 1 line

but when I flush the output, I got an error: "Invalid argument"

    snd_seq_ev_set_direct(&ev);
    ev.type = SND_SEQ_EVENT_NOTE;
    ev.data.note.duration = 1000;

NOTE events must be sent through a queue because they need a timer so that the NOTE_OFF event can be scheduled at the appropriate time.

When not using a queue, you have to send the NOTE_ON and NOTE_OFF events seperately.

Quoted 1 line
    snd_seq_ev_set_subs(&ev);

I hope some other port is subscribed to this one. :-)

HTH
Clemens

-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id149&alloc_id�66&op=click

#4 lore raw
Quoted 7 lines · Clemens Ladisch
Quoted 5 lines · Gilles Dégottex
Quoted 1 line
Quoted 1 line

but when I flush the output, I got an error: "Invalid argument"

    snd_seq_ev_set_direct(&ev);
    ev.type = SND_SEQ_EVENT_NOTE;
    ev.data.note.duration = 1000;
Quoted 5 lines

NOTE events must be sent through a queue because they need a timer so that the NOTE_OFF event can be scheduled at the appropriate time.

When not using a queue, you have to send the NOTE_ON and NOTE_OFF events seperately.

Thanks ! that's works ! I dont know where you find this in the documentation, if it's exist :P

Remark:

Why SND_SEQ_EVENT_NOTE event doesnt accept direct dispatching ? technicaly, there is surely a reason, but conceptualy, I dont see. Why do a
difference ?

Best Regards,
Gilles

-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id149&alloc_id�66&op=click

#5 lore raw
Quoted 3 lines · Gilles Dégottex

Why SND_SEQ_EVENT_NOTE event doesnt accept direct dispatching ? technicaly, there is surely a reason, but conceptualy, I dont see. Why do a difference ?

SND_SEQ_EVENT_NOTE isn't a 'real' event but gets split into two events, SND_SEQ_EVENT_NOTE_ON and _OFF, and the latter must be sent at a later time. Scheduling events to be sent later requires a timer which isn't avilable without a queue.

The SND_SEQ_EVENT_NOTE event is the only event that uses the event.data.note.duration field, but you cannot know what the value in this field means without having a timer which specifies how long one timer tick lasts.

HTH
Clemens

-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id149&alloc_id�66&op=click

#6 lore raw
Quoted 9 lines · Clemens Ladisch
Quoted 3 lines · Gilles Dégottex

Why SND_SEQ_EVENT_NOTE event doesnt accept direct dispatching ? technicaly, there is surely a reason, but conceptualy, I dont see. Why do a difference ?

SND_SEQ_EVENT_NOTE isn't a 'real' event but gets split into two events, SND_SEQ_EVENT_NOTE_ON and _OFF, and the latter must be sent at a later time. Scheduling events to be sent later requires a timer which isn't avilable without a queue.

it's a real library programmer problem, yes, but i'm not sure it should be the problem of a library user. Why dont use an internal and hidden queue ?

Quoted 4 lines

The SND_SEQ_EVENT_NOTE event is the only event that uses the event.data.note.duration field, but you cannot know what the value in this field means without having a timer which specifies how long one timer tick lasts.

Ok, without units it's a problem for everybody :) and what you think of a default units ? or accessors of the internal queue ?

if you dont like the hidden queue idea, maybe a macro wich auto-fill the event structure with courrent queuing time could be very usefull !

Regards,
Gilles

-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id149&alloc_id�66&op=click