Time-Domain Waveform Representation
You'll learn how to represent and manipulate raw audio signals as sequences of amplitude values over time using NumPy.
What Is Time-Domain Representation?
When you work with audio in machine learning, the most fundamental representation is the time-domain waveform—simply a sequence of amplitude values sampled at regular intervals. Think of it like a list of numbers where each number tells you how far the speaker membrane was pushed at that instant. If you sampled at 16,000 Hz, you get 16,000 amplitude measurements per second.
This is "raw" audio: no frequencies, no spectrograms yet—just amplitude over time.
Working with Waveforms in NumPy
After loading audio (which we've covered conceptually), you'll have a NumPy array where:
- Each element represents the amplitude at one sample point
- The array index represents time (index 0 = time 0, index 16000 = 1 second at 16kHz)
- Values typically range from -1.0 to +1.0 (normalized) or use integer ranges based on bit depth
Basic operations you can perform:
- Slicing: Extract a segment (e.g.,
waveform[16000:32000]gets the second second) - Amplitude scaling: Multiply by a constant to make louder/quieter
- Concatenation: Join audio clips using
np.concatenate() - Silence detection: Find where
np.abs(waveform) < threshold - Duration calculation:
len(waveform) / sample_rategives you seconds
Think of the waveform array like a movie frame-by-frame—except instead of images, each "frame" is just one amplitude measurement.
Key Takeaway: Time-domain waveform representation stores audio as a 1D NumPy array of amplitude values sampled over time, enabling direct manipulation through array operations like slicing, scaling, and concatenation.