Re: [Alsa-devel] midi timing fixes/questions

2001-09-18 Thread Paul Davis
In message <[EMAIL PROTECTED]>you write: >> > The only thing I can think of is that the sound card clock is drifting >> > too. >> >> Do you mean the drift as the difference between the "real" wall-clock >> time and sequencer ticks? Or between the sequencer time and ticks? > >The sequencer clock

Re: [Alsa-devel] midi timing fixes/questions

2001-09-18 Thread Takashi Iwai
At Tue, 18 Sep 2001 10:03:45 -0600, Jack Moffitt wrote: > > > > The only thing I can think of is that the sound card clock is drifting > > > too. > > > > Do you mean the drift as the difference between the "real" wall-clock > > time and sequencer ticks? Or between the sequencer time and ticks?

Re: [Alsa-devel] midi timing fixes/questions

2001-09-18 Thread Jack Moffitt
> X = real interrupt period, x = truncated in nsecs > > X = x + a > > Y = real tick duration Y, y = truncated in nsecs > > Y = y + b So X/Y is ticks/period, and x/y is what we are calulating as ticks per period. That means (X/Y) - (x/y) is the drift in

Re: [Alsa-devel] midi timing fixes/questions

2001-09-18 Thread Takashi Iwai
At Tue, 18 Sep 2001 10:07:37 +0200 (CEST), Jaroslav wrote: > > On Mon, 17 Sep 2001, Takashi Iwai wrote: > > > Hi, > > > > in this weekend I worked on the ALSA timer stuffs, too. > > The attached patch includes: > > > > - use standard list struct for handling of timers. > > It looks good. > > >

Re: [Alsa-devel] midi timing fixes/questions

2001-09-18 Thread Jack Moffitt
> > The only thing I can think of is that the sound card clock is drifting > > too. > > Do you mean the drift as the difference between the "real" wall-clock > time and sequencer ticks? Or between the sequencer time and ticks? The sequencer clock generates ticks on the pcm clock interrupt. But

Re: [Alsa-devel] midi timing fixes/questions

2001-09-18 Thread Takashi Iwai
Hi Jack, At Mon, 17 Sep 2001 20:06:48 -0600, Jack Moffitt wrote: > > > Ah, I meant that total .851 msec for 5 minutes. > > Thus it's still enough small. Sorry, I was too lame. > > > > I guess the problem is hidden somewhere in other place.. > > I noticed that after I posted. Sorry. > > If th

Re: [Alsa-devel] midi timing fixes/questions

2001-09-18 Thread Stephane Letz
Thes is a good summary of problems of precision found is tempo/ticks conversions and possible solutions by using integer and keeping fractionnal parts. http://www.manning.com/Messick/Chapter7.html Stephane Letz Grame: Centre National de creation musicale 9, Rue du Garet 69001 Lyon Tel: 04-72

Re: [Alsa-devel] midi timing fixes/questions

2001-09-18 Thread Jaroslav Kysela
On Mon, 17 Sep 2001, Takashi Iwai wrote: > Hi, > > in this weekend I worked on the ALSA timer stuffs, too. > The attached patch includes: > > - use standard list struct for handling of timers. It looks good. > - removal of resolution in sequencer -- sequencer invokes timer with > the highest

Re: [Alsa-devel] midi timing fixes/questions

2001-09-17 Thread Jack Moffitt
> Ah, I meant that total .851 msec for 5 minutes. > Thus it's still enough small. Sorry, I was too lame. > > I guess the problem is hidden somewhere in other place.. I noticed that after I posted. Sorry. If this was the only drift, we'd have 16ms after an hour. Not _great_ but probably accept

Re: [Alsa-devel] midi timing fixes/questions

2001-09-17 Thread Takashi Iwai
At Mon, 17 Sep 2001 19:49:55 -0600, Jack Moffitt wrote: > > > In theorecially maximum case: > > > > max D = (freq * t / pepriod) * max(x, y) / x^2 > > > > max D = .851 msec > > > > This looks reasonable? > > Yes. That results in 255.3ms of drift over 5 minutes. That sounds > right.

Re: [Alsa-devel] midi timing fixes/questions

2001-09-17 Thread Jack Moffitt
> In theorecially maximum case: > > max D = (freq * t / pepriod) * max(x, y) / x^2 > > max D = .851 msec > > This looks reasonable? Yes. That results in 255.3ms of drift over 5 minutes. That sounds right. jack. ___ Alsa-devel mailing l

Re: [Alsa-devel] midi timing fixes/questions

2001-09-17 Thread Takashi Iwai
At Mon, 17 Sep 2001 18:23:52 -0600, Jack Moffitt wrote: > > > Isn't it in nanoseconds (1e-9)? > > If so, the following drift will be 1/1000... > > Yes. But reading through more code, we're also losing 2/3 of a > nanosecond in tick resolution: > > tick->resolution = (tempo * 1000) / ppq; > >

Re: [Alsa-devel] midi timing fixes/questions

2001-09-17 Thread Jack Moffitt
> Isn't it in nanoseconds (1e-9)? > If so, the following drift will be 1/1000... Yes. But reading through more code, we're also losing 2/3 of a nanosecond in tick resolution: tick->resolution = (tempo * 1000) / ppq; Which means we're losing about 1.25 nanoseconds every period. I can definate

Re: [Alsa-devel] midi timing fixes/questions

2001-09-17 Thread Jack Moffitt
> > 10 * period / rate > > > > and truncated to an integer. for a period of 32 and a rate of 44100, > > this means we are throwing away .58276643 microseconds per period. > > Isn't it in nanoseconds (1e-9)? > If so, the following drift will be 1/1000... That definately looks like the c

Re: [Alsa-devel] midi timing fixes/questions

2001-09-17 Thread Takashi Iwai
At Mon, 17 Sep 2001 17:37:23 -0600, Jack Moffitt wrote: > > > There is still the same amount of drift though. > > I have calculated the drift: > > the interval in microseconds is calculated by > snd_pcm_timer_resolution_chage() like so: > > 10 * period / rate > > and truncated to an

Re: [Alsa-devel] midi timing fixes/questions

2001-09-17 Thread Jack Moffitt
> There is still the same amount of drift though. I have calculated the drift: the interval in microseconds is calculated by snd_pcm_timer_resolution_chage() like so: 10 * period / rate and truncated to an integer. for a period of 32 and a rate of 44100, this means we are throwing a

Re: [Alsa-devel] midi timing fixes/questions

2001-09-17 Thread Jack Moffitt
> in this weekend I worked on the ALSA timer stuffs, too. > The attached patch includes: This patch against CVS does the same thing as my code (although probably does it much better!). It fixes the resolution problem and we have nearly perfect sync. There is still the same amount of drift thoug

Re: [Alsa-devel] midi timing fixes/questions

2001-09-17 Thread Takashi Iwai
Hi, in this weekend I worked on the ALSA timer stuffs, too. The attached patch includes: - use standard list struct for handling of timers. - removal of resolution in sequencer -- sequencer invokes timer with the highest possible interrupts (for the assigned source). so now it doesn't mat

Re: [PATCH] Re: [Alsa-devel] midi timing fixes/questions

2001-09-17 Thread Jack Moffitt
> The first part looks good (I've put it to CVS), but the second part can > cause trouble when the PCM is not initialized (resolution is zero). I > think, if the timer is slave (we can't predict the tick time), then it's > better to stay with some reasonable defaults. So have you committed a fixe

Re: [PATCH] Re: [Alsa-devel] midi timing fixes/questions

2001-09-17 Thread Jaroslav Kysela
On Sun, 16 Sep 2001, Jack Moffitt wrote: > Of course I forgot the patch. > > It's now attached. The first part looks good (I've put it to CVS), but the second part can cause trouble when the PCM is not initialized (resolution is zero). I think, if the timer is slave (we can't predict the tick ti

[PATCH] Re: [Alsa-devel] midi timing fixes/questions

2001-09-16 Thread Jack Moffitt
Of course I forgot the patch. It's now attached. jack. diff -u -r1.53 seq_timer.c --- seq/seq_timer.c 2001/06/06 17:46:51 1.53 +++ seq/seq_timer.c 2001/09/16 22:52:54 @@ -151,7 +151,7 @@ if (!tmr->running) return; - resolution = tmr->period; +

[Alsa-devel] midi timing fixes/questions

2001-09-16 Thread Jack Moffitt
Once again I'm working on the MIDI timing (when synced with the pcm device). I've finally been able to trace through much of the code and I think I found some problems. THe attached patch does two things: 1) in snd_seq_timer_interrupt() the resolution is passed in from the pcm timer. This pat