ALSA MIDI interface - plugin
Hi
I am writing an user space ALSA i/o type PCM plugin for my board. I chose this
rather unconventional approach for supporting ALSA apps since the the the driver
which communicates with DSP using shared memory is in userspace and for some constraints the driver communication driver will always be in userspace. My audio
plugin uses calls of the coomunication driver and talks to DSP. I already have
a working plugin in place. I use it like following,
#aplay -D my_plugin test.wav
and it works.
Now, I have to support rawmidi interface also. Is it possible to write a userspace
plugin for making MIDI work? Where can I get sample code etc?
-pharaoh.
At Thu, 14 Feb 2008 20:54:28 +0530,
Quoted 4 lines · Pharaoh .
Now, I have to support rawmidi interface also. Is it possible to write a userspace
plugin for making MIDI work? Where can I get sample code etc?
It's possible, but so far, no external plugin framework is implemented for rawmidi. The external plugins are available only for PCM and control APIs. I guess it'd be relatively easy to add the external rawmidi plugins, though.
Another possibility is to write an ALSA sequencer client, and load snd-virmidi driver. Then you can connect to a rawmidi device as you like.
Takashi
Quoted 12 lines · Takashi Iwai
At Thu, 14 Feb 2008 20:54:28 +0530,
Quoted 4 lines · Pharaoh .
Now, I have to support rawmidi interface also. Is it possible to write a userspace
plugin for making MIDI work? Where can I get sample code etc?It's possible, but so far, no external plugin framework is implemented for rawmidi. The external plugins are available only for PCM and control APIs. I guess it'd be relatively easy to add the external rawmidi plugins, though.
Quoted 5 lines
Another possibility is to write an ALSA sequencer client, and load snd-virmidi driver. Then you can connect to a rawmidi device as you like.
Thanks Takashi, I am not sure I understood this fully..Can you point me to
some sample
code or relevant documentation.
-Pharaoh.
Quoted 2 lines
Takashi
Quoted 6 lines · Pharaoh .
Quoted 5 lines · Takashi Iwai
At Thu, 14 Feb 2008 20:54:28 +0530,
Quoted 3 lines · Pharaoh .
Now, I have to support rawmidi interface also. Is it possible to write a userspace
plugin for making MIDI work? Where can I get sample code etc?
Quoted 6 lines
Quoted 3 lines
Another possibility is to write an ALSA sequencer client, and load snd-virmidi driver. Then you can connect to a rawmidi device as you like.
Thanks Takashi, I am not sure I understood this fully..Can you point me to some sample
code or relevant documentation.
Look the code of aseqdump from alsa-utils project. You don't need anything related to kernel, just a normal client that creates a port and listens for events. Once you receive a MIDI event, process it and do the magic in your card.
$ aseqdump Waiting for data at port 129:0. Press Ctrl+C to end. Source_ Event_________________ Ch _Data__
$ aconnect -iol
$ aplaymidi -p 129:0 /usr/share/denemo/manual/4for2new.midi
Please note that with the alsaseq API you receive processed MIDI data... This could be a plus for your development (you don't have to implement the low-level midi parser). Timidity is a software synth that follow this approach.
About snd-virmidi, is almost the same, but the port is a 'kernel port' and it represents a virtual card. I'm not sure what advantages has it.
Signature · 1 line
Aldrin Martoq <[email protected]>
Quoted 7 lines · Pharaoh .
Quoted 3 lines · Takashi Iwai
Another possibility is to write an ALSA sequencer client, and load snd-virmidi driver. Then you can connect to a rawmidi device as you like.
Thanks Takashi, I am not sure I understood this fully..Can you point me to some sample code or relevant documentation.
There is the old usbmidid daemon that creates sequencer ports for USB MIDI devices: <http://www.alsa-project.org/~clemens/usbmidid/>.
(It won't install fully on any modern system because the hotplug scripts have been replaced with udev.)
HTH
Clemens
Quoted 6 lines
It's possible, but so far, no external plugin framework is implemented for rawmidi. The external plugins are available only for PCM and control APIs. I guess it'd be relatively easy to add the external rawmidi plugins, though.
How can I start adding an external rawmidi plugin? As you said, there is no framework ready yet. So, first a framework has to be created so that external plugins can be added the same way one would add PCM or control type plugins. It might sound a little naive but I am not familiar with the framework part of it, but it looks interesting.
1. I think for finding out what the plugin framework would consists of I need to have a look at alsa-lib and modify it too, is it correct?. If such a framework is created then
will the control flow look like this:
amidi/aplaymidi ->alsa-lib with midi plugin framework->my_midi_plugin
Can you point me to some code/doc etc which might serve as start point, basically how do I go about adding such a framework and finally, how user is going to use
it with newly added plugin? (i.e. for pcm io type plugin we use #aplay -D my_plugin test.wav, will it be similar for midi plugin also?)
-Pharaoh.