Add standaloneapp

This commit is contained in:
Roland Rabien 2023-09-21 21:25:40 -07:00
commit 9d4b363484
4 changed files with 70 additions and 2 deletions

View file

@ -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

@ -1 +1 @@
Subproject commit 8ab5721a16786261f27b01d0e59379f98811e28d
Subproject commit 07151d2546d1c0f5bf2cf275185770ccc211d6e2

67
plugin/Source/App.cpp Normal file
View file

@ -0,0 +1,67 @@
#include <JuceHeader.h>
#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;
});
}

View file

@ -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;