[Csnd] High selectivity Low Pass Filter
Date | 2013-04-12 23:32 |
From | Dolfo91 |
Subject | [Csnd] High selectivity Low Pass Filter |
Hello all, I'm trying to compile on CsoundQT a Low Pass Filter with a high selectivity (dB/oct.) to use complex waveforms genereted with GEN 07 (like Square Wave, Sawtooth etc.) without aliasing. My idea is to filter frequencies above 16-20kH with a frequential response decay as close as possible to a 90° corner. I tried a chain of simple LPFs with "butterlp" Opcode and the result is pretty good but still not as I desire. I also tried "lowpass2" but with this one the Q parameter can only be positive and I don't want any resonance effect. Any hint? Greetings. -- View this message in context: http://csound.1045644.n5.nabble.com/High-selectivity-Low-Pass-Filter-tp5721918.html Sent from the Csound - General mailing list archive at Nabble.com. |
Date | 2013-04-12 23:35 |
From | Victor Lazzarini |
Subject | Re: [Csnd] High selectivity Low Pass Filter |
Did you try the clflt opcode? http://www.csounds.com/manual/html/clfilt.html On 12 Apr 2013, at 23:32, Dolfo91 wrote:
Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie |
Date | 2013-04-12 23:54 |
From | Dolfo91 |
Subject | [Csnd] Re: High selectivity Low Pass Filter |
Thanks. I'll try at once :) -- View this message in context: http://csound.1045644.n5.nabble.com/High-selectivity-Low-Pass-Filter-tp5721918p5721920.html Sent from the Csound - General mailing list archive at Nabble.com. |
Date | 2013-04-14 00:09 |
From | Jim Aikin |
Subject | [Csnd] Re: High selectivity Low Pass Filter |
I'm not sure it's possible to do this. Once the aliasing components are in the waveform, they can't be filtered out. To avoid aliasing, you need to start with a band-limited waveform. A mathematically pure square or sawtooth will always alias (though at low fundamental frequencies the aliasing may not be audible), because some frequency components (overtones) will always fall above the Nyquist frequency. This happens when the waveform is being generated, before it hits the filter. If I'm in error about this, I trust that wiser souls will correct me ... but that's my understanding of the theory. -- View this message in context: http://csound.1045644.n5.nabble.com/High-selectivity-Low-Pass-Filter-tp5721918p5721941.html Sent from the Csound - General mailing list archive at Nabble.com. |
Date | 2013-04-14 01:05 |
From | Justin Smith |
Subject | Re: [Csnd] Re: High selectivity Low Pass Filter |
That is true. One workaround is to calculate at a much higher sampling rate and sample down. But a simple square wave is aliased at every finite sampling rate. Also, you run into many problems when you try to generate arbitrarily steep filters - the steeper the filter the more artifacts it generates (which is pretty unhelpful if you thought the filter would remove artifacts).
The right way to do this is to use a properly band limited generating function, indirectly with something like gen 10 or directly with one of the band limited generators (like buzz, gbuzz, vco, or vco2).
On Sat, Apr 13, 2013 at 4:09 PM, Jim Aikin <midiguru23@sbcglobal.net> wrote: I'm not sure it's possible to do this. Once the aliasing components are in |
Date | 2013-04-15 01:48 |
From | Dolfo91 |
Subject | [Csnd] Re: High selectivity Low Pass Filter |
Infact, reasoning a little on this, to avoid the aliasing the filter should be paradoxically applied to the function table, not to the wave already generated; I mean that the function shouldn't be able to generate harmonics above a certain frequency. "vco2" and "vco" make this and work perfectly. But is it possible to get the same results in another, surely more complicated, way (for ex. if this was possible before the compilation of these opcodes and how)? -- View this message in context: http://csound.1045644.n5.nabble.com/High-selectivity-Low-Pass-Filter-tp5721918p5721960.html Sent from the Csound - General mailing list archive at Nabble.com. |
Date | 2013-04-15 05:29 |
From | Justin Smith |
Subject | Re: [Csnd] Re: High selectivity Low Pass Filter |
gen 10, specifying the proper levels of the proper harmonics (likely you would define multiple ftables, each one only usable up to a certain frequency, when you would swap in the next which has fewer harmonics defined)
On Sun, Apr 14, 2013 at 5:48 PM, Dolfo91 <cangio.ps@hotmail.it> wrote: Infact, reasoning a little on this, to avoid the aliasing the filter should |
Date | 2013-04-16 00:55 |
From | Dolfo91 |
Subject | [Csnd] Re: High selectivity Low Pass Filter |
So different F-Tables with different harmonic components. Ok, but how can I solve the matter of changing F-Table according to the frequency of the generated wave? I tried with "if" and "then" but certain functions table should be used inside a limited range of frequencies (for ex. beetween 450-470 Hz); so they should satisfy two different conditions and this is not possible with "if" and "then". Here is the ex. kamp invalue "_AMP" kcps invalue "_FREQ" if (kcps < 450) then kfn = 1 elseif (kcps >= 450) then kfn = 2 elseif (kcps >= 470) then kfn = 3 endif aO1 oscilikt kamp, kcps, kfn outs aO1, aO1 -- View this message in context: http://csound.1045644.n5.nabble.com/High-selectivity-Low-Pass-Filter-tp5721918p5721980.html Sent from the Csound - General mailing list archive at Nabble.com. |
Date | 2013-04-16 01:15 |
From | Justin Smith |
Subject | Re: [Csnd] Re: High selectivity Low Pass Filter |
it is a bit counterintuitive, but you can ignore then cases since each case is just assigning a number and is guaranteed to undo the previous if apropriate. kfn = 1 ; this will remain the case if kcps < 450 if (kcps >= 450) then kfn = 2 endif if (kcps >= 470) then kfn = 3 endif ... I actually like ternary expressions for this kind of thing. kfn = 1 kfn = (kcps < 450) ? kfn : 2 kfn = (kcps < 470) ? kfn : 3 ... also, much more elegantly: kfn = kcps/500 (assuming your function tables were all sequential starting from fn 1 and each was designed for a min base frequency 1000 hz higher than the previous) this can be modified extensively, but the idea is you make some numeric function that maps from frequency to table number - with something like this to make sure the result is sane:
kfn = abs(kfn) ; in case a negative frequency sneaks in kfn max kfn, 1 ; lets not try to use table 0 kfn min kfn, 20 ; the tables after this are not waveform tables
this may be a fun exercise in csound programming, but remember that vco already handles basic waveforms On Mon, Apr 15, 2013 at 4:55 PM, Dolfo91 <cangio.ps@hotmail.it> wrote: So different F-Tables with different harmonic components. Ok, but how can I |
Date | 2013-04-16 15:10 |
From | Dolfo91 |
Subject | [Csnd] Re: High selectivity Low Pass Filter |
Justin Smith wrote > This may be a fun exercise in Csound programming. Infact I try to use only fundamental opcodes and a classic syntax (orchestra and score) to get a view of as low as possible level in programming with Csound ("if" remind to C/C++, for ex.). Anyway, thanks for these really clear and useful suggestions; I'll try 'em at once ;) Greetings. -- View this message in context: http://csound.1045644.n5.nabble.com/High-selectivity-Low-Pass-Filter-tp5721918p5722004.html Sent from the Csound - General mailing list archive at Nabble.com. |
Date | 2013-04-16 15:51 |
From | Justin Smith |
Subject | Re: [Csnd] Re: High selectivity Low Pass Filter |
If what low level programming is what you are after, there is goto instead of if csound, due to its history, has a passing and not at all accidental resemblance to assembly the audio generators are called opcodes after all On Tue, Apr 16, 2013 at 7:10 AM, Dolfo91 <cangio.ps@hotmail.it> wrote: Justin Smith wrote |
Date | 2013-04-16 21:55 |
From | Dolfo91 |
Subject | [Csnd] Re: High selectivity Low Pass Filter |
Justin Smith wrote > If what low level programming is what you are after, there is "goto" > instead of "if". > Csound, due to its history, has a passing and not at all accidental > resemblance to Assembly Umh, if I'm not wrong, "goto" simply skips a section of the compilation and goes directly to a pre-defined section, isn't it? I mean it doesn't set a condition. Using "goto", how I can change F-Table according to frequency of the wave generated? PS: I just discovered thanks to the Csound Manual that it is possible to set more than a condition in a "if" and "then" branch, simply using "&&" to satisfy both conditions or "||" to satisfy one of them -- View this message in context: http://csound.1045644.n5.nabble.com/High-selectivity-Low-Pass-Filter-tp5721918p5722042.html Sent from the Csound - General mailing list archive at Nabble.com. |
Date | 2013-04-16 22:13 |
From | Justin Smith |
Subject | Re: [Csnd] Re: High selectivity Low Pass Filter |
Every if compiles to a goto on the machine code level. This is the case for every programming language. if (kfreq > 450) kgoto low ktab = 2
kgoto next :low ktab = 1 :next hard to read, but does the exact same thing that an if would
you can also construct the equivalent of case / switch statements this way (a feature csound does not even have) the && syntax is a convention in if statements, but not a feature of if
kcond = (kfreq < 450) && (ksomething = 0) if (kcond) ...
On Tue, Apr 16, 2013 at 1:55 PM, Dolfo91 <cangio.ps@hotmail.it> wrote: Justin Smith wrote |
Date | 2013-04-17 00:45 |
From | Justin Smith |
Subject | Re: [Csnd] Re: High selectivity Low Pass Filter |
errata: where I used if I meant to use cngoto (kfreq > 450) low On Tue, Apr 16, 2013 at 2:13 PM, Justin Smith <noisesmith@gmail.com> wrote:
|
Date | 2013-04-17 16:32 |
From | Dolfo91 |
Subject | [Csnd] Re: High selectivity Low Pass Filter |
But it seems it works also with "if"; so what's the difference between "if" and "cngoto"?. Anyway, to summarize all of the different ways to get the same result, can you please upload a simple .csd example file containing each condition, particularly "goto" and derivates as "cngoto" etc, treated in this topic? It would be really useful! -- View this message in context: http://csound.1045644.n5.nabble.com/High-selectivity-Low-Pass-Filter-tp5721918p5722056.html Sent from the Csound - General mailing list archive at Nabble.com. |
Date | 2013-04-17 17:16 |
From | Justin Smith |
Subject | Re: [Csnd] Re: High selectivity Low Pass Filter |
The difference is that "cngoto" is more primitive - on the hardware there is no "if" instruction, but there is one that acts like "cngoto". Of course "if" is more readable, so using more primitive operations is mostly useful for learning or curiosity rather than getting things done.
I have some urgent things to attend to at work, but should be able to make time to throw together an example sometime soon.
On Wed, Apr 17, 2013 at 8:32 AM, Dolfo91 <cangio.ps@hotmail.it> wrote: But it seems it works also with "if"; so what's the difference between "if" |
Date | 2013-04-17 17:38 |
From | Dolfo91 |
Subject | [Csnd] Re: High selectivity Low Pass Filter |
Justin Smith wrote > I have some urgent things to attend to at work, but should be able to make > time to throw together an example sometime soon. Don't worry, there is no problem; it's not urgent. Rather, I say thanks for all that! -- View this message in context: http://csound.1045644.n5.nabble.com/High-selectivity-Low-Pass-Filter-tp5721918p5722062.html Sent from the Csound - General mailing list archive at Nabble.com. |