From 8646149636647b6f4ba596f5d7567d9439f7dce1 Mon Sep 17 00:00:00 2001 From: Pavel Kulik Date: Fri, 4 Oct 2024 16:40:50 -0700 Subject: [PATCH] Upgrade to API9 --- .gitignore | 1 + CMakeLists.txt | 6 +- Source/MultiBandIntegrator.cpp | 109 ++++++++++++++++++--------- Source/MultiBandIntegrator.h | 3 + Source/MultiBandIntegratorEditor.cpp | 59 ++++++++------- 5 files changed, 112 insertions(+), 66 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..722d5e7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.vscode diff --git a/CMakeLists.txt b/CMakeLists.txt index fff831e..58f9a99 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ endif() get_filename_component(PROJECT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} ABSOLUTE) get_filename_component(PLUGIN_NAME ${PROJECT_FOLDER} NAME) -set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "Build architecture for Mac OS X" FORCE) +set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "Build architecture for Mac OS X" FORCE) project(OE_PLUGIN_${PLUGIN_NAME}) set(CMAKE_SHARED_LIBRARY_PREFIX "") @@ -73,7 +73,7 @@ if(MSVC) elseif(LINUX) target_link_libraries(${PLUGIN_NAME} GL X11 Xext Xinerama asound dl freetype pthread rt) set_property(TARGET ${PLUGIN_NAME} APPEND_STRING PROPERTY LINK_FLAGS - "-fvisibility=hidden -fPIC -rdynamic -Wl,-rpath='$ORIGIN/../shared' -Wl,-rpath='$ORIGIN/../shared-api8'") + "-fvisibility=hidden -fPIC -rdynamic -Wl,-rpath='$ORIGIN/../shared' -Wl,-rpath='$ORIGIN/../shared-api9'") target_compile_options(${PLUGIN_NAME} PRIVATE -fPIC -rdynamic) target_compile_options(${PLUGIN_NAME} PRIVATE -O3) #enable optimization for linux debug @@ -83,7 +83,7 @@ elseif(APPLE) set_property(TARGET ${PLUGIN_NAME} APPEND_STRING PROPERTY LINK_FLAGS "-undefined dynamic_lookup -rpath @loader_path/../../../../shared") - install(TARGETS ${PLUGIN_NAME} DESTINATION $ENV{HOME}/Library/Application\ Support/open-ephys/plugins-api8) + install(TARGETS ${PLUGIN_NAME} DESTINATION $ENV{HOME}/Library/Application\ Support/open-ephys/plugins-api9) set(CMAKE_PREFIX_PATH /opt/local) endif() diff --git a/Source/MultiBandIntegrator.cpp b/Source/MultiBandIntegrator.cpp index 693b339..0ee3628 100644 --- a/Source/MultiBandIntegrator.cpp +++ b/Source/MultiBandIntegrator.cpp @@ -76,46 +76,85 @@ void MultiBandIntegratorSettings::setRollingWindowParameters(float sampleRate, v MultiBandIntegrator::MultiBandIntegrator() : GenericProcessor ("Multi-Band Integrator") { - + scratchBuffer.setSize(3, 10000); +} + +void MultiBandIntegrator::registerParameters() +{ addSelectedChannelsParameter(Parameter::STREAM_SCOPE, - "Channel", "The input channel to analyze", 1); - + "Channel", + "Channel", + "The input channel to analyze", 1); + + addFloatParameter(Parameter::PROCESSOR_SCOPE, + "window_ms", + "Rolling Avg Window", + "The size of the rolling average window in milliseconds", + "ms", + 1000, 10, 5000, 1); - addIntParameter(Parameter::GLOBAL_SCOPE, - "window_ms", "The size of the rolling average window in milliseconds", - 1000, 10, 5000); + addFloatParameter(Parameter::PROCESSOR_SCOPE, + "alpha_low", + "Alpha Low", + "The alpha band low cut", + "", + 6.0, 0.1, 300.0, 0.1, false); + + addFloatParameter(Parameter::PROCESSOR_SCOPE, + "alpha_high", + "Alpha High", + "The alpha band high cut", + "", + 9.0, 0.1, 300.0, 0.1, false); + + addFloatParameter(Parameter::PROCESSOR_SCOPE, + "alpha_gain", + "Alpha Gain", + "The alpha band gain", + "", + 4.0, -20.0, 20.0, 0.1, false); + + addFloatParameter(Parameter::PROCESSOR_SCOPE, + "beta_low", + "Beta Low", + "The beta band low cut", + "", + 13.0, 0.1, 300.0, 0.1, false); + + addFloatParameter(Parameter::PROCESSOR_SCOPE, + "beta_high", + "Beta High", + "The beta band high cut", + "", + 18.0, 0.1, 300.0, 0.1, false); + + addFloatParameter(Parameter::PROCESSOR_SCOPE, + "beta_gain", + "Beta Gain", + "The beta band gain", + "", + 7.0, -20.0, 20.0, 0.1, false); - addFloatParameter(Parameter::GLOBAL_SCOPE, - "alpha_low", "The alpha band low cut", - 6.0, 0.1, 300.0, false); - addFloatParameter(Parameter::GLOBAL_SCOPE, - "alpha_high", "The alpha band high cut", - 9.0, 0.1, 300.0, false); - addFloatParameter(Parameter::GLOBAL_SCOPE, - "alpha_gain", "The alpha band gain", - 4.0, -20.0, 20.0, false); - - addFloatParameter(Parameter::GLOBAL_SCOPE, - "beta_low", "The beta band low cut", - 13.0, 0.1, 300.0, false); - addFloatParameter(Parameter::GLOBAL_SCOPE, - "beta_high", "The beta band high cut", - 18.0, 0.1, 300.0, false); - addFloatParameter(Parameter::GLOBAL_SCOPE, - "beta_gain", "The beta band gain", - 7.0, -20.0, 20.0, false); - - addFloatParameter(Parameter::GLOBAL_SCOPE, - "delta_low", "The delta band low cut", + addFloatParameter(Parameter::PROCESSOR_SCOPE, + "delta_low", + "Delta Low", + "The delta band low cut", + "", 1.0, 0.1, 300.0, false); - addFloatParameter(Parameter::GLOBAL_SCOPE, - "delta_high", "The delta band high cut", + + addFloatParameter(Parameter::PROCESSOR_SCOPE, + "delta_high", + "Delta High", + "The delta band high cut", + "", 4.0, 0.1, 300.0, false); - addFloatParameter(Parameter::GLOBAL_SCOPE, - "delta_gain", "The delta band gain", - -1.0, -20.0, 20.0, false); - - scratchBuffer.setSize(3, 10000); + + addFloatParameter(Parameter::PROCESSOR_SCOPE, + "delta_gain", + "Delta Gain", + "The delta band gain", + "", + -1.0, -20.0, 20.0, 0.1, false); } AudioProcessorEditor* MultiBandIntegrator::createEditor() diff --git a/Source/MultiBandIntegrator.h b/Source/MultiBandIntegrator.h index 8352800..b7677a3 100644 --- a/Source/MultiBandIntegrator.h +++ b/Source/MultiBandIntegrator.h @@ -130,6 +130,9 @@ class MultiBandIntegrator : public GenericProcessor /** Creates the custom editor for this plugin */ AudioProcessorEditor* createEditor() override; + + /** Registers the parameters for this plugin */ + void registerParameters() override; /** Applies filters to a subset of channels, and sums the resulst*/ void process(AudioBuffer& buffer) override; diff --git a/Source/MultiBandIntegratorEditor.cpp b/Source/MultiBandIntegratorEditor.cpp index c6a1c31..11d492e 100644 --- a/Source/MultiBandIntegratorEditor.cpp +++ b/Source/MultiBandIntegratorEditor.cpp @@ -28,64 +28,67 @@ CustomLabel::CustomLabel(Parameter* param, Colour colour) : ParameterEditor(para label.addListener(this); label.setBounds(0, 0, 40, 15); label.setEditable(true); - label.setColour(Label::backgroundColourId, colour); - label.setColour(Label::textColourId, Colour(200,200,200)); addAndMakeVisible(&label); setBounds(0, 0, 40, 15); } - void BackgroundComponent::paint(Graphics& g) { - g.setColour(Colours::lightgrey); - g.fillRoundedRectangle(115, 25, 130, 65, 3.0f); - - g.setColour(Colours::darkgrey); - g.drawText("low", 120, 12, 40, 10, Justification::centred); - g.drawText("high", 160, 12, 40, 10, Justification::centred); - g.drawText("gain", 200, 12, 40, 10, Justification::centred); - - g.drawText(CharPointer_UTF8("α"), 103, 32, 50, 10, Justification::left); - g.drawText(CharPointer_UTF8("β"), 103, 52, 50, 10, Justification::left); - g.drawText(CharPointer_UTF8("δ"), 103, 72, 50, 10, Justification::left); + g.setColour( findColour (ThemeColours::componentBackground)); + g.fillRoundedRectangle(120, 25, 130, 65, 3.0f); + g.setColour (findColour (ThemeColours::defaultText)); + g.drawText("low", 125, 12, 40, 10, Justification::centred); + g.drawText("high", 165, 12, 40, 10, Justification::centred); + g.drawText("gain", 205, 12, 40, 10, Justification::centred); + g.drawText(CharPointer_UTF8("α"), 108, 32, 50, 10, Justification::left); + g.drawText(CharPointer_UTF8("β"), 108, 52, 50, 10, Justification::left); + g.drawText(CharPointer_UTF8("δ"), 108, 72, 50, 10, Justification::left); } MultiBandIntegratorEditor::MultiBandIntegratorEditor(GenericProcessor* parentNode) : GenericEditor(parentNode) { desiredWidth = 254; - - addAndMakeVisible(&backgroundComponent); - backgroundComponent.setBounds(0, 25, 250, 140); - addSelectedChannelsParameterEditor("Channel", 15, 43); - addTextBoxParameterEditor("window_ms", 15, 74); + addSelectedChannelsParameterEditor(Parameter::ParameterScope::STREAM_SCOPE, "Channel", 10, 35); + ParameterEditor* channelEditor = getParameterEditor("Channel"); + channelEditor->setLayout(ParameterEditor::Layout::nameOnTop); + channelEditor->setSize(90,34); + + addTextBoxParameterEditor(Parameter::ParameterScope::PROCESSOR_SCOPE, "window_ms", 10, 77); + ParameterEditor* windowEditor = getParameterEditor("window_ms"); + windowEditor->setLayout(ParameterEditor::Layout::nameOnTop); + windowEditor->setSize(90,34); Colour alphaColour = Colour(30,30,30); Colour betaColour = Colour(60,60,60); Colour deltaColour = Colour(90,90,90); Parameter* param = getProcessor()->getParameter("alpha_low"); - addCustomParameterEditor(new CustomLabel(param, alphaColour), 120, 55); + addCustomParameterEditor(new CustomLabel(param, alphaColour), 125, 55); param = getProcessor()->getParameter("alpha_high"); - addCustomParameterEditor(new CustomLabel(param, alphaColour), 160, 55); + addCustomParameterEditor(new CustomLabel(param, alphaColour), 165, 55); param = getProcessor()->getParameter("alpha_gain"); - addCustomParameterEditor(new CustomLabel(param, alphaColour), 200, 55); + addCustomParameterEditor(new CustomLabel(param, alphaColour), 205, 55); param = getProcessor()->getParameter("beta_low"); - addCustomParameterEditor(new CustomLabel(param, betaColour), 120, 75); + addCustomParameterEditor(new CustomLabel(param, betaColour), 125, 75); param = getProcessor()->getParameter("beta_high"); - addCustomParameterEditor(new CustomLabel(param, betaColour), 160, 75); + addCustomParameterEditor(new CustomLabel(param, betaColour), 165, 75); param = getProcessor()->getParameter("beta_gain"); - addCustomParameterEditor(new CustomLabel(param, betaColour), 200, 75); + addCustomParameterEditor(new CustomLabel(param, betaColour), 205, 75); param = getProcessor()->getParameter("delta_low"); - addCustomParameterEditor(new CustomLabel(param, deltaColour), 120, 95); + addCustomParameterEditor(new CustomLabel(param, deltaColour), 125, 95); param = getProcessor()->getParameter("delta_high"); - addCustomParameterEditor(new CustomLabel(param, deltaColour), 160, 95); + addCustomParameterEditor(new CustomLabel(param, deltaColour), 165, 95); param = getProcessor()->getParameter("delta_gain"); - addCustomParameterEditor(new CustomLabel(param, deltaColour), 200, 95); + addCustomParameterEditor(new CustomLabel(param, deltaColour), 205, 95); + + addAndMakeVisible(&backgroundComponent); + backgroundComponent.setBounds(0, 25, 250, 140); + backgroundComponent.toBack(); }