spell-music / csound-expression

Haskell Framework for Electronic Music
323 stars 31 forks source link

please explain MIDI routing #51

Open jwaldmann opened 6 years ago

jwaldmann commented 6 years ago

The documentation (Patches.md) says ".. way we can play the patches with real MIDI-device:"

dac $ mul 0.75 $ atMidi toneWheelOrgan

but on my machine this fails with

ALSA midi: Using all devices.
ALSA lib rawmidi_hw.c:233:(snd_rawmidi_hw_open) open /dev/snd/midiC2D0 failed: Device or resource busy
ALSA: error opening MIDI input device: 'hw:2,0'
ALSA midi: Error opening device: hw:2,0
ALSA midi: No devices found.

How is this supposed to work? I was expecting that some midi port shows up (e.g., in aplaymidi -l) so that I can route signals there from qjackctl.

(EDIT) some more data: I have a (USB) MIDI keyboard (Akai LPK 25) attached to the computer:

aplaymidi -l
 Port    Client name                      Port name
 14:0    Midi Through                     Midi Through Port-0
 24:0    LPK25                            LPK25 MIDI

amidi -l
Dir Device    Name
IO  hw:2,0,0  LPK25 MIDI 1

But I am still getting:

dacBy (setMidiDevice "hw:2,0,0") $ osc 200
...
ALSA lib rawmidi_hw.c:233:(snd_rawmidi_hw_open) open /dev/snd/midiC2D0 failed: Device or resource busy
ALSA: error opening MIDI input device: 'hw:2,0,0'
anton-k commented 6 years ago

I think that we need to research on how to setup the Csound flags

https://csound.com/docs/manual/CommandFlagsCategory.html

See the section: MIDI Realtime Input/Ouput

I'm myself trying various options.. till I find something that works Sometimes it helps to stop ALSA Midi bridge in the cadence

anton-k commented 6 years ago

Maybe you need to add -+rtmidi=alsa if you are referring to device by hw:CARD,DEVICE

options = def { rtmidi = Just AlsaMidi } <> setMidiDevice "hw:2,0,0"
jwaldmann commented 6 years ago

Not AlsaMidi, but AlsaSeq. The following sort-of-works:

dacBy ( def {csdFlags = def { rtmidi = Just AlsaSeq  }} ) $ midi $ \ m -> return  $ osc $ sig $ cpsmidi m

when I run this, qjackctl (in the ALSA tab) shows an input port "129:Csound", where I can send MIDI signals to.

It's slightly annoying that that the port disappears after cancelling dacBy (from ghci), so I have to re-route the external keyboard each time.

anton-k commented 6 years ago

I think this is not the issue of CE. It's issue of Linux+midi workflow. Mayb some system-wide midi settings are not csound-friendly

jwaldmann commented 6 years ago

Yes of course. Still, perhaps some other CE user knows how to handle this. But feel free to close the issue.