180 likes | 292 Views
CS 591 A1 – Computational Audio – Spring 2014. Wayne Snyder Computer Science Department Boston University. Lecture Eleven Introduction to Digital Filters Experimental Design of Simple Feedback Filters Next Time Theory: Determining the frequency response of feedback filters
E N D
CS 591 A1 – Computational Audio – Spring 2014 Wayne SnyderComputer Science DepartmentBoston University Lecture Eleven Introduction to Digital Filters Experimental Design of Simple Feedback Filters Next Time Theory: Determining the frequency response of feedback filters Types of digital filters
Digital Audio: Synthesis Concluded RECALL that synthesis methods can (approximately) be divided into two types: Amplitude Domain Methods Frequency Domain Methods We can think of the modular organization of a synthesis program as a dataflow chart of the modules (e.g., functions or methods in C or Java) that take certain parameters and produce certain outputs. Roughly you can divide these modules into Oscillators: Produce a waveform based on input parameters Filters: Take an input waveform, modify it based on parameters, and output it Miscellaneous: Timers, envelope generators, waveform “arithmetic” (add, invert, multiply, etc.) Data used in these programs can be artificial (generated by the math in your code) or real (tables of measured samples), or combination of the two. 2
Digital Audio: Synthesis Concluded: Filters Filters can be used to do a variety of tasks: Amplitude modification: reduction, increase of amplitude, stereo panning (as in HW 01) Frequency modification: Low-pass filter (allow only frequencies below some threshold) High-pass filter (allow only frequencies above some threshold) Band-pass filter (allow only frequencies in some band) Many miscellaneous tasks can be thought of as filtering: Noise reduction Tone controls Reverberation Vowel formation in vocal track In fact, almost any audio processing task can be thought of as filtering! Filters are, after the Fourier Transform, the most-used and most significant theoretical and practical aspect of audio technology; filters are especially important in music synthesis….. 3
Digital Audio: Synthesis Concluded: Filters • A Simple Model for Digital Filters • The basic idea of a digital filter is very simple; take a stream of samples, and modify it (by addition or multiplication) based on • Parameters; and • Other samples in the stream. Parameters Input samples Output samples + * Feedback (from past outputs or past inputs) Feedforward (from “future”) 4 These streams of samples can be single or multiple.
Digital Audio: Synthesis Concluded: Filters Example 1: Amplitude Shaping You have already created a simple digital filter when you changed the amplitude of the signal (either by a constant factor, as in HW 01, or by a time-varying envelope with linear interpolation, as in HW 03): Output Signal Input * Envelope Generator 5
Digital Audio: Synthesis Concluded: Filters Example 2: Noise Cancelling Headphones There are two streams of samples, those from an input signal, and those from a microphone in the environment. The listener’s ears hear BOTH signals, but would like the environmental noise to be removed. So we add an inverted version of the environmental noise to the signal, and it is removed (in theory): Output Signal Input + * Mic Input -1 6
Digital Audio: Synthesis Concluded: Filters Example 3: Echo and Reverb We can add realistic echo and reverb effects (simulating the effect of playing the signal in a physical environment, such as a canyon or a room, where the sound reflects back from a distance to the listener): In the past, such connections were called “delay lines” and could be implemented by tape machines (“tape reverb”) or other simple analog delay mechanisms. Reverb pedals are an integral part of a musican’s gear. For us, it is just a simple arithmetic operation in Python….. Outputs Signal Input + * Amp ( < 1 ) Delay Past Inputs 7
Digital Audio: Synthesis Concluded: Filters We will consider at the start two classes of filters, those for reverb and for low- and band-pass filtering. Here is the frequency response of an ideal low-pass filter, which filters out all frequencies above a certain cutoff fc: Think of this as an ideal “tone knob” on your amp or radio: it controls exactly what frequencies can be passed through. 8
Digital Audio: Synthesis Concluded: Filters Realistically, however, no filter is ideal, and has a certain envelope for how it restricts frequencies; here is a realistic low-pass filter: 9
Digital Audio: Synthesis Concluded: Filters Implementing Digital Filters A Order-K Linear (Digital) Filter is a module that takes a sequence of samples x[0..N-1] and produces an output sequence y[0..N-1]: The filter has a memory for K previous values for x[], and can do the following operations: -- Add any two values -- Multiply any value by a constant Thus, the output is a linear function of the last K values of the input; a fifth-order filter would be defined by parameters A .. E: y[i] = A*x[i] + B*x[i-1] + C*x[i-2] + D*x[i-3] + E*x[i-4] y[i] Filter y[i] 10
Digital Audio: Synthesis Concluded: Filters Let’s investigate the behavior of this for various values of the parameters; here is the baseline signal with equal values for all frequencies: y[i] = x[i] 11
Digital Audio: Synthesis Concluded: Filters Let’s investigate the behavior of this for various values of the parameters; here we have created an amplitude reducer with even frequency response (as in HW 01): 12
Digital Audio: Synthesis Concluded: Filters Let’s investigate the behavior of this for various values of the parameters; here we are summing the last two samples, which creates a typical low-pass filter: 13
Digital Audio: Synthesis Concluded: Filters Let’s investigate the behavior of this for various values of the parameters; Here is a pass-band filter: 14
Digital Audio: Synthesis Concluded: Filters Let’s investigate the behavior of this for various values of the parameters; another pass-band filter: 15
Digital Audio: Synthesis Concluded: Filters Let’s investigate the behavior of this for various values of the parameters; Another pass-band filter: 16
Digital Audio: Synthesis Concluded: Filters What is happening here?? Well, when we add samples at different points in the waveform, we may either reinforce the wave form by constructive interference: 17
Digital Audio: Synthesis Concluded: Filters What is happening here?? Well, when we add samples at different points in the waveform, we may either reinforce the wave form, or attenuate it by destructive interference: 18