From 9d4b363484c98f6f6045e0e2584deae84de4201b Mon Sep 17 00:00:00 2001 From: Roland Rabien Date: Thu, 21 Sep 2023 21:25:40 -0700 Subject: [PATCH] Add standaloneapp --- CMakeLists.txt | 1 + modules/gin | 2 +- plugin/Source/App.cpp | 67 +++++++++++++++++++++++++++++++ plugin/Source/PluginProcessor.cpp | 2 +- 4 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 plugin/Source/App.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 7303686..4d75947 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -325,6 +325,7 @@ target_include_directories (${PLUGIN_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/S juce_generate_juce_header (${PLUGIN_NAME}) target_compile_definitions (${PLUGIN_NAME} PRIVATE + JUCE_USE_CUSTOM_PLUGIN_STANDALONE_APP=1 JUCE_DISPLAY_SPLASH_SCREEN=0 JUCE_COREGRAPHICS_DRAW_ASYNC=1 JUCE_MODAL_LOOPS_PERMITTED=0 diff --git a/modules/gin b/modules/gin index 8ab5721..07151d2 160000 --- a/modules/gin +++ b/modules/gin @@ -1 +1 @@ -Subproject commit 8ab5721a16786261f27b01d0e59379f98811e28d +Subproject commit 07151d2546d1c0f5bf2cf275185770ccc211d6e2 diff --git a/plugin/Source/App.cpp b/plugin/Source/App.cpp new file mode 100644 index 0000000..6c6abba --- /dev/null +++ b/plugin/Source/App.cpp @@ -0,0 +1,67 @@ +#include +#include "PluginProcessor.h" + +static void profile (juce::PropertiesFile& settings) +{ + WavetableAudioProcessor proc; + proc.setRateAndBufferSizeDetails (44100, 512); + proc.prepareToPlay (44100, 512); + + juce::MemoryBlock data; + + if (data.fromBase64Encoding (settings.getValue ("filterState")) && data.getSize() > 0) + proc.setStateInformation (data.getData(), (int) data.getSize()); + + proc.reset(); + + juce::AudioSampleBuffer buffer (2, 512); + + for (int i = 0; i < 5000; i++) + { + buffer.clear(); + + if (i % 100 == 0) + { + juce::MidiBuffer midiOn; + midiOn.addEvent (juce::MidiMessage::noteOn (1, 60, 0.5f), 0); + midiOn.addEvent (juce::MidiMessage::noteOn (1, 70, 0.5f), 0); + midiOn.addEvent (juce::MidiMessage::noteOn (1, 80, 0.5f), 0); + + proc.processBlock (buffer, midiOn); + } + else if (i % 100 == 90) + { + juce::MidiBuffer midiOff; + + midiOff.addEvent (juce::MidiMessage::noteOff (1, 60, 0.5f), 0); + midiOff.addEvent (juce::MidiMessage::noteOff (1, 70, 0.5f), 0); + midiOff.addEvent (juce::MidiMessage::noteOff (1, 80, 0.5f), 0); + + proc.processBlock (buffer, midiOff); + } + else + { + juce::MidiBuffer midiEmpty; + proc.processBlock (buffer, midiEmpty); + } + } + +} + +juce::JUCEApplicationBase* juce_CreateApplication() +{ + return new gin::StandaloneApp([] (juce::PropertiesFile& settings) + { + if (juce::JUCEApplication::getCommandLineParameters ().contains ("-profile")) + { + auto start = juce::Time::getMillisecondCounterHiRes(); + profile (settings); + auto end = juce::Time::getMillisecondCounterHiRes(); + + printf ("Elapsed time: %.2fs\n", (end - start) / 1000); + + return false; + } + return true; + }); +} diff --git a/plugin/Source/PluginProcessor.cpp b/plugin/Source/PluginProcessor.cpp index 76ecca3..a41a85b 100644 --- a/plugin/Source/PluginProcessor.cpp +++ b/plugin/Source/PluginProcessor.cpp @@ -522,7 +522,7 @@ void WavetableAudioProcessor::reloadWavetables() auto shouldLoad = [&] (int osc, const juce::String& name, double sr) { auto& v = curTables[osc]; - if (v.name == name && juce::approximatelyEqual (v.sampleRate, sr)) + if (v.name == name && juce::exactlyEqual (v.sampleRate, sr)) return false; v.name = name;