• Welcome to ASR. There are many reviews of audio hardware and expert members to help answer your questions. Click here to have your audio equipment measured for free!

Bits are bits

Last edited:
Is there a "Dummies" reference that can explain how the CD bits or a WAV file bits gets translated into a digital signal?
Do you mean to say digital there? Because .wav files are already digital so no conversion is necessary.
 
Alfe, is there a point you are trying to make outside of what I consider obvious manufacturing variability in a medium that is going way of the dodo?

Are you stipulating that we are or are not going to get the same MD5 hash from CD 1 vs CD 2000 when we rip it to a file?
 
It's what I said above: anyone reading this would think that digital systems are fundamentally riddled with errors and it's lucky that they can be patched over with some clever guesswork - or something like that. This would make it just another branch of analogue, or "There's no such thing as digital audio". This is the "folklore" I was referring to.

I have no doubt that it is possible to get raw bit errors with an optical storage system where the media are actually handled by the consumer(!), and the challenge then is to build in enough redundancy to make it so rare that it doesn't cause a problem. "Technicians" no doubt will be interested in the number of internal errors that crop up. The same for hard drive 'bad blocks' and chip reject rates. All very interesting to the people who manufacture this stuff, but nothing to do with the ideas behind digital audio and computing - which are 'perfect' in practice as well as theory.

Dwelling on the minor differences between CD audio and CD-ROM storage seems a popular subject in these discussions, but CD is a 20th century technology anyway, and should hardly be taken as a benchmark for all things digital. People take great delight in picking fault with the idea of "Perfect Sound Forever", but I think it was a brilliant slogan that described the idea exactly. Thirty-odd years later, the original digital recordings are still available in pristine condition (for streaming, even if you ruined your CD) and, barring catastrophe, always will be.
 
Because .wav files are already digital so no conversion is necessary

I may not be asking the right question. I had seen the format of the ,WAV file, but it makes little sense to me. I "understand" at a basic level bits and bytes and ASCII characters. I have used a disc editor (many years back) to study MBRs (mainly DOS and Win 2000) and assorted files to see their formats.

So when the computer reads the bytes in a .WAV file, does it just reproduce the bits and the DAC does the rest? Could it be that simple? Nah. o_O

Apparently one can tell the computer to sample the WAV file at different rates, not just the rate it was recorded at, etc. I have read things (some time ago) that the digital "sound" is in an envelope, etc and all seemed so complicated.

I have looked for something basic, over the years but couldn't find something I could understand. I am not an EE. Thanks
 
I may not be asking the right question. I had seen the format of the ,WAV file, but it makes little sense to me. I "understand" at a basic level bits and bytes and ASCII characters. I have used a disc editor (many years back) to study MBRs (mainly DOS and Win 2000) and assorted files to see their formats.

So when the computer reads the bytes in a .WAV file, does it just reproduce the bits and the DAC does the rest? Could it be that simple? Nah. o_O
A ".wav" file is what we call a multimedia container. It holds audio data in this case in a structured way so that for example you can jump to a specific time. Think of it as a folder that holds things. It has a header that says what is in it and how to interpret it. That is we can easily look at the properties and see the sample rate, bit depth, etc.

A ripping program reads the PCM audio data from CD and then encapsulates it in the .wav format for compatibility. That way any program that can open/play a .wav file, will know how to do it.

At playback the reverse happens. A media player reads the header of the .wav file to see what it sample rate is. In a computer, it will then tell the operating system to in turn tell the sound device (e.g. a USB DAC) what sample rate it/bit depth it will be asking it to play. It will then proceed to read a chunk at a time from the .wav file, strip away all but the PCM data and send that to the sound device. The sound device will read the data as fast it needs to produce a real-time stream of data.

All in all, nothing in the PCM data gets converted. We are simply taking it out of the CD optical format container, and put it in the .wav container format for editing/playing.

.flac files are another container format but again the PCM data is universal. In the case of .flac, the PCM data is losslessly compressed. So there, there is a conversion. At playback, that lossless compressed stream needs to be expanded back to PCM and sent to the sound card.

Apparently one can tell the computer to sample the WAV file at different rates, not just the rate it was recorded at, etc. I have read things (some time ago) that the digital "sound" is in an envelope, etc and all seemed so complicated.
The first part is a function of software in a player. Once PCM data is read from .wav or .flac file, it can be resampled in software to other sample rate. As long as this conversion is done faster than the music plays at that rate, it will playback OK. Otherwise there will be a glitch. The moment you resample the files, the bits by definition change. So you are no longer dealing with same set of bits as they came from CD. Sample rate converters can change the frequency response in addition to introducing errors. On the other hand, the DAC playing the resampled file may do a better job than dealing with the original bits. Regardless, the differences will be very small -- certainly smaller than what people report in subjective tests.

The second part you mention is indeed talked about but is flat out wrong. The container, e.g. the .wav or .flac will have no impact on the value of the bits stored in them. "bits are bits" in that regard.

In theory, the work that the computer does will be different in reading a .flac or .wav file (since the former requires decompression of PCM bits). People use this knowledge to automatically conclude that the DAC will get polluted with CPU noise and hence, the sound will be different. Reality is that the CPU load for that is extremely small and at any rate, all but the worst designed DACs are not sensitive to such small changes.

Unless clearly demonstrated otherwise, there simply is no truth that the container makes a difference in how audio is played.

Let me know if you other questions on this.
 
I may not be asking the right question. I had seen the format of the ,WAV file, but it makes little sense to me. I "understand" at a basic level bits and bytes and ASCII characters. I have used a disc editor (many years back) to study MBRs (mainly DOS and Win 2000) and assorted files to see their formats.

So when the computer reads the bytes in a .WAV file, does it just reproduce the bits and the DAC does the rest? Could it be that simple? Nah. o_O

Apparently one can tell the computer to sample the WAV file at different rates, not just the rate it was recorded at, etc. I have read things (some time ago) that the digital "sound" is in an envelope, etc and all seemed so complicated.

I have looked for something basic, over the years but couldn't find something I could understand. I am not an EE. Thanks
Just think of the waveform from the mic as a varying voltage. Imagine measuring the value of the voltage on a regular basis using a voltmeter. Write down the numbers, or read them out to someone over the phone. This would be an example of sampling, and of digital streaming. The number of digits on your voltmeter represents the system's resolution, and how often you make the measurements is the sample rate.

Later, or at the other end of the phone line, the original signal can be reconstructed by turning a knob to the recorded voltages at the right times. This would be a DAC.

This is how digital audio works, and everything else is just a way of making it practical. The numbers are stored in binary (they're still just numbers though) and the file formats and so on are just a way of standardising everything e.g. allowing the playback system to know what the recorded resolution and sample rate should be. Stereo needs two streams of numbers.

Maths can show that if you filter the signal before sampling, and again after the DAC (interpolation that is done at least partially using analogue filtering), the result is perfect to an accuracy limited only by the resolution and sample rate - both of which have to be high enough to make the inaccuracies way beyond inaudible. There is no staircase, or gaps between the samples at the output.
 
At the risk of offending some: Much ado about nothing .. Bits are bits ...
 
All in all, nothing in the PCM data gets converted. We are simply taking it out of the CD optical format container, and put it in the .wav container format for editing/playing.

I think this is what I was missing. Let me see if I have it right. The PCM data on the CD (consider just mono to KISS) consists of three sets of numbers, one for time (or at least a sampling rate so the same time (delta) between each paired value is the same) , and the corresponding paired values -- one for amplitude of the signal and one for the volume.

Now the PCM data (numbers) is the same data (numbers) on the CD as in the WAV file, so nothing in the data is changed. So if one were to use a reader to look at the raw data on the CD and the WAV file, both numbers would be the same. (I guess that is logical, wonder why I couldn't see it).

I can now see how one can sample at a rate lower than the recording rate. But, now how does one sample the PCM data at a rate greater than that at which it was recorded. Seems that if the sampling rate is double the recording rate (ie 44.1 versus 88.2) that 50% of the samples would be empty (no value). How does this work, or does it?

Also thanks Cosmik & Ray.
 
Nothing is perfect, no perfect ADC, no perfect DAC why bit perfect should exist?
My terminology is that before that you end up with bits you start with precise voltage values.

No perfect analog circuits either, again not sure I'm in synch with you here. I'm dealing with some other things (like still working at 9 pm after getting in at 6 pm) so feel like I am doing more harm than good, sorry.
 
I caution you against feeding the folklore that bits are not bits: Yes, a system like CD can fall prey to errors if you smear the disc with peanut butter, but they are not inevitable - and quite clearly CDs and DVDs are bit perfect when used for distributing software. Other, more modern, systems that store and distribute data are bit perfect by default; the modern world could not operate if this were otherwise.

OK, I think it's clear that I am simply not in the game on this one if all I am doing is bolstering folklore. I have seen far too many bit errors on CDs as well as the digital links that are my day job. Most bit errors on CDs are corrected (there is pretty good error correction in the encoding) so are "bit perfect" to the DAC but I have plenty of them that exhibit dropouts and other strange sounds. Maybe mine are just old, or bad, or whatever. I'm dealing with a customer issue wherein a link is exhibiting disparity errors so am probably too sensitive to bit errors at the moment.
 
I can now see how one can sample at a rate lower than the recording rate. But, now how does one sample the PCM data at a rate greater than that at which it was recorded. Seems that if the sampling rate is double the recording rate (ie 44.1 versus 88.2) that 50% of the samples would be empty (no value). How does this work, or does it?
No it doesn't. :) You can't just put empty samples there as they would be zero volts. That would create massive distortion as each sample would jump to zero and then back to the next value.

Upsampling actually attempts to predict what the in-between value would have to be and puts that there, not a blank number. If I gave you two numbers, 2 and 4 and asked you to give me the number in the middle the answer would be 3. Same thing happens here. The process gets more complicated though if I give you 2 3 3 5 and say create values in between them. Or worse yet, I give you 1 3 5 and say to give me four numbers now (e.g. when the conversion is from 44.1 to 96 Khz where one is not multiple of the other).

Keep in mind that the goal here is not to invent what would have been here had we had originally sampled at higher rate. That is an impossibility. See this post I wrote on that: https://audiosciencereview.com/forum/index.php?threads/understanding-upsampling-interpolation.1447/

In a short form, the job of upsampling is to create the identical sound/music but at higher sample rate. The best resampler would not change the sound whatsoever. The worst one would actually distort it.
 
I think this is what I was missing. Let me see if I have it right. The PCM data on the CD (consider just mono to KISS) consists of three sets of numbers, one for time (or at least a sampling rate so the same time (delta) between each paired value is the same) , and the corresponding paired values -- one for amplitude of the signal and one for the volume.

Now the PCM data (numbers) is the same data (numbers) on the CD as in the WAV file, so nothing in the data is changed. So if one were to use a reader to look at the raw data on the CD and the WAV file, both numbers would be the same. (I guess that is logical, wonder why I couldn't see it).

I can now see how one can sample at a rate lower than the recording rate. But, now how does one sample the PCM data at a rate greater than that at which it was recorded. Seems that if the sampling rate is double the recording rate (ie 44.1 versus 88.2) that 50% of the samples would be empty (no value). How does this work, or does it?

Also thanks Cosmik & Ray.

You really on need in the mono example one number. The string of sample values. The header already told the clock how quickly to feed out samples. That is it.

Upsampling, playback at higher than the original rate, yep you just insert an empty sample between the native samples. I'll leave out the details of what happens, but you'll have a playback with everything happening as if twice the rate, but a file that was filtered for half the bandwidth.

https://dspguru.com/dsp/faqs/multirate/interpolation/


EDIT: Seeing Amir's post, read the above link for details. It also only works with doubling or trebling the sample rate. More advanced stuff is involved with non-integer upsampling. You are raising the nyquist rate, and images of the original are shifted up an octave with upsampling using zero stuffing.
 
Last edited:
OK, I think it's clear that I am simply not in the game on this one if all I am doing is bolstering folklore. I have seen far too many bit errors on CDs as well as the digital links that are my day job. Most bit errors on CDs are corrected (there is pretty good error correction in the encoding) but I have plenty of them that exhibit dropouts and other strange sounds. Maybe mine are just old, or bad, or whatever. I'm dealing with a customer issue wherein a link is exhibiting disparity errors so am probably too sensitive to bit errors at the moment.
I too have CDs that can't be read reliably even with the best tools/error correction. The media is not 100% stable or reliable.
 
I have a primer on data conversion on another site, may be able to pull the original file and email it. Just not tonight, need to finish up some things, and others are doing a better job.

Hate it when Work prevents Life.
 
I think this is what I was missing. Let me see if I have it right. The PCM data on the CD (consider just mono to KISS) consists of three sets of numbers, one for time (or at least a sampling rate so the same time (delta) between each paired value is the same) , and the corresponding paired values -- one for amplitude of the signal and one for the volume.
Kind of correct. There are no time samples. That is implied by the sample rate. In the case of CD, that is fixed t 44,100 samples/sec so all the samples played must have that cadence.

The DAC will take that stream of data in a CD player and spit them out at 44,100 or whatever its master clock tells it to do.

And amplitude and volume are one in the same.
 
I have a primer on data conversion on another site, may be able to pull the original file and email it. Just not tonight, need to finish up some things, and others are doing a better job.

Hate it when Work prevents Life.
Yes, we need to get those articles here. I can do that for you and put a header that you are the author even though the post will be under me. Do you want me to do that? Alternatively you can create the empty thread and I will populate the rest of it.
 
You really on need in the mono example one number.

Thus the volume is incorporated in the waveform, like on an oscilloscope, when the input signal increases in strength?

So the (mono) PCM data on the CD and in a WAV file, is just a single series of numbers. And if the positive portion of a sign wave in PCM data was 1, 3, 1 and the positive portion of another sign wave was 2, 6, 2, the second one would be "louder" (not necessarily twice as loud due to the logarithmic relation of loudness).

Does it seem like I sort of got the picture? THX
 
Thus the volume is incorporated in the waveform, like on an oscilloscope, when the input signal increases in strength?
Correct. The digital values are determining the level. You can then further change that up or down with the volume control in your amplifier.
 
Yes, we need to get those articles here. I can do that for you and put a header that you are the author even though the post will be under me. Do you want me to do that? Alternatively you can create the empty thread and I will populate the rest of it.


If you can do it easily, sure. That way you'll get the blame for my typos and corny jokes. :)

@Wayne: The DAC converts the numbers into voltage steps that then drive the rest of the system. DAC = Digital to Analog Converter. Amplitude is just how big the number is. CDs do not have a separate time value since the sampling rate is known. Wikipedia has a pretty decent overview: https://en.wikipedia.org/wiki/Compact_Disc_Digital_Audio

HTH - Don
 
Back
Top Bottom