Time-varying low/high/band/bandreject-pass filter (Butterworth).
in RTcmix/insts/jg
BUTTER(outsk, insk, dur, INAMP, FILTTYPE, steepness, ampbalance, inputchan, PAN, BYPASS, FREQENV[, BANDWIDTH, ringdur, OUTAMP])
CAPITALIZED parameters are pfield-enabled for table or dynamic control (see the maketable or makeconnection scorefile commands). Parameters after the [bracket] are optional and default to 0 unless otherwise noted.
Param Field | Parameter | Units | Dynamic | Optional | Notes |
---|---|---|---|---|---|
p0 | output start time | seconds | no | no | |
p1 | input start time | seconds | no | no | |
p2 | input duration | seconds | no | no | |
p3 | amplitude multiplier | relative multiplier of input signal | yes | no | |
p4 | type of filter | “lowpass”, “highpass”, “bandpass”, “bandreject” or numeric codes for the filter type (1: lowpass, 2: highpass, 3: bandpass, 4: bandreject | yes * | no | * dynamic only when using numeric codes |
p5 | steepness | > 0 | no | no | (1 is a good starting value |
p6 | balance output and input signals | 0:no, 1:yes | no | no | (usually use 1 |
p7 | input channel | - | no | no | |
p8 | pan | 0-1 stereo; 0.5 is middle | yes | no | |
p9 | bypass filter | 0: bypass off, 1: bypass on | yes | no | (usually use 0 |
p10 | filter frequency | Hz | yes | no | |
p11 | filter bandwidth for bandpass/reject types | Hz if positive; if negative, the ‘-‘ sign acts as a flag to interpret the bw values as a multiplier (0.0-1.0) of the current center frequency | yes | yes | only used for “bandpass” or “bandreject” filters |
p12 | ringdown duration | seconds | no | yes | default: 0.1 |
p13 | output amplitude multiplier | - | yes | yes | default: 1.0 |
Parameters labled as Dynamic can receive dynamic updates from a table or real-time control source.
Author: John Gibson (johgibso at indiana dot edu), 12/1/01; rev for v4, JGG, 7/24/04
BUTTER uses the butterowrth digital filter algorithm to design and instantiate various filter types.
The numeric codes for the “FILTTYPE” (p4) parameter are useful in embedded applications where strings may not be passed correctly into the parser.
p5 (“steepness”) is just the number of filters to add in series. Using more than 1 steepens the slope of the filter. If you don’t set p6 (“ampbalance”) to 1, you’ll need to change p3 (“AMP”) to adjust for loss of power caused by connecting several filters in series. Guard your ears!
p6 (“ampbalance”) tries to adjust the output of the filter so that it has the same power as the input. This means there’s less fiddling around with p3 to get the right amplitude when steepness is > 1. However, it has drawbacks: it can introduce a click at the start of the sound, it can cause the sound to pump up and down a bit, and it eats extra CPU time.
p12 (“ringdown duration”) controls how long the filter will ring once the input duration has elapsed. This is relevant only when the bandwidth is narrow enough to produce an audible ring. Very narrow bandwidths could require quite a long time to ring down (5-10 seconds or more).
p13 (“output amplitude multiplier”) lets you apply an amplitude envelope that spans the entire note, whose total duration is the sum of the input duration and the ringdown duration.
The output of BUTTER can be either mono or stereo.
very basic:
rtsetparams(44100, 1)
load("BUTTER")
rtinput("mysound.aif")
ampenv = maketable("window", 1000, "hanning")
BUTTER(0, 0, 8.7, ampenv, "bandpass", 3, 1, 0, 0, 0, 778, 90.0)
slightly more advanced:
rtsetparams(44100, 2)
load("WAVETABLE")
load("BUTTER")
/* feed wavetable into filter */
bus_config("WAVETABLE", "aux 0 out")
bus_config("BUTTER", "aux 0 in", "out 0-1")
dur = 10.0
amp = 10000
pitch = 7.00
waveform = maketable("wave", 1000,
1, 1/2, 1/3, 1/4, 1/5, 1/6, 1/7, 1/8, 1/9, 1/10, 1/11, 1/12,
1/13, 1/14, 1/15, 1/16, 1/18, 1/19, 1/20, 1/21, 1/22, 1/23, 1/24) /* saw */
reset(10000)
WAVETABLE(0, dur, amp, pitch, 0, waveform)
WAVETABLE(0, dur, amp, pitch+.0005, 0, waveform)
type = 1 // 1: lowpass, 2: highpass, 3: bandpass, 4: bandreject
amp = 1.0
sharpness = 5
if (type == 1) {
balance = 0
lowcf = 500
highcf = 5000
}
else if (type == 2) {
balance = 1
amp = amp * .4
lowcf = 1
highcf = 1400
}
ampenv = maketable("line", 1000, 0,0, 1,1, 7,1, 10,0)
filtfreqenv = maketable("line", "nonorm", 1000,
0,lowcf, dur*.2,lowcf, dur*.5,highcf, dur*.9,lowcf, dur,lowcf)
BUTTER(0, 0, dur, amp*ampenv, type, sharpness, balance, 0, 0.5, 0, filtfreqenv)
maketable, bus_config, ELL, EQ, FIR, FILTSWEEP, FILTERBANK, FOLLOWBUTTER, IIR, JFIR, MOOGVCF, MULTEQ