These four constants identify the calculation rates of inputs in SuperCollider.
calc_ScalarRatecalc_BufRatecalc_FullRatecalc_DemandRateThese helper macros assume that there is a ugen object called unit in the local scope.
IN(index)IN0(index)OUT(index)OUT0(index)INRATE(index)INBUFLENGTH(index)SAMPLERATESAMPLEDURBUFLENGTHBUFRATEBUFDURFULLRATEFULLBUFLENGTHGET_BUFbuf - a pointer to the SndBuf instancebufData - the raw float data from the bufferbufChannels - the number of channels in the bufferbufSamples - the number of samples in the bufferbufFrames - the number of frames in the bufferThe buffer is locked using the LOCK_SNDBUF macro. Buffer lock operations are specific to supernova, and don't do anything in vanilla scsynth.
GET_BUF_SHAREDGET_BUF, but the buffer is locked using LOCK_SNDBUF_SHARED.SIMPLE_GET_BUFGET_BUF, but only creates the buf variable and does not lock the buffer.SIMPLE_GET_BUF_EXCLUSIVESIMPLE_GET_BUF, but locks the buffer with LOCK_SNDBUF.SIMPLE_GET_BUF_SHAREDSIMPLE_GET_BUF, but locks the buffer with LOCK_SNDBUF_SHARED.The following macros are for use in supernova. They still exist in scsynth, but will have no effect.
RGen is a pseudorandom number generator API. Most ugen developers are not interested in seeding their own RGens and would prefer to draw from a global RGen instance supplied by SuperCollider. This can be retrieved with the code:
uint32 RGen::trand()double RGen::drand()float RGen::frand()float RGen::frand0()float RGen::frand2()float RGen::frand8()float RGen::fcoin()float RGen::flinrand()float RGen::fbilinrand()float RGen::fsum3rand()int32 RGen::irand(int32 scale)int32 RGen::irand2(int32 scale)int32 RGen::ilinrand(int32 scale)int32 RGen::ibilinrand(int32 scale)double RGen::linrand()double RGen::bilinrand()double RGen::exprandrng(double lo, double hi)double RGen::exprand(double scale)double RGen::biexprand(double scale)double RGen::exprand(double scale)double RGen::sum3rand(double scale)RGen::fsum3rand.bool sc_isnan(float/double x)x is NaN. This is a legacy function, use std::isnan instead.bool sc_isfinite(float/double x)x is finite. This is a legacy function, use std::isfinite instead.int32 sc_grayCode(int32 x)The following unary functions are available for both float32 and float64, and are the same as in sclang (minus the "sc_" prefixes):
sc_midicpssc_cpsmidisc_midiratiosc_ratiomidisc_octcpssc_cpsoctsc_ampdbsc_dbampsc_cubedsc_sqrtsc_hanwindowsc_welwindowsc_triwindowsc_rectwindowsc_scurvesc_rampsc_signsc_distortsc_softclipsc_ceilsc_floorsc_reciprocalsc_fracsc_log2 (legacy -- use std::log2(std::abs(x)))sc_log10 (legacy -- use std::log10(std::abs(x)))sc_trunc (legacy -- use std::trunc)The following unary functions are available for both float32 and float64, but have no sclang equivalent:
zapgremlins(x)sc_bitriwindow(x)sc_triwindow using absolute value.sc_scurve0(x)sc_scurve, but assumes that x is in the interval [0, 1].sc_distortneg(x)distort for x > 0, and the identity function for x <= 0.taylorsin(x)sin(x) out to x**9 / 9!. (Note lack of sc_ prefix.)sc_lg3interp(x1, a, b, c, d)sc_CalcFeedback(delaytime, decaytime)sc_wrap1(x)x around ±1, wrapping only once.sc_fold1(x)x around ±1, folding only once.sc_wrap(in, lo, hi [, range])sc_fold(in, lo, hi [, range [, range2]])sc_pow(a, b)pow(a, b), retaining the sign of a.sc_powi(x, unsigned int n)x^n, not necessarily retaining the sign of x.sc_hypotx(x, y)abs(x) + abs(y) - (min(abs(x), abs(y)) * (sqrt(2) - 1)), the minimum distance one will have to travel from the origin to (x,y) using only orthogonal and diagonal movements.The following functions are the same as in sclang (minus the "sc_" prefixes):
sc_mod(in, hi) (floats, doubles, ints)sc_round(x, quant) (floats, doubles, ints)sc_roundUp(x, quant) (floats, doubles, ints)sc_trunc(x, quant) (floats, doubles, ints)sc_gcd(a, b) (ints, longs, floats)sc_lcm(a, b) (ints, longs, floats)sc_bitAnd(a, b) (ints)sc_bitOr(a, b) (ints)sc_leftShift(a, b) (ints)sc_rightShift(a, b) (ints)sc_unsignedRightShift(a, b) (ints)sc_thresh(a, b)sc_clip2(a, b)sc_wrap2(a, b)sc_fold2(a, b)sc_excess(a, b)sc_scaleneg(a, b)sc_amclip(a, b)sc_ring1(a, b)sc_ring2(a, b)sc_ring3(a, b)sc_ring4(a, b)sc_difsqr(a, b)sc_sumsqr(a, b)sc_sqrsum(a, b)sc_sqrdif(a, b)sc_atan2(a, b) (legacy -- use std::atan2)The following constants are doubles:
pipi2 = pi/2pi32 = 3pi/2twopi = 2pirtwopi (1/2pi)log001 = log(0.001)log01 = log(0.01)log1 = log(0.1)rlog2 = 1/log(2)sqrt2 = sqrt(2)rsqrt2 = 1/sqrt(2)truncDouble = 3 * 2^51 (used to truncate precision)The following constants are floats:
pi_fpi2_fpi32_ftwopi_fsqrt2_frsqrt2_ftruncFloat = 3 * 2^22 (used to truncate precision)The macros in this section are legacy features. They are seen in many of SuperCollider's built-in ugens, and are intended to provide more efficient alternatives to the standard for (int i = 0; i < inNumSamples; i++) { out[i] = in[i] } loop. These efficiency savings are negligible on modern systems and use of these macros is not recommended, especially since they make debugging difficult.
LOOP(length, stmt)stmt, length times.LOOP1(length, stmt)LOOP, which assumes that length > 0 so a branch instruction is saved.LooP(length) stmtLooP.ZIN(index)IN, but subtracts 1 from the pointer to correct for off-by-one errors when using LOOP and ZXP.ZOUT(index)OUT, but subtracts 1 from the pointer to correct for off-by-one errors when using LOOP and ZXP.ZIN0(index)IN0.ZOUT0(index)OUT0.ZXP(z)z.ZX(z)z.PZ(z)z.ZP(z)ZOFF(rand() + rand() + rand() - 1.5) * 2/3, technically a shifted and stretched order-3 Irwin-Hall distribution.