r/AskComputerScience • u/joe-h2o • Jul 11 '26
When a computer or digital system decodes a digital audio format and converts it into a different digital format is the output always identical?
I'm not sure how to ask this question, or if the answer is obvious, but it occurred to me when thinking about MiniDisc.
Audio on an MD is stored digitally (ATRAC) and if you play it back the DAC converts it to an analogue signal. The quality of that output depends on the DAC and different ones will give differing quality. No problem with that idea.
My question is about the digital signal from the player. All my MD decks have TOSLINK optical outputs which is (I assume, linear PCM). My question is about whether the output from that connector is going to be identical if I play the same disk in different decks made by different manufacturers?
Is that PCM output signal predetermined by the input regardless of what machine processes it because it is a digital to digital transformation? In other words, is it some fixed mathematical function that always returns the same value?
I know that acoustically I would not be able to tell the difference, but would the device receiving that signal be able to tell the difference if you could capture and compare them?
Is this true/false for other digital to digital conversions too? For example, converting an mp3 file into a PCM stream?
7
u/otac0n Jul 11 '26
There is a property called “lossless” compression.
If you convert between two lossless formats, then the answer is yes. WAV PCM & Ogg are lossless.
MP3 is lossy.
2
u/green_meklar Jul 11 '26
The process is typically deterministic, that is to say, the same software, reading the same file, and writing it to the same format with the same settings, will produce (bit-by-bit) the same output data across multiple runs.
Other than that, you have very few guarantees. A lot of audio formats (notably MP3) use lossy compression, so a perfect uncompressed input waveform will typically not lead to a compressed output file that perfectly matches the original waveform. (As I recall, some musicians have complained that the MP3 compression algorithm makes music sound more sad than originally intended.) And there can be variations in sample rate, sample precision, and compression level, all of which would lead to different output data. In general you should assume that, for instance, converting a WAV to an MP3 and then the MP3 back to a WAV will not give you an identical sound to the original WAV (unless the original WAV was derived from a compressed MP3 already and every step in the process used exactly the same sample rate and compression settings).
It wouldn't be safe to assume so. For instance, some audio devices may have a fixed output sample rate, but an ability to read files of different sample rates, and they just convert to whatever their native output sample rate is- you'd get a digital signal, but maybe at 48000Hz instead of the original 192000Hz or whatever.
1
u/ghjm MSCS, CS Pro (20+) Jul 12 '26
Others have answered for lossy compressed data formats, but even if you're playing an uncompressed source like an audio CD or DVD, the PCM data is literally what's written on the media, so it can't change. But nevertheless, there are many circumstances where two players might emit different data to their outputs:
2
u/earslap Jul 11 '26
Normally your logic is correct: From a digital source to TOSLINK everything is digital, that means no conversion takes place so you will always get the same bits regardless of the device you use. It is like using a USB cable to transfer files - source to target is bit identical.
The only question mark in this specific instance is that ATRAC is a lossy compressed format. So the data that is streamed from the TOSLINK is not the raw ATRAC stream. It is the PCM stream after ATRAC is decompressed using the software inside the device. Devices might be using different / independently programmed decoders that produce different outputs due to different implementations of the spec, shortcuts and bugs. That cannot be guaranteed without knowing what exact software runs in the device and competing devices.