miegl / pifmadv Goto Github PK
View Code? Open in Web Editor NEWAdvanced Raspberry Pi FM transmitter with RDS encoding
License: GNU General Public License v3.0
Advanced Raspberry Pi FM transmitter with RDS encoding
License: GNU General Public License v3.0
Hello,
when comes rds 2.0 ?
These are the features:
Seamless support for frequencies from 64 MHz to 108 MHz (AF, EON)
New character coding: UTF-8 (old EBU Charset remains for compatibility mode for the old 0A/2A Groups).
New ODA handling, "B" groups are assigned as signalling group to the “A” groups.
Long PS-Name, up to 32 byte with UTF-8 character set. (Indian, Chinese, Arabic, and more)
RadioText (eRT) 128 byte long with UTF-8
Increased capacity from 11.4 up to 57 "A"-groups per second. (2,109 bit/s. net capacity with the single modulation-type multiple subcarriers (SMMS) technology)
Graphical RadioText – supports HTML/CSS templates (for smartphones, car radios, computers/tablets)
Supports return channel over gRT if the receiver has IP or SMS capability.
Broadcaster's graphical logo – a maximum 4 kilobyte picture (JPEG, PNG, or GIF)
Hybrid Radio feature (partly based on Radio France development)
I really like this.
cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)" NAME="Raspbian GNU/Linux" VERSION_ID="9" VERSION="9 (stretch)" ID=raspbian ID_LIKE=debian HOME_URL="http://www.raspbian.org/" SUPPORT_URL="http://www.raspbian.org/RaspbianForums" BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
uname -a
Linux streampi 4.9.59-v7+ #1047 SMP Sun Oct 29 12:19:23 GMT 2017 armv7l GNU/Linux
When I try to run the program, it first crashes. Then running it again causes it to work for 15 seconds, then stop working.
When the GPU frequency is changed to 250 (or any number) it broadcasts nothing indefinitely and hangs the pi. I can not control-c the program.
Here is the weird thing.
I installed ubuntu server onto my raspberry pi's SD card, and it seems to have fixed all of the issues i was having, and allowed me to broadcast audio perfectly. However, the range was severely limited to a couple feet with and without an antenna. Before I was getting ~100 feet with a jumper wire attached, and now I only get 3 feet (even with -w set to 7!)
What OS can I install to make this work with a long range and allow me to broadcast for more than 15 seconds?
What I'm doing: sox someinput | pi_fm_adv ... --wait 0
I don't really understand why, but when sox playback finishes, the shell hangs indefinitely, there is no CTRL+C / CTRL+Z response, and killing -9 pi_fm_adv process seem to have no effect! the pid won't die, although the shell is working...
PS: I'm on a Pi3 (the only device I seem to have managed to get working with)
When piping musing into pi_fm_adv like this
sox somefile.mp3 -t wav - | pi_fm_adv ...
It would be nice if upon sox termination pi_fm_adv could terminate as well, just like pi_fm_rds did.
Could you please point me out a way to do so or implement it as I really need this behaviour
Thank you for this brilliant implementation, thought
It appears that the signal strength lower than PiFmRds
I used to be able to hear a few hundread meters away but now only like 50 meter with PiFmAdv
I would like to run PiFmAdv under python3. What I am concerned about is the KeyboardInterrupt may not shut it down.
Is there a python3 "import"?
ps. I do not know how to add help wanted.
Upon starting this program, the monitor i was using started showing white and black dots all over the place, then my Raspberry Pi 3 stopped responding and i had to reboot. tried again and had the same effect.
Are there any suggestions for an antenna to use with this? Other's experiences?
I have found something like this: https://www.amazon.com/dp/B01HTDKAWS/ref=cm_sw_r_cp_apa_JsbxAbGW04SRV
Would something like this work? Does anyone know how you would connect something like this best to the GPIO?
Basically just the best way to boost the radius. Any suggestions would be great! What do you guys use for an antenna?
Thanks!
My radio station changes RT every 10 seconds, with two messages one saying "Welcome to Niall FM" and the other is "Now Playing: " with the song title...
Problem is that its very likely (e.g 80%) of the time to get the messages mixed up...
"Welcome to NiaNow Playing:"
or "Now Playing: Dr Dre feat SnooFM."
(The radio scrolls the text)
So of course in this picture it has cut in with the second rt has been cut off and then the now playing Rt has been inserted.
As if the RT is being transmitted then changed it continues at the same character position but with a different text.
It would be nice if this could be fixed. Im sure it wasnt in PiFMRds in 2016 not sure tho.
The script fetches the now playing from a server
If I route the audio stream of a webstream to the transmitter the audio stops after 3~4 hours.
This is caused by a buffer overflow/underrun because both the input and output streams are not synchronized.
for instance, 44.1kHz input is converted to the internal 228kHz samplerate. So far so good. But in practice 44.1kHz input is not exactly 44.1kHz (it could be 44.050kHz). and the DMA engine which is set to 228kHz is not exactly 228kHz (it could be 227.981kHz). So over time a buffer overflow or under run will occur.
You could fix this by either keep track of the buffer and adjust the 228kHz samplerate of the DMA controller to keep in sync. So if the buffer grows then slightly speed up the 228kHz clock. If the buffer shrinks slow down the 288kHz.
Or,
If the buffer buffer grows, resample the 44.1kHz input data slightly above 228kHz, or if the buffer shrinks, resample slightly below 228kHz.
But both solutions require a major rewrite of the code!
The first solution, slow down or speed up the 228kHz clock will also adjust the 19kHz pilot, 38kHz modulator and 57kHz modulator because the LUT a pre calculated at 228.0kHz.
The second solution, resample the audio slightly below or above 228kHz looks like the best solution because there is no need to resample the 19kHz, 38kHz, 57kHz LUT`s.
Br,
Vincent Bruinink.
The scope of this How-To is to be able to extract song info and put it into the RT field of RDS in pseudo real time (10 seconds delay)
This is not an issue but a 'How-To', sorry but I didn't find anywhere to put this.
install PiFmAdv as user "root" in /root directory, do not install the program as "Pi" user.
sudo apt-get install sox
sudo apt-get install lame
sudo apt-get install libsox-fmt-mp3
sudo apt-get install perl
download and compile ffmpeg from the source.
https://www.ffmpeg.org/download.html
the current version is ffmpeg-4.0.2.tar.bz2
cd /root
wget https://ffmpeg.org/releases/ffmpeg-4.0.2.tar.bz2
tar xvjf ffmpeg-4.0.2.tar.bz2
cd ffmpeg-4.0.2
./configure
make
sudo make install
IMPORTANT NOTE: on Pi2 the above FFMPEG compile process takes several hours to be completed!! Be extremely patient.
sudo nano /root/inject-title.sh
#!/bin/bash
# by pilovis - Italy - parknat12 at yahoo.com
cd /root
/bin/sleep 1
rm /tmp/rds_ctl
/bin/sleep 1
mkfifo /tmp/rds_ctl &
/bin/sleep 1
# start FM transmitter
/usr/bin/sox --buffer 65536 --input-buffer 65536 -t mp3 http://stream.srg-ssr.ch/m/rsp/mp3_128 -t wav -c 2 - | sudo ./PiFmAdv/src/pi_fm_adv --preemph eu --ctl /tmp/rds_ctl --freq 88.0 --audio - &
# RDS text injection section below - 10 seconds loop
while :
do
/usr/local/bin/ffprobe 2> /dev/null -show_format http://stream.srg-ssr.ch/m/rsp/mp3_128 | grep TAG:StreamTitle= | cut -d '=' -f 2 | /usr/bin/perl -ne 'print "PS 'RADIO-88'\nRT $_"' > /tmp/rds_ctl
/bin/sleep 10
done
note: I put rds_ctl file in /tmp (RAM tmpfs) to avoid wearing out the SD card.
sudo chmod 755 /root/inject-title.sh
sudo /bin/sh /root/inject-title.sh &
note: after a few seconds delay the FM radio should start transmitting on 88.0 Mhz with "RADIO-88" station name.
sudo killall pi_fm_adv
Enjoy
Maurizio
Im bit confused is Medium Wave ONLY AM
or is Medium Wave can be FM AS WELL ????
Because if so I want to broadcast Medium Wave FM Make more further pleas.
When i run the command to pipe audio from usb soundcard it is giving me the overrun!!! (at least ... ms long)
Ability to change frequency on the go using rds_ctl file.
Something like: FM 101.0
Before changing the GPU frequency to 250, the program would play 15 seconds of music and then stop.
After changing the gpu frequency to 250, the program does not play music anymore, and instead hangs the raspberry pi. The raspberry pi however broadcasts white noise while doing this.
I updated my raspberry pi 3 to the most recent version
PiFmAdv stops listening for commands after a while.
Not really sure what is the cause of this. Worked before but doesn't work now.
Tested on two rolling release distributions (Arch and Void).
Hello,
i get "WARNING: Frequency should be in megahertz between 76.0 and 108.0, but is 0.000000 MHz
".
i have set all parameters. in an older versions it runs
First of all: great work and thanks for making the raspi-fm-tool even better!
for testing purposes i would like to know if you plan to implement a RDS-TMC command for sending traffic related stuff via location and event codes.. as listed here for example:
https://wiki.openstreetmap.org/wiki/TMC/Event_Code_List
//EDIT: after some research i guess it needs to sit somewhere in get_rds_group(); .. and it looks like TMC is a 8A package and found something useful.. but dont know if i get it to work alone
https://www.defcon.org/images/defcon-15/dc15-presentations/dc-15-barisani_and_bianco.pdf
greetings
Hello,
I just pushed a pretty big change to this project.
PiFmAdv is now modulating the PLLC instead of clock divider. This has a big impact on quality. The stereo reception is now much better. Also stations on close frequencies to PiFmAdv aren't jammed and can be listened to even in close range to PiFmAdv antenna.
This is all great but this change has also some negative impact.
Firstly you need to add gpu_freq=250
to /boot/config.txt
to prevent frequency stability issues.
It would be much appreciated if you guys would test it out and post feedback on this issue!
Hey there!
Is it possible to change what GPIO the program broadcasts on? A project I'm working on has a HAT that goes on top of GPIO 4 (Pin 7) but leaves the others untouched. Is there a way to have the program broadcast on another GPIO pin, one that isn't in use?
No transmit signal but nevertheless console indicate opposite (it indicates startng to transmit on xx.x mhz) when use a sox source audio.
If i only use ./pi_fm_adb command, the transmision is ok.
EDIT: This issue happens to me with the example file of the tutorial "http://www.linuxvoice.com/episodes/lv_s02e01.mp3"
With PiFmRds it works correctly.
And no audio output hearing in the radio.Then I used my rtlsdr to check the spectrum ,there is no siganal . But when i use the old version of rds.c committed on13 Nov. And after compiling ,it can output audio but stuck again .I dont know what happened .
Thank for your such intersting software.
run two instance of PiFmAdv.
Will it work??
Will it halve the uotput power for each signal?
The program seems to malfunction after around 3 to 4 hours.
A high pitched constant noise is made after several overruns.
Original PiFmRds did not make this noise and would just exit the program, which was better because I had the program in a loop, so it would just start again.
Please try and get this fixed, it would make the program perfect!
Thanks!
IS raspberry pi 3 Radio MORE powerful than pi 2
If so how much do you think, will it be a bigger range?
[root@alarmpi fm]# ./pi_fm_adv --rds 0
Carrier: 107.90 Mhz, VCO: 971.1 MHz, Multiplier: 50.578125, Divider: 9
Allocating physical memory: size = 4354048, mem_ref = 5, bus_addr = fd6c8000, virt_addr = 0x76771000
Master PLLA Locked
PPM correction is 0.0000, divider is 2129.6052 (2129 + 2479*2^-12).
RDS Options:
RDS: 0
Starting to transmit on 107.9 MHz.
the parameter rds 0 results in irregular signal transmitting.
thanks for your program !
Hi, thank you for the software!
I'm trying to broadcast audio without latency. I was thinking about JACK to do that, but I can't pipe jack-stdout with pi_fm_adv because "Error: could not open stdin for audio input."
Raspbian Stretch
Any ideas ?
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!
When I start the program it crashes my pi..
I cannot VNC or anything but it doesnt shutdown it just freezes.
Hello! I've used this program for quite a while, however it was a few months ago that I stopped using it. I'm reinstalling it now and plan on using it!
I've got it installed, and I can start it and it says it's running (playing nothing), but once I try to use an audio file, or pipe audio to it, it errors and says the following:
Error: could not open input file udio
I've searched online but can't figure out what this means or how to fix it.
Any help would be appreciated!
Thank you!
The RT A/B flag does not seem to work no matter how many times I try. I tried the following command and nothing seems to happen on the RT display in SDRsharp.
echo -e "AB ON\nRT some text"
Doing the commands one at a time makes no difference and RDS Spy does not show the bit changing.
Hi,
im testing it with a Raspberry Pi 3 and 3B+, the radio works but when the program exits it brokes the network connections.
The wifi is still connected, but ping, ssh,... do not work anymore.
I have debugging a bit and it hangs at terminate function "Set GPIOs to be an output (instead of ALT FUNC 0, which is the clock)."
Trying with an older version, works fine at Pi 3, but at Pi3B+ occurs the same at code "Switch EMMC over to PLLD"
Thanks.
Ok so what is -mpx I’m guessing it’s used to limit the output power or something or like could
I set -mpx 1000000 and expect it to go to the moon?? His lol
But yeh
Hi,
is it working on a pi zero?
Using --af doesn't work with the Raspberry Pi 2 B
Hi, when I start the Audio, it just works fine. Unless I exit the Terminal Window or after a few seconds. Then it happens, that the Audio just freezes, and the whole System just seems to collide...
EXTRA RDS
BETTER QUALITY
AMAZING THX FOR MAKING!!!!
Hey there, the new feature that you just added, adding a flag to change what GPIO pin it is broadcasted on, when I run the program without the flag, it works like normal, but when I use
--gpio 20
It freezes the entire SSH session and after I force close it, it will not let me reconnect until I unplug the pi and plug it back in.
Any ideas?
I want cars to be able to switch to my station maybe using some combination of RDS TA and EON on other stations....
Or maybe rds EAS pty 31 the Emergency Alert System but I think it only works in America.
So basically I want the cars to switch to my station as soon as there in range.
Just for testing thanks
Not really an issue, but it would would be really useful to have the same syntax on both this and the "classic" version, as I could implement both versions in mpradio just by letting the user change the executable path
I just bought a USB microphone adapter, so I can use my phone to pipe audio directly into PiFmAdv. However, when piping audio, there is a ticking noise that can be heard around every second. I recorded a few seconds of this, can be heard here. This ticking sound can be heard whether my phone is actually playing audio or not, and even pressing the "mute microphone" button on my USB adapter doesn't stop the sound. I recorded audio with the adapter on my PC, and there isn't any ticking there, and it doesn't happen when transmitting a .wav file directly. I'm not sure what is causing this, but it's very audible even when playing music, so it's rather annoying.
Can I hook up to an external Transmitter somehow
I want to boost range.
And if i was too would RDS work?
****** Considering the transmitter has Low-Pass, will this filter out RDS???? ***
Hey there,
I was wondering if it's possible to output the audio to the 3.5mm jack so I can connect it to my own transmitter?
have a question but had to make issue , sorry.
lets say my house.
.====.
| |
||
| | <------ Transmitter downstairs (Worse reception)
But then...
.====.
| | <------ Transmitter Upstairs (I get much better reception)
||
| |
But this is slightly inconvenient and I would like to possibly have the Raspberry Pi Downstairs.
Can i have a wire traveling up the side of my house. and expect the range to be the same as if the Pi were upstairs.
.====.
| ( ( |(+ ) ) ) ) <--- End of wire and then radio waves.
|________| |<---- Wire from RPI
| Pi |-| <-----Raspberry pi downstairs
Because surely there would be waves generated throughout the height of the wire. up the house.
So intern there would be less waves generated at the top..
.====.
| | + ) ) ) ) ) ) ) ) ) ) ) <-- radio waves generated at end of wire.
|________| |<--- wire
| |-|<--- Rpi
Thats what i want cos more radio waves generated at higher altitude.
.====.
| | + )}}} less waves at top
|________| | }}}}
| |-| }}}} - Waves generated from all parts of wire!
If you know anything about this that would be great.
I cna hear the audio playing slowly and I get overruns about 10 secs after starting PiFmAdv.
Starting to transmit on 107.9 MHz.
overrun!!! (at least 54.438 ms long)
overrun!!! (at least 29.159 ms long)
My command:
#!/bin/bash
cd /home/pi/PiFmAdv/src
while :; do
sudo arecord -fS16_LE -r 44100 -D hw:Loopback,1,0 -c 2 - | sudo ./pi_fm_adv -ps "Niall FM" -ctl rds_ctl -audio -
sleep 2s
echo "restart"
done
When I sudo reboot when the tx is on I get disconnected from ssh as usual but the pi is still on and I can still hear music on the radio.
So then I pull the power source off.
Not a major problem just wanted to let you know.
Hi.
Please add the TP flag so I can use it with TA.
Mwahaha, THEY WILL BE FORCED TO LISTEN TO MY RADIO.
... If they have TP enabled in the car of course.
Hello,
I have some issue using a pipe with PiFmAdv, however I do not find this issue with PiFmRds.
When I execute the command: sudo arecord -fS16_LE -r 44100 -Dplughw: 1.0 -c 2 - | sudo / home / pi / PiFmAdv / src / pi_fm_adv --freq 105.10 --audio -
no error but the program cuts off just after starting it.
Same without pipe : sudo /home/pi/PiFmAdv/src/pi_fm_adv --freq 105.10 --audio /home/pi/cc.wav --ps ST-PIFM --rt 'St-PIFM RADIO' --mpx 70 --power 7 --gpio 4 --preemph 'eu'
Regards,
Thanks
(In pifmrds : sudo arecord -fS16_LE -r 44100 -Dplughw:1,0 -c 2 - | sudo /home/pi/PiFmRds/src/pi_fm_rds -freq 105.10 -audio -
)
Works fine when booted to CLI.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.