# Data Representation Representing Sound jamiedrfrostmaths com www drfrostmaths

• Slides: 17

Data Representation : : Representing Sound [email protected] com www. drfrostmaths. com @Dr. Frost. Maths Last modified: 15 th July 2019

www. drfrostmaths. com Registering on the Dr. Frost. Maths platform allows you to save all the code and progress in the various Computer Science mini-tasks. It also gives you access to the maths platform allowing you to practise GCSE and A Level questions from Edexcel, OCR and AQA. Everything is completely free. Why not register? With Computer Science questions by: Your code on any mini-tasks will be preserved. Note: The Tiffin/DFM Computer Science course uses Java. Script as its core language. Most code examples are therefore in Java. Script. Using these slides: Green question boxes can be clicked while in Presentation mode to reveal. ? Slides are intentionally designed to double up as revision notes for students, while being optimised for classroom usage. The Mini-Tasks on the DFM platform are purposely ordered to correspond to these slides, giving your flexibility over your lesson structure.

What is sound? Sound is caused by the vibration of particles. Sound travels because the vibration of one particles transfers energy to the particles around it, causing them in turn to vibrate. Over time, we can consider how a particle is ‘displaced’ from its original position as it vibrates. The maximum displacement at a particular part of the wave is known as the amplitude. The greater the amplitude, the greater the energy, and hence the louder the sound.

What is sound? Distance above original position Resting position of diaphragm time The diaphragm of a speaker can only move up and down, above or below its original position. This in turn forms a wave as we consider this vertical distance over time!

Pitch in sound (Not strictly in GCSE syllabus) This is one complete wave. The number of waves per second is known as the frequency, measured in hertz. For example, “middle C” on a piano is 261 Hz. Going up an octave precisely doubles the frequency, so we’d fit twice as many waves into a second. Mini Task: Match the description with the wave. Quiet and low pitch. Quiet and high pitch. Loud and low pitch. Loud and high pitch.

Multiple Pitches in sound (Not in GCSE syllabus) Suppose we were to hear the same sound (i. e. with the same frequency) from two different sources… In this case we end up with another sine wave with the same frequency, but with a greater amplitude, i. e. louder! This is as we’d expect: if we add extra speakers but play the same sound (even if one has a slight delay as above), we hear the same thing but just louder.

Multiple Pitches in sound (Not in GCSE syllabus) We end up with a more complex wave… But what if we were to play two different pitches, i. e. two sounds with different frequencies? Amazingly, our brain is able to take the wave below and work out the original simpler sine waves that we added together, hence working out the multiple pitches we heard. Fourier Analysis is the mathematical process of taking a wave and expressing it as a sum of sine waves.

Encoding Sound Digitally (now we’re back to the syllabus!) So sound can be represented as a single continuous wave. But how to we encode this wave digitally? 1 -1 [0. 40, 0. 80, 0. 65, 0. 04, -0. 21, 0. 02, 0. 19, -0. 07]

Audio Quality 1 What factors affect the quality of the audio? ! The sampling interval is the interval of time between each sample. Sampling frequency/sampling rate is the number of samples per second, measured in kilohertz (k. Hz), often set at 44. 1 k. Hz (44, 100 samples per second, so 1 per 0. 00002 seconds). -1

Audio Quality 1 What factors affect the quality of the audio? 111 110 101 100 011 010 001 000 -1

Audio Quality 1 110 101 100 011 010 001 ? ? 000 -1

Audio Quality Binary encoding of sound wave. 101 110 011 010 011 100 010 111 110 101 100 011 010 We have seen that we can control both the sampling rate and the sample size, based on a target overall bit rate. If we increased the sample size we’d have to reduce the sampling rate to maintain the same file size. The greater the bit rate, the better the black bars above match the -1 wave, and the better the audio quality, at the cost of greater file size. 001 000 The advantage of a higher sample size is that we can better pick up quieter sounds. With this bit rate above, we can’t represent amplitudes between these two lines because we only have these 8 different amplitudes to choose from.

Sampling Example We want to sample this wave between 0 seconds and 3 seconds, using a sample rate of 2 Hz. Our sample size is 4 bits (allowing integer values between 0000 0 and ? 1111 15 ? ) Time (s) Step 1: The sample rate is 2 Hz. That’s 2 samples per second, so at 0. 5 second increments. We’re only allowing integer amplitudes here so need to round to the nearest whole. Determine the list of samples. Step 2: Samples as integers: [3, 3, 1, 1, 3, 2, 2] Step 3: Samples in binary: [0011, 0001, 0011, 0010]

amplitude Test Your Understanding time (s) ? ? ?

Exam Question OCR Practice Paper ? ? ?

Review 1 An audio file’s sampling rate is 3. 5 k. Hz. Explain what this means. Each second, we take 3, 500 amplitude readings from the sound ? wave at set intervals. 3 ? 2 Explain why the sampling rate alone doesn’t determine the file size of a 1 minute long audio file. There is also the sampling size, which the number of bits stored for each sample. ?

Coding Mini-Tasks Return to the Dr. Frost. Maths site to complete the various tasks on encoding sound.