Challenge - 5 Problems
Audio Signal Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateWhat is the output of this code calculating RMS of an audio signal?
Given a numpy array representing an audio signal, what is the output of the RMS calculation code below?
Signal Processing
import numpy as np signal = np.array([0.5, -0.5, 0.5, -0.5]) rms = np.sqrt(np.mean(signal**2)) print(round(rms, 3))
Attempts:
2 left
💡 Hint
RMS is the square root of the average of the squares of the signal values.
✗ Incorrect
The signal squares to [0.25, 0.25, 0.25, 0.25], average is 0.25, sqrt(0.25) = 0.5.
❓ data_output
intermediateHow many peaks are detected in this audio signal?
Using scipy.signal.find_peaks on the signal array below, how many peaks are detected?
Signal Processing
import numpy as np from scipy.signal import find_peaks signal = np.array([0, 1, 0, 2, 0, 1, 0]) peaks, _ = find_peaks(signal) print(len(peaks))
Attempts:
2 left
💡 Hint
A peak is a point higher than its neighbors.
✗ Incorrect
The peaks are at indices 1 (value 1), 3 (value 2), and 5 (value 1), total 3 peaks.
❓ visualization
advancedWhich plot shows the correct frequency spectrum of a sine wave?
A sine wave of frequency 5 Hz is sampled at 50 Hz. Which plot correctly shows its frequency spectrum using FFT?
Signal Processing
import numpy as np import matplotlib.pyplot as plt fs = 50 f = 5 t = np.arange(0, 1, 1/fs) signal = np.sin(2 * np.pi * f * t) fft_vals = np.fft.fft(signal) freqs = np.fft.fftfreq(len(signal), 1/fs) plt.stem(freqs[:len(freqs)//2], np.abs(fft_vals)[:len(freqs)//2]) plt.xlabel('Frequency (Hz)') plt.ylabel('Magnitude') plt.show()
Attempts:
2 left
💡 Hint
A pure sine wave has one main frequency component.
✗ Incorrect
The FFT of a sine wave shows a peak at its frequency (5 Hz) and its symmetric negative frequency, but only positive frequencies are plotted here.
🧠 Conceptual
advancedWhat does the zero crossing rate (ZCR) indicate in an audio signal?
Choose the best description of what the zero crossing rate measures in an audio signal.
Attempts:
2 left
💡 Hint
Think about how often the signal changes sign.
✗ Incorrect
ZCR counts how many times the signal crosses zero, which relates to how quickly the signal oscillates, reflecting frequency content.
🔧 Debug
expertWhat error does this code raise when computing the spectrogram?
Identify the error raised by the code below when computing a spectrogram with scipy.signal.spectrogram.
Signal Processing
import numpy as np from scipy.signal import spectrogram signal = np.array([1, 2, 3, 4, 5]) fs = 10 f, t, Sxx = spectrogram(signal, fs, nperseg=10) print(Sxx.shape)
Attempts:
2 left
💡 Hint
Check the length of the signal vs nperseg parameter.
✗ Incorrect
The nperseg parameter cannot be larger than the signal length; here nperseg=10 but signal length=5, causing ValueError.
