1

Context and experiments

I have a virtual MIDI device, as card #1, named VirMIDI. There are associated ALSA sequencer clients (not raw MIDI), as Virtual Raw MIDI 1-0 to Virtual Raw MIDI 1-3. There are device nodes /dev/snd/midiC1D0 to /dev/snd/midiC1D3.

A software MIDI keyboard is connected to Virtual Raw MIDI 1-0 and a sound‑font synthesizer is connect to hw:VirMIDI,0.

When I play the software keyboard, there are sounds (just to check it's OK).

I can cat the device node: if I do cat /dev/snd/midiC1D0 >data.bin and play the software keyboard, the file data.bin is filled with raw MIDI events and the synthesizer play sounds (both it and cat receives the events).

However, if I later do cat data.bin >/dev/snd/midiC1D0 nothing occurs: no errors and also no sounds, the synthesizer receives no MIDI events.

It looks like it works with read access only, although writing does not trigger an error and just seems to do nothing.

If ever this matters, although not an access to the device node proper, amidi -p hw:1,0 -s data.bin does nothing neither, while amidi -p hw:1,0 -r data.bin behaves as expected.

Question

How to write to a MIDI device node like /dev/snd/midiCnDn, with expected effects, the same way one can read from the same MIDI device node? Or is it to be used for reading only?

1

The VirMIDI driver is designed as an interface between programs that access RawMIDI devices (actually, OSS devices /dev/midi*) and ALSA sequencer clients.
Everything received at the raw MIDI device (hw:1,* or /dev/*) is sent on to the sequencer port.
Everything received at the sequencer port (Virtual Raw MIDI 1-*) is sent on to the raw MIDI device.

To connect multiple raw MIDI devices, you need to go through multiple sequencer ports:

+-------+       +--------+----------------------+
| synth |  <--  | hw:1,0 | Virtual Raw MIDI 1-0 |  <-+
+-------+       +--------+----------------------+    |
                                                     |aconnect
+-----+         +--------+----------------------+    |
| cat |    -->  | hw:1,1 | Virtual Raw MIDI 1-1 |  --+
+-----+         +--------+----------------------+
  • It seems to depend on the order of the operations. If I disconnect everything, then connect the synthesizer to hw:1,1 first, I have to do the other way, connect Virtual Raw MIDI 1-0 to Virtual Raw MIDI 1-1 and write to hw:1,0. I guess the communication though a device node is one way only, and it is decided after the first connection made to the node. – Hibou57 Jun 7 '15 at 19:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.