* Re: [linux-audio-dev] External MIDI Sync using OSS/Free
@ 1999-10-26 17:11 Paul Barton-Davis
1999-10-26 18:49 ` Billy Biggs
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Paul Barton-Davis @ 1999-10-26 17:11 UTC (permalink / raw)
To: linux-sound
> My sequencer (http://www.div8.net/ttrk) mainly runs off of external MIDI
>sync, and drives a mess of synths and stuff. I use /dev/sequencer for
>MIDI input and output.
advice #1: do not use /dev/sequencer
two reasons. it doesn't exist in ALSA, which will (soon-ish) be the
default sound driver system for Linux. but more importantly, its a
horrible system. i won't list the problems with it here, but there are
many.
instead, just let the user specify the MIDI device files to use, and
then use them as "raw" read(2)/write(2) files. this works with OSS,
ALSA, Solaris and a number of other systems. then do most of your
timing stuff at user level. i don't know what your resolution needs to
be, but my "analog MIDI sequencer" program SoftWerk does all its
timing in user space (it has too - it doesn't know what to send to the
MIDI interface until its actually time to send it) and is accurate
down to about 20ms without any special priviledges. it can get a lot
more accurate than that if it needs to. OTOH, SoftWerk is an "old
school" sequencer, from back before the days of the first digital
sequencers. it has a fixed number of event steps per fixed number of
event steps, which is not what most people these days mean by "sequencer".
advice #2: if you really have external MIDI sync (do you mean MIDI clock,
or other stuff ?), then just use that to provide timing for your
application. if you have sensible hardware for your MIDI interface,
then your application will be woken up very rapidly (at least if it
runs SCHED_FIFO) after the MIDI clock byte (or any other MIDI message)
is ready to read.
if you don't have external clock, then you'd be better off using the
real time clock for timing.
advice 3: install ALSA, and use the ALSA sequencer. its a vastly more
evolved kernel sequencer system, though its still going through some
beta-testing. we would welcome your involvement in that process.
> Is there a way that I could do this more efficiently? Since my app
>might not get swapped in until late after the start arrived, and then I
>have to call the ioctl. This error then remains for the entire duration
>of the song.
use SCHED_FIFO if you can. the only downside is that it does require
that either your program, or a "helper/starter" program run setuid
root. this will reduce to the delay between your program being "ready
to run because MIDI data is available" and "running" to a virtually
insignificant time.
--p
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [linux-audio-dev] External MIDI Sync using OSS/Free
1999-10-26 17:11 [linux-audio-dev] External MIDI Sync using OSS/Free Paul Barton-Davis
@ 1999-10-26 18:49 ` Billy Biggs
1999-10-26 19:59 ` Paul Barton-Davis
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Billy Biggs @ 1999-10-26 18:49 UTC (permalink / raw)
To: linux-sound
On Tue, 26 Oct 1999, Paul Barton-Davis wrote:
> advice #1: do not use /dev/sequencer
[ solution, use /dev/midi* ]
This is pretty useless IMHO. My sequencer started off writing out
/dev/midi, and it was consistently off-sync. Badly off sync. Up to half
a second off sync. I don't know if you have a significantly better box
than I do, but mine just puked.
Oh yeah, and I got flamed real bad by diz. :)
Trying to up the priority on the process helped significantly, but a
simple switch to /dev/sequencer let my app stay usermode and still be
reasonably responsive.
I wish there were a better way to sync audio though, specifically sync
of audio to MIDI. /dev/dsp has a crappy interface to this. Does ALSA
provide any reasonable mechanism of syncing different inferfaces?
In OSS, the clock between outgoing and incomming MIDI aren't the same.
In ALSA, I'd hope that would be fixed. Does audio and sequencer also have
the same clock?
What about syncing multiple soundcards? I've found this to be next to
impossible under thud using OSS.
> advice 3: install ALSA, and use the ALSA sequencer. its a vastly more
> evolved kernel sequencer system, though its still going through some
> beta-testing. we would welcome your involvement in that process.
I know that I should definitely look into this. Promise I will.
Honest.
--
Billy Biggs vektor@div8.net
http://www.div8.net/billy wbiggs@uwaterloo.ca
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [linux-audio-dev] External MIDI Sync using OSS/Free
1999-10-26 17:11 [linux-audio-dev] External MIDI Sync using OSS/Free Paul Barton-Davis
1999-10-26 18:49 ` Billy Biggs
@ 1999-10-26 19:59 ` Paul Barton-Davis
1999-10-26 21:10 ` Jaroslav Kysela
1999-10-26 21:18 ` Jaroslav Kysela
3 siblings, 0 replies; 5+ messages in thread
From: Paul Barton-Davis @ 1999-10-26 19:59 UTC (permalink / raw)
To: linux-sound
>> advice #1: do not use /dev/sequencer
>[ solution, use /dev/midi* ]
>
> This is pretty useless IMHO. My sequencer started off writing out
>/dev/midi, and it was consistently off-sync. Badly off sync. Up to half
>a second off sync. I don't know if you have a significantly better box
>than I do, but mine just puked.
did you open it O_NONBLOCK, and which kernel were you using ? support
for O_NONBLOCK was added (by me) somewhere during the 2.1 development
series. if you tried /dev/midi on 2.0 or earlier, you'll find it works
a *lot* better under 2.2.
previously, the driver would block until there were 32 bytes of data
to read. this is a disaster! if you use select(2) and open
(...O_NONBLOCK...) i think you'll find you stay totally in sync.
this used to be a standard problem with /dev/midi, which was one
of the reasons I fixed it :)
> I wish there were a better way to sync audio though, specifically sync
>of audio to MIDI. /dev/dsp has a crappy interface to this. Does ALSA
>provide any reasonable mechanism of syncing different inferfaces?
well, it has a more evolved timer interface, but its not clear that
anyone has tried using it for anything real.
personally, most of my current applications are so phase-locked to a
soundcard DAC that i can get "perfect" sync timing from that. some
applications (and MIDI-only sequencers are a very good example of
them) are not like this, however, since they do no audio output :)
> In OSS, the clock between outgoing and incomming MIDI aren't the same.
>In ALSA, I'd hope that would be fixed. Does audio and sequencer also have
>the same clock?
i don't know the answer to either of these questions. jaroslav reads
linux-audio-dev, so he may be able to help you.
> What about syncing multiple soundcards? I've found this to be next to
>impossible under thud using OSS.
as has been discussed here a number of times, this is far from
trivial. clock rates from card to card, even the same brand, and even
from (warm) day to (cold) day vary, so its not just a matter of
finding a way to get them to all start at the same time.
in addition, you *cannot* simultaneously issue a command to every card
to start playing/recording, so unless the soundcard h/w supports a
"start when first sample > XXX is seen" command (not many do), you can
*never* get them truly synchronized. ALSA does let you get pretty
close though. I think that Benno or someone else did some tests of
this.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [linux-audio-dev] External MIDI Sync using OSS/Free
1999-10-26 17:11 [linux-audio-dev] External MIDI Sync using OSS/Free Paul Barton-Davis
1999-10-26 18:49 ` Billy Biggs
1999-10-26 19:59 ` Paul Barton-Davis
@ 1999-10-26 21:10 ` Jaroslav Kysela
1999-10-26 21:18 ` Jaroslav Kysela
3 siblings, 0 replies; 5+ messages in thread
From: Jaroslav Kysela @ 1999-10-26 21:10 UTC (permalink / raw)
To: linux-sound
On Tue, 26 Oct 1999, Billy Biggs wrote:
> I wish there were a better way to sync audio though, specifically sync
> of audio to MIDI. /dev/dsp has a crappy interface to this. Does ALSA
> provide any reasonable mechanism of syncing different inferfaces?
>
> In OSS, the clock between outgoing and incomming MIDI aren't the same.
> In ALSA, I'd hope that would be fixed. Does audio and sequencer also have
> the same clock?
Yes, if you choose the PCM device as the timer source.
> What about syncing multiple soundcards? I've found this to be next to
> impossible under thud using OSS.
No probs.
Jaroslav
-----
Jaroslav Kysela <perex@suse.cz>
SuSE Linux http://www.suse.com
ALSA project http://www.alsa-project.org
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [linux-audio-dev] External MIDI Sync using OSS/Free
1999-10-26 17:11 [linux-audio-dev] External MIDI Sync using OSS/Free Paul Barton-Davis
` (2 preceding siblings ...)
1999-10-26 21:10 ` Jaroslav Kysela
@ 1999-10-26 21:18 ` Jaroslav Kysela
3 siblings, 0 replies; 5+ messages in thread
From: Jaroslav Kysela @ 1999-10-26 21:18 UTC (permalink / raw)
To: linux-sound
On Tue, 26 Oct 1999, Jaroslav Kysela wrote:
> > What about syncing multiple soundcards? I've found this to be next to
> > impossible under thud using OSS.
>
> No probs.
Oops. Before I receive some flames, the correction is here:
There are problems with different clock sources for the chips on multiple
soundcards. ALSA driver currently doesn't support multiple soundcards
which can be synced together. The new PCM API covers this possibility,
but the driver for some hardware, which supports this feature, has not
been written yet.
Jaroslav
-----
Jaroslav Kysela <perex@suse.cz>
SuSE Linux http://www.suse.com
ALSA project http://www.alsa-project.org
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~1999-10-26 21:18 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-10-26 17:11 [linux-audio-dev] External MIDI Sync using OSS/Free Paul Barton-Davis
1999-10-26 18:49 ` Billy Biggs
1999-10-26 19:59 ` Paul Barton-Davis
1999-10-26 21:10 ` Jaroslav Kysela
1999-10-26 21:18 ` Jaroslav Kysela
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox