MCPcopy Create free account
hub / github.com/christophhart/HISE / setFromCallbackArg

Method setFromCallbackArg

hi_scripting/scripting/api/ScriptingApiObjects.cpp:8674–8771  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8672}
8673
8674void ScriptingObjects::ScriptedMacroHandler::setFromCallbackArg(const var& obj)
8675{
8676 auto checkProperty = [&](const Identifier& id)
8677 {
8678 if (!obj.hasProperty(id))
8679 reportScriptError("macro object needs property " + id.toString());
8680 };
8681
8682 checkProperty(MacroIds::MacroIndex);
8683 checkProperty(MacroIds::Attribute);
8684 checkProperty(MacroIds::Processor);
8685
8686 auto mIndex = (int)obj[MacroIds::MacroIndex];
8687
8688 if (isPositiveAndBelow(mIndex, HISE_NUM_MACROS))
8689 {
8690 auto pId = obj[MacroIds::Processor].toString();
8691
8692 auto isCustomId = (bool)obj[MacroIds::CustomAutomation];
8693
8694 if (auto p = ProcessorHelpers::getFirstProcessorWithName(getScriptProcessor()->getMainController_()->getMainSynthChain(), pId))
8695 {
8696 auto param = obj[MacroIds::Attribute];
8697 int parameterIndex = 0;
8698
8699 String pString;
8700
8701 if (param.isString())
8702 {
8703 pString = param.toString();
8704
8705 if(isCustomId)
8706 {
8707 if(auto ptr = getScriptProcessor()->getMainController_()->getUserPresetHandler().getCustomAutomationData(Identifier(param.toString())))
8708 {
8709 parameterIndex = ptr->index;
8710 }
8711 else
8712 reportScriptError("Can't find custom automation with ID " + param.toString());
8713 }
8714 else
8715 parameterIndex = var(p->getParameterIndexForIdentifier(param.toString()));
8716 }
8717 else
8718 {
8719 parameterIndex = (int)param;
8720
8721 if(isCustomId)
8722 {
8723 if(auto ptr = getScriptProcessor()->getMainController_()->getUserPresetHandler().getCustomAutomationData(parameterIndex))
8724 {
8725 pString = ptr->id;
8726 }
8727 else
8728 reportScriptError("Can't find custom automation with ID " + param.toString());
8729 }
8730 else
8731 {

Callers

nothing calls this directly

Calls 15

isPositiveAndBelowFunction · 0.85
varFunction · 0.85
fromStringFunction · 0.85
getMainController_Method · 0.80
getMacroControlDataMethod · 0.80
getMacroChainMethod · 0.80
setRangeStartMethod · 0.80
setRangeEndMethod · 0.80
StringClass · 0.50
hasPropertyMethod · 0.45
toStringMethod · 0.45
getMainSynthChainMethod · 0.45

Tested by

no test coverage detected