int MLProc::getOutputIndex(const MLSymbol name) { // get index int idx = 0; if (procInfo().hasVariableOutputs()) { // idx = name.getNumber(); // variable outputs are indexed by symbols out1, out2, ... const std::string& str = name.getString(); if (str[0] == 'o') { idx = atoi(&str[3]); } else { /* TEMP compiler issues debug() << "MLProc::getOutputIndex: bad name for variable output index " << str << "!\n"; */ } } else { idx = procInfo().getOutputMap().getIndex(name); } if (!idx) { debug() << "MLProc::getOutputIndex: null output index!\n"; } return idx; }
const String MLPluginProcessor::getParameterName (int index) { MLSymbol nameSym; const int p = mEngine.getPublishedParams(); if (index < mNumParameters) { if (p == 0) // doc has been scanned but not built { nameSym = MLSymbol("param").withFinalNumber(index); } else { // graph has been built nameSym = mEngine.getParamPtr(index)->getAlias(); //debug() << "getParameterName: " << index << " is " << nameSym.getString().c_str() << ".\n"; } } return (String(nameSym.getString().c_str())); }
bool MLSymbol::endsWith (const MLSymbol b) const { const std::string& strA = getString(); const char* pa = strA.c_str(); const int aLen = strA.length(); const std::string& strB = b.getString(); const char* pb = strB.c_str(); const int bLen = strB.length(); if(bLen > aLen) return false; for(int i=bLen - 1; i>=0; --i) { if(pa[i + aLen - bLen] != pb[i]) return false; } return true; }
bool MLSymbol::beginsWith (const MLSymbol b) const { const std::string& strA = getString(); const char* pa = strA.c_str(); const int aLen = strA.length(); const std::string& strB = b.getString(); const char* pb = strB.c_str(); const int bLen = strB.length(); if(bLen > aLen) return false; for(int i=0; i<bLen; ++i) { if(pa[i] != pb[i]) return false; } return true; }
int MLProc::getInputIndex(const MLSymbol name) { // get index int idx = 0; if (procInfo().hasVariableInputs()) { idx = name.getFinalNumber(); } else { // will be > 0 for valid names, otherwise 0 idx = procInfo().getInputMap().getIndex(name); } if (!idx) { debug() << "MLProc::getInputIndex: proc " << getName() << " has no input " << name << "\n"; } return idx; }
const String MLPluginProcessor::symbolToXMLAttr(const MLSymbol sym) { std::string nameCopy = sym.getString(); unsigned len = nameCopy.length(); for(unsigned c = 0; c < len; ++c) { unsigned char k = nameCopy[c]; if(k == '#') { nameCopy[c] = ':'; } else if(k == '*') { nameCopy[c] = 0xB7; } } return (String(nameCopy.c_str())); }
void MLParamGroupMap::setGroup(const MLSymbol groupSym) { unsigned i = 0; bool found = false; std::string groupStr = groupSym.getString(); for (i=0; i<mGroupVec.size(); i++) { if (!groupStr.compare(mGroupVec[i])) { found = true; break; } } if(!found) { // create new group mGroupVec.push_back(groupStr); } mCurrentGroup = i; }
void SoundplaneModel::doPropertyChangeAction(MLSymbol p, const MLProperty & newVal) { // debug() << "SoundplaneModel::doPropertyChangeAction: " << p << " -> " << newVal << "\n"; int propertyType = newVal.getType(); switch(propertyType) { case MLProperty::kFloatProperty: { float v = newVal.getFloatValue(); if (p.withoutFinalNumber() == MLSymbol("carrier_toggle")) { // toggles changed -- mute carriers unsigned long mask = 0; for(int i=0; i<32; ++i) { MLSymbol tSym = MLSymbol("carrier_toggle").withFinalNumber(i); bool on = (int)(getFloatProperty(tSym)); mask = mask | (on << i); } mCarriersMask = mask; mCarrierMaskDirty = true; // trigger carriers set in a second or so } else if (p == "all_toggle") { bool on = (bool)(v); for(int i=0; i<32; ++i) { MLSymbol tSym = MLSymbol("carrier_toggle").withFinalNumber(i); setProperty(tSym, on); } mCarriersMask = on ? ~0 : 0; mCarrierMaskDirty = true; // trigger carriers set in a second or so } else if (p == "max_touches") { mTracker.setMaxTouches(v); mMIDIOutput.setMaxTouches(v); mOSCOutput.setMaxTouches(v); } else if (p == "lopass") { mTracker.setLopass(v); } else if (p == "z_thresh") { mTracker.setThresh(v); } else if (p == "z_max") { mTracker.setMaxForce(v); } else if (p == "z_curve") { mTracker.setForceCurve(v); } else if (p == "snap") { sendParametersToZones(); } else if (p == "vibrato") { sendParametersToZones(); } else if (p == "lock") { sendParametersToZones(); } else if (p == "data_freq_midi") { // TODO attribute mMIDIOutput.setDataFreq(v); } else if (p == "data_freq_osc") { // TODO attribute mOSCOutput.setDataFreq(v); } else if (p == "midi_active") { mMIDIOutput.setActive(bool(v)); } else if (p == "midi_multi_chan") { mMIDIOutput.setMultiChannel(bool(v)); } else if (p == "midi_start_chan") { mMIDIOutput.setStartChannel(int(v)); } else if (p == "midi_pressure_active") { mMIDIOutput.setPressureActive(bool(v)); } else if (p == "osc_active") { bool b = v; mOSCOutput.setActive(b); listenToOSC(b ? kDefaultUDPReceivePort : 0); } else if (p == "osc_send_matrix") { bool b = v; mSendMatrixData = b; } else if (p == "t_thresh") { mTracker.setTemplateThresh(v); } else if (p == "bg_filter") { mTracker.setBackgroundFilter(v); } else if (p == "quantize") { bool b = v; mTracker.setQuantize(b); sendParametersToZones(); } else if (p == "rotate") { bool b = v; mTracker.setRotate(b); } else if (p == "retrig") { mMIDIOutput.setRetrig(bool(v)); sendParametersToZones(); } else if (p == "hysteresis") { mMIDIOutput.setHysteresis(v); sendParametersToZones(); } else if (p == "transpose") { sendParametersToZones(); } else if (p == "bend_range") { mMIDIOutput.setBendRange(v); sendParametersToZones(); } else if (p == "debug_pause") { debug().setActive(!bool(v)); } else if (p == "kyma_poll") { mMIDIOutput.setKymaPoll(bool(v)); } } break; case MLProperty::kStringProperty: { const std::string& str = newVal.getStringValue(); if (p == "viewmode") { // nothing to do for Model } else if (p == "midi_device") { mMIDIOutput.setDevice(str); } else if (p == "zone_JSON") { loadZonesFromString(str); } } break; case MLProperty::kSignalProperty: { const MLSignal& sig = newVal.getSignalValue(); if(p == MLSymbol("carriers")) { // get carriers from signal assert(sig.getSize() == kSoundplaneSensorWidth); for(int i=0; i<kSoundplaneSensorWidth; ++i) { mCarriers[i] = sig[i]; } mNeedsCarriersSet = true; } if(p == MLSymbol("tracker_calibration")) { mTracker.setCalibration(sig); } if(p == MLSymbol("tracker_normalize")) { mTracker.setNormalizeMap(sig); } } break; default: break; } }