📖 Scenario: You have recorded a short audio clip that sounds a bit dull. You want to improve the sound by adjusting the volume of different frequency bands. This process is called audio equalization.Imagine you have a simple audio signal represented as a list of numbers (samples). You want to boost or reduce certain parts of the sound to make it clearer or more pleasant.
🎯 Goal: Build a simple audio equalizer that adjusts the volume of low, mid, and high frequency parts of an audio signal using given gain values.You will create the audio data, set gain values for each frequency band, apply the gains to the audio signal, and then output the adjusted audio signal.
📋 What You'll Learn
Create a list called audio_samples with 10 exact sample values.
Create a dictionary called gains with keys 'low', 'mid', and 'high' and their gain values.
Apply the gains to the audio samples by multiplying each sample by the correct gain based on its index.
Print the final list of adjusted audio samples.
💡 Why This Matters
🌍 Real World
Audio equalization is used in music production, broadcasting, and hearing aids to improve sound quality by adjusting volume levels of different frequencies.
💼 Career
Understanding audio equalization is important for audio engineers, sound designers, and anyone working with digital audio processing.
Progress0 / 4 steps
1
Create the audio samples
Create a list called audio_samples with these exact values: 0.2, 0.5, 0.7, 0.6, 0.4, 0.3, 0.1, 0.05, 0.02, 0.01.
Signal Processing
Hint
Use square brackets to create a list and separate the numbers with commas.
2
Set gain values for frequency bands
Create a dictionary called gains with keys 'low', 'mid', and 'high' and values 1.5, 1.0, and 0.5 respectively.
Signal Processing
Hint
Use curly braces to create a dictionary with keys and values separated by colons.
3
Apply gains to the audio samples
Create a new list called adjusted_samples by multiplying each sample in audio_samples by the correct gain from gains. Use the first 3 samples for the 'low' gain, the next 4 samples for the 'mid' gain, and the last 3 samples for the 'high' gain. Use a for loop with index and sample to iterate over enumerate(audio_samples).
Signal Processing
Hint
Use enumerate to get both index and sample. Use if and elif to check the index ranges.
4
Print the adjusted audio samples
Write a print statement to display the list adjusted_samples.
Signal Processing
Hint
Use print(adjusted_samples) to show the final list.
Practice
(1/5)
1. What is the main purpose of audio equalization in signal processing?
easy
A. To convert audio signals into text
B. To increase the volume of the audio signal only
C. To adjust the balance of frequency components in an audio signal
D. To remove all background noise completely
Solution
Step 1: Understand audio equalization
Audio equalization changes the levels of different frequency parts of sound to improve or customize it.
Step 2: Identify the main function
It adjusts bass, mid, and treble frequencies, not just volume or noise removal.
Final Answer:
To adjust the balance of frequency components in an audio signal -> Option C
Quick Check:
Audio equalization = frequency adjustment [OK]
Hint: Think: equalization means balancing frequencies [OK]
Common Mistakes:
Confusing equalization with volume control
Assuming it converts audio to text
Believing it removes all noise
2. Which of the following is the correct way to represent a simple bass boost filter gain in code?
easy
A. gain = 1.5 # Boost bass frequencies by 50%
B. gain = -1.5 # Boost bass frequencies by 50%
C. gain = 0 # No change to bass frequencies
D. gain = 'boost' # String value for gain
Solution
Step 1: Understand gain values in filters
Positive gain values increase (boost) frequency levels; negative values reduce (cut) them.
Step 2: Identify correct gain for bass boost
Gain of 1.5 means 50% increase, which is a boost; negative or zero values do not boost.
Final Answer:
gain = 1.5 # Boost bass frequencies by 50% -> Option A
Quick Check:
Positive gain boosts frequencies [OK]
Hint: Positive gain means boost, negative means cut [OK]
Common Mistakes:
Using negative gain to boost frequencies
Setting gain to zero expecting boost
Using non-numeric gain values
3. Given this Python code snippet for equalizing audio frequencies, what will be the output?
frequencies = {'bass': 100, 'mid': 500, 'treble': 10000}
gain = {'bass': 1.2, 'mid': 1.0, 'treble': 0.8}
equalized = {k: frequencies[k] * gain[k] for k in frequencies}
print(equalized)
medium
A. {'bass': 120.0, 'mid': 500.0, 'treble': 8000.0}
4. Identify the error in this code snippet for applying a treble cut filter:
frequencies = {'bass': 100, 'mid': 500, 'treble': 10000}
gain = {'bass': 1.0, 'mid': 1.0, 'treble': 0.5}
for freq in frequencies:
frequencies[freq] = frequencies[freq] * gain['freq']
print(frequencies)
medium
A. Multiplying frequencies by gain is incorrect
B. The print statement is missing parentheses
C. The for loop should iterate over gain, not frequencies
D. Using 'freq' as a string key instead of variable freq in gain dictionary
Solution
Step 1: Check dictionary key usage in loop
The code uses gain['freq'], which looks for key 'freq' literally, not the variable freq.
Step 2: Correct key access
It should be gain[freq] without quotes to use the variable's value as key.
Final Answer:
Using 'freq' as a string key instead of variable freq in gain dictionary -> Option D
Quick Check:
Variable keys need no quotes [OK]
Hint: Use variable keys without quotes in dictionaries [OK]
Common Mistakes:
Using string keys instead of variables
Thinking multiplication is wrong
Confusing loop iteration variable
5. You have an audio signal with frequency bands: bass=80Hz, mid=1000Hz, treble=12000Hz. You want to reduce bass by 20%, keep mid unchanged, and boost treble by 30%. Which gain dictionary correctly applies this equalization?
hard
A. {'bass': 1.2, 'mid': 1.0, 'treble': 0.7}
B. {'bass': 0.8, 'mid': 1.0, 'treble': 1.3}
C. {'bass': 0.2, 'mid': 1.3, 'treble': 1.0}
D. {'bass': 0.8, 'mid': 0.7, 'treble': 1.3}
Solution
Step 1: Calculate gain values for each band
Reduce bass by 20% means multiply by 0.8; mid unchanged means 1.0; boost treble by 30% means multiply by 1.3.
Step 2: Match gains to options
{'bass': 0.8, 'mid': 1.0, 'treble': 1.3} matches these values exactly; others do not.
Final Answer:
{'bass': 0.8, 'mid': 1.0, 'treble': 1.3} -> Option B
Quick Check:
Gain = 1 ± percentage change [OK]
Hint: Gain = 1 ± percentage change (0.8 means 20% cut) [OK]
Common Mistakes:
Mixing boost and cut values
Applying wrong percentages
Changing mid frequency unintentionally
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.