Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use mpd/mpc with PiFmRds to rebroadcast internet radios and/or MP3 playlist #73

Open
pilovis opened this Issue Jan 19, 2017 · 10 comments

Comments

Projects
None yet
3 participants
@pilovis
Copy link

pilovis commented Jan 19, 2017

This is the audio section for /etc/mpd.conf to use PiFmRds as the output audio device:

audio_output {
type "pipe"
name "PiFm"
command "sox -t raw -esi -b32 -c2 -r44100 - -t wav - firfit /root/75usPreEmphasis.ff | sudo /root/PiFmRds/src/pi_fm_rds -freq 88.0 -rt 'Rochenroll Ciulers' -ps RADIO-88 -audio -"
format "44100:32:2"
}

note: eventually adjust the paths on the above, same for frequence, rt and ps.
don't forget to comment out (or to remove) all the other "audio_output" sections

You need to push your Rasperry Pi2 up to 1000 Mhz (Pi2 overclock), to get good results (cpu and LAN controller heathsinks needed for prolungate operations).

CPU usage is about 55% @ 1000 Mhz overclocking on Pi2.

@pilovis

This comment has been minimized.

Copy link
Author

pilovis commented Jan 19, 2017

sudo apt-get install sox
sudo apt-get install lame
sudo apt-get install libsox-fmt-mp3

@pilovis

This comment has been minimized.

Copy link
Author

pilovis commented Jan 19, 2017

this is my 75usPreEmphasis.ff file , not a real 75 or 50uS emphasis, but it gives the best audio output, at least here in Europe:

20 0.000
50 0.001
100 0.004
500 0.096
600 0.138
700 0.186
800 0.241
900 0.303
1000 0.370
2000 1.290
3000 2.430
4000 3.540
5000 4.530
6000 5.380
7000 6.100
8000 6.690
9000 7.190
10000 7.610
11000 7.950
12000 8.250
13000 8.490
14000 8.710
15000 8.890
16000 9.050
17000 9.180
18000 9.300
19000 9.400
20000 9.490
21000 10.000
22000 10.313
23000 10.696
24000 11.063

@pilovis

This comment has been minimized.

Copy link
Author

pilovis commented Jan 19, 2017

The best would be to get the playing song's name/artist from MPD with "mpc current" command and to inject it to RDS "rt"

@pilovis

This comment has been minimized.

Copy link
Author

pilovis commented Jan 19, 2017

I have an idea, what about if we create a network of PiFmRDS transmitters, all connected to a single and centralized internet radio stream?
Something like PiFmRDSNetradio :)
Each transmitter uses a very low transmitting power (mostly legal in many countries), but by connecting many togheter, located in different areas, we could create a bigger coverage, like the huge WiFi FON free hot spots.

@pilovis

This comment has been minimized.

Copy link
Author

pilovis commented Jan 19, 2017

By connecting an antenna like this one, the coverage range will increase up to 500 mt in open air without obstacles (you should check before if it is legal on your country, probably not ...):

https://www.amazon.com/Stellar-Labs-30-2435-Outdoor-Omnidirectional/dp/B00DHHOZBI

connect the hot pole of the antenna, by a 75 ohm coaxial cable, to a capacitor of 1 nF connected in series to the GPIO 4 of the Raspberry (needed to avoid short circuit vs GND) and the cold pole to GND of raspberry and also to ground (earth ground) like this picture: http://www.hamradio.in/circuits/images/FMAntenna_Fig2.gif

Keep the coaxial cable lenght shorter than a few meters.

A bandpass filter between raspberry and the antenna, to cut the harmonics frequences, is absolutely needed!
like this one: http://electronics-diy.com/schematics/803/LPF+Bro.gif (keep connections as short as possible, use ceramic capacitors and don't forget the 1nf capacitor soldered to GPIO4 pin (in series) to avoid short circuit vs GND).
Filter used for eliminate unwanted harmonic frequency at second and third. Notch filter, Band Pass Filter (BPF), and High Pass Filter (HPF) sometime combined in constructing LPF design. Schematic below for FM Broadcast Lowpass Filter 88-108 MHz. It has been tested with a good result. Note : Make the coils at 74 nH and eventually trim them to adjust exact value.

@pilovis

This comment has been minimized.

Copy link
Author

pilovis commented Jan 20, 2017

If you want to make the transmitter more robust and less sensitive to micro network outages, add these lines at the end of the /etc/mpd.conf file:

samplerate_converter "internal"
audio_buffer_size "8192"
buffer_before_play "10%"

To get more infos on MPD/MPC see my specific how-to on OpenWRT forum:
[HowTo] Openwrt cheap Digital Stereo WiFi Internet Radio & MP3 Player
https://forum.openwrt.org/viewtopic.php?id=49013

@Santanix

This comment has been minimized.

Copy link

Santanix commented Feb 13, 2017

Hello!
I'm new to Pi but I manage to trasmit mpd music to FM. What I cannot is with your code because I can't find the file "75usPreEmphasis.ff". I hear some background noise and in another thread you say the sound get better with PreEmphasis. My cod working is:

audio_output {
type "pipe"
name "PiFm"
command "sox -t raw -b 32 -c 2 -r 44100 -e signed-integer - -t wav -b 32 -c 2 -r 44100 - | sudo /home/pi/PiFmRds/src/pi_fm_rds -audio -"
format "44100:32:1"
}

Can you explain how I can get PreEnphasis working with your file PreEnphasis?

Thank you!

@spabinger

This comment has been minimized.

Copy link

spabinger commented Mar 13, 2017

Add this parameter to your sox command (see first post)
- firfit /root/75usPreEmphasis.ff

@Santanix

This comment has been minimized.

Copy link

Santanix commented Mar 13, 2017

Thanks for the reply!
I manage to get it working with the code equal to yours, I only changed the path to the file 75usPreEmphasis because I couldn't find the file so I created one in dir of PiFmRds.
command "sox -t raw -esi -b32 -c2 -r44100 - -t wav - firfit /pi/PiFmRds/75usPreEmphasis.ff | sudo /pi/PiFmRds/src/pi_fm_rds -audio -"
format "44100:32:2"
Is ok making the PreEmphasis file? ( I make a test file, changed the name and termination like above, and inside are the numbers you posted here)
Again, Thank You!

@pilovis

This comment has been minimized.

Copy link
Author

pilovis commented Sep 10, 2018

see here for updated how-to:

miegl/PiFmAdv#37

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.