From ea4397907fd60c7f09e00e68741d510a82455ef2 Mon Sep 17 00:00:00 2001 From: jens Date: Fri, 28 Apr 2023 14:08:59 +0200 Subject: [PATCH] - added load of fxb through GUI - added load of fxp through GUI --- Source/JaySynthAudioProcessorEditor.cpp | 12 ++-- Source/PluginProcessor.cpp | 76 ++++++++++++------------- Source/PluginProcessor.h | 1 + 3 files changed, 45 insertions(+), 44 deletions(-) diff --git a/Source/JaySynthAudioProcessorEditor.cpp b/Source/JaySynthAudioProcessorEditor.cpp index b1d0016..074ca4a 100644 --- a/Source/JaySynthAudioProcessorEditor.cpp +++ b/Source/JaySynthAudioProcessorEditor.cpp @@ -4931,7 +4931,8 @@ void JaySynthAudioProcessorEditor::buttonClicked (Button* buttonThatWasClicked) if (buttonThatWasClicked == m_button_bank_load) { - FileChooser fc("Load bank"); + String filePatterns("*.fxb;*.xml"); + FileChooser fc("Load bank", File::nonexistent, filePatterns, false); if (fc.browseForFileToOpen()) { File const &file = fc.getResult(); @@ -4940,7 +4941,8 @@ void JaySynthAudioProcessorEditor::buttonClicked (Button* buttonThatWasClicked) } else if (buttonThatWasClicked == m_button_bank_save) { - FileChooser fc("Save bank"); + String filePatterns("*.fxb;*.xml"); + FileChooser fc("Save bank", File::nonexistent, filePatterns, false); if (fc.browseForFileToSave(true)) { File const &file = fc.getResult(); @@ -4949,7 +4951,8 @@ void JaySynthAudioProcessorEditor::buttonClicked (Button* buttonThatWasClicked) } else if (buttonThatWasClicked == m_button_patch_load) { - FileChooser fc("Load patch"); + String filePatterns("*.fxp;*.xml"); + FileChooser fc("Load patch", File::nonexistent, filePatterns, false); if (fc.browseForFileToOpen()) { File const &file = fc.getResult(); @@ -4958,7 +4961,8 @@ void JaySynthAudioProcessorEditor::buttonClicked (Button* buttonThatWasClicked) } else if (buttonThatWasClicked == m_button_patch_save) { - FileChooser fc("Save patch"); + String filePatterns("*.fxp;*.xml"); + FileChooser fc("Save patch", File::nonexistent, filePatterns, false); if (fc.browseForFileToSave(true)) { File const &file = fc.getResult(); diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 0801b12..e357134 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -796,15 +796,6 @@ void JaySynthAudioProcessor::getStateInformation (MemoryBlock& destData) copyXmlToBinary (*xml, tmpBlock); GZIPEnc.write(tmpBlock.getData(), tmpBlock.getSize()); outputStream.flush(); - -#if 0 - { - File pluginfile = File::getSpecialLocation (File::currentExecutableFile).getParentDirectory(); - File file(pluginfile.getFullPathName() + String("/bank.xml")); - file.create(); - xml->writeToFile (/*const File &destinationFile*/file, /*const String &dtdToUse*/"JSYNTH_BANK_FILE" /*, const String &encodingType="UTF-8", int lineWrapLength=60*/); - } -#endif } void JaySynthAudioProcessor::setStateInformation (const void* data, int sizeInBytes) @@ -866,15 +857,6 @@ void JaySynthAudioProcessor::getCurrentProgramStateInformation (MemoryBlock& des // then use this helper function to stuff it into the binary blob and return it.. copyXmlToBinary (*xml, tmpBlock); GZIPEnc.write(tmpBlock.getData(), tmpBlock.getSize()); - -#if 0 -//#ifdef SYNTH_DEBUG - { - File file(String("C:\\Users\\jens\\JaySynth\\") + String(currpatch->getName()) + String(".xml")); - file.create(); - xml->writeToFile (/*const File &destinationFile*/file, /*const String &dtdToUse*/"JSYNTH_PATCH_FILE" /*, const String &encodingType="UTF-8", int lineWrapLength=60*/); - } -#endif } void JaySynthAudioProcessor::setCurrentProgramStateInformation (const void* data, int sizeInBytes) @@ -909,33 +891,30 @@ void JaySynthAudioProcessor::setCurrentProgramStateInformation (const void* data if (xmlState->hasTagName ("JSYNTH_PATCH")) { xml2patch(*xmlState, currpatch); - -#if 0 - // ok, now pull out our parameters.. - currpatch->setName(xmlState->getStringAttribute("NAME")); - for (i=0; i < SYNTH_NUM_PARAMS; i++) - { - value = (synth_float_t) xmlState->getDoubleAttribute (getParameterNameXML(i), currpatch->getParameter(i)); - if (i==SYNTH_PARAM_TUNE) - { - if (value > 400.0) - { - value = 1200*log(value/440)/log(2.0); - } - } - currpatch->setParameter(i, value); - } - ((JaySynthMidiCC*)currpatch->getMidiCC())->importXML(xmlState); -#endif - setCurrentProgram(getCurrentProgram()); + setCurrentProgram(getCurrentProgram()); } - } } void JaySynthAudioProcessor::loadPatch (const File &file, int index) { - String filename(file.getFullPathName()); + String ext = file.getFileExtension(); + if (String(".fxp") == ext) + { + MemoryBlock mem; + file.loadFileAsData(mem); + fxProgram *program = (fxProgram*)mem.getData(); + if (String((const char*)&program->chunkMagic) == String(cMagic)) + { + bool is_regular = String((const char*)&program->fxMagic) == String(fMagic); + bool is_opaque = String((const char*)&program->fxMagic) == String(chunkPresetMagic); + if (is_opaque) + { + uint32_t size = ByteOrder::swap((uint32_t)program->content.data.size); + setCurrentProgramStateInformation(program->content.data.chunk, (int)size); + } + } + } } void JaySynthAudioProcessor::savePatch (const File &file, int index) @@ -943,9 +922,26 @@ void JaySynthAudioProcessor::savePatch (const File &file, int index) String filename(file.getFullPathName()); } +//#include void JaySynthAudioProcessor::loadBank (const File &file) { - String filename(file.getFullPathName()); + String ext = file.getFileExtension(); + if (String(".fxb") == ext) + { + MemoryBlock mem; + file.loadFileAsData(mem); + fxBank *bank = (fxBank*)mem.getData(); + if (String((const char*)&bank->chunkMagic) == String(cMagic)) + { + bool is_regular = String((const char*)&bank->fxMagic) == String(bankMagic); + bool is_opaque = String((const char*)&bank->fxMagic) == String(chunkBankMagic); + if (is_opaque) + { + uint32_t size = ByteOrder::swap((uint32_t)bank->content.data.size); + setStateInformation(bank->content.data.chunk, (int)size); + } + } + } } void JaySynthAudioProcessor::saveBank (const File &file) diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h index 66211fb..add3849 100644 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -16,6 +16,7 @@ #include "JaySynthSound.h" #include "JaySynth.h" #include "JK_MidiClock.h" +#include //============================================================================== /**