Before digging into filters and digital signal processing, it might be worth to stop and reflect on the object of using a machine for music generation. Are we getting too mechanical that we need mechanisms for achieving ideas and creations?. There is a tendency to think that products resulting from a system, a machine, are molded to be mass produced and widely distributed. In this way an idea turns into a 'template' and its innovative features and success translate into patterns for replication of a hit. To think about a subject matter under this framework seems too constrained and thus limiting a wide array of features encompassed under the terms of computer music.
More than three decades have passed since our first international computer music conference (ICMC). Furthermore, The Computer Music Journal (CMJ) has been publishing papers for almost half a century. ICMS's are still happening every year and CMJ still publishing state of the art, stating and not being too idealistic, facts that a computer is far from being just a machine and probing music produced with computers is not just templates of mass produced patterns. Likewise papers keep publishing and conferences still going on periodically because in part early promises of computer technology have not materialized and remain as goals to be achieved for the faithful pursuer.
Even so, a lot has been achieved, hence horizons have widened for many. Instead of a machine, a computer is more like a 'lab', an environment to test ideas, procedures, methods, and more. With it, prototyping, modeling, arranging, editing and of course, creation of works among others are attained. Given this scope, a composer can question aesthetic issues, musical possibilities within a broad spectrum of past-present and future. Beyond analysis and synthesis techniques people can go further into frameworks encompassing new definitions of performance, interactions, listening spaces, just to name a few.
If music is a tradition, the use of a computer follows experiments and language searches on the real of the second half of the twentieth century not leaving ideas of the first half and even before. Recall “Sound Houses” in the “New Atlantis” hinted by Sir Francis Bacon (circa 1627):
“ We have also sound-houses, where we practice and demonstrate all sounds and their generation. We have harmonies, which you have not, of quarter-sounds and lesser slides of sounds. Divers instruments of music likewise to you unknown, some sweeter than any you have, together with bells and rings that are dainty and sweet...”
It does not look computer music is coerced to “digital media” as some want to label it. It goes further beyond those bounds. An advantage of the LAB analogy expressed before, is that ideas on other domains of knowledge can be tested and confronted to the music domain by means of an algorithm. For instance the idea of digital filtering came from replicating a physical mechanism into a discrete computer model of its functionality. Namely, tape recorders of the fifties and sixties. On the issue of “Composers and the Computer” Curtis Roads (circa 1985) abetted hints for what computer techniques beyond a machine might certainly course people pursuing this practice:
Some digital techniques are little more than precise versions of previous mechanical or analog processes. But precision is not the most important attribute of the computer. What the computer offers the composer is programmability. -The extension of functionality in any direction-...
... The computer can be used to control a synthesizer, to process sounds, to edit scores, to create scores according to composer-specified rules, to print music, to analyze music, and to act as a partner in improvisation.
Signal processing on a digital domain in a computer is an opportunity for ingenuity. Thereby, it is a method for testing ideas and for discoveries. Though, it can be challenging, it is usually rewarding. Filters process media and when in audio domains they become hammer and chisel for crafting sound in music works. A filter can remove, reduce or even strengthen certain bands of frequencies in a signal. There are infinite impulse response filters (IIR) and finite impulse response filters (FIR). On IIR filters output is recirculated into input in such a way that sound could keep recirculating in a loop forever, depending upon settings of the feedback volume control. Therefore, infinite repeats translate into infinite response. On FIR filters repeats are finite. Important to note here that 'repeats' mean 'delays' on DSP parlance. The frequency response of a filter shows which frequencies a filter passes and which it rejects. Filters are classified by the kind of frequencies they pass as follows:
More complex filters can be made out of combinations of these simpler filters. Likewise, any complex filter can be broken down into combinations of above filters. In addition to modifying the amplitude of signals based on their frequency, filters commonly modify the phase of the signals, delaying phases of some frequencies more than others. We start our examples by trying out a band pass on Snd. Here we want to get a band of frequencies in-between lower and upper frequencies. In other words we want to isolate some frequencies given a center frequency and a bandwidth. There are several ways to design a Bandpass but here and for the purpose of getting your hands right into DSP Bandpass from a FIR filter design is going to be tried.
Snd's s7 is a full featured DSP environment stocking plenty of tools to do almost any kind of conceivable signal processing techniques. You can have a canonical filter of any order and type in addition to IIR and FIR filters of any order. You just need to supply filter coefficients accordingly into the filter's generator. It is not fair to think that DSP is just boiling down recipes for getting right coefficients for a given application. Nevertheless for the time being, it is worth thinking about coefficients for our filtering applications. For the implementation of a Bandpass we need to find “the recipe” for finding its coefficients. To understand this procedure it is helpful to understand the workings of an FIR filter.
Recall that a finite impulse response FIR filter is a filter whose impulse response (or response to any finite length input) is of finite duration, because it settles to zero in finite time. An impulse response might be thought of as a single '1' (one) followed by many '0' (zeroes), on the digital discrete domain. Zeroes will come out after the one has made its way through the delay line of the filter. Most digital filters are function of a delay line. A discrete-time FIR filter of order N, each value of the output sequence is a weighted sum of the most recent input values:
Where, 'x[n]' is the input signal, 'y[n]' is the output signal, 'N' is the filter order; 'b_i' is the value of the impulse response at the i'th sample for 0 ≤ i ≤ N. Values of 'b' might also be referred as filter coefficients.
For an analytical explanation of FIR filters or for further information “HERE” or, go to Julius Smith's General Filters page: “HERE”
Several Bandpass implementations can be found on “dsp.scm”. Below is Bill Shotstaedt's code for a Bandpass FIR filter structure of order 30. While defining FIRs within Snd's filter generator, order and xcoeffs need to be supplied. The “order” argument should be one greater than the nominal filter order. “xcoeffs” are all coefficients in an array or a vector of size “order”.
|
|
Following are equations for calculating coefficients for this filter and where W_0 is lower frequency and W_1 is upper frequency. N is the order of the the filter and n is each coefficient number. Keep on mind that most filter definitions wor with radian frequencies. If Hertz are easier to handle then frequencies need to be converted.
Each value is stored in an array so that we have a vector with all coefficients to be pass into the filter unit generator of Snd.. Below there is a function definition to see if the filter really works.
|
Copy-and-paste -all-of-the-above- code into a new file and save it as “bandpass.cms”.
|
|
Above a screenshot of Snd's window showing the timeline waveform on one side and the spectrum (FFT) on the other. Notice the peak around 3000 Hz.
|
A function call above for “bpass-noise” with a center frequency of 1200 Hz., a bandwidth of 500 Hz., and filter order of 60. Listen and look at the new spectra. Band should be narrower.
|
And finally above, a function call with a filter order of 100. Frequency peak of 3000 Hz, should be sharper.
A screenshot of Snd's spectrum (FFT) window with the filter response. Notice that peaks are very close to 3000 Hz. We might call this a successful implementation of a Bandpass FIR filter.
Next another rendition of a Bandpass but this time using the Butterworth type. Once again there is an example on dsp.scm also adapted and written for Snd by Bill Schottstaedt. More information about Butterworth filters: “HERE”.. A thorough description of “dsp.scm” and its implementation is of course found on Snd's documentation.. Main characteristic of Butterworth filters is having a flat response and though suitable for occasions when a stable pass band is needed. Filter structure definition as well as its implementation on Snd's s7 is provided as follows:
|
Copy-and-paste -all-of-the-above- code into a new file and save it as “butterworth.cms”.
|
|
|
A screenshot of Snd's spectrum (FFT) window with the filter response. Notice a filter's flat response and peaks very close to 3000 Hz.
The canonical 'biquad' filter is a second-order IIR filter with two poles and two zeros. In practical terms, it is a versatile filter with options for a wide variety of implementations such as lowpass, highpass, bandpass, notch filter, among others. As an IIR filter, recall that each application depends on the coefficients of its difference equation. Nonetheless, below we are applying coefficients such that we have a resonance filter, almost like a Helmholtz 'resonator', if we can call it like that.
|
Copy-and-paste this code into a new file and save it as “resonance.cms”.
|
|
|
A screenshot of Snd's spectrum (FFT). Look at the filter's response of this sound and a resonance near 3000 Hz.
Last example is a feedback Comb filter. Comb filters are basic building blocks for digital audio effects. For example acoustic echo simulation is one instance of a comb filter. The feedback comb filter is a special case of an IIR “recursive” digital filter, since there is feedback from the delayed output to the input. The feedback comb filter can be regarded as a series of echoes, exponentially decaying and uniformly spaced in time. There can be time varying comb filters that produce “effects”, such as flanging, phasing and chorusing among others. Snd's comb filter implementation is a delay line with a scaler on the feedback. On this example we are time changing frequencies of the combs so that a changing resonance is heard as time goes by.
|
Copy-and-paste this code into a new file and save it as “combfilter.cms”.
|
|
|
|
|
A screenshot of Snd's spectrum (FFT). Look at the filter's response of this sound showing combs at almost middle of the sound file.
© Copyright 2001-2022 CCRMA, Stanford University. All rights reserved.
Created and Mantained by Juan Reyes