On Tue, 2005-07-26 at 19:09 +0200, Christoph Eckert wrote:
Ah! Well then
perhaps the shortest route would be to just
use amidi combined with one the exec() variants?
I'll study the code of amidi.
But if you do make the effort and boil it down to
a few
lines of clean alsa code, please post it back here. The
example you are writing is short, concise and perfect for a
mini tutorial.
If I get this far, I'll do so.
OK!
What I found so far for a minimum raw_sysex example is:
snd_rawmidi_t *handle_out = 0;
char* device = "hw:0,0"; // This may or may not be the device ...
int err = snd_rawmidi_open(/*in*/NULL,/*out*/&handle_out,
device,0);
if (err)
exit(EXIT_FAILURE);
// some midi data
unsigned char gm_reset[] =
{ 0xf0, 0x7e, 0x7f, 0x09, 0x01, 0xf7 };
snd_rawmidi_write(handle_out,gm_reset,sizeof(gm_reset));
// snd_rawmidi_drain(handle_out);
snd_rawmidi_close(handle_out);
I haven't found an easy shortcut to get a list of possible devices
(except for what is in amidi)
The code above will wait forever if the device is already taken.
Opening the device with SND_RAWMIDI_NONBLOCK as last argument will get
you past that point, but then the write operation may fail (returning
negative) or return less bytes than you asked for to be written. This is
where one should "drain" the device and resend the missing bytes, as I
understand it.
mvh // Jens M Andreasen