Opendigitalradio / dablin

DAB/DAB+ receiver for Linux (including ETI-NI and EDI AF playback)
GNU General Public License v3.0
118 stars 26 forks source link

DAB sample rate incorrect on some radio stations yet other streams are fine on the same mux #74

Closed diddy-boy closed 6 months ago

diddy-boy commented 7 months ago

Hi there Dablin is being used as part of another project but some radio channels on the same mux sound odd at the wrong sample rate.

There is at least one stream issue for every digital mux here in the UK. I have referenced the main national DAB mux for the BBC as this issue can be reproduced by anyone with DAB on openwebrx in the UK.

The DAB mux in question is :-

https://en.wikipedia.org/wiki/BBC_National_DAB

This mux consists of the radio stations :-

BBC Radio 1 BBC Radio 2 BBC Radio 3 BBC Radio 4 BBC Radio 5 Live BBC Radio 6 Music BBC Radio 1 Xtra BBC Radio 4 Xtra BBC AsianNetwork BBC World Service

All stations work correctly except :- BBC Radio 5 Live (64-80 kbit/s Mono) BBC Radio 4 xtra (80 kbit/s Mono) BBC AsianNetwork (64 kbit/s Mono) BBC World Service (64Kbit/s Mono)

They all sound like Alvin and the Chipmunks. I suspect that its because the streams are mono. Is this an issue in Dablin ?

thanks in advance Rich

andimik commented 7 months ago

This sounds more a problem with either your sound card or ffmpeg.

basicmaster commented 7 months ago

@diddy-boy You refer to the embedded use as part of OpenWebRX, don't you? Apparently OpenWebRX assumes a fixed sample rate of 48 kHz and Stereo audio. However for PCM output (which is used by OpenWebRX here) DABlin uses the native sample rate and channel count of the actual service. This may vary, e.g. BBC Radio 1 has 48 kHz Stereo, while BBC World Service has 48 kHz Mono (and e.g. BFBS UK on SDL National has 32 kHz Mono). So everytime a service doesn't match 48 kHz Stereo, it won't sound right.

A simple solution would be to let DABlin output the audio in encoded form (just a lossless repackaging that doesn't consume much CPU power) via the -u parameter and add a separate audio player (ffplay of vlc) afterwards in the processing chain.

Another solution would be to add support to DABlin for always using the same fixed sample rate/channel count for PCM output. But this might require sample rate conversion in case the audio decoders for MP2/AAC don't have built-in support for this...

diddy-boy commented 7 months ago

Hi Stefan Yes I am refering to Openwebrx, how would you guess ? lol

thank you for the reply. Here in the UK, the government has gone for cramming in as many digital stations as possible over quality hence the mess we have.

Thanks for the reply

Regards

Richard

On Mon, 11 Mar 2024 at 20:10, Stefan Pöschel @.***> wrote:

@diddy-boy https://github.com/diddy-boy You refer to the embedded use as part of OpenWebRX, don't you? Apparently OpenWebRX assumes a fixed sample rate of 48 kHz and Stereo audio https://github.com/luarvique/openwebrx/blob/846c7fa19604ec5c9b1261703a0cf93ba98f9607/csdr/chain/dablin.py#L94. However for PCM output (which is used by OpenWebRX here https://github.com/luarvique/openwebrx/blob/846c7fa19604ec5c9b1261703a0cf93ba98f9607/csdr/module/toolbox.py#L171) DABlin uses the native sample rate and channel count of the actual service. This may vary, e.g. BBC Radio 1 has 48 kHz Stereo, while BBC World Service has 48 kHz Mono (and e.g. BFBS UK on SDL National has 32 kHz Mono). So everytime a service doesn't match 48 kHz Stereo, it won't sound right.

A simple solution would be to let DABlin output the audio in encoded form (just a lossless repackaging that doesn't consume much CPU power) via the -u parameter and add a separate audio player (ffplay of vlc) afterwards in the processing chain.

Another solution would be to add support to DABlin for always using the same fixed sample rate/channel count for PCM output. But this might require sample rate conversion in case the audio decoders for MP2/AAC don't have built-in support for this...

— Reply to this email directly, view it on GitHub https://github.com/Opendigitalradio/dablin/issues/74#issuecomment-1989344234, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUIOCVE67YL2AGSZCUM6T73YXYFS5AVCNFSM6AAAAABEQNK7DCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOBZGM2DIMRTGQ . You are receiving this because you were mentioned.Message ID: @.***>

basicmaster commented 7 months ago

There is a further way to address jketterl/openwebrx#155: I could add an additional output option that still outputs the PCM samples, but initially prepends a RIFF WAVE header. This way @jketterl could retrieve sample rate/sample format/channel count of the PCM samples and configure the audio output of OpenWebRX accordingly.

basicmaster commented 6 months ago

I just added a RIFF WAVE output. This way the necessary parameters can be derived from the prepended header, for correct audio output.

I hereby also changed the sample format to always 16bit integer, as 32bit float makes the WAVE output more complex. 16bit CD quality should be sufficient for DAB here.

diddy-boy commented 6 months ago

Brilliant.

Thanks for that Hopefully this should fix the dab sample rate issues on some muxes

Rich

On Sat, 30 Mar 2024 at 11:20 am, Stefan Pöschel @.***> wrote:

I just added a RIFF WAVE output. This way the necessary parameters can be derived from the prepended header, for correct audio output.

I hereby also changed the sample format to always 16bit integer, as 32bit float makes the WAVE output more complex. 16bit CD quality should be sufficient for DAB here.

— Reply to this email directly, view it on GitHub https://github.com/Opendigitalradio/dablin/issues/74#issuecomment-2028017847, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUIOCVAZAIVJTY3EGL5HG7DY22GWFAVCNFSM6AAAAABEQNK7DCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRYGAYTOOBUG4 . You are receiving this because you were mentioned.Message ID: @.***>