From alsa-devel-owner@alsa.jcu.cz  Wed Feb 10 23:45:08 1999
Received: from havoc.gtf.org (IDENT:data@panic.ohr.gatech.edu [130.207.47.194])
	by marvin.jcu.cz (8.9.1a/8.9.1) with ESMTP id XAA11787
	for <alsa-devel@alsa.jcu.cz>; Wed, 10 Feb 1999 23:44:53 +0100
Received: (from data@localhost)
	by havoc.gtf.org (8.8.7/8.8.7) id RAA19320
	for alsa-devel@alsa.jcu.cz; Wed, 10 Feb 1999 17:44:51 -0500
From: Data <data@havoc.gtf.org>
Message-Id: <199902102244.RAA19320@havoc.gtf.org>
Subject: A Proposal [was: Re: MIDI/PCM synchro]
To: perex@jcu.cz (Jaroslav Kysela)
Date: Wed, 10 Feb 1999 06:29:57 -0500 (EST)
In-Reply-To: <Pine.LNX.3.96.990210120427.3166J-100000@entry.jcu.cz> from "Jaroslav Kysela" at Feb 10, 99 12:08:09 pm
Content-Type: text
Reply-To: alsa-devel@alsa.jcu.cz
Sender: alsa-devel-owner@alsa.jcu.cz
Precedence: list

> 
> I think this feature will be very useful for all applications where should
> be synchronized audio stream with MIDI stream.
> 
> 							Jaroslav

.. and I've just come up with an idea for how to do it.

The process would operate as follows:

1. A capability would be added to the upper-level PCM drivers.  The user 
   could request that the driver send a timing message to the sequencer 
   once every n samples.  For example, to send 30 fps quarter-frames with 
   a 44.1 KHz sampling rate, the driver would send a message of some sort 
   to the sequencer every 367.5 samples.  For accuracy the user 
   could request fractional intervals, and the driver would interpolate 
   accordingly.

2. The user would then tell the sequencer that it was being externally 
   clocked, and the sync source would be the PCM driver.

3. When playback commences, the user first tells the sequencer to use a 
   certain SMPTE offset, then to start playing.  The sequencer would 
   reset its internal data to reflect the requested time, and begin 
   waiting for timing messages from the PCM driver.

4. The user then begins shovelling off bytes to the PCM driver.  When this 
   happens the driver begins sending timing messages since it is now 
   playing samples.

5. The sequencer would then begin sending timing messages to its clients.  
   For a hard disk recorder one of these would generate MTC messages and 
   route them to a MIDI output.

6. When playback stops, the user ceases to feed the PCM driver with data, 
   and then issues a 'stop' command to the sequencer, which leaves off 
   waiting for timing messages.

Latency here would be minimal, but in the case of MTC, timing errors can be 
corrected anyway, by applying small offsets to the SMPTE offset passed to the 
sequencer.

Any reactions?

cheerio
Michael Ashton



