📖 Scenario: You have recorded a short audio clip and want to reduce its size for easier sharing. Audio compression helps by simplifying the sound data while keeping it clear enough to understand.
🎯 Goal: Learn how to create a simple audio data list, set a compression threshold, filter out quiet sounds below that threshold, and see the compressed audio data.
📋 What You'll Learn
Create a list of audio sample amplitudes
Set a compression threshold value
Use a list comprehension to keep only samples above the threshold
Print the compressed audio data list
💡 Why This Matters
🌍 Real World
Audio compression is used in music streaming, phone calls, and podcasts to reduce file size and save bandwidth while keeping sound quality good.
💼 Career
Understanding basic audio compression helps in roles like audio engineering, software development for media apps, and data science involving sound data.
Progress0 / 4 steps
1
Create audio sample data
Create a list called audio_samples with these exact amplitude values: 0.1, 0.5, 0.05, 0.7, 0.2, 0.9, 0.03, 0.4.
Signal Processing
Hint
Use square brackets to create a list and separate values with commas.
2
Set compression threshold
Create a variable called threshold and set it to 0.2 to filter out quiet sounds below this value.
Signal Processing
Hint
Use a simple assignment to create the threshold variable.
3
Filter audio samples above threshold
Use a list comprehension to create a new list called compressed_audio that contains only the values from audio_samples that are greater than or equal to threshold.
Signal Processing
Hint
Use [sample for sample in audio_samples if sample >= threshold] to filter the list.
4
Display compressed audio data
Print the compressed_audio list to see the filtered audio samples after compression.
Signal Processing
Hint
Use print(compressed_audio) to show the result.
Practice
(1/5)
1. What is the main goal of audio compression?
easy
A. To reduce the file size while keeping sound quality acceptable
B. To increase the file size for better quality
C. To convert audio files into video files
D. To remove all background noise completely
Solution
Step 1: Understand the purpose of audio compression
Audio compression aims to make audio files smaller so they use less space and bandwidth.
Step 2: Identify the correct goal
The goal is to reduce size but keep the sound quality good enough for listening.
Final Answer:
To reduce the file size while keeping sound quality acceptable -> Option A
Quick Check:
Audio compression = smaller files with good quality [OK]
Hint: Compression means smaller size, not bigger [OK]
Common Mistakes:
Thinking compression increases file size
Confusing audio with video conversion
Assuming all noise is removed
2. Which of the following is a correct statement about lossy audio compression?
easy
A. It keeps all original audio data intact
B. It removes some audio data permanently to reduce size
C. It converts audio to text format
D. It increases the audio file size
Solution
Step 1: Define lossy compression
Lossy compression removes some audio data permanently to save space.
Step 2: Compare options
Only It removes some audio data permanently to reduce size correctly describes lossy compression; others are incorrect or unrelated.
Final Answer:
It removes some audio data permanently to reduce size -> Option B
D. It should multiply, not divide, by compression_rate
Solution
Step 1: Understand compression calculation
Compressed size should be original size multiplied by compression rate (fraction less than 1).
Step 2: Identify the error in code
The code divides file_size_mb by compression_rate, which increases size incorrectly.
Final Answer:
It should multiply, not divide, by compression_rate -> Option D
Quick Check:
Compression size = original size * rate [OK]
Hint: Compression reduces size, so multiply by rate [OK]
Common Mistakes:
Using division instead of multiplication
Assuming variable names cause error
Expecting import needed for math
5. You have a 100 MB audio file and want to compress it to about 25% of its size using lossy compression. Which bitrate should you choose if the original bitrate is 160 kbps?
Options: A) 40 kbps B) 80 kbps C) 120 kbps D) 160 kbps
hard
A. 40 kbps
B. 80 kbps
C. 120 kbps
D. 160 kbps
Solution
Step 1: Calculate target bitrate for 25% size
25% means 0.25 times original bitrate: 160 kbps * 0.25 = 40 kbps.
Step 2: Choose bitrate matching target
40 kbps is 40 kbps, which matches the target bitrate for 25% size.
Final Answer:
40 kbps -> Option A
Quick Check:
160 * 0.25 = 40 kbps [OK]
Hint: Multiply original bitrate by compression fraction [OK]
Common Mistakes:
Choosing bitrate higher than target size
Confusing percentage with absolute value
Ignoring lossy compression effect
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.