MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / AddEffect

Method AddEffect

Source/EffectChain.cpp:69–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67}
68
69void EffectChain::AddEffect(std::string type, std::string desiredName, bool onTheFly)
70{
71 if (mEffects.size() >= MAX_EFFECTS_IN_CHAIN)
72 return;
73
74 IAudioEffect* effect = TheSynth->GetEffectFactory()->MakeEffect(type);
75 if (effect == nullptr)
76 throw UnknownEffectTypeException();
77 assert(effect->GetType() == type); //make sure things are named the same in code
78 std::vector<std::string> otherEffectNames;
79 for (auto* e : mEffects)
80 otherEffectNames.push_back(e->Name());
81 std::string name = GetUniqueName(desiredName, otherEffectNames);
82 effect->SetName(name.c_str());
83 effect->SetTypeName(type, kModuleCategory_Processor);
84 effect->SetParent(this);
85 effect->CreateUIControls();
86 if (onTheFly)
87 {
88 ofxJSONElement empty;
89 effect->LoadLayoutBase(empty);
90 effect->SetUpFromSaveDataBase();
91 }
92
93 if (mInitialized) //if we've already been initialized, call init on this
94 effect->Init();
95
96 mEffectMutex.lock();
97 mEffects.push_back(effect);
98 mEffectMutex.unlock();
99 AddChild(effect);
100
101 float* dryWet = &(mDryWetLevels[mEffects.size() - 1]);
102 *dryWet = 1;
103
104 EffectControls controls;
105 controls.mMoveLeftButton = new ClickButton(this, "<", 0, 0);
106 controls.mMoveLeftButton->SetCableTargetable(false);
107 controls.mMoveRightButton = new ClickButton(this, ">", 0, 0);
108 controls.mMoveRightButton->SetCableTargetable(false);
109 controls.mDeleteButton = new ClickButton(this, "x", 0, 0);
110 controls.mDeleteButton->SetCableTargetable(false);
111 controls.mDryWetSlider = new FloatSlider(this, ("mix" + ofToString(mEffects.size() - 1)).c_str(), 0, 0, 60, 13, dryWet, 0, 1, 2);
112 controls.mPush2DisplayEffectButton = new ClickButton(this, ("edit " + name).c_str(), 0, 0);
113 controls.mPush2DisplayEffectButton->SetShowing(false);
114 controls.mPush2DisplayEffectButton->SetCableTargetable(false);
115 mEffectControls.push_back(controls);
116}
117
118void EffectChain::Process(double time)
119{

Callers 2

ButtonClickedMethod · 0.80
SpawnModuleOnTheFlyMethod · 0.80

Calls 15

GetUniqueNameFunction · 0.85
ofToStringFunction · 0.85
sizeMethod · 0.80
MakeEffectMethod · 0.80
GetEffectFactoryMethod · 0.80
SetTypeNameMethod · 0.80
SetParentMethod · 0.80
LoadLayoutBaseMethod · 0.80
SetUpFromSaveDataBaseMethod · 0.80
SetCableTargetableMethod · 0.80
GetTypeMethod · 0.45

Tested by

no test coverage detected