| 182 | } |
| 183 | |
| 184 | void ProcessorWithScriptingContent::controlCallback(ScriptingApi::Content::ScriptComponent *component, var controllerValue) |
| 185 | { |
| 186 | if (thisAsJavascriptProcessor == nullptr) |
| 187 | thisAsJavascriptProcessor = dynamic_cast<JavascriptProcessor*>(this); |
| 188 | |
| 189 | Processor* thisAsProcessor = dynamic_cast<Processor*>(this); |
| 190 | |
| 191 | |
| 192 | #if USE_FRONTEND |
| 193 | |
| 194 | if (component->isAutomatable() && |
| 195 | component->getScriptObjectProperty(ScriptingApi::Content::ScriptComponent::Properties::isPluginParameter) && |
| 196 | getMainController_()->getPluginParameterUpdateState()) |
| 197 | { |
| 198 | float newValue = (float)controllerValue; |
| 199 | FloatSanitizers::sanitizeFloatNumber(newValue); |
| 200 | |
| 201 | dynamic_cast<PluginParameterAudioProcessor*>(getMainController_())->setScriptedPluginParameter(component->getName(), newValue); |
| 202 | } |
| 203 | |
| 204 | #endif |
| 205 | |
| 206 | if (component->isConnectedToMacroControll()) |
| 207 | { |
| 208 | |
| 209 | float v = jlimit<float>(0.0, 127.0, (float)component->getValue()); |
| 210 | |
| 211 | component->setMacroRecursionProtection(true); |
| 212 | |
| 213 | getMainController_()->getMainSynthChain()->setMacroControl(component->getMacroControlIndex(), v, sendNotification); |
| 214 | |
| 215 | component->setMacroRecursionProtection(false); |
| 216 | } |
| 217 | else if (component->isConnectedToProcessor()) |
| 218 | { |
| 219 | float v = (float)controllerValue; |
| 220 | FloatSanitizers::sanitizeFloatNumber(v); |
| 221 | |
| 222 | auto index = component->getConnectedParameterIndex(); |
| 223 | |
| 224 | if (index == -2) // intensity |
| 225 | { |
| 226 | if (auto mod = dynamic_cast<Modulation*>(component->getConnectedProcessor())) |
| 227 | { |
| 228 | mod->setIntensity(v); |
| 229 | BACKEND_ONLY(component->getConnectedProcessor()->sendOtherChangeMessage(dispatch::library::ProcessorChangeEvent::Intensity)); |
| 230 | } |
| 231 | } |
| 232 | else if (index == -3) // bypassed |
| 233 | { |
| 234 | component->getConnectedProcessor()->setBypassed(v > 0.5f, sendNotification); |
| 235 | BACKEND_ONLY(component->getConnectedProcessor()->sendOtherChangeMessage(dispatch::library::ProcessorChangeEvent::Bypassed)); |
| 236 | } |
| 237 | else if (index == -4) // enabled |
| 238 | { |
| 239 | component->getConnectedProcessor()->setBypassed(v < 0.5f, sendNotification); |
| 240 | BACKEND_ONLY(component->getConnectedProcessor()->sendOtherChangeMessage(dispatch::library::ProcessorChangeEvent::Bypassed)); |
| 241 |
no test coverage detected