Sunteți pe pagina 1din 13

Theory and Techniques of Electronic Music

DRAFT: March 3, 2006

Miller Puckette

Copyright c 2006 Miller Puckette All rights reserved.

Contents
1 Sinusoids, amplitude and frequency 1.1 Measures of Amplitude . . . . . . . . . . . . . 1.2 Units of Amplitude . . . . . . . . . . . . . . . 1.3 Controlling Amplitude . . . . . . . . . . . . . 1.4 Frequency . . . . . . . . . . . . . . . . . . . . 1.5 Synthesizing a Sinusoid . . . . . . . . . . . . 1.6 Superposing Signals . . . . . . . . . . . . . . 1.7 Periodic Signals . . . . . . . . . . . . . . . . . 1.8 About the Software Examples . . . . . . . . . Quick Introduction to Pd . . . . . . . . . . . How to nd and run the examples . . . . . . 1.9 Examples . . . . . . . . . . . . . . . . . . . . Constant amplitude scaler . . . . . . . . . . . Amplitude control in decibels . . . . . . . . . Smoothed amplitude control with an envelope Major triad . . . . . . . . . . . . . . . . . . . Conversion between frequency and pitch . . . More additive synthesis . . . . . . . . . . . . Exercises . . . . . . . . . . . . . . . . . . . . . . . 2 Wavetables and samplers 2.1 The Wavetable Oscillator . . . . . . . . 2.2 Sampling . . . . . . . . . . . . . . . . . 2.3 Enveloping samplers . . . . . . . . . . . 2.4 Timbre stretching . . . . . . . . . . . . . 2.5 Interpolation . . . . . . . . . . . . . . . 2.6 Examples . . . . . . . . . . . . . . . . . 2.6.1 wavetable oscillator . . . . . . . 2.6.2 wavetable lookup in general . . . 2.6.3 using a wavetable as a sampler . 2.6.4 looping samplers . . . . . . . . . 2.6.5 Overlapping sample looper . . . 2.6.6 Automatic read point precession iii . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 5 6 7 8 9 12 13 14 17 19 19 19 21 23 24 24 25 27 29 31 35 37 41 45 49 49 50 52 54 56 58

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

iv

CONTENTS 61 61 63 65 69 70 71 73 75 77 79 79 81 82 84 84 86 89 89 92 94 95 96 98 98 99 102 103 103 106 107 110 113 119 119 122 126 132 135 135 137 138 139 140

3 Audio and control computations 3.1 The sampling theorem . . . . . . . . . . . . . . . . . . . . 3.2 Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3 Control streams . . . . . . . . . . . . . . . . . . . . . . . . 3.4 Converting from audio signals to numeric control streams 3.5 Control streams in block diagrams . . . . . . . . . . . . . 3.6 Event detection . . . . . . . . . . . . . . . . . . . . . . . . 3.7 Control computation using audio signals directly . . . . . 3.8 Operations on control streams . . . . . . . . . . . . . . . . 3.9 Control operations in Pd . . . . . . . . . . . . . . . . . . . 3.10 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.10.1 Sampling and foldover . . . . . . . . . . . . . . . . 3.10.2 Converting controls to signals . . . . . . . . . . . . 3.10.3 Non-looping sample player . . . . . . . . . . . . . . 3.10.4 Signals to controls . . . . . . . . . . . . . . . . . . 3.10.5 Analog-style sequencer . . . . . . . . . . . . . . . . 3.10.6 MIDI-style synthesizer . . . . . . . . . . . . . . . . 4 Automation and voice management 4.1 Envelope Generators . . . . . . . . . . . . . . . . . . 4.2 Linear and Curved Amplitude Shapes . . . . . . . . 4.3 Continuous and discontinuous control changes . . . . 4.3.1 Muting . . . . . . . . . . . . . . . . . . . . . 4.3.2 Switch-and-ramp . . . . . . . . . . . . . . . . 4.4 Polyphony . . . . . . . . . . . . . . . . . . . . . . . . 4.5 Voice allocation . . . . . . . . . . . . . . . . . . . . . 4.6 Voice tags . . . . . . . . . . . . . . . . . . . . . . . . 4.7 Encapsulation in Pd . . . . . . . . . . . . . . . . . . 4.8 Examples . . . . . . . . . . . . . . . . . . . . . . . . 4.8.1 ADSR envelope generator . . . . . . . . . . . 4.8.2 Transfer functions for amplitude control . . . 4.8.3 Additive synthesis: Rissets bell . . . . . . . . 4.8.4 Additive synthesis: spectral envelope control 4.8.5 Polyphonic synthesis: sampler . . . . . . . . . 5 Modulation 5.1 Taxonomy of spectra . . . . . . . . . . . . . . . . . 5.2 Multiplying audio signals . . . . . . . . . . . . . . 5.3 Waveshaping . . . . . . . . . . . . . . . . . . . . . 5.4 Frequency and phase modulation . . . . . . . . . . 5.5 Examples . . . . . . . . . . . . . . . . . . . . . . . 5.5.1 Ring modulation and spectra . . . . . . . . 5.5.2 Octave divider and formant adder . . . . . 5.5.3 Waveshaping and dierence tones . . . . . . 5.5.4 Waveshaping using Chebychev polynomials 5.5.5 Waveshaping using an exponential function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

CONTENTS 5.5.6 5.5.7

v Sinusoidal waveshaping: evenness and oddness . . . . . . 141 Phase modulation and FM . . . . . . . . . . . . . . . . . 143 147 148 151 151 152 152 156 158 163 163 166 167 168 172 173 174 176 178 178 183 187 192 194 196 199 200 206 206 207 208 209 211 213 214 216 216 219

6 Designer spectra 6.1 Carrier/modulator model . . . . . . . . . . 6.2 Pulse trains . . . . . . . . . . . . . . . . . . 6.2.1 Pulse trains via waveshaping . . . . 6.2.2 Pulse trains via wavetable stretching 6.2.3 Resulting spectra . . . . . . . . . . . 6.3 Movable ring modulation . . . . . . . . . . 6.4 Phase-aligned formant (PAF) generator . . 6.5 Examples . . . . . . . . . . . . . . . . . . . 6.5.1 Wavetable pulse train . . . . . . . . 6.5.2 Simple formant generator . . . . . . 6.5.3 Two-cosine carrier signal . . . . . . . 6.5.4 The PAF generator . . . . . . . . . . 6.5.5 Stretched wavetables . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

7 Time shifts 7.1 Complex numbers . . . . . . . . . . . . . . . . . . . . . . . . 7.1.1 Sinusoids as geometric series . . . . . . . . . . . . . . 7.2 Time shifts and phase changes . . . . . . . . . . . . . . . . . 7.3 Delay networks . . . . . . . . . . . . . . . . . . . . . . . . . . 7.4 Recirculating delay networks . . . . . . . . . . . . . . . . . . 7.5 Power conservation and complex delay networks . . . . . . . 7.6 Articial reverberation . . . . . . . . . . . . . . . . . . . . . . 7.6.1 Controlling reverberators . . . . . . . . . . . . . . . . 7.7 Variable and fractional shifts . . . . . . . . . . . . . . . . . . 7.8 Accuracy and frequency response of interpolating delay lines 7.9 Pitch shifting . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.10 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.10.1 Fixed, noninterpolating delay line . . . . . . . . . . . 7.10.2 Recirculating comb lter . . . . . . . . . . . . . . . . . 7.10.3 Variable delay line . . . . . . . . . . . . . . . . . . . . 7.10.4 Order of execution and lower limits on delay times . . 7.10.5 Order of execution in non-recirculating delay lines . . 7.10.6 Non-recirculating comb lter as octave doubler . . . . 7.10.7 Time-varying complex comb lter: shakers . . . . . . 7.10.8 Reverberator . . . . . . . . . . . . . . . . . . . . . . . 7.10.9 Pitch shifter . . . . . . . . . . . . . . . . . . . . . . . . 7.10.10 Exercises . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . .

vi

CONTENTS 221 222 222 224 224 227 227 228 231 231 232 234 234 235 236 238 238 239 241 244 245 247 247 250 250 250 253 255 255 256 258 258 261 261 265 265 267 267 267 268 269 271 272 275 277

8 Filters 8.1 Taxonomy of lters . . . . . . . . . . . . . . . . . . . . . . . . 8.1.1 Low-pass and high-pass lters . . . . . . . . . . . . . . 8.1.2 Band-pass and stop-band lters . . . . . . . . . . . . . 8.1.3 Equalizing lters . . . . . . . . . . . . . . . . . . . . . 8.2 Designing lters . . . . . . . . . . . . . . . . . . . . . . . . . . 8.2.1 Elementary non-recirculating lter . . . . . . . . . . . 8.2.2 Non-recirculating lter, second form . . . . . . . . . . 8.2.3 Elementary recirculating lter . . . . . . . . . . . . . . 8.2.4 Compound lters . . . . . . . . . . . . . . . . . . . . . 8.2.5 Real outputs from complex lters . . . . . . . . . . . . 8.3 Designing lters . . . . . . . . . . . . . . . . . . . . . . . . . . 8.3.1 One-pole low-pass lter . . . . . . . . . . . . . . . . . 8.3.2 One-pole, one-zero high-pass lter . . . . . . . . . . . 8.3.3 Shelving lter . . . . . . . . . . . . . . . . . . . . . . . 8.3.4 Band-pass lter . . . . . . . . . . . . . . . . . . . . . . 8.3.5 Peaking and band-stop lter . . . . . . . . . . . . . . 8.3.6 Butterworth lters . . . . . . . . . . . . . . . . . . . . 8.3.7 Stretching the unit circle with rational functions . . . 8.3.8 Butterworth band-pass lter . . . . . . . . . . . . . . 8.3.9 Time-varying coecients . . . . . . . . . . . . . . . . 8.3.10 Impulse responses of recirculating lters . . . . . . . . 8.3.11 All-pass lters . . . . . . . . . . . . . . . . . . . . . . 8.4 Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.4.1 Subtractive synthesis . . . . . . . . . . . . . . . . . . . 8.4.2 Envelope following . . . . . . . . . . . . . . . . . . . . 8.4.3 Single Sideband Modulation . . . . . . . . . . . . . . . 8.5 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.5.1 Prefabricated low-, high-, and band-pass lters . . . . 8.5.2 Prefabricated time-variable band-pass lter . . . . . . 8.5.3 Envelope followers . . . . . . . . . . . . . . . . . . . . 8.5.4 Single sideband modulation . . . . . . . . . . . . . . . 8.5.5 Using elementary lters directly: shelving and peaking 8.5.6 Making and using all-pass lters . . . . . . . . . . . . 9 Fourier analysis and resynthesis 9.1 Fourier analysis of periodic signals . . . . . . . . . 9.1.1 Fourier transform as additive synthesis . . . 9.1.2 Periodicity of the Fourier transform . . . . 9.2 Properties of Fourier transforms . . . . . . . . . . 9.2.1 Fourier transform of DC . . . . . . . . . . . 9.2.2 Shifts and phase changes . . . . . . . . . . 9.2.3 Fourier transform of a sinusoid . . . . . . . 9.3 Fourier analysis of non-periodic signals . . . . . . . 9.4 Fourier analysis and reconstruction of audio signals 9.4.1 Narrow-band companding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

CONTENTS 9.4.2 Timbre stamping (classical vocoder) . Phase . . . . . . . . . . . . . . . . . . . . . . 9.5.1 Phase relationships between channels . Phase bashing . . . . . . . . . . . . . . . . . . Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

vii 279 281 285 286 288 297 299 300 302 304 309 309 310 311 314

9.5 9.6 9.7

10 Classical waveforms 10.1 Symmetries and Fourier series . . . . . . . . . . . . . . . . . . . . 10.1.1 Sawtooth waves and symmetry . . . . . . . . . . . . . . . 10.2 Decomposing the classical waveforms into sawtooth and parabolic waves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10.3 Fourier series of the elementary waveforms . . . . . . . . . . . . . 10.4 Predicting and controlling foldover . . . . . . . . . . . . . . . . . 10.4.1 Oversampling . . . . . . . . . . . . . . . . . . . . . . . . . 10.4.2 Sneaky triangle waves . . . . . . . . . . . . . . . . . . . . 10.4.3 Transition splicing . . . . . . . . . . . . . . . . . . . . . . 10.5 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

viii

CONTENTS

Introduction
This book is about using electronic techniques to record, synthesize, process, and analyze musical sounds, a practice which came into its modern form in the years 1948-1952, but whose technological means and artistic uses have undergone several revolutions since then. Nowadays most electronic music is made using computers, and this book will focus exclusively on what used to be called computer music, but which should really now be called electronic music using a computer. Most of the available computer music tools have antecedents in earlier generations of equipment. The computer, however, is relatively cheap and the results of using one are much easier to document and re-create than those of earlier generations of equipment. In these respects at least, the computer makes the ideal electronic music instrumentuntil someone invents something even cheaper and more exible than a computer. The techniques and practices of electronic music can be studied (at least in theory) without making explicit reference to the current state of technology. Still, its important to provide working examples of them. So each chapter starts with theory (without any reference to implementation) and ends with a series of examples realized in a currently available software package. The ideal reader of this book is anyone who knows and likes electronic music of any genre, has plenty of facility with computers in general, and who wants to learn how to make electronic music from the ground up, starting with the humble oscillator and continuing through sampling, FM, ltering, waveshaping, delays, and so on. This will take plenty of time. This book doesnt concern itself with the easier route of downloading precooked software to try out these techniques; instead, the emphasis is on learning how to use a general-purpose computer music environment to realize them yourself. Of the several such packages are available, well use Pd, but that shouldnt stop you from using these same techniques in some other environment such as Csound or Max/MSP. To facilitate this, each chapter is divided into a softwareindependent discussion of theory, followed by actual examples in Pd, which you can transpose into your own favorite package. To read this book you must also understand mathematics through intermediate algebra and trigonometry, which most students should have mastered by age 17 or so. A quick glance at the rst few pages of chapter one should show you if youre ready to take it on. Many adults in the U.S. and elsewhere may 1

CONTENTS

have forgotten this material and will want to get their Algebra 2 textbooks out as a reference. A refresher by F. Richard Moore appears in [Str85, pp. 1-68]. You dont need much background in music as it is taught in the West; in particular, Western written music notation is not needed. Some elementary bits of Western music theory are used, such as the tempered scale, the A-BC system of naming pitches, and terms like note and chord. Also you should be familiar with the fundamental terminology of musical acoustics such as sinusoids, amplitude, frequency, and the overtone series. Each chapter starts with a theoretical discussion of some family of techniques or theoretical issues, followed by a a series of examples realized in Pd to illustrate them. The examples are included in the Pd distribution, so you can run them and/or edit them into your own spinos. In addition, all the gures were created using Pd patches, which appear in an electronic supplement. These arent carefully documented but in principle could be used as an example of Pds drawing capabilities for anyone interested in learning more about that.

Chapter 1

Sinusoids, amplitude and frequency


Electronic music is made by synthesizing or processing digital audio signals. These are sequences of numbers, ..., x[n 1], x[n], x[n + 1], ... where the index n, called the sample number, may range over some or all the integers. A single number in the sequence is called a sample. (Some writers use the word sample dierently, to mean recorded soundbut in this book well only use the word to mean a single number.) An example of a digital audio signal is the S inusoid: Sinusoid x[n] = a cos(n + ) where a is the amplitude, is the angular frequency, and is the initial phase. The phase is a function of the sample number n, equal to + n. The initial phase is the phase at the zeroth sample (n = 0). Strictly speaking, this is the real Sinusoid, distinct from the complex Sinusoid introduced later in chapter 7; but where theres no chance of confusion we will simply say Sinusoid to speak of the real-valued one. Figure 1.1 shows a Sinusoid graphically. In part (a) of the gure, the horizontal axis shows successive values of n and the vertical axis shows the corresponsding values of x[n]. The graph is drawn in such a way as to emphasize the sampled nature of the signal. Alternatively, we could draw it more simply as a continuous curve (part b). The upper drawing is the most faithful representation of the (digital audio) Sinusoid, whereas the lower one can be considered as idealization of it. 3

CHAPTER 1. SINUSOIDS, AMPLITUDE AND FREQUENCY

x[n] (a) 1 49 -1 0 n

x(n) (b) 1 50 -1

Figure 1.1: A digital audio signal, showing its discrete-time nature (part a), and idealized as a continuous function (part b). This signal is a (real-valued) Sinusoid, fty points long, with amplitude 1, angular frequency 0.24, and initial phase zero.

1.1. MEASURES OF AMPLITUDE

Sinusoids play a key role in audio processing because, if you shift one of them left or right by any number of samples, you get another one. This makes it easy to calculate the eect of all sorts of operations on sinusoids. Our ears use this same special property to help us parse incoming sounds, which is why sinusoids, and combinations of sinusoids, can be used for a variety of musical eects. Digital audio signals do not have any intrinsic relationship with time, but to listen to them we must choose a sample rate, usually given the variable name R, which is the number of samples that t into a second. Time is related to sample number by Rt = n, or t = n/R. A sinusoidal signal with angular frequency has a real-time frequency equal to f= R 2

in cycles per second, because a cycle is 2 radians and a second is R samples. A real-world audio signals amplitude might be expressed as a time-varying voltage or air pressure, but the samples of a digital audio signal are unitless numbers. Well casually assume here that there is ample numerical accuracy so that we can ignore round-o errors, and that the numerical format is unlimited in range, so that samples may take any value we wish. However, most digital audio hardware works only over a xed range of input and output values, most often between -1 and 1. Modern digital audio processing software usually uses a oating-point representation for signals. This allows us to use whatever units are most convenient for any given task, as long as the nal audio output is within the hardwares range.

1.1

Measures of Amplitude

Strictly speaking, all the samples in a digital audio signal are themselves amplitudes, and we also spoke of the amplitude a of the Sinusoid above. In dealing with general digital audio signals, it is useful to have measures of amplitude for them. Amplitude and other measures are best thought of as applying to a window, a xed range of samples of the signal. For instance, the window starting at sample M of length N of an audio signal x[n] consists of the samples, x[M ], x[M + 1], . . . , x[M + N 1] The two most frequently used measures of amplitude are the peak amplitude, which is simply the greatest sample (in absolute value) over the window: Apeak {x[n]} = max |x[n]|, n = M, . . . , M + N 1

and the root mean square (RMS) amplitude: ARMS {x[n]} = P {x[n]}

To access for fully document please click here.

S-ar putea să vă placă și