Bits of Bytes.co

IGCSE / GCSE Computer Science

  • Home
  • 1 - Theory of Computer Science
  • 2 - Practical Problem Solving and Programming
  • Pre-Release Material
    • 2018 June >
      • 22 >
        • 22 - Cow Task
        • 22 - Task 1
        • 22 - Task 2
        • 22 - Task 3
  • 1 - Computer Systems (2023)
Picture
MENU
  • Home
  • 1 - Theory of Computer Science
  • 2 - Practical Problem Solving and Programming
  • Pre-Release Material
    • 2018 June >
      • 22 >
        • 22 - Cow Task
        • 22 - Task 1
        • 22 - Task 2
        • 22 - Task 3
  • 1 - Computer Systems (2023)
1 - Computer Systems /  Sound Representation

Sound Representation


Sound Files

For digital sound to exist there must be some sort of process involved that can convert the sound that we hear into something that the computer can process. The sounds that we hear and that can travel through the real world come in the form of analogue waves, analogue waves are continuous.  This type of wave is completely different to a digital signal which at any one time has to be in one particular state.

Analogue sound signals are continuous where as digital signals are
discrete:
Picture

Sound Sampling

The process of converting an analogue signal into a digital one is known as sampling. Sampling involves taking a sample of the analogue signal at set intervals:
Picture
In the image above you can see the red line which represents the analogue sound wave.  The black line represents the digital signal and the sampling process.  

Each time the black line meets the analogue wave, a sample is taken.  This sample is essentially a binary representation of a sound note.

The Y Axis represents the bit depth.  In this case there are 16 different possible notes (0 - 16),  to represent 16 different states you need 4 bits. This means that each sample is 4 bits.

The X axis represents the sample frequency, samples are always taken at a consistent, set frequency.

Improving sound file quality

Increasing the Bit Depth

In the above example. the bit depth is only 4 thus allowing for only 16 different sounds to be represented.  In reality, to produce a song or sound worth listening to, many more sounds will be required. 

To achieve this we can increase the bit depth.  Increasing the bit depth will increase the accuracy of which the analogue wave can be sampled.

Increasing the bit depth will increase the sound quality, but it will also increase the file size as each sample will be represented by more bits.
Increasing the Sample Frequency

Another way to improve the quality of the sound file is to increase the sample frequency.  The more frequently that you sample the analogue wave, the less parts of the wave will be left out thus increasing the quality.

Increasing the sample frequency will increase the sound quality, but it will also increase the file size as there will now be more samples, each to be represented by the bits that make the sample.
Key points
​
Digital sound will never have quality as good as analogue sound as there will always be part of the sound wave missing between samples.  Increasing the sample frequency and bit depth will improve the quality, however there will always be small parts of the sound wave missing.

Calculating File Size

Just like with image files, it is possible to calculate the size of a sound file as long as you know the bit depth and the sample frequency.

Worked example:
Picture
Using this image we can count that there have been 32 samples taken

We can also see, using the y axis that there are 16 possible sound states which needs to be represented using 4 bits per sample.

To calculate the size of the sound file you simply need to multiply the bit depth by the number of samples...


32 X 4 = 128 bits
128 / 8 = 16 Bytes 
Exam Tip

When faced with an exam question like this, take extra care in working out the bit depth and number of samples!


Compression of sound files

Compression is the process of reducing the amount of data used to represent a file. This is useful for a number of reasons...  first of all it reduces the amount of space needed to be stored on your hard drive, secondly if somebody has a slower internet connection (Bandwidth), it will reduce the time taken to load or transmit. Sound files have to be compressed all the time as they are very often subject to being downloaded or streamed. 

Sound compression can occur in two ways, these are Lossy compression and lossless compression.

Lossy compression
Lossy compression works the same way that it does with images. it reduces the size of the file by permanently removing data.  With sound the compression algorithm works using the scientific idea that humans can not hear all parts of a sound wave.

Normal human beings can only hear sounds between 8 hz and 22 hz.  As you get older the range of hz that you can hear reduces.  (You can check your hearing range at this website : ​Noise Addicts

Lossy compression works by taking out the samples of a sound wave that were outside of the normal human hearing range.  This in theory should not reduce quality too much, but will decrease the file size.  As it is lossy compression, once these sounds have been removed, they cannot be put back in.

MP3 files are compressed with Lossy compression.  As a result they can be up to 90% smaller than an uncompressed file.


Picture

​Lossless Compression

Lossless compression works with sound similarly to Images.  Using RLE is seeks to spot similar samples and states how many of those samples are together rather than individually plotting each sample.

Midi Files


​MIDI stands for:

Musical
Instrument
Digital
Interface



MIDI files are sound files, however they are very different to traditional sound files in that they do not store any actual sounds.
Picture
Rather than storing data for actual sounds, MIDI files store instructions for how sound should be played.  These sounds can then be played by real MIDI instruments or through a speaker interface.

The instructions in a MIDI file can include the following:
  • The pitch of the note to be played
  • When each note should start and stop playing
  • The duration of a note
  • The volume of a note
  • The tempo of the music
  • The type of instrument that should play each note.

As no actual sound data is stored in a MIDI file, they are very small files.  They are much smaller than MP3 files.

​You can have a go at making / playing MIDI files at ONLINE SEQUENCER


Est. 2015 - Copyright © 2020