OP25, Liquidsoap, and Pulseaudio as a service problem

Status
Not open for further replies.

fdmac

Member
Joined
Jan 14, 2010
Messages
5
Hey all,

OP25 is an awesome product. I'm working to change my feeds over to this from a BCD996P2 because it's so much better on our system. OP25 and Liquidsoap run beautifully from the terminal but fail miserably as a service.

I have an RPI 3B+, RTLSDR, and am running Raspbian Stretch. Pulseaudio has been installed, I have local audio and am streaming to BCFY....until I try to run them as services. Then I receive this error:

Code:
Oct 11 07:39:19 p25_south pulseaudio[8200]: [pulseaudio] server-lookup.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
Oct 11 07:39:19 p25_south pulseaudio[8200]: [pulseaudio] main.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11

My op25-rx service:
Code:
[Unit]
Description=op25-rx
After=syslog.target network.target nss-lookup.target network-online.target
Requires=network-online.target

[Service]
User=1000
Group=1000
WorkingDirectory=/home/pi/op25/op25/gr-op25_repeater/apps
ExecStart=/bin/bash -- op25.sh
RestartSec=5
Restart=on-failure

[Install]
WantedBy=multi-user.target

And my op25-liq
Code:
[Unit]
Description=op25-liq
After=syslog.target network.target nss-lookup.target network-online.target
Requires=network-online.target

[Service]
User=1000
Group=1000
WorkingDirectory=/home/pi/op25/op25/gr-op25_repeater/apps
ExecStart=/usr/bin/liquidsoap op25.liq
RestartSec=5
Restart=on-failure

[Install]
WantedBy=multi-user.target

I've been searching around for how to tackle the dbus error for pulseaudio, but I've had no success. I tried uninstalling, rebooting, and reinstalling with no success. I've tried switching back to ALSA and that's a couple of hours down the drain as well. I'd really like to have local audio.

Suggestions?
 

boatbod

Member
Joined
Mar 3, 2007
Messages
3,339
Location
Talbot Co, MD
Pulseaudio is trying to connect to the X11 desktop which it cannot do because you are starting pa from a system service and the desktop may not be running at that point in time. Do some googling of pulseaudio as a system service.

Personally I think it might be easier to run op25 and liquidsoap headless with no local audio, then start a local audio player from the desktop connected to the broadcastify stream.
 

wgbecks

Active Member
Joined
Jan 17, 2005
Messages
921
Location
NE Wisconsin
What version of Raspbian Stretch are you using? I have multiple RPI-3B+ on Stretch Lite where I have pulseaudio running without any issues.
Performing sudo apt-get install pulseaudio pulseaudio-utils on Raspbian Stretch Lite creates the necessary startup without the need for X11 support.

On Raspbian Buster Lite you will need to create a startup. I added @reboot pulseaudio --start to the bottom of crontab. Its simple and it has never failed to provide local audio while liquidsoap takes care of the streaming to BCFY.

On yet another RPI I am using pulseaudio to support a USB audio codec that a use to add audio from a standalone FM receiver into the liquidsoap stream along with the p25 audio for a fire department that is still using analog FM along with their P25.
 

fdmac

Member
Joined
Jan 14, 2010
Messages
5
What version of Raspbian Stretch are you using? I have multiple RPI-3B+ on Stretch Lite where I have pulseaudio running without any issues.
Performing sudo apt-get install pulseaudio pulseaudio-utils on Raspbian Stretch Lite creates the necessary startup without the need for X11 support.
Strange...I'm using Raspbian Stretch and I'm guessing it didn't add the proper startup info. If you have it running as a service, could you share that config?
 

fdmac

Member
Joined
Jan 14, 2010
Messages
5
Personally I think it might be easier to run op25 and liquidsoap headless with no local audio, then start a local audio player from the desktop connected to the broadcastify stream.
What fun is that? :)

I'd like to get it working locally as well so I can use this as the scanner on my desk as well as feed my RR feed.
 

wgbecks

Active Member
Joined
Jan 17, 2005
Messages
921
Location
NE Wisconsin
It may be that your existing installation of pulseaudio is corrupted or screwed up. I believe you mentioned that you've uninstalled and reinstalled it to no avail. It might be far easier to start with a clean image of Raspbian. I'd suggest that you go with the new Raspbian Buster Lite and run headless if you don't already do so with Stretch.

Install op25 with the install.sh script and then install pulseaudio as shown in README-rpi3-liquidsoap. Then install liquidsoap as shown but eliminate the second portion that refers to the plugin's as this will error out on Buster because these get installed by default. Finally, be sure
to add @reboot pulseaudio --start to your crontab (crontab -e) and reboot. Pulseaudio will start and restart with every boot or reboot.

Follow the instruction to stetup the services that start op25 and liquidsoap exactly as they are written and uncomment the line in op25.liq
that reads "output.pulseaudio(input)" and run alsamixer to turn up the pulseaudio volume control.

Bill
 

wgbecks

Active Member
Joined
Jan 17, 2005
Messages
921
Location
NE Wisconsin
Here's another suggestion that adds Automatic Gain Control (AGC) to liquidsoap that compensates for the volume (level) differences that are so typical on P25 systems. Modify (edit) op25.liq to insert and change the lines shown in BOLD below. You may want to tweak the threshold and gain values but these should work well. The gain of 3 is somewhat aggressive but you can go up/down according to the degree of processing desired. This has been tested on the RPI-3A, 3B+ and RPI-4B and works quite well.

------- op25.liq-----
# Make the native sample rate compatible with op25
set("frame.audio.samplerate", 8000)
# Compress and normalize, producing a more uniform and "full" sound.
# @category Source / Sound Processing
# @param s The input source.
def nrj(s)
compress(threshold=-18.,ratio=3.,gain=3.,normalize(s))
end
input = nrj(mksafe(input.external(buffer=0.25, channels=2, samplerate=8000, restart_on_error=false, "./audio.py -s -x 2")))

# Consider increasing the buffer value on slow systems such as RPi3. e.g. buffer=0.25
# Longer buffer results in less choppy audio but at the expense of increased latency.
--------

Bill
 

kdttocs

Newbie
Joined
Apr 15, 2013
Messages
3
Location
San Diego, CA
This is perfect! Can you explain what adjusting threshold and gain values changes?

Here's another suggestion that adds Automatic Gain Control (AGC) to liquidsoap that compensates for the volume (level) differences that are so typical on P25 systems. Modify (edit) op25.liq to insert and change the lines shown in BOLD below. You may want to tweak the threshold and gain values but these should work well. The gain of 3 is somewhat aggressive but you can go up/down according to the degree of processing desired. This has been tested on the RPI-3A, 3B+ and RPI-4B and works quite well.

------- op25.liq-----
# Make the native sample rate compatible with op25
set("frame.audio.samplerate", 8000)
# Compress and normalize, producing a more uniform and "full" sound.
# @category Source / Sound Processing
# @param s The input source.
def nrj(s)
compress(threshold=-18.,ratio=3.,gain=3.,normalize(s))
end
input = nrj(mksafe(input.external(buffer=0.25, channels=2, samplerate=8000, restart_on_error=false, "./audio.py -s -x 2")))

# Consider increasing the buffer value on slow systems such as RPi3. e.g. buffer=0.25
# Longer buffer results in less choppy audio but at the expense of increased latency.
--------

Bill
 

wgbecks

Active Member
Joined
Jan 17, 2005
Messages
921
Location
NE Wisconsin
The threshold value is the audio level relative to 0 dBfs where the compressor starts to reduce gain as specified by the ratio value. Typically,
the default of -18 is just right. The gain value sets the peak output audio level from the compressor and directly relates to the peak audio level that is obtained in the mp3 stream going up to BCFY or to your own personal Icecast server. I don't recommend setting this any higher than
the default (3) else clipping of the higher voice levels may occur.

The compressor does not ramp up low level audio, it only applies compression to the voice waveform when it reaches the threshold of compression. The recovered audio from the op25 vocoder is low and I typically specify (-x 2) on my liquidsoap input statement. However, you may need to use values of (-x 2.5) or even (-x 3) if the voice levels on your system are low in order to reach the knee of the compression curve.
 
Last edited:

maus92

Member
Premium Subscriber
Joined
Jun 23, 2004
Messages
8,041
Location
The OP
I've found OP25 runs better on an actual computer, thus I retired the RPi3b and Rpi4, and now use a NUC. Much more stable.
 
Status
Not open for further replies.
Top