From d5cf54e76e0b167d7da2f305c67793a4e3c56eaa Mon Sep 17 00:00:00 2001 From: Shane Dunne Date: Sun, 1 Sep 2019 15:01:24 -0400 Subject: [PATCH] Default voice count is 8 To ensure backward-compatibility with older banks, the program format has been updated to include a new "voiceCount" attribute (with value 32). When loading patches, the patch XML is checked, and if it does not include the "voiceCount" attribute, the value of the VOICE_COUNT parameter is scaled by 0.25, i.e., to the range 0-8, instead of the new range 0-32. Newly-saved patches will have the new attribute, and the parameter value will not be scaled when the patch is read in. --- .gitignore | 1 + OB-Xd.jucer | 26 +++++++++++++++++++-- Source/PluginEditor.cpp | 2 +- Source/PluginProcessor.cpp | 46 ++++++++++++++++++++++---------------- 4 files changed, 53 insertions(+), 22 deletions(-) diff --git a/.gitignore b/.gitignore index fbffd30..af48007 100644 --- a/.gitignore +++ b/.gitignore @@ -318,3 +318,4 @@ __pycache__/ *.odx.cs *.xsd.cs *.exe +Source/Images/appIcon.png diff --git a/OB-Xd.jucer b/OB-Xd.jucer index ea27bba..6d4ba21 100644 --- a/OB-Xd.jucer +++ b/OB-Xd.jucer @@ -136,8 +136,7 @@ - + @@ -159,6 +158,28 @@ + + + + + + + + + + + + + + + + + + + + + + @@ -178,5 +199,6 @@ + diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 8615fba..577e01d 100755 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -645,7 +645,7 @@ void ObxdAudioProcessorEditor::mouseUp(const MouseEvent& e) DirectoryIterator it(getFilter()->getSkinFolder(), false, "*", File::findDirectories); while (it.next()) { - skins.addUsingDefaultSort(it.getFile());r + skins.addUsingDefaultSort(it.getFile()); } for (int i = 0; i < skins.size(); ++i) diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index b22f670..8467903 100755 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -734,6 +734,7 @@ void ObxdAudioProcessor::getStateInformation (MemoryBlock& destData) { XmlElement* xpr = new XmlElement("program"); xpr->setAttribute(S("programName"), programs.programs[i].name); + xpr->setAttribute(S("voiceCount"), Motherboard::MAX_VOICES); for (int k = 0; k < PARAM_COUNT; ++k) { @@ -752,10 +753,25 @@ void ObxdAudioProcessor::getStateInformation (MemoryBlock& destData) copyXmlToBinary(xmlState,destData); } -/* + +void ObxdAudioProcessor::getCurrentProgramStateInformation(MemoryBlock& destData) +{ + XmlElement xmlState = XmlElement("Datsounds"); + + for (int k = 0; k < PARAM_COUNT; ++k) + { + xmlState.setAttribute(String(k), programs.currentProgramPtr->values[k]); + } + + xmlState.setAttribute(S("voiceCount"), Motherboard::MAX_VOICES); + xmlState.setAttribute(S("programName"), programs.currentProgramPtr->name); + + copyXmlToBinary(xmlState, destData); +} + void ObxdAudioProcessor::setStateInformation (const void* data, int sizeInBytes) { - if (XmlElement* const xmlState = getXmlFromBinary(data,sizeInBytes)) + if (std::unique_ptr xmlState = getXmlFromBinary(data,sizeInBytes)) { XmlElement* xprogs = xmlState->getFirstChildElement(); if (xprogs->hasTagName(S("programs"))) @@ -763,11 +779,14 @@ void ObxdAudioProcessor::setStateInformation (const void* data, int sizeInBytes) int i = 0; forEachXmlChildElement(*xprogs, e) { + bool newFormat = e->hasAttribute("voiceCount"); programs.programs[i].setDefaultValues(); for (int k = 0; k < PARAM_COUNT; ++k) { - programs.programs[i].values[k] = e->getDoubleAttribute(String(k), programs.programs[i].values[k]); + float value = float(e->getDoubleAttribute(String(k), programs.programs[i].values[k])); + if (!newFormat && k == VOICE_COUNT) value *= 0.25f; + programs.programs[i].values[k] = value; } programs.programs[i].name = e->getStringAttribute(S("programName"), S("Default")); @@ -787,13 +806,16 @@ void ObxdAudioProcessor::setStateInformation (const void* data, int sizeInBytes) void ObxdAudioProcessor::setCurrentProgramStateInformation(const void* data,int sizeInBytes) { - if (XmlElement* const e = getXmlFromBinary(data, sizeInBytes)) + if (std::unique_ptr e = getXmlFromBinary(data, sizeInBytes)) { programs.currentProgramPtr->setDefaultValues(); + bool newFormat = e->hasAttribute("voiceCount"); for (int k = 0; k < PARAM_COUNT; ++k) { - programs.currentProgramPtr->values[k] = e->getDoubleAttribute(String(k), programs.currentProgramPtr->values[k]); + float value = float(e->getDoubleAttribute(String(k), programs.currentProgramPtr->values[k])); + if (!newFormat && k == VOICE_COUNT) value *= 0.25f; + programs.currentProgramPtr->values[k] = value; } programs.currentProgramPtr->name = e->getStringAttribute(S("programName"), S("Default")); @@ -801,20 +823,6 @@ void ObxdAudioProcessor::setCurrentProgramStateInformation(const void* data,int setCurrentProgram(programs.currentProgram); } } -*/ -void ObxdAudioProcessor::getCurrentProgramStateInformation(MemoryBlock& destData) -{ - XmlElement xmlState = XmlElement("Datsounds"); - - for (int k = 0; k < PARAM_COUNT; ++k) - { - xmlState.setAttribute(String(k), programs.currentProgramPtr->values[k]); - } - - xmlState.setAttribute(S("programName"), programs.currentProgramPtr->name); - - copyXmlToBinary(xmlState, destData); -} //============================================================================== bool ObxdAudioProcessor::loadFromFXBFile(const File& fxbFile)