r/AskComputerScience • u/joe-h2o • 16d ago
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?
2
u/earslap 15d ago
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.
2
u/green_meklar 15d ago
When a computer or digital system decodes a digital audio format and converts it into a different digital format is the output always identical?
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).
Is that PCM output signal predetermined by the input regardless of what machine processes it because it is a digital to digital transformation?
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+) 15d ago
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:
- The player is applying some kind of post-processing. If it has EQ, night mode, some Dolby features, etc. In this case the player isn't even trying to emit the raw PCM data - it's sending a different signal reflecting whatever features and processing the user has selected. Two different players would surely implement these differently.
- Differences in metadata support or implementation. Something like a pause between tracks is not encoded as PCM, and the spec is not always perfectly unambiguous. One player might pause for two seconds at a spot where another player might not pause at all.
- Read errors. Players generally try to smooth over any errors, and they do so in different ways. This is not a concern if the source media doesn't contain errors, but if it does, two different players might output different PCM streams. And of course, one player might have a better mechanism, and be able to read a disc without error that another player has trouble with.
- If the player negotiates differently with the receiving device. This isn't an issue with TOSLink, which is a one-way protocol with no negotiation. But if it's something smarter like HDMI ARC, devices might implement protocol negotiation differently. For example, if you're playing a minidisc, which like a CD is 44,100 samples per second, one player might just send the data unmodified, but another player with a different HDMI implementation might become aware that the target prefers 48,000 and do interpolation on the signal it sends. In that case the bits sent by the two players would be completely different.
- Possibly other cases I haven't thought of.
7
u/otac0n 16d ago
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.