RustAudio / rodio

Rust audio playback library
Apache License 2.0
1.72k stars 223 forks source link

Playback of CDDA (audio CD) #607

Open kayhannay opened 1 week ago

kayhannay commented 1 week ago

Hello, I'm wondering if it is possible to play an audio CD via rodio. I have no idea how to handle this. I know CDDA is a bit old fashioned, but I work on a music player for my kids and they often listen to audio CDs. Do you have any idea how to solve this? Tanks a lot!

dvdsk commented 1 week ago

CDDA is just PCM at 16bit 44100hz its not that different then wav. You will need to write a 'decoder' that provides rodio with 16 bit samples. Decoders in rodio implement Source a trait that is similar to the standard library's iterator trait. Except Source always iterates over PCM samples (audio samples) and provides some extra info such as number of channels and sample rate.

Unfortunately to figure out the details such as where the pcm audio starts on the cd you will need a copy of IEC 60908:1999. That currently retails for around 400 euro's/dollars. Though you could get it in other ways...

A simpler method may be to recognize the inserted disc and then play the corresponding ripped audio?

dvdsk commented 1 week ago

oh nevermind I just rememberd that CDDA contains error recovery codes. So not a simple PCM stream... There are crates that decode reed-soloman but CDDA uses a modified version of reed soloman .....

Tbh this sounds like a herculean effort. I looked through the IEC 60908:1999 and it scares me...

If I where you I would not use rodio but have your application wrap some command line linux tool for cd playback.

dvdsk commented 1 week ago

oh and yet another alternative: find a C or C++ library that decodes CDDA streams then generate Rust bindings using bindgen and use that as a decoder with rodio