For electrical engineers and computer scientists.
Digital signal processing techniques have become the method of choice in signal processing as digital computers have increased in speed, convenience, and availability. At the same time, the C language is proving itself to be a valuable programming tool for real-time computationally intensive software tasks. This book is a complete guide to digital real-time signal processing techniques in the C language.
1. Digital Signal Processing Fundamental
1. Sequences 2. The Sampling Function 3. Samples Signal Spectra 4. Spectra of Continuous Time and Discrete Time Signals 5. Linear Time-Invariant Operators 8. Causality 10. Difference Equations 10. The z- Transform Description of Linear Operators 11. Frequency Domain Transfer Function of an Operator 14. Frequency Response from the z-Transform Description 15. Digital Filters 17. Finite Impulse Response (FIR) Filters 18. Infinite Impulse Response (IIR) Filters 21. Examples of Filter Responses 22. Filter Specifications 23. Discrete Fourier Transforms 25. Form 25. Properties 26. Power Spectrum 27. Averaged Periodograms 28. The Fast Fourier Transform (FFT) 28. An Example of the FFT 30. Nonlinear Operators 32. m-Law and A-Law Compression 33. Probability and Random Processes 35. Basic Probability 35. Random Variables 36. Mean, Variance, and Gaussian Random Variables 37. Quantization of Sequences 40. Random Processes, Autocorrelation, and Spectral Density 42. Modeling Real-World Signals with AR Processes 43. Adaptive Filters and Systems 46. Wiener Filter Theory 48. LMS Algorithms 50. References 51.
The Elements of Real-Time DSP Programming 53. Variables and Data Types 56. Types of Numbers 56. Arrays 58. Operators 59. Assignment Operators 59. Arithmetic and Bitwise Operators 60. Combined Operators 61. Logical Operators 61. Operator Precedence and Type Conversion 62. Program Control 63. Conditional Execution: if-else 63. The Switch Statement 64. Single-Line Conditional Expressions 65. Loops: while, do-while, and for 66. Program Jumps: break, continue, and goto 67. Functions 69. Defining and Declaring Functions 69. Storage Class, Privacy, and Scope 71. Function Prototypes 73. Macros and the C Preprocessor 74. Conditional Preprocessor Directives 74. Aliases and Macros 75. Pointers and Arrays 77. Special Pointer Operators 77. Pointers and Dynamic Memory Allocation 78. Arrays of Pointers 80. Structures 82. Declaring and Referencing Structures 82. Pointers to Structures 84. Complex Numbers 85. Common C Programming Pitfalls 87. Array Indexing 87. Failure to Pass-by-Address 87. Misusing Pointers 88. Numerical C Extensions 90. Complex Data Types 90. Iteration Operators 91. Comments on Programming Style 92. Software Quality 93. Structured Programming 95. References 97.
Typical Floating-Point Digital Signal Processors 99. AT&T DSP32C and DSP3210 100. Analog Devices ADSP-210XX 104. Texas Instruments TMS320C3X and TMS320C40 108. Typical Programming Tools for DSP 111. Basic C Compiler Tools 111. Memory Map and Memory Bandwidth Considerations 113. Assembly Language Simulators and Emulators 114. Advanced C Software Tools for DSP 117. Source Level Debuggers 117. Assembly-C Language Interfaces 120. Numeric C Compilers 121. ReaL-Time System Design Considerations 124. Physical Input/Output (Memory Mapped, Serial, Polled) 124. Interrupts and Interrupt- Driven I/O 125. Efficiency of Real-Time Compiled Code 128. Multiprocessor Architectures 130.
Real-Time FIR and IIR Filters 132. FIR Filter Function 134. FIR Filter Coefficient Calculation 136. IIR Filter Function 145. Real-Time Filtering Example 151. Filtering to Remove Noise 158. Gaussian Noise Generation 158. Signal-to-Noise Ratio Improvement 160. Sample Rate Conversion 160. FIR Interpolation 163. Real-Time Interpolation Followed by Decimation 163. Real-Time Sample Rate Conversion 167. Fast Filtering Algorithms 168. Fast Convolution Using FFT Methods 170. Interpolation Using the FFT 176. Oscillators and Waveform Synthesis 178. IIR Filters as Oscillators 178. Table-Generated Waveforms 179. References 187.
FFT Power Spectrum Estimation 186. Speech Spectrum Analysis 187. Doppler Radar Processing 190. Parametric Spectral Estimation 193. ARMA Modeling of Signals 193. AR Frequency Estimation 198. Speech Processing 200. Speech Compression 201. ADPCM (G.722) 202. Music Processing 218. Equalization and Noise Removal 218. Pitch-Shifting 220. Music Synthesis 225. Adaptive Filter Applications 228. LMS Signal Enhancement 228. Frequency Tracking with Noise 233. References 237.
Digital signal processing techniques have become the method of choice in signal processing as digital computers have increased in speed, convenience, and availability. As microprocessors have become less expensive and more powerful, the number of DSP applications which have become commonly available has exploded. Thus, some DSP microprocessors can now be considered commodity products. Perhaps the most visible high volume DSP applications are the so called multimedia applications in digital audio, speech processing, digital video, and digital communications. In many cases, these applications contain embedded digital signal processors where a host CPU works in a loosely coupled way with one or more DSPs to control the signal flow or DSP algorithm behavior at a real-time rate.
Unfortunately, the development ofsignal processing algorithms for these specialized embedded DSPs is still difficult and often requires specialized training in a particular assembly language for the target DSP. The tools for developing new DSP algorithms are slowly improving as the need to design new DSP applications more quickly becomes important.
The C language is proving itself to be a valuable programming tool for real- time computationally intensive sof tware tasks. C has high-level language capabilities (such as structures, arrays, and functions) as well as low-level assembly language capabilities (such as bit manipulation, direct hardware input/output, and macros) which makes C an ideal language f or embedded DSP. Most of the manufacturers of digital signal processing devices (such as Texas Instruments, AT&T, Motorola, and Analog Devices) provide C compilers, simulators, and emulators for their parts. These C compilers offer standard C language with extensions for DSP to allow for very efficient code to be generated. For example, an inline assembly language capability is usually provided in order to optimize the performance of time critical parts of an application. Because the majority of the code is C, an application can be transferred to another processor much more easily than an all assembly language program.
This book is constructed in such a way that it will be most useful to the engineer who is familiar with DSP and the C language, but who is not necessarily an expert in both. All of the example programs in this book have been tested using standard C c ompilers in the UNIX and MS- DOS programming environments. In addition, the examples have been compiled utilizing the real-time programing tools of specific real- time embedded DSP microprocessors (Analog Devices ADSP-21020 and ADSP- 21062; Texas Instr ument's TMS320C30 and TMS320C40; and AT&T's DSP32C) and then tested with real-time hardware using real world signals. All of the example programs presented in the text are provided in source code form on the IBM PC floppy disk included with the book.
The text is divided into several sections.
Chapters 1 and 2 cover the basic principles of digital signal processing and C programming. Readers familiar with these topics may wish to skip one or both chapters.
Chapter 3 introduces the basic real-time DSP programming techniques and typical programming environments which are used with DSP microprocessors.
Chapter 4 covers the basic real-time filtering techniques which are the cornerstone of one-dimensional real-time digital signal processing. Finally, several real-time DSP applications are presented in Chapter 5, including speech compression, music signal processing, radar signal processing, and adaptive signal processing techniques.
The floppy disk included with this text contains C language source code for all of the DSP programs discussed in this book. The floppy disk has a high density format and was written by MS-DOS. The appendix and the READ.ME files on the floppy disk provide more information about how to compile and run the C programs. These programs have been tested using Borland's TURBO C (version 3 and greater) as well as Microsoft C (versions 6 and greater) for the IBM PC. Real-time DSP platforms using the Analo g Devices ADSP-21020 and the ADSP-21062, the Texas Instruments TMS320C30, and the AT&T DSP32C have been used extensively to test the real-time performance of the algorithms.
I thank the following people for their generous help: Laura Mercs for help in preparing the electronic manuscript and the software for the DSP32C; the engineers at Analog Devices (in particular Steve Cox, Marc Hoffman, and Hans Rempel) for their revi ew of the manuscript as well as hardware and software support; Texas Instruments for hardware and software support; Jim Bridges at Communication Automation & Control, Inc., and Talal Itani at Domain Technologies, Inc.
Paul M. Embree
IBM and IBM PC are trademarks of the International Business Machines Corporation.
MS-DOS and Mircosoft C are trademarks of the Microsoft Corporation.
TURBOC is a trademark of Borland International.
UNIX is a trademark of American Telephone and Telegraph Corporation.
DSP32C and DSP3210 are trademarks of American Telephone and Telegraph Corporation.
TMS320C30, TMS320C31, and TMS320C40 are trademarks of Texas Instruments Incorporated.
ADSP-21020, ADSP-21060, and ADSP-21062 are trademarks of Analog Devices Incorporated.