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
ChucK exploration
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [1 Post]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
Marotte



Joined: Dec 03, 2007
Posts: 2
Location: Tibet

PostPosted: Mon Dec 10, 2007 1:52 pm    Post subject: ChucK exploration Reply with quote  Mark this post and the followings unread

Hi,

So I post my second chuck piece, I made a silly FM synth :

Code:

second / samp => float samplerate;
<<< "Samplerate :",samplerate >>>;
145. => float tempo;
minute / tempo => dur beat;
4 * beat => dur tick;

class MathFX
 {
   Dyno limiter; limiter.limit();
   SinOsc o; o.gain (0);
   120. => o.freq;
   o => limiter => dac;

    fun void play ()
       {
          <<< "Fun play () started" >>>;
          o.freq () => float initialfreq;
          // KEY ON ...
          while (o.gain() < .999)
            {
                o.gain () + .001 => o.gain; // Find how to make an exponential attack, linear for now.
                samp => now;
                <<< o.gain () >>>;
             }
         
          // Do something...
             
                .0 => float x;
                Math.rand2f (.25,12) => float len;
                while (x < len)
                  { 
                     .0072 + x + (Math.rand2f(.001,.01)*x)=> x;
                     <<< x,o.freq (),o.gain () >>>;
                     40 + Math.rand2(18,36) * Math.exp(Math.exp(Math.sin(3*x))-Math.sqrt(x/16)) => o.freq;
                     6::ms + .04*x::ms => now;                 
                  }

          //////
          // KEY OFF...
          while (o.gain() > 0.01)
            {
                o.gain () - (Math.exp(.007*o.gain())-1) => o.gain;
                samp => now;
                <<< o.gain () >>>;
             }
                   
 
          initialfreq => o.freq;
          <<< "Fun play () finished" >>>;
       }
 }


MathFX fx1;

while (1)
{
fx1.play();

while (now % beat > samp) samp => now; // Wait next beat :)


}


I find very interesting in chuck that you can modulate anything just anyway you want Smile Adding randomness for fun this is useful I think.

I did not use ADSR this time because I discovered something anoying with them : Let's say you have SinOsc o => ADSR env => dac;

If you "env.keyOn();" then modulate o frequency, when you "env.keyOff ()", o frequency automatically return to the initial freq to do the release Sad

In addition, the poor attack stuff I made is totally dumb,because freq modulation only start then attack is finished, the constant initial osc freq is used during attack...

Cheer's

Stef
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 [1 Post]
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


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