Preface xv
Acknowledgments xix
1 Introduction to Real-Time Digital Signal Processing 1
1.1 Basic Elements of Real-Time DSP Systems 2
1.2 Analog Interface 3
1.2.1 Sampling 3
1.2.2 Quantization and Encoding 7
1.2.3 Smoothing Filters 8
1.2.4 Data Converters 9
1.3 DSP Hardware 10
1.3.1 DSP Hardware Options 11
1.3.2 Digital Signal Processors 13
1.3.3 Fixed- and Floating-Point Processors 14
1.3.4 Real-Time Constraints 15
1.4 DSP System Design 16
1.4.1 Algorithm Development 16
1.4.2 Selection of DSP Hardware 18
1.4.3 Software Development 19
1.4.4 Software Development Tools 20
1.5 Experiments and Program Examples 21
1.5.1 Get Started with CCS and eZdsp 22
1.5.2 C File I/O Functions 26
1.5.3 User Interface for eZdsp 30
1.5.4 Audio Playback Using eZdsp 35
1.5.5 Audio Loopback Using eZdsp 38
Exercises 42
References 43
2 DSP Fundamentals and Implementation Considerations 44
2.1 Digital Signals and Systems 44
2.1.1 Elementary Digital Signals 44
2.1.2 Block Diagram Representation of Digital Systems 47
2.2 System Concepts 48
2.2.1 LTI Systems 48
2.2.2 The z-transform 52
2.2.3 Transfer Functions 54
2.2.4 Poles and Zeros 58
2.2.5 Frequency Responses 61
2.2.6 Discrete Fourier Transform 65
2.3 Introduction to Random Variables 66
2.3.1 Review of Random Variables 67
2.3.2 Operations of Random Variables 68
2.4 Fixed-Point Representations and Quantization Effects 72
2.4.1 Fixed-Point Formats 72
2.4.2 Quantization Errors 75
2.4.3 Signal Quantization 75
2.4.4 Coefficient Quantization 78
2.4.5 Roundoff Noise 78
2.4.6 Fixed-Point Toolbox 79
2.5 Overflow and Solutions 81
2.5.1 Saturation Arithmetic 81
2.5.2 Overflow Handling 82
2.5.3 Scaling of Signals 82
2.5.4 Guard Bits 83
2.6 Experiments and Program Examples 83
2.6.1 Overflow and Saturation Arithmetic 83
2.6.2 Function Approximations 86
2.6.3 Real-Time Signal Generation Using eZdsp 94
Exercises 99
References 101
3 Design and Implementation of FIR Filters 102
3.1 Introduction to FIR Filters 102
3.1.1 Filter Characteristics 102
3.1.2 Filter Types 104
3.1.3 Filter Specifications 106
3.1.4 Linear Phase FIR Filters 108
3.1.5 Realization of FIR Filters 110
3.2 Design of FIR Filters 114
3.2.1 Fourier Series Method 114
3.2.2 Gibbs Phenomenon 116
3.2.3 Window Functions 118
3.2.4 Design of FIR Filters Using MATLAB1 120
3.2.5 Design of FIR Filters Using the FDATool 122
3.3 Implementation Considerations 125
3.3.1 Quantization Effects in FIR Filters 125
3.3.2 MATLAB1 Implementations 127
3.3.3 Floating-Point C Implementations 128
3.3.4 Fixed-Point C Implementations 129
3.4 Applications: Interpolation and Decimation Filters 130
3.4.1 Interpolation 130
3.4.2 Decimation 131
3.4.3 Sampling Rate Conversion 133
3.4.4 MATLAB1 Implementations 134
3.5 Experiments and Program Examples 135
3.5.1 FIR Filtering Using Fixed-Point C 135
3.5.2 FIR Filtering Using C55xx Assembly Program 136
3.5.3 Symmetric FIR Filtering Using C55xx Assembly Program 137
3.5.4 Optimization Using Dual-MAC Architecture 138
3.5.5 Real-Time FIR Filtering 140
3.5.6 Decimation Using C and Assembly Programs 141
3.5.7 Interpolation Using Fixed-Point C 142
3.5.8 Sampling Rate Conversion 142
3.5.9 Real-Time Sampling Rate Conversion 143
Exercises 144
References 147
4 Design and Implementation of IIR Filters 148
4.1 Introduction 148
4.1.1 Analog Systems 148
4.1.2 Mapping Properties 150
4.1.3 Characteristics of Analog Filters 151
4.1.4 Frequency Transforms 153
4.2 Design of IIR Filters 154
4.2.1 Bilinear Transform 155
4.2.2 Filter Design Using the Bilinear Transform 156
4.3 Realization of IIR Filters 158
4.3.1 Direct Forms 158
4.3.2 Cascade Realizations 160
4.3.3 Parallel Realizations 161
4.3.4 Realization of IIR Filters Using MATLAB1 162
4.4 Design of IIR Filters Using MATLAB1 164
4.4.1 Filter Design Using MATLAB1 164
4.4.2 Frequency Transforms Using MATLAB1 166
4.4.3 Filter Design and Realization Using the FDATool 166
4.5 Implementation Considerations 168
4.5.1 Stability 168
4.5.2 Finite-Precision Effects and Solutions 170
4.5.3 MATLAB1 Implementations of IIR Filters 172
4.6 Practical Applications 174
4.6.1 Recursive Resonators 174
4.6.2 Recursive Quadrature Oscillators 177
4.6.3 Parametric Equalizers 179
4.7 Experiments and Program Examples 179
4.7.1 Direct-Form I IIR Filter Using Floating-Point C 179
4.7.2 Direct-Form I IIR Filter Using Fixed-Point C 181
4.7.3 Cascade IIR Filter Using Fixed-Point C 182
4.7.4 Cascade IIR Filter Using Intrinsics 185
4.7.5 Cascade IIR Filter Using Assembly Program 188
4.7.6 Real-Time IIR Filtering 189
4.7.7 Parametric Equalizer Using Fixed-Point C 190
4.7.8 Real-Time Parametric Equalizer 190
Exercises 191
References 194
5 Frequency Analysis and the Discrete Fourier Transform 195
5.1 Fourier Series and Fourier Transform 195
5.1.1 Fourier Series 195
5.1.2 Fourier Transform 197
5.2 Discrete Fourier Transform 198
5.2.1 Discrete-Time Fourier Transform 198
5.2.2 Discrete Fourier Transform 200
5.2.3 Important Properties 202
5.3 Fast Fourier Transforms 205
5.3.1 Decimation-in-Time 206
5.3.2 Decimation-in-Frequency 208
5.3.3 Inverse Fast Fourier Transform 209
5.4 Implementation Considerations 210
5.4.1 Computational Issues 210
5.4.2 Finite-Precision Effects 210
5.4.3 MATLAB1 Implementations 211
5.4.4 Fixed-Point Implementation Using MATLAB1 212
5.5 Practical Applications 214
5.5.1 Spectral Analysis 214
5.5.2 Spectral Leakage and Resolution 215
5.5.3 Power Spectral Density 219
5.5.4 Convolution 222
5.6 Experiments and Program Examples 224
5.6.1 DFT Using Floating-Point C 224
5.6.2 DFT Using the C55xx Assembly Program 226
5.6.3 FFT Using Floating-Point C 227
5.6.4 FFT Using Fixed-Point C with Intrinsics 227
5.6.5 Experiment with the FFT and IFFT 231
5.6.6 FFT Using the C55xx Hardware Accelerator 231
5.6.7 Real-Time FFT Using the C55xx Hardware Accelerator 233
5.6.8 Fast Convolution Using the Overlap–Add Technique 234
5.6.9 Real-Time Fast Convolution 235
Exercises 236
References 238
6 Adaptive Filtering 239
6.1 Introduction to Random Processes 239
6.2 Adaptive Filters 243
6.2.1 Introduction to Adaptive Filtering 243
6.2.2 Performance Function 244
6.2.3 Method of Steepest Descent 248
6.2.4 LMS Algorithm 249
6.2.5 Modified LMS Algorithms 251
6.3 Performance Analysis 252
6.3.1 Stability Constraint 252
6.3.2 Convergence Speed 253
6.3.3 Excess Mean-Square Error 254
6.3.4 Normalized LMS Algorithm 254
6.4 Implementation Considerations 255
6.4.1 Computational Issues 255
6.4.2 Finite-Precision Effects 256
6.4.3 MATLAB1 Implementations 257
6.5 Practical Applications 259
6.5.1 Adaptive System Identification 259
6.5.2 Adaptive Prediction 262
6.5.3 Adaptive Noise Cancellation 264
6.5.4 Adaptive Inverse Modeling 267
6.6 Experiments and Program Examples 268
6.6.1 LMS Algorithm Using Floating-Point C 268
6.6.2 Leaky LMS Algorithm Using Fixed-Point C 270
6.6.3 Normalized LMS Algorithm Using Fixed-Point C and Intrinsics 270
6.6.4 Delayed LMS Algorithm Using Assembly Program 274
6.6.5 Experiment of Adaptive System Identification 275
6.6.6 Experiment of Adaptive Predictor 276
6.6.7 Experiment of Adaptive Channel Equalizer 277
6.6.8 Real-Time Adaptive Prediction Using eZdsp 279
Exercises 280
References 282
7 Digital Signal Generation and Detection 283
7.1 Sine Wave Generators 283
7.1.1 Lookup Table Method 283
7.1.2 Linear Chirp Signal 286
7.2 Noise Generators 288
7.2.1 Linear Congruential Sequence Generator 288
7.2.2 Pseudo-random Binary Sequence Generator 289
7.2.3 White, Color, and Gaussian Noise 290
7.3 DTMF Generation and Detection 291
7.3.1 DTMF Generator 291
7.3.2 DTMF Detection 292
7.4 Experiments and Program Examples 298
7.4.1 Sine Wave Generator Using Table Lookup 298
7.4.2 Siren Generator Using Table Lookup 299
7.4.3 DTMF Generator 299
7.4.4 DTMF Detection Using Fixed-Point C 300
7.4.5 DTMF Detection Using Assembly Program 301
Exercises 302
References 302
8 Adaptive Echo Cancellation 304
8.1 Introduction to Line Echoes 304
8.2 Adaptive Line Echo Canceler 306
8.2.1 Principles of Adaptive Echo Cancellation 306
8.2.2 Performance Evaluation 308
8.3 Practical Considerations 309
8.3.1 Pre-whitening of Signals 309
8.3.2 Delay Estimation 309
8.4 Double-Talk Effects and Solutions 312
8.5 Nonlinear Processor 314
8.5.1 Center Clipper 314
8.5.2 Comfort Noise 315
8.6 Adaptive Acoustic Echo Cancellation 315
8.6.1 Acoustic Echoes 316
8.6.2 Acoustic Echo Canceler 317
8.6.3 Subband Implementations 318
8.6.4 Delay-Free Structures 321
8.6.5 Integration of Acoustic Echo Cancellation with Noise Reduction 321
8.6.6 Implementation Considerations 322
8.7 Experiments and Program Examples 323
8.7.1 Acoustic Echo Canceler Using Floating-Point C 323
8.7.2 Acoustic Echo Canceler Using Fixed-Point C with Intrinsics 325
8.7.3 Integration of AEC and Noise Reduction 326
Exercises 328
References 329
9 Speech Signal Processing 330
9.1 Speech Coding Techniques 330
9.1.1 Speech Production Model Using LPC 331
9.1.2 CELP Coding 332
9.1.3 Synthesis Filter 334
9.1.4 Excitation Signals 337
9.1.5 Perceptual Based Minimization Procedure 340
9.1.6 Voice Activity Detection 341
9.1.7 ACELP Codecs 343
9.2 Speech Enhancement 350
9.2.1 Noise Reduction Techniques 350
9.2.2 Short-Time Spectrum Estimation 351
9.2.3 Magnitude Spectrum Subtraction 353
9.3 VoIP Applications 355
9.3.1 Overview of VoIP 355
9.3.2 Discontinuous Transmission 357
9.3.3 Packet Loss Concealment 358
9.3.4 Quality Factors of Media Stream 359
9.4 Experiments and Program Examples 360
9.4.1 LPC Filter Using Fixed-Point C with Intrinsics 360
9.4.2 Perceptual Weighting Filter Using Fixed-Point C with Intrinsics 364
9.4.3 VAD Using Floating-Point C 365
9.4.4 VAD Using Fixed-Point C 367
9.4.5 Speech Encoder with Discontinuous Transmission 368
9.4.6 Speech Decoder with CNG 369
9.4.7 Spectral Subtraction Using Floating-Point C 370
9.4.8 G.722.2 Using Fixed-Point C 372
9.4.9 G.711 Companding Using Fixed-Point C 373
9.4.10 Real-Time G.711 Audio Loopback 373
Exercises 374
References 375
10 Audio Signal Processing 377
10.1 Introduction 377
10.2 Audio Coding 378
10.2.1 Basic Principles 378
10.2.2 Frequency-Domain Coding 383
10.2.3 Lossless Audio Coding 386
10.2.4 Overview of MP3 387
10.3 Audio Equalizers 389
10.3.1 Graphic Equalizers 389
10.3.2 Parametric Equalizers 391
10.4 Audio Effects 397
10.4.1 Sound Reverberation 398
10.4.2 Time Stretch and Pitch Shift 399
10.4.3 Modulated and Mixed Sounds 401
10.4.4 Spatial Sounds 409
10.5 Experiments and Program Examples 411
10.5.1 MDCT Using Floating-Point C 411
10.5.2 MDCT Using Fixed-Point C and Intrinsics 415
10.5.3 Pre-echo Effects 416
10.5.4 MP3 Decoding Using Floating-Point C 419
10.5.5 Real-Time Parametric Equalizer Using eZdsp 421
10.5.6 Flanger Effects 422
10.5.7 Real-Time Flanger Effects Using eZdsp 423
10.5.8 Tremolo Effects 424
10.5.9 Real-Time Tremolo Effects Using eZdsp 425
10.5.10 Spatial Sound Effects 425
10.5.11 Real-Time Spatial Effects Using eZdsp 426
Exercises 427
References 428
11 Introduction to Digital Image Processing 430
11.1 Digital Images and Systems 430
11.1.1 Digital Images 430
11.1.2 Digital Image Systems 431
11.2 Color Spaces 432
11.3 YCbCr Sub-sampled Color Space 433
11.4 Color Balance and Correction 434
11.4.1 Color Balance 434
11.4.2 Color Correction 435
11.4.3 Gamma Correction 436
11.5 Histogram Equalization 437
11.6 Image Filtering 440
11.7 Fast Convolution 448
11.8 Practical Applications 452
11.8.1 DCT and JPEG 452
11.8.2 Two-Dimensional DCT 452
11.8.3 Fingerprint 455
11.8.4 Discrete Wavelet Transform 456
11.9 Experiments and Program Examples 461
11.9.1 YCbCr to RGB Conversion 462
11.9.2 White Balance 464
11.9.3 Gamma Correction and Contrast Adjustment 465
11.9.4 Image Filtering 467
11.9.5 DCT and IDCT 468
11.9.6 Image Processing for Fingerprints 469
11.9.7 The 2-D Wavelet Transform 470
Exercises 474
References 475
Appendix A Some Useful Formulas and Definitions 477
A.1 Trigonometric Identities 477
A.2 Geometric Series 478
A.3 Complex Variables 479
A.4 Units of Power 480
References 483
Appendix B Software Organization and List of Experiments 484
Appendix C Introduction to the TMS320C55xx Digital Signal Processor 490
C.1 Introduction 490
C.2 TMS320C55xx Architecture 490
C.2.1 Architecture Overview 490
C.2.2 On-Chip Memories 494
C.2.3 Memory-Mapped Registers 495
C.2.4 Interrupts and Interrupt Vector 498
C.3 TMS320C55xx Addressing Modes 498
C.3.1 Direct Addressing Modes 501
C.3.2 Indirect Addressing Modes 502
C.3.3 Absolute Addressing Modes 505
C.3.4 MMR Addressing Mode 505
C.3.5 Register Bits Addressing Mode 506
C.3.6 Circular Addressing Mode 507
C.4 TMS320C55xx Assembly Language Programming 508
C.4.1 Arithmetic Instructions 508
C.4.2 Logic and Bit Manipulation Instructions 509
C.4.3 Move Instruction 509
C.4.4 Program Flow Control Instructions 510
C.4.5 Parallel Execution 514
C.4.6 Assembly Directives 516
C.4.7 Assembly Statement Syntax 518
C.5 C Programming for TMS320C55xx 520
C.5.1 Data Types 520
C.5.2 Assembly Code Generation by C Compiler 520
C.5.3 Compiler Keywords and Pragma Directives 522
C.6 Mixed C and Assembly Programming 525
C.7 Experiments and Program Examples 529
C.7.1 Examples 529
C.7.2 Assembly Program 530
C.7.3 Multiplication 530
C.7.4 Loops 531
C.7.5 Modulo Operator 532
C.7.6 Use Mixed C and Assembly Programs 533
C.7.7 Working with AIC3204 533
C.7.8 Analog Input and Output 534
References 535
Index 537