Skip to content

Commit

Permalink
Upgrade to API9
Browse files Browse the repository at this point in the history
  • Loading branch information
medengineer committed Oct 5, 2024
1 parent 5ca1771 commit 8646149
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 66 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.vscode
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 "")
Expand Down Expand Up @@ -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

Expand All @@ -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()

Expand Down
109 changes: 74 additions & 35 deletions Source/MultiBandIntegrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 3 additions & 0 deletions Source/MultiBandIntegrator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<float>& buffer) override;
Expand Down
59 changes: 31 additions & 28 deletions Source/MultiBandIntegratorEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

}

0 comments on commit 8646149

Please sign in to comment.