Audio filters can range from devices that subtly shape the tonal characteristics of a sound to ones that dramatically remove whole portions of a sound spectrum to create new sounds. Csound includes several versions of each of the commonest types of filters and some more esoteric ones also. The full list of Csound's standard filters can be found here. A list of the more specialised filters can be found here.
The first type of filter encountered is normally the lowpass filter. As its name suggests it allows lower frequencies to pass through unimpeded and therefore filters higher frequencies. The crossover frequency is normally referred to as the 'cutoff' frequency. Filters of this type do not really cut frequencies off at the cutoff point like a brick wall but instead attenuate increasingly according to a cutoff slope. Different filters offer cutoff slopes of different of steepness. Another aspect of a lowpass filter that we may be concerned with is a ripple that might emerge at the cutoff point. If this is exaggerated intentionally it is referred to as resonance or 'Q'.
In the following example, three lowpass filters filters are demonstrated: tone, butlp and moogladder. tone offers a quite gentle cutoff slope and therefore is better suited to subtle spectral enhancement tasks. butlp is based on the Butterworth filter design and produces a much sharper cutoff slope at the expense of a slightly greater CPU overhead. moogladder is an interpretation of an analogue filter found in a moog synthesizer – it includes a resonance control.
In the example a sawtooth waveform is played in turn through each filter. Each time the cutoff frequency is modulated using an envelope, starting high and descending low so that more and more of the spectral content of the sound is removed as the note progresses. A sawtooth waveform has been chosen as it contains strong higher frequencies and therefore demonstrates the filters characteristics well; a sine wave would be a poor choice of source sound on account of its lack of spectral richness.
EXAMPLE 05C01_tone_butlp_moogladder.csd
<CsoundSynthesizer> <CsOptions> -odac ; activates real time sound output </CsOptions> <CsInstruments> ; Example by Iain McCurdy sr = 44100 ksmps = 32 nchnls = 1 0dbfs = 1 instr 1 prints "tone%n" ; indicate filter type in console aSig vco2 0.5, 150 ; input signal is a sawtooth waveform kcf expon 10000,p3,20 ; descending cutoff frequency aSig tone aSig, kcf ; filter audio signal out aSig ; filtered audio sent to output endin instr 2 prints "butlp%n" ; indicate filter type in console aSig vco2 0.5, 150 ; input signal is a sawtooth waveform kcf expon 10000,p3,20 ; descending cutoff frequency aSig butlp aSig, kcf ; filter audio signal out aSig ; filtered audio sent to output endin instr 3 prints "moogladder%n" ; indicate filter type in console aSig vco2 0.5, 150 ; input signal is a sawtooth waveform kcf expon 10000,p3,20 ; descending cutoff frequency aSig moogladder aSig, kcf, 0.9 ; filter audio signal out aSig ; filtered audio sent to output endin </CsInstruments> <CsScore> ; 3 notes to demonstrate each filter in turn i 1 0 3; tone i 2 4 3; butlp i 3 8 3; moogladder e </CsScore> </CsoundSynthesizer>
A highpass filter is the converse of a lowpass filter; frequencies higher than the cutoff point are allowed to pass whilst those lower are attenuated. atone and buthp are the analogues of tone and butlp. Resonant highpass filters are harder to find but Csound has one in bqrez. bqrez is actually a multi-mode filter and could also be used as a resonant lowpass filter amongst other things. We can choose which mode we want by setting one of its input arguments appropriately. Resonant highpass is mode 1. In this example a sawtooth waveform is again played through each of the filters in turn but this time the cutoff frequency moves from low to high. Spectral content is increasingly removed but from the opposite spectral direction.
EXAMPLE 05C02_atone_buthp_bqrez.csd
<CsoundSynthesizer> <CsOptions> -odac ; activates real time sound output </CsOptions> <CsInstruments> ; Example by Iain McCurdy sr = 44100 ksmps = 32 nchnls = 1 0dbfs = 1 instr 1 prints "atone%n" ; indicate filter type in console aSig vco2 0.2, 150 ; input signal is a sawtooth waveform kcf expon 20, p3, 20000 ; define envelope for cutoff frequency aSig atone aSig, kcf ; filter audio signal out aSig ; filtered audio sent to output endin instr 2 prints "buthp%n" ; indicate filter type in console aSig vco2 0.2, 150 ; input signal is a sawtooth waveform kcf expon 20, p3, 20000 ; define envelope for cutoff frequency aSig buthp aSig, kcf ; filter audio signal out aSig ; filtered audio sent to output endin instr 3 prints "bqrez(mode:1)%n" ; indicate filter type in console aSig vco2 0.03, 150 ; input signal is a sawtooth waveform kcf expon 20, p3, 20000 ; define envelope for cutoff frequency aSig bqrez aSig, kcf, 30, 1 ; filter audio signal out aSig ; filtered audio sent to output endin </CsInstruments> <CsScore> ; 3 notes to demonstrate each filter in turn i 1 0 3 ; atone i 2 5 3 ; buthp i 3 10 3 ; bqrez(mode 1) e </CsScore> </CsoundSynthesizer>
A bandpass filter allows just a narrow band of sound to pass through unimpeded and as such is a little bit like a combination of a lowpass and highpass filter connected in series. We normally expect at least one additional parameter of control: control over the width of the band of frequencies allowed to pass through, or 'bandwidth'.
In the next example cutoff frequency and bandwidth are demonstrated independently for two different bandpass filters offered by Csound. First of all a sawtooth waveform is passed through a reson filter and a butbp filter in turn while the cutoff frequency rises (bandwidth remains static). Then pink noise is passed through reson and butbp in turn again but this time the cutoff frequency remains static at 5000Hz while the bandwidth expands from 8 to 5000Hz. In the latter two notes it will be heard how the resultant sound moves from almost a pure sine tone to unpitched noise. butbp is obviously the Butterworth based bandpass filter. reson can produce dramatic variations in amplitude depending on the bandwidth value and therefore some balancing of amplitude in the output signal may be necessary if out of range samples and distortion are to be avoided. Fortunately the opcode itself includes two modes of amplitude balancing built in but by default neither of these methods are active and in this case the use of the balance opcode may be required. Mode 1 seems to work well with spectrally sparse sounds like harmonic tones while mode 2 works well with spectrally dense sounds such as white or pink noise.
EXAMPLE 05C03_reson_butbp.csd
<CsoundSynthesizer> <CsOptions> -odac ; activates real time sound output </CsOptions> <CsInstruments> ; Example by Iain McCurdy sr = 44100 ksmps = 32 nchnls = 1 0dbfs = 1 instr 1 prints "reson%n" ; indicate filter type in console aSig vco2 0.5, 150 ; input signal: sawtooth waveform kcf expon 20,p3,10000 ; rising cutoff frequency aSig reson aSig,kcf,kcf*0.1,1 ; filter audio signal out aSig ; send filtered audio to output endin instr 2 prints "butbp%n" ; indicate filter type in console aSig vco2 0.5, 150 ; input signal: sawtooth waveform kcf expon 20,p3,10000 ; rising cutoff frequency aSig butbp aSig, kcf, kcf*0.1 ; filter audio signal out aSig ; send filtered audio to output endin instr 3 prints "reson%n" ; indicate filter type in console aSig pinkish 0.5 ; input signal: pink noise kbw expon 10000,p3,8 ; contracting bandwidth aSig reson aSig, 5000, kbw, 2 ; filter audio signal out aSig ; send filtered audio to output endin instr 4 prints "butbp%n" ; indicate filter type in console aSig pinkish 0.5 ; input signal: pink noise kbw expon 10000,p3,8 ; contracting bandwidth aSig butbp aSig, 5000, kbw ; filter audio signal out aSig ; send filtered audio to output endin </CsInstruments> <CsScore> i 1 0 3 ; reson - cutoff frequency rising i 2 4 3 ; butbp - cutoff frequency rising i 3 8 6 ; reson - bandwidth increasing i 4 15 6 ; butbp - bandwidth increasing e </CsScore> </CsoundSynthesizer>
A comb filter is a special type of filter that creates a harmonically related stack of resonance peaks on an input sound file. A comb filter is really just a very short delay effect with feedback. Typically the delay times involved would be less than 0.05 seconds. Many of the comb filters documented in the Csound Manual term this delay time, 'loop time'. The fundamental of the harmonic stack of resonances produced will be 1/loop time. Loop time and the frequencies of the resonance peaks will be inversely proportionsl – as loop time get smaller, the frequencies rise. For a loop time of 0.02 seconds the fundamental resonance peak will be 50Hz, the next peak 100Hz, the next 150Hz and so on. Feedback is normally implemented as reverb time – the time taken for amplitude to drop to 1/1000 of its original level or by 60dB. This use of reverb time as opposed to feedback alludes to the use of comb filters in the design of reverb algorithms. Negative reverb times will result in only the odd numbered partials of the harmonic stack being present.
The following example demonstrates a comb filter using the vcomb opcode. This opcode allows for performance time modulation of the loop time parameter. For the first 5 seconds of the demonstration the reverb time increases from 0.1 seconds to 2 while the loop time remains constant at 0.005 seconds. Then the loop time decreases to 0.0005 seconds over 6 seconds (the resonant peaks rise in frequency), finally over the course of 10 seconds the loop time rises to 0.1 seconds (the resonant peaks fall in frequency). A repeating noise impulse is used as a source sound to best demonstrate the qualities of a comb filter.
EXAMPLE 05C04_comb.csd
<CsoundSynthesizer> <CsOptions> -odac ;activates real time sound output </CsOptions> <CsInstruments> ;Example by Iain McCurdy sr = 44100 ksmps = 32 nchnls = 1 0dbfs = 1 instr 1 ; -- generate an input audio signal (noise impulses) -- ; repeating amplitude envelope: kEnv loopseg 1,0, 0,1,0.005,1,0.0001,0,0.9949,0 aSig pinkish kEnv*0.6 ; pink noise pulses ; apply comb filter to input signal krvt linseg 0.1, 5, 2 ; reverb time alpt expseg 0.005,5,0.005,6,0.0005,10,0.1,1,0.1 ; loop time aRes vcomb aSig, krvt, alpt, 0.1 ; comb filter out aRes ; audio to output endin </CsInstruments> <CsScore> i 1 0 25 e </CsScore> </CsoundSynthesizer>
In addition to a wealth of low and highpass filters Csound several more unique filters. Multimode such as bqrez provide several different filter types within a single opcode. Filter type is normally chosen using an i-rate input argument that functions like a switch. Another multimode filter, clfilt, offers addition filter controls such as 'filter design' and 'number of poles' to create unusual sound filters. unfortunately some parts of this opcode are not implemented yet.
eqfil is essentially a parametric equaliser but multiple iterations could be used as modules in a graphic equaliser bank. In addition to the capabilities of eqfil, pareq adds the possibility of creating low and high shelving filtering which might prove useful in mastering or in spectral adjustment of more developed sounds.
rbjeq offers a quite comprehensive multimode filter including highpass, lowpass, bandpass, bandreject, peaking, low-shelving and high-shelving, all in a single opcode
statevar offers the outputs from four filter types - highpass, lowpass, bandpass and bandreject - simultaneously so that the user can morph between them smoothly. svfilter does a similar thing but with just highpass, lowpass and bandpass filter types.
phaser1 and phaser2 offer algorithms containing chains of first order and second order allpass filters respectively. These algorithms could conceivably be built from individual allpass filters but these ready-made versions provide convenience and added efficiency
hilbert is a specialist IIR filter that implements the Hilbert transformer.
For those wishing to devise their own filter using coefficients Csound offers filter2 and zfilter2.
There has been error in communication with Booktype server. Not sure right now where is the problem.
You should refresh this page.