All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steve deRosier <derosier@pianodisc.com>
To: alsa-devel@lists.sourceforge.net
Subject: Sync between MIDI and audio
Date: Thu, 28 Aug 2003 17:48:36 -0700	[thread overview]
Message-ID: <3F4EA2E4.2010902@pianodisc.com> (raw)
In-Reply-To: <5.1.0.14.2.20030828232924.021e2830@192.168.10.1>

I'm writting an app that plays a special format and uses both the Alsa 
seq and pcm interfaces to output MIDI and audio data together.  I'm 
almost done, but I've got one problem that is plaugeing me: I can't get 
the two to stay in sync.

Basically, what I'm doing is using writei() to send frames to the audio 
and for midi:
void SendTimeEvent( snd_seq_event_t *event, snd_seq_real_time_t *iRealTime)
{
   snd_seq_ev_set_source( event, mPort );
   snd_seq_ev_set_subs(event);
   snd_seq_ev_schedule_real(event, mQueue, 0, iRealTime );
   snd_seq_event_output(hSeq, event);
   snd_seq_drain_output(hSeq);
}

I call this with iRealTime calculated based on the number of frames I've 
sent to the audio.  I recieve the MIDI data and the audio samples in 
sync from a different portion of the program, and the time that the MIDI 
should be played at is the time that sample gets played plus a constant 
offset.

Both the MIDI and audio play just fine (the piano plays and so does the 
digital audio).

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.

Any ideas of where to look?

Thanks in advance,
- Steve



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf

  reply	other threads:[~2003-08-29  0:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-28 21:44 Terratec Aureon Space 7.1 and digital out Dennis van der Meer
2003-08-29  0:48 ` Steve deRosier [this message]
2003-08-29  1:27   ` Sync between MIDI and audio Paul Davis
2003-09-02 16:39     ` 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=3F4EA2E4.2010902@pianodisc.com \
    --to=derosier@pianodisc.com \
    --cc=alsa-devel@lists.sourceforge.net \
    /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.