All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steve deRosier <derosier@pianodisc.com>
To: Clemens Ladisch <clemens@ladisch.de>
Cc: Alsa-Devel <alsa-devel@lists.sourceforge.net>
Subject: Re: How to tell how many frames gone to PCM
Date: Wed, 27 Apr 2005 13:31:31 -0700	[thread overview]
Message-ID: <426FF6A3.5050304@pianodisc.com> (raw)
In-Reply-To: <Pine.HPX.4.33n.0504271910000.28618-100000@studcom.urz.uni-halle.de>



Clemens Ladisch wrote:
> Steve deRosier wrote:
> 
>>Clemens Ladisch wrote:
>>
>>>You should check the error code, but otherwise this looks OK.
>>
>>Error code for which function?
> 
> 
> snd_seq_set_queue_timer (it's the only nontrivial function, the others
> just set parameters for this one)
> 
> As a rule, every error code should be checked.

Agreed.  Must have missed that one; fixed, thanks.

>>Here's a question... I'd like to get the current time from both
>>the PCM and the MIDI device in order to confirm they've got the
>>clock linked. Is there a meaningful way to test that?
> 
> 
> There is no PCM time per se, you have to use the frame count as time.
> 
> A MIDI queue doesn't have its own "real time" either; whenever you use
> a "real time" timestamp you end up using the system clock.  Only the
> tick counter is synchronized to the timer interrupt.  (And no, this
> isn't documented anywhere.)
> 
> And I guess this is your problem -- it should go away if you schedule
> the MIDI events using ticks instead of real time.
> 
> The nice thing about using ticks is that you can set them up to be any
> quantity you want (in this case probably the same as one PCM frame or
> period).
> 

Interesting!  Thats a real clue for once.  Looking back over our other Alsa players, I'm noticing they're all using ticks, not real time scheduling.  Forgeting the +4/PERIOD_SIZE hack I've got in there for a moment (I must have a culmative off-by-one error somewhere), this player always seemed sloppy, where as the other player was real crisp.  Would I be guessing right that if several real-time scheduled events were supposed to go out, but built up till the tick happened, all of those would be sent out and then more events would buffer till the next tick?  

Ok, I'm changing to tick-based timing.  How do I setup my tick timing?  Is the sample code in the docs what I'm looking for?:
void set_tempo(snd_seq_t *handle)
{
        snd_seq_queue_tempo_t *tempo;
        snd_seq_queue_tempo_alloca(&tempo);
        snd_seq_queue_tempo_set_tempo(tempo, 1000000); // 60 BPM
        snd_seq_queue_tempo_set_ppq(tempo, 48); // 48 PPQ
        snd_seq_set_queue_tempo(handle, tempo);
}

Ideas of the PPQ and BPM I should use to match 1 tick to 1 frame?

Thanks,
- Steve


-------------------------------------------------------
SF.Net email is sponsored by: Tell us your software development plans!
Take this survey and enter to win a one-year sub to SourceForge.net
Plus IDC's 2005 look-ahead and a copy of this survey
Click here to start!  http://www.idcswdc.com/cgi-bin/survey?id=105hix

  reply	other threads:[~2005-04-27 20:31 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-26 20:18 How to tell how many frames gone to PCM Steve deRosier
2005-04-26 20:16 ` Lee Revell
2005-04-26 21:07   ` Steve deRosier
2005-04-26 21:17     ` Lee Revell
2005-04-26 21:45       ` Steve deRosier
2005-04-27 14:36         ` Clemens Ladisch
2005-04-27 16:56           ` Steve deRosier
2005-04-27 17:22             ` Clemens Ladisch
2005-04-27 20:31               ` Steve deRosier [this message]
2005-04-28  8:25                 ` Clemens Ladisch
2005-05-02 18:04                   ` Steve deRosier
2005-05-03  8:05                     ` Clemens Ladisch
     [not found] ` <ad2655cb0504270201165f9859@mail.gmail.com>
2005-04-27 16:43   ` Steve deRosier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=426FF6A3.5050304@pianodisc.com \
    --to=derosier@pianodisc.com \
    --cc=alsa-devel@lists.sourceforge.net \
    --cc=clemens@ladisch.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.