Introduction to Diqital Siqnal Processing

9
Introduction to Diqital Siqnal Processing Computer Musically Speaking Tae Hong Park Tulane University, USA Y | * World Scientific NEW JERSEY • LONDON • SINGAPORE • BEIJING • SHANGHAI • HONG KONG • TAIPEI • CHENNA

Transcript of Introduction to Diqital Siqnal Processing

I n t r o d u c t i o n t o

Diqital Siqnal Processing

Computer Musically Speaking

Tae Hong Park Tulane University, USA

Y | * World Scientific NEW JERSEY • LONDON • SINGAPORE • BEIJING • SHANGHAI • HONG KONG • TAIPEI • CHENNA

CONTENTS

Preface v

Acknowledgements ix

About the Book Cover Design xi

1. Acoustics, Hearing Limitations, and Sampling 1

1 Introduction 1 2 The Sine Tone 2 3 Human Hearing and Its Limitations 4

3.1 Duration 4 3.2 Pitch 5 3.3 Amplitude and sound levels 6

3.3.1 Sound intensity level (SIL) 6 3.3.2 Sound pressure level (SPL) 8 3.3.3 Just noticeable difference (JND) . . . . 8 3.3.4 Equal loudness curve 8

3.4 Auditory masking 11 4 Sampling: The Art of Being Discrete 13

4.1 Sampling theorem 18 4.2 Aliasing 20

5 Quantization and Pulse Code Modulation (PCM) . . . . 26 5.1 SNR and QSNR 28

6 DC Component 29 7 Distortion and Square Waves 31

7.1 Dithering 33 8 Musical Examples 37 References and Further Reading 38

xiii

xiv Introduction to Digital Signal Processing

2. Time-Domain Signal Processing I 40

1 Introduction 40 2 Amplitude Envelope and ADSR 41 3 Wavetable Synthesis 43 4 Windowing, RMS, and Amplitude Envelope 46

4.1 Windowing: More details 46 4.2 RMS and amplitude envelope 50

5 Time-Domain Fundamental Frequency Computation . . 53 5.1 Zero-crossing rate 54 5.2 Autocorrelation 58 5.3 Cross-correlation 64

6 Sample Rate Conversion 65 6.1 Up-sampling 65 6.2 Down-sampling 66

7 Overlap and Add (OLA) 68 7.1 OLA: Problems and solutions 71

8 Musical Examples 72 References and Further Reading 74

3. Time-Domain Processes II 75

1 Introduction 75 2 Granular Synthesis 75

2.1 Basic granular synthesis parameters 76 2.2 Asynchronous granular synthesis 79 2.3 Pitch shifting and time stretching/compression . 80 2.4 Sound morphing with granular synthesis 81

3 Amplitude Distortion and Waveshaping 81 3.1 Dynamic compressor 83 3.2 Distortion 85 3.3 Dynamic expander 86 3.4 Tape saturation 87 3.5 Waveshaping synthesis 87

3.5.1 Chebychev polynomials of the 1st kind 88

4 Some Familiar Time-Domain DSP Effects 91 4.1 Equal power panning 91 4.2 Delays 92

4.2.1 Echo, chorus, and flanging 92

Contents xv

5 Musical Examples 95 References and Further Reading 96

4. Sine Waves 97

1 Introduction 97 2 Sinusoids Revisited 98 3 Imaginary, Complex Numbers, and Euler's Formula . . . 99

3.1 Euler's formula 101 4 Sinusoidal Modulation Techniques I: Amplitude 102

4.1 Beating 102 4.2 Amplitude modulation and ring modulation . . . 105 4.3 Amplitude modulation (AM) 106 4.4 Ring modulation 108

4.4.1 Ring modulation with complex signals 108

5 Sinusoidal Modulation Techniques II: Frequency 110 5.1 FM: Sidebands and the Bessel function I l l 5.2 Modulation index 115 5.3 General topics in FM control parameters 116

6 Musical Examples 118 References and Further Reading 121

5. Linear Time-Invariant Systems 122

1 Introduction 122 2 Difference Equations: Starting with the Moving

Average Algorithm 123 2.1 Causality 125 2.2 Difference equations: General form 125

3 Linear-Time Invariant (LTI) Systems 127 3.1 Linearity property: Scalability

and superposition 128 3.2 Time-invariance property:

Time-shift invariance 129 3.3 Importance of LTI systems in DSP 131

4 Impulse Response 132 4.1 Finite impulse response (FIR) and infinite

impulse response (IIR) 135 4.2 Stability and IIR systems 136

xvi Introduction to Digital Signal Processing

5 Convolution 138 5.1 Convolution "Need to Knows" 140

6 System Diagrams and Digital Building Blocks 141 7 Musical Examples 143

6. Frequency Response 145

1 Introduction 145 2 The Frequency Response 146

2.1 Characteristics and properties of H(е-?6*) 149 2.1.1 Frequency range and Nyquist revisited . 149 2.1.2 H(e:>e) and periodicity property 154 2.1.3 Symmetry 155

2.2 More stuff on the frequency response 156 3 Phase Response and Phase Distortion 160

3.1 Phase delay 163 3.2 Linearity and phase 165 3.3 Phase response and continuous phase 167 3.4 Group delay 168

4 The (Almost) Magical Z-Transform 172 4.1 What does all this mean? Part I 174 4.2 What does all this mean? Part II: poles

and zeros 175 4.3 What does all this mean? Part III:

the unit circle and the z-plane 176 4.4 More "complex" systems 181

5 Region of Convergence (ROC) 181 5.1 Causal system ROC 186 5.2 Mixed-causality systems 187 5.3 ROC summary 188

6 Stability and the Unit Circle 188 7 The Inverse Z-Transform 190

7.1 Long division method 191 7.2 Taylor series expansion method 193 7.3 Contour integration/residue theorem method . . 195

8 Useful Tools in MATLAB® 197 9 Musical Examples 198 References and Further Reading 199

Contents xvii

7. Filters 200

1 Introduction 200 2 Low/High/Band-Pass and Band-Stop Filters 201

2.1 Filter design specifications 203 2.2 Passband, stopband, and transition band 204 2.3 Cutoff frequency 205 2.4 Filter order, filter sharpness, and ripple 205 2.5 MATLAB® filter design tools 219

3 Filter Examples 222 3.1 Subtractive synthesis and filters 223 3.2 Bi-quadratic filter (a.k.a. Bi-quad filter)

and the Wah-Wah filter 225 3.3 The Comb-filter 233

3.3.1 Comb-filter interpretation 235 3.3.2 Comb-filter examples 238

3.4 String vibration and standing waves 242 3.5 Physical modeling synthesis and the plucked

string model 245 3.5.1 Direct implementation of difference

equations 253 3.6 Phase as a filtering application 254

3.6.1 The chorus effect 254 3.6.2 Multi-tap filters and filter banks . . . . 256 3.6.3 Fractional delay 259 3.6.4 The flanger effect 261 3.6.5 The all-pass filter 262 3.6.6 Very basic all-pass filter reverb 266

4 Musical Examples 272 References and Further Reading 274

8. Frequency-Domain and the Fourier Transform 276

1 Introduction 276 2 Additive Synthesis 277 3 The Fourier Transform 280 4 The Discrete-Time Fourier Transform (DTFT)

and the Discrete Fourier Transform (DFT) 281

xviii Introduction to Digital Signal Processing

4.1 Magnitude, Phase, and Other Basic Properties of the DFT 288

4.2 Time Resolution vs. Frequency Resolution in DFTs 289

5 Short-Time Fourier Transform (STFT) 292 6 Zero Padding 293 7 Aliasing Revisited 295 8 Another Look: Down-Sampling and Up-Sampling

Revisited 298 8.1 Down-Sampling 298 8.2 Up-Sampling 302

9 Windowing Revisited: A View from the Frequency-Domain Side 304 9.1 Rectangular Window 310 9.2 Hann Window 310 9.3 Hamming Window 311 9.4 Blackman Window 312 9.5 Chebychev and Kaiser Windows 312 9.6 Not Just More Windowing Stuff 313

10 The Fast Fourier Transform (FFT) 319 11 Convolution (also) Revisited 321

11.1 Circular Convolution and Time-Aliasing 322 12 One More Look at Dithering 325 13 Spectrogram 327 14 Fourier Transform Properties and Summary 329 15 MATLAB® and Fourier Transform 331 16 Musical Examples 331 References and Further Reading 332

9. Spectral Analysis, Vocoders, and other Goodies 333

1 Introduction 333 1.1 Musical signals and important nomenclatures . . 333

2 Spectral Analysis 335 2.1 Long-term average spectrum (LTAS) 336 2.2 Log vs. linear 336 2.3 Spectral peaks, valleys, and spectral envelope . . 340

Contents xix

2.4 Extraction of fundamental frequency and harmonics 344 2.4.1 Inverse comb-filtering 345 2.4.2 Cepstrum analysis 349 2.4.3 Harmonic product spectrum 350

3 Vocoders (Voice Coders) 352 3.1 Channel-vocoder 352

3.1.1 Filter banks, envelope followers, and the encoder 354

3.1.2 Voiced and unvoiced analysis and the decoder 356

3.1.3 Voiced and unvoiced decision-making . . 359 3.1.3.1 Zero-crossing analysis . . . . 359 3.1.3.2 Pre-emphasized energy ratio 363 3.1.3.3 Low-band to full-band

energy ratio 363 3.1.3.4 Spectral flatness measure . . 364

3.2 Linear predictive coding (LPC) 366 3.3 LPC coefficient computation 371 3.4 The phase vocoder 373

3.4.1 Estimation of instantaneous frequency 375

3.4.2 Phase unwrapping 377 3.4.3 Phase vocoder: Filter-bank

interpretation 379 3.4.4 Phase vocoder: Fourier transform

interpretation 385 3.4.5 Phase vocoder basics: Time

and pitch-shifting 390 3.4.5.1 Time-shifting 391 3.4.5.2 Pitch-shifting 396

4 Research Topics in Computer Music 397 4.1 Salient feature extraction 397

4.1.1 Spectral envelope 398 4.1.2 Spectral centroid 399 4.1.3 Shimmer and Jitter 400 4.1.4 Spectral flux 400 4.1.5 Log spectral spread 401 4.1.6 Roll-off 401

xx Introduction to Digital Signal Processing

4.1.7 Attack time (rise time) 402 4.1.8 Amplitude modulation (Tremolo) . . . . 402 4.1.9 Temporal centroid 403

4.2 MIR (Music information retrieval) 403 4.2.1 Query-by-humming (QbH) 404 4.2.2 Automatic beat detection and rhythm

analysis 405 4.2.3 Automatic timbre recognition 406

4.3 FMS (feature modulation synthesis) 407 5 Musical Examples 409 References and Further Reading 411

Appendix 415

1 To Scale or Not to Scale: That is the Question 415 1.1 Equal temperament scale 415 1.2 Just intonation 416 1.3 Bark scale 416 1.4 Mel scale 417

2 MATLAB® Programs Used in This Book 418

Index 423