Sunday, November 2, 2014

Digital audio and sound cards interface (as provided to the OS).

PCM Or pulse code modulation is a method to digitize audio.

Just like a digital camera, the pixels are replaced with 'samples per second' and the bit depth is also in bits, which specifies the detail which each sample holds.

A sample contains the amplitude and frequency of the analog sound at a given point in time. Since analog is analog, it can have an infinite range of amplitude. But a digital sample can have only limited. Thus each sample also has a depth which's the amount of information stored in each sample (specified in bits, commonly 16, 24, 32) which then defines the range of amplitude the same can have. The depth is also called the 'sampling format' cause it defines the encoding of each sample as stored in a digital medium. There are various encoding schemes available like signed 8/16/24/32 bit, unsigned 8/16/24/32 bit, LE 8/16/24/32 bit, BE 8/16/24/32 bit etc...

To record a whole time range of an analog sound (or a complete waveform), samples are taken at regular intervals. This interval is called the sampling rate. This's analogous to the FPS in a video.

It happens that sampling rate limits the maximum frequency PCM can store (for some reason, probably cause low sampling rate has a high probability of missing out peaks). 44.1 KHZ sampling rate can store frequencies from 20 to 20,000 Hz; however higher the sampling rate, the better.

A sound card is a device which either converts analog signals to digital or opposite or both.
The sound cards do I/o with the OS in PCM format. For if you're playing an audio file which's not stored as PCM, the audio player will first have to decode it to PCM and then send it to the sound card. Same thing happens for recording. The audio sent by the sound card to the OS is almost always in PCM.

A sound card will support various sampling formats of I/O at various sampling rates.

When PCM is stored raw on a digital medium, the file usually has an extension '.wav'.
Wav can store audio in stereo. To accomplish this, the samples are placed in pairs in format such as LRLRLR; this's send to the sound card which knows this formatting. It'll send the left sample to the left speaker and right sample to the right speaker.

Now for multichannel audio. The PCM format can be encoded to store multichannel audio in similar way as stereo, where each channel will have it's individual sampling rate and L/R channel; this includes the subwoofer (LFE) channel.

For multichannel PCM to be decoded and changed to analog, the sound card needs to be told by the OS to operate in multichannel mode; in this mode the analog ports which otherwise were used for input may change their purpose for output.

No comments:

Post a Comment