11
$\begingroup$

Because I might encode my music in lossy format for other devices or edit them, I prefer to keep a high-res copy of my music. However, I know that it is possible to upsample a file using ffmpeg and it would appear the same as an authentic high-res file with ffprobe. Is there anyway I can tell apart a "fake" high-res file (converted from CD-quality or mp3/aac) apart from a "real" high-res file (exported high-res by the producer)?

$\endgroup$
5
  • $\begingroup$ Did you tried Audiochecker? $\endgroup$
    – user124853
    May 23 at 18:26
  • $\begingroup$ Or AuCDtect? Website tausoft.org seems to be down right now, but the tool can be also found on other sites $\endgroup$
    – Reeno
    May 24 at 8:19
  • $\begingroup$ @user124853 Yes, I've tried that. Unfortunately I'm running macOS so it's really inconvenient to use it. Plus I think it's based on aucdtect. $\endgroup$
    – Joy Jin
    May 25 at 3:03
  • $\begingroup$ @Reeno I've been using aucdtect. Only problem: it does not support high-res files. It is stated clearly on the website that it can only work with CD-quality files and when I use it with high-res files to confirm it crashes. $\endgroup$
    – Joy Jin
    May 25 at 3:04
  • $\begingroup$ @Reeno There is also a bit of controversy around effectiveness of aucdtect on hydrogenaud.io forum where it is released. Some say that after strong dithering or adding lots of noise a low-quality mp3/aac is indistinguishable from lossless sources for aucdtect. $\endgroup$
    – Joy Jin
    May 25 at 3:05
11
$\begingroup$

Let's get some basics out of the way first.

An audio format is basically defined by three different things: sample rate, bit depth and compression type. The compression type can be either lossless (WAV, PCM, FLAC, ALAC) or "lossy" (AAC, MP3, OGG, MQA, etc). Lossy compression works by shaping the quantization noise so it's masked by the remaining content and inaudible. Lossy formats are characterized by their bit-rate: the higher the bit-rate, the less quantization is done.

The typical life cycle is the following: recording, mixing and happens at 96kHz floating point. When that's done, there are typically two masters made: a studio master at 96kHz/24-bit and a CD master at 44.1kHz/16-bit.

The label will send one of these two to the distribution channel, e.g. Spotify. Which one depends on the contract. Spotify will then create the formats that they need for their streaming platform, which almost always includes lossy compression. For example Spotify uses OGG at 320 kb/s. Apple Music uses AAC at 256 kb/s. Which format gets to the customer depends on the contract between the customer and the distribution.

Is there anyway I can tell apart a "fake" high-res file (converted from CD-quality or mp3/aac) apart from a "real" high-res file

Here are a few things to look for in a spectral analysis

  1. Each format has it's own rolloff: CD drops like a rock at 20 kHz and MP3 drops steeply at 16 kHz. If you have a 96 kHz file with these sharp drop offs, it's likely been up-sampled.
  2. Inspect the content above 20 kHz. If there is random "noise like" features in there, it's probably genuine. If it has very little content and/or the content looks like a low-pass filtered mirror image of the content below 20 kHz, it's been up-sampled.
  3. You can look at correlation at high frequencies. For a genuine recording this will mostly be uncorrelated. If there is significant correlation, it's a potential sign of "joint stereo coding" which could hint at lossy compression.
  4. Look at the recording date: If it's been made before 1990 it's almost guaranteed to be up-sampled. There never was a digital studio master and the best they can do is to sample a tape master.

Some formats like MQA, include authentication, i.e. they put a "seal" on the content and can detect whether the "seal" has been tampered with. It's also possible to put a watermark on the content.

Update

You may be able to detect bit padding as well: Any "decent" CD quality file have been properly noise shaped and dithered. It's possible that signs of this will survive the up sampling process can be detected. I've neve tried that, so I don't know how feasible it is, but it sure would be interesting to try.

$\endgroup$
9
  • 2
    $\begingroup$ Nowadays state-of-the-art is so called "audio super resolution", i.e. machine learning based upsampling. It will still show small difference is noise spectrum and stereo correlation, but it is much harder to recognize compared to traditional upsampling. $\endgroup$
    – jpa
    May 22 at 18:37
  • 4
    $\begingroup$ @jpa oh my, people will throw machine learning at everything nowadays, no matter how nonsensical it is, won't they? There's no point in upsampling 44.1 kHz to something higher (at least not for human consumption). There's not really any point in upsampling lo-fi sample rates to 44.1 either – better to just use a good lossy compression algorithm to save bandwidth, instead of low sample rate. $\endgroup$ May 22 at 20:21
  • 1
    $\begingroup$ Not sure I agree with 4. If it was mastered on 30ips half inch, or even 15ips quaterter-inch, then you could always do a new transfer at whatever is today's 'popular' high-end rates. Sure, in the 80s we were mixing to Sony F1, 16-bit 44.1kHz, with zero headroom tolerance like today's structures, but there was also a 30ips safety master run simultaneously; which is actually what the record co went back to when they eventually did the iTunes digital re-masters. $\endgroup$
    – Tetsujin
    May 23 at 16:33
  • $\begingroup$ @leftaroundabout if there is no reason to upsampling them, why would one care about this question anyway? $\endgroup$
    – lucidbrot
    May 23 at 17:31
  • 5
    $\begingroup$ @lucidbrot - people upsample audio all the time, in the mistaken belief they will "gain something". This is rarely done by experts in the field, it is usually done by people who, to put it politely, haven't a clue ;) You can expound for a long time about the 'air' above 20KHz & how it may influence perception, but how many people do you know who can hear 20KHz, or have audio equipment that could play it back? "HiFI" has more pseudo-science than science at consumer level. $\endgroup$
    – Tetsujin
    May 23 at 18:09
8
$\begingroup$

@Hilmar's answer has this pretty much sewn up. The only addition I will make is a visualisation of what an up-sampled spectrum would look like.

Here is a bassoon that was recorded at 96kHz. The recording was reasonably dirty so you can see a fair amount of frequency content above 22kHz (~44.1kHz Nyquist).

Bassoon at 96kHz

Bassoon at 96kHz

The 96 kHz file was then downsampled to a 44.1kHz wav file. Downsampling will involve low pass filtering the original audio data. When the 44.1 kHz version is upsampled back to 96kHz, we can see that frequency content has been thrown away.

Bassoon exported to 44.1 kHz then upsampled back to 96kHz

Bassoon

$\endgroup$
2
  • 1
    $\begingroup$ I don't think your approach to bit-depth detection will work in the presence of upsampling. In particular, if you want to turn 44.1khz/16-bit audio into a 96khz/32-bit, you will need to interpolate all values and if you don't mess up, that interpolation will happen in 32-bits, so you will get all sorts of intermediate values. If you know the interpolation algorithm, you can probably still do it, but I don't think it will be easy. $\endgroup$
    – mlk
    May 24 at 9:15
  • $\begingroup$ Ah, very true. I was shooting from the hip a little on that one. It's a fun problem, but I'm off the mark by quite a way. Will remove it $\endgroup$
    – fdcpp
    May 24 at 15:49
4
$\begingroup$

A file that where the signal path has been kept 96kHz from microphone to loudspeaker has the potential for signal components up to 48kHz. Most physical sound sources, rooms and microphones will roll off towards those frequencies, but slowly and gently.

If the spectrum of a 96kHz file has signs of brick-wall filtering at 22 or 24kHz, this could be a sign that somewhere in the signal chain, 44.1 or 48kHz sampling was used. It could mean that the synth used by the musician had 48kHz D/A converters.

In the end, if you cannot hear the difference, does it matter? Afaik, no-one has reliably been able to hear the degradation of a 44.1/16-bit system in fair conditions (in a way that would let you publish results in a scientific journal. Anecdotal claims about all kinds of stuff flourish among hifi people).

$\endgroup$
1
$\begingroup$

You could try using spectrograms to do some forensics. I don’t think there’s a generalized solution, or any way to say for certain which formats can be detected as having been up sampled. Refer to the following for nifty photos: https://sound.stackexchange.com/questions/37730/which-spectrogram-shows-higher-quality-of-the-song

MP3 works using a lossless compression scheme known as Huffman coding, which can achieve very high compression ratios when redundant data is present. An encoder might do a time-frequency analysis of the input using the MDCT-IV (I think), compare the result to psychoacoustic models, and zero out content in a way that the audible distortion is minimized. This zeroing is what makes the compression lossy. The more zeros, the more redundant data, the better the compression. Note that this is very broad, and the MP3 spec/implementations are more involved. If you look at the MP3 spectrograms in the linked answer, especially the 128kbps example, you can use visual inspection to see all the black, boxy stuff around the orangish/reddish signal. This would suggest a lossy codec was used. It can be a little tricky to tell, because they typically/always have a boxy quality to them, but we’re looking for black/zero data where it doesn’t look natural.

Upsampling the sample rate from a CD might have a similar effect. Let’s say we start with 44.1kHz and go to 192kHz. Our input has a bandwidth 22.1kHz, and the output a bandwidth of 96kHz. The upsampler needs to figure out what to do with all that content. A sensible approach would be to ‘set’ all that content to zero, so a spectrogram would show all black in that upper range. So if we see the upper bandwidth isn’t being used, that might suggest it’s been upsampled from a lower rate. It might also be that the recording just had a lower bandwidth, which basically means that it could have been recorded at a lower sample rate without loss of information. This is just a hypothetical upsampler though, there isn’t international law pertaining to how it’s done, and there are practical limitations to how effective the ‘zeroing’ is, including the cleverness of whomever designed it.

Checking for a change in bit depth is something I’ve not ever tried to do, but I’ll hazard a guess anyway. Audible distortion from bit depth is most apparent at low signal levels, and will either manifest as harmonic distortion or noise. I’d look for a segment where the signal fades to silence and see what’s going on there. Maybe we’d see some harmonics pop up, or some noise that doesn’t seem like it should be there, and perhaps the magnitudes would give us an estimate of the bit depth.

$\endgroup$
4
  • $\begingroup$ I think the description how MP3 works is a little misleading. It doesn't really "zero out things". It reduces bit depth which generates quantization noise. The trick is to shape the quantization noise so it's below the masking threshold of the current content. $\endgroup$
    – Hilmar
    May 22 at 16:49
  • $\begingroup$ @Hilmar Yeah, I can’t find my book on the subject, and reference material online is expectedly sparse. I did find this paper with a section on artifacts, which I’ll want to double back on and update my answer. ee.columbia.edu/~dpwe/papers/Brand99-mp3.pdf. It references that if the desired bit rate cannot be achieved, then high frequency content could be zeroed out, which admittedly is more of an edge case than a general statement. $\endgroup$
    – Dan Szabo
    May 22 at 18:59
  • $\begingroup$ @Hilmar: At least at low bitrates, DCT-based lossy compression normally does also zero some small DCT coefficients, accepting some distortion when it saves enough bitrate to be worth it. But yes, reducing bit-depth of all the DCT coefficients is also critical; just zeroing some isn't the primary mechanism. $\endgroup$ May 22 at 19:28
  • $\begingroup$ (This is definitely a thing in video compression, e.g. see x265's description of psycho-visual options lead to "fewer coefficients are zeroed by RDOQ’s rate distortion analysis". For audio, codecs like MP3 and newer (with a psycho-acoustic model) look for frequencies "masked" by louder nearby frequencies, and can fully zero those coefficients, saving bits so the audible parts don't have to be quantized as aggressively. So I think it applies there, too. But MP2 still did the DCT + quantization without psy stuff.) $\endgroup$ May 22 at 19:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.