RomanKubiak / ctrlr

Ctrlr
BSD 3-Clause "New" or "Revised" License
518 stars 60 forks source link

Opening MIDI devices on Linux always fails. Fix inside #492

Open lkamp opened 1 year ago

lkamp commented 1 year ago

I built from source on Arch Linux, version 5.6.0, downloaded from the GitHub releases page.

Opening a MIDI device always failed. I fixed the issue by changing CtrlrMIDIDevice.cpp line 54 from

outJucePtr = MidiOutput::openDevice (getProperty(Ids::midiDevIndex).toString()).release();

to

outJucePtr = MidiOutput::openDevice ((int)getProperty(Ids::midiDevIndex)).release();

Same thing has to be done on line 75 to open MIDI input.

This was only tested on current version of Arch Linux. No guarantee that it works on all platforms.

keinstein commented 1 year ago

Actually Midi Ports are two dimensional in Linux (ALSA) and each dimension may change independently. Flat port numbers change as soon as a device with a lower ALSA device number will change its number of ports. This may happen more often with software MIDI devices. The string representation is slightly better.

keinstein commented 1 year ago

You could try outJucePtr = MidiOutput::openDevice (getProperty(Ids::midiDevId).toString()).release(); and

inJucePtr = MidiInput::openDevice (getProperty(Ids::midiDevId).toString(), this).release();

midiDevId is implemented in https://github.com/keinstein/ctrlr/tree/dehnhardt_midichanges which is based on https://github.com/RomanKubiak/ctrlr/pull/151 Could you try it, please? If @dehnhardt agrees I could make a pull request for that.

dehnhardt commented 1 year ago

I don't mind.