CMM344 Digital Signal Analysis and Processing

Digital Signal Analysis and ProcessingUnit 1014 min read

DSP Applications: Filters, Speech, Audio, Video & Real-Time Systems

Unit 10 of Digital Signal Analysis and Processing explores how DSP techniques are applied in real-world systems, covering audio processing, speech coding, image/video compression, biomedical signal analysis, and real-time embedded systems. This note includes industry examples, design trade-offs, and hands-on case studi

TAKEAWAYS:

  • DSP applications span audio/speech processing (codecs, noise cancellation), video/image compression (JPEG, H.264), and biomedical signals (ECG filtering, EEG analysis).
  • Real-time constraints (latency, sampling rate) dictate hardware choices (FPGAs vs. microcontrollers) and algorithm efficiency (e.g., FFT vs. DCT).
  • Trade-offs exist between computational complexity (e.g., IIR vs. FIR filters) and performance (e.g., bitrate vs. quality in MP3).
  • Embedded systems (e.g., smartphones, IoT sensors) use DSP for tasks like adaptive filtering (noise reduction in calls) or feature extraction (voice assistants).
  • Industry examples: WhatsApp uses Opus codec (DSP-based) for low-latency voice/video; NTC filters power line harmonics with digital filters to stabilize grids.
  • Exam focus: Link theory (e.g., Nyquist, aliasing) to applications (e.g., "Why does WhatsApp sample at 48 kHz?"), and compare algorithms (e.g., "IIR vs. FIR for ECG denoising").

1. Audio and Speech Processing Applications

1.1 Speech Coding and Compression

Definition: Speech coding reduces the bitrate of digital audio while preserving intelligibility. Key techniques include:

  • Waveform coders (PCM, ADPCM): Simple but high bitrate.
  • Vocoders (LPC, CELP): Model speech production (source-filter model) for low bitrate (e.g., 2.4 kbps for VoIP).
  • Hybrid coders (AMR, Opus): Combine waveform and vocoder elements for balance (e.g., WhatsApp’s Opus uses Silk for wideband speech).

How It Works:

  1. Preprocessing: Noise suppression (e.g., spectral subtraction) and echo cancellation.
  2. Analysis: Extract features like Linear Predictive Coding (LPC) coefficients or Mel-frequency cepstral coefficients (MFCCs).
  3. Quantization/Encoding: Compress using DCT (Discrete Cosine Transform) or CELP (Code-Excited Linear Prediction).
  4. Synthesis: Reconstruct speech at the receiver.

Example: WhatsApp Voice Calls

  • Opus codec (IETF standard) uses hybrid mode:
    • Silk: For narrowband (8 kHz) speech (e.g., calls).
    • Celt: For wideband (16 kHz) audio (e.g., music).
  • Sampling rate: 16–48 kHz (adaptive).
  • Bitrate: 6–128 kbps (adjusts dynamically).
  • Why DSP?:
    • Noise cancellation: Uses adaptive filters (LMS algorithm) to remove background noise.
    • Bandwidth efficiency: CELP encodes speech at ~12 kbps (vs. 64 kbps for PCM).
flowchart LR
    A["Microphone Input"] --> B["Pre-emphasis\n(High-pass filter)"]
    B --> C["Frame Blocking\n(20–30 ms)"]
    C --> D["Windowing\n(Hamming)"]
    D --> E["LPC Analysis\n(10th-order)"]
    E --> F["CELP Encoding\n(Codebook search)"]
    F --> G["Bitstream\n(~12 kbps)"]
    G --> H["Transmission\n(Internet/Cellular)"]
    H --> I["Decoding\n(Receiver-side)"]
    I --> J["Synthesis\n(LPC + Excitation)"]
    J --> K["Playback\n(Speaker)"]

Real Picture: Opus codec block diagramWhatsApp’s Opus codec pipeline (Silk + Celt modules). (Image: CELT-codec-block-diagram-simple-en.svg: *CELT-codec-block-di, CC0, via Wikimedia Commons)

1.2 Audio Effects and Enhancement

Applications:

  • Noise reduction: Used in Ncell calls (adaptive filtering) or podcasts (RNR—Real-time Noise Reduction).
  • Equalization: Apps like BandLab use FIR/IIR filters to shape frequency response.
  • Reverb/delay: Simulated via convolution with impulse responses (e.g., guitar pedals).

Example: NTC Power Line Filtering

  • Problem: Harmonics in power signals (from inverters, solar panels) cause equipment failure.
  • Solution: Digital notch filters (IIR) remove specific frequencies (e.g., 50 Hz, 150 Hz).
  • Implementation:
    • Sampling rate: 1 kHz (Nyquist for 500 Hz harmonics).
    • Filter design: Butterworth or Chebyshev (steep roll-off).
    • Hardware: DSP chip (e.g., TI TMS320) or FPGA.
**Circuit**:

Truth Table: (Not applicable; use pole-zero plot for filter response.) Exam Tip:

  • Always relate sampling rate to Nyquist: "Why can’t NTC filter 60 Hz harmonics at 1 kHz sampling?"
  • Compare FIR vs. IIR: "Which would you use for power line filtering? Why?"

2. Image and Video Processing

2.1 Image Compression (JPEG, JPEG 2000)

Key Techniques:

  • DCT (Discrete Cosine Transform): Converts spatial domain to frequency domain (like FFT but for 2D).
  • Quantization: High-frequency coefficients (less perceptible) are discarded.
  • Entropy coding: Huffman/Rice coding for compression.

Example: Daraz Product Images

  • Workflow:
    1. Color space conversion: RGB → YCbCr (luminance/chrominance separation).
    2. DCT on 8×8 blocks: High-frequency components quantized aggressively.
    3. Zig-zag scan + RLE: Efficient encoding of zero coefficients.
  • Result: 10:1 compression with minimal quality loss.
flowchart LR
    A["RGB Image"] --> B["YCbCr\nConversion"]
    B --> C["8x8 Block\nDCT"]
    C --> D["Quantization\n(Lossy)"]
    D --> E["Zig-zag Scan"]
    E --> F["Entropy\nCoding\n(Huffman)"]
    F --> G["JPEG File"]

Real Picture:

2.2 Video Compression (H.264/AVC, H.265/HEVC)

Techniques:

  • Motion estimation: Predict frames using block matching (e.g., 16×16 macroblocks).
  • DCT + Quantization: Like JPEG but with inter-frame compression.
  • Entropy coding: CABAC (Context-Adaptive Binary Arithmetic Coding).

Example: YouTube Video Streaming

  • H.264/AVC:
    • Bitrate: 500 kbps–5 Mbps (adaptive).
    • Frame types: I (intra), P (predicted), B (bidirectional).
    • DSP role: Motion compensation (IDCT + interpolation) and deblocking filters.
  • Why DSP?:
    • Real-time encoding: Uses SIMD instructions (e.g., SSE/AVX) or GPU shaders.
    • Adaptive bitrate: Adjusts GOP structure based on network conditions.

Exam Tip:

  • Compare JPEG vs. H.264: "Why does H.264 use motion estimation while JPEG does not?"
  • Trade-offs: "How does increasing DCT block size affect compression ratio vs. artifacts?"

3. Biomedical Signal Processing

3.1 ECG and EEG Analysis

Applications:

  • ECG filtering: Remove 50/60 Hz power-line interference and baseline wander.
  • EEG seizure detection: Use wavelet transforms or FIR bandpass filters.

Example: Portable ECG Monitor (e.g., Withings ScanWatch)

  • Signal chain:
    1. Amplification: Instrumentation amp (gain = 1000).
    2. Anti-aliasing filter: Butterworth LPF (cutoff = 0.5 × sampling rate).
    3. Digital filtering:
      • Notch filter: 50 Hz (IIR, 2nd order).
      • High-pass: 0.5 Hz (remove baseline drift).
    4. Feature extraction: QRS detection via thresholding + peak finding.

Real Picture:

3.2 Ultrasound Imaging

DSP Techniques:

  • Beamforming: Delay-and-sum algorithm for phased array transducers.
  • Speckle reduction: Adaptive Wiener filtering.
  • Doppler processing: FFT for blood flow velocity.

Example: Ncell’s Health Services (Partnerships with hospitals)

  • Ultrasound probe DSP:
    • Sampling rate: 20 MHz (for 10 MHz center frequency).
    • Filtering: Bandpass (1–10 MHz) to reject clutter.
    • Image reconstruction: Delay-law processing for focus.
flowchart TD
    A["Transducer\n(Sends pulse)"]
    A --> B["Received\nEchoes"]
    B --> C["Amplification\n(TGC)"]
    C --> D["Bandpass\nFiltering"]
    D --> E["Beamforming\n(Delay-and-sum)"]
    E --> F["Envelope\nDetection"]
    F --> G["Scan\nConversion"]
    G --> H["Display\n(Monitor)"]

4. Real-Time DSP Systems

4.1 Embedded DSP Hardware

Platforms:

Hardware Use Case DSP Features
Microcontrollers (STM32) Low-cost sensors (e.g., air quality) Fixed-point arithmetic, CMSIS-DSP library
DSP Processors (TI TMS320) Industrial (e.g., NTC grid monitoring) Harvard architecture, SIMD, low latency
FPGAs (Xilinx Zynq) High-speed (e.g., radar, 5G) Parallel processing, custom filters
GPUs (NVIDIA CUDA) Video transcoding (e.g., YouTube) Massive parallelism (e.g., CUDA cores)

Example: Pathao’s Ride-Hailing GPS Filtering

  • Problem: GPS noise (jitter, multipath) causes inaccurate routes.
  • Solution:
    • Kalman filter: Fuses GPS + accelerometer data.
    • Low-pass filtering: Smooths position estimates (cutoff = 0.5 Hz).
  • Hardware: STM32F4 (ARM Cortex-M4 with FPU).

Exam Tip:

  • Latency vs. accuracy: "Why does Pathao use a 0.5 Hz cutoff for GPS?"
  • Fixed-point vs. floating-point: "When would you choose a DSP processor over an FPGA?"

4.2 Real-Time Operating Systems (RTOS)

Key Features for DSP:

  • Deterministic timing: Priority scheduling for audio/video streams.
  • Memory management: DMA (Direct Memory Access) for high-speed I/O.
  • Libraries: FFTW (fast FFT), libsamplerate (resampling).

Example: NEPSE Stock Market Audio Alerts

  • System:
    • Input: Stock price data stream (100 Hz).
    • DSP tasks:
      1. Trend detection: Moving average filter (window = 5 samples).
      2. Alert generation: Threshold crossing → synthesize speech (TTS).
    • RTOS: FreeRTOS on Raspberry Pi CM4.
  • Why DSP?:
    • Low latency: Alerts must trigger within 10 ms.
    • Efficiency: Fixed-point math reduces power consumption.
flowchart LR
    A["Stock Data\nStream"] --> B["Moving Avg\nFilter (5-tap)"]
    B --> C["Threshold\nCheck"]
    C -->|"Trigger"| D["TTS Engine\n(Flite)"]
    C -->|"No Trigger"| E["Loop"]
    D --> F["Audio\nOutput"]

5. Wireless Communications

5.1 OFDM in 4G/5G (LTE, Wi-Fi)

DSP Techniques:

  • IFFT/OFDM: Converts frequency-domain symbols to time-domain for transmission.
  • Channel estimation: Pilot symbols + least-squares fitting.
  • Equalization: MMSE or ZF filters to combat ISI.

Example: Ncell 4G Network

  • OFDM parameters:
    • Subcarrier spacing: 15 kHz (LTE).
    • FFT size: 1024 points (for 20 MHz bandwidth).
    • Cyclic prefix: 4.7 µs (to avoid ISI).
  • DSP chain:
    1. Serial-to-parallel: Convert bits to QAM symbols.
    2. IFFT: Generate OFDM symbol.
    3. CP addition: Add guard interval.
    4. Pulse shaping: Root-raised cosine filter.

Real Picture:

5.2 MIMO Processing

Techniques:

  • Spatial multiplexing: Multiple antennas for higher data rates.
  • Beamforming: Steer antenna patterns (e.g., Griffiths-Jim algorithm).
  • Interference cancellation: Zero-forcing (ZF) or minimum mean-square error (MMSE).

Example: Google Wi-Fi Mesh

  • MIMO 2×2:
    • Encoding: Spatial streams (e.g., 2x2 MIMO for 2 spatial streams).
    • Decoding: V-BLAST algorithm at receiver.
  • DSP role:
    • Channel matrix estimation: Pilot-based.
    • Equalization: MMSE-SIC (successive interference cancellation).
flowchart LR
    A["Source\nData"] --> B["Spatial\nMapping"]
    B --> C["IFFT\n+ CP"]
    C --> D["MIMO\nTransmit\n(2 Antennas)"]
    D --> E["Wireless\nChannel"]
    E --> F["MIMO\nReceive\n(2 Antennas)"]
    F --> G["FFT\n+ CP Removal"]
    G --> H["Channel\nEstimation"]
    H --> I["MMSE\nEqualization"]
    I --> J["Data\nRecovery"]

## In the Real World

  1. WhatsApp Voice Calls (Opus Codec)

    • Idea: Hybrid speech coding (Silk + Celt) combines waveform and parametric coding.
    • How: Uses CELP for low bitrate (12 kbps) and adaptive filtering for noise cancellation.
    • Impact: Enables clear calls over 3G networks with <300 ms latency.
  2. NTC Smart Grid Monitoring

    • Idea: Digital notch filters (IIR) remove power line harmonics.
    • How: Samples at 1 kHz, applies 2nd-order filters at 50 Hz, 150 Hz, etc.
    • Impact: Reduces equipment failure and stabilizes voltage.
  3. Pathao Ride-Hailing GPS

    • Idea: Kalman filtering fuses noisy GPS with accelerometer data.
    • How: Predicts position using a state-space model (process noise = GPS jitter).
    • Impact: Smoother routes and lower fuel consumption for drivers.
  4. YouTube Video Compression (H.264/AVC)

    • Idea: Inter-frame compression (motion estimation + DCT).
    • How: Encodes only changes between frames (P/B frames) and uses CABAC for entropy coding.
    • Impact: 80% bandwidth savings vs. raw video.
  5. Withings ECG Watch

    • Idea: Adaptive filtering removes 50 Hz noise and baseline wander.
    • How: Combines a notch filter (50 Hz) and high-pass filter (0.5 Hz).
    • Impact: Enables FDA-cleared ECG monitoring on a wristwatch.

## Exam Tip

  1. Link Theory to Applications:

    • Nyquist theorem: "Why does WhatsApp sample at 48 kHz for music but 16 kHz for calls?"
    • Aliasing: "What happens if NTC’s power signal sampler runs at 900 Hz (instead of 1 kHz)?"
  2. Compare Algorithms:

    • FIR vs. IIR: "Which would you use for ECG denoising? Justify with stability and phase response."
    • DCT vs. FFT: "Why does JPEG use DCT instead of FFT for compression?"
  3. Real-World Trade-offs:

    • Bitrate vs. quality: "How does increasing the bitrate in Opus from 12 kbps to 24 kbps affect call clarity?"
    • Latency vs. complexity: "Why does Pathao use a 5-tap moving average instead of a 20-tap filter?"
  4. Hardware Selection:

    • When to use FPGA vs. DSP processor:
      • FPGA: Custom filters (e.g., radar), parallelism.
      • DSP: Fixed-point math, low power (e.g., STM32 for wearables).
  5. Diagram-Based Questions:

    • Draw and explain:
      • Block diagram of a CELP encoder.
      • State diagram of a Kalman filter (prediction/update steps).
      • Timing diagram of OFDM symbol transmission (IFFT + CP).
  6. Common Pitfalls:

    • Forgetting anti-aliasing: Always mention low-pass filtering before sampling (e.g., in ECG or audio).
    • Ignoring real-time constraints: "Why can’t YouTube use a 1024-point FFT if the video must encode in <100 ms?"
    • Mixing continuous/discrete: "Explain why a 50 Hz notch filter in MATLAB must use fs = 1000 Hz for correct design."

Visual Summary:

**Mermaid Classification**:
```mermaid
mindmap
  root((DSP Applications))
    Audio/Speech
      WhatsApp: Opus (Silk + Celt)
      Ncell: Noise cancellation (LMS)
    Video
      YouTube: H.264 (DCT + motion estimation)
      Daraz: JPEG (block DCT)
    Biomedical
      ECG: Notch filter (50 Hz)
      Ultrasound: Beamforming (delay-and-sum)
    Wireless
      Ncell 4G: OFDM (IFFT + CP)
      Google Wi-Fi: MIMO (V-BLAST)
    Embedded
      Pathao: Kalman filter (GPS fusion)
      NTC: IIR notch (power harmonics)

Based on the PU BE Computer (PU) syllabus for Digital Signal Analysis and Processing (CMM344), unit 10.

Discussion

Loading…