void TriggerJuicePlugin::d_setParameterValue(uint32_t index, float value) { switch (index) { case paramSplit: split = value; break; case paramRev: rev = value; if (rev<0.5) { left.close(d_getSampleRate()/10); right.close(d_getSampleRate()/10); } else { left.open(d_getSampleRate()/10); right.open(d_getSampleRate()/10); } break; case paramAttack: attack = value; break; case paramRelease: release = value; break; case paramMS: MS = value; break; } }
void TriggerJuicePlugin::d_setProgram(uint32_t index) { if (index != 0) return; /* Default parameter values */ split = 0.0f; rev = 0.0f; attack = 0.0f; release = 0.0f; MS = 0.0f; /* Default variable values */ attack=release=0; rev=split=MS=0; left.setSr(d_getSampleRate()); right.setSr(d_getSampleRate()); //parameter smoothing for (int i=0; i<2; i++) { sA[i] = 0.99f; sB[i] = 1.f - sA[i]; sZ[i] = 0; } /* reset filter values */ d_activate(); }
void PowerJuiceX2Plugin::d_setParameterValue(uint32_t index, float value) { switch (index) { case paramAttack: attack = value; attackSamples = d_getSampleRate()*(attack/1000.0f); break; case paramRelease: release = value; releaseSamples = d_getSampleRate()*(release/1000.0f); break; case paramThreshold: threshold = value; break; case paramRatio: ratio = value; break; case paramMakeup: makeup = value; makeupFloat = fromDB(makeup); break; case paramMix: mix = value; break; } }
void DistrhoPlugin3BandEQ::d_activate() { xLP = std::exp(-2.0f * kPI * freqLP / (float)d_getSampleRate()); a0LP = 1.0f - xLP; b1LP = -xLP; xHP = std::exp(-2.0f * kPI * freqHP / (float)d_getSampleRate()); a0HP = 1.0f - xHP; b1HP = -xHP; }
void WobbleJuicePlugin::d_run(float** inputs, float** outputs, uint32_t frames) { //fetch the timepos struct from host; const TimePos& time = d_getTimePos(); /* sample count for one bar */ bar = ((120.0/(time.bbt.valid ? time.bbt.beatsPerMinute : 120.0))*(d_getSampleRate())); //ONE, two, three, four tick = bar/(std::round(division)); //size of one target wob phaseOffset = phase*M_PI; //2pi = 1 whole cycle if (time.playing) { /* if rolling then sync to timepos */ tickOffset = time.frame-std::floor(time.frame/tick)*tick; //how much after last tick if (tickOffset!=0) { //TODO: why do we need this?? percentage = tickOffset/tick; } else { percentage = 0; } sinePos = (M_PI*2)*percentage; if (sinePos>2*M_PI) { //TODO: can this ever happen?? sinePos = 0; } } else { /* else just keep on wobblin' */ sinePos += (M_PI)/(tick/2000); //wtf, but works if (sinePos>2*M_PI) { sinePos = 0; } } /* phase of 0..1 filter = 500..16k */ currentPhaseL = getBlendedPhase(sinePos+phaseOffset, wave); currentPhaseR = getBlendedPhase(sinePos-phaseOffset, wave); /* logarithmic */ cutoffL = std::exp((std::log(range)-std::log(500))*currentPhaseL+std::log(500)); cutoffR = std::exp((std::log(range)-std::log(500))*currentPhaseR+std::log(500)); //output filtered signal filterL.recalc(cutoffL, reso*4, d_getSampleRate(), drive); filterR.recalc(cutoffR, reso*4, d_getSampleRate(), drive); filterL.process(frames, inputs[0], outputs[0]); filterR.process(frames, inputs[1], outputs[1]); }
void DistrhoPluginPingPongPan::d_setParameterValue(uint32_t index, float value) { if (d_getSampleRate() <= 0.0) return; switch (index) { case paramFreq: fFreq = value; waveSpeed = (k2PI * fFreq / 100.0f)/(float)d_getSampleRate(); break; case paramWidth: fWidth = value; break; } }
void ZamEQ2Plugin::d_run(const float** inputs, float** outputs, uint32_t frames) { float srate = d_getSampleRate(); lowshelf(0, 0, srate, freql, gainl); peq(1, 0, srate, freq1, gain1, q1); peq(2, 0, srate, freq2, gain2, q2); highshelf(3, 0, srate, freqh, gainh); for (uint32_t i = 0; i < frames; i++) { double tmp,tmpl, tmph; double in = inputs[0][i]; in = sanitize_denormal(in); //lowshelf tmpl = (gainl == 0.f) ? in : run_filter(0, 0, in); //highshelf tmph = (gainh == 0.f) ? tmpl : run_filter(3, 0, tmpl); //parametric1 tmp = (gain1 == 0.f) ? tmph : run_filter(1, 0, tmph); //parametric2 tmpl = (gain2 == 0.f) ? tmp : run_filter(2, 0, tmp); outputs[0][i] = inputs[0][i]; outputs[0][i] = (float) tmpl; outputs[0][i] *= from_dB(master); } }
void DistrhoPlugin3BandEQ::d_setParameterValue(uint32_t index, float value) { if (d_getSampleRate() <= 0.0) return; switch (index) { case paramLow: fLow = value; lowVol = std::exp( (fLow/48.0f) * 48 / kAMP_DB); break; case paramMid: fMid = value; midVol = std::exp( (fMid/48.0f) * 48 / kAMP_DB); break; case paramHigh: fHigh = value; highVol = std::exp( (fHigh/48.0f) * 48 / kAMP_DB); break; case paramMaster: fMaster = value; outVol = std::exp( (fMaster/48.0f) * 48 / kAMP_DB); break; case paramLowMidFreq: fLowMidFreq = std::fmin(value, fMidHighFreq); freqLP = fLowMidFreq; //fLowMidFreq * (fLowMidFreq / 24000.0f) * (fLowMidFreq / 24000.0f); xLP = std::exp(-2.0f * kPI * freqLP / (float)d_getSampleRate()); a0LP = 1.0f - xLP; b1LP = -xLP; break; case paramMidHighFreq: fMidHighFreq = std::fmax(value, fLowMidFreq); freqHP = fMidHighFreq; //fMidHighFreq * (fMidHighFreq / 24000.0f) * (fMidHighFreq / 24000.0f); xHP = std::exp(-2.0f * kPI * freqHP / (float)d_getSampleRate()); a0HP = 1.0f - xHP; b1HP = -xHP; break; } }
void ZamSFZPlugin::d_setState(const char* key, const char* value) { if (strcmp(key, "filepath") == 0) { char *tmp; char file[1024] = {0}; snprintf(file, 1024, "%s", value); tmp = strrchr(file, '/'); filename.assign(tmp, 1, strlen(tmp) - 1); path.assign(value, 0, strlen(value) - strlen(tmp)); loading = true; printf("Path: %s\nFile: %s\n", path.c_str(), filename.c_str()); sfz.clearsamples(); sfz.loadsamples(path, filename); sfz.pitchshiftsamples((int)d_getSampleRate()); loading = false; } }
void rollLFOs() { float bar, tick, tickOffset, sinePos, percentage; const TimePos& time = d_getTimePos(); for (int i=0; i<9; i++) { sinePos = modules[i]->getSinePos(); /* sample count for one bar */ bar = ((120.0/(time.bbt.valid ? time.bbt.beatsPerMinute : 120.0))*(d_getSampleRate())); //ONE, two, three, four tick = bar/(std::round(params[i][0])); //size of one target wob if (time.playing) { /* if rolling then sync to timepos */ tickOffset = time.frame-std::floor(time.frame/tick)*tick; //how much after last tick if (tickOffset!=0) { //TODO: why do we need this?? percentage = tickOffset/tick; } else { percentage = 0; } sinePos = (M_PI*2)*percentage; if (sinePos>2*M_PI) { //TODO: can this ever happen?? sinePos = 0; } } else { /* else just keep on wobblin' */ sinePos += (M_PI)/(tick/2000); //wtf, but works if (sinePos>2*M_PI) { sinePos = 0; } } modules[i]->setSinePos(sinePos); } }
void ZaMultiCompX2Plugin::run_comp(int k, float inL, float inR, float *outL, float *outR) { float srate = d_getSampleRate(); float width=(knee-0.99f)*6.f; float attack_coeff = exp(-1000.f/(attack * srate)); float release_coeff = exp(-1000.f/(release * srate)); int stereolink = (stereodet > 0.5f) ? STEREOLINK_MAX : STEREOLINK_AVERAGE; float slewfactor = 80.0;//1.f + knee/2.f; float cdb=0.f; float Lgain = 1.f; float Rgain = 1.f; float Lxg, Lyg; float Rxg, Ryg; float Lxl, Lyl, Ly1; float Rxl, Ryl, Ry1; Lyg = Ryg = 0.f; inL = sanitize_denormal(inL); inR = sanitize_denormal(inR); Lxg = (inL==0.f) ? -160.f : to_dB(fabs(inL)); Rxg = (inR==0.f) ? -160.f : to_dB(fabs(inR)); Lxg = sanitize_denormal(Lxg); Rxg = sanitize_denormal(Rxg); Lyg = Lxg + (1.f/ratio-1.f)*(Lxg-thresdb[k]+width/2.f)*(Lxg-thresdb[k]+width/2.f)/(2.f*width); Lyg = sanitize_denormal(Lyg); Ryg = Rxg + (1.f/ratio-1.f)*(Rxg-thresdb[k]+width/2.f)*(Rxg-thresdb[k]+width/2.f)/(2.f*width); Ryg = sanitize_denormal(Ryg); if (2.f*(Lxg-thresdb[k])<-width) { Lyg = Lxg; } else if (2.f*fabs(Lxg-thresdb[k])<=width && Lyg >= old_yg[0][k]) { attack_coeff = exp(-1000.f/(attack*slewfactor * srate)); } else if (2.f*fabs(Lxg-thresdb[k])<=width && Lyg < old_yg[0][k]) { Lyg = thresdb[k] + (Lxg-thresdb[k])/ratio; Lyg = sanitize_denormal(Lyg); } else if (2.f*(Lxg-thresdb[k])>width) { Lyg = thresdb[k] + (Lxg-thresdb[k])/ratio; Lyg = sanitize_denormal(Lyg); } if (2.f*(Rxg-thresdb[k])<-width) { Ryg = Rxg; } else if (2.f*fabs(Rxg-thresdb[k])<=width && Ryg >= old_yg[1][k]) { attack_coeff = exp(-1000.f/(attack*slewfactor * srate)); } else if (2.f*fabs(Rxg-thresdb[k])<=width && Ryg < old_yg[1][k]) { Ryg = thresdb[k] + (Rxg-thresdb[k])/ratio; Ryg = sanitize_denormal(Ryg); } else if (2.f*(Rxg-thresdb[k])>width) { Ryg = thresdb[k] + (Rxg-thresdb[k])/ratio; Ryg = sanitize_denormal(Ryg); } if (stereolink == STEREOLINK_MAX) { Lxl = Rxl = fmaxf(Lxg - Lyg, Rxg - Ryg); } else { Lxl = Rxl = (Lxg - Lyg + Rxg - Ryg) / 2.f; } old_y1[0][k] = sanitize_denormal(old_y1[0][k]); old_y1[1][k] = sanitize_denormal(old_y1[1][k]); old_yl[0][k] = sanitize_denormal(old_yl[0][k]); old_yl[1][k] = sanitize_denormal(old_yl[1][k]); Ly1 = fmaxf(Lxl, release_coeff * old_y1[0][k]+(1.f-release_coeff)*Lxl); Lyl = attack_coeff * old_yl[0][k]+(1.f-attack_coeff)*Ly1; Ly1 = sanitize_denormal(Ly1); Lyl = sanitize_denormal(Lyl); cdb = -Lyl; Lgain = from_dB(cdb); Ry1 = fmaxf(Rxl, release_coeff * old_y1[1][k]+(1.f-release_coeff)*Rxl); Ryl = attack_coeff * old_yl[1][k]+(1.f-attack_coeff)*Ry1; Ry1 = sanitize_denormal(Ry1); Ryl = sanitize_denormal(Ryl); cdb = -Ryl; Rgain = from_dB(cdb); if (stereolink == STEREOLINK_MAX) gainr[k] = fmaxf(Lyl, Ryl); else gainr[k] = (Lyl + Ryl) / 2.f; *outL = inL; *outL *= Lgain; *outR = inR; *outR *= Rgain; old_yl[0][k] = Lyl; old_yl[1][k] = Ryl; old_y1[0][k] = Ly1; old_y1[1][k] = Ry1; old_yg[0][k] = Lyg; old_yg[1][k] = Ryg; }
void ZamSFZPlugin::d_run(const float**, float** outputs, uint32_t frames, const MidiEvent* midievent, uint32_t midicount) { float srate = d_getSampleRate(); int slowfactor = (int) srate / (speed * 2400); // 1-20 ~ 20-1 uint32_t i; if (loading == true) { for (i = 0; i < frames; i++) { outputs[0][i] = 0.f; outputs[1][i] = 0.f; } } else { for (i = 0; i < midicount; i++) { int type = midievent[i].data[0] & 0xF0; int chan = midievent[i].data[0] & 0x0F; int num = midievent[i].data[1]; int vel = midievent[i].data[2]; if (type == 0x90 && chan == 0x0) { // NOTE ON int newvoice = -1; //printf("ON: Note %d\n", num); //printf("ON: begin attack\n"); for (int k = 0; k < 128; k++) if (!voice[k].playing) newvoice = k; if (newvoice == -1) newvoice = 0; //steal #0 curvoice = &voice[newvoice]; curvoice->envpos = 1; // begin attack curvoice->playing = true; curvoice->notenum = num; curvoice->vi = vel / 127.f; curvoice->curamp = curvoice->vi; curvoice->rampstate = 0; } else if (type == 0x80 && chan == 0x0) { // NOTE OFF //printf("OFF: Note\n"); //find voice with current notenum nvoices = 0; for (int k = 0; k < 128; k++) { if (voice[k].playing && voice[k].notenum == num) { voice[k].envpos = MAX_ENV / 2 + 1; // begin release; } if (!voice[k].playing && voice[k].notenum == num) { voice[k].notenum = -1; } } } } bool signal; float wavel; float waver; float outl; float outr; for (i = 0; i < frames; i++) { signal = false; outl = outr = 0.f; int k; Voice* j; // process envelope positions per sample for (k = 0; k < 128; k++) { j = &voice[k]; if (j->playing) { if (j->envpos <= 0) { //silence j->playing = false; j->notenum = -1; j->envpos = 0; j->slowcount = 0; j->curamp = 0.f; j->vi = 0.f; j->rampstate = 0; } else if (j->envpos > 0 && (int) j->envpos < MAX_ENV / 2) { //attack j->curamp = j->vi * env_y[j->envpos]; //printf("att: %d envpos=%d curamp=%.2f\n",k,j->envpos, j->curamp); j->slowcount++; j->envpos += ((j->slowcount % slowfactor) == 0) ? 1 : 0; } else if (j->envpos > MAX_ENV / 2) { //release j->curamp = j->vi * env_y[j->envpos]; //printf("rel: %d envpos=%d curamp=%.2f\n",k,j->envpos, j->curamp); j->slowcount++; j->envpos += ((j->slowcount % slowfactor) == 0) ? 1 : 0; if (j->envpos == MAX_ENV) { //end of release j->playing = false; j->notenum = -1; j->envpos = 0; j->slowcount = 0; j->curamp = 0.f; j->vi = 0.f; j->rampstate = 0; //printf("killed, n=%d\n",k); } } else if (j->envpos >= j->maxsamples || j->rampstate >= j->maxsamples) { j->playing = false; j->notenum = -1; j->envpos = 0; j->slowcount = 0; j->curamp = 0.f; j->vi = 0.f; j->rampstate = 0; } else { //sustain j->curamp = j->vi * env_y[MAX_ENV/2]; //printf("sustain...\n"); } } } for (k = 0; k < 128; k++) { if (voice[k].curamp < 0.f && voice[k].playing) printf("WTF NEG\n"); if (!voice[k].playing) { voice[k].rampstate = 0; continue; } signal = true; voice[k].rampstate++; if (voice[k].rampstate >= voice[k].maxsamples) { wavel = waver = 0.f; voice[k].rampstate = 0; voice[k].playing = false; voice[k].notenum = -1; voice[k].envpos = 0; voice[k].slowcount = 0; voice[k].curamp = 0.f; voice[k].vi = 0.f; } else { int n = voice[k].notenum; int v = voice[k].vi * 127.; int l = 0; for (int k = 0; k < sfz.layers[n].max; k++) { if (sfz.layers[n].l[k].lovel <= v && v <= sfz.layers[n].l[k].hivel) { l = k; break; } } int pos = voice[k].rampstate; wavel = sfz.sample[n][l][0][pos]; waver = sfz.sample[n][l][1][pos]; } outl += wavel*voice[k].curamp/2.; outr += waver*voice[k].curamp/2.; } if (signal) { //outl; //outr; outputs[0][i] = outl*from_dB(gain); outputs[1][i] = outr*from_dB(gain); } else { outputs[0][i] = 0.f; outputs[1][i] = 0.f; } } } }
void animate() { //sync orbit with frame, bpm const TimePos& time = d_getTimePos(); bar = ((120.0/(time.bbt.valid ? time.bbt.beatsPerMinute : 120.0))*(d_getSampleRate())); int multiplier = 16;//2000*4; tickX = bar/(std::round(orbitSpeedX))*multiplier; tickY = bar/(std::round(orbitSpeedY))*multiplier; tick = bar/(std::round(subOrbitSpeed))*multiplier; if (time.playing) { /* if rolling then sync to timepos */ tickOffsetX = time.frame-std::floor(time.frame/tickX)*tickX; tickOffsetY = time.frame-std::floor(time.frame/tickY)*tickY; tickOffset = time.frame-std::floor(time.frame/tick)*tick; percentageX = tickOffsetX/tickX; percentageY = tickOffsetY/tickY; percentage = tickOffset/tick; sinePosX = (M_PI*2)*percentageX; sinePosY = (M_PI*2)*percentageY; sinePos = (M_PI*2)*percentage; } else { /* else just keep on wobblin' */ sinePosX += (2*M_PI)/(tickX); sinePosY += (2*M_PI)/(tickY); sinePos += (M_PI)/(tick); if (sinePosX>2*M_PI) { sinePosX = 0; } if (sinePosY>2*M_PI) { sinePosY = 0; } if (sinePos>2*M_PI) { sinePos = 0; } } //0..1 //0..3 //0, 1, 2, 3 //* 0.25 //0, 0.25, 0.5, 0.75 float tempPhaseX = std::round(orbitPhaseX*3)*0.25; float tempPhaseY = std::round(orbitPhaseY*3)*0.25; orbitX = x+getBlendedPhase(sinePosX + tempPhaseX*(2*M_PI), std::round(orbitWaveX))*(orbitSizeX/2); orbitY = y+getBlendedPhase(sinePosY+M_PI/2 + tempPhaseY*(2*M_PI), std::round(orbitWaveY))*(orbitSizeY/2); subOrbitX = smoothParameter(orbitX+getBlendedPhase(sinePos, 3)*(subOrbitSize/3), 0); subOrbitY = smoothParameter(orbitY+getBlendedPhase(sinePos+M_PI/2, 3)*(subOrbitSize/3), 1); if (orbitX<0) orbitX=0; if (orbitX>1) orbitX=1; if (orbitY<0) orbitY=0; if (orbitY>1) orbitY=1; if (subOrbitX<0) subOrbitX=0; if (subOrbitX>1) subOrbitX=1; if (subOrbitY<0) subOrbitY=0; if (subOrbitY>1) subOrbitY=1; }
void ZaMultiCompX2Plugin::d_run(const float** inputs, float** outputs, uint32_t frames) { float srate = d_getSampleRate(); float maxxL = maxL; float maxxR = maxR; int tog1 = (toggle[0] > 0.5f) ? 1 : 0; int tog2 = (toggle[1] > 0.5f) ? 1 : 0; int tog3 = (toggle[2] > 0.5f) ? 1 : 0; int listen1 = (listen[0] > 0.5f) ? 1 : 0; int listen2 = (listen[1] > 0.5f) ? 1 : 0; int listen3 = (listen[2] > 0.5f) ? 1 : 0; set_lp_coeffs(xover1, ONEOVERROOT2, srate, 0, 0); set_lp_coeffs(xover1, ONEOVERROOT2, srate, 1, 0); set_hp_coeffs(xover1, ONEOVERROOT2, srate, 2, 0); set_hp_coeffs(xover1, ONEOVERROOT2, srate, 3, 0); set_lp_coeffs(xover2, ONEOVERROOT2, srate, 4, 0); set_lp_coeffs(xover2, ONEOVERROOT2, srate, 5, 0); set_hp_coeffs(xover2, ONEOVERROOT2, srate, 6, 0); set_hp_coeffs(xover2, ONEOVERROOT2, srate, 7, 0); set_lp_coeffs(xover1, ONEOVERROOT2, srate, 0, 1); set_lp_coeffs(xover1, ONEOVERROOT2, srate, 1, 1); set_hp_coeffs(xover1, ONEOVERROOT2, srate, 2, 1); set_hp_coeffs(xover1, ONEOVERROOT2, srate, 3, 1); set_lp_coeffs(xover2, ONEOVERROOT2, srate, 4, 1); set_lp_coeffs(xover2, ONEOVERROOT2, srate, 5, 1); set_hp_coeffs(xover2, ONEOVERROOT2, srate, 6, 1); set_hp_coeffs(xover2, ONEOVERROOT2, srate, 7, 1); for (uint32_t i = 0; i < frames; ++i) { float tmp1[2], tmp2[2], tmp3[2], tmp4[2], tmp5[2], tmp6[2]; float fil1[2], fil2[2], fil3[2], fil4[2]; float outL[MAX_COMP+1] = {0.f}; float outR[MAX_COMP+1] = {0.f}; float inl = sanitize_denormal(inputs[0][i]); float inr = sanitize_denormal(inputs[1][i]); inl = (fabs(inl) < DANGER) ? inl : 0.f; inr = (fabs(inr) < DANGER) ? inr : 0.f; int listenmode = 0; // Interleaved channel processing fil1[0] = run_filter(0, 0, inl); fil1[1] = run_filter(0, 1, inr); tmp1[0] = run_filter(1, 0, fil1[0]); tmp1[1] = run_filter(1, 1, fil1[1]); if (tog1) run_comp(0, tmp1[0], tmp1[1], &outL[0], &outR[0]); tmp2[0] = tog1 ? outL[0] * from_dB(makeup[0]) : tmp1[0]; tmp2[1] = tog1 ? outR[0] * from_dB(makeup[0]) : tmp1[1]; fil2[0] = run_filter(2, 0, inl); fil2[1] = run_filter(2, 1, inr); tmp3[0] = run_filter(3, 0, fil2[0]); tmp3[1] = run_filter(3, 1, fil2[1]); fil3[0] = run_filter(4, 0, tmp3[0]); fil3[1] = run_filter(4, 1, tmp3[1]); tmp4[0] = run_filter(5, 0, fil3[0]); tmp4[1] = run_filter(5, 1, fil3[1]); if (tog2) run_comp(1, tmp4[0], tmp4[1], &outL[1], &outR[1]); tmp3[0] = tog2 ? outL[1] * from_dB(makeup[1]) : tmp4[0]; tmp3[1] = tog2 ? outR[1] * from_dB(makeup[1]) : tmp4[1]; fil4[0] = run_filter(6, 0, inl); fil4[1] = run_filter(6, 1, inr); tmp5[0] = run_filter(7, 0, fil4[0]); tmp5[1] = run_filter(7, 1, fil4[1]); if (tog3) run_comp(2, tmp5[0], tmp5[1], &outL[2], &outR[2]); tmp6[0] = tog3 ? outL[2] * from_dB(makeup[2]) : tmp5[0]; tmp6[1] = tog3 ? outR[2] * from_dB(makeup[2]) : tmp5[1]; outputs[0][i] = outputs[1][i] = 0.f; if (listen1) { listenmode = 1; outputs[0][i] += outL[0] * tog1*from_dB(makeup[0]) + (1.-tog1) * tmp1[0]; outputs[1][i] += outR[0] * tog1*from_dB(makeup[0]) + (1.-tog1) * tmp1[1]; } if (listen2) { listenmode = 1; outputs[0][i] += outL[1] * tog2*from_dB(makeup[1]) + (1.-tog2) * tmp4[0]; outputs[1][i] += outR[1] * tog2*from_dB(makeup[1]) + (1.-tog2) * tmp4[1]; } if (listen3) { listenmode = 1; outputs[0][i] += outL[2] * tog3*from_dB(makeup[2]) + (1.-tog3) * tmp5[0]; outputs[1][i] += outR[2] * tog3*from_dB(makeup[2]) + (1.-tog3) * tmp5[1]; } if (!listenmode) { outputs[0][i] = tmp2[0] + tmp3[0] + tmp6[0]; outputs[1][i] = tmp2[1] + tmp3[1] + tmp6[1]; } outputs[0][i] = sanitize_denormal(outputs[0][i]); outputs[1][i] = sanitize_denormal(outputs[1][i]); outputs[0][i] *= from_dB(globalgain); outputs[1][i] *= from_dB(globalgain); tmp1[0] = outputs[0][i]; tmp1[1] = outputs[1][i]; run_limit(tmp1[0], tmp1[1], &outL[3], &outR[3]); outputs[0][i] = outL[3]; outputs[1][i] = outR[3]; if (resetl) { maxL = fabsf(outputs[0][i]); resetl = false; } else { maxxL = (fabsf(outputs[0][i]) > maxxL) ? fabsf(outputs[0][i]) : sanitize_denormal(maxxL); } if (resetr) { maxR = fabsf(outputs[1][i]); resetr = false; } else { maxxR = (fabsf(outputs[1][i]) > maxxR) ? fabsf(outputs[1][i]) : sanitize_denormal(maxxR); } } outl = (maxxL <= 0.f) ? -160.f : to_dB(maxxL+limit); outr = (maxxR <= 0.f) ? -160.f : to_dB(maxxR+limit); }
void PowerJuiceX2Plugin::d_setProgram(uint32_t index) { if (index != 0) return; /* Default parameter values */ attack = 20.0f; release = 200.0f; threshold = 0.0f; ratio = 1.0f; makeup = 0.0f; mix = 1.0f; makeupFloat = fromDB(makeup); attackSamples = d_getSampleRate()*(attack/1000.0f); releaseSamples = d_getSampleRate()*(release/1000.0f); w = 563; //waveform plane size, size of the plane in pixels; w2 = 1126; //wavefowm array h = 121; //waveform plane height x = 27; //waveform plane positions y = 53; dc = 113; //0DC line y position /* Default variable values */ averageCounter = 0; inputMax = 0.0f; balancer = 1.0f; GR = 1.0f; newRepaint = false; input.start = 0; rms.start = 0; gainReduction.start = 0; RMSStack.start = 0; lookaheadStack.start = 0; repaintSkip = 0; kFloatRMSStackCount = 400.0f/44100.0f*d_getSampleRate(); RMSStack.data = (float*) calloc(kFloatRMSStackCount, sizeof(float)); kFloatLookaheadStackCount = 800.0f/44100.0f*d_getSampleRate(); lookaheadStack.data = (float*) calloc(kFloatLookaheadStackCount, sizeof(float)); refreshSkip= 300.0f/44100.0f*d_getSampleRate(); std::memset(rms.data, 0, sizeof(float)*kFloatStackCount); std::memset(gainReduction.data, 0, sizeof(float)*kFloatStackCount); std::memset(RMSStack.data, 0, sizeof(float)*kFloatRMSStackCount); std::memset(lookaheadStack.data, 0, sizeof(float)*kFloatLookaheadStackCount); for (int j=0; j < kFloatStackCount; ++j) history.rms[j] = h +y; for (int j=0; j < kFloatStackCount; ++j) history.gainReduction[j] = h +y; d_activate(); }
void ZaMultiCompX2Plugin::run_limit(float inL, float inR, float *outL, float *outR) { float srate = d_getSampleRate(); float width=0.01; float threshdb = -0.5; float attack_coeff = exp(-1000.f/(0.001 * srate)); float release_coeff = exp(-1000.f/(50.0 * srate)); float cdb=0.f; float Lgain = 1.f; float Rgain = 1.f; float Lxg, Lyg; float Rxg, Ryg; float Lxl, Lyl, Ly1; float Rxl, Ryl, Ry1; Lyg = Ryg = 0.f; inL = sanitize_denormal(inL); inR = sanitize_denormal(inR); Lxg = (inL==0.f) ? -160.f : to_dB(fabs(inL)); Rxg = (inR==0.f) ? -160.f : to_dB(fabs(inR)); Lxg = sanitize_denormal(Lxg); Rxg = sanitize_denormal(Rxg); Lyg = Lxg + (1.f/100.0-1.f)*(Lxg-threshdb+width/2.f)*(Lxg-threshdb+width/2.f)/(2.f*width); Lyg = sanitize_denormal(Lyg); Ryg = Rxg + (1.f/100.0-1.f)*(Rxg-threshdb+width/2.f)*(Rxg-threshdb+width/2.f)/(2.f*width); Ryg = sanitize_denormal(Ryg); if (2.f*(Lxg-threshdb) < -width) { Lyg = Lxg; } else { Lyg = threshdb + (Lxg-threshdb)/100.0; Lyg = sanitize_denormal(Lyg); } if (2.f*(Rxg-threshdb) < -width) { Ryg = Rxg; } else { Ryg = threshdb + (Rxg-threshdb)/100.0; Ryg = sanitize_denormal(Ryg); } Lxl = Rxl = fmaxf(Lxg - Lyg, Rxg - Ryg); old_l1[0] = sanitize_denormal(old_l1[0]); old_l1[1] = sanitize_denormal(old_l1[1]); old_ll[0] = sanitize_denormal(old_ll[0]); old_ll[1] = sanitize_denormal(old_ll[1]); Ly1 = fmaxf(Lxl, release_coeff * old_l1[0]+(1.f-release_coeff)*Lxl); Lyl = attack_coeff * old_ll[0]+(1.f-attack_coeff)*Ly1; Ly1 = sanitize_denormal(Ly1); Lyl = sanitize_denormal(Lyl); cdb = -Lyl; Lgain = from_dB(cdb); Ry1 = fmaxf(Rxl, release_coeff * old_l1[1]+(1.f-release_coeff)*Rxl); Ryl = attack_coeff * old_ll[1]+(1.f-attack_coeff)*Ry1; Ry1 = sanitize_denormal(Ry1); Ryl = sanitize_denormal(Ryl); cdb = -Ryl; Rgain = from_dB(cdb); *outL = inL; *outL *= Lgain; *outR = inR; *outR *= Rgain; limit = fmaxf(Lyl, Ryl); old_ll[0] = Lyl; old_ll[1] = Ryl; old_l1[0] = Ly1; old_l1[1] = Ry1; }
void DistrhoPluginPingPongPan::d_activate() { waveSpeed = (k2PI * fFreq / 100.0f)/(float)d_getSampleRate(); }