HydrogenAudio

Hydrogenaudio Forum => General Audio => Topic started by: Kracken on 2014-12-07 19:29:34

Title: Resampling Hi-Res Audio
Post by: Kracken on 2014-12-07 19:29:34
Hello Forum!

I have read some threads and am trying to understand how to down-sample FLAC files and would welcome any advice.

My music collection is played mostly through my ipod classic 160GB. I also listen through itunes on my PC.

Currently its in .mp4 format and I am in the process of converting the library to to ALAC

I now have some Hi-Res stuff ranging from 24-44 to 24-192

If I understand correctly my ipod classic can play files up to 24-48?

I figure I'd down-sample the Hi-Res stuff to 24-44 or 24-48 depending on the source (96/2=48, 48 divides into 192, 44.1 into 88 etc).

QUESTION:

After converting the FLAC to WAV, and then using Foobar2000 with foo dsp resampler,

For a 192Hz file should I first bring it down to 96Hz then do it once again to 48?

QUESTION:

I only need the one plugin?

QUESTION?

Its as simple as I've described? No extra steps needed to avoid audible errors?



Thank-you for reading!









Title: Re: Resampling Hi-Res Audio
Post by: saratoga on 2014-12-07 20:07:10
Quote
I figure I'd down-sample the Hi-Res stuff to 24-44 or 24-48 depending on the source (96/2=48, 48 divides into 192, 44.1 into 88 etc).


Pick one and use it for everything.  I'd lean towards 44.1k because it tends to be more commonly used for music.

Quote
After converting the FLAC to WAV, and then using Foobar2000 with foo dsp resampler,


Don't convert to wav, you'll lose your tags.  Just load the files in foobar, and transcode to the new format with the resampler set to whatever sampling rate you decide on.

Quote
For a 192Hz file should I first bring it down to 96Hz then do it once again to 48?


No.  Don't try to outsmart foobar.

Title: Re: Resampling Hi-Res Audio
Post by: Kracken on 2014-12-07 21:21:23
Gracias saratoga

Another question I have is that the author of the guide (http://translate.google.com/translate?sl=auto&tl=en&js=n&prev=_t&hl=en&ie=UTF-8&u=http%3A%2F%2Faudiophilesoft.ru%2Fpubl%2Fmy%2F16_44%2F11-1-0-36&act=url) Im using suggests using "channel mixer", "Advanced Limiter" and "Dither".

If Im not changing the bit depth are these things necessary?
Title: Re: Resampling Hi-Res Audio
Post by: DVDdoug on 2014-12-07 21:46:51
Quote
Im using suggests using "channel mixer", "Advanced Limiter" and "Dither".
I'd say less processing is better...  unless you want to change the sound in some way.

I assume the channel mixer is for mixing-down from 5.1 or 7.1 to 2-channel stereo.

You don't need a limiter unless you are boosting the volume to the point of clipping and you want to "round over" the peaks instead of ending-up with hard-clipped peaks.

Dither is supposed to help when you downsample the bit depth.  At 16-bits (or better) the dither is somewhere around -90dB down and you can't hear the dither (or the effects of dither).  If you downsample to 8-bits, dither will probably make an improvement (But I don't use 8-bit files and I've never tried it). "Everybody does it" and it doesn't hurt, but IMO if you can't hear the difference it doesn't matter.
Title: Re: Resampling Hi-Res Audio
Post by: Porcus on 2014-12-08 13:43:52
Hi-rez is just as often peak-normalized as everything else is?  It isn't so that the signal peaks at negative xx decibels?
Title: Re: Resampling Hi-Res Audio
Post by: Merovingian on 2014-12-08 13:56:04
If Im not changing the bit depth are these things necessary?

Resampling usually needs to be followed by peak limiting, as it may introduce overs.
Brickwalling your peaks at -1 db doesn't hurt. Just make sure apply all processing before any dithering.
Title: Re: Resampling Hi-Res Audio
Post by: Wombat on 2014-12-08 14:08:48
If Im not changing the bit depth are these things necessary?

Resampling usually needs to be followed by peak limiting, as it may introduce overs.
Brickwalling your peaks at -1 db doesn't hurt. Just make sure apply all processing before any dithering.

Peak limiting itself may cause more problems as it solves. Normaly you won't hear slightly clipped samples from resampling. If you want to prevent it just lower the overall level, like with normalizing.
Title: Re: Resampling Hi-Res Audio
Post by: Kracken on 2014-12-08 16:10:33
I have found that .mp3 and .mp4 are louder than ALAC on my ipod classic.

I don't wish to lower the overall level because of this.

I can really crank up my itunes on my PC though with good quality headphones, though it would suck if I could hear clicks or distortions etc. (i.e. clipping?).

I was intending on deleting the bloated Hi-Res files once resampled and then converted to ALAC so I hope I get it right the first time. I could return to the store worst case...

Is it time consuming to analyze a resampled album for clipping and overs?
Title: Re: Resampling Hi-Res Audio
Post by: Merovingian on 2014-12-08 17:30:16
Quote
Normaly you won't hear slightly clipped samples from resampling


True. It is however an option if you are being pedantic, which of course leads to being even more pedantic with respect to limiter choice/settings.
Title: Re: Resampling Hi-Res Audio
Post by: bennetng on 2014-12-08 17:42:52
Is it time consuming to analyze a resampled album for clipping and overs?


In foobar2000, select the files you want to analyze > right click > replaygain > scan per-file track gain

Files with Track peak 1.000000 are possibly clipped, but doesn't automatically mean they have audible distortion. You still need to listen to the files to check them, doing so can be very time consuming.

At last, click Cancel to close the result window.
Title: Re: Resampling Hi-Res Audio
Post by: DVDdoug on 2014-12-08 18:18:15
Quote
Is it time consuming to analyze a resampled album for clipping and overs?
You can't analyze after conversion.  You'd have to re-sample to floating-point, then analyze before converting back to 24-bits.  Integer files are limited to 0dBFS so there are no "overs" in the digital data and there's no way of knowing if a 0dB sample should have gone over 0dB.  (Several 0dB samples in a row usually indicates clipping, but several 0dB samples in a row are probably not from inter-sample overs.)

And, many commercial recordings already have some clipping so it's hard to know if clipping was caused by the resampling. 

Quote
I can really crank up my itunes on my PC though with good quality headphones, though it would suck if I could hear clicks or distortions etc. (i.e. clipping?).
I'd be amazed if you can hear the slight (and short duration) clipping due to inter-sample overs. 

In theory limiting should be less audible, but with limiting you are still altering (distorting) the waveform and if you can't hear the clipping you can't get audibly better than that!

If you are paranoid you could re-sample to floating point, normalize, and then convert to integer.  That would, of course, reduce the volume of any files with overs.  (I'm not that paranoid and I don't worry about inter-sample overs.)
Title: Re: Resampling Hi-Res Audio
Post by: bennetng on 2014-12-08 18:28:45
Right. Convert into float is the most reliable (and more time consuming) method and replaygain scans can show Track peaks larger than 1. Lossy formats like mp3/aac can be decoded into float therefore their scanning results are often larger than 1.
Title: Re: Resampling Hi-Res Audio
Post by: phofman on 2014-12-08 19:19:47
In the end any format is always converted to integer as that is the format of DA conversion. How does a MP3 conversion code producing integer PCM samples for playback differ from the code producing integer PCM samples for FLAC compression? IMO the very same clipping will occur in both cases.
Title: Re: Resampling Hi-Res Audio
Post by: DVDdoug on 2014-12-08 19:35:56
Quote
In the end any format is always converted to integer as that is the format of DA conversion.
True!

Quote
How does a MP3 conversion code producing integer PCM samples for playback differ from the code producing integer PCM samples for FLAC compression? IMO the very same clipping will occur in both cases.
Sometimes there is a digital volume control, so the full-scale integer data isn't always sent to the DAC.    If the MP3 decoder generates floating-point and the DSP volume control works in floating-point, you can avoid clipping.

But, I've NEVER heard of this slight-clipping causing audible artifacts....  I've never heard of a case where MP3 encoding was non-transparent, but then became transparent when the volume was reduced (before encoding) to keep the peaks below 0dB.

You can also boost the volume in an audio editor above 0dB (most audio editors use floating-point) and as long as you're not listening at full-volume you may not clip your DAC.  So, sometimes people don't know there's a problem 'till they render to (integer) WAV.
Title: Re: Resampling Hi-Res Audio
Post by: 2Bdecided on 2014-12-08 20:18:47
Resampling usually needs to be followed by peak limiting, as it may introduce overs.
Brickwalling your peaks at -1 db doesn't hurt.

That's a bad idea.

I wouldn't worry about any of this. Just resample it to 44/16 or 44/24 and leave it alone.

However, any "high res" purchase that hits 0dB FS or generates inter-sample overs should be returned for a refund and shamed on these forums.

Cheers,
David.
Title: Re: Resampling Hi-Res Audio
Post by: Wombat on 2014-12-08 20:29:36
However, any "high res" purchase that hits 0dB FS or generates inter-sample overs should be returned for a refund and shamed on these forums.

Unfortunately the market has already noticed that we so called Audacity Cowboys look fo clipping. Recent HiBit releases often have maximum peaks exactly constant on all tracks like as last step simply a lowering of volume is done. The DR loudnes database is full with that info.
Title: Re: Resampling Hi-Res Audio
Post by: Merovingian on 2014-12-08 20:33:53
Quote
However, any "high res" purchase that hits 0dB FS or generates inter-sample overs should be returned for a refund and shamed on these forums.


I agree, but the source doesn't generate overs. If inter-sample overs occur during playback (of the original "high res" source), it is mostly due to the re-sampling algorithm present in the device.
But yes, overs don't occur all the time (during re-sampled playback). It's a combo of prone source material and crappy conversion algorithms.
Title: Re: Resampling Hi-Res Audio
Post by: 2Bdecided on 2014-12-08 21:25:50
Quote
However, any "high res" purchase that hits 0dB FS or generates inter-sample overs should be returned for a refund and shamed on these forums.


I agree, but the source doesn't generate overs. If inter-sample overs occur during playback (of the original "high res" source), it is mostly due to the re-sampling algorithm present in the device.
Well, if ideal Nyquist sinc resampling yields inter-sample overs, then the source implicitly contains inter-sample overs IMO.

"high res" sources shouldn't be getting anywhere near this. I know some do, but it's a bad joke if they do. It implies a level of quality control and an attitude to recording that can't even get the best out of a 128kbps mp3, never mind a CD or something that claims to be "better".

Cheers,
David.
Title: Re: Resampling Hi-Res Audio
Post by: Kees de Visser on 2014-12-08 21:40:39
However, any "high res" purchase that hits 0dB FS or generates inter-sample overs should be returned for a refund and shamed on these forums.
Why not insist on having the original 32 bit fp data that is the master format in most digital audio workstations? It allows almost lossless level reduction if your DAC can't handle the peaks.
Title: Re: Resampling Hi-Res Audio
Post by: Case on 2014-12-08 21:44:49
I have tried to find music where intersample clipping produces audible issues but haven't found any. From synthetic tests on numerous sound cards I know integrated and normal consumer cards all have problems handling intersample overs but in music the distortion seems to get hidden. A synthetic test file that has peak 4 dB above full scale requires 3-4 dB volume reduction on the sound cards and DACs I tested to not glitch. Highest intersample peak I found in my music files peaks 4.7 dB above digital full scale, yet it sounds fine to my ears. I didn't try careful ABXing though.

In case anyone cares to find problematic intersamples in their files, here's a foobar2000 component I made for the purpose. It uses resampling routines from the player and I recommend installing lvqcl's excellent SoX resampler for highest quality results and improved scanning speed.[attachment=8084:foo_true...truepeak.fb2k-component]
Title: Re: Resampling Hi-Res Audio
Post by: phofman on 2014-12-09 09:04:40
If the MP3 decoder generates floating-point and the DSP volume control works in floating-point, you can avoid clipping.


Yes, in this specific case. In other cases the OS volume control is applied to integer. If using volume control facility provided by the soundcard, it is always integer-based. Too late for any clipping protection.

IMO it is a nonissue.
Title: Re: Resampling Hi-Res Audio
Post by: darkflame23 on 2015-05-23 10:38:12
In case anyone cares to find problematic intersamples in their files, here's a foobar2000 component I made for the purpose. It uses resampling routines from the player and I recommend installing lvqcl's excellent SoX resampler for highest quality results and improved scanning speed.[attachment=8084:foo_true...truepeak.fb2k-component]


I've just installed this component, but how do I now scan the files?
Title: Re: Resampling Hi-Res Audio
Post by: Kohlrabi on 2015-05-23 12:31:00
However, any "high res" purchase that hits 0dB FS or generates inter-sample overs should be returned for a refund and shamed on these forums.
The same should apply to Redbook Audio CD releases, but that would probably exceed the storage capacity of the webspace this forum is hosted on.
Title: Re: Resampling Hi-Res Audio
Post by: Brazil2 on 2015-05-23 12:56:45
I've just installed this component, but how do I now scan the files?

Select the files then right click them and use one of the Scan true-peaks options from the ReplayGain menu.
Title: Re: Resampling Hi-Res Audio
Post by: Arnold B. Krueger on 2015-05-23 14:24:45
I have tried to find music where intersample clipping produces audible issues but haven't found any. From synthetic tests on numerous sound cards I know integrated and normal consumer cards all have problems handling intersample overs but in music the distortion seems to get hidden. A synthetic test file that has peak 4 dB above full scale requires 3-4 dB volume reduction on the sound cards and DACs I tested to not glitch. Highest intersample peak I found in my music files peaks 4.7 dB above digital full scale, yet it sounds fine to my ears. I didn't try careful ABXing though.

In case anyone cares to find problematic intersamples in their files, here's a foobar2000 component I made for the purpose. It uses resampling routines from the player and I recommend installing lvqcl's excellent SoX resampler for highest quality results and improved scanning speed.[attachment=8084:foo_true...truepeak.fb2k-component]



You are describing a 2-part problem:

(1) Music that creates inter-sample overages.

(2) Inter-sample overages that are audible.

Creating files with inter-sample overages is IME something that "just happens"  during normal audio production of new recordings if you are trying to keep peak levels near FS.

When I was producing stereo tracks from multitrack recordings they just seemed to happen from time to time.  When I noticed them I sample edited the file to smooth them out of existence.  They were rare enough for that to be feasible, but they showed up in every so many minutes of recording. This was 5 or more years ago so I can't remember many details.

I've never studied whether inter-sample overages are audible.  The concern is of course that they are a kind of clipping, and clipping can be audible, that they might be audible.

There is an existing ABX test that studies the audibility of relatively infrequent clipping here:  Link to highly diagnostic file for clipping with very rare clipping added (http://www.hydrogenaud.io/forums/index.php?showtopic=107570&view=findpost&p=895047)

I think that the above test shows that under certain ideal conditions, very sparse clipping can be highly audible.  However, while it is based on a natural sound recorded acoustically, the spectral contents of my test files  are miles away from being like typical music.

(1) I conclude that creating inter-sample overages is a natural consequence of many common audio production operations if the file(s) involved have peak values that are within a few dB of FS.

(2) It seems to me but I have not proven to my own satisfaction that under certain ideal conditions, inter-sample overages may be highly audible.


Title: Re: Resampling Hi-Res Audio
Post by: xnor on 2015-05-23 14:55:41
That component (truepeak) seems to have a bug. I generated a test file with 4 inter-sample overs. Only the last one is detected (count=1, first position=last one).
If I attenuate that last peak a bit, then it detects the second to last peak (count still 1).
Title: Re: Resampling Hi-Res Audio
Post by: Case on 2015-05-23 15:50:18
The count isn't the number of inter-sample overs. I wanted to count how many times the exact same highest peak value is present in the file.
Title: Re: Resampling Hi-Res Audio
Post by: Arnold B. Krueger on 2015-05-23 16:26:47
The count isn't the number of inter-sample overs. I wanted to count how many times the exact same highest peak value is present in the file.


I created some files for ABXing related to intersample clipping.

One file has intersample clipping but no ordinary digital clipping.

The other file has neither kind of clipping.

Their contents are the same (usual) natural sound,  sample-aligned, and level matched.

Yes, I've ABXed them and scored 16/16 but the dog ate my homework I crashed FB2K trying to save my ABX log.

Well sorry guys, the conference refused to upload the zip file despite the size was within limits. Again. :-(

Tough for me, tough for you!
Title: Re: Resampling Hi-Res Audio
Post by: xnor on 2015-05-23 17:22:21
The count isn't the number of inter-sample overs. I wanted to count how many times the exact same highest peak value is present in the file.


Oh, okay. But I think it would make more sense to count all samples with an amplitude above 0 dBFS.
Title: Re: Resampling Hi-Res Audio
Post by: Arnold B. Krueger on 2015-05-23 17:28:45
The count isn't the number of inter-sample overs. I wanted to count how many times the exact same highest peak value is present in the file.


Oh, okay. But I think it would make more sense to count all samples with an amplitude above 0 dBFS.


I found it very interesting to listen to all of the nastiness in those files I made with a few inter-sample overs, but zero (0.0) samples that were really close to FS, et alone at it.

There is now no doubt in my mind that inter-sample clipping is a potentially audible problem. It is just a matter of degree.

I think we get away with it for the same reason we get away with occasional, brief clipping - masking both temporal and spectral.
Title: Re: Resampling Hi-Res Audio
Post by: xnor on 2015-05-23 17:59:52
Well, yeah, "potentially".

A lossy codec may even introduce properly clipped samples (not inter-sample overs) regularly if the source material is compressed enough, but it doesn't appear to be a big problem either.
Different converters will also react differently. Some have additional headroom..

Anyway, I couldn't tell since I'm using ReplayGain which usually attenuates my tracks. I'd still prefer the fb2k RG clipping protection to work on "true" peaks.
Title: Re: Resampling Hi-Res Audio
Post by: Case on 2015-05-23 21:12:12
I think it would make more sense to count all samples with an amplitude above 0 dBFS.

Valid point. I altered the scanner to do exactly that. I also added a decibel display for track peak values and advanced preferences setting to optionally write the peak values into standard ReplayGain fields. [attachment=8329:foo_true...truepeak.fb2k-component]
Title: Re: Resampling Hi-Res Audio
Post by: xnor on 2015-05-23 22:27:02
You're a god.
Title: Re: Resampling Hi-Res Audio
Post by: lvqcl on 2015-05-23 23:03:17
I took a track, upsampled it from 44.1 to 176.4 kHz with fb2k SoX resampler, and measured its peak value with a standard RG plugin:

Original track: peak value = 1.000  (+0 dbFS)
passband = 95% (default): peak = 1.125830  (+1.03 dbFS)
passband = 99%: peak = 1.123885  (+1.01 dbFS)
passband = 95%, min. phase: peak = 1.265038  (+2.04 dbFS)
passband = 99%, min. phase: peak = 1.267221  (+2.06 dbFS)

The exact value of intersample overs depends on the way that we reconstruct a waveform.
Title: Re: Resampling Hi-Res Audio
Post by: Arnold B. Krueger on 2015-05-24 10:48:36
The count isn't the number of inter-sample overs. I wanted to count how many times the exact same highest peak value is present in the file.


Oh, okay. But I think it would make more sense to count all samples with an amplitude above 0 dBFS.


As the files that the forum software won't let me upload, clearly show it is surely possible to have very many instances of clearly audible intersample clipping without any samples at all that are at or above 0 dB FS.

AFAIK zero of the many instances of intersample clipping that I have seen in the real world, none of which involved resampling or lossy coding, involved samples >= 0 dB FS.

IOW, you can fix all of the resamplers and lossy coders so they don't cause this problem, and it will still be happening.
Title: Re: Resampling Hi-Res Audio
Post by: xnor on 2015-05-24 12:03:35
I was talking about all samples >0 dBFS after oversampling/resampling, this includes inter-sample as well as ordinary clipping (as is possible in any floating point format, and is not uncommon in lossy codecs, e.g. mp3).
Title: Re: Resampling Hi-Res Audio
Post by: Arnold B. Krueger on 2015-05-24 12:17:51
I was talking about all samples >0 dBFS after oversampling/resampling, this includes inter-sample as well as ordinary clipping (as is possible in any floating point format, and is not uncommon in lossy codecs, e.g. mp3).


Well, this points out a good use for upsampling. Upsample the apparently unclipped file, look for actual clipped samples, and there  are probably  the locations of your inter-sample clipping.

In general,  inter sample clipping seemingly can be corrected by changing at most two or three samples, and IME the changes don't seem to have to be particularly well thought out to be exceedingly hard to hear.

This can contrast with intersample clipping, which can be very audible and nasty.
Title: Re: Resampling Hi-Res Audio
Post by: xnor on 2015-05-24 12:31:44
That's what the true-peak scanner does. It upsamples and interpolates, and now these extra samples will expose peaks (in the worst case >0 dBFS) that were not directly visible using fewer samples.

This is just temporary though to write this info into the file's tags. RG can then prevent clipping by applying the right gain. There is no need to modify anything manually.
Title: Re: Resampling Hi-Res Audio
Post by: Arnold B. Krueger on 2015-05-24 13:11:38
That's what the true-peak scanner does. It upsamples and interpolates, and now these extra samples will expose peaks (in the worst case >0 dBFS) that were not directly visible using fewer samples.

This is just temporary though to write this info into the file's tags. RG can then prevent clipping by applying the right gain. There is no need to modify anything manually.


Right, the manual mods are for people who are in production, or want to get max loudness without clipping or traditional forms of limiting or dynamics compression.

The potential gains are on the order of 3 dB.
Title: Re: Resampling Hi-Res Audio
Post by: LedHed8 on 2015-05-25 17:59:53
Right, the manual mods are for people who are in production, or want to get max loudness without clipping or traditional forms of limiting or dynamics compression.

The potential gains are on the order of 3 dB.

Please correct my understanding/misunderstanding (as the case may be).  In other words, one can use this process as a highly accurate clipping free (other than inherent and irreversible clipping in the source material) "normalizer"?

For example, I have a primitive DAC/DAP that is not capable of using Replaygain, Advanced Limiting, etc..  As such, I may use foo truepeak along with the SoX resampler to scan my lame V5/V4 mp3 files, write those values to the Replaygain tags (having checked that option in Advanced Settings), and then apply track gain to those files with a pre-selected dB target value of my choosing (92 to 96dB) without adding any additional clipping to the files (given that I have also checked the prevent clipping option in Advanced Settings beforehand).

FWIW- I will be using this device and these files in relatively noisy environments, so "bonking" the dynamic range of certain albums is ok with me under these usage conditions.  My main concern is that additional clipping distortion isn't added to the files.

Thanks for the time.  Best Regards,

LedHed8



Topic locked: New discussion moved to foo_truepeak True Peak Scanner (https://hydrogenaud.io/index.php/topic,125719.0.html)