void SkidderEditor::rateDisplayConvert(float value, char *string, void *temporatestring) { if ( onOffTest(theTempoSync) ) { strcpy(string, (char*)temporatestring); if (strlen(string) <= 3) strcat(string, " cycles/beat"); } else sprintf(string, "%.3f Hz", rateScaled(value)); }
float SkidderEditor::calculateTheCycleRate() { float tempoBPS; // tempo sync is being used if ( onOffTest(effect->getParameter(kTempoSync)) ) { // "auto" mode; get the current tempo from the effect if ( effect->getParameter(kTempo) <= 0.0f ) tempoBPS = ((Skidder*)effect)->currentTempoBPS; // otherwise use the user-inputted tempo else tempoBPS = tempoScaled(effect->getParameter(kTempo)) / 60.0f; return ( tempoBPS * (((Skidder*)effect)->tempoRateTable->getScalar(effect->getParameter(kTempoRate))) ); } // tempo sync is not being used so just return the simple "free" rate value else return rateScaled(effect->getParameter(kRate)); }
//----------------------------------------------------------------------------------------- void skidder::processValley(float SAMPLERATE) { float rateRandFactor = rateRandFactorScaled(fRateRandFactor); // stores the real value float cycleRate; // the base current skid rate value float randFloat, randomRate; // the current randomized rate value float fPulsewidthRandomized; // stores the latest randomized pulsewidth 0.0 - 1.0 value bool barSync = false; // true if we need to sync up with the next bar start long countdown; if (useRandomFloor) amp = randomFloor; else amp = floor; valleySamples--; if (valleySamples <= 0) { rms = 0.0f; // reset rms now because valley is over // // This is where we figure out how many samples long each // envelope section is for the next skid cycle. // if (onOffTest(fTempoSync)) // the user wants to do tempo sync / beat division rate { cycleRate = currentTempoBPS * (tempoRateTable->getScalar(fTempoRate)); // set this true so that we make sure to do the measure syncronisation later on } else cycleRate = rateScaled(fRate); // if (fRateRandFactor > 0.0f) { // get a random value from 0.0 to 1.0 randFloat = (float)rand() * ONE_DIV_RAND_MAX; // square-scale the random value & then scale it with the random rate range randomRate = ( randFloat * randFloat * ((cycleRate*rateRandFactor)-(cycleRate/rateRandFactor)) ) + (cycleRate/rateRandFactor); cycleSamples = (long) (SAMPLERATE / randomRate); barSync = false; // we can't do the bar sync if the skids durations are random } else cycleSamples = (long) (SAMPLERATE / cycleRate); // if (fPulsewidth > fPulsewidthRandMin) { fPulsewidthRandomized = ( ((float)rand()*ONE_DIV_RAND_MAX) * (fPulsewidth-fPulsewidthRandMin) ) + fPulsewidthRandMin; pulseSamples = (long) ( ((float)cycleSamples) * pulsewidthScaled(fPulsewidthRandomized) ); } else pulseSamples = (long) ( ((float)cycleSamples) * pulsewidthScaled(fPulsewidth) ); valleySamples = cycleSamples - pulseSamples; slopeSamples = (long) ((SAMPLERATE/1000.0f)*(fSlope*(SLOPEMAX))); slopeDur = slopeSamples; slopeStep = 1.0f / (float)slopeDur; // calculate the fade increment scalar plateauSamples = pulseSamples - (slopeSamples * 2); if (plateauSamples < 1) // this shrinks the slope to 1/3 of the pulse if the user sets slope too high { slopeSamples = (long) (((float)pulseSamples) / 3.0f); slopeDur = slopeSamples; slopeStep = 1.0f / (float)slopeDur; // calculate the fade increment scalar plateauSamples = pulseSamples - (slopeSamples * 2); } // go to slopeIn next if slope is not 0.0, otherwise go to plateau if (slopeDur > 0) state = slopeIn; else state = plateau; // this puts random float values from -1.0 to 1.0 into panRander panRander = ( ((float)rand()*ONE_DIV_RAND_MAX) * 2.0f ) - 1.0f; } //end of the "valley is over" if-statement }