ComponentResult IPlugProcess::SetChunk(OSType chunkID, SFicPlugInChunk *chunk) { TRACE; if (chunkID == mPluginID) { int dataSize = chunk->fSize - sizeof(SFicPlugInChunkHeader); ByteChunk IPlugChunk; IPlugChunk.PutBytes(chunk->fData, dataSize); mPlug->UnserializeState(&IPlugChunk, 0); for (int i = 0; i< mPlug->NParams(); i++) { IParam *p = mPlug->GetParam(i); int idx = i+kPTParamIdxOffset; switch (p->Type()) { case IParam::kTypeDouble: { CPluginControl_Continuous *control = dynamic_cast<CPluginControl_Continuous*>(GetControl(idx)); SetControlValue(idx, control->ConvertContinuousToControl( p->Value() )); break; } case IParam::kTypeInt: case IParam::kTypeEnum: case IParam::kTypeBool: { CPluginControl_Discrete *control = dynamic_cast<CPluginControl_Discrete*>(GetControl(idx)); SetControlValue(idx, control->ConvertDiscreteToControl( p->Int() )); break; } default: break; } } fNumPlugInChanges++; return noErr; } return kChunkRangeErr; }
void SpaceBass::OnParamChange(int paramIdx) { IMutexLock lock(this); IParam* param = GetParam(paramIdx); if(paramIdx == mLFOWaveform) { voiceManager.setLFOMode(static_cast<Oscillator::OscillatorMode>(param->Int())); } else if(paramIdx == mLFOFrequency) { voiceManager.setLFOFrequency(param->Value()); } else { using std::tr1::placeholders::_1; using std::tr1::bind; VoiceManager::VoiceChangerFunction changer; switch(paramIdx) { case mOsc1Waveform: changer = bind(&VoiceManager::setOscillatorMode, _1, 1, static_cast<Oscillator::OscillatorMode>(param->Int())); break; case mOsc1PitchMod: changer = bind(&VoiceManager::setOscillatorPitchMod, _1, 1, param->Value()); break; case mOsc2Waveform: changer = bind(&VoiceManager::setOscillatorMode, _1, 2, static_cast<Oscillator::OscillatorMode>(param->Int())); break; case mOsc2PitchMod: changer = bind(&VoiceManager::setOscillatorPitchMod, _1, 2, param->Value()); break; case mOscMix: changer = bind(&VoiceManager::setOscillatorMix, _1, param->Value()); break; // Filter Section: case mFilterMode: changer = bind(&VoiceManager::setFilterMode, _1, static_cast<Filter::FilterMode>(param->Int())); break; case mFilterCutoff: changer = bind(&VoiceManager::setFilterCutoff, _1, param->Value()); break; case mFilterResonance: changer = bind(&VoiceManager::setFilterResonance, _1, param->Value()); break; case mFilterLfoAmount: changer = bind(&VoiceManager::setFilterLFOAmount, _1, param->Value()); break; case mFilterEnvAmount: changer = bind(&VoiceManager::setFilterEnvAmount, _1, param->Value()); break; // Volume Envelope: case mVolumeEnvAttack: changer = bind(&VoiceManager::setVolumeEnvelopeStageValue, _1, EnvelopeGenerator::ENVELOPE_STAGE_ATTACK, param->Value()); break; case mVolumeEnvDecay: changer = bind(&VoiceManager::setVolumeEnvelopeStageValue, _1, EnvelopeGenerator::ENVELOPE_STAGE_DECAY, param->Value()); break; case mVolumeEnvSustain: changer = bind(&VoiceManager::setVolumeEnvelopeStageValue, _1, EnvelopeGenerator::ENVELOPE_STAGE_SUSTAIN, param->Value()); break; case mVolumeEnvRelease: changer = bind(&VoiceManager::setVolumeEnvelopeStageValue, _1, EnvelopeGenerator::ENVELOPE_STAGE_RELEASE, param->Value()); break; // Filter Envelope: case mFilterEnvAttack: changer = bind(&VoiceManager::setFilterEnvelopeStageValue, _1, EnvelopeGenerator::ENVELOPE_STAGE_ATTACK, param->Value()); break; case mFilterEnvDecay: changer = bind(&VoiceManager::setFilterEnvelopeStageValue, _1, EnvelopeGenerator::ENVELOPE_STAGE_DECAY, param->Value()); break; case mFilterEnvSustain: changer = bind(&VoiceManager::setFilterEnvelopeStageValue, _1, EnvelopeGenerator::ENVELOPE_STAGE_SUSTAIN, param->Value()); break; case mFilterEnvRelease: changer = bind(&VoiceManager::setFilterEnvelopeStageValue, _1, EnvelopeGenerator::ENVELOPE_STAGE_RELEASE, param->Value()); break; } voiceManager.changeAllVoices(changer); } }
void Synthesis::OnParamChange(int paramIdx) { IMutexLock lock(this); VoiceManager& voiceManager = VoiceManager::getInstance(); IParam* param = GetParam(paramIdx); // std::cout << paramIdx << "\n"; // printf("\nparam: %s", paramIdx); switch(paramIdx) { // Volume Envelope: case mB: voiceManager.updateInharmonicityCoeff(param->Value()); break; case mNumPartials: voiceManager.updateNumPartials(param->Value()); break; case mStringDetuneRange: voiceManager.updateStringDetuneRange(param->Value()); break; case mPartialDetuneRange: voiceManager.updatePartialDetuneRange(param->Value()); break; case mDamping: voiceManager.updateDamping(param->Value()); break; case mLinearTerm: voiceManager.updateLinearTerm(param->Value()); break; case mSquaredTerm: voiceManager.updateSquaredTerm(param->Value()); break; case mCubicTerm: voiceManager.updateCubicTerm(param->Value()); break; case mBrightnessA: voiceManager.updateBrightnessA(param->Value()); break; case mBrightnessB: voiceManager.updateBrightnessB(param->Value()); break; case mPitchBendCoarse: voiceManager.updatePitchBendCoarse(param->Value()); break; case mPitchBendFine: voiceManager.updatePitchBendFine(param->Value()); break; default: break; } }