
신기술 & 미래
Digital Signal ProcessingDSP (디지털 신호 처리)
디지털 신호 처리(DSP)는 디지털로 변환된 신호를 수학적으로 분석·변환·합성하는 기술이다. 오디오 이퀄라이저, 노이즈 캔슬링, 음성 인식, 이미지 처리의 기반이 된다.
핵심 개념
샘플링 정리 (Nyquist-Shannon):
- 원래 신호를 정확히 복원하려면 최대 주파수의 2배 이상으로 샘플링
- 가청 주파수 20kHz → CD 품질 44.1kHz 샘플링
푸리에 변환:
- 시간 영역 신호 → 주파수 영역으로 변환
- FFT(Fast Fourier Transform): O(n log n)으로 효율적 계산
필터:
- LPF (Low-Pass Filter): 저주파만 통과
- HPF (High-Pass Filter): 고주파만 통과
- BPF (Band-Pass Filter): 특정 대역만 통과Python으로 FFT 분석
python
import numpy as np
import matplotlib.pyplot as plt
from scipy import signal
from scipy.io import wavfile
# WAV 파일 읽기
sample_rate, audio = wavfile.read('audio.wav')
audio = audio.astype(np.float32) / 32768.0 # 정규화
# FFT로 주파수 분석
n = len(audio)
fft_result = np.fft.rfft(audio)
frequencies = np.fft.rfftfreq(n, d=1/sample_rate)
magnitude = np.abs(fft_result) / n
# 스펙트로그램
f, t, Sxx = signal.spectrogram(audio, sample_rate)
plt.pcolormesh(t, f, 10 * np.log10(Sxx), shading='gouraud')
plt.ylabel('주파수 (Hz)')
plt.xlabel('시간 (초)')
plt.title('스펙트로그램')디지털 필터 설계
python
from scipy import signal
import numpy as np
sample_rate = 44100
# 1kHz 이하 저역통과 필터 (Butterworth)
cutoff = 1000 # Hz
nyquist = sample_rate / 2
normalized_cutoff = cutoff / nyquist
b, a = signal.butter(N=4, Wn=normalized_cutoff, btype='low')
# 오디오에 필터 적용
filtered_audio = signal.filtfilt(b, a, audio)
# 이퀄라이저 (피킹 필터)
def peaking_eq(freq, gain_db, Q, sample_rate):
"""특정 주파수를 boost/cut하는 필터"""
w0 = 2 * np.pi * freq / sample_rate
A = 10 ** (gain_db / 40)
alpha = np.sin(w0) / (2 * Q)
b = [1 + alpha*A, -2*np.cos(w0), 1 - alpha*A]
a = [1 + alpha/A, -2*np.cos(w0), 1 - alpha/A]
return b, a관련 문서
- •/wiki/video-encoding
- •/wiki/signal-processing
- •/wiki/whisper