DAB receiver - SDR-J DAB

SDR-J-DAB 0.98∗
Software for SDR: the DAB receiver(s)
Jan van Katwijk
Lazy Chair Computing
The Netherlands
[email protected]
February 17, 2015
∗
©: 2015, Jan van Katwijk, Lazy Chair Computing
1
1
Introduction
Differences between versions 0.97 and 0.96 Modifications to the DAB software when
compared to the 0.96 version are limited.
• One of the unresolved issus in the previous version(s) of the DAB receiver was that
the audio-outputbuffer tended to overflow regularly. This lead to ticking in the outputstream (when the - pretty large - buffers were full and then data was just thrown away).
Measurement showed that for each AAC segment in a DAB+ stream, a segment containing 120 msec, PCM samples good for not less than 127 msec audio were generated.
It seems that the faad software interprets the AAC960 code as AAC1024 code, which
would explain the difference. Since the faad library is borrowed and not under control,
we ”solved” this issue by extending the software pipeline by a downsampler from 51200
to 48000 samples per second1 . Obviously, there is the opportunity to switch off this
additional downsampler by a setting in the .ini file.
• A second modification was adding the interface to the Mirics sdrPlay. Thanks to the
Mirics people who made libraries available for both Windows and Linux, it was pretty
simple to interface to the sdrPlay.
• A third modification was re¨ımplementing the dumping facility. With the addition of
support for the Mirics device with more (at least 10) bits per sample, the dumping
facility was extended to generate common .wav files. (For backwards compatibility, the
possibility of reading in .raw files is maintained.)
• A fourth issue was the configuration selection between em ffmpeg and KJMP resp. ffmpeg
and faad in generating the executables. It was decided to simplify the building process
by eliminating the choice: now all DAB frames are processed using KJMP, all DAB+
frames are processed using faad2 .
• Finally - an implementation detail - the handling of the DABstick interface for Windows
and Linux was harmonized. The required functions from the ”.dll” under Windows
resp. ”.so” under Linux for both Mirics devices and DABsticks are loaded dynamically:
running the program in absence of the library for the device is certainly possible (using
the device is not).
Differences between versions 0.98 and 0.97 From a user’s perspective the main difference is that a second version of the DAB software with a very limited GUI - the mini - is
made part of the distribution. The difference between these two versions is the GUI and GUI
handling, they share all code for the actual data processing.
A second difference is the addition of the Airspy device in the list of supported devices.
As is well known, ExtioXXX.dll files are constrained to 32 bits Windows, and since the DAB
software requires 64 bit Windows, ExtioXXX.dll’s cannot be used in the interface.
1
2
Work is being done to look for the correct settings of the faad library
It is not too complicated to modify the code such that the ffmpeg library is used.
2
A third - minor - difference is the addition of a small colored field indicating the state of
time synchronization: green is OK, blue means that the signalstrength is low, but the software
is trying, and yellow means it is hopeless with this signal.
A fourth difference is that now for each of the selected devices a small frame will pop-up
when the device is selected, where settings specific to the device are handled.
The DAB software has been tested under Windows 7, and various 64 bits versions of both
Ubuntu and Fedora.
2
Installation
The DABreceiver software comes - as the other members of the SDR-J family - in two flavors:
for Windows 64 there is a single zipped folder containing the executables of the DAB receivers
as well as some of the required dlls. For Linux, sources are available and one has to create the
executables.
2.1
Installation under Windows
Just unpack the zipped file. A folder windows64-bin will be created that contains the executables and (almost) all required ”.dll”’s. For using either a Mirics sdrPlay or a DABstick, some
additional steps have to be taken.
Mirics sdrPlay One has to install a Mirics driver through a Mirics installer program. The
libraries and installation software for the Mirics sdrPlay can be obtained from the developers
http://www.sdrplay.com/downloads.html. If/when installation is successful, the appropriate
”.dll” will be found when running either of the dabreceivers.
DABsticks For successfully running the software with a DABstick, one has to obtain the
appropriate rtlsdr.dll file, and one needs to install another usb driver for the RTL2832 based
sticks. Installing the right USB driver is done by the Zadig program. There are many examples
on the internet how to run Zadig. Basically just run the Zadig program with the DABstick
inserted in one of the USB ports. The Zadig program (should) detect(s) the DABstick, and
will suggest WinUSB as a replacement.
Downloading the ”.dll” file is best done from the site of the developers http://sdr.osmocom.org/trac/wiki/rtlsdr. Pls ensure that you download the 64 bit version. Place the ”.dll” file in the windows64-bin
folder or adjust the searchpath.
2.2
Installation under Linux
For developing executables under Linux, the packed sources are available. A brief description
of building for Linux is given in section 4 of this manual. That section also contains some notes
on the installation of libraries required for the Mirics device and the DABstick under Linux.
3
3
Running the DABreceivers
Starting the program is by clicking on its icon or using a command line in a command window
with the (path)name of the program.
3.1
The DAB-mini
The first start of the DAB-mini program is to be done in a command line setting: one has to
specify the device that is being used. Open a command window, ”cd” to the folder where the
program is kept, and start the program with
sdr-j-dab-mini -D XXXXX
where XXX is to be replaced by either ”sdrplay” for the Mirics sdrplay, by ”dabstick” for
RT2832 based DABsticks, or ”airspy” for the airspy device.
By default the program will start up with as selected band ”Band III”, and will be configured to use DAB Mode 1. The band can be selected in the command line, as can the
Mode.
dab-mini -D sdrplay -M "Mode 1" -B L_Band
will select the sdrPlay as device, Mode 1 as mode and the L Band for the channel selection.
For Mode one may use ”Mode 1”, ”Mode 2”, ”Mode 3” and ”Mode 4”, for the band one may
use ”L BAND” and ”MODE III”. Do not forget the quotes.
These parameter settings will be stored and used the next times the program is started.
So there is no need to specify the parameters once they are set. When a parameter is given in
the command line, it overrules previous choices.
The dab-mini will start automatically and will try to identify an ensemble.
Channel selection - in the selected band - is possible through the combobox on the bottom left
on the GUI, gain selection (actually selection of gain reduction) is possible using the spinbox
to the right of the channel selector. The indicator on the screen needs to be green, in which
case time synchronization is ok. If yellow or blue, no (time) synchronization has been achieved.
Output selection is by the remaining combobox.
It may take some time before an ensemble - and its constituents - can be
identified. In weak signal environments, it might be helpful to press the reset
button, such that the synchronization process is restarted. It also might be helpful
to find a suitable setting for the ”gain” selector, depending on the specific conditions.
3.2
The DAB receiver
Starting the program will set it in an idle state. Before processing can start, one has to select
a device through clicking on an entry on the appropriate combobox. Supported devices are:
• no device. No input device will be selected, input will consist of nothing;
4
• sdrPlay. A Mirics sdrPlay as input device is assumed to be connected to an USB port.
Output of the sdrPlay device - and thus program input - consists of a raw stream of 10
bit integer values, mapped onto complex I/Q samples by the software.
• DABstick. A DAB-stick as input device is assumed to be connected to an USB port.
DAB-stick output - and thus program input - consists of a raw byte stream, mapped
onto complex I/Q samples by the software.
• airspy. An airspy device as input is assumed to be connected to an USB port. ”.raw”
file input. A menu will be displayed for selecting a file. The raw bytes in this file will
be the input. Note that the format of the input is a raw stream of I/Q data bytes as
delivered by the DAB-stick. The filename should have an extension ”.raw”. Such a file
could have been generated by previous versions of the DABreceiver software. Current
”dumping” creates a ”.wav” file.
• ”.wav” file input. A menu will be displayed for selecting a file. The data in this file will
be used as input. ”.wav” files, suitable as input file, can be generated by the program
itself. Note that only ”.wav” files with the correct samplerate (2048000) and 2 channels
will be accepted.
If/when a device is selected a small window will apear with settings specific to the device, i.e.
gain, offsets etc.
The program will use an ”.ini” file, $(HOME)/.jsdr-dab.ini for obtaining some state information from previous sessions and for some general configuration data. Absence of the ”.ini”
file (as will be the case in most cases on a first invocation of the program) will not harm
the program, just some (seemingly) suitable default values will be chosen and - after normal
program termination - the ”.ini” file will be created.
It is common practice to just start the programs and quit it to obtain an ”.ini” files with
default values.
5
After having selected a device (selector labeled ”1”), the user of the DABreceiver may select
a Mode (selector labeled ”2”), a band (selector labeled ”3”), and a channel (selector labeled
”4”). The channels map onto the standardized frequencies for the DAB channels in the selected
band.
Mode is by default set to Mode ”1”, band to ”III”.
Actual running of the program will start after pressing the ”START” button (labeled ”5”).
When started, the DABreceiver will to try to synchronize with the incoming data: this may
take (quite) some time, depending on the quality of the received signal. In general, one will
see the spectrum first, and, as soon as there is time synchronization, dots of the signal will
show in the black screen. The more the collection of dots resembles a large ’X’, the better the
quality of the signal. The execution of the program can be stopped by pressing the ”QUIT”
button (labeled ”6”) The button labeled ”15” selects between a spectrumview and a waterfall
view on the incoming data.
When synchronized, the program will try to identify the name of the ensemble and the
names of the programs encoded within the ensemble. As soon as correct data is found, the
names of the stations covered by the ensemble will be displayed (16). Selecting such a particular
station in the list by clicking with the mouse on it will start further decoding and might lead
to sound output.
When in sync, three numbers, right from the device and channel selector, are displayed in
larger digits:
• the detected offset in KHz. A simple mechanism is applied to try to correct for a possible
deviation of the oscillator of the device. When synchronized, the offset in KHz, as
found by the software, will be displayed. The number just below this Khz offset is the
instantaneous offset in Hz, which may vary during reception due to e.g. atmospheric
conditions.
6
• the actual, detected, length of the frames in number of samples, which should be 196606.
• the actual samplerate, which should be 2048000
The bottom line of the GUI will show (technical) information on the selected station. The
display top-left shows one OFDM symbol of each frame in the complex plane. The more a
clear and large X is shown, the better the quality of the received signal. The spectrum display
shows the spectrum of the received signal, it has a width of app 2 MHz.
Dumping the raw input data will be initialized after pressing the ”dump” button (labeled
”7”) and the subsequent selection of a file through the file menu (and stopping after pressing
it again). Writing the PCM audio onto a file is initialized by clicking on the ”audioDump”
button (labeled ”8”) and selecting a file through the file menu that appears. Again, pressing
the button for a second time will stop dumping.
Audio output of the DABreceiver will be sent to a soundcard, the channel on the soundcard
is selected through the selector labeled ”9”. One must realize that after selecting a different
output device, output might have to be restarted by (re-)selecting a ”station”.
Pressing button labeled ”10” will cause a soft reset, i.e. the synchronization will start all
over again. Pressing on button ”MP2”a (labeled ”11”) will ask for selecting a file to which the
MP2 output (i.e. regular DAB output, if any) will be written. Pressing the button again will
close the output file and stop writing. The file then can be used as input to other decoders.
The same applies to button ”AAC” (labeled ”12”) for DAB + output.
Lowering the selected frequency is steps of 1 Khz is done by pressing the button labeled
”13”, similarly, increasing the frequency is steps of 1 Khz is done by pressing the button labeled
”14”. For experimental purposes, there are some more spin-boxes and selectors, these do not
relate to normal operation.
The ”.ini” file Many of the settings for the DABreceiver will be read from the ”.ini” file on
program startup. If no ”.ini” file exists (yet), suitable defaults for the various sliders and selectors are chosen. The default location for the ”.ini” file for the DABreceiver is $(HOME)/.jsdrdab.ini3 . The file contains entries
[General]
band=BAND III
channel=12C
device=dabstick
Concurrent=0
displaySize=2048
iqDisplaysize=512
autoCorrector=1
rateAdjust=2
overflowShown=1
faadcorrect=1
Concurrent is not settable through the GUI, it tells to run the MPEG decoder in a different
thread (value 1) or in the same thread as the rest of the dab decoding (value 0). On a machine
3
Calling the program with -i filename will make the file filename the ”.ini” file
7
with many computing cores, there is a slight gain in efficiency when concurrent execution is
selected.
displaySize cannot be set through the GUI, it is the number of elements in the spectrum
display. The smallest value with reasonable results is 128.
iqDisplaySize indicates the number of points used to create the X on the scope. This size
cannot be altered throug the GUI.
autoCorrector is a boolean value (0 : false, 1 : true). When set the program tries to detect
the correct coarse offset for the selected frequency. When not set, the GUI selectors have to
be used for course synchronization. This setting, default set to 1, cannot be altered through
the GUI.
overflowShown is a boolean value (0 : false, 1 :true). When set the program reports
periodically the amount of overflow in the input buffer. This setting, default set to 0, cannot
be altered through the GUI.
faadcorrect indicates whether or not an internal downconverter from 51200 to 48000 should
be used. The default is set to 1, i.e. a correction will be applied. This setting cannot be altered
through the GUI.
The ”.ini” file will also contain settings for the selected devices.
4
Building the executables under Linux
Unpacking the sources of the distribution is in a single directory sdr-j-dabreceiver-0.98 with as
subdirectories:
• src, where the sources are kept, and
• includes, where the include files reside.
• large-gui, where sources specific to the regular DAB receiver are stored, and
• small-gui, where the sources, specific to the dab-mini are stored.
These latter two directories contain (a.o) a file CMakeLists.txt and a file sdr-j-dabreceiver098.pro. The former contains data for using cmake as generating device, the latter contains
data for QMake as generating device.
Required packages and Libraries
One needs, next to the GNU compiler suite (g++),
• Qt-4.7 or Qt-4.8 (No effort has been made as yet to use Qt-5)
• Qwt 6.x.x. The sources, developed under Fedora, are based on Qwt 6.1.0.
• libusb-1.0,
• libportaudio. Ubuntu 14.04 LTS still supports libportaudio-1.18, as standard package.
Replace this with 1.19, which is easy using the standard package handler.
• libsndfile and libsamplerate,
8
• libfftw3f, we use, different from previous releases, floats rather than doubles and therefore
the libfftw3f,
• libfaad,
• librtlsdr in case one wants to use a DABstick,
• libmirsdrapi-rsp.so, for the sdrPlay.
For these packages, one needs both the library and the development package.
Ubuntu
For Ubuntu a validity check is given in the shell script below
#!/bin/bash
#
echo "Preparing the environment for Ubuntu"
echo "ensure that the udev rules are adapted for the usb devices
echo " "
echo "install packages"
sudo apt-get install gcc g++ \
libqt4-dev libqwt6-qt4 libqwt6-qt4-dev \
libfftw3-3 libfftw3-dev \
alsa-base libasound2 libasound2-dev alsa-utils libasound2-plugins \
libportaudio2 libportaudio-dev \
libsndfile1 libsndfile1-dev \
libsamplerate0 libsamplerate0-dev \
libusb-1.0-0 libusb-1.0-0-dev \
librtlsdr librtlsdr-dev
libfaad libfaad-dev
Note that Ubuntu repositories provide for a package librtlsdr.
Fedora
For Fedora, depending on the distribution, the following script might help
#!/bin/bash
#
echo "Preparing the environment for Fedora"
echo " "
echo "install packages"
sudo yum install gcc gcc-c++ \
qt qt-devel qwt qwt-devel \
fftw fftw-devel \
alsa-lib alsa-lib-devel alsa-tools portaudio portaudio-devel \
libsndfile libsndfile-devel libsamplerate libsamplerate-devel alsa-plugins-samplerate \
libusb1 libusb1-devel \
rtlsdr rtlsdr-devel \
faad2-devel
Note that Fedora (at least recent versions) provide for a package rtlsdr in their repositories.
9
Mirics sdrPlay Mirics Ltd provides on its sdrPlay site www.sdrplay.com a support program
for installing the shared object library, libmirsdrapi-rsp.so. The library will be installed in
/usr/local/lib.
librtlsdr In most cases librtlsdr is indeed available and can be installed through the mechanisms available with the Linux distribution. In case the library is not available, a description
of the library and how to build it is to be found on the osmocom site
http://sdr.osmocom.org/trac/wiki/rtl-sdr
Note that, under Ubuntu 14.04 the kerneldriver dvb usb rtl28xxu needs to be put on the blacklist.
Qmake and CMake The current distribution was built using qmake-qt4 as generator for
Makefiles. qmake will use the .pro file as basis. The ”dabreceiver.pro” file contains - thanks
to contributors - lines that have shown to be working on Fedora, Ubuntu systems and - by
default commented out - on freeBSD. Next to a ”.pro” file, a CMakeLists.txt is available for
use with CMake.
Other Linux distributions most likely will provide the full set of packages required for
building, probably on other locations, in which case the ”.pro” resp. or CMakeLists.txt files
may need to be adapted to the particularities of the different Linux distributions.
When all libraries (including the corresponding ”include” files) are in place, for use with
qmake, one executes in the directory small-gui or large-gui
qmake-qt4
make
to generate the executable, which will be put in the directory mentioned as value of the DEST
variable.
In case CMake is used for building an executable, one creates within either the small-gui
or large-gui directory an empty directory ”build” and calls ”cmake ..”.
mkdir build
cd build
cmake ..
make
sudo make install
The executable will then be created and installed in /usr/local/bin.
It it obviously wise to ensure rights for reading and writing usb port and soundcards before
running the program. One may use the instructions given on the aforementioned osmocom
page, installation instructions for the Mirics dongle or sdrPlay.
5
Final remarks
The SDR-J software uses a number of libraries, made available through (L)GPL style licenses
and parts of the code is based on ideas of others. In all cases attempts are made to indicate
10
the rightfull owner of the copyrights. The software itself is available as is, under a GPL V2
license.
The SDR-J set of software is essentially the result of a hobby project. It is - obviously not finished, after all it is software and it is most likely that it never will be finished. Many
enhancements (and experiments) are still waiting to be done. Contributions in any form, e.g.
by suggestions for extensions, by contributing to code, or by donations for further development.
11