HydrogenAudio

Lossless Audio Compression => Lossless / Other Codecs => Topic started by: 16Bit Audiophile on 2018-05-05 10:39:33

Title: Resampling: SoX vs. ALAC
Post by: 16Bit Audiophile on 2018-05-05 10:39:33
Hi,

I've been downsizing some of my HD 24Bit audio to 16Bit 44,1/ 48 kHz. I was playing around with XiVero MusicScope a bit and then noticed that the spectrum changes whether I first convert to WAV or when I compress to ALAC directly.

(http://www.klauseulenbach.de/wp-content/uploads/2018/05/1-WAV-SoX-VHQ.png)
(http://www.klauseulenbach.de/wp-content/uploads/2018/05/2-ALAC.png)

There are minor differences between SoX MQ and VHQ Linear Phase already, though minor. But generally it looks like SoX has a steep roll-off whereas ALAC is a lot more linear and shows less SPL at 19+ kHz.

I'm on a Mac and I use XLD. Which would you generally prefer? Is there a reason why one would make more sense over the other? There are no options for using FLAC for resampling. How does it compare?
Title: Re: Resampling: SoX vs. ALAC
Post by: magicgoose on 2018-05-07 12:26:44
ALAC is just a compression format, not a resampler.
Title: Re: Resampling: SoX vs. ALAC
Post by: 16Bit Audiophile on 2018-05-07 16:42:35
OK, then what tool does XLD use to resample? Shouldn't it be SoX too? But the outcome is very different.
Title: Re: Resampling: SoX vs. ALAC
Post by: saratoga on 2018-05-07 18:59:17
OK, then what tool does XLD use to resample? Shouldn't it be SoX too?

It is probably not SoX.  Check the documentation?
Title: Re: Resampling: SoX vs. ALAC
Post by: bennetng on 2018-05-07 19:15:10
http://tmkk.undo.jp/xld/dsd.html.en

I don't have a Mac so I am unable to try it, but SoX's resampling algorithm is adjustable.

BTW, your spectrum is in linear mode but human hearing is in log mode so the differences should be small, did you try to ABX them?
Title: Re: Resampling: SoX vs. ALAC
Post by: 16Bit Audiophile on 2018-05-07 20:09:44
It is probably not SoX.  Check the documentation?
I couldn't find it but XLD uses SoX for resampling from DSD so why would it use something else for conversion from higher PCM? The DSD settings do not seem to affect the resampling method of the original post.

your spectrum is in linear mode but human hearing is in log mode so the differences should be small, did you try to ABX them?
I don't hear the difference between -50 dB or -51 dB at 19 kHz.
I know the linear display is not accurate to hearing but it makes the differences easier to see that I mentioned in the original post.
Title: Re: Resampling: SoX vs. ALAC
Post by: Nikaki on 2018-05-08 11:49:41
SoX uses quite a wide array of resampling parameters, including roll-off settings. Results will vary depending on what each program that uses SoX thinks is best.

The SoX "quality setting" that some software out there presents to the user are just common presets. But in reality SoX provides much more than just preset quality settings. That means two different programs that use SoX can produce quite different results.

With that being said, resampling is pretty much an open-ended complexity algorithm. There's no upper limit to accuracy. If you wanted 100% accuracy, you'd have infinite complexity. Usually, the high complexity settings of a resampler just represent a set of parameters that are well past the point of diminishing returns, but they're still not actually fully accurate. So you shouldn't worry about it much. If you chose the highest quality setting in both programs, the results should be indistinguishable from each other, even if they don't look the same when looking at the sample data.
Title: Re: Resampling: SoX vs. ALAC
Post by: 16Bit Audiophile on 2018-05-08 16:36:22
Thank you @Nikaki, I'm probably overthinking it. It's not like my hearing at 18 kHz is better than at -80 dB...
I just noticed that when I'm using SoX for resampling in JRiver MC23 there is no roll-off at all. I'm not sure which method is best. Aesthetically I'd say the early linear roll-off from ALAC looks most natural and leaves the least impression that 16/44,1 would be limiting.
Title: Re: Resampling: SoX vs. ALAC
Post by: Wombat on 2018-05-08 16:56:43
No visible roll-off may simply mean aliasing.
Title: Re: Resampling: SoX vs. ALAC
Post by: bennetng on 2018-05-08 17:32:45
Instead of songs you can use the TestSignals.zip below to test resamplers.
http://src.infinitewave.ca/faq.html

Convert Swept_24.wav (as hi-res files are often 24-bit instead of 32 int/float) with different settings and attach the converted files here and we'll analyze them.
Title: Re: Resampling: SoX vs. ALAC
Post by: kode54 on 2018-05-09 01:24:20
I just checked XLD's source code. If the ALAC output plugin finds that the system configured an ALAC format to a different sample rate than was requested, it uses Core Audio's built-in resampler.

https://sourceforge.net/p/xld/code/HEAD/tree/trunk/XLDAlacOutput/XLDAlacOutputTask.m#l1460
Title: Re: Resampling: SoX vs. ALAC
Post by: 16Bit Audiophile on 2018-05-09 09:28:10
Thanks a bunch for helping me clear this up!

I have also received a reply on the JRiver board:
Quote
It is a steep filter with a very late cutoff - and it might be best if the cutoff was reduced slightly - but it does roll-off rather than aliasing.
https://yabb.jriver.com/interact/index.php/topic,115843.0.html (https://yabb.jriver.com/interact/index.php/topic,115843.0.html)