Hi folks,

Is it possible to change the center frequency of a band pass filter, while keeping its bandwidth the same?

I’m trying to do this, using a low frequency SinOsc, whose output is shifted using the following function from Charles Dodge:

y = (( ( ymax - ymin ) / (xmax -xmin ) ) * ( x - xmin ) ) + ymin

(Parentheses are in keeping with SC’s proclivities.)

Here’s the code::

data = env * PlayBuf.ar(numChannels: 1, bufnum: a.bufnum, rate: 1.0, startPos: 0.0) ;

// the following is an attempt at implementing the scaling function:

// y = ( (ymax-ymin)/(xmax-xmin) ) * ( x - xmin ) + ymin ;

// as described in Charles Dodge’s book “Computer Music”

//

// the idea is to implement a band pass filter in which the center frequency oscillates

// between ymax and ymin, but the bandwidth remains the same.

cf = 800 ; // center frequency

bw = 500 ; // desired bandwith

xmax = 1.0 ; // xmax and xmin are the limits of the SinOsc()

xmin = -1.0 ;

ymax = cf + ( bw / 2 ) ; // these are the desired limits for the band pass filter

ymin = cf - ( bw / 2 ) ;

scale = ( ymax - ymin ) / ( xmax - xmin ) ;

cf2 = (scale * (SinOsc.ar(freq: 1) - xmin) ) + ymin ; // calculate current value of cf

rQ = cf2 / bw ; // recalculate value of rQ, given new value of cf

output = BPF.ar(data, cf2, rQ); /// pass data through BandPassFilter()

Out.ar(0, output)

Thanks for any help or advice.

Arun Chandra