Re: [linux-audio-dev] MIDI sequencing (was: [ANN] ALSA 0.9.0 HOWTO as HTML)

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [linux-audio-dev] MIDI sequencing (was: [ANN] ALSA 0.9.0 HOWTO as HTML)
From: Dr. Matthias Nagorni (mana_AT_suse.de)
Date: Wed Apr 10 2002 - 15:53:22 EEST


Hi,

On Wed, 10 Apr 2002, Richard Bown wrote:

> I've got a bit of a basic question about ALSA sequencing. Do I have to
> handle my own synth polyphony over the synth devices I see? For example
> on my SBLive I've got 4 available ports (65,0 - 65,3) and if I send
> everything to one dest port from a single src port I get playback but
> some notes cut each other off. Sounds somethinglike a polyphony problem
> - either that or finger-trouble.
>
> I'm looking at the "context" code in pmidi and scratching my head. Do I
> have to use more than a single dest and source port for MIDI sequencing?
> If so, why? Is there a simple overview of the port subscription model
> somewhere?

You only need one single output port for MIDI sequencing. You just schedule
the events on the queue and then have them sent to the output port. As to
notes, you can schedule them either as NOTEON / NOTEOFF events or as NOTE
events. As mentioned in the HOWTO, NOTE events consist of a NOTEON and
NOTEOFF event and they schedule an NOTEOFF event according to their length
once their NOTEON event has been processed.

Now it is up to the synthesizer device being connected to the output port
how it handles the NOTEOFF events. If a SBLive receives a NOTEOFF event on
channel n, all corresponding oscillators of that note and channel are
muted. miniFMsynth does the same (however, it does not check the channel):

case SND_SEQ_EVENT_NOTEOFF:
    for (l1 = 0; l1 < POLY; l1++) {
         if (gate[l1] && note_active[l1] && (note[l1] == ev->data.note.note)) {
              env_time[l1] = 0;
              gate[l1] = 0;
         }
    }

As I understood it, you ask what to do if you have, say, a long note c' on
channel 1 and a short note c' on the same channel, which is played while the
long note is still present. On a SBLive, the short note would mute the long
note due to its NOTEOFF event. If you have this problem of crossing voices,
it is better to use different MIDI channels for the voices which might
interfere. However, you can also try timidity. This does not mute all
oscillators with a given channel and note once a NOTEOFF event on this
channel and note is received.

The four wavetable destination ports of SBLive are just there in case you
need more than 16 MIDI channels. If you would like to implement a 64 track
MIDI player, you would send track 1-16 to 65:0 channel 1-16,
17-32 to 65:1, channel 1-16 and so on.

Matthias

-- 
Dr. Matthias Nagorni
SuSE GmbH
Deutschherrnstr. 15-19    phone: +49 911 74053375
D - 90429 Nuernberg       fax  : +49 911 74053483


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Wed Apr 10 2002 - 15:40:45 EEST