OP25 audio volume control

Status
Not open for further replies.

boatbod

Member
Joined
Mar 3, 2007
Messages
3,338
Location
Talbot Co, MD
Anyone running the boatbod fork of op25 who needs a little volume boost can now achieve this direct from the command line using a new "-x scale-factor" parameter. Scale-factor is a floating point number used as a multiplier; 1.0 is unity gain, numbers less than 1.0 reduce the volume and numbers greater than 1.0 increase it. If you get carried away you will distort/clip the audio.

e.g.
-x 1.0 (default, unity gain)
-x 0.5 (cut in half)
-x 2.0 (double)

The changes are all python based (in rx.py, sockaudio.py and audio.py) so you only have to "git pull" to get them.

For future study:-
- make gain adjustable through the terminal
- implement AGC to normalize the levels
 

NebraskaCoder

Member
Joined
Oct 26, 2016
Messages
325
Location
Omaha, NE
Awesome! I can't wait to try it. I just bought a new laptop to dual boot with. The old one wasn't loud enough (among other problems).

Sent from my SM-G965U using Tapatalk
 

nokoa3116

Member
Joined
Jan 12, 2017
Messages
163
I have been playing with that setting with the command that runs rx.py, I am not sure that the volume changes. I keep raising because I don't think it's loud enough, I got all the way to 25. I am using this command to listen "nc -kluvw 1 127.0.0.1 25565 | aplay --device loop1 -c1 -f S16_LE".
 

boatbod

Member
Joined
Mar 3, 2007
Messages
3,338
Location
Talbot Co, MD
I have been playing with that setting with the command that runs rx.py, I am not sure that the volume changes. I keep raising because I don't think it's loud enough, I got all the way to 25. I am using this command to listen "nc -kluvw 1 127.0.0.1 25565 | aplay --device loop1 -c1 -f S16_LE".

The audio level isn't going to change because you are not using either the built-in audio player (sockaudio.py) or the standalone audio player (audio.py). The nc | aplay method of playing audio across a network is rather basic and has no frills such as audio gain and the ability to flush buffers at the end of a transmission.

Note: if you do use audio.py you'll need to specify the audio gain on that command line, rather than the rx.py command line.
 

nokoa3116

Member
Joined
Jan 12, 2017
Messages
163
Thanks for the reply. I previously used audio.py but it kept stopping after an hour or so. I moved back to use the command I listed above because it seemed to work without stopping.
 

boatbod

Member
Joined
Mar 3, 2007
Messages
3,338
Location
Talbot Co, MD
Thanks for the reply. I previously used audio.py but it kept stopping after an hour or so. I moved back to use the command I listed above because it seemed to work without stopping.

"Kept stopping" as in it would quit to the command line, or simply ceased playing audio?
We've had some fairly consistent reports of this happening on RPi3 hardware and it seems to be possibly related to ALSA kernel modules (went away with a different OS image loaded) but it's hard to say for sure. What hardware are you running?
 

nokoa3116

Member
Joined
Jan 12, 2017
Messages
163
"Kept stopping" as in it would quit to the command line, or simply ceased playing audio?
We've had some fairly consistent reports of this happening on RPi3 hardware and it seems to be possibly related to ALSA kernel modules (went away with a different OS image loaded) but it's hard to say for sure. What hardware are you running?

By keeps stopping I mean that there is no audio coming out. I have two OP25 instances with two dongles outputting to two ALSA loopback devices. When I output it to the computer speakers I had no issues. It's running on a Dell Latitude E4310 laptop with Ubuntu 18.04 LTS
 

boatbod

Member
Joined
Mar 3, 2007
Messages
3,338
Location
Talbot Co, MD
By keeps stopping I mean that there is no audio coming out. I have two OP25 instances with two dongles outputting to two ALSA loopback devices. When I output it to the computer speakers I had no issues. It's running on a Dell Latitude E4310 laptop with Ubuntu 18.04 LTS
The stoppage seems to be related to the loopback driver.
 

jhaab

Newbie
Joined
Jan 16, 2018
Messages
11
Location
Bloomington, IL
Is it possible with OP25 to have audio play over USB speakers in addition to the stream to IceCast? I am rather new to Linux but been trying to see if this can be done.

Thanks!

Jason
 

boatbod

Member
Joined
Mar 3, 2007
Messages
3,338
Location
Talbot Co, MD
Is it possible with OP25 to have audio play over USB speakers in addition to the stream to IceCast? I am rather new to Linux but been trying to see if this can be done.

Thanks!

Jason
Yes, assuming you can get audio to play over Bluetooth without icecast. The trick is you need to modify asound.come to "clone" the pcm stream and send it to two devices at once. There's an example of how to do that recently posted in this forum.
 

nokoa3116

Member
Joined
Jan 12, 2017
Messages
163
The stoppage seems to be related to the loopback driver.

I used the instructions on the forums here saying how to stream op25 to broadcastify, by creating the two alsa devices. -O in rx.py never worked for me, it never got anywhere. I used audio.py, it worked, but it just randomly stops. It sometimes says PCM underrun, but sometimes audio just stops coming in with no sign of an issue in the terminal. I set up everything again on another computer and same issue occurs.

Is there any other way for me to turn up the volume or audio gain? The feed is just too quiet.
 

boatbod

Member
Joined
Mar 3, 2007
Messages
3,338
Location
Talbot Co, MD
-O is the command line parameter for audio output device, not audio gain.

-x <num> is the gain control, where 1.0 is unity.
 

nokoa3116

Member
Joined
Jan 12, 2017
Messages
163
-O is the command line parameter for audio output device, not audio gain.

-x <num> is the gain control, where 1.0 is unity.

I know. I am sorry. What I am saying is, when I add the parameter "-O loop0" to the line that runs rx.py no sound reaches that device.at all. When I use audio.py it breaks, not sending any sound, and Darkice also breaks due to that.
 

boatbod

Member
Joined
Mar 3, 2007
Messages
3,338
Location
Talbot Co, MD
I know. I am sorry. What I am saying is, when I add the parameter "-O loop0" to the line that runs rx.py no sound reaches that device.at all. When I use audio.py it breaks, not sending any sound, and Darkice also breaks due to that.

Do you have the "loop0" alsa device configured? What happens if you run "aplay -D loop0" in a command prompt?
If loop0 is properly configured the aplay command should sit there waiting for stdin. If loop0 is not configured, you'll see an immediate error message.

e.g.
Code:
gnorbury@yoga2 ~/op25/op25/gr-op25_repeater/www/www-static $ aplay -D loop0
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM loop0
aplay: main:722: audio open error: No such file or directory
 

nokoa3116

Member
Joined
Jan 12, 2017
Messages
163
Do you have the "loop0" alsa device configured? What happens if you run "aplay -D loop0" in a command prompt?
If loop0 is properly configured the aplay command should sit there waiting for stdin. If loop0 is not configured, you'll see an immediate error message.

e.g.
Code:
gnorbury@yoga2 ~/op25/op25/gr-op25_repeater/www/www-static $ aplay -D loop0
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM loop0
aplay: main:722: audio open error: No such file or directory

Yeah it just sits there waiting for a response.

loop0 gets a resource busy, I am assuming because I am using it at the moment in another instance.
 

Attachments

  • Capture.JPG
    Capture.JPG
    110.5 KB · Views: 61

boatbod

Member
Joined
Mar 3, 2007
Messages
3,338
Location
Talbot Co, MD
Yeah it just sits there waiting for a response.

loop0 gets a resource busy, I am assuming because I am using it at the moment in another instance.

Something is apparently not working correctly with loop0, assuming that you executed the aplay command with neither op25 or darkice running in other windows.
-- it's not an op25 problem, but likely either a modprobe.d or asounds.conf configuration issue.
 

nokoa3116

Member
Joined
Jan 12, 2017
Messages
163
Something is apparently not working correctly with loop0, assuming that you executed the aplay command with neither op25 or darkice running in other windows.
-- it's not an op25 problem, but likely either a modprobe.d or asounds.conf configuration issue.

Op25 was running with audio going to loop0 and darkice running as well, I didn't want to turn it off as it was streaming. What do you think the issue can be with the loopback devices, I have installed everything on another computer and the issues still persist.
 

boatbod

Member
Joined
Mar 3, 2007
Messages
3,338
Location
Talbot Co, MD
Op25 was running with audio going to loop0 and darkice running as well, I didn't want to turn it off as it was streaming. What do you think the issue can be with the loopback devices, I have installed everything on another computer and the issues still persist.

I don't understand what you're saying. On one hand you say that using device "loop0" doesn't work, but on the other you say you don't want to shut down op25/darkice because it is streaming, which implies that you are successfully using loop0.

Are you thinking you can adjust the volume (using audio.sh) while the app is running? If so, you have misunderstood how the parameter works; you set it on the command line of rx.py (along with all the other parameters) at startup.
 

nokoa3116

Member
Joined
Jan 12, 2017
Messages
163
I don't understand what you're saying. On one hand you say that using device "loop0" doesn't work, but on the other you say you don't want to shut down op25/darkice because it is streaming, which implies that you are successfully using loop0.

Are you thinking you can adjust the volume (using audio.sh) while the app is running? If so, you have misunderstood how the parameter works; you set it on the command line of rx.py (along with all the other parameters) at startup.

Okay, here I will elaborate. The following is what I run, in the order that I run them.

First I run OP25 using this in the command line.
Code:
./rx.py --args 'rtl=0' -v 10 -D cqpsk -N 'LNA:36' -f 772.30625e6 -S 2400000 -V -q -1 -2 -T trunk.tsv -w 2> stderr_police.2
As you can see I don't use the output or audio gain from there.


Next I run my audio command.
Code:
nc -kluvw 1 127.0.0.1 23456 | aplay --device loop0 -c1 -f S16_LE
Again, I am not using audio.py to output sound, instead using the above command to output sound to loop0. This command does not allow me to change audio gain.

The reason I don't use audio.py is because after a few minutes of it working successfully, outputting audio to loop0 and applying audio gain. The audio suddenly stops being outputted. There don't appear to be any error messages on the audio.py terminal. In addition using the -O parameter in the rx.py command to output sound directly from there, does not output anything for me. When I use the above command, everything works well for the long run, but the audio volume is simply too low that I need to find another solution.
Code:
./audio.py -O loop0 -x 4
The above command is what I run WHEN using audio.py.


Lastly I run darkice which uses loop0 as the device it is streaming.

So all in all, I am streaming, what I have is working, but when using audio.py or -O and -x in rx.py audio keeps stopping, thus I am using the aplay command listed above.

I hope this makes more sense now.
 

boatbod

Member
Joined
Mar 3, 2007
Messages
3,338
Location
Talbot Co, MD
The intermittent stopping of the loopback device is a known issue particularly on a RPi3. Seems to be something in the kernel because I've been told that changing distribution has helped.

That said, the audio gain has no bearing on loopback or alsa in general. It simply performs a scaling (multiplication) of the pcm samples before they are sent out to the alsa library.

Unless you are using two channel dmr or sending pcm over udp, there is no reason to consider using audio.py; rx.py has everything you need.

You can also control volume outside of op25 through the alsamixer utility. If I recall, the volume can be turned up to 110% very easily.
 
Status
Not open for further replies.
Top