Author |
Message |
Dr. Spankenstein
Joined: Mar 03, 2007 Posts: 136 Location: Cambridge
Audio files: 1
|
Posted: Mon Jun 11, 2007 3:01 am Post subject:
Implementing a Comb Filter using the available filters... |
 |
|
Hello again guys,
I've been reading through the list of available filters and have come across no references to a Comb Filter. I was wondering if anyone had any bright ideas on how to implement one in ChucK using the Unit Generators that are available, along with the coefficients required?
I guess it might have something to do with the OnePole filter but I am not too hot on this subject
Thanks for your time,
Rhys |
|
Back to top
|
|
 |
kijjaz

Joined: Sep 20, 2004 Posts: 765 Location: bangkok, thailand
Audio files: 4
|
Posted: Mon Jun 11, 2007 5:26 am Post subject:
|
 |
|
Looking at the meaning of 'comb filter' can give me basic ideas for producing a comb filter easily.
from http://en.wikipedia.org/wiki/Comb_filter
".. a comb filter adds a delayed version of a signal to itself .."
so let's just use only delays and simple routing.
- comb filter without feedback. (comb filter in Feedforward form mentioned in wikipedia)
So it's simply adding the delayed signal to the output.
I'll implement this using a DelayA
(for a flat respond, I hope..
but Delay, DelayA, DelayL can all be used, but will produce a different effect because of their different artifacts to the frequency domain)
Let's first here a pure white noise:
Code: | Noise s => dac;
0.4 => s.gain;
1::second => now; |
Ahhh.. i love sea breeze.
Now i'll add the delayed channel, then add the result to dac:
Code: | Noise s => dac;
0.4 => s.gain;
1::second => now;
s => DelayA delay1 => dac;
second => delay1.max;
2::ms => delay1.delay;
1::second => now; |
After adding the delayed signal,
you can notice the combing effect of the delay right away.
change the delay1.delay time to hear pitches coming out.
The fundamental frequency that this combing effect create is...
second / delay time.
The above example has delay time = 2::ms..
so let's check with chuck what fundamental frequency the comb filter's producting:
Code: | <<< second / 2::ms >>>;
result:
500.000000 :(float) |
And if you want to convert frequency to delay time,
just do this calculation: second / frequency (in float)
(for example, second / 500.0 should yeild 2::ms)
- - -
let's extend the example so that we can hear the feedback effect of a comb filter.
Code: | Noise s => dac;
0.2 => s.gain;
1::second => now;
s => DelayA delay1 => dac;
delay1 => Gain delayfeedback => delay1; // the feedback loop is added here
0.8 => delayfeedback.gain; // feedback amount
second => delay1.max;
2::ms => delay1.delay;
1::second => now; |
Now i've lowered the gain of s..
because we have more 'resonance' out of the feedback effect of the delay.
you can set delayfeedback.gain to value between 0 - 1 to see the feedback in action.
you can also set the feedback gain more than 1, but the sound can get louder until clipped in this situation.
(but yes, it is useful in other situation)
- - -
to conclude:
to achieve a Feed Forward Comb Filter effect:
(the source) => (the output);
(the source) => Delay combfilter => (the output);
then set combfilter: max (to the maximum delay you'll need), delay (to the delay time of the comb filter)
to achive a Feedback of the comb filter:
add: combfilter => Gain feedbackgain => combfilter;
BONUS:
to chuck the delay part with feedback all in one expression:
(the source) => Delay combfilter => Gain feedbackgain => combfilter => (the output); |
|
Back to top
|
|
 |
kijjaz

Joined: Sep 20, 2004 Posts: 765 Location: bangkok, thailand
Audio files: 4
|
Posted: Mon Jun 11, 2007 5:45 am Post subject:
|
 |
|
An example in my idea on connecting only delays
and feedback them all over the system.
So these are actually all Comb Filters.
Change the Delay type (from DelayA to Delay, DelayL)
to see the effect of the delay type to the frequency response.
Decrease the feedback3.gain from 50% to hear a decayed system sound instead of a sustained sound.
Code: | // Connect Impulse to delay1 to delay2 to delay3
Impulse s => DelayA d1 => DelayA d2 => DelayA d3;
// output d2 to left and d3 to right
d2 => Pan2 p1 => dac;
d3 => Pan2 p2 => dac;
-1 => p1.gain;
1 => p2.gain;
// set master volumn
0.5 => p1.gain => p2.gain;
// feedback back from d3 to both d1, d2
// distributing 50% of its output to each.
d3 => Gain feedback3 => d1;
feedback3 => d2;
0.5 => feedback3.gain;
// initiate d1, d2, d3
second => d1.max => d2.max => d3.max;
// randomize d1, d2, d3's comb filter frequency
// to a ranadom multiples of 110hz (up to 6x).
// Calculated by Delay Time = second / frequency in float
second / (Std.rand2(1, 6) * 110) => d1.delay;
<<< "d1 frequency:", second / d1.delay() >>>;
second / (Std.rand2(1, 6) * 110) => d2.delay;
<<< "d2 frequency:", second / d2.delay() >>>;
second / (Std.rand2(1, 6) * 110) => d3.delay;
<<< "d3 frequency:", second / d3.delay() >>>;
// Give d1 a kickstart with an impulse
s.next(1.0);
// Hear the bell.
10::second => now; |
|
|
Back to top
|
|
 |
Dr. Spankenstein
Joined: Mar 03, 2007 Posts: 136 Location: Cambridge
Audio files: 1
|
Posted: Tue Jun 12, 2007 2:45 am Post subject:
|
 |
|
Thanks very much kijjaz!
Now that you've explained it to me in ChucK code I can finally understand the fundamentals of how the comb filter works.
I'm now fiddling with the delay time on the fly to change the fundamental frequency of my drum hits...it has certainly breathed new life into them and given me another path to go down.
Many thanks again
Rhys |
|
Back to top
|
|
 |
kijjaz

Joined: Sep 20, 2004 Posts: 765 Location: bangkok, thailand
Audio files: 4
|
Posted: Tue Jun 12, 2007 3:16 pm Post subject:
|
 |
|
Wow.. Fiddling with delay time on the fly?
hmm.. sounds like a chorusing for the drums.. that's so nice!
How do you implement that to get a smooth-sounding result?
i'll try that on my own also, to find a closer-to-analog character chorusing.
- - -
I'd like to try adding a 1-pole filter (lowpass and highpass) after the delay
to ear out a filtered comb filter sound also.
That'd smooth some chorused drum sounds well.
Lets share some tweaking technics further more.
Keep fighting we all !  |
|
Back to top
|
|
 |
Dr. Spankenstein
Joined: Mar 03, 2007 Posts: 136 Location: Cambridge
Audio files: 1
|
Posted: Wed Jun 13, 2007 2:33 am Post subject:
|
 |
|
Instead of a one pole filter I've gone for a band pass filter that is the same frequency as the fundamental frequency of the comb filter. Adjusting the bandwidth or Q helps mellow out the sound a little.
Rhys |
|
Back to top
|
|
 |
|