mirror of
https://github.com/JvanKatwijk/dab-cmdline
synced 2025-10-05 15:42:46 +02:00
Example 3 Example 3 is an example program, not using the library, but binding directly to the functions implementing the dab decoding. All callbacks are defined, most of them with an empty body. In this version, we send the audio output directly to stdout rather than - using portaudio - sending it to the soundcard. >>>>>>>>>>>>> NOTES <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< a. There is no rate conversion done, the pcm samples, as arriving from the mp2 or aac decoder are just passed on The pcmHandler has as one of its parameters the rate b. If you want to pipe the output to e.g. aplay then be aware that there might be gaps. If a data fragment can not be decoded, no PCM samples are emitted. For aac these are segments of 24 msec In order to ensure a continuous stream of samples out you may define STREAM_OUTPUT (see CMakeLists.txt) file, in which case the samples are fed into a separate thread that will fill in gaps with values 0. Note however, that still no rate conversion takes place. While the Dutch services as as far as I know all 48000 samples/second, e.g. in Switzerland theu are not. >>>>>>>>>>>>>>>>END OF NOTE <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< See the file main.cpp for the command line options. I just tried to have the command line options similar to the ones of example 2 (However, choises for audio output are obviously not available). Feel free to improve the program Points to note: bytesOut is a new callback function, a function that is called from the tdc handler (and later may be from others as well) The data parameter is a packet with a 4 byte header byte 0 is 0xFF byte 1 is 0x00 byte 2 is 0xFF byte 3 is 0x00 byte 4 is the high byte of the 16 bit size byte 5 is the low byte of the 16 bit size byte 6 is 0x00 byte 7 is 0 for packet type 0, 0xFF for packet type 1 Note that the lenngth is the length of the data part, so not taking the header into account The bytesOut function puts the data into a simple TCP server that can be read from port 8888 (depending on the configuration).