8_1_4

WHAT: Understand how sound can be represented and manipulated using Binary digits

SMART START:

(Think, pair, share)

How does a human ear drum work?

Extra Mile:

Consider how a computer might interpret sound.

HOW:

Activity 1 - READ

You should know by now that computers store and process data as 0's and 1's. We have learnt how to represent numbers, text and images as 0's and 1's but how can we do this with sound? We first need to look at how sound travels and how the human ear processes sound.

Sound in the real world travels when an object vibrates producing a sound wave. This sound wave makes our ear drum vibrate and our brains interpret the sound.

A microphone mimics an ear drum by having a component that vibrates along with a sound. The vibrations are sent as an electrical signal that is interpreted by the computer as sound.

A sound wave is a continuous wave that picks up every part of the sound. Even sounds that the human ear can't interpret.

Computers use an analogue to digital converter to interpret the wave.

Computers don't interpret the entire wave because this would take up too many resources. Instead, the computer SAMPLES the wave at regular INTERVALS.

For CD quality sound you would need to take 44,100 samples per second. We call this a FREQUENCY and it is measure in HERTZ.

Each sound recording needs a BIT RATE. The bit rate determines the combinations of 1's and 0's that can be used to record each sample of the sound.

Just like with images, if we had a 1 bit sound file, we would be able to record 2 unique "slices" of the wave (see right). You can probably guess that this wouldn't produce a good quality recording. The higher the bit rate, the more "slices" we can take out of the wave.

The graphic below shows 16 slices being taken across the wave. This would be a 4-bit sound file because 4 bits has 16 possible combinations of 1's and 0's.

(image adapted from wikipedia commons)

The key things to remember here are:

  • Bit rate - the number of slices taken across the wave
  • Frequency - the number of samples taken per second

When the bit rate increases, more slices can be taken from the wave.

When the frequency increase, more samples can be taken per second.

CHECK:

EMBED:

For this activity you will need some sound editing software, headphones and a microphone. Audacity is a free download from this website: http://www.audacityteam.org/download/ and can be used to edit and manipulate sound.

Investigation

  1. Find some royalty free MP3s from the internet and save them into a folder.
  2. Open Audacity
  3. Import the sound file (File > Import)
  4. Listen to the sound
  5. Adjust the bit rate and the frequency
  6. Listen to the sound
  7. Export the sound file as an mp3 (File > Export)
  8. Adjust the bit rate and frequency again.
  9. Export the sound file again.
  10. Look at what happens to the file size of the mp3 when the bit rate and frequency is adjusted.

Use trial and error to find out the lowest bit rate and frequencies that can be used to create a "good" quality sound recording.

CLASSROOM IDEAS:

Students can manipulate sound using the activity above or they could use sound in Python.

UsingPython.com has a great piece of code for this to get students started:

#------------------------------------------------
# Binary Representation of Sound
# More programs at UsingPython.com/programs
#------------------------------------------------

#------------------------------------------------
# Challenge 1: Can you program your own song?
# Challenge 2: Can you add more notes (e.g. F#, Bb)
# Challenge 3: Can you add more octaves?
#------------------------------------------------

import winsound

print("Binary Representation of sound")
print("More programs at UsingPython.com")
print("--------------------------------\n")
print("Enter the duration of each note (in ms)?")
print("e.g. 200")
rate = int(input(">"))

print("Enter a 4-bit binary note")
print("Or more than one note separated by spaces")

print("Notes:")
print("0000 = no sound")
print("0001 = Low C")
print("0010 = D")
print("0011 = E")
print("0100 = F")
print("0101 = G")
print("0110 = A")
print("0111 = B")
print("1000 = High C")


print("e.g: ")
print("0101 0101 0101 0010 0011 0011 0010 0000 0111 0111 0110 0110 0101")
soundBinary = input(">")

for note in soundBinary.split():

    if note == "0000":          #rest
        freq = 37
    elif note == "0001":        #low c
        freq = 262
    elif note == "0010":        #d
        freq = 294
    elif note == "0011":        #e
        freq = 330
    elif note == "0100":        #f
        freq = 349
    elif note == "0101":        #g
        freq = 392
    elif note == "0110":        #a
        freq = 440
    elif note == "0111":        #b
        freq = 494
    elif note == "1000":        #high c
        freq = 523
        
    winsound.Beep(freq, rate)