diff --git a/CMakeLists.txt b/CMakeLists.txt index dc34d2a..0b1acd8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -182,6 +182,7 @@ target_link_libraries(${TARGET_NAME} juce::juce_graphics juce::juce_gui_basics juce::juce_gui_extra + juce::juce_audio_basics onnxruntime PUBLIC diff --git a/source/PluginProcessor.cpp b/source/PluginProcessor.cpp index 029a4f6..69e11cb 100644 --- a/source/PluginProcessor.cpp +++ b/source/PluginProcessor.cpp @@ -23,7 +23,7 @@ AudioPluginAudioProcessor::AudioPluginAudioProcessor() grainDelay1(1), grainDelay2(2), processorCompressor(parameters) -{ +{ network1Name = "Funk"; network2Name = "Djembe"; @@ -169,6 +169,7 @@ void AudioPluginAudioProcessor::prepareToPlay (double sampleRate, int samplesPer void AudioPluginAudioProcessor::releaseResources() { // When playback stops, you can use this as an opportunity to free up any // spare memory, etc. + measurer.reset(); } bool AudioPluginAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const { @@ -195,9 +196,8 @@ bool AudioPluginAudioProcessor::isBusesLayoutSupported (const BusesLayout& layou void AudioPluginAudioProcessor::processBlock (juce::AudioBuffer& buffer, juce::MidiBuffer& ) { - juce::AudioProcessLoadMeasurer::ScopedTimer s(measurer); + juce::AudioProcessLoadMeasurer::ScopedTimer s(measurer, buffer.getNumSamples()); { - dryWetMixer.setDrySamples(buffer); stereoToMono(monoBuffer, buffer); diff --git a/source/PluginProcessor.h b/source/PluginProcessor.h index 2052447..3c7b11e 100644 --- a/source/PluginProcessor.h +++ b/source/PluginProcessor.h @@ -11,6 +11,7 @@ #include "dsp/gain/ProcessorGain.h" #include "dsp/Filter/IIRCutoffFilter.h" #include "dsp/grainDelay/GrainDelay.h" +//#include //============================================================================== @@ -123,6 +124,8 @@ float latency; + + //============================================================================== JUCE_HEAVYWEIGHT_LEAK_DETECTOR (AudioPluginAudioProcessor) }; diff --git a/source/ui/CustomComponents/Footer/FooterComponent.cpp b/source/ui/CustomComponents/Footer/FooterComponent.cpp index 00b19ca..13ae78d 100644 --- a/source/ui/CustomComponents/Footer/FooterComponent.cpp +++ b/source/ui/CustomComponents/Footer/FooterComponent.cpp @@ -60,7 +60,7 @@ void FooterComponent::updateSpecs(){ latencySeconds = (float)latencySamples / float(sampleRate); //processorUse = processor.getCpuLoad(); - processorUse = systemSpecs.getCPULoad(); + processorUse = processor.getCpuLoad(); std::string cpuString = "CPU: " + std::to_string((int)processorUse ) + " %"; cpuLabel.setText(cpuString, juce::dontSendNotification); diff --git a/source/ui/CustomComponents/Footer/FooterComponent.h b/source/ui/CustomComponents/Footer/FooterComponent.h index 37a5ad0..5a777fa 100644 --- a/source/ui/CustomComponents/Footer/FooterComponent.h +++ b/source/ui/CustomComponents/Footer/FooterComponent.h @@ -9,7 +9,6 @@ #include "../../../PluginParameters.h" #include "../../../PluginProcessor.h" #include "../../../ui/LookAndFeel/CustomFontLookAndFeel.h" -#include "../../../utils/SystemSpecs.h" class FooterComponent : public juce::Component, juce::Timer { public: @@ -39,8 +38,6 @@ class FooterComponent : public juce::Component, juce::Timer { CustomFontLookAndFeel customFontLookAndFeel; juce::Font font; - SystemSpecs systemSpecs; - }; diff --git a/source/ui/CustomComponents/XYPad/XYPad.cpp b/source/ui/CustomComponents/XYPad/XYPad.cpp index e07418b..5491612 100644 --- a/source/ui/CustomComponents/XYPad/XYPad.cpp +++ b/source/ui/CustomComponents/XYPad/XYPad.cpp @@ -102,12 +102,7 @@ void XYPad::resized() void XYPad::parameterChanged(const juce::String& parameterID, float newValue) { - if (parameterID == PluginParameters::SELECT_NETWORK1_ID.getParamID() && newValue == 0.f) { - updateKnobName(1, network1Name); - } else if (parameterID == PluginParameters::SELECT_NETWORK2_ID.getParamID() && newValue == 0.f) { - updateKnobName(2, network2Name); - } - + if (parameterID == PluginParameters::FADE_ID.getParamID()){ float fadeValue = parameters.getRawParameterValue(PluginParameters::FADE_ID.getParamID())->load(); onModelMixChange(fadeValue); diff --git a/source/utils/SystemSpecs.cpp b/source/utils/SystemSpecs.cpp deleted file mode 100644 index c959502..0000000 --- a/source/utils/SystemSpecs.cpp +++ /dev/null @@ -1,139 +0,0 @@ -// -// Created by schee on 22/08/2023. -// - -#include "SystemSpecs.h" - -#if JUCE_WINDOWS - #include "windows.h" - - static ULARGE_INTEGER lastCPU, lastSysCPU, lastUserCPU; - static int numProcessors; - static HANDLE self; - - SystemSpecs::SystemSpecs() { - SYSTEM_INFO sysInfo; - FILETIME ftime, fsys, fuser; - - GetSystemInfo(&sysInfo); - numProcessors = sysInfo.dwNumberOfProcessors; - - GetSystemTimeAsFileTime(&ftime); - memcpy(&lastCPU, &ftime, sizeof(FILETIME)); - - self = GetCurrentProcess(); - GetProcessTimes(self, &ftime, &ftime, &fsys, &fuser); - memcpy(&lastSysCPU, &fsys, sizeof(FILETIME)); - memcpy(&lastUserCPU, &fuser, sizeof(FILETIME)); - } - SystemSpecs::~SystemSpecs() {} - - double SystemSpecs::getCPULoad() { - - FILETIME ftime, fsys, fuser; - ULARGE_INTEGER now, sys, user; - double percent; - - GetSystemTimeAsFileTime(&ftime); - memcpy(&now, &ftime, sizeof(FILETIME)); - - GetProcessTimes(self, &ftime, &ftime, &fsys, &fuser); - memcpy(&sys, &fsys, sizeof(FILETIME)); - memcpy(&user, &fuser, sizeof(FILETIME)); - percent = (sys.QuadPart - lastSysCPU.QuadPart) + - (user.QuadPart - lastUserCPU.QuadPart); - percent /= (now.QuadPart - lastCPU.QuadPart); - percent /= numProcessors; - lastCPU = now; - lastUserCPU = user; - lastSysCPU = sys; - - return percent * 100; - } - -#elif JUCE_LINUX - #include "stdlib.h" - #include "stdio.h" - #include "string.h" - #include "sys/times.h" - #include "sys/vtimes.h" - - static clock_t lastCPU, lastSysCPU, lastUserCPU; - static int numProcessors; - - SystemSpecs::SystemSpecs(){ - FILE* file; - struct tms timeSample; - char line[128]; - - lastCPU = times(&timeSample); - lastSysCPU = timeSample.tms_stime; - lastUserCPU = timeSample.tms_utime; - - file = fopen("/proc/cpuinfo", "r"); - numProcessors = 0; - while(fgets(line, 128, file) != NULL){ - if (strncmp(line, "processor", 9) == 0) numProcessors++; - } - fclose(file); - } - - double SystemSpecs::getCPULoad(){ - struct tms timeSample; - clock_t now; - double percent; - - now = times(&timeSample); - if (now <= lastCPU || timeSample.tms_stime < lastSysCPU || - timeSample.tms_utime < lastUserCPU){ - //Overflow detection. Just skip this value. - percent = -1.0; - } - else{ - percent = (timeSample.tms_stime - lastSysCPU) + - (timeSample.tms_utime - lastUserCPU); - percent /= (now - lastCPU); - percent /= numProcessors; - percent *= 100; - } - lastCPU = now; - lastSysCPU = timeSample.tms_stime; - lastUserCPU = timeSample.tms_utime; - - return percent; - } - -#elif JUCE_MAC - #include - #include - #include - #include - - static unsigned long long _previousTotalTicks = 0; - static unsigned long long _previousIdleTicks = 0; - - double SystemSpecs::getCPULoad() { -// host_cpu_load_info_data_t cpuinfo; -// mach_msg_type_number_t count = HOST_CPU_LOAD_INFO_COUNT; -// if (host_statistics(mach_host_self(), HOST_CPU_LOAD_INFO, (host_info_t)&cpuinfo, &count) == KERN_SUCCESS) -// { -// unsigned long long totalTicks = 0; -// for(int i=0; i 0) ? ((float)idleTicksSinceLastTime)/totalTicksSinceLastTime : 0); -// _previousTotalTicks = totalTicks; -// _previousIdleTicks = idleTicks; -// return ret; - return 0.0; - } -#endif - - diff --git a/source/utils/SystemSpecs.h b/source/utils/SystemSpecs.h deleted file mode 100644 index b19cda5..0000000 --- a/source/utils/SystemSpecs.h +++ /dev/null @@ -1,23 +0,0 @@ -// -// Created by schee on 22/08/2023. -// - -#ifndef SCYCLONE_SYSTEMSPECS_H -#define SCYCLONE_SYSTEMSPECS_H -#include "JuceHeader.h" - -class SystemSpecs { - public: - SystemSpecs(); - ~SystemSpecs(); - - double getCPULoad(); - double calculateCPULoad(); - private: - juce::SystemStats::OperatingSystemType os; -}; - - - - -#endif //SCYCLONE_SYSTEMSPECS_H