I'm writting an app that plays a special format and uses both the Alsa seq and pcm interfaces to output MIDI and audio data together. I'm almost done, but I've got one problem that is plaugeing me: I can't get the two to stay in sync.

Basically, what I'm doing is using writei() to send frames to the audio and for midi:
void SendTimeEvent( snd_seq_event_t *event, snd_seq_real_time_t *iRealTime)
{
snd_seq_ev_set_source( event, mPort );
snd_seq_ev_set_subs(event);
snd_seq_ev_schedule_real(event, mQueue, 0, iRealTime );
snd_seq_event_output(hSeq, event);
snd_seq_drain_output(hSeq);
}


I call this with iRealTime calculated based on the number of frames I've sent to the audio. I recieve the MIDI data and the audio samples in sync from a different portion of the program, and the time that the MIDI should be played at is the time that sample gets played plus a constant offset.

Both the MIDI and audio play just fine (the piano plays and so does the digital audio).

The problem: the MIDI and audio start synced up, but after a while they start to drift further and further apart. I've checked my stuff exaustively to make sure that it's not the fault of my program, so I'm figuring it is caused by me not setting up something properly in alsa to make the two streams synced up.

Any ideas of where to look?

Thanks in advance,
- Steve



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Alsa-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/alsa-devel

Reply via email to