static void crashHandler() { if (JUCEApplication::isStandaloneApp()) { MemoryBlock mb (SystemStats::getStackBacktrace().toUTF8(), SystemStats::getStackBacktrace().length()); File::getSpecialLocation(File::currentApplicationFile) .startAsProcess("--crashReport=\"" +File::getSpecialLocation(File::currentApplicationFile).getFullPathName() +"\" --stackTrace=\""+mb.toBase64Encoding() +"\""); } else { const String stackTrace = SystemStats::getStackBacktrace(); File crashFile (File::getSpecialLocation(File::currentApplicationFile).getFileExtension()+".crash"); AlertWindow::showMessageBox (AlertWindow::WarningIcon, "Ctrlr has crashed", "Looks like Ctrlr has crashed, since this is not a standalone instance, we won't do anything.\ A crash log will be written to "+crashFile.getFullPathName() +"\n\n"+stackTrace); crashFile.replaceWithText ("Ctrlr crash at: "+Time::getCurrentTime().toString(true, true, true, true) + "\nStack trace:\n"+stackTrace); } }
StandaloneFilterWindow::~StandaloneFilterWindow() { PropertySet* const globalSettings = getGlobalSettings(); globalSettings->setValue (T("windowX"), getX()); globalSettings->setValue (T("windowY"), getY()); deleteAndZero (optionsButton); if (globalSettings != 0 && deviceManager != 0) { XmlElement* const xml = deviceManager->createStateXml(); globalSettings->setValue (T("audioSetup"), xml); delete xml; } if (globalSettings != 0 && filter != 0) { MemoryBlock data; filter->getStateInformation (data); globalSettings->setValue (T("filterState"), data.toBase64Encoding()); } deleteAndZero (deviceManager); deleteFilter(); }
const String imageToBase64 (const Image &image) { MemoryBlock memoryBlock; MemoryOutputStream memoryStream(memoryBlock,true); PNGImageFormat png; png.writeImageToStream (image, memoryStream); return (memoryBlock.toBase64Encoding()); }
//============================================================================== void WrappedJucePlugin::savePresetToXml(XmlElement* element) { if (instance) { MemoryBlock pluginState; instance->getStateInformation(pluginState); XmlElement* chunk = new XmlElement (T("juceVSTPluginData")); chunk->addTextElement (pluginState.toBase64Encoding ()); element->addChildElement (chunk); } }
static void create_state(struct SoundPlugin *plugin, hash_t *state){ #if JUCE_LINUX const MessageManagerLock mmLock; #endif Data *data = (Data*)plugin->data; AudioPluginInstance *audio_instance = data->audio_instance; // save state { MemoryBlock destData; audio_instance->getStateInformation(destData); if (destData.getSize() > 0){ String stateAsString = destData.toBase64Encoding(); HASH_put_chars(state, "audio_instance_state", stateAsString.toRawUTF8()); } } // save program state { MemoryBlock destData; audio_instance->getCurrentProgramStateInformation(destData); if (destData.getSize() > 0){ String stateAsString = destData.toBase64Encoding(); HASH_put_chars(state, "audio_instance_program_state", stateAsString.toRawUTF8()); } } HASH_put_int(state, "audio_instance_current_program", audio_instance->getCurrentProgram()); HASH_put_int(state, "x_pos", data->x); HASH_put_int(state, "y_pos", data->y); }
//============================================================================== static StringPairArray parseMidiChunk (InputStream& input, int64 size) { const int64 originalPosition = input.getPosition(); MemoryBlock midiBlock; input.readIntoMemoryBlock (midiBlock, (ssize_t) size); MemoryInputStream midiInputStream (midiBlock, false); StringPairArray midiMetadata; MidiFile midiFile; if (midiFile.readFrom (midiInputStream)) { midiMetadata.set (CoreAudioFormat::midiDataBase64, midiBlock.toBase64Encoding()); findTempoEvents (midiFile, midiMetadata); findTimeSigEvents (midiFile, midiMetadata); } input.setPosition (originalPosition + size); return midiMetadata; }
e->setAttribute ("uid", (int) node->nodeId); e->setAttribute ("x", node->properties ["x"].toString()); e->setAttribute ("y", node->properties ["y"].toString()); e->setAttribute ("uiLastX", node->properties ["uiLastX"].toString()); e->setAttribute ("uiLastY", node->properties ["uiLastY"].toString()); PluginDescription pd; plugin->fillInPluginDescription (pd); e->addChildElement (pd.createXml()); XmlElement* state = new XmlElement ("STATE"); MemoryBlock m; node->getProcessor()->getStateInformation (m); state->addTextElement (m.toBase64Encoding()); e->addChildElement (state); return e; } void FilterGraph::createNodeFromXml (const XmlElement& xml) { PluginDescription pd; forEachXmlChildElement (xml, e) { if (pd.loadFromXml (*e)) break; }
XmlElement* PMixDocument::createNodeXml (AudioProcessorGraph::Node* const node) noexcept { AudioPluginInstance* plugin = dynamic_cast <AudioPluginInstance*> (node->getProcessor()); if (plugin == nullptr) { jassertfalse; return nullptr; } XmlElement* e = new XmlElement ("NODE"); e->setAttribute ("uid", (int) node->nodeID); e->setAttribute ("x", node->properties ["x"].toString()); e->setAttribute ("y", node->properties ["y"].toString()); e->setAttribute ("uiLastX", node->properties ["uiLastX"].toString()); e->setAttribute ("uiLastY", node->properties ["uiLastY"].toString()); e->setAttribute ("uiStatus", node->properties ["uiStatus"].toString()); PluginDescription pd; plugin->fillInPluginDescription (pd); if(!InternalPluginFormat::isInternalFormat(pd.name)) { e->setAttribute("colour", node->properties ["colour"].toString()); e->setAttribute ("iposx", node->properties ["iposx"].toString()); e->setAttribute ("iposy", node->properties ["iposy"].toString()); } e->addChildElement (pd.createXml()); XmlElement* state = new XmlElement ("STATE"); MemoryBlock m; node->getProcessor()->getStateInformation (m); state->addTextElement (m.toBase64Encoding()); e->addChildElement (state); if(!InternalPluginFormat::isInternalFormat(pd.name)) { XmlElement* params = new XmlElement ("PARAMS"); Array<var>* paramsArray = node->properties.getVarPointer("params")->getArray(); params->addTextElement("["); for(int i=0;i<paramsArray->size();i++) { var parameterIdx = paramsArray->getReference(i); params->addTextElement(parameterIdx.toString()); if(i != paramsArray->size()-1) params->addTextElement(", "); } params->addTextElement("]"); e->addChildElement(params); Array<var>* presetsArr = node->properties.getVarPointer("presets")->getArray(); for(int i=0;i<presetsArr->size();i++) { XmlElement* presetXML = new XmlElement ("PRESET"); DynamicObject* thePreset = presetsArr->getReference(i).getDynamicObject(); presetXML->setAttribute("name", thePreset->getProperty("name").toString()); presetXML->setAttribute("x", thePreset->getProperty("x").toString()); presetXML->setAttribute("y", thePreset->getProperty("y").toString()); presetXML->setAttribute("radius", thePreset->getProperty("radius").toString()); presetXML->setAttribute("hidden", thePreset->getProperty("hidden").toString()); //presetXML->setAttribute("distance", thePreset->getProperty("distance").toString()); presetXML->setAttribute("coeff", thePreset->getProperty("coeff").toString()); presetXML->setAttribute("uid", thePreset->getProperty("uid").toString()); Array<var>* paramsArray = thePreset->getProperty("state").getArray(); presetXML->addTextElement("["); for(int i=0;i<paramsArray->size();i++) { var parameterIdx = paramsArray->getReference(i); presetXML->addTextElement(parameterIdx.toString()); if(i != paramsArray->size()-1) presetXML->addTextElement(", "); } presetXML->addTextElement("]"); e->addChildElement(presetXML); } } return e; }
const String fileToBase64 (const File &file) { MemoryBlock memoryBlock; file.loadFileAsData (memoryBlock); return (memoryBlock.toBase64Encoding()); }