Support JUCE 5.4.3 AND 5.4.4
JUCE 5.4.4 breaks a lot of code, because several APIs that used to use plain pointer types have been converted to std::unique_ptr. Fortunately, this only affects the OB-Xd code in two spots. I've done a bit of fancy footwork with #define/#if to allow the code to compile cleanly with either version, but this kind of thing shouldn't be carried on forever. I'd strongly recommend switching to JUCE 5.4.4 as soon as it's practical, and then getting rid of all this #if business.
This commit is contained in:
parent
ae76e125dc
commit
1e54c4d37d
1 changed files with 80 additions and 55 deletions
|
@ -11,6 +11,9 @@ It contains the basic startup code for a Juce application.
|
||||||
#include "PluginEditor.h"
|
#include "PluginEditor.h"
|
||||||
#include "Engine/Params.h"
|
#include "Engine/Params.h"
|
||||||
|
|
||||||
|
// Compare JUCE_VERSION against this to check for JUCE 5.4.3 and earlier
|
||||||
|
#define JUCE_543 328707
|
||||||
|
|
||||||
//only sse2 version on windows
|
//only sse2 version on windows
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
#define __SSE2__
|
#define __SSE2__
|
||||||
|
@ -724,7 +727,7 @@ AudioProcessorEditor* ObxdAudioProcessor::createEditor()
|
||||||
}
|
}
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
void ObxdAudioProcessor::getStateInformation (MemoryBlock& destData)
|
void ObxdAudioProcessor::getStateInformation(MemoryBlock& destData)
|
||||||
{
|
{
|
||||||
XmlElement xmlState = XmlElement("Datsounds");
|
XmlElement xmlState = XmlElement("Datsounds");
|
||||||
xmlState.setAttribute(S("currentProgram"), programs.currentProgram);
|
xmlState.setAttribute(S("currentProgram"), programs.currentProgram);
|
||||||
|
@ -734,6 +737,7 @@ void ObxdAudioProcessor::getStateInformation (MemoryBlock& destData)
|
||||||
{
|
{
|
||||||
XmlElement* xpr = new XmlElement("program");
|
XmlElement* xpr = new XmlElement("program");
|
||||||
xpr->setAttribute(S("programName"), programs.programs[i].name);
|
xpr->setAttribute(S("programName"), programs.programs[i].name);
|
||||||
|
xpr->setAttribute(S("voiceCount"), Motherboard::MAX_VOICES);
|
||||||
|
|
||||||
for (int k = 0; k < PARAM_COUNT; ++k)
|
for (int k = 0; k < PARAM_COUNT; ++k)
|
||||||
{
|
{
|
||||||
|
@ -750,12 +754,32 @@ void ObxdAudioProcessor::getStateInformation (MemoryBlock& destData)
|
||||||
xmlState.setAttribute(String(i), bindings.controllers[i]);
|
xmlState.setAttribute(String(i), bindings.controllers[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
copyXmlToBinary(xmlState,destData);
|
copyXmlToBinary(xmlState, destData);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObxdAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
|
void ObxdAudioProcessor::getCurrentProgramStateInformation(MemoryBlock& destData)
|
||||||
{
|
{
|
||||||
if (XmlElement* const xmlState = getXmlFromBinary(data,sizeInBytes))
|
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 JUCE_VERSION <= JUCE_543
|
||||||
|
XmlElement * const xmlState = getXmlFromBinary(data, sizeInBytes);
|
||||||
|
#else
|
||||||
|
std::unique_ptr<XmlElement> xmlState = getXmlFromBinary(data, sizeInBytes);
|
||||||
|
#endif
|
||||||
|
if (xmlState)
|
||||||
{
|
{
|
||||||
XmlElement* xprogs = xmlState->getFirstChildElement();
|
XmlElement* xprogs = xmlState->getFirstChildElement();
|
||||||
if (xprogs->hasTagName(S("programs")))
|
if (xprogs->hasTagName(S("programs")))
|
||||||
|
@ -763,11 +787,14 @@ void ObxdAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
|
||||||
int i = 0;
|
int i = 0;
|
||||||
forEachXmlChildElement(*xprogs, e)
|
forEachXmlChildElement(*xprogs, e)
|
||||||
{
|
{
|
||||||
|
bool newFormat = e->hasAttribute("voiceCount");
|
||||||
programs.programs[i].setDefaultValues();
|
programs.programs[i].setDefaultValues();
|
||||||
|
|
||||||
for (int k = 0; k < PARAM_COUNT; ++k)
|
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"));
|
programs.programs[i].name = e->getStringAttribute(S("programName"), S("Default"));
|
||||||
|
@ -783,43 +810,41 @@ void ObxdAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
|
||||||
|
|
||||||
setCurrentProgram(xmlState->getIntAttribute(S("currentProgram"), 0));
|
setCurrentProgram(xmlState->getIntAttribute(S("currentProgram"), 0));
|
||||||
|
|
||||||
|
#if JUCE_VERSION <= JUCE_543
|
||||||
delete xmlState;
|
delete xmlState;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void ObxdAudioProcessor::setCurrentProgramStateInformation(const void* data,int sizeInBytes)
|
void ObxdAudioProcessor::setCurrentProgramStateInformation(const void* data, int sizeInBytes)
|
||||||
{
|
{
|
||||||
if (XmlElement* const e = getXmlFromBinary(data, sizeInBytes))
|
#if JUCE_VERSION <= JUCE_543
|
||||||
|
XmlElement * const e = getXmlFromBinary(data, sizeInBytes);
|
||||||
|
#else
|
||||||
|
std::unique_ptr<XmlElement> e = getXmlFromBinary(data, sizeInBytes);
|
||||||
|
#endif
|
||||||
|
if (e)
|
||||||
{
|
{
|
||||||
programs.currentProgramPtr->setDefaultValues();
|
programs.currentProgramPtr->setDefaultValues();
|
||||||
|
|
||||||
|
bool newFormat = e->hasAttribute("voiceCount");
|
||||||
for (int k = 0; k < PARAM_COUNT; ++k)
|
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"));
|
programs.currentProgramPtr->name = e->getStringAttribute(S("programName"), S("Default"));
|
||||||
|
|
||||||
setCurrentProgram(programs.currentProgram);
|
setCurrentProgram(programs.currentProgram);
|
||||||
|
|
||||||
|
#if JUCE_VERSION <= JUCE_543
|
||||||
delete e;
|
delete e;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
bool ObxdAudioProcessor::loadFromFXBFile(const File& fxbFile)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue