Skip to content

Commit fbef3a6

Browse files
committed
Compatibility updates for API9
1 parent 0fabdb2 commit fbef3a6

File tree

6 files changed

+45
-93
lines changed

6 files changed

+45
-93
lines changed

CMakeLists.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ endif()
1010
get_filename_component(PROJECT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} ABSOLUTE)
1111
get_filename_component(PLUGIN_NAME ${PROJECT_FOLDER} NAME)
1212

13-
set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "Build architecture for Mac OS X" FORCE)
13+
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "Build architecture for Mac OS X" FORCE)
1414

1515
project(OE_PLUGIN_${PLUGIN_NAME})
1616
set(CMAKE_SHARED_LIBRARY_PREFIX "")
@@ -70,21 +70,21 @@ if(MSVC)
7070
elseif(LINUX)
7171
target_link_libraries(${PLUGIN_NAME} PRIVATE GL X11 Xext Xinerama asound dl freetype pthread rt)
7272
set_property(TARGET ${PLUGIN_NAME} APPEND_STRING PROPERTY LINK_FLAGS
73-
"-fvisibility=hidden -fPIC -rdynamic -Wl,-rpath='$ORIGIN/../shared' -Wl,-rpath='$ORIGIN/../shared-api8'")
73+
"-fvisibility=hidden -fPIC -rdynamic -Wl,-rpath='$ORIGIN/../shared' -Wl,-rpath='$ORIGIN/../shared-api9'")
7474
target_compile_options(${PLUGIN_NAME} PRIVATE -fPIC -rdynamic)
7575
target_compile_options(${PLUGIN_NAME} PRIVATE -O3) #enable optimization for linux debug
7676

7777
install(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION ${GUI_BIN_DIR}/plugins)
7878
elseif(APPLE)
7979
set_target_properties(${PLUGIN_NAME} PROPERTIES BUNDLE TRUE)
8080
set_property(TARGET ${PLUGIN_NAME} APPEND_STRING PROPERTY LINK_FLAGS
81-
"-undefined dynamic_lookup -rpath @loader_path/../../../../shared-api8")
81+
"-undefined dynamic_lookup -rpath @loader_path/../../../../shared-api9")
8282
set_target_properties(${PLUGIN_NAME} PROPERTIES
8383
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY ""
8484
XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED NO
8585
)
8686

87-
install(TARGETS ${PLUGIN_NAME} DESTINATION $ENV{HOME}/Library/Application\ Support/open-ephys/plugins-api8)
87+
install(TARGETS ${PLUGIN_NAME} DESTINATION $ENV{HOME}/Library/Application\ Support/open-ephys/plugins-api9)
8888
endif()
8989

9090
#create filters for vs and xcode
@@ -99,7 +99,7 @@ endforeach()
9999
option(COPY_PYTHON_DL "Creates a directory and copies the python dynamic library for packaging" OFF)
100100

101101
# Find and link python and pybind11
102-
find_package(Python 3.8 REQUIRED COMPONENTS Interpreter Development)
102+
find_package(Python 3.8 COMPONENTS Interpreter Development REQUIRED)
103103
add_subdirectory(extern/pybind11)
104104
target_link_libraries(${PLUGIN_NAME} PRIVATE pybind11::embed)
105105

@@ -145,6 +145,6 @@ elseif(APPLE)
145145
${CMAKE_COMMAND} -E copy ${_pythondylib} $<TARGET_BUNDLE_DIR:${PLUGIN_NAME}>/../shared)
146146
else()
147147
add_custom_command(TARGET ${PLUGIN_NAME} POST_BUILD COMMAND
148-
${CMAKE_COMMAND} -E copy ${_pythondylib} $ENV{HOME}/Library/Application\ Support/open-ephys/shared-api8)
148+
${CMAKE_COMMAND} -E copy ${_pythondylib} $ENV{HOME}/Library/Application\ Support/open-ephys/shared-api9)
149149
endif()
150150
endif()

Modules/examples/bandpass_filter.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,8 @@ def process(self, data):
5555
Parameters:
5656
data - numpy array.
5757
"""
58-
try:
59-
for i in range(self.num_chans):
60-
data[i] = butter_bandpass_filter(self.sos[i], data[i])
61-
except:
62-
pass
58+
for i in range(self.num_chans):
59+
data[i] = butter_bandpass_filter(self.sos[i], data[i])
6360

6461
def start_acquisition(self):
6562
""" Called at start of acquisition """

Source/PythonProcessor.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,6 @@ PythonProcessor::PythonProcessor()
4444
moduleName = "";
4545
editorPtr = NULL;
4646
currentStream = 0;
47-
48-
addStringParameter(Parameter::GLOBAL_SCOPE, "python_home", "Path to python home", String());
49-
addStringParameter(Parameter::GLOBAL_SCOPE, "script_path", "Path to python script", String(), true);
50-
addIntParameter(Parameter::GLOBAL_SCOPE,
51-
"current_stream", "Currently selected stream",
52-
0, 0, 200000);
5347
}
5448

5549
PythonProcessor::~PythonProcessor()
@@ -65,6 +59,12 @@ PythonProcessor::~PythonProcessor()
6559
}
6660
}
6761

62+
void PythonProcessor::registerParameters()
63+
{
64+
addStringParameter(Parameter::PROCESSOR_SCOPE, "python_home", "Python Home", "Path to python home", String());
65+
addStringParameter(Parameter::PROCESSOR_SCOPE, "script_path", "Script Path", "Path to python script", String(), true);
66+
addSelectedStreamParameter(Parameter::PROCESSOR_SCOPE, "current_stream", "Stream", "Currently selected stream", {}, 0, true, true);
67+
}
6868

6969
AudioProcessorEditor* PythonProcessor::createEditor()
7070
{
@@ -96,7 +96,7 @@ void PythonProcessor::updateSettings()
9696
};
9797

9898
ttlChan = new EventChannel(ttlChannelSettings);
99-
ttlChan->addProcessor(processorInfo.get());
99+
ttlChan->addProcessor(this);
100100
eventChannels.add(ttlChan);
101101

102102
localEventChannels[streamId] = eventChannels.getLast();
@@ -363,7 +363,8 @@ void PythonProcessor::parameterValueChanged(Parameter* param)
363363
}
364364
else if (param->getName().equalsIgnoreCase("current_stream"))
365365
{
366-
uint16 candidateStream = (uint16) (int) param->getValue();
366+
String streamKey = param->getValueAsString();
367+
uint16 candidateStream = getDataStream(streamKey)->getStreamId();
367368

368369
if(streamExists(candidateStream)
369370
&& currentStream != candidateStream)
@@ -392,7 +393,7 @@ bool PythonProcessor::initInterpreter(String pythonHome)
392393
AlertWindow::showMessageBox (AlertWindow::InfoIcon,
393394
"Select Python Home path",
394395
"To use the plugin you need provide the path to your preferred Python installation. "
395-
"Please select the folder where your python is located in the next step.");
396+
"Please select the folder where your python environment is located in the next step.");
396397

397398
FileChooser chooser ("Please select the path to your preferred Python installation",
398399
{ File::getSpecialLocation(File::userHomeDirectory) });
@@ -594,7 +595,7 @@ void PythonProcessor::handlePythonException(const String& title, const String& m
594595
TextEditor* customMsgBox = new TextEditor();
595596
customMsgBox->setReadOnly(true);
596597
customMsgBox->setMultiLine(true);
597-
customMsgBox->setFont(Font("Fira Code", "Regular", 14.0f));
598+
customMsgBox->setFont(FontOptions(14.0f));
598599
customMsgBox->setSize(400, 300);
599600
customMsgBox->setText(String(e.what()));
600601

Source/PythonProcessor.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ class PythonProcessor : public GenericProcessor
8484
/** The class destructor, used to deallocate memory */
8585
~PythonProcessor();
8686

87+
/** Registers the parameters of the processor */
88+
void registerParameters() override;
89+
8790
/** If the processor has a custom editor, this method must be defined to instantiate it. */
8891
AudioProcessorEditor* createEditor() override;
8992

Source/PythonProcessorEditor.cpp

Lines changed: 20 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2525

2626
ScriptPathButton::ScriptPathButton(Parameter* param) : ParameterEditor(param)
2727
{
28-
utilButton = std::make_unique<UtilityButton>("...", Font(12));
28+
utilButton = std::make_unique<UtilityButton>("...");
29+
utilButton->setFont (FontOptions (12.0f));
2930
utilButton->addListener(this);
3031
addAndMakeVisible(utilButton.get());
3132

@@ -35,7 +36,7 @@ ScriptPathButton::ScriptPathButton(Parameter* param) : ParameterEditor(param)
3536

3637
void ScriptPathButton::buttonClicked(Button* label)
3738
{
38-
FileChooser chooseScriptDirectory("Please select a python script...", File(CoreServices::getDefaultUserSaveDirectory()), "*.py");
39+
FileChooser chooseScriptDirectory("Please select a python script...", File(), "*.py");
3940

4041
if (chooseScriptDirectory.browseForFileToOpen())
4142
{
@@ -59,69 +60,39 @@ PythonProcessorEditor::PythonProcessorEditor(PythonProcessor* parentNode)
5960

6061
desiredWidth = 190;
6162

62-
streamSelection = std::make_unique<ComboBox>("Stream Selector");
63-
streamSelection->setBounds(20, 32, 155, 20);
64-
streamSelection->addListener(this);
65-
addAndMakeVisible(streamSelection.get());
63+
addSelectedStreamParameterEditor(Parameter::PROCESSOR_SCOPE, "current_stream", 20, 34);
64+
getParameterEditor("current_stream")->setLayout(ParameterEditor::Layout::nameHidden);
65+
getParameterEditor("current_stream")->setSize(150, 20);
6666

67-
scriptPathLabel = std::make_unique<Label>("Script Path Label", "No Module Loaded");
67+
68+
scriptPathLabel = std::make_unique<TextEditor>("Script Path Label");
69+
scriptPathLabel->setText("No Module Loaded", false);
6870
scriptPathLabel->setTooltip(scriptPathLabel->getText());
69-
scriptPathLabel->setMinimumHorizontalScale(0.7f);
70-
scriptPathLabel->setBounds(20, 65, 135, 20);
71-
scriptPathLabel->setColour(Label::backgroundColourId, Colours::grey);
72-
scriptPathLabel->setColour(Label::backgroundWhenEditingColourId, Colours::white);
73-
scriptPathLabel->setJustificationType(Justification::centredLeft);
71+
scriptPathLabel->setMultiLine(false);
72+
scriptPathLabel->setReadOnly(true);
73+
scriptPathLabel->setCaretVisible(false);
74+
scriptPathLabel->setBounds(20, 65, 125, 20);
75+
scriptPathLabel->setJustification(Justification::centredLeft);
7476
addAndMakeVisible(scriptPathLabel.get());
7577

7678
Parameter* scriptPathPtr = getProcessor()->getParameter("script_path");
77-
addCustomParameterEditor(new ScriptPathButton(scriptPathPtr), 160, 65);
79+
addCustomParameterEditor(new ScriptPathButton(scriptPathPtr), 150, 65);
7880

79-
reloadButton = std::make_unique<UtilityButton>("Reload", Font(12));
80-
reloadButton->setBounds(60, 95, 80, 25);
81+
reloadButton = std::make_unique<UtilityButton>("Reload");
82+
reloadButton->setFont (FontOptions (13.0f));
83+
reloadButton->setBounds(60, 95, 70, 25);
8184
reloadButton->addListener(this);
8285
addAndMakeVisible(reloadButton.get());
8386

8487
}
8588

86-
void PythonProcessorEditor::updateSettings()
87-
{
88-
89-
currentStream = (uint16) (int)getProcessor()->getParameter("current_stream")->getValue();
90-
streamSelection->clear();
91-
92-
for (auto stream : getProcessor()->getDataStreams())
93-
{
94-
if (currentStream == 0)
95-
currentStream = stream->getStreamId();
96-
97-
streamSelection->addItem(stream->getName(), stream->getStreamId());
98-
}
99-
100-
if (streamSelection->indexOfItemId(currentStream) == -1)
101-
{
102-
if (streamSelection->getNumItems() > 0)
103-
currentStream = streamSelection->getItemId(0);
104-
else
105-
currentStream = 0;
106-
}
107-
108-
if (currentStream > 0)
109-
{
110-
streamSelection->setSelectedId(currentStream, sendNotification);
111-
}
112-
113-
114-
}
115-
11689
void PythonProcessorEditor::startAcquisition()
11790
{
118-
streamSelection->setEnabled(false);
11991
reloadButton->setEnabled(false);
12092
}
12193

12294
void PythonProcessorEditor::stopAcquisition()
12395
{
124-
streamSelection->setEnabled(true);
12596
reloadButton->setEnabled(true);
12697
}
12798

@@ -135,23 +106,11 @@ void PythonProcessorEditor::buttonClicked(Button* button)
135106

136107
}
137108

138-
void PythonProcessorEditor::comboBoxChanged(ComboBox* cb)
139-
{
140-
if (cb == streamSelection.get())
141-
{
142-
currentStream = cb->getSelectedId();
143-
144-
if (currentStream > 0)
145-
getProcessor()->getParameter("current_stream")->setNextValue(currentStream);
146-
}
147-
148-
}
149-
150-
151109
void PythonProcessorEditor::setPathLabelText(String text, String tooltip)
152110
{
153-
scriptPathLabel->setText(text, dontSendNotification);
111+
scriptPathLabel->setText(text, false);
154112
scriptPathLabel->setTooltip(tooltip);
113+
scriptPathLabel->setCaretPosition(0);
155114
}
156115

157116

Source/PythonProcessorEditor.h

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ class ScriptPathButton : public ParameterEditor,
5656

5757
class PythonProcessorEditor :
5858
public GenericEditor,
59-
public Button::Listener,
60-
public ComboBox::Listener
59+
public Button::Listener
6160
{
6261
public:
6362

@@ -67,9 +66,6 @@ class PythonProcessorEditor :
6766
/** Destructor */
6867
~PythonProcessorEditor() { }
6968

70-
/** Called when underlying settings are updated */
71-
void updateSettings() override;
72-
7369
/** Called just prior to the start of acquisition, to allow custom commands. */
7470
void startAcquisition() override;
7571

@@ -79,20 +75,16 @@ class PythonProcessorEditor :
7975
/** Respond to button clicks*/
8076
void buttonClicked(Button* button) override;
8177

82-
/** Called when a ComboBox changes*/
83-
void comboBoxChanged(ComboBox* comboBox) override;
84-
8578
/** Sets the text & tooltip of the path label */
8679
void setPathLabelText(String text, String tooltip);
8780

8881
private:
8982

9083
PythonProcessor* pythonProcessor;
9184

92-
std::unique_ptr<Label> scriptPathLabel;
85+
std::unique_ptr<TextEditor> scriptPathLabel;
9386
std::unique_ptr<Button> scriptPathButton;
94-
std::unique_ptr<Button> reloadButton;
95-
std::unique_ptr<ComboBox> streamSelection;
87+
std::unique_ptr<UtilityButton> reloadButton;
9688

9789
uint16 currentStream = 0;
9890

0 commit comments

Comments
 (0)