==============================================================================
| 951 | |
| 952 | //============================================================================== |
| 953 | void FireAudioProcessor::getStateInformation(juce::MemoryBlock& destData) |
| 954 | { |
| 955 | // You should use this method to store your parameters in the memory block. |
| 956 | // You could do that either as raw data, or use the XML or ValueTree classes |
| 957 | // as intermediaries to make it easy to save and load complex data. |
| 958 | |
| 959 | int xmlIndex = 0; |
| 960 | juce::XmlElement xmlState { "state" }; |
| 961 | |
| 962 | // 1. save treestate (parameters) |
| 963 | auto state = treeState.copyState(); |
| 964 | std::unique_ptr<juce::XmlElement> treeStateXml(state.createXml()); |
| 965 | xmlState.insertChildElement(treeStateXml.release(), xmlIndex++); |
| 966 | |
| 967 | // 2. save current preset ID, width and height |
| 968 | std::unique_ptr<juce::XmlElement> currentStateXml { new juce::XmlElement { "otherState" } }; |
| 969 | currentStateXml->setAttribute("currentPresetID", statePresets.getCurrentPresetId()); |
| 970 | currentStateXml->setAttribute("editorWidth", editorWidth); |
| 971 | currentStateXml->setAttribute("editorHeight", editorHeight); |
| 972 | |
| 973 | xmlState.insertChildElement(currentStateXml.release(), xmlIndex++); |
| 974 | |
| 975 | // 3. Save LFO Shapes |
| 976 | auto* lfoState = new juce::XmlElement("LFO_STATE"); |
| 977 | auto& lfoDataToSave = lfoManager->getLfoData(); |
| 978 | for (int i = 0; i < lfoDataToSave.size(); ++i) |
| 979 | { |
| 980 | auto* lfoXml = new juce::XmlElement("LFO"); |
| 981 | lfoXml->setAttribute("index", i); |
| 982 | lfoDataToSave[i].writeToXml(*lfoXml); |
| 983 | lfoState->addChildElement(lfoXml); |
| 984 | } |
| 985 | xmlState.insertChildElement(lfoState, xmlIndex++); |
| 986 | |
| 987 | // 4. Save Modulation Matrix Routings |
| 988 | auto* modMatrixState = new juce::XmlElement("MODULATION_STATE"); |
| 989 | for (const auto& routing : lfoManager->getModulationRoutings()) // Get from manager |
| 990 | { |
| 991 | auto* routingXml = new juce::XmlElement("ROUTING"); |
| 992 | routing.writeToXml(*routingXml); |
| 993 | modMatrixState->addChildElement(routingXml); |
| 994 | } |
| 995 | xmlState.insertChildElement(modMatrixState, xmlIndex++); |
| 996 | |
| 997 | copyXmlToBinary(xmlState, destData); |
| 998 | } |
| 999 | |
| 1000 | void FireAudioProcessor::setStateInformation(const void* data, int sizeInBytes) |
| 1001 | { |
nothing calls this directly
no test coverage detected