From: Paul Davis Subject: Re: Sync between MIDI and audio Date: Thu, 28 Aug 2003 21:27:32 -0400 Sender: alsa-devel-admin@lists.sourceforge.net Message-ID: <200308290127.h7T1RWfg019789@oud> References: <3F4EA2E4.2010902@pianodisc.com> Return-path: In-reply-to: Your message of "Thu, 28 Aug 2003 17:48:36 PDT." <3F4EA2E4.2010902@pianodisc.com> Errors-To: alsa-devel-admin@lists.sourceforge.net List-Help: List-Post: List-Subscribe: , List-Unsubscribe: , List-Archive: To: derosier@pianodisc.com Cc: alsa-devel@lists.sourceforge.net List-Id: alsa-devel@alsa-project.org >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. you either have to force the sequencer queue to use the PCM device as a clock, or you have to use the RTC as the clock for both (which will cause audio glitches every so often since it drifts w.r.t. the audio clock). you can't expect this to "just work" - you've created a system with two clocks (the sequencer queue and the PCM device), and such systems will never stay in sync. this is a very tricky area of linux audio/MIDI programming, and my personal advice would be to use kernel 2.5/2.6 or the backport of the hi-res timers code. you can then get usec-accurate scheduling of events (in SCHED_FIFO tasks, anyway) and forget the ALSA queue. hopefully, the ALSA sequencer will at some point take advantage of the new timers. even so, its still not a simple thing to do. --p ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf