exch-bms2 / beatoraja

Cross-platform rhythm game based on Java and libGDX.
GNU General Public License v3.0
642 stars 148 forks source link

Low latency audio on Linux #320

Open Tearnote opened 6 years ago

Tearnote commented 6 years ago

jPortAudio does not have a Linux version, and probably never will. This leaves Linux only with "OpenAL (LibGDX Sound)", which feels a lot more delayed than PortAudio on Windows. A lower latency option for Linux should be made available, if one exists.

narcow commented 4 years ago

From my understanding, the current standard for low-latency audio on Linux is JACK. The JACK audio server also exists for other platforms (including Windows and OSX), so it would potentially be a new cross-platform option rather than something for Linux only.

0e4ef622 commented 3 years ago

Apparently you can compile jportaudio on linux no problem and it works? Here's what I did:

$ git clone --depth=1 'https://github.com/portaudio/portaudio'
$ cd portaudio/bindings/java/c/src
$ gcc -fPIC *.c -shared -o libjportaudio.so -I/usr/lib/jvm/java-8-openjdk/include -I/usr/lib/jvm/java-8-openjdk/include/linux -lportaudio

I'm on Arch Linux, so you might need to change the include paths.

Now you should have libjportaudio.so, you can put this wherever.

Then, add to beatoraja-config.command


export LD_LIBRARY_PATH="/path/to/directory/containing/libjportaudio.so/"
export LD_PRELOAD="/usr/lib/libportaudio.so" # might be different depending on your distro
ars-magna commented 3 years ago

Apparently you can compile jportaudio on linux no problem and it works? Here's what I did:

$ git clone --depth=1 'https://github.com/portaudio/portaudio'
$ cd portaudio/bindings/java/c/src
$ gcc -fPIC *.c -shared -o libjportaudio.so -I/usr/lib/jvm/java-8-openjdk/include -I/usr/lib/jvm/java-8-openjdk/include/linux -lportaudio

I'm on Arch Linux, so you might need to change the include paths.

Now you should have libjportaudio.so, you can put this wherever.

Then, add to beatoraja-config.command

export LD_LIBRARY_PATH="/path/to/directory/containing/libjportaudio.so/"
export LD_PRELOAD="/usr/lib/libportaudio.so" # might be different depending on your distro

Brilliant, this workaround has me set for the moment, thank you for that.