void JuceDemoPluginAudioProcessor::setStateInformation(const void* data, int sizeInBytes) { // You should use this method to restore your parameters from this memory block, // whose contents will have been created by the getStateInformation() call. // This getXmlFromBinary() helper function retrieves our XML from the binary blob.. ScopedPointer<XmlElement> xmlState(getXmlFromBinary(data, sizeInBytes)); if (xmlState != nullptr) { // make sure that it's actually our type of XML object.. if (xmlState->hasTagName("MYPLUGINSETTINGS")) { // ok, now pull out our parameters.. lastUIWidth = xmlState->getIntAttribute("uiWidth", lastUIWidth); lastUIHeight = xmlState->getIntAttribute("uiHeight", lastUIHeight); wetGain = (float)xmlState->getDoubleAttribute("wetGain", wetGain); delayAmount = (float)xmlState->getDoubleAttribute("delayAmount", delayAmount); delayTime = (float)xmlState->getDoubleAttribute("delayTime", delayTime); delayFeedbackAmount = (float)xmlState->getDoubleAttribute("delayFeedback", delayFeedbackAmount); pan = (float)xmlState->getDoubleAttribute("pan", pan); dryOn = (float)xmlState->getDoubleAttribute("dryOn", dryOn); midSide = (float)xmlState->getDoubleAttribute("midSide", midSide); roomSize = (float)xmlState->getDoubleAttribute("roomSize", roomSize); roomDamp = (float)xmlState->getDoubleAttribute("roomDamp", roomDamp); hpfFreq = (float)xmlState->getDoubleAttribute("hpfFreq", hpfFreq); hpfQ = (float)xmlState->getDoubleAttribute("hpfQ", hpfQ); saturationAmount = (float)xmlState->getDoubleAttribute("saturation",saturationAmount); midOn = (float)xmlState->getDoubleAttribute("midOn",midOn); lpfFreqValue = (float)xmlState->getDoubleAttribute("lpfFreq", lpfFreqValue); lpfQValue = (float)xmlState->getDoubleAttribute("lpfQ", lpfQValue); } } }
// set state, including the view status, from a binary blob stored in host. // void MLPluginProcessor::setStateFromBlob (const void* data, int sizeInBytes) { debug() << "setStateFromBlob: " << sizeInBytes << "bytes of XML data.\n"; XmlElementPtr xmlState(getXmlFromBinary (data, sizeInBytes)); if (xmlState) { bool setViewAttributes = true; setStateFromXML(*xmlState, setViewAttributes); mpLatestStateLoaded = xmlState; } }
void BeatboxVoxAudioProcessor::setStateInformation(const void* data, int sizeInBytes) { // You should use this method to restore your parameters from this memory block, // whose contents will have been created by the getStateInformation() call. std::unique_ptr<XmlElement> xmlState(getXmlFromBinary(data, sizeInBytes)); if (xmlState.get() != nullptr) { if (xmlState->hasTagName(processorState.state.getType())) processorState.state = ValueTree::fromXml(*xmlState); } }
void JuceBoxAudioProcessor::setStateInformation (const void* data, int sizeInBytes) { Logger::writeToLog("- setStateInformation()."); ScopedPointer<XmlElement> xmlState(getXmlFromBinary(data, sizeInBytes)); if (xmlState) { if (xmlState->hasTagName("JuceBox")) { String sampleFilePath = xmlState->getStringAttribute("sampleFile"); Logger::writeToLog("- sampleFile = " + sampleFilePath); sampleFile = sampleFilePath; loadSound(); } } }
//============================================================================= void KawaMidSideAudioProcessor::setStateInformation (const void* data, int sizeInBytes) { ScopedPointer<XmlElement> xmlState( getXmlFromBinary (data, sizeInBytes) ); //========================================================================= if ( xmlState != nullptr ) { if ( xmlState->hasTagName( "kawaMidSide_Parameter" ) ) { bool isMideMode_ = xmlState->getBoolAttribute( "isMidMode", false ); bool isDoubleMode_ = xmlState->getBoolAttribute( "isDoubleLevelMode", false ); //================================================================= setDoubleLevelMode( isDoubleMode_ ); setMidMode( isMideMode_ ); //================================================================= } } //========================================================================= }
// set Processor and Environment states from XML or JSON in binary. // state is in JSON format. XML can be read for backwards compatibility.. // void MLPluginProcessor::setPatchAndEnvStatesFromBinary (const void* data, int sizeInBytes) { // first try getting XML from binary- this will fail if blob is not in XML format XmlElementPtr xmlState(getXmlFromBinary (data, sizeInBytes)); if (xmlState) { bool setViewAttributes = true; setStateFromXML(*xmlState, setViewAttributes); } else { // TODO uncompress here std::string stateStr (static_cast<const char *>(data), sizeInBytes); // trim starting whitespace const char * pStart = stateStr.data(); const char * pTrimmedStart = pStart; while(isspace(*pTrimmedStart) && (pTrimmedStart - pStart < sizeInBytes)) { pTrimmedStart++; } // assume JSON bool OK = true; cJSON* root = cJSON_Parse(pTrimmedStart); if(root) { cJSON* patchState = cJSON_GetObjectItem(root, "patch"); if(patchState) { mpPatchState->setStateFromJSON(patchState); } else { OK = false; } cJSON* environmentState = cJSON_GetObjectItem(root, "environment"); if(environmentState) { mpEnvironmentState->setStateFromJSON(environmentState); } else { OK = false; } cJSON_Delete(root); } if(!OK) { // TODO notify user in release debug() << "MLPluginProcessor::setPatchAndEnvStatesFromBinary: couldn't load JSON!\n"; } } // push state for access by "Revert To saved" mpPatchState->clearStateStack(); mpPatchState->pushStateToStack(); }