Subject: [linux-audio-dev] Sequencer Sync Woes
From: Billy Biggs (bbiggs_AT_DIV8.NET)
Date: Tue Feb 06 2001 - 05:55:53 EET
I'm rewriting my sequencer. I'm trying to output 24ppq MIDI sync
pulses to drive the rest of my gear.
I'm using an es1371 with joystick-MIDI. I have a thread for the
editor, and another writing to /dev/midi00. The MIDI thread is running
as SCHED_FIFO, and uses a small nanosleep to throttle itself. Even 16th
note snare rolls sound jumpy with stutters at 140 bpm. Very bad.
I had better luck using /dev/sequencer with my old MPU-401 card,
queueing up a tick ahead to avoid skipping and using the timestamps to
help keep my sequencer in sync with a remote clock. Unfortunately, the
es1371 has no /dev/sequencer code (AFAIK), and the API sucks. The ALSA
sequencer has no documentation, and I can't see anything to indicate if
it exists or works.
So, maybe I'm ok to use /dev/midi00? Is that what everyone else uses?
Am I doing something wrong in my loop? Is there a way to yield a
smaller amount of time maybe so I can poll more often? My pseudocode:
loop {
nanosleep( 5ms ); // something less than HZ I guess?
// let the editor get some cpu
diff = gettimeofday - time_last_tick_we_sent_was_due
if diff > time_per_tick:
- output a sync tick along with the notes for this tick
- remember the time that tick was supposed to be sent, we use
that for the difference above
fi
}
Should I write a kernel module which I can use to queue writes?
timedwrite( struct timeval tv, int fd, void *, size_t )
I must be missing the obvious if it's this hard to get a sequencer to
work.
-- Billy Biggs bbiggs_AT_dumbterm.net http://www.billybiggs.com/ wbiggs_AT_uwaterloo.ca
This archive was generated by hypermail 2b28 : Tue Feb 06 2001 - 06:07:45 EET