Equivalent of tone opcode for MaxMSP
Date | 2005-10-10 02:22 |
From | Richard M. Otero |
Subject | Equivalent of tone opcode for MaxMSP |
I'm working on a project which involves porting some Csound code from the Csound Book to MaxMSP, and I can't figure out which MSP object will perform the same function as Csound's tone opcode. I know I can do it with biquad~, but I'm not sure how to figure out the correct coefficients. Any suggestions will be very helpful. Thanks, Rich |
Date | 2005-10-10 05:35 |
From | David Akbari |
Subject | Re: Equivalent of tone opcode for MaxMSP |
On Oct 9, 2005, at 9:22 PM, Richard M. Otero wrote: > I'm working on a project which involves porting some Csound code from > the Csound Book to MaxMSP, and I can't figure out which MSP object > will perform the same function as Csound's tone opcode. I know I can > do it with biquad~, but I'm not sure how to figure out the correct > coefficients. Any suggestions will be very helpful. > > Thanks, > Rich > Hi Rich, According to the Max/MSP help file for [reson~]: reson~ implements the following filter equation: y[n] = gain * (x[n] - r * x[n-2]) + c1 * y[n-1] + c2 * y[n-2], ... where r, c1, and c2 are parameters calculated from the input center frequency and Q. Whereas from the Csound Manual: Tone is a 1 term IIR filter. Its formula is: y[n] = c1 * x[n] + c2 * y[n-1] + c3 * y[n-2] ... So other than the added control of Q (inverse of ƒc) it seems to be implementing a similar filter algorithm, perhaps this could be suitable for your needs? -David |
Date | 2005-10-10 09:10 |
From | Istvan Varga |
Subject | Re: Equivalent of tone opcode for MaxMSP |
David Akbari wrote: > Tone is a 1 term IIR filter. Its formula is: > > y[n] = c1 * x[n] + c2 * y[n-1] + c3 * y[n-2] ... tone is actually y[n] = c1 * x[n] + c2 * y[n-1] where c1 and c2 are calculated as follows: b = 2 - cos(khp * 2 * PI / sr) c2 = b - sqrt(b * b - 1) c1 = 1 - c2 khp is the cutoff frequency, sr is the sample rate, and b is a temporary variable |
Date | 2005-10-10 09:19 |
From | Victor Lazzarini |
Subject | Re: Equivalent of tone opcode for MaxMSP |
Is this in the csound manual? If so, it must be corrected as it is wrong. The Filter equation quoted is second-order and (depending on c1,c2, c3) implements a resonator. A 1st-order low-pass IIR that implements tone is: [cf is cuttoff frequency] a = 2 - cos(2*pi*cf/sr) c2 = sqrt(a^2 -1) - a c1 = 1 + c2 y[n] = c1*x[n] - c2*y[n-1] [for a high-pass 'flip', just use -c2 instead of c2 in the equations above]. Victor >Tone is a 1 term IIR filter. Its formula is: > >y[n] = c1 * x[n] + c2 * y[n-1] + c3 * y[n-2] ... > >So other than the added control of Q (inverse of c) it seems to be >implementing a similar filter algorithm, perhaps this could be suitable >for your needs? > > >-David >-- >Send bugs reports to this list. >To unsubscribe, send email to csound-unsubscribe@lists.bath.ac.uk Victor Lazzarini Music Technology Laboratory Music Department National University of Ireland, Maynooth |
Date | 2005-10-11 04:45 |
From | Richard M. Otero |
Subject | Re: Equivalent of tone opcode for MaxMSP |
Thanks, Victor, Istvan, and Dave. Just to clarify for my own sake: y[n] = c1*x[n] -c2*y[n-1] is a first-order lowpass IIR filter (Victor's example) and y[n] = c1*x[n]+c2*y[n-1] is a first-order highpass IIR filter (Istvan's example via Victor's explanation of the use of -c2 instead of c2). I'm not sure what Dave's example is: y[n] = c1*x[n]+c2*y[n-1]+c3*y[n-2] ... A higher-order highpass IIR filter? Is each occurence of the c variable a pole? I hope Dr. B doesn't see this thread because I probably should have memorized all this when I took his DSP class. I'll have to consult my notes... Thanks again for your help, Rich On Oct 10, 2005, at 4:19 AM, Victor Lazzarini wrote: > Is this in the csound manual? If so, it must be > corrected as it is wrong. The Filter equation > quoted is second-order and (depending on c1,c2, c3) > implements a resonator. > > A 1st-order low-pass IIR that implements tone is: > > [cf is cuttoff frequency] > > a = 2 - cos(2*pi*cf/sr) > c2 = sqrt(a^2 -1) - a > c1 = 1 + c2 > > y[n] = c1*x[n] - c2*y[n-1] > > [for a high-pass 'flip', just use -c2 instead of c2 in the equations > above]. > > Victor > > >> Tone is a 1 term IIR filter. Its formula is: >> >> y[n] = c1 * x[n] + c2 * y[n-1] + c3 * y[n-2] ... >> >> So other than the added control of Q (inverse of ƒc) it seems to be >> implementing a similar filter algorithm, perhaps this could be >> suitable for your needs? >> >> >> -David >> -- >> Send bugs reports to this list. >> To unsubscribe, send email to csound-unsubscribe@lists.bath.ac.uk > > Victor Lazzarini > Music Technology Laboratory > Music Department > National University of Ireland, Maynooth > -- > Send bugs reports to this list. > To unsubscribe, send email to csound-unsubscribe@lists.bath.ac.uk > |
Date | 2005-10-11 07:30 |
From | David Akbari |
Subject | Re: Equivalent of tone opcode for MaxMSP |
On Oct 10, 2005, at 11:45 PM, Richard M. Otero wrote: > I'm not sure what Dave's example is: > > y[n] = c1*x[n]+c2*y[n-1]+c3*y[n-2] ... > OMG I just realized the error ... I was thinking of [lores~] when i typed that!~! They say your mental capacity drops by over 50% and declines rapidly after you have been up for 17+ hours. In any event your best bet on implementing it in MSP would be probably to use the [expr~] object. Although I'm not certain it works well in MaxMSP?? (I know it's great in Pd!) That way you can ensure that it is implemented exactly as it is in Csound. > I hope Dr. B doesn't see this thread because I probably should have > memorized all this when I took his DSP class. > LOL I know!! ... *hides* -David |
Date | 2005-10-11 09:42 |
From | Victor Lazzarini |
Subject | Re: Equivalent of tone opcode for MaxMSP |
yes, but remember that in that case c1 = 1 - c2 (as c2 from the lp example is now -c2). So you can actually use the same filter equation, but just change c1 and c2 y[n] = c1*x[n] - c2*y[n-1] intermediary variable: a = 2 - cos(2pi*cf/sr) lp case: c2 = sqrt(a^2-1) - a, c1 = 1 + c2 hp case: c2= a - sqrt(a^2-1), c1 = 1 - c2 I hope it's clear now. Dave's example generally implements a 2nd order BP filter, a reson if you use c2 = 2Rcos(2*pi*fc/sr), c3 = -R^2 where R is the radius (calculated from the BW) and fc is the centre frequency. Victor At 04:45 11/10/2005, you wrote: >y[n] = c1*x[n]+c2*y[n-1] is a first-order highpass IIR filter (Istvan's >example via Victor's explanation of the use of -c2 instead of c2). Victor Lazzarini Music Technology Laboratory Music Department National University of Ireland, Maynooth |
Date | 2005-10-11 10:12 |
From | Istvan Varga |
Subject | Re: Equivalent of tone opcode for MaxMSP |
Richard M. Otero wrote: > y[n] = c1*x[n] -c2*y[n-1] is a first-order lowpass IIR filter (Victor's > example) > > and > > y[n] = c1*x[n]+c2*y[n-1] is a first-order highpass IIR filter (Istvan's > example via Victor's explanation of the use of -c2 instead of c2). My example actually behaves in the same way, as even though +c2 is used instead of -c2, c2 is calculated with a different sign. In fact, I took the code directly from the tone opcode itself. |