From alsa-devel-owner@alsa.jcu.cz  Fri Feb 12 11:28:30 1999
Received: from entry.jcu.cz (IDENT:perex@entry.jcu.cz [160.217.1.111])
	by marvin.jcu.cz (8.9.1a/8.9.1) with SMTP id LAA15858
	for <alsa-devel@alsa.jcu.cz>; Fri, 12 Feb 1999 11:27:58 +0100
Date: Fri, 12 Feb 1999 11:27:58 +0100 (CET)
From: Jaroslav Kysela <perex@jcu.cz>
To: alsa <alsa-devel@alsa.jcu.cz>
Subject: Re: More PCM/RT stuff (replies mostly)
In-Reply-To: <199902120251.VAA27164@havoc.gtf.org>
Message-ID: <Pine.LNX.3.96.990212103702.4644H-100000@entry.jcu.cz>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Reply-To: alsa-devel@alsa.jcu.cz
Sender: alsa-devel-owner@alsa.jcu.cz
Precedence: list

On Thu, 11 Feb 1999, Data wrote:

>   My main concern, however, is that we in fact often require interrupts at 
> _half_-sample intervals.  For example, with a sampling rate of 44.1 KHz and a 
> frame rate of 30 fps, interrupts must occur every 367.5 samples. Obviously 
> if we round off, using for example a 368-byte blocksize, we will quickly find
> ourselves out of sync with the playback signal.  The obvious solution to
> me would be to employ a variable blocksize, using for example alternating
> 367 and 368-sample blocks, or at least to have alternating _series_
> of these.  I do not know, without further study of the code, whether
> this would be practical.  Mr.  Kysela, have you any thoughts on this?

You mentioned all possible implementations for this feature.

1) Use accurate PCM fragment size for sequencer timming.
2) Use small fragment size which will generate accepting error.
   If you set for example fragment size to 128 bytes, you get
   error +- 363us by the 44.1kHz, stereo, 16-bit format.
3) Use some good sequencer timer which works with enough frequency.
   (But note: most of todays soundcards doesn't have own timer, thus
    we can only use 100Hz system timer on i386 platform :-(().

If we look to this table (point one):

rate			| fps		| samples per fps
------------------------+---------------+-------------------
44100Hz			| 25		| 1764
44100Hz			| 30		| 1470
44100Hz			| 50		| 882
44100Hz			| 60		| 735
48000Hz			| 25		| 1920
48000Hz			| 30		| 1600
48000Hz			| 50		| 960
48000Hz			| 60		| 800

As you can see, I think that these numbers show us, that first
implementation is best (no error).

The timer setup should be implemented over an ioctl with parameters like:
I want use PCM timer from device C/D (C = card, D = PCM device) as timer
source. The time offset should be send in the SND_SEQ_EVENT_START event.

Maybe we can also add some tick handler called from timer routine which
should be used by special kernel clients like SMPTE sender.

							Jaroslav

-----
Jaroslav Kysela <perex@jcu.cz>
Academic Computer Centre, University of South Bohemia
Branisovska 31, C. Budejovice, CZ-370 05 Czech Republic


