Denis wrote:
> I wrote a c code to send MIDI message "NOTE ON" to sequencer, but I get
> "Segmentation fault".
> What's wrong with it?

Some fields of ev contain random data, so you better clear it before using
it:
      snd_seq_ev_clear(&ev);

>     ev.type = SND_SEQ_EVENT_NOTEON;
>     ev.data.note.channel = 0x00;
>     ev.data.note.note = 0x30;
>     ev.data.note.velocity = 0x7f;

>     ev.data.note.duration = 0x7f;

.duration isn't needed for a _NOTEON event (only for _NOTE event, and then
you would need a running queue).

And some other fields need to be set (see seqmid.h for the definitions of
these macros):

     snd_seq_ev_set_source(&ev, portid); // source port
     snd_seq_ev_set_subs(&ev);           // send to all subscribers
     snd_seq_ev_set_direct(&ev);         // send directly, not through a queue

>    snd_seq_event_output_direct(ctxp,&ev);

Now it should be working.


HTH
Clemens




-------------------------------------------------------
This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger 
for complex code. Debugging C/C++ programs can leave you feeling lost and 
disoriented. TotalView can help you find your way. Available on major UNIX 
and Linux platforms. Try it free. www.etnus.com
_______________________________________________
Alsa-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/alsa-user

Reply via email to