← Teacher guide

Sound as numbers

Students sample a sound wave on a board, changing the samples a wave and the levels, to see that audio is stored as a list of measured, rounded amplitudes, and that more samples and levels sound closer but need more numbers (AC9TDI8K03 node 4).

Data representation · Data as numbers · about 40 minutes · Open the student lesson

Classroom resources

Load these into Waypoints Prepare: choose Load URL and paste the copied address, or download the file and import it. In Prepare, the worksheet's Teacher edition shows the answers; the student copy hides them.

Students will be able to

Timing

Predict and Try 6 min · Worked example 10 min · Vary 12 min · Practise and Make 12 min

Before class

Try the boards yourself, with sound on: the play buttons use the browser's audio (headphones help in class).

The one idea: sound is stored as samples, measurements of the wave's height at regular times, each rounded to a level. More samples and more levels are closer to the real sound and need more data.

Simplifications to say out loud: the board shows a few samples a wave of one pure tone; real recordings take 44 100 or 48 000 samples a second with 65 536 levels (16 bits), and playback smooths the steps. The "% off the wave" counts the step shape too, so it never reaches 0 here. Two samples a wave landing on the crossings is a simplified hint at the sampling theorem.

Running the lesson

  1. Predict: students who chose "the wave is stored" hold Sam's misconception; come back to them after the Try.
  2. Try: play the original and the copy at 8 and 16 samples.
  3. Worked example: ask what level a sample at the very top of the wave gets.
  4. Vary: the 2-samples task usually surprises; ask why the copy is silent.
  5. Make: compare answers at 16 levels too (10 samples is then just over 10%).

The hard part (on purpose)

Students think the recording is the wave itself. Keep pointing at the dots: those are the only numbers the computer has; the steps are rebuilt from them.

When students get stuck

What you will seeA question to askThe fix
A student says the computer stores the wave (Sam's mistake).What are the dots on the board?They are the only numbers stored; everything else is rebuilt.
A student thinks more levels means more numbers.How many dots are there when you change the levels?Same dots, finer rounding: levels change each number, not how many.

Answers to the checks

  1. twice as many samples: A recording measures the wave **8** times each wave. You change it to **16** times each wave. The recording now holds…
    Twice as many numbers. Each measurement (sample) is one number, so twice as many samples is twice as many numbers, and the stepped copy gets closer to the real wave.
  2. Try: take more samples: Move Samples a wave from 8 up to 16. How many numbers are stored now?

    16 samples a wave × 2 waves = 32 numbers, twice as many as before. The steps are closer to the wave.
  3. One wave, step by step: A recording takes 8 samples each wave, for 3 waves. How many numbers does it store?
    24
    8 × 3 = 24 numbers.
  4. Find the mistake: Sam explains how sound is recorded. Click the line where the explanation first goes wrong.
    line 2
    Line 2: the computer can't store a smooth curve. It stores measurements taken at regular times, each rounded to a level, so a recording is close to the sound but not exact.
  5. More levels: What does using **more levels** change?
    Each sample can be rounded less, so it is closer to the real height
    More levels means finer rounding, so each number is closer to the real height. Each number then needs more space to store.
  6. Fewer levels: Turn Levels down to 4. What happens to the steps? Play it.

    With only 4 levels, every sample is rounded a long way, so the steps are coarse and it sounds harsher.
  7. Many samples: Put Levels back to 256, then push Samples a wave to 32.

    32 samples a wave with 256 levels hugs the wave closely: this is why good recordings take many samples and many levels.
  8. Few samples: Now drop Samples a wave to 4. How close is the copy?

    Only 4 measurements a wave: the steps are a rough copy, about 25% off the wave. Fewer samples, fewer numbers, worse sound.
  9. Two samples: Drop Samples a wave to 2. What do the numbers say? Play it.

    Both samples land where the wave crosses the middle, so every number is the same: the recording is silent. A wave needs more than two samples a wave to be caught.
  10. Samples or levels?: Which stores more numbers: 32 samples a wave with 16 levels, or 16 samples a wave with 256 levels?
    32 samples with 16 levels
    Each sample is one number, so 32 samples a wave is twice as many numbers. More levels make each number bigger to store, not more numbers.
  11. CD quality: Music is sampled 44 100 times a second. How many samples are in a 10 second clip?
    441000
    44 100 × 10 = 441 000 samples (and twice that for stereo: two channels).
  12. Half the rate: You halve the sample rate of a recording. What happens to the number of numbers stored?
    It halves
    Half the samples, half the numbers: a smaller file, but a rougher copy.
  13. Big files: Why are music files so much bigger than text files?
    Every second needs tens of thousands of numbers
    A page of text is a few thousand codes; one second of music is 44 100 samples (per channel).
  14. Review: pixels: Review: an image is 2 pixels by 2 pixels, three numbers a pixel. How many numbers?
    12
    4 pixels × 3 = 12 numbers.
  15. just good enough: With 256 levels, find the fewest samples a wave that keep the copy less than 10% off the wave.

    10 samples a wave is 9.8% off; 9 is 11%. Fewer samples make a smaller file, so engineers choose the fewest that sound good enough.

Solutions

One possible solution for each task. Other correct programs are fine.

Vary: one setting at a time › Fewer levels

Open task: any program that does what the step asks.

Vary: one setting at a time › Many samples

Open task: any program that does what the step asks.

Vary: one setting at a time › Few samples

Open task: any program that does what the step asks.

Vary: one setting at a time › Two samples

Open task: any program that does what the step asks.

Vary: one setting at a time › Samples or levels?

Open task: any program that does what the step asks.

just good enough

Open task: any program that does what the step asks.

Stretch and support

Stretch: Phone calls use about 8 000 samples a second; music uses 44 100. Why is a phone call still understandable?

Support: Keep the counting rule on the board: numbers = samples a wave × waves (or samples a second × seconds).

Exit ticket

A recording takes 8 000 samples a second for 5 seconds. How many samples? What happens to sound quality if you use 4 000 a second?

40 000 samples. Fewer samples: a rougher copy (and a smaller file).

What each step is for

Where it leads

Next: Bits and binary numbers, then How many patterns? (why one byte holds 0 to 255 and why 16-bit audio has 65 536 levels).

Code links: micro:bit and Arcade play tones from numbers; the micro:bit's microphone gives a sound level 0 to 255.