electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Links  |  Store
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks GalleryGallery 
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
 Forum index » DIY Hardware and Software » ChucK programming language
Language Problem
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [9 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
rogan



Joined: Dec 16, 2007
Posts: 60
Location: Urbana, IL
Audio files: 4

PostPosted: Sun May 25, 2008 10:34 pm    Post subject: Language Problem
Subject description: Rogan needs help getting syntax right.
Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message
Frostburn



Joined: Dec 12, 2007
Posts: 253
Location: Finland
Audio files: 9

PostPosted: Mon May 26, 2008 10:31 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message
rogan



Joined: Dec 16, 2007
Posts: 60
Location: Urbana, IL
Audio files: 4

PostPosted: Mon May 26, 2008 10:51 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message
Inventor



Joined: Oct 13, 2007
Posts: 1700
Location: Florida, USA
Audio files: 67

PostPosted: Mon May 26, 2008 1:58 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website
rogan



Joined: Dec 16, 2007
Posts: 60
Location: Urbana, IL
Audio files: 4

PostPosted: Mon May 26, 2008 3:35 pm    Post subject: Reply with quote  Mark this post and the followings unread

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!


Allpass.ck
 Description:
Allpass filter

Download
 Filename:  Allpass.ck
 Filesize:  922 Bytes
 Downloaded:  16 Time(s)


NestedAllpass.ck
 Description:
Nestable Allpass

Download
 Filename:  NestedAllpass.ck
 Filesize:  575 Bytes
 Downloaded:  23 Time(s)

Back to top
View user's profile Send private message
rogan



Joined: Dec 16, 2007
Posts: 60
Location: Urbana, IL
Audio files: 4

PostPosted: Mon May 26, 2008 3:37 pm    Post subject: Reply with quote  Mark this post and the followings unread

Inventor, I must be a different sort of monster than the "other" Rogan. :)
Back to top
View user's profile Send private message
Inventor



Joined: Oct 13, 2007
Posts: 1700
Location: Florida, USA
Audio files: 67

PostPosted: Mon May 26, 2008 3:47 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website
Frostburn



Joined: Dec 12, 2007
Posts: 253
Location: Finland
Audio files: 9

PostPosted: Tue May 27, 2008 1:02 am    Post subject: Reply with quote  Mark this post and the followings unread

Nice to see someone doing class based UnitGens. Keep at it rogan. :)
Your syntax is a bit off... You are defining functions that crash ChucK by not returning what they are supposed to.
I started from scratch and made new allpass classes.

My knowledge of allpass filters and reverbs comes from around here. But I didn't read it too carefully so there might be some glaring errors in my implementation.

Attached is my take on the nested allpass design.


allpassexample.ck
 Description:
Nested allpass implementation with UnitGen classes.

Download
 Filename:  allpassexample.ck
 Filesize:  4.13 KB
 Downloaded:  25 Time(s)


_________________
To boldly go where no man has bothered to go before.
Back to top
View user's profile Send private message
rogan



Joined: Dec 16, 2007
Posts: 60
Location: Urbana, IL
Audio files: 4

PostPosted: Tue May 27, 2008 10:18 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [9 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » ChucK programming language
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum
Once You Know, You Newegg

Please support our site. If you click through and buy from
our affiliate partners, we earn a small commission.


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003, 2004, 2005, 2006 and 2007 by electro-music.com