Data representation · A level · AQA 7517 4.5.6.7, Eduqas A500QS 2.3 · about 30 min
Sample rate, sample resolution, the Nyquist theorem and aliasing, and MIDI events played on the robot's piezo.
[1 mark]How many bytes does a 30 second mono recording take at a sampling rate of 8,000 Hz and a sample resolution of 8 bits?
[1 mark]A recording must keep frequencies up to 5,000 Hz. What is the lowest sampling rate, in Hz, the Nyquist theorem allows?
[1 mark]A 440 Hz tone is sampled at 600 Hz. What happens?
[1 mark]Which of these are MIDI event messages or data carried in them?
Tick every answer that is true.
[1 mark]Which is a disadvantage of MIDI compared with sampled sound?
[1 mark]What does this program print?
for note in [57, 69, 81]:
print(note, round(440 * 2 ** ((note - 69) / 12)))57 220 69 440 81 880
Twelve note numbers make an octave, which halves or doubles the frequency.
events is a list of (note, seconds) pairs: note is a MIDI note number (0 to 127) and seconds is how long to play it.
1. Write frequency(note), which returns 440 × 2^((note - 69) / 12) rounded to the nearest whole number with round, as an int.
2. For each event in order, print note <note> = <frequency> Hz and play it on the piezo with tone(frequency, seconds).
3. After the last note, print minimum sample rate: <n> Hz, where n is twice the highest frequency you played: the Nyquist rate for recording those notes' fundamental frequencies.
Calculate every frequency; do not type them in.
# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()
events = [(60, 0.25), (64, 0.25), (67, 0.25), (72, 0.5)]
def frequency(note):
return 440The hint students can ask for: Every 12 note numbers is an octave, and an octave doubles the frequency, so the frequency is 440 times 2 to the power of how many twelfths the note is above note 69. Play each note for its own duration. The Nyquist rate is twice the highest frequency you need to keep.
# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()
events = [(60, 0.25), (64, 0.25), (67, 0.25), (72, 0.5)]
def frequency(note):
return round(440 * 2 ** ((note - 69) / 12))
highest = 0
for note, seconds in events:
f = frequency(note)
print("note", note, "=", f, "Hz")
tone(f, seconds)
if f > highest:
highest = f
print("minimum sample rate:", 2 * highest, "Hz")
Any program that meets the task's checks is marked correct in the simulator; this is one way, not the only way.