Project 8 of 9, for Caitlin
Radio Station Finder
Caitlin wants music on the roof for the last night of term, and the old Studio radio hisses from one end of the dial to the other. Smooth the dial, find the real stations, and turn it up.
Sign up free to open itLog in
Act 9 needs a free account, so your work is saved as you go. Act 1 is open to everyone.
The brief
- CaitlinIt's the last night of term so we need music, and I've brought the old Studio radio up.
- CaitlinThe whole dial's just hiss, though. Auto-tune found one very loud crackle and then nothing.
- NeilThat's a noisy signal, rocket telemetry looks just like that. You smooth it out before you trust it.
- CaitlinSmooth the dial, find the real stations, and we'll have music up here.
The dial gives one signal reading for every 0.1 MHz from 88.0 to 108.0, in dial.txt. Write find_stations(readings, start=88.0, step=0.1, window=5, floor=0.5) in tuner.py:
- smooth the readings with a moving average: each value becomes the mean of itself and up to
window // 2neighbours on each side (fewer at the ends) - a station is a smoothed value, not at either end, that is higher than the one before it, at least as high as the one after it, and at least
floor - return the stations' frequencies, rounded to one decimal place, strongest first
>>> find_stations(readings) [96.4, 101.7]
What's in it
- Smoothing a noisy signal
- The ends of the dial
- Listening to the dial
- Finding the peaks
- A flat top
- Smoothing out the crackle
- The tuner
- Ship it