miegl / PiFmAdv

Advanced Raspberry Pi FM transmitter with RDS encoding
GNU General Public License v3.0
487 stars 82 forks source link

Slight Distortion on Speech #43

Open mrwish7 opened 5 years ago

mrwish7 commented 5 years ago

Hi,

I've been using this great tool to play with transmitting radio stations from a satellite tuner which carry RDS UECP data within the MP2 audio stream itself (designed usually for cable networks in Germany/Switzerland which use this RDS data to feed into their FM modulators for cable FM signals).

I wrote a small Python script which reads the data from the audio stream and outputs it to stdout in rds_ctl format for PiFmAdv - https://github.com/mrwish7/uecp_tool/blob/master/uecp_tool.py

e.g.

PS set to: " hr4 " Set TA to OFF PS set to: " Sie " PS set to: " sagte " RT set to: "Sie sagte doch sie liebt mich von Anders, Thomas & Silbereisen, " PS set to: "doch sie" PS set to: " liebt " RT set to: "Santa Claus is comin' to town von Beach Boys " PS set to: " hr4 " PS set to: " Santa " PS set to: "Claus is" PS set to: " comin' " PS set to: "to town " PS set to: " von " RT set to: "Santa Claus is comin' to town von Beach Boys " PS set to: " Beach " PS set to: " Boys " PS set to: " hr4 "

This all works perfectly, however I'm having problems with optimising the audio of the transmission. I'm using FFMPEG to limit the 48kHz MP2 signal to 30kHz and also convert it to PCM for input to PiFmAdv -

curl -s http://localhost:9981/play/stream/channel/62ac871a6dadea71434d184d15c84cfe?profile=audio | tee >(python3.5 ../../uecp_pifm.py 320 > rds) | ffmpeg -i pipe:0 -acodec pcm_s16le -ar 30000 -f wav pipe:1 | sudo ./pi_fm_adv --audio - --freq 91.0 --preemph eu --cutoff 15000 --pi D364 --ctl rds

The main problem I'm having is that even though the audio is very quiet*, when the radio station is airing speech, the sound sort of "clips" and distorts a bit as they speak. Is there any settings I can add to optimise this? Otherwise the audio sounds very good!

*The audio is really quiet, much quieter than broadcast FM signals, so the volume on the radio has to be turned up a lot. I can fix this by adding something like -af 'volume=8dB' to my FFMPEG command to boost the volume - but this has the issue of making the speech distortion worse the higher you boost the volume!

miegl commented 5 years ago

You can play around with the --mpx option. (default value is 40) Also it's pointless to downsample the audio to 30kHz.