0
0
RosConceptBeginner · 3 min read

What is Sampling Rate for Audio Signal: Simple Explanation and Example

The sampling rate for an audio signal is the number of samples taken per second to represent the sound digitally. It is measured in Hertz (Hz) and determines the audio quality and frequency range that can be captured.
⚙️

How It Works

Imagine recording a song by taking snapshots of the sound wave at regular intervals. The sampling rate is how often you take these snapshots every second. If you take more snapshots, you capture more detail of the sound wave, making the recording clearer and closer to the original sound.

For example, a sampling rate of 44,100 Hz means you take 44,100 samples every second. This is the standard for CD-quality audio and can capture sounds up to about 22,050 Hz, which covers the range of human hearing. If the sampling rate is too low, the audio will lose detail and may sound distorted or unnatural.

💻

Example

This example shows how to generate a simple audio signal and change its sampling rate using Python. We create a sine wave sound and then resample it to a lower rate to hear the difference.

python
import numpy as np
import matplotlib.pyplot as plt
from scipy.signal import resample

# Original sampling rate and duration
fs_original = 44100  # 44.1 kHz
duration = 1.0       # 1 second

# Time array
t = np.linspace(0, duration, int(fs_original * duration), endpoint=False)

# Generate a 440 Hz sine wave (A4 note)
frequency = 440
signal = np.sin(2 * np.pi * frequency * t)

# Resample to a lower sampling rate
fs_new = 8000  # 8 kHz
num_samples_new = int(fs_new * duration)
signal_resampled = resample(signal, num_samples_new)

# Plot original and resampled signals
plt.figure(figsize=(10, 4))
plt.plot(t[:1000], signal[:1000], label='Original 44.1 kHz')
plt.plot(np.linspace(0, duration, num_samples_new)[:1000], signal_resampled[:1000], label='Resampled 8 kHz', alpha=0.7)
plt.legend()
plt.title('Original vs Resampled Audio Signal (First 1000 samples)')
plt.xlabel('Time [seconds]')
plt.ylabel('Amplitude')
plt.show()
Output
A plot showing two sine waves: the original 44.1 kHz signal with smooth waveform and the resampled 8 kHz signal with fewer samples and less detail.
🎯

When to Use

Sampling rate is important whenever you convert real-world sounds into digital form. Use a higher sampling rate when you want high-quality audio, such as music production, podcasts, or voice recordings. Lower sampling rates can be used for applications where file size matters more than quality, like phone calls or voice assistants.

Choosing the right sampling rate balances sound quality and data size. For example, streaming services often use 44.1 kHz or 48 kHz for good quality, while telephony uses 8 kHz to save bandwidth.

Key Points

  • The sampling rate is how many times per second an audio signal is measured.
  • Higher sampling rates capture more detail and higher frequencies.
  • 44.1 kHz is standard for CD-quality audio.
  • Lower sampling rates reduce file size but can lose sound quality.
  • Choose sampling rate based on your quality needs and storage limits.

Key Takeaways

Sampling rate defines how often audio is sampled per second and affects sound quality.
44.1 kHz sampling rate captures the full range of human hearing for clear audio.
Lower sampling rates save space but reduce audio detail and frequency range.
Use higher sampling rates for music and professional audio, lower for voice-only applications.
Balancing sampling rate and file size is key in digital audio processing.