Bird
Raised Fist0
Signal Processingdata~20 mins

Audio signal characteristics in Signal Processing - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Audio Signal Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate
2:00remaining
What 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))
A0.5
B0.25
C1.0
D0.0
Attempts:
2 left
💡 Hint
RMS is the square root of the average of the squares of the signal values.
❓ data_output
intermediate
2:00remaining
How 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))
A4
B3
C2
D1
Attempts:
2 left
💡 Hint
A peak is a point higher than its neighbors.
❓ visualization
advanced
3:00remaining
Which 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()
AA flat plot with no peaks
BA plot with peaks at 0 Hz and 25 Hz
CA plot with multiple peaks evenly spaced from 0 to 50 Hz
DA plot with a single peak at 5 Hz
Attempts:
2 left
💡 Hint
A pure sine wave has one main frequency component.
🧠 Conceptual
advanced
1:30remaining
What 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.
AThe average amplitude of the signal over time
BThe total energy contained in the signal
CThe number of times the signal amplitude crosses zero per unit time, indicating frequency content
DThe maximum amplitude value in the signal
Attempts:
2 left
💡 Hint
Think about how often the signal changes sign.
🔧 Debug
expert
2:00remaining
What 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)
AValueError: nperseg must not be greater than input length
BTypeError: unsupported operand type(s) for /: 'int' and 'str'
CIndexError: index out of range
DNo error, prints (1, 1)
Attempts:
2 left
💡 Hint
Check the length of the signal vs nperseg parameter.

Practice

(1/5)
1. Which characteristic of an audio signal determines how many samples are taken per second?
easy
A. Duration
B. Amplitude
C. Frequency
D. Sampling rate

Solution

  1. Step 1: Understand sampling rate meaning

    Sampling rate is the number of samples recorded per second in an audio signal.
  2. Step 2: Compare with other characteristics

    Amplitude is signal strength, frequency is pitch, duration is length of sound.
  3. Final Answer:

    Sampling rate -> Option D
  4. Quick Check:

    Samples per second = Sampling rate [OK]
Hint: Sampling rate = samples per second in audio [OK]
Common Mistakes:
  • Confusing frequency with sampling rate
  • Thinking amplitude controls sample count
  • Mixing duration with sampling rate
2. Which of the following is the correct way to represent a sine wave signal in Python using numpy for frequency 440 Hz and sampling rate 8000 Hz?
easy
A. t = np.linspace(0, 1, 8000); signal = np.sin(2 * np.pi * 440 * t)
B. t = np.arange(0, 1, 440); signal = np.sin(2 * np.pi * 8000 * t)
C. t = np.linspace(0, 440, 8000); signal = np.sin(2 * np.pi * t)
D. t = np.arange(0, 1, 1/440); signal = np.sin(2 * np.pi * 8000 * t)

Solution

  1. Step 1: Define time vector correctly

    Use np.linspace(0, 1, 8000) to create 1 second with 8000 samples.
  2. Step 2: Calculate sine wave with correct frequency

    Signal = sin(2π * frequency * time), so 2 * np.pi * 440 * t is correct.
  3. Final Answer:

    t = np.linspace(0, 1, 8000); signal = np.sin(2 * np.pi * 440 * t) -> Option A
  4. Quick Check:

    Time vector and frequency match signal formula [OK]
Hint: Time vector length = sampling rate, sine uses 2πf t [OK]
Common Mistakes:
  • Using np.arange with wrong step size
  • Swapping frequency and sampling rate
  • Incorrect time vector range
3. Given this Python code snippet, what is the maximum amplitude value of the generated signal?
import numpy as np
sampling_rate = 1000
frequency = 5
 t = np.linspace(0, 1, sampling_rate)
signal = 0.5 * np.sin(2 * np.pi * frequency * t)
medium
A. 1.0
B. 0.5
C. 5.0
D. 0.05

Solution

  1. Step 1: Understand amplitude scaling

    The sine function outputs values between -1 and 1. Multiplying by 0.5 scales amplitude to ±0.5.
  2. Step 2: Identify maximum amplitude

    Maximum amplitude is the positive peak, which is 0.5 here.
  3. Final Answer:

    0.5 -> Option B
  4. Quick Check:

    Amplitude scale factor = 0.5 [OK]
Hint: Amplitude scales sine peak values directly [OK]
Common Mistakes:
  • Confusing frequency with amplitude
  • Ignoring the 0.5 multiplier
  • Assuming sine max is always 1 without scaling
4. Identify the error in this code that generates a 1-second 440 Hz sine wave sampled at 8000 Hz:
import numpy as np
t = np.linspace(0, 1, 440)
signal = np.sin(2 * np.pi * 440 * t)
medium
A. The sine function should use cosine instead
B. The frequency should be 8000 instead of 440
C. The time vector length should be 8000, not 440
D. The sampling rate should be 440 instead of 8000

Solution

  1. Step 1: Check time vector length for sampling rate

    Sampling rate is 8000 Hz, so time vector must have 8000 points for 1 second.
  2. Step 2: Identify mismatch in code

    Code uses 440 points in time vector, which is incorrect for 8000 Hz sampling.
  3. Final Answer:

    The time vector length should be 8000, not 440 -> Option C
  4. Quick Check:

    Sampling rate = time vector length [OK]
Hint: Time vector length = sampling rate x duration [OK]
Common Mistakes:
  • Confusing frequency with sampling rate
  • Changing sine to cosine unnecessarily
  • Using wrong sampling rate value
5. You have a recorded audio signal sampled at 16000 Hz with a duration of 2 seconds. You want to extract a 440 Hz sine wave component from it. Which steps correctly describe this process?
hard
A. Apply a bandpass filter around 440 Hz, then analyze amplitude and phase
B. Downsample the signal to 440 Hz, then compute FFT
C. Increase amplitude to 16000, then apply lowpass filter at 2 Hz
D. Use a highpass filter at 2 seconds, then normalize frequency

Solution

  1. Step 1: Use bandpass filter around target frequency

    To isolate 440 Hz, apply a bandpass filter centered near 440 Hz to keep that frequency and remove others.
  2. Step 2: Analyze filtered signal

    After filtering, analyze amplitude and phase to understand the sine wave component.
  3. Final Answer:

    Apply a bandpass filter around 440 Hz, then analyze amplitude and phase -> Option A
  4. Quick Check:

    Bandpass filter isolates frequency component [OK]
Hint: Bandpass filter isolates specific frequency [OK]
Common Mistakes:
  • Downsampling to frequency value instead of sampling rate
  • Confusing filter types and cutoff frequencies
  • Misunderstanding duration as filter parameter
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard