Пример #1
0
String MLPluginProcessor::getStateAsText ()
{
    // create an outer XML element.
	ScopedPointer<XmlElement> xmlProgram (new XmlElement(JucePlugin_Name));
	getStateAsXML(*xmlProgram);
	
	return xmlProgram->createDocument (String::empty, true, false);
}
Пример #2
0
var AudioModule::getJSONData()
{
	var data = Module::getJSONData();

	ScopedPointer<XmlElement> xmlData = am.createStateXml();
	if (xmlData != nullptr)
	{
		data.getDynamicObject()->setProperty("audioSettings", xmlData->createDocument("", true, false));
	}

	return data;
}
void CtrlrEditor::performShowKeyboardMappingDialog(const int menuItemID)
{
	ScopedPointer <KeyMappingEditorComponent> keys (new KeyMappingEditorComponent (*owner.getCommandManager().getKeyMappings(), true));
	owner.getWindowManager().showModalDialog ("Keyboard mapping", keys, true, this);

	ScopedPointer <XmlElement> keysXml (owner.getCommandManager().getKeyMappings()->createXml (true));

	if (keysXml)
	{
		owner.setProperty (Ids::ctrlrKeyboardMapping, keysXml->createDocument(""));
	}
}
Пример #4
0
void CtrlrPanelUtilities::reloadContent()
{
    if ((owner.isVisible() && owner.getSelection()->getNumSelected() == 0) || owner.getSelection()->getNumSelected() > 1)
	{
		ScopedPointer <XmlElement> xml (owner.getOwner().getPanelTree().createXml());
		if (xml)
		{
			codeDocument.replaceAllContent (xml->createDocument(String::empty));
		}
	}
	else if (owner.isVisible() && owner.getSelection()->getNumSelected() == 1)
	{
		CtrlrComponent *c =  owner.getSelection()->getSelectedItem(0);
		if (c)
		{
			ScopedPointer <XmlElement> xml (c->getOwner().getModulatorTree().createXml());
			String doc = xml->createDocument(String::empty);
			if (doc.length() <= 8192)
			{
				codeDocument.replaceAllContent (doc);
			}
		}
	}
}
Пример #5
0
void PluginProcessor::setStateInformation(const void* data, int sizeInBytes)
{
    // Restore parameters from memory block whose contents will have been 
    // created by the getStateInformation() call.
    ScopedPointer<XmlElement> root = getXmlFromBinary(data, sizeInBytes);

	DBG("PluginProcessor::getStateInformation - Retrieving XML: " + root->createDocument(""));

    if (root)
    {
        // Squirrel this data away, in case we need to reload it, e.g. after
        // recreating the device parameters
        if (root->getChildByName("parametervalues"))
        {
            scopeSync->getParameterController()->storeParameterValues(*(root->getChildByName("parametervalues")));
            scopeSync->getParameterController()->restoreParameterValues();
        }
        
        if (root->getChildByName("configurationfilepath"))
        {
            String configurationFilePath = root->getChildByName("configurationfilepath")->getAllSubText();

            scopeSync->changeConfiguration(configurationFilePath);
        }

		if (root->getChildByName("oscuid"))
        {
            int oscUID = root->getChildByName("oscuid")->getAllSubText().getIntValue();

            scopeSync->getParameterController()->getParameterByScopeCode("osc")->setUIValue(static_cast<float>(oscUID));
        }
    }
    else
    {
        DBG("PluginProcessor::setStateInformation - Could not restore XML");
    }
}
Пример #6
0
void HisePlayerExporter::run()
{
	ValueTree metadata("Info");

	ProjectHandler* handler = &GET_PROJECT_HANDLER(chainToExport);

	metadata.setProperty(Identifier("Name"), SettingWindows::getSettingValue((int)SettingWindows::ProjectSettingWindow::Attributes::Name, handler), nullptr);
	metadata.setProperty(Identifier("Version"), SettingWindows::getSettingValue((int)SettingWindows::ProjectSettingWindow::Attributes::Version, handler), nullptr);
	metadata.setProperty(Identifier("Company"), SettingWindows::getSettingValue((int)SettingWindows::UserSettingWindow::Attributes::Company, handler), nullptr);
	metadata.setProperty(Identifier("CompanyWebsite"), SettingWindows::getSettingValue((int)SettingWindows::UserSettingWindow::Attributes::CompanyURL, handler), nullptr);

	ValueTree library("LibraryData");

	if (threadShouldExit()) return;

	setStatusMessage("Exporting Preset");
	setProgress(0.0);
	library.addChild(exportPresetFile(), -1, nullptr);

	if (threadShouldExit()) return;

	setStatusMessage("Exporting Embedded Files");
	setProgress(1.0 / 7.0);
	library.addChild(exportEmbeddedFiles(true), -1, nullptr);
	
	if (threadShouldExit()) return;

	setStatusMessage("Exporting User Preset Files");
	setProgress(2.0 / 7.0);
	library.addChild(exportUserPresetFiles(), -1, nullptr);
	
	if (threadShouldExit()) return;

	setStatusMessage("Exporting Audio Files");
	setProgress(3.0 / 7.0);
	library.addChild(exportReferencedAudioFiles(), -1, nullptr);
	
	if (threadShouldExit()) return;

	setStatusMessage("Exporting Image Files");
	setProgress(4.0 / 7.0);
	library.addChild(exportReferencedImageFiles(), -1, nullptr);

	if (threadShouldExit()) return;

	setStatusMessage("Compressing Data");
	setProgress(5.0 / 7.0);

	ValueTree collection("HisePlayerLibrary");

	ScopedPointer<XmlElement> metaXml = metadata.createXml();

	collection.setProperty(Identifier("Info"), metaXml->createDocument("", true, false), nullptr);
	var compressedData = PresetHandler::writeValueTreeToMemoryBlock(library, true);
	
	collection.setProperty(Identifier("Data"), compressedData, nullptr);

	setStatusMessage("Writing File");
	setProgress(6.0 / 7.0);
	PresetHandler::writeValueTreeAsFile(collection, libraryFile.getFullPathName(), false);


	if (threadShouldExit()) return;
}
Пример #7
0
//==============================================================================
void JucerDocument::fillInGeneratedCode (GeneratedCode& code) const
{
    code.className = className;
    code.componentName = componentName;
    code.parentClasses = parentClasses;
    code.constructorParams = constructorParams;
    code.initialisers.addLines (variableInitialisers);

    if (! componentName.isEmpty())
        code.constructorCode << "setName (" + quotedString (componentName, false) + ");\n";

    // call these now, just to make sure they're the first two methods in the list.
    code.getCallbackCode (String::empty, "void", "paint (Graphics& g)", false)
        << "//[UserPrePaint] Add your own custom painting code here..\n//[/UserPrePaint]\n\n";

    code.getCallbackCode (String::empty, "void", "resized()", false)
        << "//[UserPreResize] Add your own custom resize code here..\n//[/UserPreResize]\n\n";

    if (ComponentLayout* l = getComponentLayout())
        l->fillInGeneratedCode (code);

    fillInPaintCode (code);

    ScopedPointer<XmlElement> e (createXml());
    jassert (e != nullptr);
    code.jucerMetadata = e->createDocument ("", false, false);

    resources.fillInGeneratedCode (code);

    code.constructorCode
        << "\n//[UserPreSize]\n"
           "//[/UserPreSize]\n";

    if (initialWidth > 0 || initialHeight > 0)
        code.constructorCode << "\nsetSize (" << initialWidth << ", " << initialHeight << ");\n";

    code.getCallbackCode (String::empty, "void", "paint (Graphics& g)", false)
        << "//[UserPaint] Add your own custom painting code here..\n//[/UserPaint]";

    code.getCallbackCode (String::empty, "void", "resized()", false)
        << "//[UserResized] Add your own custom resize handling here..\n//[/UserResized]";

    // add optional methods
    StringArray baseClasses, returnValues, methods, initialContents;
    getOptionalMethods (baseClasses, returnValues, methods, initialContents);

    for (int i = 0; i < methods.size(); ++i)
    {
        if (isOptionalMethodEnabled (methods[i]))
        {
            String baseClassToAdd (baseClasses[i]);

            if (baseClassToAdd == "Component" || baseClassToAdd == "Button")
                baseClassToAdd.clear();

            String& s = code.getCallbackCode (baseClassToAdd, returnValues[i], methods[i], false);

            if (! s.contains ("//["))
            {
                String userCommentTag ("UserCode_");
                userCommentTag += methods[i].upToFirstOccurrenceOf ("(", false, false).trim();

                s << "\n//[" << userCommentTag << "] -- Add your code here...\n"
                  << initialContents[i];

                if (initialContents[i].isNotEmpty() && ! initialContents[i].endsWithChar ('\n'))
                    s << '\n';

                s << "//[/" << userCommentTag << "]\n";
            }
        }
    }
}
Пример #8
0
static String valueTreeToString (const ValueTree& v)
{
    const ScopedPointer<XmlElement> xml (v.createXml());
    return xml != nullptr ? xml->createDocument ("", true, false) : String();
}
Пример #9
0
void SampleEditHandler::SampleEditingActions::createMultimicSampleMap(SampleEditHandler* handler)
{
	const String multimicTokens = PresetHandler::getCustomName("Multimic Tokens", "Enter a semicolon separated list of all mic position tokens starting with the existing mic position");

	auto list = StringArray::fromTokens(multimicTokens, ";", "\"");

	if (list.size() == 0)
		return;

	auto firstToken = list[0];

	String listString = "\n";

	for (auto l : list)
		listString << l << "\n";

	if (PresetHandler::showYesNoWindow("Confirm multimic tokens", "You have specified these tokens:" + listString + "\nPress OK to create a multimic samplemap with these mic positions"))
	{
		ValueTree v = handler->getSampler()->getSampleMap()->exportAsValueTree();

		for (int i = 0; i < v.getNumChildren(); i++)
		{
			auto sample = v.getChild(i);

			if (sample.getNumChildren() != 0)
			{
				PresetHandler::showMessageWindow("Already a multimic samplemap", "The samplemap has already multimics", PresetHandler::IconType::Error);
				return;
			}

			auto filename = sample.getProperty("FileName").toString();

			if (!filename.contains(firstToken))
			{
				PresetHandler::showMessageWindow("Wrong first mic position", "You have to specify the current mic position as first mic position.\nSample: " + filename, PresetHandler::IconType::Error);
				return;
			}

			sample.removeProperty("FileName", nullptr);

			for (auto token : list)
			{
				auto fChild = ValueTree("file");
				fChild.setProperty("FileName", filename.replace(firstToken, token, false), nullptr);
				sample.addChild(fChild, -1, nullptr);
			}
		}

		PresetHandler::showMessageWindow("Merge successful", "Press OK to choose a location for the multimic sample map");

		auto sampleMapDirectory = GET_PROJECT_HANDLER(handler->getSampler()).getSubDirectory(ProjectHandler::SubDirectories::SampleMaps);

		FileChooser fc("Save multimic Samplemap", sampleMapDirectory, "*.xml", true);

		v.setProperty("MicPositions", multimicTokens, nullptr);

		if (fc.browseForFileToSave(true))
		{
			auto f = fc.getResult();

			auto path = f.getRelativePathFrom(sampleMapDirectory).upToFirstOccurrenceOf(".xml", false, false).replace("\\", "/");

			v.setProperty("ID", path, nullptr);

			ScopedPointer<XmlElement> xml = v.createXml();
			f.replaceWithText(xml->createDocument(""));
		}
	}
}