A small japanese page is here.
The following documents are found in alsa-kernel/Documentation/DocBook directory, too. The files below are generated from them.
A tutorial for writing a PCI ALSA driver.
ALSA Driver API Reference
The following one is converted from a plain-text file in alsa-kernel/Documentation directory.
Descriptions about ALSA OSS-Emulation on the kernel.
The sequencer API has been totally rewritten based on the concept of encapsulation. This is a way to hide the structure members from user space and give access only via the defined functions. The advantage of this method is its extensibility. Since the structure is opaque and its size is defined dynamically, even if we change the internal structure members or its size, the previously compiled code can run without any changes. The disadvantage is, of course, that it's not nice to look at, and slight overhead via function calls instead of direct access. But this could be improved via C++ wrapper or something like that..
The change from the old API style to the encapsulated style is like following:
snd_seq_port_info_t pinfo;with
snd_seq_port__info_t *pinfo; snd_seq_port_info_alloca(&pinfo);
pinfo.capability = SND_SEQ_PORT_CAP_READ;with
snd_seq_port_info_set_capability(pinfo, SND_SEQ_PORT_CAP_READ);and to read the structure member, replace
int cap = pinfo.capability;with
int cap = snd_seq_port_info_get_capability(pinfo);
There are some functions changed from the older version:
group is removed from client and port information.
Also cap_group is removed from port information too.
snd_seq_get/set_queue_client are renamed to
snd_seq_get/set_queue_usage.
Along with this change, snd_seq_use_queue is removed.
snd_seq_query_subs_t is renamed to
snd_seq_query_subscribe_t.
snd_seq_delete_port takes only the port id argument. Much easier, isn't it?
snd_seq_input_buffer_size and snd_seq_output_buffer_size
are renamed to
snd_seq_get_input_buffer_size and
snd_seq_get_output_buffer_size, respectively.
Similarly,
snd_seq_resize_input_buffer and snd_seq_resize_output_buffer
are renamed to
snd_seq_set_input_buffer_size and
snd_seq_set_output_buffer_size, respectively.
snd_seq_get_named_queue is renamed to snd_seq_query_named_queue.
convert_time is named as time_update.
snd_seq_get/set_queue_owner are removed.
Use snd_seq_get/set_queue_info instead.
I've ported some applications for the new api (see below section). Both aseqview and vkeybd support the new api as default now. Also patch for pmidi 1.5.1 is available.
Here are some patches to support ALSA 0.9.0.
The newer version of latency-test tool is available. It's for 2.6 kernel only, and uses RTC as the interrupt source.
About the latency on linux, please refer to this page. I hacked Benno's latency measurement tools for ALSA. Here is the one.
My colleague, Werner Fink, extended/fixed Andy's ac3play. You can find the latest version here.
Here is the dummy library for ALSA 0.9.0. This library provides
libasound.so.1 which returns simply errors on all ALSA 0.5.x
API, so that the older programs can even run without complaining
unresolved symbols.
If you are using KDE, you'll need probably this stuff.
The RPM packages below for ALSA 0.9 already includes
this library.
IMPORTANT: Please install this library before installing
the ALSA 0.9.x library. This will overwrite /usr/lib/libasound.la.
[Updated!] See THIS PAGE.
I've made unofficial RPM packages of ALSA releated stuffs for the SuSE distribution. The packages had been put on this web page for a while but now they are on suse ftp server to avoid the version conflict. Please refer to ftp://ftp.suse.com/pub/people/tiwai or its mirrors.
Now there are also RPM packages for ALSA 0.9. The packages are built only for suse 7.2, since it takes fairly long time to compile all the stuff (and the ALSA is being changed everyday, as you know :) You can find them at ftp://ftp.suse.com/pub/people/tiwai/alsa9-packages .
[2000/07/14]
The ALSA sequencer patch was already
merged to TiMidity++ main tree.
Get the latest source from
here.
The ALSA sequencer interface is the interface of timidity to create ALSA sequencer ports with real-time response. You may play MIDI upon ALSA sequencer system without wavetable like Emu8000/10k1.
For enabling this interface, configure TiMidity with
--enable-alsaseq option.
Of course, you need to enable ALSA audio :-)
Thus the minimum configure example becomes:
% ./configure --enable-audio=alsa --enable-alsaseq
The ALSA seq interface is invoked when -iA option is
specified to timidity.
Eventually the -Bx,y option is required for reduction of
latency, where x is the fragments and y is
the bits of audio buffer size. In both cases, smaller numbers
result in faster real-time response.
Typically, -B2,8 is enough. This specifies two fragments
with 256 samples.
% timidity -iA -B2,8 -Os -EFreverb=0In this example, the reverb effect is disabled, because it eats lots of CPU power. You may also turn off chrous effect via
-EFchorus=0
if less CPU usage is preferred.
Then you'll get an output like this:
Timidity starting in ALSA server mode Opening sequencer port 128:0 128:1This shows that timidity created ALSA sequencer ports 128:0 and 128:1.
For hearing MIDI music, run pmidi to send events to this port:
% pmidi -p128:0 foo.midYes, it's an overkill :-) (Originally, you can listen to MIDI music directly via timidity, of course.)
For connecting MIDI keyboard input to timidity,
% aconnect 64:0 128:0
This interface tries to reset process priority as SCHED_FIFO
and as high as possible. This is allowed only for root.
Thus you need to invoke timidity as root or
install the timidity binary with setuid root.
The SCHED_FIFO'd program shows much better real-time response.
Timidity loads instruments dynamically at each time a PRM_CHANGE event is received. This causes sometimes pauses during playback. It occurs often in the playback via pmidi. Furthermore, timidity resets the loaded instruments when the all subscriptions are disconnected. Thus for keeping all loaded instruments also after playback is finished, you need to connect a dummy port (e.g. midi input port) to timidity port via aconnect:
% aconnect 64:0 128:0
If you prefer a bit more fancy visual output, use my tiny program, aseqview (see below).
% aseqview -p2 &Then connect two ports to timidity ports:
% aconnect 129:0 128:0 % aconnect 129:1 128:1The outputs ought to be redirected to 129:0,1 instead of 128:0,1.
Here is the latest patch to 2.10.4. It includes the support of ALSA 0.9.0 with the new sequencer API.
RTC has a nice high-frequent interrupt capability up to 8192 Hz. Although this can be used (on the recent kernel) even from userspace via fasync signals, it is not allowed to use the interrupt from kernel. This is the very reason of this patch.
This tiny patch adds a hook to the RTC driver in linux kernel.
A callback function is called at each interrupt.
For changing frequency, starting and stopping interrupts, use
rtc_control function.
The older version of this patch had more functionalities than the
current version, for example, multiple callbacks with different
frequencies are allowed.
From this patch, however, I intensionally removed these things,
because of simplicity.
Only one callback can be used exclusively (even to user-space).
That is, if a kernel driver (e.g. ALSA RTC timer) registers the callback,
no other threads can use RTC interrupt. /dev/rtc cannot
be opened during it.
The patches are prepared for 2.2.16 and 2.4.0 kernels. Since SuSE-7.0 distribution includes its own patch to RTC already, further patch is prepared separately. Please note that these patches are already included in the latest ALSA CVS (0.6.0) under alsa-drivers/utils/patches.
The following patches have been already included in the ALSA CVS main stream.
The patch enables us to use wavetable synth on Emu10k1 (SB Live!) chip.
It works just like Emu8000 (SB AWE 32/64) cards but with more voices (64 maximum).
As well as Emu8000 chip, you'll need to load SoundFont files via OSS emulation
using sfxload program.
The sfxload can be obtained from my page.
The known bugs are as follows:
Please note that this patch may cause problems to Emu8k driver, because many parts were rewritten to share the common routines.
~/.gamix/Config
file before starting.
seq_lock.c.
/dev/music support in OSS-Sequencer emulation.
ASeqView is an ALSA sequencer user-client which works as event viewr. It visualizes received events, e.g. note-on/off, controls, pitch wheels, using bar graphs, as often seen in many sequencer programs. Using this viewer, even a simple command line sequencer like pmidi or playmidi1 becomes a cool one with graphical interface :-)
Another feature of ASeqView is redirection of events. ASeqView can output the received events to subscription ports with some modification like channel mute or pitch change. Since this works as a real-time filter client, such modifications can be applied also in real-time without complexity.
The latest version (0.2.3) includes the piano view support (thanks to Patrick Horn). See the screenshot below.
This program is originally for AWE32/64 driver on OSS/Free, but
it works now on ALSA, too.
Start the program with --device alsa option.
Then, connect this client to any ALSA port by aconnect utility, for example,
% aconnect 128:0 65:0Alternatively, you can use
--addr 65:0 option to connect
directly from vkeybd.
Some demo programs for ALSA sequencer. Most of the part has been impelemented in aseqview. I just show this for test only.
Takashi Iwai tiwai@suse.de;
Go to My Home Page