Skip to content

Commit

Permalink
Load preset by drag and drop vvp file on header component
Browse files Browse the repository at this point in the history
  • Loading branch information
VASTDynamics committed Mar 2, 2024
1 parent 2408fae commit 0cb57c7
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 5 deletions.
6 changes: 6 additions & 0 deletions VASTvaporizer/Source/Plugin/VASTAudioProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,12 @@ void VASTAudioProcessor::initializeToDefaults() {
m_parameterState.undoManager->beginNewTransaction(); //start new transcation only here?
}

void VASTAudioProcessor::loadPresetFile(File presetvvpfile) {
VASTPresetElement lPreset{};
std::unique_ptr<juce::XmlDocument> xml(new XmlDocument(presetvvpfile));
bool success = loadPatchXML(xml.get(), false, &lPreset, lPreset.presetarrayindex, lPreset);
}

void VASTAudioProcessor::setCurrentProgram(int index)
{
if (index >= getNumPrograms()) {
Expand Down
1 change: 1 addition & 0 deletions VASTvaporizer/Source/Plugin/VASTAudioProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ class VASTAudioProcessor : public AudioProcessor
bool isUserPatch();
String getUserPatchName();
void savePatchXML(File *selectedFile);
void loadPresetFile(File presetvvpfile);
bool loadPatchXML(XmlDocument* xmlDoc, bool bNameOnly, const VASTPresetElement* preset, int index, VASTPresetElement& resultPresetData);
static String getVSTPath();
static String getVSTPathAlternative();
Expand Down
27 changes: 26 additions & 1 deletion VASTvaporizer/Source/Plugin/VASTHeaderComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,19 @@ void VASTHeaderComponent::buttonClicked (juce::Button* buttonThatWasClicked)
//[/UserbuttonClicked_Post]
}

void VASTHeaderComponent::filesDropped (const juce::StringArray& filenames, int mouseX, int mouseY)
{
//[UserCode_filesDropped] -- Add your code here...
if (filenames.size() < 1)
return;
String filename = filenames[0];
File presetfile = File(filename);
if ((!presetfile.existsAsFile()) || (!presetfile.getFileExtension().equalsIgnoreCase(".vvp")))
return;
myProcessor->loadPresetFile(presetfile);
//[/UserCode_filesDropped]
}

void VASTHeaderComponent::mouseDown (const juce::MouseEvent& e)
{
//[UserCode_mouseDown] -- Add your code here...
Expand Down Expand Up @@ -476,6 +489,16 @@ void VASTHeaderComponent::mouseDown (const juce::MouseEvent& e)


//[MiscUserCode] You can add your own definitions of your custom methods or any other code here...
bool VASTHeaderComponent::isInterestedInFileDrag(const juce::StringArray& filenames)
{
if (filenames.size() < 1)
return false;
String filename = filenames[0];
File presetfile = File(filename);
if ((!presetfile.existsAsFile()) || (!presetfile.getFileExtension().equalsIgnoreCase(".vvp")))
return false;
return true;
}
//[/MiscUserCode]


Expand All @@ -489,12 +512,14 @@ void VASTHeaderComponent::mouseDown (const juce::MouseEvent& e)
BEGIN_JUCER_METADATA

<JUCER_COMPONENT documentType="Component" className="VASTHeaderComponent" componentName=""
parentClasses="public Component" constructorParams="AudioProcessorEditor *editor, AudioProcessor* processor"
parentClasses="public Component, public FileDragAndDropTarget"
constructorParams="AudioProcessorEditor *editor, AudioProcessor* processor"
variableInitialisers="myEditor((VASTAudioProcessorEditor*)editor), myProcessor((VASTAudioProcessor*)processor)"
snapPixels="8" snapActive="1" snapShown="1" overlayOpacity="0.330"
fixedSize="1" initialWidth="325" initialHeight="76">
<METHODS>
<METHOD name="mouseDown (const juce::MouseEvent&amp; e)"/>
<METHOD name="filesDropped (const juce::StringArray&amp; filenames, int mouseX, int mouseY)"/>
</METHODS>
<BACKGROUND backgroundColour="ff323e44">
<RECT pos="0 0 0M 0M" fill="linear: -46.769% -42.105%, 100.923% 105.263%, 0=ff212527, 1=ff0b0b0b"
Expand Down
3 changes: 3 additions & 0 deletions VASTvaporizer/Source/Plugin/VASTHeaderComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
//[/Comments]
*/
class VASTHeaderComponent : public Component,
public FileDragAndDropTarget,
public juce::ComboBox::Listener,
public juce::Button::Listener
{
Expand All @@ -54,12 +55,14 @@ class VASTHeaderComponent : public Component,
VASTComboPreset* getComponentCPreset() {
return c_Preset.get();
}
bool isInterestedInFileDrag(const juce::StringArray& filenames);
//[/UserMethods]

void paint (juce::Graphics& g) override;
void resized() override;
void comboBoxChanged (juce::ComboBox* comboBoxThatHasChanged) override;
void buttonClicked (juce::Button* buttonThatWasClicked) override;
void filesDropped (const juce::StringArray& filenames, int mouseX, int mouseY) override;
void mouseDown (const juce::MouseEvent& e) override;

// Binary resources:
Expand Down
8 changes: 4 additions & 4 deletions build_win.bat
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ rmdir /S /Q cmake-build
for %%t in (%targets%) do (
@echo Building for %%t
if "%%t"=="Win32" (
cmake -B"cmake-build\Win32" -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_VERSION=10.0.22000.0 -G "Visual Studio 16 2019" -T v142 -A Win32 -DCMAKE_PREFIX_PATH=../JUCE/install -DASIO_SDK_LOCATION:STRING=".\asiosdk" -DAAX_SDK_LOCATION:STRING=".\AAX_SDK\aax-sdk-2-6-0" -DVST2_SDK_LOCATION:STRING=".\VST_SDK\VST2_SDK" -DBUILD_AVX=ON -DBUILD_32=ON
cmake -B"cmake-build\Win32" -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_VERSION=10.0.22000.0 -G "Visual Studio 16 2019" -T v142 -A Win32 -DCMAKE_PREFIX_PATH=../JUCE/install -DASIO_SDK_LOCATION:STRING=".\asiosdk" -DAAX_SDK_LOCATION:STRING=".\AAX_SDK\aax-sdk-2-6-0" -DVST2_SDK_LOCATION:STRING=".\VST_SDK\VST2_SDK" -DBUILD_AVX=ON -DBUILD_32=ON -DBUILD_SHARED_LIBS:BOOL=OFF -DBUILD_STATIC_LIBS:BOOL=ON
cmake --build "cmake-build\Win32" --config Release
) else if "%%t"=="Win32SSE2" (
cmake -B"cmake-build\Win32SSE2" -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_VERSION=10.0.22000.0 -G "Visual Studio 16 2019" -T v142 -A Win32 -DCMAKE_PREFIX_PATH=../JUCE/install -DASIO_SDK_LOCATION:STRING=".\asiosdk" -DAAX_SDK_LOCATION:STRING=".\AAX_SDK\aax-sdk-2-6-0" -DVST2_SDK_LOCATION:STRING=".\VST_SDK\VST2_SDK" -DBUILD_AVX=OFF -DBUILD_32=ON
cmake -B"cmake-build\Win32SSE2" -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_VERSION=10.0.22000.0 -G "Visual Studio 16 2019" -T v142 -A Win32 -DCMAKE_PREFIX_PATH=../JUCE/install -DASIO_SDK_LOCATION:STRING=".\asiosdk" -DAAX_SDK_LOCATION:STRING=".\AAX_SDK\aax-sdk-2-6-0" -DVST2_SDK_LOCATION:STRING=".\VST_SDK\VST2_SDK" -DBUILD_AVX=OFF -DBUILD_32=ON -DBUILD_SHARED_LIBS:BOOL=OFF -DBUILD_STATIC_LIBS:BOOL=ON
cmake --build "cmake-build\Win32SSE2" --config Release
) else if "%%t"=="x64" (
cmake -B"cmake-build\x64" -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_VERSION=10.0.22000.0 -G "Visual Studio 16 2019" -T v142 -A x64 -DCMAKE_PREFIX_PATH=../JUCE/install -DASIO_SDK_LOCATION:STRING=".\asiosdk" -DAAX_SDK_LOCATION:STRING=".\AAX_SDK\aax-sdk-2-6-0" -DVST2_SDK_LOCATION:STRING=".\VST_SDK\VST2_SDK" -DBUILD_AVX=ON -DBUILD_32=OFF
cmake -B"cmake-build\x64" -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_VERSION=10.0.22000.0 -G "Visual Studio 16 2019" -T v142 -A x64 -DCMAKE_PREFIX_PATH=../JUCE/install -DASIO_SDK_LOCATION:STRING=".\asiosdk" -DAAX_SDK_LOCATION:STRING=".\AAX_SDK\aax-sdk-2-6-0" -DVST2_SDK_LOCATION:STRING=".\VST_SDK\VST2_SDK" -DBUILD_AVX=ON -DBUILD_32=OFF -DBUILD_SHARED_LIBS:BOOL=OFF -DBUILD_STATIC_LIBS:BOOL=ON
cmake --build "cmake-build\x64" --config Release
) else if "%%t"=="x64SSE2" (
cmake -B"cmake-build\x64SSE2" -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_VERSION=10.0.22000.0 -G "Visual Studio 16 2019" -T v142 -A x64 -DCMAKE_PREFIX_PATH=../JUCE/install -DASIO_SDK_LOCATION:STRING=".\asiosdk" -DAAX_SDK_LOCATION:STRING=".\AAX_SDK\aax-sdk-2-6-0" -DVST2_SDK_LOCATION:STRING=".\VST_SDK\VST2_SDK" -DBUILD_AVX=OFF -DBUILD_32=OFF
cmake -B"cmake-build\x64SSE2" -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_VERSION=10.0.22000.0 -G "Visual Studio 16 2019" -T v142 -A x64 -DCMAKE_PREFIX_PATH=../JUCE/install -DASIO_SDK_LOCATION:STRING=".\asiosdk" -DAAX_SDK_LOCATION:STRING=".\AAX_SDK\aax-sdk-2-6-0" -DVST2_SDK_LOCATION:STRING=".\VST_SDK\VST2_SDK" -DBUILD_AVX=OFF -DBUILD_32=OFF -DBUILD_SHARED_LIBS:BOOL=OFF -DBUILD_STATIC_LIBS:BOOL=ON
cmake --build "cmake-build\x64SSE2" --config Release
) else (
@echo Unknown target "%%t"
Expand Down

0 comments on commit 0cb57c7

Please sign in to comment.