lmms icon indicating copy to clipboard operation
lmms copied to clipboard

Cannot use external midi controllers under FreeBSD

Open probonopd opened this issue 3 years ago • 18 comments

Bug Summary

Cannot use external midi controllers under FreeBSD even though the messages do show up on /dev/umidi0.0.

Trying to follow https://www.youtube.com/watch?v=YVXp4JdFaGU but it seems not to work like this on FreeBSD.

Can OSS Raw MIDI not using /dev/umidi*.0 (e.g., linked to /dev/midi) on FreeBSD?

A search turns up https://lists.freebsd.org/pipermail/freebsd-multimedia/2011-September/012431.html

So I was looking for midi software that could work with a midi keyboard on an usb midi interface (snd_uaudio, /dev/umidi0.0), and found that at least both rosegarden and musescore only know alsa seq interfaces (which we don't have nor emulate on FreeBSD), not raw midi (I'm not sure there's a difference between alsa raw midi and oss raw midi) I then found audio/lmms which appears to support oss midi, but couldn't get it to work with my interface

Unfortunately with no clear answer.

Steps to reproduce

  1. Run FreeBSD (e.g., the helloSystem Live ISO) and install LMMS [not running jackd, just the plain FreeBSD sound system]
  2. Attach external midi controller
  3. Verify that the midi controller works; for example with sudo ln -sf /dev/umidi*.0 /dev/midi ; fluidsynth -m oss -a oss path_to/some.sf2. Verify that you can hear sound as you operate the controller. This proves that the USB MIDI controller messages appear correctly on /dev/midi. Then quit fluidsynth
  4. Start LMMS
  5. Preferences -> MIDI image
  6. In the TripleOscillator track, select MIDI -> Input (note that no USB devices are shown here, is this normal?) image
  7. Play on the controller.
  8. Is it necessary to do anything here? Not clear! image

Expected behavior

You hear sound in LMMS and see activity.

Actual behavior

You hear nothing in LMMS and see no activity.

Screenshot

Affected LMMS versions

1.2.2 on FreeBSD 13.0-RELEASE (helloSystem 0.7.0)

Logs

Click to expand

probonopd avatar Jan 09 '22 15:01 probonopd

6 is not normal. LMMS doesn't appear to be able to detect your MIDI keyboard. Unclear if this is OS-specific or controller specific, as some controllers may give issues.

What is supposed to happen: when you hover on input button ("eingang"), it should show another drop-down. image

when you hover on input button ("eingang"), it should show another drop-down, like it shown on output ("ausgang"):

image

In this list, except for input, your MIDI keyboard should show up.

Monospace-V avatar Jan 09 '22 15:01 Monospace-V

As a workaround, is there a way to tell it to just use whatever MIDI messages appear on /dev/midi and not worry about which USB device actually is responsible for sending them there?

probonopd avatar Jan 09 '22 17:01 probonopd

Usually we just use jack_umidi from ports, but would be great to support native devices too.

hselasky avatar Jan 09 '22 18:01 hselasky

I'm also pointing out: https://github.com/hselasky/alsa-seq-server/ which converts any FreeBSD USB MIDI device into an native ALSA device.

hselasky avatar Jan 09 '22 20:01 hselasky

Thanks @hselasky. How do https://github.com/hselasky/jack_umidi and/or https://github.com/hselasky/alsa-seq-server/ work with lmms? I can't seem to find a README. (I wanted to avoid jackd because it is not plug-and-play and alsa because i fear it adds latency and both are not "the native FreeBSD sound system". But at this point I will use anything that makes my keyboard work with LMMS.)

probonopd avatar Jan 09 '22 21:01 probonopd

Hi,

ALSA is event driven and has very little latency. JACK is polling based and has more latency.

pkg install jack_umidi man jack_umidi

pkg install alsa-seq-server man alsa-seq-server

--HPS

hselasky avatar Jan 09 '22 22:01 hselasky

Thanks @hselasky.

So I did:

ls /dev/*midi*
# /dev/umidi1.0
sudo alsa-seq-server -d /dev/umidi1.0
ls /dev/*seq* 
# /dev/sequencer0

However, no change on the LMMS side. The USB keyboard is not showing up in the MIDI Input menu and LMMS stays silent when keys are pressed.

I fear that (USB) MIDI does not work at with LMMS on FreeBSD. Does anyone know for sure?

Looks like I am not the only one who is having trouble:

https://www.bsdforen.de/threads/freebsd-als-daw.36233/

Bei Lmms gibt es zwar die MIDI option über OSS, aber das Funktioniert nicht.

With Lmms there is the MIDI option via OSS, but this does not work.

https://mailing.freebsd.multimedia.narkive.com/lrXIx5O6/using-a-midi-keyboard-with-freebsd-jack-update-ardour3-alpha

So I was looking for midi software that could work with a midi keyboard on an usb midi interface (snd_uaudio, /dev/umidi0.0), (...) audio/lmms which appears to support oss midi, but couldn't get it to work with my interface

Even when using JACK (which I try to avoid because it is the opposite of "plug and play"), it seems to not work:

https://forums.freebsd.org/threads/how-to-test-usb-midi.74484/

As a regular user i could start jackd &jack_umidi via (...) Now I need something with gives a midi RX in qjackctl in order to connect. (lmms) is not shown. Why?

So before I spend much more time fiddling around it would be great to hear from someone who actually managed to use a USB MIDI controller with LMMS on FreeBSD, because at this point I am not sure whether it can even work at all.

probonopd avatar Jan 15 '22 11:01 probonopd

So to be clear: All I am looking for is LMMS use the MIDI information that is clearly showing up in /dev/umidi0.0:

FreeBSD% midicat -d -q rmidi/0.0 -o /dev/null
90 3c 4e
90 40 55
90 43 49
90 43 00
90 3c 00
90 40 00

probonopd avatar Jan 15 '22 12:01 probonopd

Did you use aconnect to connect LMMS and the MIDI device?

hselasky avatar Jan 16 '22 11:01 hselasky

When I do

sudo pkg install alsa-utils

aconnect -i
# client 0: 'M-Audio Keystati #0' [type=Kernel]
#    0 'port-0 

aconnect -o
# client 0: 'M-Audio Keystati #0' [type=Kernel]
#    0 'port-0

how can I "connect LMMS and the MIDI device"?

Note that I do not see "ALSA-Sequencer" in this dropdown menu in LMMS:

image

There is only one choice in the dropdown menu (the one that is shown in the screenshot).

probonopd avatar Jan 16 '22 16:01 probonopd

Was the ALSO support compiled out, or perhaps under some ifdef's in the code. OSS RAW midi is not ALSA.

Also check the permissions of the character devices.

hselasky avatar Jan 16 '22 21:01 hselasky

I installed the official FreeBSD binary package with sudo pkg install -y lmms. So if I am not mistaken, only OSS is compiled in:

https://github.com/freebsd/freebsd-ports/blob/ca43d5d0b0edcfddff72556b3ff38fbf5aed87e1/audio/lmms/Makefile#L49-L50

OPTIONS_DEFINE=		OSS JACK PULSEAUDIO PORTAUDIO SDL SNDIO
OPTIONS_DEFAULT=	OSS

There is also CMAKE_OFF=WANT_ALSA in:

https://github.com/freebsd/freebsd-ports/blob/ca43d5d0b0edcfddff72556b3ff38fbf5aed87e1/audio/lmms/Makefile#L45-L46

It looks like we have two separate issues that, together, effectively prevent MIDI keyboards from working in LMMS on FreeBSD:

  • MIDI keyboards apparently do not work with OSS in LMMS (at least I could not get it to work after a lot of trial and error) - this probably needs to be addressed in the LMMS project (here)
  • The FreeBSD LMMS port and package seems to have all sound systems except OSS disabled (especially, ALSA) - this should probably be addressed by the FreeBSD LMMS port maintainers

Ideally, both issues would be addressed.

I am still wondering why LMMS cannot "just" use the raw MIDI messages from /dev/umidi0.0 directly without any special sound system in between. Seems the least complicated to me. Is this what the "OSS" option is supposed to do?

probonopd avatar Jan 17 '22 21:01 probonopd

The FreeBSD LMMS port and package seems to have all sound systems except OSS disabled (especially, ALSA) - this should probably be addressed by the FreeBSD LMMS port maintainers

I can confirm that recompiling LMMS from FreeBSD Ports with the following change regarding WANT_ALSA in the Makefile allows one to use alsa-seq-server to talk to MIDI controllers:

CMAKE_OFF=      WANT_CALF WANT_CAPS WANT_CMT WANT_SWH WANT_STK \
                WANT_TAP WANT_VST
CMAKE_ON=       WANT_QT5 WANT_ALSA

Run make clean ; make config ; make to define which of the supported sound systems and MIDI interfaces will be available. LMMS can support the following MIDI interfaces on FreeBSD if it is configured accordingly at compile time: ALSA, OSS, Sndio, JACK. The ALSA one is known to work. Unfortunately it is not enabled in the binary package shipped in FreeBSD packages.

To use it, select "ALSA-Sequencer (Advanced Linux Sound Architecture)" from the MIDI interface dropdown menu in the MIDI pane of the LMMS settings, restart ALSA, click on the gear icon e.g., in the TripleOscillator track, and select MIDI -> Input -> 0:0 (name of your USB device).

If you see

ALSA lib seq_hw.c:466:(snd_seq_hw_open) open /dev/snd/seq failed: No such file or directory
cannot open sequencer: No such file or directory

when you start LMMS, then most likely sudo alsa-seq-server -d /dev/umidi* is not running (see above).

probonopd avatar Jan 18 '22 18:01 probonopd

It might be possible for alsa-seq-server itself to scan for all midi devices regularly and automatically attach to them. Feel free to contribute patches. Also an rc.d file would be great.

--HPS

hselasky avatar Jan 19 '22 15:01 hselasky

@probonopd Could you test if #6276 fixes this?

PhysSong avatar Jan 22 '22 03:01 PhysSong

@probonopd #6276 is merged. Waiting for your reply.

PhysSong avatar Jan 29 '22 06:01 PhysSong

@hselasky do you know how to change the Makefile for the FreeBSD port to compile this from master? Sorry I am still new to Ports

probonopd avatar Jan 29 '22 13:01 probonopd

We just upgraded our Linux CI to Ubuntu 20.04 in #7015, so it might be worth checking if this issue still exists in nightly.

Also, Sndio is now available as a midi/audio interface in nightly.

messmerd avatar May 08 '24 19:05 messmerd