electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 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
Happy New Year 2008 Patches
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 3 [63 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Goto page: 1, 2, 3 Next
Author Message
kijjaz



Joined: Sep 20, 2004
Posts: 765
Location: bangkok, thailand
Audio files: 4

PostPosted: Thu Jan 03, 2008 9:01 am    Post subject: Happy New Year 2008 Patches
Subject description: Let's chuck to celebrate!
Reply with quote  Mark this post and the followings unread

Let's share some celebration patches.
I've got this singing patch to sing for you for the New Year:

Code:
Step f => LPF f_f => SinOsc s => LPF s_f => TriOsc ws => PRCRev r => dac;

f_f.set(50, .2);
s.gain(.6);
s_f.set(500, .5);
ws.sync(1);
r.mix(.1);
r.gain(.5);
   
int A[200];
for(int i; i < 200; i++) maybe => A[i];
0 => int a;

do
{
    0 => a;
    for(int i; i < 200-1; i++) A[i] ^ A[i+1] * maybe => A[i] +=> a;
    a - 36 => Std.mtof => f.next;
    s.phase(0);
    Math.pow(a, 3)::ms / 4000 => now;
}
while(a > 10);


another modified one with more folkish behavior.

Code:
Step f => LPF f_f => SinOsc s => LPF s_f => TriOsc ws => PRCRev r => dac;

f_f.set(100, .2);
s.gain(.5);
s_f.set(500, .5);
ws.sync(1);
r.mix(.1);
r.gain(.5);
   
int A[20];
for(int i; i < 20; i++) maybe => A[i];
0 => int a;

do
{
    0 => a;
    for(int i; i < 20-1; i++) A[i] ^ A[i+1] * maybe => A[i] +=> a;
    a + 60 => Std.mtof => f.next;
    s.phase(0);
    Math.pow(a, 3)::ms / 2 => now;
}
while(a > 2);
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Frostburn



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

PostPosted: Thu Jan 03, 2008 12:13 pm    Post subject: Reply with quote  Mark this post and the followings unread

This one is a bit long:
The sound of the Lorenz attractor controlled by the mouse:
Linux users may need to allow ChucK to acces hid:
Code:
chmod a+r /dev/input/*


Give your mouse's device number to the code as an argument:
For example:
chuck moused_lorenz.ck:1
Opens mouse 1
Code:

//Mouse controlled Lorenz attractor

500.0 => float time_scale; //Time speeds up by this factor... A mock frequency of sorts for the attractor...
time_scale*samp/second => float delta_t; //Define the time step
0.1 => float mouser_scale; //How much an unit movement of the mouse changes the parameter it's bound to.


//Create three integrating circuits using the Euler's method for solving differential equations.
Impulse dxdt => OnePole x => blackhole;
Impulse dydt => OnePole y => blackhole;
Impulse dzdt => OnePole z => blackhole;
delta_t => x.b0 => y.b0 => z.b0;
-1.0 => x.a1 => y.a1 => z.a1;

//Let's hear something!
x => Gain gl => dac.left;
y => Gain gr => dac.right;
0.01 => gl.gain; //Oh my, we're a bit loud aren't we.
0.01 => gr.gain; //Hush!
//dac => WvOut w => blackhole; "foo.wav" => w.wavFilename; //Write the insanity to a file!

//Time. The attractor is time invariant so this is not used; Provided for experimenting purposes.
0.0 => float t;

//Just start somewhere...
0.5 => float initial_x;
0.1 => float initial_y;
0.2 => float initial_z;

//These are the "default" values that make the Lorenz attractor chaotic (making it a strange attractor)
//The mouse is rigged to modify these:
10.0 => float sigma; //modified by the x-axis
28.0 => float rho; //modified by the y-axis
8.0/3.0 => float beta; //modified by the mouse-wheel y-axis


50.0 => float limit; //Contain the attractor in a box to keep it stable.

initial_x/delta_t => dxdt.next;
initial_y/delta_t => dydt.next;
initial_z/delta_t => dzdt.next;
samp => now;

true => int we_are_on;

0 => int mouser_device;
if( me.args() ) me.arg(0) => Std.atoi => mouser_device;
spork~mouser(mouser_device); //Wave the mouse around for sounds!

while(we_are_on){
   
    //Lorenz attractor definition:
    sigma * ( y.last() - x.last() ) => dxdt.next;
    x.last() * ( rho - z.last() ) - y.last() => dydt.next;
    x.last() * y.last() - beta * z.last() => dzdt.next;
   
    //Don't overflow:
    if ( Std.fabs(x.last()) > limit ) -x.last() => dxdt.next;
    if ( Std.fabs(y.last()) > limit ) -y.last() => dydt.next;
    if ( Std.fabs(z.last()) > limit ) -z.last() => dzdt.next;
   
    delta_t +=> t; //Not used for anything at the moment.
    samp => now;
}
//w.closeFile();

fun void mouser(int device){
    //Modified from /examples/hid/mouse.ck
    // make HidIn and HidMsg
    Hid hi;
    HidMsg msg;
   
    // which mouse
    //0 => int device;
    // get from command line
    //if( me.args() ) me.arg(0) => Std.atoi => device;

    // open mouse 0, exit on fail
    if( !hi.openMouse( device ) ) me.exit();
    <<< "mouse '" + hi.name() + "' ready", "" >>>;

    // infinite event loop
    while( true )
    {
        // wait on HidIn as event
        hi => now;

        // messages received
        while( hi.recv( msg ) )
        {
            // mouse motion
            if( msg.isMouseMotion() )
            {
                if( msg.deltaX )
                {
                    //<<< "mouse motion:", msg.deltaX, "on x-axis" >>>;
                    mouser_scale*msg.deltaX +=> sigma;
                }
               
                if( msg.deltaY )
                {
                    //<<< "mouse motion:", msg.deltaY, "on y-axis" >>>;
                    mouser_scale*msg.deltaY +=> rho;
                }
            }
           
            // mouse button down
            else if( msg.isButtonDown() )
            {
                //<<< "mouse button", msg.which, "down" >>>;
                //If it gets stuck just click on the mouse
                Std.rand2f(-10.0,10.0)/delta_t => dxdt.next;
                Std.rand2f(-10.0,10.0)/delta_t => dydt.next;
                Std.rand2f(-10.0,10.0)/delta_t => dzdt.next;
                samp => now;
               
                if(msg.which == 1) false => we_are_on; //The right mouse-button turns things off
            }
           
            // mouse button up
            /*else if( msg.isButtonUp() )
            {
                <<< "mouse button", msg.which, "up" >>>;
            }*/
           
            // mouse wheel motion
            else if( msg.isWheelMotion() )
            {
                /*if( msg.deltaX )
                {
                    //<<< "mouse wheel:", msg.deltaX, "on x-axis" >>>;
                }*/
               
                if( msg.deltaY )
                {
                    //<<< "mouse wheel:", msg.deltaY, "on y-axis" >>>;
                    mouser_scale*msg.deltaY +=> beta;
                }
            }
        }
    }
}



moused_lorenz.ck
 Description:
The sound of the Lorenz attractor

Download
 Filename:  moused_lorenz.ck
 Filesize:  4.43 KB
 Downloaded:  391 Time(s)

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



Joined: Jan 18, 2005
Posts: 4145
Location: Sweden
Audio files: 371
G2 patch files: 100

PostPosted: Thu Jan 03, 2008 3:41 pm    Post subject: Reply with quote  Mark this post and the followings unread

Some pathetic fireworks in the distance. Smile

Code:
Noise noize;
dac;

10 => int VOICE_AMOUNT;

BPF hpfs[VOICE_AMOUNT];
Envelope highEnvelopes[VOICE_AMOUNT];
Pan2 highPans[VOICE_AMOUNT];

for (0 => int i; i < 10; i++) {
   0.002 => highEnvelopes[i].time;
   0 => highEnvelopes[i].value;
   0.2 => hpfs[i].gain;
   noize => hpfs[i] => highEnvelopes[i] => highPans[i] => dac;
}

fun void moveHPFFreqs() {
   while (true) {
      for (0 => int i; i < VOICE_AMOUNT; i++) {
         hpfs[i].freq() + Math.randf()*0.001 => float freq;
         freq => hpfs[i].freq;
      }
      1::ms => now;
   }
}

spork ~ moveHPFFreqs();

0 => int nextHighVoice;

Event sprinkleEvent;

fun void sprinkle() {
   while (true) {
      sprinkleEvent => now;
      for (0.4 => float volume; volume < pi / 2.0; 0.02 +=> volume) {
         1.0 => highEnvelopes[nextHighVoice].value;
         0.0 => highEnvelopes[nextHighVoice].target;
         Math.randf() => highPans[nextHighVoice].pan;
         hpfs[nextHighVoice].set(3000.0 +Math.randf()*1000.0 + Math.sin(volume)*1000, 6 + Math.randf()*4);
         if (++nextHighVoice >= VOICE_AMOUNT) {
            0 => nextHighVoice;
         }
         
         35::ms + Math.randf()*17::ms => now;
      }
   }
}

spork ~ sprinkle();

LPF lpfs[VOICE_AMOUNT];
Envelope lowEnvelopes[VOICE_AMOUNT];
Pan2 lowPans[VOICE_AMOUNT];

for (0 => int i; i < 10; i++) {
   0.05 => lowEnvelopes[i].time;
   0 => lowEnvelopes[i].value;
   noize => lpfs[i] => lowEnvelopes[i] => lowPans[i] => dac;
}

0 => int nextLowVoice;

while (true) {
   if (Math.randf() > 0.9) {
      1.0 => lowEnvelopes[nextLowVoice].value;
      0.0 => lowEnvelopes[nextLowVoice].target;
      Math.randf() => lowPans[nextLowVoice].pan;
      lpfs[nextLowVoice].set(100.0 +Math.randf()*90.0, 6 + Math.randf()*4);
      if (++nextLowVoice >= VOICE_AMOUNT) {
         0 => nextLowVoice;
      }
   }
   if (Math.randf() > 0.998) {
      sprinkleEvent.signal();
   }
   10::ms => now;
}


Edit: Disabled HTML to fix broken code.

_________________
Antimon's Window
@soundcloud @Flattr home - you can't explain music

Last edited by Antimon on Fri Jan 04, 2008 7:01 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
Frostburn



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

PostPosted: Fri Jan 04, 2008 3:52 am    Post subject: Reply with quote  Mark this post and the followings unread

Antimon wrote:
Some pathetic fireworks in the distance. :)

Code:
Noise noize;
dac;

10 => int VOICE_AMOUNT;

BPF hpfs[VOICE_AMOUNT];
Envelope highEnvelopes[VOICE_AMOUNT];
Pan2 highPans[VOICE_AMOUNT];

for (0 => int i; i <10> highEnvelopes[i].time;
   0 => highEnvelopes[i].value;
   0.2 => hpfs[i].gain;
   noize => hpfs[i] => highEnvelopes[i] => highPans[i] => dac;
}

...


Can't get it to work... even that first 'for' statement seems to be missing a right parenthesis.
It's good practice to preview the post once and copy the code back to ChucK to see if it renders properly.

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



Joined: Jan 18, 2005
Posts: 4145
Location: Sweden
Audio files: 371
G2 patch files: 100

PostPosted: Fri Jan 04, 2008 7:03 am    Post subject: Reply with quote  Mark this post and the followings unread

Frostburn wrote:

Can't get it to work... even that first 'for' statement seems to be missing a right parenthesis.
It's good practice to preview the post once and copy the code back to ChucK to see if it renders properly.


Thanks for the good practice tip. Embarassed I had forgotten to disable HTML. Sorry about that.

/Stefan

_________________
Antimon's Window
@soundcloud @Flattr home - you can't explain music
Back to top
View user's profile Send private message Visit poster's website
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 6221
Location: near Austin, Tx, USA
Audio files: 267

PostPosted: Wed Jan 16, 2008 10:35 pm    Post subject: Reply with quote  Mark this post and the followings unread

What a cool effect, experiencing science through audio. Nicely done, Frostburn, and nice image too. I suggest adding to the Lorentz attractor so that it attracts blondes and brunettes also. Preferably ones with either straight or wavy hair. When you get that one working you will earn an honorable place among ChucKists indeed.

Inventor
who misses his ChucK buddies alot!
Back to top
View user's profile Send private message Send e-mail
Frostburn



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

PostPosted: Thu Jan 17, 2008 10:47 am    Post subject: Reply with quote  Mark this post and the followings unread

Inventor wrote:
What a cool effect, experiencing science through audio. Nicely done, Frostburn, and nice image too. I suggest adding to the Lorentz attractor so that it attracts blondes and brunettes also. Preferably ones with either straight or wavy hair. When you get that one working you will earn an honorable place among ChucKists indeed.

Thanks, your image is a nice one too. Smile
Is it a photo or a ray-trace rendering?

The Lorentz attractor needs no additions. In low frequencies it attracts brown noise (brunettes) and when pitched beyond reason it attracts white noise (blondes). Too bad they don't have hair, be it straight or all wavely.

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


Joined: Oct 13, 2007
Posts: 6221
Location: near Austin, Tx, USA
Audio files: 267

PostPosted: Thu Jan 17, 2008 11:10 am    Post subject: Reply with quote  Mark this post and the followings unread

Thanks for asking, Frostburn, my image is a close-up photo of a chainmaille sphere. I created the math that says how many rings per row to make a nearly perfect sphere, so I'm proud of my little creation. It was sort of math meets art and coexists for a change, lol.
Back to top
View user's profile Send private message Send e-mail
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Thu Jan 17, 2008 12:42 pm    Post subject: Reply with quote  Mark this post and the followings unread

What? Math & art are fine together! :¬).

Serious mathematicians strive for beauty in proofs and where would painting be without perspective? I don't think there is the slightest issue between them. Without going into fields where it's obvious like our own or architecture to me it's quite clear that all art depends on ratios, the artist may not consciously be treating those like fractions but that doesn't mean there's no math there. Without creativity, on the other hand, you can forget about solving complex issues and without a sense of style you will likely drown in their solution, lot of art in math, I say.

We could do a theme project about the mathematics of beauty and the beauty of equations!

I like the image too, BTW ;¬)

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frostburn



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

PostPosted: Thu Jan 17, 2008 2:43 pm    Post subject: Reply with quote  Mark this post and the followings unread

The official sporks person wrote:
We could do a theme project about the mathematics of beauty and the beauty of equations!

Nice idea Kassen! Count me in.

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


Joined: Oct 13, 2007
Posts: 6221
Location: near Austin, Tx, USA
Audio files: 267

PostPosted: Thu Jan 17, 2008 6:00 pm    Post subject: Reply with quote  Mark this post and the followings unread

Frostburn wrote:
The official sporks person wrote:
We could do a theme project about the mathematics of beauty and the beauty of equations!

Nice idea Kassen! Count me in.


I'll go for that also.
Back to top
View user's profile Send private message Send e-mail
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 6221
Location: near Austin, Tx, USA
Audio files: 267

PostPosted: Thu Jan 17, 2008 10:47 pm    Post subject: Reply with quote  Mark this post and the followings unread

Here, I have made the first contribution to our math meets art effort. I propose we make a song with the sounds of mathematics in it. In the spirit of songs like "Girls, Girls, Girls" by Motley Crue, I suggest we begin the song with the sound of a revving engine. It is thematic because the musical instrument patches mathematically model the system, and make it sound close to the real thing so the model is a good one. It's math making music with a rock-and-roll flair to it. Should make a nice song intro.

If you agree that we shall make a song, then what do you suppose your contribution will be?


rev_engine_intro.ck
 Description:
Revs a throaty musclecar V8 from 0 to max along a sinusoidal profile of rpm. Makes a great song introduction.

Download
 Filename:  rev_engine_intro.ck
 Filesize:  520 Bytes
 Downloaded:  260 Time(s)

Back to top
View user's profile Send private message Send e-mail
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 6221
Location: near Austin, Tx, USA
Audio files: 267

PostPosted: Fri Jan 18, 2008 3:12 am    Post subject: Reply with quote  Mark this post and the followings unread

Hmm, I'm having trouble getting it to record. It makes a screeching sound in the wav file for some reason. Not sure what the problem is, sigh. Also I'm not too pleased with the revving sequence, it should have multiple revs of different final amplitudes, and should not decay after the peak of each rev sequence. I'll fix that later after I get your thoughts on it.
Back to top
View user's profile Send private message Send e-mail
Frostburn



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

PostPosted: Sat Jan 19, 2008 9:32 am    Post subject: Reply with quote  Mark this post and the followings unread

For the beauty of math I'll look into quarternions. I always though they were beautiful. Time to see if they also produce beautiful sounds.
I just hope I don't fry my CPU with too many complex differential equations all dancing the Runge-Kutta.

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


Joined: Oct 13, 2007
Posts: 6221
Location: near Austin, Tx, USA
Audio files: 267

PostPosted: Sat Jan 19, 2008 1:24 pm    Post subject: Reply with quote  Mark this post and the followings unread

Whoa, what a wicked Wiki page, those quarternions are hard to understand! Maybe they'll make nice music though.
Back to top
View user's profile Send private message Send e-mail
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Sat Jan 19, 2008 3:06 pm    Post subject: Reply with quote  Mark this post and the followings unread

Inventor wrote:

If you agree that we shall make a song, then what do you suppose your contribution will be?


I like the idea of making a song together but I have to think about what I'd contribute.... I was thinking about doing something with sonifying a sorting algorithm to morph noise to a saw but that will be heavy on the CPU so that's not such a social thing to do if we'll all share one song so one CPU.

I'd like to do something with DSP and sound though as I've been doing so much in ChucK with sequencing and samples that it would be nice to do something very different for a change.

Is there anyone who'd like to link math to music on a compositional level and keep the central overview over our song/project?

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 6221
Location: near Austin, Tx, USA
Audio files: 267

PostPosted: Sat Jan 19, 2008 3:33 pm    Post subject: Reply with quote  Mark this post and the followings unread

Well, i am not really the type to organize the efforts of a group, but perhaps I could do some of the job for us. I presume that in our song we will have some "mix" of the three (or more) tracks. Perhaps I could write the framework for doing that, i.e. the sequencer. But I don't really have any experience in sporking, functions, or well, in doing that at all. So IF i can do that I'll need some thoughts from you guys on HOW to do that. All I can say is I might give it a try.

Perhaps as well I could do some creative composition in terms of actually deciding what way to combine our sounds together. Should it tell a story? Will there be lyrics? Perhaps it could be an adventure, where some main character discovers math by listening to it somehow. Something like "Oblio and Arrow", I'm thinking. Or that could be another random thought that doesn't matter. I do have Audacity so I can record voice. Can't sing, so it would have to be a story narrative, but they say my voice is relaxing, or "hypnotizing" to hear.
Back to top
View user's profile Send private message Send e-mail
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 6221
Location: near Austin, Tx, USA
Audio files: 267

PostPosted: Sat Jan 19, 2008 5:06 pm    Post subject: Reply with quote  Mark this post and the followings unread

How about a video for our project? I was thinking about maybe plotting the functions that we are listening to as we listen to them. I'm a very visual person, and math is often conveyed to us in visual form as function plots and such, so if we are portraying the beauty of math, then wouldn't it make sense to do so visually as well?

Now, that something I could contribute, because i have POV-Ray skills and all that. Hmm on a compositional level we now have motor sounds, quartnion-thingie sounds, and whatever I misunderstood Kassen describing. Perhaps we also want something simple like a sinusoid. Enter perhaps the Chakra tones, so pleasing to hear, that are just sinusoids at specific frequencies for throat, heart, etc. I think they go about 350 Hz or so.

One possible theme is "Oblio goes to college" in which we have our familiar character Oblio from the land of Point go to college and as he enters various classes or professor's offices in the math department, he hears the song of that encounter and we see its video. Just thinking out loud. Thoughts?
Back to top
View user's profile Send private message Send e-mail
Frostburn



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

PostPosted: Sun Jan 20, 2008 1:49 am    Post subject: Reply with quote  Mark this post and the followings unread

I'm not a great organisator either and a joint production like this needs at least a common sequencing syntax. I'd like to go a bit experimental with everything so it propably won't be possible but let's work on our ideas, post them here and see if it's possible to work with them togerther.

On the CPU side of things quarternion differentials are way too heavy for realtime performance. If I stick with them, we can forget light-weight songs. But on the sine-wave side of things they're on the meat.
For example if we look at the equation dz/dt = i*z we get z = exp(i*t) which is known to be cos(t)+i*sin(t).

Another thing that I've looked in to lately is self modulating sine waves and different networks of them. I've managed to produce all kinds of sounds from horns to woodwinds and soft ethtearal pads. The only problem is that they're usually very much out of tune because the self modulation process changes the oscillation frequency in an unpredictable manner for complex networks. The good thing though is that they're very light computationally and can be done in plain chuck code.

I was also thinking of composing in ratios instead of absolute notes. So that there would be a main frequency and all the other voices would be small ratios of it in the form of p/q where p and q are integers. Also the changes of the main freq would be ratios. This would propably disturb people who are used to absolute pitch and sound generally wierd. I'll see if it's anything good.

On a final note I'd like to ask how you view mathematics.
For me she is an abstract world of her own and her beaty is reflected on the simple and yet deep identities and symmetries like the famous Euler's identity exp(i*pi)+1 == 0

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



Joined: Sep 20, 2004
Posts: 765
Location: bangkok, thailand
Audio files: 4

PostPosted: Sun Jan 20, 2008 1:56 am    Post subject: Reply with quote  Mark this post and the followings unread

Hmm i'll let the algorithmic composition ideas to all you guys.
i'll design some mathematical sounding instruments for you to test.

yes i love self-modulating oscillators very much -_-"
I'll work out some new ones from the idea.
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Frostburn



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

PostPosted: Sun Jan 20, 2008 4:22 am    Post subject: Reply with quote  Mark this post and the followings unread

Here's a quick demonstration of the simplest self modulating SinOsc playing a ratio based melody to get some feel of that too.


sm_sin_demo.ck
 Description:
A cute little melody going in 3/4.

Download
 Filename:  sm_sin_demo.ck
 Filesize:  7.42 KB
 Downloaded:  191 Time(s)


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



Joined: Sep 20, 2004
Posts: 765
Location: bangkok, thailand
Audio files: 4

PostPosted: Sun Jan 20, 2008 12:10 pm    Post subject: Reply with quote  Mark this post and the followings unread

Oh yes.. that's one with a very nice sound.. (kinda like a wood trumpet I imagine hahah)
today I come back to play more with Self-FMing sine oscillator
I imagined that using negative feedback and delay
might help shaping the sound especially to keep it in tune while chaotically vibrating at the same time.

so here's the test sound.
it sounds quite acoustic
(or can be like distortion-guitar feedback)

Code:
// by kijjaz (kijjasak triyanond - kijjaz@yahoo.com)
// feel free to use, modify, and redistribute with credits of all contributors

// change these values to hear out some behaviors
440.0 => float MainFreq;
4.0 => float DelayMultiples;
-0.9 => float DelayFeedback;
120.0 => float RandomRange;
// note: after playing around sometimes, i notice that using negative DelayFeedback
// helps make the pitch more in-tune

// main SinOsc (s1)
// the output passes through a delay (d1) with feedback (d1_fb)
// the delay is then fed through a gain (d1_g)
// which will be used to FM s1

// lastly, s1 is added with reverb and then output to soundcard

SinOsc s1 => DelayA d1 => Gain d1_fb => d1 => Gain d1_g => s1 => NRev reverb => dac;
s1.sync(2);
d1.max(second);
d1.delay(second / MainFreq * DelayMultiples);
d1_fb.gain(DelayFeedback); // use negative feedback
d1_fb.op(3); // prepare for modulation for future extension
d1_g.op(3); // prepare for modulation for future extension

reverb.mix(.02);
reverb.gain(.5);

s1.freq(MainFreq);

// test drive
while(true)
{
    Std.rand2f(0, RandomRange) => d1_g.gain;
    800::ms => now;
}


Embarassed thanks.. i hope this kind of sound, maybe still quite simple,
can be of any use to the collaboration.

update:

this one has note attack envelope
it can shape more kinds of percussive sounds.

Code:
// by kijjaz (kijjasak triyanond - kijjaz@yahoo.com)
// feel free to use, modify, and redistribute with credits of all contributors

// change these values to hear out some behaviors
440.0 => float MainFreq;
9.0/8.0 => float DelayMultiples;
-0.99 => float DelayFeedback;
440.0 => float RandomRange;
// note: after playing around sometimes, i notice that using negative DelayFeedback
// helps make the pitch more in-tune
4000.0 => float NoteDecayTime;

// main SinOsc (s1)
// the output passes through a delay (d1) with feedback (d1_fb)
// the delay is then fed through a gain (d1_g)
// which will be used to FM s1

// lastly, s1 is added with reverb and then output to soundcard

SinOsc s1 => DelayA d1 => Gain d1_fb => d1 => Gain d1_g => s1 => NRev reverb => dac;

s1.sync(2);
d1.max(second);
d1.delay(second / MainFreq * DelayMultiples);
d1_fb.gain(DelayFeedback); // use negative feedback
d1_fb.op(3); // prepare for modulation for future extension
d1_g.op(3); // prepare for modulation for future extension

reverb.mix(.02);
reverb.gain(.5);

// note envelope: this value modulate feedback amplitude that's fed into s1
Impulse i2 => Gain g2 => Gain g2_fb => g2 => d1_g;
g2_fb.gain(1.0 - 1.0 / NoteDecayTime);

s1.freq(MainFreq);

// test drive
while(true)
{
    Std.rand2f(0, RandomRange) => d1_g.gain;
    i2.next(1.0);
    250::ms => now;
}
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Frostburn



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

PostPosted: Sun Jan 20, 2008 2:35 pm    Post subject: Reply with quote  Mark this post and the followings unread

After playing around with rational frequencies I quickly found out that frequencies that are related by a ratio with a prime number bigger than five in the numerator or in the denominator sound discordant.
What we are left with is the limit 5 tuning. There all the frequencies are related by hamming number ratios.
I then thought that if hamming numbers sound good we need lot's of them! => Additive synthesis with hamming number harmonics. 8)


hamming_number_harmonics.ck
 Description:
Plays an additive synth patch of hamming number harmonics at 220.0 Hz

Download
 Filename:  hamming_number_harmonics.ck
 Filesize:  2.86 KB
 Downloaded:  173 Time(s)


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


Joined: Apr 03, 2004
Posts: 24079
Location: The Netherlands, Enschede
Audio files: 278
G2 patch files: 320

PostPosted: Sun Jan 20, 2008 3:04 pm    Post subject: Reply with quote  Mark this post and the followings unread

Frostburn wrote:
What we are left with is the limit 5 tuning. There all the frequencies are related by hamming number ratios.


Thanks for that link, the relation with Hamming numbers was new to me Very Happy

_________________
Jan
also .. could someone please turn down the thermostat a bit.
Posted Image, might have been reduced in size. Click Image to view fullscreen.
Back to top
View user's profile Send private message Visit poster's website
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Sun Jan 20, 2008 4:20 pm    Post subject: Reply with quote  Mark this post and the followings unread

kijjaz wrote:
(kinda like a wood trumpet I imagine hahah)


trivia;
Strictly speaking the Didgerido is a "wood trumpet". Really.

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 3 [63 Posts]
View unread posts
View new posts in the last week
Goto page: 1, 2, 3 Next
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


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use