コード例 #1
0
void MLPluginProcessor::loadStateFromFile(const File& f)
{
	if (f.exists())
	{
		String extension = f.getFileExtension();
		if (extension == ".mlpreset")
		{
			// load cross-platform mlpreset file.
			ScopedPointer<XmlDocument> stateToLoad (new XmlDocument(f));
			if (stateToLoad != NULL)
			{
				XmlElementPtr pDocElem (stateToLoad->getDocumentElement(true));
				setStateFromXML(*pDocElem, false);
				mpLatestStateLoaded = pDocElem;
			}
		}        
		else if (extension == ".aupreset")
		{
			// tell AU wrapper to load AU-compatible .aupreset file.
			sendMessageToMLListener (MLAudioProcessorListener::kLoad, f);
		}
	}	
}
コード例 #2
0
void MLPluginProcessor::setPatchStateFromText (const String& stateStr)
{
	const String& trimmedState = stateStr.trimStart();
	if(trimmedState[0] == '{')
	{
		// assume JSON
		cJSON* root = cJSON_Parse(trimmedState.toUTF8());
		if(root)
		{
			mpPatchState->setStateFromJSON(root);
			cJSON_Delete(root);
		}
		else
		{
			debug() << "MLPluginProcessor::setPatchStateFromText: couldn't create JSON object!\n";
		}
	}
	else if (trimmedState[0] == '<')
	{
		// assume XML
		ScopedPointer<XmlDocument> stateToLoad (new XmlDocument(trimmedState));
		if (stateToLoad != NULL)
		{
			XmlElementPtr pDocElem (stateToLoad->getDocumentElement(true));
			setStateFromXML(*pDocElem, false);
		}
		else
		{
			debug() << "MLPluginProcessor::setPatchStateFromText: couldn't create XML object!\n";
		}
	}
	else
	{
		debug() << "MLPluginProcessor::setPatchStateFromText: unknown format for .mlpreset file!\n";
	}
	updateChangedProperties();
}