PDA

View Full Version : Fantasy Grounds Local Sounds in Linux Ubuntu Environment with Pipewire



Thelgor
November 6th, 2023, 03:01
*** This post has been updated to represent a more stable configuration ***

I don't know if information on setting up a Linux environment to make use of the Sound triggering capability of FGU has been posted somewhere, but I haven't been able to find any after a brief search. What follows are details about what I've done to get Sounds triggering for my FGU sessions. As a caveat, this is for a basic set up. There are many possible variations in configuration to set Linux up to perform the tasks in a manner of your choosing but that would be a book (or short story) worth of typing.

For reference, the basic set up uses Kubuntu 23.04, Pipewire 0.3.65, WirePlumber 0.4.13, qpwgraph 0.3.9, VLC 3.0.18, Discord 0.0.32, and Fantasy Grounds Unity 4.4.5. I also make use of Soundux 0.2.7, Kenku FM 1.4.1, and OBS Studio 29.0.2.1 in a more involved configuration. This is using a KDE Plasma desktop.

Note: Directions are for Ubuntu distributions only. File locations may be different in other distros.
Note: I don't explain how to set up local sound files in FGU - there's plenty of instructions on that.
Note: I'm still learning all this. This is not optimized :)
Note: I'm working on a video that covers more but figured this basic setup might be interesting to someone.

Background
Linux distros are moving away from the old audio combination of Pulse Audio and JACK to the sound and video server of Pipewire. Along with WirePlumber, for session and policy management, Pipewire provides everything needed to supply audio in the Linux environment. However, an issue to overcome is the dynamic way that Pipewire handles streams.
Another bothersome issue is learning concepts such as sinks, sources, and devices to really make use of the flexibility available to end users. However, it's not too hard.

Setup 1
The most challenging aspect of setting this up on Linux is getting the right audio elements to make use of the sounds. Since Pipewire dynamically creates and destroys objects, we need to set up a little stability that we can rely on.

First, we need to configure Pipewire with a static element we can rely on. Create a Pipewire configuration file in /home/<username>/.config/pipewire/pipewire.conf.d/virt-coupled-stream.conf. If the directory and file do not exist, create them.

Second, enter the following lines in your new virt-coupled-stream.conf file:



context.modules = [
{ name = libpipewire-module-loopback
args = {
audio.position = [ FL FR ]
capture.props = {
media.class = Audio/Sink
node.name = my_virtual_sink
node.description = "my-virtual-sink"
}
playback.props = {
media.class = Audio/Source
node.name = my_virtual_source
node.description = "my-virtual-source"
target.object = "my-virtual-default-source"
}
}
}
]

If you're interested in learning about this configuration, Pipewire Wiki - Coupled Streams (https://gitlab.freedesktop.org/pipewire/pipewire/-/wikis/Virtual-Devices#coupled-streams)

Third, reboot your system. It's much easier than trying to explain why or address issues that may come up from restarting services. If you have qpwgraph installed, you'll see your new virtual sink and source displayed.


Fourth, after rebooting, run "wpctl status" from the command line. You'll get a response that shows you your setup and defaults:


.
.
.
Audio
├─ Devices:
│ 45. GP106 High Definition Audio Controller [alsa]
│ 46. C922 Pro Stream Webcam [alsa]
│ 47. XIBERIA [alsa]
│ 48. Built-in Audio [alsa]

├─ Sinks:
│ 35. my-virtual-sink [vol: 0.15]
│ 55. GP106 High Definition Audio Controller Digital Stereo (HDMI) [vol: 0.30]
│ * 57. XIBERIA Analog Stereo [vol: 0.45]

├─ Sink endpoints:

├─ Sources:
│ 34. my-virtual-source [vol: 1.00]
│ * 56. C922 Pro Stream Webcam Analog Stereo [vol: 0.97]
│ 58. XIBERIA Mono [vol: 1.53]

.
.
.

You'll want to check where that * is under Sinks. You want to change it to the ID of the virtual sink with the command "wpctl set-default <id>" where id is the Sink ID you want to use. This example would be "wpctl set-default 35". This sets it so that any dynamically created audio stream automatically connects to your virtual sink. As an example, when you click on that Play icon in FGU to play a sound, whatever sound device starts locally is going to output audio to your sink instead of anything else. You will then be able to output that stream to Discord, your headphones, whereever. For this basic configuration, we'll use VLC. Though, we can use any audio player we want.

Fifth, set up your distro to use VLC to play audio files you'll use in FGU - such as .wav, .mp3, etc. Linux Desktop environments will differ on how to do this.

Sixth, set up VLC with the following settings. Your version may or may not have these settings and they may be in different locations:

Media: Enable "Quit at the end of playlist" - closes player after playing sound
Tools -> Preferences -> Interface: Turn off "Allow only one instance" - play concurrently...not consecutively
Tools -> Preferences -> Audio: Output module: Automatic (Try PulseAudio server before ALSA audio)
Interface -> Main Interfaces: Check Web checkbox - is not needed in this configuration but have it checked anyway
Interface -> Main Interfaces -> Qt: Start VLC with only a systray icon (so you don't see the VLC window pop-up when it plays a sound)


Seventh (if using it), set up Kinku FM to use my-virtual-source as its input.

Eighth, we need to set up the patches correctly. qpwgraph provides an easy interface to make these connections. You'll have two virtual objects that make up your sink: a playback that takes streams into the sink, and a monitor that allows you to hear the contents of the sink. When you play audio, it'll automatically connect to the playback sink. You need to set up the graph so that the monitor sink connects to your headphones/speakers/monitor speakers - whatever produces sound you can hear.

Take a look at the attachments to see how the graphs are layed out.

Now enjoy sounds from your game when you click the play button from your playlist. Play an hour long mood music file and a short little sound effect at the same time with the same player.

Thelgor
November 12th, 2023, 00:05
Posted a video for any interested: https://www.youtube.com/watch?v=auEC6jkrpq8

Jiminimonka
November 12th, 2023, 00:32
Thanks!

Thelgor
February 11th, 2024, 22:41
I've created an updated version of my video for Kubuntu 23.10. I've been able to cut the time down to just under 10 minutes. Which is good because my voice reminds me of the "How it's made" announcer - to me anyway.

https://www.youtube.com/watch?v=mJUqbCV_P0k