ChucK Standard Libraries API
these libraries are provide by default with ChucK - new ones can also
be imported with ChucK dynamic linking (soon to be documented...). The
existing libraries are organized by namespaces in ChucK. They are as
follows.
namespace: Std
Std is a standard library in ChucK, which includes utility functions random number generation,
unit conversions, and absolute value.
[example]
// infinite time-loop
while( true )
{
// generate random float (and print)
<<< Std.rand2f( 100.0, 1000.0 ) >>>;
// wait a bit
50::ms => now;
}
[function]:
int rand ( ); // soon-to-be-deprecated; use Math.random()
[function]:
int rand2 ( int min, int max ); // soon-to-be-deprecated; use Math.random2()
[function]:
float randf ( ); // soon-to-be-deprecated; use Math.randomf()
[function]:
float rand2f ( float min, float max ); // soon-to-be-deprecated; use
Math.random2f()
[function]:
int setenv ( string key, string value );
namespace: Machine
Machine is ChucK runtime interface to the virtual machine. this interface can
be used to manage shreds. They are similar to the On-the-fly Programming Commands,
except these are invoked from within a ChucK program, and are subject to the timing mechanism.
----------
namespace: Math
Math contains the standard math functions, including all trignometric functions expects angles
to be in radians, as well as random number generators.
[example]
// print sine of pi/2
<<<< Math.sin( Math.PI / 2.0 ) >>>;
[example 2]
// infinite time-loop
while( true )
{
// generate random float (and print)
<<< Math.random2f( 100.0, 1000.0 ) >>>;
// wait a bit
50::ms => now;
}
[function]:
float random2f ( float min, float max );
Next: Chuck Standard Unit Generators
Return to Programming Guide
|