ALSA Sequencer System




Takashi Iwai

SuSE GmbH, Nuremberg, Germany


suse-small.gif

Linux Kongress, Sep. 21, 2000
Erlangen, Germany


(page 1)


Outline





(page 2)


Characteristics of ALSA




(page 3)


Structure of ALSA

archtect.gif



(page 4)


ALSA Drivers


you'll see so many modules!


ex) SB AWE64 with sequencer


Card Driver

snd-card-sbawe - SB AWE 32/64

Mid-Level Drivers

snd-pcm - PCM
snd-hwdep - H/W-dep device
snd-timer - Timer
snd-opl3 - FM OPL3
snd-rawmidi - RawMIDI
snd-seq-device - Sequencer manager

Low-Level Drivers

snd-mpu401-uart - MPU401 driver
snd-emu8000 - Emu8000 driver
snd-sb16-dsp - SB16 DSP driver
snd-sb16-csp - SB16 CSP
snd-sb-common - SB8/16 common
snd-util-mem - Emu/Trident memory manager
snd - ALSA core

Sequencer Kernel Clients (loaded as plug-in)

snd-synth-opl3 - FM OPL3
snd-seq-midi - MIDI synth
snd-synth-emu8000 - Emu8000 WaveTable

Sequencer Support (loaded as plug-in)

snd-seq-virmidi - Virtual MIDI device
snd-seq-instr - Instrument abstract layer
snd-ainstr-fm - FM OPL3 instrument support
snd-synth-emux - Emu8000/10k1 wavetable support
snd-seq-midi-emul - MIDI emulation
snd-seq-midi-event - MIDI byte stream conversion


(page 5)


ALSA Library




(page 6)


OSS Compatibility


ALSA is (almost :-) full compatible with OSS




(page 7)


What's Sequencer?


The role of sequencer =


Problems of OSS sequencer


ALSA sequencer



(page 8)


Structure of ALSA Sequencer

struct1.gif


(page 9)


Sequencer as Dispatcher

struct2.gif


(page 10)


Sequencer as Dispatcher - 2



(page 11)


Sequencer as Scheduler

struct3.gif


(page 12)


Sequencer as Scheduler - 2




(page 13)


Multiple Queues

qstruct.gif



(page 14)


Client
client.gif



(page 15)


Special Clients




(page 16)


Other Kernel Clients




(page 17)


Port Capabilities


Access to the port is controlled via capability bits
SND_SEQ_PORT_CAP_XXX





(page 18)


Subscription


Subscription = connection between two ports





(page 19)


Subscription Examples





(page 20)


More about Subscription





(page 21)


Double Queue System

Concept



Implementation
queueup.gif


(page 22)


Event

A fixed size event packet:

snd_seq_event_t {
snd_seq_event_type type; /* event type */
unsigned char flags; /* event flags */
char tag; /* for removing */
unsigned char queue; /* schedule queue */

union {
snd_seq_tick_time_t tick; /* MIDI tick */
snd_seq_real_time_t time; /* real-time */
} time; /* schedule time */

snd_seq_addr_t source; /* source address */
snd_seq_addr_t dest; /* destination address */

union { /* event data: 12bytes */
snd_seq_ev_note note; /* note events */
snd_seq_ev_ctrl control; /* chanel control events */
snd_seq_ev_ext ext; /* external data */
....
} data;

};



(page 23)


Event Types



(page 24)


Variable Length Events - Case 1
dispatchk1.gif
dispatchk2.gif
dispatchk3.gif



(page 25)


Variable Length Events - Case 2
dispatchu1.gif
dispatchu2.gif
dispatchu3.gif



(page 26)


Variable Length Events - Case 3
schedk1.gif
schedk2.gif
schedk3.gif


(page 27)


Variable Length Events - Case 4
schedu1.gif
schedu2.gif
schedu3.gif
schedu4.gif



(page 28)


More Efficiency..?




--> Use of mmap



(page 29)


Synchronization

Synchronization = running two (or more) queues
at the same position with the same tempo






(page 30)


Implementation of Sync


sync.gif



(page 31)


Implementation of Sync - 2







(page 32)


Sequencer API



(page 33)


Proc Interface


Files under /proc/asound/seq







(page 34)


OSS Emulation

oss-seq.gif



(page 35)


Latency Test

Echo-back events from a user-client to itself

Iteration = 10,000,000, CPU = celeron 400MHz, Kernel 2.2.16 low-latency




(page 36)


Playback with TiMidity++

pmidi -> sequencer -> aseqview -> output (timidity)



(page 37)


Combination with Jazz++

jazz-system.gif


(page 38)


Network Transparency

seq-net.gif


(page 39)


Combination of Sync

sync-ex.gif


(page 40)


Remarkable Notes




(page 41)


Known Problems






(page 42)


Further Works to Do









(page 43)


Resources





(page 44)