void *meter_oksize(t_meter *x, t_rect *newrect) { TTLimit(newrect->width, kWidthMinimum, kWidthMaximum); TTLimit(newrect->height, kHeightMinimum, kHeightMaximum); meterCacheSurface(x); // Now draw the gradient and cache it in our surface return (void*)1; }
TTErr GaussWindow::calculateValue(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt data) { TTFloat64 superscript = -0.5 * pow( ( (2. * x) - 1. ) / mSigma, 2 ); y = exp(superscript); TTLimit(y, 0.0, 1.0 ); // just in case return kTTErrNone; }
TTErr TTBalance::setFrequency(const TTValue& newValue) { mFrequency = (double)newValue; TTLimit(mFrequency, 1., (sr*0.45)); c = 1 / ( tan( kTTPi*(mFrequency/sr) ) ); a0 = 1 / (1 + kTTSqrt2*c + c*c); a1 = 2*a0; a2 = a0; b1 = 2*a0*( 1 - c*c ); b2 = a0 * (1 - kTTSqrt2*c + c*c); return kTTErrNone; }
TTErr TrapezoidWindow::calculateValue(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt data) { TTFloat64 twoOverAlpha = 2. / mAlpha; TTFloat64 alphaOverTwo = mAlpha / 2.; if ( x < alphaOverTwo ) { // attack portion y = x * twoOverAlpha; } else if ( x > ( 1 - alphaOverTwo ) ) { // release portion y = (1 - x) * twoOverAlpha; } else { // sustain portion y = 1.; } TTLimit(y, 0.0, 1.0 ); return kTTErrNone; }
TTErr TukeyWindow::calculateValue(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt data) { TTFloat64 twoOverAlpha = 2. / mAlpha; TTFloat64 alphaOverTwo = mAlpha / 2.; if ( x < alphaOverTwo ) { // attack portion y = 0.5 * (1 + cos( kTTPi * ((twoOverAlpha * x) - 1))); } else if ( x > ( 1 - alphaOverTwo) ) { // release portion y = 0.5 * (1 + cos( kTTPi * ((twoOverAlpha * x) - twoOverAlpha + 1))); } else { // sustain portion y = 1.; } TTLimit(y, 0.0, 1.0 ); // just in case return kTTErrNone; }