-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make MIDI keyboards "just work" #261
Comments
Maybe @hselasky knows? |
Hi, USB MIDI keyboards in FreeBSD are RAW and do not go through the sequencer infrastructure for various reasons. I think portaudio doesn't scan for these devices. Technically they should work just fine with any application, as long as they detect properly. Usually when starting synths, I just override the default MIDI device. ZynAddSubFX example: env MIDI_DEVICE=/dev/umidiX.X zynaddsubfx -I OSS ........ There is also a small tool to wrapper for FreeBSD USB MIDI devices into ALSA: https://github.com/hselasky/alsa-seq-server Else "jack_umidi" is frequently used. Feel free to submit patches. Many people use JACK for more advanced setups, but patching portaudio to recognize /dev/umidi* would be great too. --HPS |
Thanks @hselasky, very helpful. I should add that I am not using JACK because it is way too complex for "normal users" in my opinion. I am also not using ALSA because it, too, adds complexity (albeit less). Hence I am interested in a "plan FreeBSD sound" solution, which I assume is OSS.
At this point I a wondering 2 things:
What I am after is the user experience on the Mac: You plug in a MIDI keyboard, open GarageBand, and it "just works". If possible I would like to make things equally easy on helloSystem. Thanks for any pointers, they are very helpful since I know nothing about this and searching in the FreeBSD handbook also didn't enlighten me. |
Try to add "-O OSS". Shouldn't need jackd.
Not all applications support this environment variable.
"/dev/midi" is the OSS compatible sequencer global interface. USB MIDI devices are not hooked up there. They simply create a per-device character device, which transport raw MIDI.
Sure. I use them every week. I use "midipp" from ports to route and re-direct all MIDI events between applications. If you want to use fluidsynth I think to you need to use the ALSA MIDI backend or possibly also jackd will work.
Most programs come from Linux and are integrated there. Then the compatibility options are very few: Either you patch the program to support MIDI_DEVICE= or you use JACKD or you use ALSA MIDI.
I see. On Mac there is only one MIDI API, so that makes it easier for everyone. In FreeBSD and Linux there are multiple ones. Maybe what we need is some kind of libmidi library in FreeBSD and a midi server which can route events. That is exactly what ALSA MIDI does and my simplified daemon at github. It even can redirect MIDI via wine that way.
Sure. I hope you got a satisfying answer. BTW: I have some youtube videos which show how I use MIDI on FreeBSD. Just search for hselasky on YouTube. |
I can confirm that I see data (gibberish) coming in on First thing I do see this: I hope this means progress. Can I use this to "route events" (meaning MIDI data) to applications such as MuseScore, fluidsynth/QSynth and the like?
Meaning |
D'oh! At least for fluidsynth the solution is really simple:
So a first step would probably be to just put this symlink in place by default on helloSystem. |
You should check if /dev/midi is already there, else you will get a kernel panic when the system tries to create such a device. MidiPP can route MIDI events, but the best would be to implement a midi server for FreeBSD of some kind, so that the same midi device can be used by multiple applications. By MIDI server I mean: You see, sometimes applications want to serve MIDI data aswell, and then you need a server to do that. I wonder if sndio also does something similar, but I didn't check yet. Are you interested in doing some work in this area? |
I just put the ALSA MIDI sequencer server into FreeBSD ports: I would recommend this over JACKD if you need low latency. |
@mekanix : FYI |
I'm very interested in doing some work on this. I think I mentioned (maybe even few years back) I would enjoy having something like virtual_midi resembling virtual_oss, so I'm in. @hselasky just create repo somewhere and mention it here for reference. |
Yes, I would like the last plugged in MIDI device to be symlinked to
Yes, I understand. I was trying to send MIDI commands to
Is the ALSA MIDI server related to the ALSA stack in any way other than the name?
Is this what I was calling an "OSS MIDI server"? |
This won't work when you have multiple MIDI devices. Attaching or removing any MIDI device will mess with /dev/midi :-(
Yes, /dev/umidiX.Y can only be opened once. You got it.
The ALSA MIDI API is supported by libasound.so . It is a separate API from the audio interface.
The ALSA MIDI sequencer server is already BSD licensed, so I would recommend going down that route instead of re-inventing the wheel. Why do we need yet another MIDI API? There is a manual page "man alsa-seq-server" which explains some examples how to use it. It also supports hot-plug of MIDI devices. Basically you just pre-specify the device names, and then the alsa-seq-server will automagically attach / detach. This can be improved, but I'd like to have some help on that. --HPS |
Regarding LMMS, opened a ticket upstream: |
As one step toward making MIDI keyboards "just work" on helloSystem, I wonder whether we need to start some daemon(s) whenever we detect a new Apparently as soon as we run e.g., jack_umidi, the device becomes unavailable for other sound systems:
So we need a way for umidi-supporting applications like fluidsynth, and for jack_umidi and alsa-seq-server (and possibly even more sound systems like PulseAudio, Pipewire and whatnot) to listen to the MIDI messages all at the same time. Can't be that hard, can it? For it to make any kind of difference, though, all ports and packages in FreeBSD would need to have JACK and PulseAudio support enabled, which currently seems not to be the case at least for MuseScore and LMMS. On the Mac, you open GarageBand, plug in the USB MIDI keyboard (yes, even in this order) and a dialog will say that a new MIDI controller has been found and is now available. You can start playing right away. No fiddling around! This is our benchmark. The whole MIDI situation in FreeBSD is currently really frustrating because "nothing works" plug and play (similar to how Xorg felt over 20 years ago). Can we fix it? |
As for MuseScore: It seems like no one has systematically tested whether MIDI keyboards work with the music applications in FreeBSD ports and packages? https://www.freshports.org/audio/musescore/ suggests that ALSA, JACK, and PulseAudio are all disabled.
So how is MuseScore supposed to work with hardware MIDI controllers as inputs on FreeBSD using PortAudio? What does the user have to do to make it work? Or is using hardware MIDI controllers via PortAudio simply broken altogether? |
Hi, I made some improvements to alsa-seq-server , including an rc.d file: https://cgit.freebsd.org/ports/commit/?id=75a7c03777f8a809a35ebaa04c2cbf716a11f656 --HPS |
Hello @hselasky, does this mean that when it is started as a service, then alsa-seq-server will handle all umidi devices? Also those plugged in after alsa-seq-server started? |
@probonopd : Yes. It will consume all /dev/umidi devices. |
Very cool. Thank you so much @hselasky. This will make things easier! |
@probonopd : Some updates. Make sure you get the latest version from FreeBSD ports as of today. |
@probonopd : Maybe we can do some investigation which ports should have ALSA MIDI enabled by default. |
@mekanix : FYI |
fluidsynth has a special mode where it can run as a server, but only when using ALSA MIDI. Not sure if they support JACK. midipp has also been updated to support ALSA MIDI. --HPS |
@hselasky your change to
When I now do the following:
then I can successfully click on the "gears" icon e.g., next to TripleOscillator, and select my MIDI keyboard as an input. And it does work! I am now thinking of enabling the But will this break applications like
man fluidsynth just says
unfortunately without any explanation what "server process" means in this context. I was assuming that this means it will run as a background daemon, but it might mean something completely different altogether. |
This post will be updated as we find more applications.
I checked all
Then I checked which ones of those reference
Looks like we have to search even outside of the
|
The -s option basically means start an ALSA client. You'll see fluidsynth show up in "aconnect -l" |
audio/midipp also works with ALSA now. |
Could we iuse this to get support for WebMIDI into browsers on FreeBSD? |
Trying to send MIDI to a USB MIDI device using
|
What does dmesg say about your MIDI device? Is jack_umidi installed? If yes, then uninstall or disable. Is alsa-seq-server running (the latest version and default arguments)? --HPS |
No
1.0.8
|
Just stumbled about this by @hselasky:
@hselasky: Could you please elaborate how to get WINE to work with MIDI on FreeBSD using alsa-seq-server? That would be awesome! It would be the key to running REAPER with MIDI support on FreeBSD, which I am sure would make a lot of people very happy! |
Edit the Makefile for "emulators/wine/Makefile" : Under "CONFIGURE_ARGS" replace:
Then rebuild. You probably can narrow down the ALSA support to only do MIDI however. Not sure if you can use both. |
Do you see any chance to make this change the default so that binary packages will support MIDI? |
If it works and doesn't conflict with OSS support, maybe a config option to switch it would be OK? Last time I tried this, Wine Audio was a bit too slow to driver low latency audio ... |
It would be great @hselasky. Last time I tried to compile WINE on Cirrus CI the build was cancelled after many hours. I don't have a local powerful build machine. So it would be nice if there was a WINE package flavor in pkg that would support ALSA. Can it be made so that ALSA is only used for the MIDI portion? (Or can you think of another way to teach it MIDI on FreeBSD?) |
Similarly, it would be nice if |
Chromium shows a keyboard symbol in the URL bar but access to MIDI devices (used by, e.g., https://www.synthmata.com/volca-fm/) doesn't seem to work. Is it missing support for ALSA Sequencer? |
@probonopd : Chromium can be re-compiled with ALSA instead of OSS. Will likely work then. --HPS |
Would be great to have it enabled by default in the port or have a package flavor for it then, too. Compiing huge applications like WINE or Chromium will probably take days on the kinds of hardware I have available ;-) |
@hselasky https://cgit.freebsd.org/ports/commit/?id=ce1e733047cfa6bdea3d1bfb767814c7fa2a9809 is great but who would need to do what so that one can Also, if non-ALSA sound is lower latency, how could we use OSS sound with |
Compiled WINE locally as suggested above. Took under an hour, so much better than I had feared. However, running into:
|
Yikes, forgot to update the pkg-plist in the patch. |
Try this patch: Or just update the ports tree to the very latest from GIT! |
Wait, are you saying I don't need to do |
https://github.com/freebsd/freebsd-ports portsnap fetch update should do it now I guess. Remember only wine-devel is patched in upstream. |
|
Try: make MAKE_JOBS_UNSAFE=yes Maybe your system is out of memory. --HPS |
Some things are just strage. I built wine on this machine the other day. Now it hangs on
Hence I hope one day the ALSA version of WINE will be in pkg. |
I'm so happy this software I made finally became useful to someone! |
Thank you so much @hselasky, this is very, very useful! |
Finally I succeeded getting REAPER (as an example) to work properly with a MIDI USB keyboard. Procedure:
Results in ~14/11ms delay on my 11th gen Intel CPU Framework Laptop. I further installed
Some plugins require
To make it more convenient to launch WINE,
Finally, I can use FreeBSD to make music! So happy. Thanks again @hselasky. Note to self. |
Thank you for kind words :-) |
Ableton Live 11 also running nicely with MIDI keybord. |
Dexed (standalone app) built from FreeBSD Ports (so, no WINE there) also running nicely with MIDI keybord, so all JUCED based ones should work nicely. The |
But when I try to play in LMMS or MuseScore it does not work.
Why?
Do we need something utterly complicated like JACK just to make the keyboard work?
The text was updated successfully, but these errors were encountered: