Topic:  Digital filters  (see homework #6, due Nov-8) (also see below, projects)

A moving average is computed by taking the sum xn + xn-1 as n slides along sample-by-sample in a signal and returning it scaled by 0.5 -- it's the average of the current sample and the previous one. The result is to smooth out fast changes (high frequencies) otherwise called a low-pass filter.

A high-pass filter is made by taking the difference, i.e. xn - xn-1 to pass the faster sample-to-sample fluctuations and reject steadier (low frequency) content.

The IIR version of a low-pass is yn = xn + yn-1 and would have an even stronger smoothing effect since it's response continues over more than the immediate samples.

The same structure relates to one-shot echoes and recirculating echoes, e.g. echo.scm where
(for n = sample number)
the FIR form is yn = xn + xn-delay
the IIR form is yn = xn - yn-delay
Their frequency response curves are distinct -- FIR has notches (zeroes) and IIR has resonances  (poles).

filter.scm introduces simple filters based on difference equations whose first- and second-order forms are

one-zero  yn = a0 xn + a1 xn-1
one-pole  yn = a0 xn - b1 yn-1
two-zero  yn = a0 xn + a1 xn-1+ a2 xn-2
two-pole  yn = a0 xn - b1 yn-1 - b2 yn-2

where the a's and b's are coefficients on each zero or pole term. The script demonstrates how a filter of order N exhibits N inflections in frequency response of the filter. The resulting spectrum is partitioned into N equal divisions. The longer the time delay, the more notched or comb-like the response (like the tube responses we've measured). Lower-order (shorter delay) versions correspond to physically small filter devices (like hands cupped in front of the mouth) and are more "EQ"-like in effect.

Using the one-zero difference equation structure, note that the moving average filter above is implemented by specifying a0 = 0.5 and a1 = 0.5

Broadband excitation best demonstrates frequency characteristics. The new script uses both click and random noise sources. The latter is a recent addition to init.scm (copy it from ~cc/220) and itself demonstrates the Scheme random function tailored to produce 16-bit values within our signal range of +- 1.0

More elaborate filters are concocted with careful balances of zeroes and poles coefficients, and arbitrarily long order. reson.scm demonstrates one useful form which provides an adjustable formant filter with parameters for gain, center frequency, and sharpness. It can provide a broad or narrow resonance, right down to a whistle approaching a sine tone. In physical terms, what is such a narrow filter that when tuned so sharply that it rings like a sinusoid? There is a way to think that makes a connection with the pendulum. In this case, the difference equation responds analogously to a physical object with mass and resonant frequency (which we've already modeled with sinusoid motion...). Mass-spring-damper systems can be modeled by digital filters.

Mini-Projects for Autumn Quarter
These are short answers to burning questions, or short compositional studies using the Snd / Scheme platform.

Examples:

Meetings with CC scheduled for all day, Tuesday, 6th to discuss topics.