electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links  |  Store
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 
Live streaming at radio.electro-music.com

  host / artist show at your time
  EdisonRex Edison's Electronic Review
Please visit the chat
 Forum index » DIY Hardware and Software » ChucK programming language
Chuck for Dummies
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [3 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
Khepri



Joined: Jul 20, 2009
Posts: 20
Location: Canada

PostPosted: Tue Aug 14, 2012 3:22 pm    Post subject: Chuck for Dummies
Subject description: Attack Rate
Reply with quote  Mark this post and the followings unread

I'm thinking of starting a "Chuck for Dummies" writing project for myself. Who knows - it might eventually develop into a fairly comprehensive basic-level reference for those in need of this kind of "for Dummies" thing.

So . . . here's a "for Dummies" kind of question: What exactly does an Envelope's "rate" parameter do? Is it a curve? Some exponential thing? (Non-math Dummy here.) If, for example, you can decide an ADSR's decay period, why do you need a "rate" of change when you've already specified the duration of that change?

Thanks

_________________
Don't fear mistakes. There are none.
- Miles Davis
Back to top
View user's profile Send private message
Antimon



Joined: Jan 18, 2005
Posts: 3730
Location: Sweden
Audio files: 275
G2 patch files: 96

PostPosted: Wed Aug 15, 2012 1:40 pm    Post subject: Reply with quote  Mark this post and the followings unread

With ChucK, I can recommend experimenting with some code when wondering about stuff like this, since it's so easy and you learn stuff while doing. :)

Anyway, this one is kind of interesting. Envelope provides a single linear slope, and the rate, time and duration settings on it are interchangeable. Setting one affects the other two.

I sat down and fiddled a bit and came up with this code:

Code:
Envelope e => blackhole;
Envelope e2 => blackhole;
SinOsc o => dac;
SinOsc o2 => dac;

0.3 => o.gain;
0.3 => o2.gain;

200 => e.value;
400 => e.target;
1::second => e.duration;

300 => e2.value;
500 => e2.target;
1.0/220.5 => e2.rate;

<<< "e time", e.time(), e.rate(), (1.0/e.rate()) >>>;
<<< "e2 time", e2.time(), e2.rate() >>>;

while (true) {
        e.value() => o.freq;
        e2.value() => o2.freq;
        1::ms => now;
}


It ramps up the frequency of two oscillators (the while loop at the end is for copying values from the envelopes to the oscillators), one of them is set using duration() and the other using rate(). They both take one second to complete.

The value 1/220.5 seems connected to the sample frequency, which is 44100 kHz here. If this is consistent then rate means units per 200 samples (if my brain got this right). It looks esoteric enough though that I wouldn't trust it really. I'd recommend using time() or duration() and just calculating the time you want.

Anyway I think all the envelope slopes are linear. If you want exponential/logarithmic stuff you'll have to roll your own, maybe using a loop like I did here or something.

If that didn't help at all give a shout and I'll try to be more coherent. :)

Edit: wrote time(), I meant duration()

_________________
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
Khepri



Joined: Jul 20, 2009
Posts: 20
Location: Canada

PostPosted: Wed Aug 15, 2012 6:04 pm    Post subject: Reply with quote  Mark this post and the followings unread

Thanks very much, Antimon! I appreciate the example code. I should be able to take a good look at it tomorrow. I'm inexperienced enough with both C syntax and ChucK that I sometimes don't even see a way to test things out. But you are right -- it is quite an easy system to test things on, generally. I was doing that with ADSR today, and will try adding some envelopes to the same tune tomorrow.

Khepri

_________________
Don't fear mistakes. There are none.
- Miles Davis
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 [3 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
e-m mkii

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 through 2009 by electro-music.com - Conditions Of Use