void IParam::InitDouble(const char* name, double defaultVal, double minVal, double maxVal, double step, const char* label, const char* group, double shape) { if (mType == kTypeNone) mType = kTypeDouble; strcpy(mName, name); strcpy(mLabel, label); strcpy(mParamGroup, group); mValue = defaultVal; mMin = minVal; mMax = IPMAX(maxVal, minVal + step); mStep = step; mDefault = defaultVal; for (mDisplayPrecision = 0; mDisplayPrecision < MAX_PARAM_DISPLAY_PRECISION && step != floor(step); ++mDisplayPrecision, step *= 10.0) { ; } SetShape(shape); }
void IPlugSideChain::ProcessDoubleReplacing(double** inputs, double** outputs, int nFrames) { // Mutex is already locked for us. bool in1ic = IsInChannelConnected(0); bool in2ic = IsInChannelConnected(1); bool in3ic = IsInChannelConnected(2); bool in4ic = IsInChannelConnected(3); printf("%i %i %i %i, ------------------------- \n", in1ic, in2ic, in3ic, in4ic); #ifdef RTAS_API double* in1 = inputs[0]; double* in2 = inputs[1]; double* scin1 = inputs[2]; double* out1 = outputs[0]; double* out2 = outputs[1]; double peakL = 0.0, peakR = 0.0, peakLS = 0.0; for (int s = 0; s < nFrames; ++s, ++in1, ++in2, ++scin1, ++out1, ++out2) { *out1 = *in1 * mGain; *out2 = *in2 * mGain; peakL = IPMAX(peakL, fabs(*in1)); peakR = IPMAX(peakR, fabs(*in2)); peakLS = IPMAX(peakLS, fabs(*scin1)); } double xL = (peakL < mPrevL ? METER_DECAY : METER_ATTACK); double xR = (peakR < mPrevR ? METER_DECAY : METER_ATTACK); double xLS = (peakLS < mPrevLS ? METER_DECAY : METER_ATTACK); peakL = peakL * xL + mPrevL * (1.0 - xL); peakR = peakR * xR + mPrevR * (1.0 - xR); peakLS = peakLS * xLS + mPrevLS * (1.0 - xLS); mPrevL = peakL; mPrevR = peakR; mPrevLS = peakLS; if (GetGUI()) { GetGUI()->SetControlFromPlug(mMeterIdx_L, peakL); GetGUI()->SetControlFromPlug(mMeterIdx_R, peakR); GetGUI()->SetControlFromPlug(mMeterIdx_LS, peakLS); } #else double* in1 = inputs[0]; double* in2 = inputs[1]; double* scin1 = inputs[2]; double* scin2 = inputs[3]; double* out1 = outputs[0]; double* out2 = outputs[1]; double peakL = 0.0, peakR = 0.0, peakLS = 0.0, peakRS = 0.0; //Stupid hack because logic connects the sidechain bus to the main bus when no sidechain is connected //see coreaudio mailing list #ifdef AU_API if (GetHost() == kHostLogic) { if(!memcmp(in1, scin1, nFrames * sizeof(double))) { memset(scin1, 0, nFrames * sizeof(double)); memset(scin2, 0, nFrames * sizeof(double)); } } #endif for (int s = 0; s < nFrames; ++s, ++in1, ++in2, ++scin1, ++scin2, ++out1, ++out2) { *out1 = *in1 * mGain; *out2 = *in2 * mGain; peakL = IPMAX(peakL, fabs(*in1)); peakR = IPMAX(peakR, fabs(*in2)); peakLS = IPMAX(peakLS, fabs(*scin1)); peakRS = IPMAX(peakRS, fabs(*scin2)); } double xL = (peakL < mPrevL ? METER_DECAY : METER_ATTACK); double xR = (peakR < mPrevR ? METER_DECAY : METER_ATTACK); double xLS = (peakLS < mPrevLS ? METER_DECAY : METER_ATTACK); double xRS = (peakRS < mPrevRS ? METER_DECAY : METER_ATTACK); peakL = peakL * xL + mPrevL * (1.0 - xL); peakR = peakR * xR + mPrevR * (1.0 - xR); peakLS = peakLS * xLS + mPrevLS * (1.0 - xLS); peakRS = peakRS * xRS + mPrevRS * (1.0 - xRS); mPrevL = peakL; mPrevR = peakR; mPrevLS = peakLS; mPrevRS = peakRS; if (GetGUI()) { GetGUI()->SetControlFromPlug(mMeterIdx_L, peakL); GetGUI()->SetControlFromPlug(mMeterIdx_R, peakR); GetGUI()->SetControlFromPlug(mMeterIdx_LS, peakLS); GetGUI()->SetControlFromPlug(mMeterIdx_RS, peakRS); } #endif }
void IPlugMultiTargets::ProcessDoubleReplacing(double** inputs, double** outputs, int nFrames) { // Mutex is already locked for us. double* in1 = inputs[0]; double* in2 = inputs[1]; double* out1 = outputs[0]; double* out2 = outputs[1]; double peakL = 0.0, peakR = 0.0; GetTime(&mTimeInfo); IKeyboardControl* pKeyboard = (IKeyboardControl*) mKeyboard; if (pKeyboard->GetKey() != mKey) { IMidiMsg msg; if (mKey >= 0) { msg.MakeNoteOffMsg(mKey + 48, 0, 0); mMidiQueue.Add(&msg); } mKey = pKeyboard->GetKey(); if (mKey >= 0) { msg.MakeNoteOnMsg(mKey + 48, pKeyboard->GetVelocity(), 0, 0); mMidiQueue.Add(&msg); } } for (int offset = 0; offset < nFrames; ++offset, ++in1, ++in2, ++out1, ++out2) { while (!mMidiQueue.Empty()) { IMidiMsg* pMsg = mMidiQueue.Peek(); if (pMsg->mOffset > offset) break; // TODO: make this work on win sa #if !defined(OS_WIN) && !defined(SA_API) SendMidiMsg(pMsg); #endif int status = pMsg->StatusMsg(); switch (status) { case IMidiMsg::kNoteOn: case IMidiMsg::kNoteOff: { int velocity = pMsg->Velocity(); // Note On if (status == IMidiMsg::kNoteOn && velocity) { mNote = pMsg->NoteNumber(); mFreq = 440. * pow(2., (mNote - 69.) / 12.); mNoteGain = velocity / 127.; } // Note Off else // if (status == IMidiMsg::kNoteOff || !velocity) { if (pMsg->NoteNumber() == mNote) mNote = -1; mNoteGain = 0.; } break; } } mMidiQueue.Remove(); } *out1 = sin( 2. * M_PI * mFreq * mPhase / mSampleRate ) * mGainLSmoother.Process(mGainL * mNoteGain); *out2 = sin( 2. * M_PI * mFreq * 1.01 * (mPhase++) / mSampleRate ) * mGainRSmoother.Process(mGainR * mNoteGain); peakL = IPMAX(peakL, fabs(*out1)); peakR = IPMAX(peakR, fabs(*out2)); } const double METER_ATTACK = 0.6, METER_DECAY = 0.05; double xL = (peakL < mPrevL ? METER_DECAY : METER_ATTACK); double xR = (peakR < mPrevR ? METER_DECAY : METER_ATTACK); peakL = peakL * xL + mPrevL * (1.0 - xL); peakR = peakR * xR + mPrevR * (1.0 - xR); mPrevL = peakL; mPrevR = peakR; if (GetGUI()) { GetGUI()->SetControlFromPlug(mMeterIdx_L, peakL); GetGUI()->SetControlFromPlug(mMeterIdx_R, peakR); } mMidiQueue.Flush(nFrames); }