What?As kind of a for-fun project, I implemented native sound output for OpenMPT when running on Wine on Linux. The first version to have it is 1.27.00.34 r7701 as of 2017-02-26. It has only been tested on the following system setups so far:
OpenMPT | Distribution | Architecture | Wine Version | Packages | Remarks |
1.27-old | Debian 8 | amd64 | wine 1.6.2 | wine wine32-tools | |
1.27-old | Debian 8 | amd64 | wine-development 1.7.29 | wine-development wine64-development-tools | |
1.27-old | Ubuntu 14.04 LTS | amd64 | wine 1.6.2 | wine wine-1.6-dev | |
1.27 | Debian 9 | amd64 | wine-development 2.0-3+b2 | wine64-development wine64-development-tools | |
1.27 | Ubuntu 16.04 LTS | i686 | wine-development 1.9.6 | wine-development libwine-development-dev | |
1.27 | Ubuntu 16.04 LTS | amd64 | wine-development 1.9.6 | wine-development libwine-development-dev | |
1.28 | Debian 9 | amd64 | wine-development 2.0-3+b2 | wine64-development wine64-development-tools | |
1.28 | Debian 10 | amd64 | wine 4.0 | wine wine64 libwine-dev wine64-tools | |
1.28 | Ubuntu 16.04 LTS | i686 | wine-development 1.9.6 | wine-development libwine-development-dev | |
1.28 | Ubuntu 16.04 LTS | amd64 | wine-development 1.9.6 | wine-development libwine-development-dev | |
1.28 | Ubuntu 18.04 LTS | amd64 | wine 3.0 | wine-stable wine64-tools libwine-dev | |
1.28 | Ubuntu 20.04 LTS | amd64 | wine 5.0 | wine wine64-tools libwine-dev | - Harmless compiler warning when using RtAudio.
|
1.28 | Linux Mint 19.3 | amd64 | wine 3.0 | wine-stable wine64-tools libwine-dev | - Do not use the wine-stable or wine-installer 4.0 (or later) packages provided by Linux Mint,
because although they provide winegcc, they fail to provide windows.h. Force the Wine 3.0 packages provided by upstream Ubuntu 18.04 LTS instead.
|
1.28 | GhostBSD 11.1 ALPHA1 (FreeBSD 11.1-RC3) | amd64 | wine-development 2.13 | wine-devel | |
1.29 | Debian 10 | amd64 | wine 4.0 | wine wine64 libwine-dev wine64-tools | |
1.29 | Ubuntu 18.04 LTS | amd64 | wine 3.0 | wine-stable wine64-tools libwine-dev | |
1.29 | Ubuntu 20.04 LTS | amd64 | wine 5.0 | wine wine64-tools libwine-dev | |
1.29 | Linux Mint 19.3 | amd64 | wine 3.0 | wine-stable wine64-tools libwine-dev | - Do not use the wine-stable or wine-installer 4.0 (or later) packages provided by Linux Mint,
because although they provide winegcc, they fail to provide windows.h. Force the Wine 3.0 packages provided by upstream Ubuntu 18.04 LTS instead.
|
1.29 | Linux Mint 20.1 | amd64 | wine 5.0 | wine wine64-tools libwine-dev | - Do not use the wine-installer package provided by Linux Mint,
because although it provides winegcc, it fails to provide windows.h.
|
1.30 | Ubuntu 20.04 LTS | amd64 | wine 5.0 | wine wine64-tools libwine-dev | |
1.30 | Linux Mint 20.1 | amd64 | wine 5.0 | wine wine64-tools libwine-dev | - Do not use the wine-installer package provided by Linux Mint,
because although it provides winegcc, it fails to provide windows.h.
|
1.30 | Linux Mint 20.2 | amd64 | wine 5.0 | wine wine64-tools libwine-dev | - Do not use the wine-installer package provided by Linux Mint,
because although it provides winegcc, it fails to provide windows.h.
|
1.31 | Debian 11 | amd64 | wine 5.0 | wine wine64 libwine-dev wine64-tools | |
1.32 | Debian 11 | amd64 | wine 5.0 | wine wine64 libwine-dev wine64-tools | |
This means, that OpenMPT can now, as an EXPERIMENTAL feature, completely bypass the emulation of Windows sound drivers as implemented in Wine, and instead talk to the native Linux APIs directly.
In its current form, only support for PulseAudio and PortAudio is implemented.
Support for PulseAudio currently still uses the "Simple API" which is suboptimal for the features that OpenMPT wants to use. This will be improved to use the full API in a later OpenMPT version.
Support for PortAudio is probably final in its current form and is no high priority. PortAudio itself can, in particular, talk to ALSA devices directly. PortAudio can also talk to JACK, but this has not been tested at all in OpenMPT and very probably does not work correctly yet.
In addition to using native Linux sound APIs, OpenMPT can now also boost the thread priority, which was not possible at all when using the standard Windows APIs as emulated by Wine. OpenMPT can use both, Linux Realtime Scheduling priorities directly as well as setting system-defined priorities through RealtimeKit. The way OpenMPT chooses between these 2 ways is the way recommended by the Linux Audio Developers community.
How?Using Wine integration in OpenMPT has various requirements on the host system:
- OpenMPT bitness must be the same as host system bitness, i.e. use OpenMPT 32bit on i686 and OpenMPT 64bit on x86-64.
- On Debian or Ubuntu (and derivates), the following packages must be installed: coreutils dialog make pkg-config cpp gcc g++ binutils ccache xterm.
- Additionally, the Wine developments headers and tools must also be installed. These are called completely different but similarly looking names on various distributions. See the list of tested systems for hints on what package names to look out for.
- The following packages need optionally be installed: libpulse-dev (for PulseAudio), libjack-jackd2-dev and portaudio19-dev (for PortAudio), libdbus-1-dev (for RealtimeKit)
- Other distributions should also work, but you have to figure out the required packages yourself.
In order to enable Wine integration, go to the
Wine options tab (the tab is only shown if OpenMPT actually detected Wine), check the checkbox and restart OpenMPT. Additional settings are available under
Advanced settings in the
WineSupport section. For most of these settings, you need to restart OpenMPT for them to take effect.
(https://forum.openmpt.org/index.php?action=dlattach;topic=5792.0;attach=417;image)
If OpenMPT Wine integration is enabled, OpenMPT will compile the required library adapters for your system on startup itself. It will
spawn a terminal window and show a progress bar while doing so. Please do not be scared or surprised when you see the terminal window popping up. Starting native host applications from within a Windows application running on Wine is officially supported behaviour of Wine. If all works fine, native sound devices will be listed in the
Sound Card settings.
(https://forum.openmpt.org/index.php?action=dlattach;topic=5792.0;attach=419;image)
Technical Details2 shared libraries are compiled by OpenMPT. The required source code is distributed with OpenMPT in the file
openmpt-wine-support.zip and must match the OpenMPT version exactly.
(https://forum.openmpt.org/index.php?action=dlattach;topic=5792.0;attach=421;image)
openmpt_wine_support.dll gets placed below
AppData/ in the Wine environment. This is a Wine DLL, which will be loaded by OpenMPT and used as a proxy to call to the system native library
libopenmpt_native_support.so.
libopenmpt_native_support.so gets placed below
$XDG_DATA_HOME/ on the host system. The shared library is a host-native library that implements the OpenMPT sound device API on top of the PulseAudio or PortAudio libraries provided by the host system.
OpenMPT will recompile these libraries as required and cache the result such that starting the exact same version of OpenMPT again does not require recompiling.
We also need prebuilt binaries. ;)
It's not really feasible to provide pre-built binaries for the n different Linux distributions times m different Wine versions out there. If you have problems with the feature (if so, please post them), those would most likely also exist with pre-built binaries.
Quote from: Saga Musix on February 27, 2017, 22:43:07
It's not really feasible to provide pre-built binaries for the n different Linux distributions times m different Wine versions out there. If you have problems with the feature (if so, please post them), those would most likely also exist with pre-built binaries.
Such wine libraries should be compatible with different wine versions (ex. wineasio works well). The process of building a wine library is very complicated for users.
That's why we should have built-in binaries.
Compatibility with different Wine versions should in fact not be a problem.
However, there are a couple of other problems:
- The way we use 2 libraries (which is absolutely required to keep the code maintainable and extendible) requires hard-coding the library path of the .so in the .dll. That path is user-specific and even runtime dependent on environment variables.
- Providing binaries would require different binaries for different system setups. In the past, you often stated that you do not want PulseAudio on your system. If we provided binaries, these would drag in PulseAudio (and PortAudio and DBus) as a dependency for you OR we would have to implement dynamic on-demand loading for these libraries which would increase the maintenance overhead considerably.
Thus, the effort to make binaries would require: #distributions (because of different settings in the distribution default C++ ABI used by the native .so library) * #configurations * #platforms. The distributions amount to about 2 stable Debian versions, Debian testing, 2 stable Ubuntu LTS versions, the latest Ubuntu non-LTS, latest Fedora, latest OpenSuse, probably latest Arch and Gentoo, which amounts to about 10 systems I would have to maintain to actually build those, let alone actually test them. There are about 2^3 configurations and 3 platforms (i568, i686+SSE2, x86-64). This results in 10*8*3 = 240 packages. I wont do that. Ever.
Also consider that we only have about 5% users on Wine (of which (I am guessing here because we do not have these numbers) about 50% are using Linux) of which (even more guessing) at best 10% would even be using the Wine integration feature at all. Providing packages for about 0.25% of the users is not worth the effort.
Also, what aspect of building the libraries is difficult?
We only require packages in the stock distribution repository.
Installing binary packages would require users either to setup an additional package repository in their package manager or install the OpenMPT Wine integration packages by hand.
How can I also build these libraries outside openmpt?
-----------
I got an error:
http://www.zimagez.com/zimage/2017-02-2814-37-56.php
FIXED: http://pastebin.com/7zEujVNn
This is a known bug in the current Wine development version and will be fixed in the next Wine update (which I suppose will be available in a few days).
http://www.zimagez.com/zimage/2017-02-2815-11-13.php
The buffer value is probably invalid.
Quote from: monsterovich on February 28, 2017, 13:18:37
http://www.zimagez.com/zimage/2017-02-2815-11-13.php
The buffer value is probably invalid.
The value displayed as "Buffer" is just the overall buffer/latency divided by the buffer that is requested/used by OpenMPT/PortAudio, i.e. it's literally just currentlatency/latency as shown the line below it.
In any case, that latency is way higher than I would expect it to need to be for stable playback. Is your ALSA default device using dmix?
Quote from: monsterovich on February 28, 2017, 12:29:08
How can I also build these libraries outside openmpt?
Even though that is technically possible of course, it is currently not supported and I do not want to document that right now because the process will almost certainly be changed often.
Also, different versions are guarded and cached using checksums, which you would have to calculate manually when compiling outside of OpenMPT in order to be able to place the libraries in the expected directory (the checksum is part of the pathname).
Quote from: manx on February 28, 2017, 14:02:35
Is your ALSA default device using dmix?
Yes. (http://pastebin.com/MBtjryF7)
Quote from: monsterovich on February 28, 2017, 18:35:27
Quote from: manx on February 28, 2017, 14:02:35
Is your ALSA default device using dmix?
Yes. (http://pastebin.com/MBtjryF7)
So, your dmix is configured for about 93ms of latency. The numbers are not all that surprising then.
Note that PulseAudio does not use a fixed period and buffer output strategy but rather a huge buffer which may be filled on as short notice as required, allowing it to dynamically work with appropriate application to outputjack latency as required and desired per application. That is, IMHO, way better suited for occasional DAW usage than dmix is.
As of r8368, this now also works on Debian 9.
Supported also on BSD now, since r8780.
Tested on:
GhostBSD 11.1 ALPHA1 (FreeBSD 11.1-RC3), wine-development 2.13 (wine-devel)
https://pastebin.com/dpprgJTy
Can you please allow to build 32bit wrapper on 64bit system (-m32 or something)?
Quote from: monsterovich on October 05, 2017, 22:48:36
https://pastebin.com/dpprgJTy
Can you please allow to build 32bit wrapper on 64bit system (-m32 or something)?
Theoretically possible, but certainly will not happen to be supported in the near future.
There is a hidden setting [WineSupport]ForeignOpenMPT. If you set that to 1, OpenMPT will try to build for non-native bitness, however that feature is unsupported and not very well tested and I cannot remember right now if it even ever worked even on Debian systems where I test mostly.
We do explicitly not provide active support for this situation though, because of various reasons:
The amount of differences between distributions in the way compiling for Wine is already amazingly huge as it is, even when only targeting the native platform. Targeting foreign bitness will increase the amount of situations to support manyfold.
Library placement in the file system differs completely between Debian, Ubuntu, other Linux, other platforms (i.e. at least 4 ways to handle it). Some systems completely special case Wine and do not allow to even install general 32bit packages on 64bit systems at all. This implies having to consider which packages are even available there at all. Detecting available foreign packages is also not really portable (yes, pkg-config, but we would have to GUESS the actual host triplet and pkg-config path used for 32bit) (also, this would not be any easier when building by hand).
So no, this is an experimental feature, and only supports a subset of available configurations. You either have to use native bitness OpenMPT (and are thus limited to 64bit VST plugins due to the Wine UI rendering problem, though we might be able to provide a work-around for that sometime, albeit not soonish either), or use 32bit OpenMPT on your 64bit system and not use the Wine integration feature (WASAPI support in Wine and OpenMPT works nearly perfect these days, so you would not lose all that much anyway).
In any case, this is and will stay to be a highly experimental feature because it requires an unproportionally huge amount of development time to implement and test (the test matrix is incredibly huge, compared to other features), and I do not want to invest the time to extend the scope that much for ever so smaller diminishing returns.
We might support building by hand some time, but not right now.
Reactivated my forum account to come in here and say thank you very much for this feature! This makes OpenMPT so much more usable on my preferred OS.
I also have a request: compiling Wine support failed for me for a while until I specifically went to these forums to search for help, at which point I stumbled upon this thread. The thread contains invaluable information for those who want to get this to work, but none of this info is available in any of the standard help docs or during any step where the compilation/native support fails. It might be a good idea to put the instructions on the wiki and link to it straight from the application itself (as well as the terminal window) when things go wrong, just to point people in the right direction. A link to this thread for support might also be good!
Quote from: DaVince on January 13, 2018, 08:45:40
I also have a request: compiling Wine support failed for me for a while until I specifically went to these forums to search for help, at which point I stumbled upon this thread. The thread contains invaluable information for those who want to get this to work, but none of this info is available in any of the standard help docs or during any step where the compilation/native support fails. It might be a good idea to put the instructions on the wiki and link to it straight from the application itself (as well as the terminal window) when things go wrong, just to point people in the right direction. A link to this thread for support might also be good!
Uhm, it's documented at https://wiki.openmpt.org/Manual:_Setup/Wine (https://wiki.openmpt.org/Manual:_Setup/Wine). I do not see right now what information would be missing from the wiki, short of the list of tested configurations, for which it links to this precise thread.
We do not link to the precise wiki/manual page from any other UI element in OpenMPT, and I do not think we should special case this.
I guess I could add a link in the error message when compilation fails, though - precisely because this is an experimental feature and known to fail under a lot of circumstances.
Quote from: DaVince on January 13, 2018, 08:45:40
Reactivated my forum account to come in here and say thank you very much for this feature! This makes OpenMPT so much more usable on my preferred OS.
Great to hear.
I'm curious though: What particular audio output problems do you experience when using the standard audio output methods in OpenMPT on Wine (and not using the native Wine integration features)? Which Wine version? Which distribution? What kind of audio setup on the Wine and side? Which OpenMPT output backend?
Oh, sorry, I couldn't find that wiki article before, my bad!
QuoteI'm curious though: What particular audio output problems do you experience when using the standard audio output methods in OpenMPT on Wine (and not using the native Wine integration features)? Which Wine version? Which distribution? What kind of audio setup on the Wine and side? Which OpenMPT output backend?
For me, picking the sound options always meant there was a trade-off between having decent latency and making sure the audio doesn't become crackly. Having even a slight delay when entering notes is annoying, but it was necessary because setting the latency/period too low meant getting the crackles and audio glitches. Sometimes there's also a glitch where the entire song will play back way too quickly and sound all crackly. This has happened across any version of OpenMPT on any version of Xubuntu in the past years.
I've encountered neither of these cases when using the native Wine driver so far, and there's no noticeable lag either. It's great.
Quote from: DaVince on January 13, 2018, 13:26:02
QuoteI'm curious though: What particular audio output problems do you experience when using the standard audio output methods in OpenMPT on Wine (and not using the native Wine integration features)? Which Wine version? Which distribution? What kind of audio setup on the Wine and side? Which OpenMPT output backend?
For me, picking the sound options always meant there was a trade-off between having decent latency and making sure the audio doesn't become crackly. Having even a slight delay when entering notes is annoying, but it was necessary because setting the latency/period too low meant getting the crackles and audio glitches. Sometimes there's also a glitch where the entire song will play back way too quickly and sound all crackly. This has happened across any version of OpenMPT on any version of Xubuntu in the past years.
I've encountered neither of these cases when using the native Wine driver so far, and there's no noticeable lag either. It's great.
Fair enough. Even though we have not been seeing any particular problems regarding sound output on any Ubuntu/Xubuntu version in the last couple of years - especially not when using the "WASAPI" output backend in OpenMPT.
However different systems behave differently, so we added the native Wine integration as another option for people like you who experience such problems.
Hi, I'm running this on FreeBSD via WINE 9.0 and when it's compiling native libraries, it shows this error.
usr/include/sys/param.h:44:13 note: expanded from macro: 'BSD'
#define BSD 199506 /* System version (year & month). */
^
1 error generated.
gmake: *** [build/wine/native_support.mk:208: src/openmpt/sounddevice/SoundDeviceManager.o] Error 1
Quote from: s0m3guy on February 16, 2024, 13:20:12I'm running this on FreeBSD via WINE 9.0 and when it's compiling native libraries, it shows this error.
I currently do not have any FreeBSD install available for testing, but I guess r20133 (1.32) and r20134 (1.31) should probably fix this. Test builds will be available in a couple of hours at https://builds.openmpt.org/ (https://builds.openmpt.org/).
Nice, I'm using r20151 and it successfully compiled for my system!