Rockbox Technical Forums

Support and General Use => Audio Playback, Database and Playlists => Topic started by: mcmurray on October 15, 2007, 12:03:01 AM

Title: Enabling 24bit-44.1/48/88.2/96khz playback - iAudio and others?
Post by: mcmurray on October 15, 2007, 12:03:01 AM
I apologise if I have posted this in the wrong section, but I am very new here.

I noticed that the iAudio x5 (and possibly iPod) hardware allows for 24bit playback .  My question is, what would need to be done to get Rockbox to play 24bit FLAC files on this player?  I'm prepared to do it myself if need be, just need a little guidance on where to look in the source code etc.

Before people ask, yes I can hear and appreciate the difference between 16bit and 24bit, and I have a need for this functionality in a portable player.  

Thank you.
Title: Re: Enabling 24bit-44.1/48/88.2/96khz playback - iAudio and others?
Post by: saratoga on October 15, 2007, 12:27:51 AM

I noticed that the iAudio x5 (and possibly iPod) hardware allows for 24bit playback .  My question is, what would need to be done to get Rockbox to play 24bit FLAC files on this player?  I'm prepared to do it myself if need be, just need a little guidance on where to look in the source code etc.

A lot of the codecs already output at 32 bit precision, however I think the playback engine does eventually truncate/dither everything down to 16 bit.  You'd have to ask preglow about that to be sure.  

That said, no device rockbox runs on (and probably no DAP ever made) has an SNR which is limited by 16 bit resolution, so I don't see a lot of point in using 24 bit sample precision, except maybe a tiny bit of battery saving by eliminating dither for people who actually care about that sort of thing on a DAP.  Otherwise there'd be no practical gain that I can see.

Before people ask, yes I can hear and appreciate the difference between 16bit and 24bit, and I have a need for this functionality in a portable player.  

Well, you're out of luck then.  However, I am curious where you're getting 24 bit material from.
Title: Re: Enabling 24bit-44.1/48/88.2/96khz playback - iAudio and others?
Post by: mcmurray on October 15, 2007, 01:55:59 AM
My 24bit material is from DVD-Audio and DVD-Video rips, also I have been listening to some taped live music in 24bit format (see www.flacmusic.com) which sounds amazing and more is becoming available every day.  I also intend to rip my vinyl collection to 24bit FLAC.

24bit doesn't just provide a better snr than 16 bit, it also provides more resolution (16777216 discrete levels for 24bit as opposed to 65536 levels for 16 bit i.e. much closer to analogue performance), and a higher signal to quantization distortion ratio.  Even though the SNR may not be limited by 16bit, the higher resolution will still be noticable (in the same way that vinyl provides very good resolution in spite of poor SNR).

I will try and contact preglow and see what needs to be done.

edit:  if you are wondering how I rip DVD-Audio, google "ppcmripper"

Title: Re: Enabling 24bit-44.1/48/88.2/96khz playback - iAudio and others?
Post by: lazpete on October 15, 2007, 05:50:21 AM
Im using and listening to ripped albums at 24 bit 96 khz in flac on my sansa e200. Large but fantastic...
Title: Re: Enabling 24bit-44.1/48/88.2/96khz playback - iAudio and others?
Post by: Llorean on October 15, 2007, 05:52:42 AM
The Sansa still plays back at 16/44, so you're wasting a lot of bits there.
Title: Re: Enabling 24bit-44.1/48/88.2/96khz playback - iAudio and others?
Post by: lazpete on October 15, 2007, 06:31:08 AM
Oh, didnt know that.
Well, guess a resampling is in order then.
Title: Re: Enabling 24bit-44.1/48/88.2/96khz playback - iAudio and others?
Post by: mcmurray on October 15, 2007, 07:33:29 AM
I've done some reading on the TI AIC23B audio chip used in the X5 and it seems that with a clock frequency of 11.2896Mhz the only sample rates available are 44.1 and 88.2 Khz.  Not much use since most 24bit material I've come across is either 48khz or 96khz.  Bugga.

I'll look in to the iPod as I heard it may be 24bit capable.
Title: Re: Enabling 24bit-44.1/48/88.2/96khz playback - iAudio and others?
Post by: preglow on October 15, 2007, 09:00:29 AM
I will try and contact preglow and see what needs to be done.
I'll just reply here so other people can read the reply too.
Saratoga is correct in saying that everything is truncated (or dithered, if you have that enabled) to 16 bits. This operation can be changed to other bit depths rather easily in dsp.c, but there are other sides to the problem too:
1. currently, the pcm buffering layer stores everything as 16 bit ints in the queue where the audio is stored before being sent to the DAC. I'm not sure how hard it'd be to change this to 32 bit data.
2. we use DMA for transfering audio to the DAC. Using DMA imposes a limit of maximum 16 bits on us, so we'll need another interrupt based driver for transfering sizes above 16 bits. This driver will be slower than the current DMA one, but I'm not sure how much.
Title: Re: Enabling 24bit-44.1/48/88.2/96khz playback - iAudio and others?
Post by: mcmurray on October 15, 2007, 11:39:11 AM
Thanks for chiming in preglow.  Just one stupid question, why is the DMA transfer limited to 16bits?  
Title: Re: Enabling 24bit-44.1/48/88.2/96khz playback - iAudio and others?
Post by: saratoga on October 15, 2007, 02:26:58 PM
My 24bit material is from DVD-Audio and DVD-Video rips, also I have been listening to some taped live music in 24bit format (see www.flacmusic.com) which sounds amazing and more is becoming available every day.  I also intend to rip my vinyl collection to 24bit FLAC.

Be careful here.  No concert recording is going to have even close to 16 bit resolution, so these should probably be kept at 16 bit.  Likewise, vinyl cannot do 16 bit either, so 24 bit is silly.  DVD-V is just AC3, DTS or MP2 lossy compressed audio, so theres no point in 24 bit playback.  That really just leaves DVD-A, and even that is not always 24 bit.

24bit doesn't just provide a better snr than 16 bit, it also provides more resolution (16777216 discrete levels for 24bit as opposed to 65536 levels for 16 bit i.e. much closer to analogue performance), and a higher signal to quantization distortion ratio.  

These are all the same thing.  The only improvement is that the SNR is no longer restricted to ~ 100dB.  However, this isn't really a limitation, as you can't really hear any wider range, unless you're a child in an anechoic chamber.

Even though the SNR may not be limited by 16bit, the higher resolution will still be noticable (in the same way that vinyl provides very good resolution in spite of poor SNR).

Resolution and SNR are essentially the same thing.  Vinyl provides poor SNR and poor resolution.

Im using and listening to ripped albums at 24 bit 96 khz in flac on my sansa e200. Large but fantastic...

You're listening to our somewhat poor resampler.  You'd get much higher fidelity out of CD audio I'm afraid.  It seems to me you really need to sit down and ABX some of your tracks at 24 bit and at 16 bit.  I think you'll be surprised what the difference really is if you think our resampler sounds "fantastic" :)
Title: Re: Enabling 24bit-44.1/48/88.2/96khz playback - iAudio and others?
Post by: preglow on October 15, 2007, 04:09:12 PM
Thanks for chiming in preglow.  Just one stupid question, why is the DMA transfer limited to 16bits?  
AFAIK just a pure hardware limitation. Nothing more to it, Motorola just didn't put in a possibility to use higher bit depths with DMA.
Title: Re: Enabling 24bit-44.1/48/88.2/96khz playback - iAudio and others?
Post by: mcmurray on October 16, 2007, 02:13:36 AM


Be careful here.  No concert recording is going to have even close to 16 bit resolution, so these should probably be kept at 16 bit.  Likewise, vinyl cannot do 16 bit either, so 24 bit is silly.  DVD-V is just AC3, DTS or MP2 lossy compressed audio, so theres no point in 24 bit playback.  That really just leaves DVD-A, and even that is not always 24 bit.



I'm going to respectfully disagree with you on those points.  I have compared the 24bit FLAC concert recordings with the 16bit FLAC and the 24bit sounds a lot clearer and defined than the 16.  I'm happy to upload some examples to megaupload for your perusal.

There are also many DVD-Video discs that contain 24bit LPCM audio (although only a small percentage).  99% of the DVD-Audio discs I have seen contain 24bit 2ch audio, some of which store the 2ch audio on the DVD-Video section.  (dualdisc however is a different story, with all sony releases 16bit only).  And with the recent introduction of MVI discs with compulsory 24bit stereo, we have more reason to consider high res playback.

As for the vinyl rips I haven't ripped one yet, but through my system vinyl sounds better than it's CD counterparts, worth archiving to 24bit imho.

Anyway it seems that getting the iAudio x5 to play 24bit isn't going to work at the sample rates I require.  However I am shortly going to begin hardware design on a non-portable rockbox based audiophile dap that meets my needs.
Title: Re: Enabling 24bit-44.1/48/88.2/96khz playback - iAudio and others?
Post by: saratoga on October 16, 2007, 05:16:03 PM

I'm going to respectfully disagree with you on those points.  I have compared the 24bit FLAC concert recordings with the 16bit FLAC and the 24bit sounds a lot clearer and defined than the 16.  I'm happy to upload some examples to megaupload for your perusal.

Well, I'm sorry, but its not possible to exceed 16 bit resolution during concert recording.  Just think about what that would require.  You'd need ~100dB above the noise floor.  Ever been to a concert with less then 40dB ambient?  I haven't.  Even at that level, you'd need peaks 20dB above the threshold of pain.  This doesn't happen.  Most of the concert recordings I have would fit in 8-12 bit nicely.

There are also many DVD-Video discs that contain 24bit LPCM audio (although only a small percentage).  99% of the DVD-Audio discs I have seen contain 24bit 2ch audio, some of which store the 2ch audio on the DVD-Video section.  (dualdisc however is a different story, with all sony releases 16bit only).  And with the recent introduction of MVI discs with compulsory 24bit stereo, we have more reason to consider high res playback.

Yeah but thats mostly lossy stuff.  Even MVI is usually AC3 or DTS I think.  Not much point in 24 bit for that.

As for the vinyl rips I haven't ripped one yet, but through my system vinyl sounds better than it's CD counterparts, worth archiving to 24bit imho.

Worth archiving maybe, but certainly not playing back.  They don't even have 16 bit resolution.  You gain nothing from 24 bit playback of a < 16 bit source.  Thats how it works.  You need the whole chain to have 24 bit or equivalent accuracy, and if its coming from AC3, DTS or vinyl you're not getting that.  You can't just take a 16 bit or even lower equivalent source and expect to gain

Title: Re: Enabling 24bit-44.1/48/88.2/96khz playback - iAudio and others?
Post by: pabouk on October 17, 2007, 04:19:15 AM
Well, I'm sorry, but its not possible to exceed 16 bit resolution during concert recording.  Just think about what that would require.  You'd need ~100dB above the noise floor.  Ever been to a concert with less then 40dB ambient?  I haven't.  Even at that level, you'd need peaks 20dB above the threshold of pain.  This doesn't happen.  Most of the concert recordings I have would fit in 8-12 bit nicely.
I think that the quantization noise of the 12 bit recording will be easily noticeable and distinguishable from the ambient noise. Please do not mix quantization and ambient noise. They are very different things. The ambient noise is a part of the recording (EDIT: which is usually desired).

I do not have any equipment to test resolutions above 16 bit and I also think that I do not have good ears but I think that some people can benefit from higher resolutions - at least in recordings with high dynamic range (classical music).

24bit doesn't just provide a better snr than 16 bit, it also provides more resolution (16777216 discrete levels for 24bit as opposed to 65536 levels for 16 bit i.e. much closer to analogue performance), and a higher signal to quantization distortion ratio.  Even though the SNR may not be limited by 16bit, the higher resolution will still be noticeable (in the same way that vinyl provides very good resolution in spite of poor SNR).
The resolution directly implies one part of the SNR. See quantization noise (http://en.wikipedia.org/wiki/Quantization_noise).

Mcmurray, which equipment do you use for listening to 24 bit recordings? Did you do blind ABX test (http://en.wikipedia.org/wiki/ABX_test)? I am afraid that you are deceived by a placebo effect or the 24 bit recording is different in comparison to the 16 bit recording - for example uncompressed dynamic range or other differences in mastering. Please try to convert the 24 bit recording to 16 bits and then do the ABX test between the original 24 bit recording and the one downsampled to 16 bits. For both things you can use foobar 2000.
Title: Re: Enabling 24bit-44.1/48/88.2/96khz playback - iAudio and others?
Post by: lazpete on October 17, 2007, 07:28:06 AM


Im using and listening to ripped albums at 24 bit 96 khz in flac on my sansa e200. Large but fantastic...

You're listening to our somewhat poor resampler.  You'd get much higher fidelity out of CD audio I'm afraid.  It seems to me you really need to sit down and ABX some of your tracks at 24 bit and at 16 bit.  I think you'll be surprised what the difference really is if you think our resampler sounds "fantastic" :)
[/quote]

Did a resampling of the Joni Mitchell album Blue, to 16 bit 44.1 khz, in foobar and I agree . It is accualy better on the sansa now.
Title: Re: Enabling 24bit-44.1/48/88.2/96khz playback - iAudio and others?
Post by: preglow on October 17, 2007, 08:32:05 AM
Did a resampling of the Joni Mitchell album Blue, to 16 bit 44.1 khz, in foobar and I agree . It is accualy better on the sansa now.
No surprises involved. If you have music files you know you're only going to be listening to on a current Rockbox, you should resample them to 44.1 kHz on a computer. Even if we do get a good resampler some day, the kind of resampling you can do offline on a computer will always be better, since we need to do our resampling realtime. I believe some of our targets do support 96 kHz playback in hardware though, so when we enable support for that, you might be interested in keeping them at the original sample rate. I kind of cringe every time I have to call our current deal a resampler at all. It's just a linear interpolator and is basically the the second worst resampler there is.
Title: Re: Enabling 24bit-44.1/48/88.2/96khz playback - iAudio and others?
Post by: saratoga on October 17, 2007, 12:40:56 PM
I think that the quantization noise of the 12 bit recording will be easily noticeable and distinguishable from the ambient noise.

I don't if the ambient is much louder then 30dB, which it will in virtually all cases.

Please do not mix quantization and ambient noise. They are very different things. The ambient noise is a part of the recording (EDIT: which is usually desired).

Of course, however, the ambient noise masks the quantization noise.  In general, to hear quantization noise, it cannot be masked since properly dithered quant noise is not easy to pick out of other sounds (by design).  This is the principle that mp3/ogg/etc are based on.  Thats how you can listen to an mp3/ogg/DTS/AC3/AAC/whatever file with an SNR of just 30 or 40dB and not notice the (quite loud) quantization noise thats constantly blasting at you.
Title: Re: Enabling 24bit-44.1/48/88.2/96khz playback - iAudio and others?
Post by: jaylee on September 28, 2010, 06:37:22 AM
Many targets of RB are well designed, enable higher sample rate and bit depth may get better sound quality?
Title: Re: Enabling 24bit-44.1/48/88.2/96khz playback - iAudio and others?
Post by: soap on September 28, 2010, 06:48:07 AM
Many targets of RB are well designed, enable higher sample rate and bit depth may get better sound quality?

As answered above:

Unlikely.  Can you hear frequencies above 22 KHz?  Can you hear noise 96 dB down in a mix?

The only reason you might hear a difference with native 48 playback is where Rockbox's 48->44 resampler is poorly performing.  This could be addressed for the benefit of all.
Title: Re: Enabling 24bit-44.1/48/88.2/96khz playback - iAudio and others?
Post by: jaylee on September 28, 2010, 07:11:58 AM

Unlikely.  Can you hear frequencies above 22 KHz?  Can you hear noise 96 dB down in a mix?

The only reason you might hear a difference with native 48 playback is where Rockbox's 48->44 resampler is poorly performing.  This could be addressed for the benefit of all.

emmmmm, you're justified in this. it seems the only meaningful thing for RB (and a DAP) is enabling 48khz playback.
Title: Re: Enabling 24bit-44.1/48/88.2/96khz playback - iAudio and others?
Post by: soap on September 28, 2010, 08:26:43 AM

Unlikely.  Can you hear frequencies above 22 KHz?  Can you hear noise 96 dB down in a mix?

The only reason you might hear a difference with native 48 playback is where Rockbox's 48->44 resampler is poorly performing.  This could be addressed for the benefit of all.

emmmmm, you're justified in this. it seems the only meaningful thing for RB (and a DAP) is enabling 48khz playback.

It IS enabled.  Not hardware 48 playback, but 48->44.1 resampled playback. Do you have a specific audible issue with it as it stands now or a theoretical distrust of it?
Title: Re: Enabling 24bit-44.1/48/88.2/96khz playback - iAudio and others?
Post by: Benway on September 28, 2010, 08:54:02 AM
[..]
Unlikely.  Can you hear frequencies above 22 KHz?  Can you hear noise 96 dB down in a mix?
[...]

Humm, I think you're confusing sample rate and audible frequency.  ???
Of course a sample rate of 22 kHz is audibly better than 44 Khz. This has nothing to do with being able to hear frequencies above 22 kHz.
Title: Re: Enabling 24bit-44.1/48/88.2/96khz playback - iAudio and others?
Post by: torne on September 28, 2010, 08:57:56 AM
No we aren't. By the Nyquist-Shannon sampling theorem, you only need the sample rate to be double the highest audible frequency. So, unless you can hear above 22KHz, there's no need to use a sample rate higher than 44KHz.
Title: Re: Enabling 24bit-44.1/48/88.2/96khz playback - iAudio and others?
Post by: jaylee on September 29, 2010, 09:58:55 AM


It IS enabled.  Not hardware 48 playback, but 48->44.1 resampled playback. Do you have a specific audible issue with it as it stands now or a theoretical distrust of it?

i don't trust resample like 48<->44.1, that's not integral, deteriorates sound quality.
Title: Re: Enabling 24bit-44.1/48/88.2/96khz playback - iAudio and others?
Post by: Llorean on September 29, 2010, 10:15:07 AM
Whether or not it deteriorates sound quality, the important question is whether it audibly does so. Rockbox has many optimizations that deteriorate sound quality in one way or another in minimalistic ways allowing files to, for example, be decoded faster. But if the amount it deteriorates is something you can't reasonably distinguish, does it matter?
Title: Re: Enabling 24bit-44.1/48/88.2/96khz playback - iAudio and others?
Post by: soap on September 29, 2010, 10:38:58 AM


It IS enabled.  Not hardware 48 playback, but 48->44.1 resampled playback. Do you have a specific audible issue with it as it stands now or a theoretical distrust of it?

i don't trust resample like 48<->44.1, that's not integral, deteriorates sound quality.
I'll repeat my question.
Do you have a specific audible issue with it as it stands now or a theoretical distrust of it?


Title: Re: Enabling 24bit-44.1/48/88.2/96khz playback - iAudio and others?
Post by: saratoga on September 29, 2010, 12:27:20 PM
Regarding other sample sizes:

We already use full 32 bit precision for everything.  If theres ever a target with a 24 bit DAC it will work as is with rockbox.

Regarding other sample rates:

We currently resample everything using linear interpolation which results in a lot of distortion/aliasing at higher frequencies.  We could improve this either by using better interpolation (cubic spline seems like a good choice, but some kind of IIR based approach might work too) or by supporting more sample rates in playback.

If we wanted to support more sample rates in playback a few things would have to change:

  This will probably work at 48kHz fine, since thats only 9% different.  We'd just have to scale the band center frequencies by 9%.  It probably won't work at 32 or 96k though, so it would need to be disabled for really wierd sample rates.

  This needs to be disabled if either of the tracks has a different sample rate

  All the NATIVE_FREQUENCY macros need to become variables and we need to hunt through the code and make sure theres no hidden assumptions about sample duration.

  Transitions between different sample rates probably cannot be gapless, so we don't really have to do anything here.  They'll be a click when you reclock the DAC anyway
[/list]
Title: Re: Enabling 24bit-44.1/48/88.2/96khz playback - iAudio and others?
Post by: amishfury on November 02, 2010, 01:05:44 PM
No we aren't. By the Nyquist-Shannon sampling theorem, you only need the sample rate to be double the highest audible frequency. So, unless you can hear above 22KHz, there's no need to use a sample rate higher than 44KHz.

there is a very good argument for higher samplerates though... the closer you get to the upper end of the frequency range supported by the samplerate the more aliasing... higher quality DACs of course handle that aliasing better than lesser DACs but also higher samplerates eliminate much of the aliasing simply by having the increased resolution

of course these arguments don't generally apply to portable players where the most common preference is to sacrifice some audio fidelity for smaller file size on top of the fact that most portable players are not exactly designed for samplerates higher than 44.1KHz
Title: Re: Enabling 24bit-44.1/48/88.2/96khz playback - iAudio and others?
Post by: torne on November 02, 2010, 01:14:32 PM
there is a very good argument for higher samplerates though... the closer you get to the upper end of the frequency range supported by the samplerate the more aliasing... higher quality DACs of course handle that aliasing better than lesser DACs but also higher samplerates eliminate much of the aliasing simply by having the increased resolution
See the sampling theorem again: there's no aliasing at all as long as the sample rate is at least double the signal frequency. Aliasing doesn't start until you *exceed* that. Human hearing even in the young stops around 20KHz, so 44.1KHz sampling is sufficient for playback purposes.
Title: Re: Enabling 24bit-44.1/48/88.2/96khz playback - iAudio and others?
Post by: soap on November 02, 2010, 03:43:23 PM
I believe amishfury is attempting to refer to problems caused by the low pass filters on non-oversampling DACs having the tail of their roll-off in the (upper part) of the audible range.