DAB/DAB+

From Sundtek Wiki
Jump to navigation Jump to search

DAB/DAB+

The DAB/DAB+ USB Stick decodes DAB/DAB+ onchip and transfers the decoded audio data fully digital to the host system. Currently Linux and MacOS are supported.

Installation Linux

open a terminal and enter following commands:

sudo -s
wget http://sundtek.de/media/sundtek_netinst.sh
chmod 777 sundtek_netinst.sh
./sundtek_netinst.sh

In case you want to distribute the local stations digitally you can also install our streaming server (again on the commandline)

just run following commands:
sudo -s
/opt/bin/mediaclient --installstreamer

Installation MacOSX

MacOSX:

- https://www.sundtek.de/media/sundtek_driver_macosx_190727.1744.dmg
- https://www.sundtek.de/media/dablet_v0.1.dmg

First install the driver, afterwards dablet_v0.1.dmg

Installation Raspberry PI

In case you don't want to use our radio application, the installation is the same as on a regular linux system

sudo -s
wget http://sundtek.de/media/sundtek_netinst.sh
chmod 777 sundtek_netinst.sh
./sundtek_netinst.sh

Radio Application:

cd $HOME
sudo apt-get install qt5-default
wget http://sundtek.de/media/dablet_raspbian.tar.gz
tar xf dablet_raspbian.tar.gz
./dablet

DAB/DAB+ commandline interface

scan for transponders:

/opt/bin/mediaclient --scandabfrequencies /dev/dab0 
scanning: 5A / 174928000
scanning: 5B / 176640000
scanning: 5C / 178352000
[LOCKED]
scanning: 5D / 180064000
scanning: 6A / 181936000
scanning: 6B / 183648000
scanning: 6C / 185360000
scanning: 6D / 187072000
scanning: 7A / 188928000
scanning: 7B / 190640000
[LOCKED]
scanning: 7C / 192352000
scanning: 7D / 194064000
[LOCKED]
scanning: 8A / 195936000

tune to a transponder:

/opt/bin/mediaclient -m DAB -f 194064000
Using device: /dev/dab0
Tuning: 194064000
[LOCKED]

turn on direct audio playback in the driver (the driver will try to play back audio via alsa, pulseaudio or oss:

/opt/bin/mediaclient -m DAB -g off

scan a dab transponder:

/opt/bin/mediaclient --scandabservices /dev/dab0 
Service Name, Service ID, Component ID
BR-Klassik         0xd314   0xb
Inforadio          0xd335   0x8
FH Europa          0xd496   0x3
radioeins          0xd332   0x1
radioBERLIN 88 8   0xd321   0x6
kulturradio        0xd323   0x5
Fritz              0xd333   0x7
Antenne            0xd431   0x0
SWR3               0xd3a3   0x4
Bayern 2           0xd412   0xc
WDR2               0xd392   0x2
MDR JUMP           0xd3c2   0xd
rbb TPEG           0xe0d11019   0xc00a
rbb EPG            0xe0d01019   0xc009

Tune to a specific DAB station:

/opt/bin/mediaclient -m DAB -f 194064000 --sid 0xd321
Using device: /dev/dab0
Tuning: 194064000, 0xd321
[LOCKED]


Read signal statistics:

/opt/bin/mediaclient --readsignal=0 -d /dev/dab0
FREQUENCY: 178352000  LOCKED: YES  RSSI: 172  SNR:  10 FIC_QUALITY: 100 CNR: 14
FREQUENCY: 178352000  LOCKED: YES  RSSI: 173  SNR:  10 FIC_QUALITY: 100 CNR: 13
FREQUENCY: 178352000  LOCKED: YES  RSSI: 172  SNR:  10 FIC_QUALITY: 100 CNR: 12
FREQUENCY: 178352000  LOCKED: YES  RSSI: 173  SNR:  10 FIC_QUALITY: 100 CNR: 13
FREQUENCY: 178352000  LOCKED: YES  RSSI: 173  SNR:  10 FIC_QUALITY: 100 CNR: 13
FREQUENCY: 178352000  LOCKED: YES  RSSI: 173  SNR:   9 FIC_QUALITY: 100 CNR: 12
FREQUENCY: 178352000  LOCKED: YES  RSSI: 173  SNR:   9 FIC_QUALITY: 100 CNR: 12

C API

Scan for DAB Frequencies

example:

int media_scan_dabfrequencies(char *device, int devfd, int console, int running) {
        int fd;
        int rv;
        int nlen;
        char tmp[30];
        if (devfd>=0)
                fd = devfd;
        else
                fd = net_open(device, O_RDWR);

        if (fd>=0) {
                struct dab_frequency dabf;
                struct dab_tuner dabt;
                int i;
                int e;
                int current_scan_index=-1;
                struct dab_scan_setup setup;
                struct dab_scan_parameters parameters;
                memset(&parameters, 0x0, sizeof(struct dab_scan_parameters));
                memset(&setup, 0x0, sizeof(struct dab_scan_setup));
                net_ioctl(fd, DAB_SCAN_SETUP, &setup);

                do {
                        net_ioctl(fd, DAB_SCAN_NEXT_FREQUENCY, &parameters);
                        if (current_scan_index != parameters.scan_index) {
                                if (console>=0) {
                                        sprintf(tmp, "%s %d\n", dab_frequency_list[parameters.scan_index].channel, dab_frequency_list[parameters.scan_index].freq*1000);
                                        rv=write(console, tmp, nlen);
                                } else {
                                        fprintf(stdout, "%s %d\n", dab_frequency_list[parameters.scan_index].channel, dab_frequency_list[parameters.scan_index].freq*1000);
                                        fflush(stdout);
                                }
                        }

                        switch(parameters.status) {
                        case DAB_SCAN_LOCKED:
                        {
                                if (console>=0) {
                                        rv=write(console, "[LOCKED]\n", 9);
                                } else {
                                        fprintf(stdout, "[LOCKED]\n");
                                }
                                break;
                        }
                        case DAB_SCAN_SEARCHING:
                                usleep(10000);
                                break;
                        case DAB_SCAN_COMPLETE:
                        {
                                if (console>=0) {
                                        rv=write(console, "[FINISHED]\n", 11);
                                } else {
                                        fprintf(stdout, "\nScan completed\n");
                                }
                                break;
                        }
                        }
                        current_scan_index = parameters.scan_index;
                        if (console>=0 && running == 0)
                                break;
                } while (parameters.status != DAB_SCAN_COMPLETE);

                if (devfd == -1)
                        net_close(fd);
        }
        return 0;
}


Scan for DAB Services

int media_scan_dabservices(char *device) {
        int fd;
        int rv;
        int i=0;
        fd = net_open(device, O_RDWR);
        if (fd>=0) {
                struct dab_service service;
                printf("Service Name, Service ID, Component ID\n");
                while(1) {
                        service.id=i++;
                        rv = net_ioctl(fd, DAB_GET_SERVICE, &service);
                        if (rv == -1)
                                break;
                        printf("%16s\t0x%x\t0x%x\n", service.service_name, service.sid, service.comp[0]);
                }
                net_close(fd);
        }
        return 0;
}

DAB Get Date

int media_dab_get_date(char *device) {

       int fd;
       struct dab_time t;
       printf("opening device: %s\n", device);
       fd = net_open(device, O_RDWR);
       memset(&t, 0x0, sizeof(struct dab_time));
       if (fd>=0) {
               printf("GET DAB TIME:\n");
               net_ioctl(fd, DAB_GET_TIME, &t);
               printf("%d-%d-%d %d:%d:%d\n", t.year, t.months, t.days, t.hours, t.minutes, t.seconds);
               net_close(fd);
       }
       return 0;

}

Dab get Ensemble Info

int media_dab_get_ensemble_info(char *device) {
        int fd;
        struct dab_ensemble_info info;
        printf("opening device: %s\n", device);
        fd = net_open(device, O_RDWR);
        if (fd>=0) {
                printf("GET ENSEMBLE INFO:\n");
                net_ioctl(fd, DAB_GET_ENSEMBLE_INFO, &info);
                printf("Ensemble Label: %s\n", info.label);
                net_close(fd);
        }
        return 0;
}

Mute

int set_mute(int fd, char *arg) {
        int type = 0;
        struct v4l2_control control;
        if (strcmp(arg, "off") == 0) {
                control.id = V4L2_CID_AUDIO_MUTE;
                control.value = 0;
                fprintf(stdout, "Enabling audiostream\n");
                net_ioctl(fd, VIDIOC_S_CTRL, &control);
        } else if (strcmp(arg, "on") == 0) {
                fprintf(stdout, "Disabling audiostream\n");
                control.id = V4L2_CID_AUDIO_MUTE;
                control.value = 1;
                net_ioctl(fd, VIDIOC_S_CTRL, &control);
        } else
                fprintf(stdout, "Wrong argument [%s] choose between on|off\n", arg);

        return 0;
}

etc.

There are a few more features, in case you need more details just contact us.