Difference between revisions of "DAB/DAB+"

From Sundtek Wiki
Jump to navigation Jump to search
Line 98: Line 98:
 
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
 
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
 +
</pre>
 +
 +
=== C API ===
 +
 +
==== scan for DAB/DAB Frequencies ====
 +
 +
example:
 +
<pre>
 +
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;
 +
}
 
</pre>
 
</pre>

Revision as of 14:25, 25 July 2019

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

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


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/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;
}