Quiz: Microphone Input & FFT Spectral Analysis¶
Test your understanding of Live microphone capture, amplitude tracking, Fast Fourier Transform (FFT), and frequency bin visualization with these review questions.
1. Which p5.sound class captures live audio input from the user's computer or mobile microphone?¶
- p5.AudioIn
- p5.Microphone
- p5.SoundCapture
- p5.LiveInput
Show Answer
The correct answer is A. p5.AudioIn accesses the user's live audio input device (microphone or line-in). Options B, C, and D are not p5.sound classes.
Concept Tested: p5 AudioIn Class
2. What mathematical algorithm transforms time-domain audio waveform signals into discrete frequency-domain spectrum bins?¶
- Fast Fourier Transform (FFT)
- Euler Integration
- Perlin Gradient Lattice
- Bresenham Line Algorithm
Show Answer
The correct answer is A. The Fast Fourier Transform (FFT) algorithm efficiently decomposes complex time-domain acoustic waveforms into their constituent frequency components (spectrum amplitudes). Options B, C, and D solve completely different mathematical problems.
Concept Tested: Fast Fourier Transform Concept
3. What does fft.analyze() return in p5.js?¶
- A single scalar volume float
- An array of amplitude values (0-255) across frequency spectrum bins from bass to treble
- The duration of the audio track in seconds
- An array of 3D vertex coordinates
Show Answer
The correct answer is B. fft.analyze() returns an array of energy values (0 to 255) representing the amplitude of each frequency bin from lowest bass to highest treble. Option B describes amplitude.getLevel().
Concept Tested: FFT Analyze Spectrum Array
4. Which p5.sound helper method extracts the instantaneous energy level of a predefined frequency range such as 'bass', 'mid', or 'treble'?¶
- fft.getBand('bass')
- fft.getEnergy('bass')
- fft.sample('bass')
- fft.filter('bass')
Show Answer
The correct answer is B. fft.getEnergy(presetOrFrequency) returns the amplitude energy (0 to 255) of a specific frequency range (e.g. 'bass', 'lowMid', 'mid', 'highMid', 'treble'). Options B, C, and D are not p5.sound methods.
Concept Tested: FFT Get Energy Function
5. What is the difference between measuring volume with p5.Amplitude versus frequency with p5.FFT?¶
- Amplitude only works with microphones while FFT only works with sound files
- Amplitude measures total overall signal volume (loudness), while FFT breaks sound down into individual pitch/frequency bands
- FFT only works in 3D WebGL mode
- Amplitude returns frequencies while FFT returns decibels
Show Answer
The correct answer is B. p5.Amplitude tracks single-value overall sound level (loudness from 0.0 to 1.0). p5.FFT provides spectral analysis, isolating low bass kicks from high cymbal sizzles. Options B, C, and D are incorrect.
Concept Tested: Amplitude vs FFT Comparison
6. What does fft.waveform() return, and how is it visually displayed on canvas?¶
- A 3D mesh of sound waves
- A histogram of audio file sizes
- An array of time-domain amplitude values (-1.0 to +1.0) used to draw an oscilloscope waveform line
- An array of RGB color values
Show Answer
The correct answer is C. fft.waveform() returns time-domain instantaneous amplitude values between -1.0 and 1.0, which can be plotted across the x-axis to render a real-time audio oscilloscope. Options B, C, and D are incorrect.
Concept Tested: FFT Waveform Oscilloscope
7. How do you program an audio-reactive visual where a central circle pulses and expands in response to a live drum kick?¶
- Call random(100) inside draw()
- Set circle size to frameCount
- Sample bass energy with fft.getEnergy('bass') and map the value to circle diameter
- Rotate the canvas by millis()
Show Answer
The correct answer is C. Sampling fft.getEnergy('bass') detects low-frequency transients (kick drums). Mapping this energy value (0-255) to circle radius causes the shape to pulse dynamically with the musical rhythm. Options B, C, and D ignore audio input.
Concept Tested: Audio Reactive Beat Pulse
8. What does the smoothing parameter (between 0.0 and 1.0) passed to new p5.FFT(smoothing, bins) control?¶
- The pitch shift transposition amount
- The volume level of audio playback
- The temporal responsiveness and dampening between consecutive analysis frames to reduce jitter
- The canvas frameRate limit
Show Answer
The correct answer is C. Smoothing dampens rapid fluctuations between FFT frames. A value of 0.8 creates smooth, fluid visualizer transitions, while 0.0 provides raw instantaneous response. Options B, C, and D are false.
Concept Tested: FFT Smoothing Parameter
9. Why is threshold beat detection (detecting when instantaneous energy exceeds a rolling average by a multiplier) superior to static threshold checks for live audio?¶
- Rolling averages prevent browser memory leaks
- Dynamic thresholding runs on GPU compute shaders
- Static thresholds only work with synthesized sine waves
- Dynamic thresholding automatically adapts to songs of varying mastering loudness and dynamic range without manual recalibration
Show Answer
The correct answer is D. Music loudness varies widely across genres and recording levels. Comparing current energy against a moving window average ($E > C \cdot \bar{E}$) reliably detects rhythmic peaks regardless of overall master volume. Options B, C, and D are false.
Concept Tested: Dynamic Beat Detection Algorithm
10. To draw a classic frequency bar visualizer across the canvas width, how should spectrum array values be mapped?¶
- Apply spectrum values as canvas rotation angles
- Draw a single rectangle with width = spectrum.length
- Sort the array alphabetically and print to console
- Iterate through spectrum array, calculating x from index / length and bar height from spectrum[i]
Show Answer
The correct answer is D. Looping through the array spectrum = fft.analyze() and mapping each bin index to horizontal coordinate x = i * (width / spectrum.length) with height h = map(spectrum[i], 0, 255, 0, height) draws an audio spectrum bar chart. Options B, C, and D do not produce frequency bar charts.
Concept Tested: Frequency Bar Visualizer Layout