Using the HiFiBerry DAC and JMPX for FM music transmissions
Using the HiFiBerry DAC and JMPX for FM music transmissions
[asis]
A very interesting use case for a 192kHz capable sound card is FM transmission. As a FM transmitter is basically a mono device, it needs some tricks to encode stereo audio. If you also want to integrate data transmissions as your are used from RDS tuners, it gets even more complicated. Basically you have to multiplex 2 low-bandwidth channels into one higher-bandwidth channel. Therefore you will need a sound card that supports at least 96kHz output (for stereo audio) or even 192kHz (if you want to integrate RDS data transmissions). Luckily, all HiFiBerry DAC+ boards support 192KHz output – so you can use this guide with all of our DAC+ boards. There are already software tools available and the HiFiBerry user Jonti Olds has written a very nice guide how to implement this on a Raspberry Pi. It is published here with his permission. You can find the original on his Github project page.
Note: Before buying and connecting an FM transmitter to the Raspberry Pi check out the local regulations in your country. While low-power FM transmitters are legal in many countries, regulations are different in different countries. You can find the FCC regulations for the United State here, look for similar regulations in your country.
Running JMPX on a Raspberry Pi3 with a HiFiBerry DAC+
This was done on the latest version of Raspberrian as of May 2017 (I think it is called Jessie). Typing uname -a
produced Linux raspberrypi 4.4.50-v7+ #970 SMP Mon Feb 20 19:18:29 GMT 2017 armv7l GNU/Linux
. The hardware was a Raspberry Pi3 and a HiFiberry DAC+.
Compiling JMPX
This is easy if you have everything already installed but putting all the packages on your Pi is still a hassle. Most if not all of the packages needed can be installed using the following command. sudo apt-get install qt5-default libopus-dev qt5-qmake libjack-jackd2-dev build-essential qjackctl git
. if I have left something out please let me know.
After all the dependant packages are install now comes the compiling; this can be done by typing the following
cd ~
git clone http://github.com/jontio/JMPX
cd JMPX
qmake && make && sudo make install
By default this will setup JMPX to run with JACK which so far seems to be the only way to successfully run JMPX with Linux.
Installing the HiFiBerry DAC+
For this version Raspberrian installing the HiFiBerry DAC+ is easy but the installation documentation on the HiFiberry site one needed step to get it running with JACK.
First physically install the HiFiBerry DAC+ into the Pi then edit /boot/config.txt
, for example, by typing sudo leafpad /boot/config.txt
leafpad is installed by typing sudo apt-get install leafpad
Comment out the dtparam=audio=on
line, then add the following two lines dtoverlay=hifiberry-dacplus
and dtoverlay=i2s-mmap
The file should look something like the following at the bottom if the ordering of the config.txt
file has not changed sine me writing this.
# Additional overlays and parameters
# are documented /boot/overlays/README
# Enable audio (loads snd_bcm2835)
#dtparam=audio=on
# Enable HiFiBerry DAC+ and mmap for JACK
dtoverlay=hifiberry-dacplus
dtoverlay=i2s-mmap
Now reboot the Pi and you should be ready to go.
Running JMPX
First type qjackctl
in a command window to start the JACK GUI. Pressing the setup button will allow you to configure JACK. Change the setting to match the follow image.
You might want to try increasing frames/period to 8192 by using the CLI interface to jack but for some reason this can’t be done in the GUI.
After exiting the settings window click start to start JACK. Fingers crossed it starts successfully.
Now from another console type JMPX
and click modulate. Clicking connect in qjackctl will bring up the connection window; this allows you to decide what device connects to what other device. The connections can be automated using the patchbay in qjackctl but for now just connect them manually as you need.
Running VLC
Most likely you will want something like VLC running. For programs like these there are usually JACK plugins. For VLC type sudo apt-get install vlc vlc-plugin-jack
. You will need to enable the JACK output in VLC and after doing this VLC will have to be restarted to apply the new setting.
Now VLC should appear in your connections.
Quick real life test
Using just the DSCA input to JMPX and using a low power single chip FM transmitter seemed to work fine.