Skip to content
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

Open
probonopd opened this issue Jul 24, 2021 · 75 comments
Open

Make MIDI keyboards "just work" #261

probonopd opened this issue Jul 24, 2021 · 75 comments
Labels
bug Something isn't working

Comments

@probonopd
Copy link
Member

probonopd commented Jul 24, 2021

dmesg
ugen4.6: <M-Audio Keystation Mini 32 MK3> at usbus4
uaudio0 on uhub12
uaudio0: <M-Audio Keystation Mini 32 MK3, class 0/0, rev 1.11/1.11, addr 5> on usbus4
uaudio0: No playback.
uaudio0: No recording.
uaudio0: MIDI sequencer.
uaudio0: No HID volume keys found.

ls /dev/ | grep umidi
umidi0.0

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?

@probonopd probonopd added the bug Something isn't working label Jul 24, 2021
@probonopd
Copy link
Member Author

image

It says nothing about "MIDI Input"...

@probonopd
Copy link
Member Author

Maybe @hselasky knows?

@hselasky
Copy link

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

@probonopd
Copy link
Member Author

probonopd commented Jul 26, 2021

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.

  • env MIDI_DEVICE=/dev/umidiX.X zynaddsubfx -I OSS compains about missing jackd
  • (sudo) env MIDI_DEVICE=/dev/umidi0.0 musescore does not make the MIDI keyboard work in MuseScore
  • sudo qsynth -a oss, when configured to use OSS instead of jackd, is complaining about missing /dev/midi (where is this supposed to come from?)

image

At this point I a wondering 2 things:

  1. Is using MIDI devices with OSS on FreeBSD even possible?
  2. Is this documented somewhere?

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.

@hselasky
Copy link

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.

* `env MIDI_DEVICE=/dev/umidiX.X zynaddsubfx -I OSS` compains about missing jackd

Try to add "-O OSS". Shouldn't need jackd.

* `(sudo) env MIDI_DEVICE=/dev/umidi0.0 musescore` does not make the MIDI keyboard work in MuseScore

Not all applications support this environment variable.

* `sudo qsynth -a oss`, when configured to use OSS instead of jackd, is complaining about missing `/dev/midi` (where is this supposed to come from?)

"/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.

image

At this point I a wondering 2 things:

1. Is using MIDI devices with OSS on FreeBSD even possible?

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.

2. Is this documented somewhere?

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.

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.

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.

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.

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.

@probonopd
Copy link
Member Author

probonopd commented Jul 27, 2021

I can confirm that I see data (gibberish) coming in on sudo cat /dev/umidi0.0 when I press keys on the MIDI keyboard.

First thing sudo midipp does is also complain Could not connect to the JACK subsystem! (which I am not using at all).

I do see this:

image

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?

my simplified daemon at github

Meaning midipp?

@probonopd
Copy link
Member Author

D'oh! At least for fluidsynth the solution is really simple:

sudo ln -s /dev/umidi0.0 /dev/midi
fluidsynth -m oss -a oss ~/Desktop/MuseScore_General.sf2

So a first step would probably be to just put this symlink in place by default on helloSystem.

@hselasky
Copy link

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.
The best would be to patch fluidsynth to take the devicename somehow.
You maybe also need to add a devfs rule for the umidi* devices, to change permissions or ownership.

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:
https://github.com/hselasky/alsa-seq-server

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?

@hselasky
Copy link

hselasky commented Aug 2, 2021

I just put the ALSA MIDI sequencer server into FreeBSD ports:
https://cgit.freebsd.org/ports/commit/?id=a3c9b320dbc478af1dbd3339e9d5f1925204fc5a

I would recommend this over JACKD if you need low latency.

@hselasky
Copy link

hselasky commented Aug 2, 2021

@mekanix : FYI

@mekanix
Copy link

mekanix commented Aug 2, 2021

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.

@probonopd
Copy link
Member Author

You maybe also need to add a devfs rule for the umidi* devices, to change permissions or ownership.

Yes, I would like the last plugged in MIDI device to be symlinked to /dev/midi with permissions that allow everyone to use it. What is the best way to do this?

the best would be to implement a midi server for FreeBSD of some kind

Yes, I understand. I was trying to send MIDI commands to /dev/midi while fluidsynth was using it, but it did not let me to. I guess this is where the MIDI server would come in.

I just put the ALSA MIDI sequencer server into FreeBSD ports

Is the ALSA MIDI server related to the ALSA stack in any way other than the name?
Would an "OSS MIDI server" look different?

I would enjoy having something like virtual_midi resembling virtual_oss, so I'm in.

Is this what I was calling an "OSS MIDI server"?

@hselasky
Copy link

hselasky commented Aug 3, 2021

You maybe also need to add a devfs rule for the umidi* devices, to change permissions or ownership.

Yes, I would like the last plugged in MIDI device to be symlinked to /dev/midi with permissions that allow everyone to use it. What is the best way to do this?

This won't work when you have multiple MIDI devices. Attaching or removing any MIDI device will mess with /dev/midi :-(

the best would be to implement a midi server for FreeBSD of some kind

Yes, I understand. I was trying to send MIDI commands to /dev/midi while fluidsynth was using it, but it did not let me to. I guess this is where the MIDI server would come in.

Yes, /dev/umidiX.Y can only be opened once. You got it.

I just put the ALSA MIDI sequencer server into FreeBSD ports

Is the ALSA MIDI server related to the ALSA stack in any way other than the name?

The ALSA MIDI API is supported by libasound.so . It is a separate API from the audio interface.

Would an "OSS MIDI server" look different?

I would enjoy having something like virtual_midi resembling virtual_oss, so I'm in.

Is this what I was calling an "OSS MIDI server"?

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

@probonopd
Copy link
Member Author

probonopd commented Jan 9, 2022

Regarding LMMS, opened a ticket upstream:
LMMS/lmms#6263

@probonopd
Copy link
Member Author

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 /dev/umidi* device node (e.g., using devd). Similar to what automount does for disks. For example, we could start jack_umidi -C /dev/umidi* each time such a device node appears. Possibly we would need to do the same for alsa-seq-server -d /dev/umidi*?

Apparently as soon as we run e.g., jack_umidi, the device becomes unavailable for other sound systems:

FreeBSD% sudo ln -sf /dev/umidi*.0 /dev/midi

FreeBSD% fluidsynth -m oss -a oss dx7/AR\ DX7\ Clean\ Analog.sf2
/dev/midi: Device busy
Failed to create the MIDI thread; no MIDI input
will be available. You can access the synthesizer 
through the console.

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?

@probonopd
Copy link
Member Author

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.

===> The following configuration options are available for musescore-3.6.1_2:
     ALSA=off: ALSA audio architecture support
     JACK=off: JACK audio server support
     PORTAUDIO=on: PortAudio library support
     PULSEAUDIO=off: PulseAudio sound server support
     WEBENGINE=on: Use WebEngine in the welcome panel

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?

@hselasky
Copy link

Hi,

I made some improvements to alsa-seq-server , including an rc.d file:

https://cgit.freebsd.org/ports/commit/?id=75a7c03777f8a809a35ebaa04c2cbf716a11f656

--HPS

@probonopd
Copy link
Member Author

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?

@hselasky
Copy link

@probonopd : Yes. It will consume all /dev/umidi devices.

@probonopd
Copy link
Member Author

Very cool. Thank you so much @hselasky. This will make things easier!

@hselasky
Copy link

@probonopd : Some updates. Make sure you get the latest version from FreeBSD ports as of today.

@hselasky
Copy link

@probonopd : Maybe we can do some investigation which ports should have ALSA MIDI enabled by default.

@hselasky
Copy link

@mekanix : FYI

@hselasky
Copy link

D'oh! At least for fluidsynth the solution is really simple:

sudo ln -s /dev/umidi0.0 /dev/midi
fluidsynth -m oss -a oss ~/Desktop/MuseScore_General.sf2

So a first step would probably be to just put this symlink in place by default on helloSystem.

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

@probonopd
Copy link
Member Author

probonopd commented Jan 28, 2022

@hselasky your change to alsa-seq-server works for me, and indeed does improve things a lot in terms of plug-and-play "it just works":

# Become root
sudo su

# Update ports tree
portsnap fetch update
# Updating from Tue Jan 18 09:48:36 CET 2022 to Fri Jan 28 17:05:19 CET 2022.

# Go to alsa-seq-server port
cd /usr/ports/audio/alsa-seq-server

# Install all build dependencies for this port
make build-depends-list | cut -c 12- | xargs pkg install -y

# Build the port, make a package, and install it
make
make package
pkg add -f ./work/pkg/alsa-seq-server-1.0.5.pkg

# Start the alsa-seq-server process
service alsa_seq_server onestart

When I now do the following:

  • Attach MIDI keyboard via USB to the computer
  • Launch a self-compiled version (not the one from FreeBSD packages) of lmms with ALSA support enabled
  • Select "ALSA Sequencer" in the lmms settings
  • Restart lmms

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 alsa_seq_server service by default on helloSystem (the reasoning is: helloSystem should be plug-and-play, JACK is not plug-and-play and people who can configure JACK can probably figure out what they need to change).

But will this break applications like fluidsynth?

fluidsynth has a special mode where it can run as a server, but only when using ALSA MIDI. Not sure if they support JACK.

man fluidsynth just says

  -s, --server
    Start FluidSynth as a server process

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.

@probonopd
Copy link
Member Author

probonopd commented Jan 28, 2022

@probonopd : Maybe we can do some investigation which ports should have ALSA MIDI enabled by default.

This post will be updated as we find more applications.

  • audio/lmms (known to work with alsa-seq-server if compiled with ALSA)
  • audio/musescore (see below)
  • audio/midipp (see below)
  • audio/fluidsynth

I checked all audio ports that contain "ALSA" in their Makefile:

FreeBSD% find audio -name Makefile -exec grep -H -r "ALSA" {} \; | cut -d ":" -f 1 | sort | uniq

Then I checked which ones of those reference midi in their source code. This gives the following candidates, in addition to the already known ones above:

  • audio/ecasound
  • audio/hydrogen
  • audio/kmix
  • audio/linuxsampler
  • audio/muse-sequencer
  • audio/ocp
  • audio/pd
  • audio/qmidinet
  • audio/qtractor
  • audio/wildmidi
  • audio/zmusic
  • audio/zynaddsubfx

Looks like we have to search even outside of the audio/ ports directory:

  • emulators/wine (see below)
  • ...

@hselasky
Copy link

But will this break applications like fluidsynth?
Not at all.

The -s option basically means start an ALSA client. You'll see fluidsynth show up in "aconnect -l"

@hselasky
Copy link

audio/midipp also works with ALSA now.

@probonopd
Copy link
Member Author

Compiled MuseScore with ALSA support from Ports. Can select ALSA but keybord input does not seem to work. Maybe something more needs to be changed in the MuseScore port?

image

@probonopd
Copy link
Member Author

Could we iuse this to get support for WebMIDI into browsers on FreeBSD?
E.g., to use things like https://www.webaudiomodules.org/wamsynths/webdx7/.

@probonopd
Copy link
Member Author

Trying to send MIDI to a USB MIDI device using amidi, but:

FreeBSD% sudo amidi -l 
no sound card found

@hselasky
Copy link

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

@probonopd
Copy link
Member Author

What does dmesg say about your MIDI device?

ugen5.2: <TinyUSB TinyUSB Device> at usbus5
uaudio1 on uhub5
uaudio1: <TinyUSB TinyUSB Device, class 0/0, rev 2.00/1.00, addr 2> on usbus5
uaudio1: No playback.
uaudio1: No recording.
uaudio1: MIDI sequencer.
uaudio1: No HID volume keys found.

Is jack_umidi installed?

No

Is alsa-seq-server running (the latest version and default arguments)?

1.0.8

FreeBSD% ps ax | grep midi
 267  -  S<s    0:01,48 /usr/local/sbin/alsa-seq-server -B -F umidi -i 8

FreeBSD% sudo amidi -l 
Passwort: 
no sound card found

@probonopd
Copy link
Member Author

probonopd commented Apr 9, 2022

Now, if we could WINE get to recognize MIDI keyboards via ALSA, I think many people (myself included) would be very happy since it can run REAPER and Windows VSTs really well.

Just stumbled about this by @hselasky:

Then you can for example use a FIFO as interface for MIDI or a real MIDI device. Works with emulators/wine.

mkfifo /midi
chmod 0777 /midi

@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!

image

@hselasky
Copy link

hselasky commented Apr 11, 2022

Edit the Makefile for "emulators/wine/Makefile" :

Under "CONFIGURE_ARGS" replace:

                --without-alsa \
with:
                --with-alsa \

and

                --with-oss \
into:
                --without-oss \

Then rebuild. You probably can narrow down the ALSA support to only do MIDI however. Not sure if you can use both.
--HPS

@probonopd
Copy link
Member Author

Do you see any chance to make this change the default so that binary packages will support MIDI?

@hselasky
Copy link

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 ...

@probonopd
Copy link
Member Author

probonopd commented Apr 17, 2022

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?)

@probonopd
Copy link
Member Author

probonopd commented Apr 17, 2022

Similarly, it would be nice if audio/carla was built by default with ALSA support or if there was a package flavor with ALSA support so that it could benefit from the newfound MIDI plug-and-play capability that @hselasky built into audio/alsa-seq-server/ (really makes a ton of difference - the difference between a lot of fiddling and "it just works"). Maybe @urivict would consider it?

@probonopd
Copy link
Member Author

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?

image

@hselasky
Copy link

@probonopd : Chromium can be re-compiled with ALSA instead of OSS. Will likely work then.

--HPS

@hselasky
Copy link

@probonopd
Copy link
Member Author

probonopd commented Apr 21, 2022

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 ;-)

@probonopd
Copy link
Member Author

probonopd commented Apr 30, 2022

@hselasky https://cgit.freebsd.org/ports/commit/?id=ce1e733047cfa6bdea3d1bfb767814c7fa2a9809 is great but who would need to do what so that one can pkg install wine or pkg install wine-alsa and it would work with MIDI keyboards via alsa_seq_server?

Also, if non-ALSA sound is lower latency, how could we use OSS sound with alsa_seq_server just for MIDI?

@probonopd
Copy link
Member Author

Compiled WINE locally as suggested above. Took under an hour, so much better than I had feared.

However, running into:

root@FreeBSD:/usr/ports/emulators/wine # make package
===>  Building package for wine-6.0.3_2,1
pkg-static: Unable to access file /usr/ports/emulators/wine/work/stage/usr/local/lib/wine/fakedlls/wineoss.drv:No such file or directory
pkg-static: Unable to access file /usr/ports/emulators/wine/work/stage/usr/local/lib/wine/wineoss.drv.so:No such file or directory
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/emulators/wine
*** Error code 1

Stop.
make: stopped in /usr/ports/emulators/wine

@hselasky
Copy link

hselasky commented May 1, 2022

Yikes, forgot to update the pkg-plist in the patch.

@hselasky
Copy link

hselasky commented May 1, 2022

Try this patch:
https://cgit.freebsd.org/ports/commit/?id=eb5fce936ef1e4c2ff51d5064fe153d15a5f7107

Or just update the ports tree to the very latest from GIT!

@probonopd
Copy link
Member Author

Or just update the ports tree to the very latest from GIT!

Wait, are you saying I don't need to do portsnap fetch extract update but can use git instead? That'd be much quicker I guess.

@hselasky
Copy link

hselasky commented May 1, 2022

https://github.com/freebsd/freebsd-ports

portsnap fetch update

should do it now I guess. Remember only wine-devel is patched in upstream.

@probonopd
Copy link
Member Author

gcc10 -m64 -c -o tools/wrc/po.o tools/wrc/po.c -Itools/wrc -Iinclude -D__WINESRC__ -Wall -pipe -fcf-protection=none \
  -fno-stack-protector -fno-strict-aliasing -Wdeclaration-after-statement -Wempty-body \
  -Wignored-qualifiers -Winit-self -Wno-packed-not-aligned -Wshift-overflow=2 -Wstrict-prototypes \
  -Wtype-limits -Wunused-but-set-parameter -Wvla -Wwrite-strings -Wpointer-arith -Wlogical-op \
  -isystem /usr/local/include -O2 -pipe  -fstack-protector-strong -Wl,-rpath=/usr/local/lib/gcc10 -isystem /usr/local/include -fno-strict-aliasing 
gcc10 -m64 -c -o tools/wrc/utils.o tools/wrc/utils.c -Itools/wrc -Iinclude -D__WINESRC__ -Wall -pipe \
  -fcf-protection=none -fno-stack-protector -fno-strict-aliasing -Wdeclaration-after-statement \
  -Wempty-body -Wignored-qualifiers -Winit-self -Wno-packed-not-aligned -Wshift-overflow=2 \
  -Wstrict-prototypes -Wtype-limits -Wunused-but-set-parameter -Wvla -Wwrite-strings -Wpointer-arith \
  -Wlogical-op -isystem /usr/local/include -O2 -pipe  -fstack-protector-strong -Wl,-rpath=/usr/local/lib/gcc10 -isystem /usr/local/include -fno-strict-aliasing 
gcc10 -m64 -c -o tools/wrc/wpp.o tools/wrc/wpp.c -Itools/wrc -Iinclude -D__WINESRC__ -Wall -pipe -fcf-protection=none \
  -fno-stack-protector -fno-strict-aliasing -Wdeclaration-after-statement -Wempty-body \
  -Wignored-qualifiers -Winit-self -Wno-packed-not-aligned -Wshift-overflow=2 -Wstrict-prototypes \
  -Wtype-limits -Wunused-but-set-parameter -Wvla -Wwrite-strings -Wpointer-arith -Wlogical-op \
  -isystem /usr/local/include -O2 -pipe  -fstack-protector-strong -Wl,-rpath=/usr/local/lib/gcc10 -isystem /usr/local/include -fno-strict-aliasing 
gcc10 -m64 -c -o tools/wrc/wrc.o tools/wrc/wrc.c -Itools/wrc -Iinclude -D__WINESRC__ -DNLSDIR="\"/usr/local/share/wine/nls\"" \
  -DINCLUDEDIR="\"/usr/local/include\"" -DBIN_TO_NLSDIR=\"`tools/makedep -R /usr/local/bin /usr/local/share/wine/nls`\" \
  -DBIN_TO_INCLUDEDIR=\"`tools/makedep -R /usr/local/bin /usr/local/include`\" -Wall -pipe -fcf-protection=none \
  -fno-stack-protector -fno-strict-aliasing -Wdeclaration-after-statement -Wempty-body \
  -Wignored-qualifiers -Winit-self -Wno-packed-not-aligned -Wshift-overflow=2 -Wstrict-prototypes \
  -Wtype-limits -Wunused-but-set-parameter -Wvla -Wwrite-strings -Wpointer-arith -Wlogical-op \
  -isystem /usr/local/include -O2 -pipe  -fstack-protector-strong -Wl,-rpath=/usr/local/lib/gcc10 -isystem /usr/local/include -fno-strict-aliasing 
bison -o tools/wrc/parser.tab.c -d tools/wrc/parser.y
tools/wrc/parser.y: warning: 5 shift/reduce conflicts [-Wmaybe-uninitialized]
  310 |     if (end == file) end++;
      |        ^
tools/wrc/wrc.c:297:11: note: 'dir' was declared here
  297 |     char *dir;
      |           ^~~
gmake[2]: Leaving directory '/usr/ports/emulators/wine-devel/work/wine-7.7'
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/emulators/wine-devel
*** Error code 1

Stop.
make: stopped in /usr/ports/emulators/wine-devel

@hselasky
Copy link

hselasky commented May 1, 2022

Try:

make MAKE_JOBS_UNSAFE=yes

Maybe your system is out of memory.

--HPS

@probonopd
Copy link
Member Author

Some things are just strage. I built wine on this machine the other day.

Now it hangs on

root@FreeBSD:/usr/ports/emulators/wine-devel # make MAKE_JOBS_UNSAFE=yes
===>  Building for wine-devel-7.7,1
cd /usr/ports/emulators/wine-devel/work/wine-7.7 && gmake depend
gmake[2]: Entering directory '/usr/ports/emulators/wine-devel/work/wine-7.7'
tools/makedep
gmake[2]: Leaving directory '/usr/ports/emulators/wine-devel/work/wine-7.7'
gmake[2]: Entering directory '/usr/ports/emulators/wine-devel/work/wine-7.7'
bison -o tools/wrc/parser.tab.c -d tools/wrc/parser.y
tools/wrc/parser.y: warning: 5 shift/reduce conflicts [

Hence I hope one day the ALSA version of WINE will be in pkg.

probonopd added a commit that referenced this issue Nov 9, 2022
Needed for MIDI controllers, like MIDI keyboards
#261
Thanks @hselasky
@hselasky
Copy link

hselasky commented Nov 9, 2022

I'm so happy this software I made finally became useful to someone!

@probonopd
Copy link
Member Author

Thank you so much @hselasky, this is very, very useful!

@probonopd
Copy link
Member Author

probonopd commented Jan 21, 2023

Finally I succeeded getting REAPER (as an example) to work properly with a MIDI USB keyboard. Procedure:

  • Bring /usr/ports to the same commit as the packages you are using (e.g., 2023Q1)
  • Build the wine-proton Port, with ALSA support, without OSS support, without PulseAudio support, using make package
  • cp /usr/ports/emulators/wine-proton/work/stage/usr/local/wine-proton/lib/wine/x86_64-windows/winealsa.drv /usr/local/wine-proton/lib/wine/x86_64-windows/
  • cp /usr/ports/emulators/wine-proton/work/stage/usr/local/wine-proton/lib/wine/x86_64-unix/winealsa.drv.so /usr/local/wine-proton/lib/wine/x86_64-unix/
  • As regular user (NOT as root) /usr/local/wine-proton/bin/pkg32.sh install wine-proton mesa-dri
  • Install FreeBSD 32 bit compat libraries as per Running Ableton Live in WINE on helloSystem hello#310
  • If it is there, rm /usr/local/wine-proton/lib/wine/x86_64-windows/winepulse.drv
  • Alternatively, possibly this works (to be confirmed): env PATH=/usr/local/wine-proton/bin/:$PATH winetricks settings sound=alsa
  • Check with env WINEARCH=win64 /usr/local/wine-proton/bin/winecfg under "Audio" that ALSA is being used
  • Install REAPER with /usr/local/wine-proton/bin/wine64 ~/Downloads/reaper673_x64-install.exe
  • Start REAPER with /usr/local/wine-proton/bin/wine64 /home/user/.wine/dosdevices/c:/Program\ Files/REAPER\ \(x64\)/reaper.exe
  • Configure REAPER Audio to use WASAPI, Exclusive Mode (it may be necessary to set "Input channels" to 0)

Results in ~14/11ms delay on my 11th gen Intel CPU Framework Laptop.

I further installed

  • Dexed
  • BlueARP

Some plugins require

  • sudo pkg install winetricks
  • env PATH=/usr/local/wine-proton/bin/:$PATH winetricks vcrun6sp6

To make it more convenient to launch WINE,

  • sudo ln -s /usr/local/wine-proton/bin/wine64 /usr/local/bin/wine64 (on helloSystem, this also should make double-clicking on Windows applications work)

Finally, I can use FreeBSD to make music! So happy. Thanks again @hselasky.

Note to self. wine-proton uses a hardcoded username for the Windows home directory, unlike other versions of WINE. This is perferable for my use case, where I want to "freeze" WINEPREFIXes as read-only and share them across all users of the system, something that is really cumbersome on normal WINE.

@hselasky
Copy link

Thank you for kind words :-)

@probonopd
Copy link
Member Author

Ableton Live 11 also running nicely with MIDI keybord.

@probonopd
Copy link
Member Author

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 alsa_seq_server is doing wonders. I hope all software on FreeBSD will get ALSA compiled in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants