Playing sound
Categories: data representation sound
When you play a sound file from your computer or other device, through speakers or headphones, it goes through the following stages. These are more or less the opposite the stages in recording a sound:
The player software reads the sound data from file, and sends the data to the hardware, which converts it to an electrical signal, which in turn drives the speaker.
Sound player software
The sound player software reads the sound data from a sound file in a standard format such as WAV or MP3. It uncompresses the data, if necessary, and passes it to the sound hardware.
Sound hardware
The sound hardware consists of a digital to analogue converter (DAC) and an amplifier
Most devices have built in sound hardware, although with a PC you can use a separate sound card to obtain higher quality.
If you use USB headphones, the conversion hardware is built in to the headphones. The sound is is sent over the USB connection in digital form, and converted to an electrical signal by the headphones. Your computer sound hardware will be bypassed in that case.
Digital to Analogue Converter
The sound file stores the waveform as a list of numbers which represent the sound level.
As an example, our sound file might use the number 0 to 7 to represent a signal level of 0.0 to 1.0. The DAC takes the numbers and converts them back into an electrical signal:
Although the electrical signal is continuous (it can take any value within the range), the output of the DAC can only take values which match the quantised levels of the input data. However, the sound system filters the output to produce a smoother curve (in green).
Amplifier
The output of the DAC must be amplified to provide enough power to create a sound. Most devices such as phones or laptops only supply enough power to drive a set of headphones. If you want to use loudspeakers, you will need an additional amplifier. For example, the speakers you might use with a PC often have their own built-in amplifier.
The output signal will not be exactly the same as the input signal because it has been sampled and quantised, both of which distort the signal. But the distortion shown here is deliberately exaggerated to illustrate the effect. The signal is typically sampled tens of thousands of times per second, and quantised to tens of thousands of levels, creating very good quality sound.
See also
- Binary
- Bits and bytes
- Units of storage
- Powers of two
- Representing numbers
- Binary numbers
- Hexadecimal numbers
- Adding binary numbers
- Negative binary numbers
- Bitwise logical operations
- Binary shift
- Character representation
- ASCII
- Extended ASCII
- Unicode
- Digital images
- Bitmap images
- Computer colour
- Colour depth
- Vector images
- Image file formats
- Computer sound
- Recording sound
- Sound file formats
Sign up to the Creative Coding Newletter
Join my newsletter to receive occasional emails when new content is added, using the form below:
Popular tags
555 timer abstract data type abstraction addition algorithm and gate array ascii ascii85 base32 base64 battery binary binary encoding binary search bit block cipher block padding byte canvas colour coming soon computer music condition cryptographic attacks cryptography decomposition decryption deduplication dictionary attack encryption file server flash memory hard drive hashing hexadecimal hmac html image insertion sort ip address key derivation lamp linear search list mac mac address mesh network message authentication code music nand gate network storage none nor gate not gate op-amp or gate pixel private key python quantisation queue raid ram relational operator resources rgb rom search sort sound synthesis ssd star network supercollider svg switch symmetric encryption truth table turtle graphics yenc