| Author |
Message |
rogan

Joined: Dec 16, 2007 Posts: 60 Location: Urbana, IL
Audio files: 4
|
Posted: Sun May 25, 2008 10:34 pm Post subject:
Language Problem Subject description: Rogan needs help getting syntax right. |
 |
|
Hi all,
I'm writing a reverb package based on the Gardner reverbs found in <<The CSound Book>>, and I'm basically being held up by my own lack of understanding of chuck syntax.
I'm trying to implement nested allpass filters by adding a nesting function to my Allpass class (which I'll post when it's ready :) ). The problem is when I want to be able to nest any number of allpasses within my filter. I do this by trying to create an array of Allpass objects which I connect to one another. The problem in my code is that I don't instantiate my array of Allpass objects right, but I'm not sure how to actually do this correctly. Could somebody point me in the right direction?
| Code: |
public class NestedAllpass extends Allpass
{
Allpass nested[];
0 => int numNested;
public UGen nest (Allpass @ toNest){
nested[numNested] @=> toNest;
numNested++;
if ( numNested == 0 ) {
delay =< sum;
delay => nested[numNested].chuck => sum;
} else {
nest[numNested - 1] =< sum;
nest[numNested - 1] => nested[numNested].chuck => sum;
}
}
//
// Schematic of the Allpass
// ---<----feeback -<----------
// | |
// in -->-+| delay | --> (nest)-+ sum ---> out
// | |
// ==->----feedforward->-----------
//
}
|
|
|
|
Back to top
|
|
 |
Frostburn

Joined: Dec 12, 2007 Posts: 253 Location: Finland
Audio files: 9
|
Posted: Mon May 26, 2008 10:31 am Post subject:
|
 |
|
ChucK doesn't support dynamic arrays yet. I could make an example that creates new arrays all the time but because ChucK doesn't yet have garbage collection either that's a bad idea. It's hard to write a correction when I don't know how you're classes are supposed work but I'll try to correct the nest function for you.
If you pass an Object to a function it's always a reference so the @ isn't necessary in the argument definition.
| Code: |
//...snipped some code
public UGen nest (Allpass toNest){ //change: no @
toNest => nested[numNested]
numNested++;
if ( numNested == 1 ) { //change: when you call the function for the first time numNested is 1 when we reach this part.
//...snipping more code
|
_________________ To boldly go where no man has bothered to go before. |
|
|
Back to top
|
|
 |
rogan

Joined: Dec 16, 2007 Posts: 60 Location: Urbana, IL
Audio files: 4
|
Posted: Mon May 26, 2008 10:51 am Post subject:
|
 |
|
Thanks, Frostburn!
I went ahead and changed my nesting function last night, so that it either nests one or two allpass filters inside the main allpass (depending on how it's called). I'm not sure that I'll use more than two anywhere, but I always want to make my code as generic as possible.
I'll post my gardner reverbs tonight, after I've made a few modifications.... |
|
|
Back to top
|
|
 |
Inventor

Joined: Oct 13, 2007 Posts: 1700 Location: Florida, USA
Audio files: 67
|
Posted: Mon May 26, 2008 1:58 pm Post subject:
|
 |
|
Hi rogan, are you related to the Japanese monster Rogan who battled Godzilla and lost? Of course you lost, nobody beats Godzilla! OK, I jest but every ChucKist must have a sense of humor, don't you think?
I am pleased to learn about your reverb work and it will be interesting to see your results. Please keep us posted and maybe even post some mp3's of your reverb software. Thanks and happy ChucKing! _________________ For those about to ChucK, we salute you! - Ge Wang
Let's make noise for peace! - kijjaz |
|
|
Back to top
|
|
 |
rogan

Joined: Dec 16, 2007 Posts: 60 Location: Urbana, IL
Audio files: 4
|
Posted: Mon May 26, 2008 3:35 pm Post subject:
|
 |
|
Hi all,
I've attached some preliminary work on Gardener Reverbs as presented by Hans Mikelson in <<The CSound Book>>. I'm running into the weirdest problem. I can't connect to my object with its "chuck" function (this is a method I borrowed from some of Frostburn's classes); instead, I get a nullpointer error ("NullPointerException: shred[id=1:combtest.ck], PC=[32]"). Can anybody see where I go wrong?
Here is my testing code
| Code: |
SmallRoom1 reverb;
SinOsc sin;
880 => sin.freq;
0.5 => sin.gain;
sin => reverb.chuck => dac;
5::second => now;
|
And here is my Small Room code. Note that this works if it's not a class; it's the connecting that breaks it. I find this weird, because I use almost the exact same "chuck" method in my Allpass class.
| Code: |
public class SmallRoom1
{
//
// All pass filters
//
Allpass ap0;
Allpass ap1;
NestedAllpass nap1;
Allpass ap2;
NestedAllpass nap2;
// 1st
nap1.param(35::ms, 0.15);
ap0.param(22::ms, 0.25);
ap1.param(8.3::ms, 0.3);
nap1.nest(ap0, ap1);
// 2nd
nap2.param(66::ms, 0.08);
ap2.param(30::ms, 0.3);
ap2 => nap2.nest;
// // //
LPF lpf;
6000 => lpf.freq;
HPF bpfL;
800 => bpfL.freq;
LPF bpfH;
2400 => bpfH.freq;
0.5 => bpfH.gain;
Gain out;
0.5 => out.gain;
Gain feedback;
0.5 => feedback.gain;
lpf => nap1.chuck => out;
bpfH => nap1.chuck => nap2.chuck => out;
nap2.out() => feedback => bpfL => bpfH;
public UGen chuck(UGen in){
in => lpf;
return out;
}
}
|
Also, as you may notice, I can't figure out how to use a bandpass filter? How does one specify the width of the bandpass (BPF)?
Thanks!
| Description: |
|
 Download |
| Filename: |
Allpass.ck |
| Filesize: |
922 Bytes |
| Downloaded: |
16 Time(s) |
| Description: |
|
 Download |
| Filename: |
NestedAllpass.ck |
| Filesize: |
575 Bytes |
| Downloaded: |
23 Time(s) |
|
|
|
Back to top
|
|
 |
rogan

Joined: Dec 16, 2007 Posts: 60 Location: Urbana, IL
Audio files: 4
|
Posted: Mon May 26, 2008 3:37 pm Post subject:
|
 |
|
| Inventor, I must be a different sort of monster than the "other" Rogan. :) |
|
|
Back to top
|
|
 |
Inventor

Joined: Oct 13, 2007 Posts: 1700 Location: Florida, USA
Audio files: 67
|
Posted: Mon May 26, 2008 3:47 pm Post subject:
|
 |
|
Hey, as long as you can ChucK you're fine by me! : ) _________________ For those about to ChucK, we salute you! - Ge Wang
Let's make noise for peace! - kijjaz |
|
|
Back to top
|
|
 |
Frostburn

Joined: Dec 12, 2007 Posts: 253 Location: Finland
Audio files: 9
|
|
|
Back to top
|
|
 |
rogan

Joined: Dec 16, 2007 Posts: 60 Location: Urbana, IL
Audio files: 4
|
Posted: Tue May 27, 2008 10:18 am Post subject:
|
 |
|
| Ah, interesting. I hadn't realized that my errors were coming from my NestedAllpass model. Thanks, Frostburn; it's always nice to have an extra pair of eyes. Once I had my stated return values correct, everything was fine. Also, those Allpasses should work the same as the ones I made. |
|
|
Back to top
|
|
 |
|