Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 591 S1 – Computational Audio -- Spring, 2017

Similar presentations


Presentation on theme: "CS 591 S1 – Computational Audio -- Spring, 2017"— Presentation transcript:

1 CS 591 S1 – Computational Audio -- Spring, 2017
Wayne Snyder Computer Science Department Boston University Lecture 7 Smoothing and Digital Filters Subtractive synthesis Formant synthesis of voice signals Demo of synthesis platforms Lecture 8 (Thursday) Physical Modeling Synthesis Karplus-Strong String Synthesis HW 03 out tomorrow, due Sunday 2/26. First Midterm is Thursday 3/3. Book Report over Spring Break. 1

2 Smoothing Algorithms and Digital Filters
Smoothing refers to the processing of reducing small variations in a signal (or, more generally, a function) and emphasizing longer-term trends; in signal processing, this is usually cast more generally in terms of a filter, which supresses particular frequencies (e.g., higher frequencies) in a signal: 2

3 Smoothing Algorithms and Digital Filters
Smoothing Algorithms: We may think of smoothing as the process of transforming a signal using a weighted moving average of 2k+1 values around a sample for some k: Original signal X: …. X[i–k], … , X[i-1], X[i], X[i+1], … , X[i+k], …. Ci-k * X[i–k] + … + Ci-1 * X[i-1] + Ci * X[i] + Ci+1 * X[i+1] + … + Ci+k * X[i+k] = Y[i] We “slide” this “smoothing window” through the original signal X (which has been padded with k 0’s at the beginning and end, to account for what to do with partial windows at the beginning and end) to produce a smoothed signal Y: …. Y[i–k], … , Y[i-1], Y[i], Y[i+1], … , Y[i+k], …. Note: To keep the amplitude of the smoothed signal in the same range, we assume that Ci-k + … + Ci + …. + Ci+k = 1.0 3

4 Smoothing Algorithms and Digital Filters
Depending on how we set k (the width of the “smoothing window”) and the coefficients Ci-k, …, Ci, …., Ci+k, we get different kinds of smoothing: Rectangular (“Boxcar”) Smoothing: Each C = 1/(2k+1) Triangular Smoothing: The C’s “swell” in a triangle, emphasizing the current sample and its near neighbors: 2k+1 = 7 4

5 Smoothing Algorithms and Digital Filters
This is often only done with “past” values of the current sample: Exponential Smoothing uses an exponential (or geometric) decrease in the coefficients as you go farther back in the “past”: α = 0.5 5

6 Smoothing Algorithms and Digital Filters
Examples: Original Signal: Rectangular Smoothing (k = 1): Rectangular Smoothing (k = 2): Larger windows mean more smoothing! 6

7 Smoothing Algorithms and Digital Filters
Examples: Original Signal: Rectangular Smoothing [0.2, 0.2, 0.2, 0.2, 0.2]: Rectangular Smoothing [0.2, 0.2, 0.2, 0.0, 0.0]: Exponential Smoothing [ , , 0.125, 0.25, 0.5, 0.0, 0.0, 0.0, 0.0 ]: 7

8 Smoothing Algorithms and Digital Filters
A similar technique which does not exactly fit this “weighted moving average” scheme is median smoothing: Y[i] = median( X[i-k], …., X[i], ….., X[i+k] ) This will ignore extreme outliers: But otherwise acts similarly with rectangular smoothing, but with faster transitions to plateaus: 8

9 Smoothing Algorithms and Digital Filters
A useful variation of smoothing (call it “anti-smoothing” is to subtract the smoothed signal from the original; in the case of median smoothing, this will preserve the peaks and ignore the valleys! It can be useful in “peak picking” stages in audio programming: 9

10 Smoothing Algorithms and Digital Filters
In digital signal processing, the general process of modifying an input signal (e.g., by smoothing) is referred to as filtering: Filters can be used to do a variety of tasks: Amplitude modification: reduction, increase of amplitude 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 10

11 Digital Audio: Synthesis Concluded: Filters
We will consider only 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: 11

12 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: 12

13 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] y[i] Filter 13

14 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] 14

15 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 15

16 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: 16

17 Digital Audio: Synthesis Concluded: Filters
Let’s investigate the behavior of this for various values of the parameters; Here is a pass-band filter: 17

18 Digital Audio: Synthesis Concluded: Filters
Let’s investigate the behavior of this for various values of the parameters; another pass-band filter: 18

19 Digital Audio: Synthesis Concluded: Filters
Let’s investigate the behavior of this for various values of the parameters; Another pass-band filter: 19

20 Digital Audio: Synthesis Concluded: Filters
What is happening here?? Well, when we add samples at different points in the waveform, we may reinforce the wave form by constructive interference. Example: SR = 44100, we add samples at distance 100 (e.g., Y[1000] = 0.5*X[1000] + 0.5*X[900], Y[1001] = 0.5*X[1001] + 0.5*X[901], etc.) and a component sine wave is at frequency 44100/100 = 441 Hz, so that the delayed wave is perfectly in phase, and the component wave will be effectively the same: X[900] X[1000] 20

21 Digital Audio: Synthesis Concluded: Filters
But when the component wave is exactly out of phase, we may remove the wave form by destructive interference. Example: SR = 44100, we add samples at distance 100 (e.g., Y[1000] = 0.5*X[1000] + 0.5*X[900], Y[1001] = 0.5*X[1001] + 0.5*X[901], etc.) and a component sine wave is at frequency 44100/200 = Hz, so that the delayed wave is out of phase by π, and the component wave will be removed, since the sum of each pair of points is 0.0. X[900] X[1000] 21

22 Digital Audio: Synthesis Concluded: Filters
Reverb Filters Using the same paradigm at a longer distance (e.g., 0.5 seconds) results in an echo or reverberation of the signal: 22


Download ppt "CS 591 S1 – Computational Audio -- Spring, 2017"

Similar presentations


Ads by Google