[chuck-users] adsr
eduard aylon
eduard.aylon at gmail.com
Sun Sep 10 10:37:22 EDT 2006
Hi all,
I am testing how ADSR UGen works and I am still not sure what do
parameters to (time)members (attackTime, decayTime, etc) mean. Are
they automatically casted to seconds?
For instance:
ADSR env;
env.attackTime( .1 );
Does this mean that attackTime is 100::ms?
I have tried to understand how ADSR works with the following patch:
sinosc s => ADSR env => dac;
env.attackTime( .01 );
env.releaseTime( 1 );
env.decayTime( 0 );
1=>env.keyOn;
<<< "begin note_on", env.state(), now/ms>>>;
while( !env.state() )
{
1::samp=>now;
if( env.state() )
<<< "end_of_attack", env.state(), now/ms>>>;
}
1=>env.keyOff;
<<< "begin note_off", env.state(), now/ms>>>;
while( env.state() == 1 )
{
1::samp=>now;
}
<<< "end_of_decay", env.state(), now/ms>>>;
while( env.state() == 2 )
{
1::samp=>now;
}
<<< "end_of_sustain", env.state(), now/ms>>>;
while( env.state() == 3 )
{
1::samp=>now;
}
<<< "end_of_release", env.state(), now/ms>>>;
while( env.state() != 4 )
{
1::samp=>now;
}
<<< "done.", env.state(), now/ms>>>;
which ouput is the following:
begin note_on 0 0.000000
end_of_attack 1 10.000000
begin note_off 3 10.000000
end_of_decay 3 10.000000
end_of_sustain 3 10.000000
end_of_release 4 2010.000000
done. 4 2010.000000
This would bean that attack lasts for 10::ms as env.attackTime() was
set to .01. But then I don't understand why release ends at 2010::ms
as releaseTime() is set to 1.
Note that decayTime is set to zero and there is no sustain, as you
can see from the output.
Can anybody give me a hand on how to interpret the parameters to ADSR
members?
Thanks,
eduard
More information about the chuck-users
mailing list