From e91990adaf26db6ab8552561b86e760561318581 Mon Sep 17 00:00:00 2001 From: bparks13 Date: Mon, 4 Nov 2024 14:19:32 -0500 Subject: [PATCH 1/9] Emsure actions run on push to juce8 branch --- .github/workflows/linux.yml | 2 +- .github/workflows/mac.yml | 2 +- .github/workflows/windows.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 2469ea9..1aebf3a 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -2,7 +2,7 @@ name: linux on: push: - branches: [main] + branches: [main,juce8] pull_request: env: diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index 2372540..fd47aa1 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -2,7 +2,7 @@ name: mac on: push: - branches: [main] + branches: [main,juce8] pull_request: env: diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 55f58cd..64e223c 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -2,7 +2,7 @@ name: Windows on: push: - branches: [main] + branches: [main,juce8] pull_request: env: From 670fc1676bea096784e92356529a0d14ff45f4af Mon Sep 17 00:00:00 2001 From: Anjal Doshi Date: Tue, 7 Jan 2025 12:45:01 -0800 Subject: [PATCH 2/9] Update CMakeLists.txt for API9 --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3776d29..9e90a0e 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 "") @@ -70,7 +70,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 @@ -78,9 +78,9 @@ elseif(LINUX) elseif(APPLE) set_target_properties(${PLUGIN_NAME} PROPERTIES BUNDLE TRUE) set_property(TARGET ${PLUGIN_NAME} APPEND_STRING PROPERTY LINK_FLAGS - "-undefined dynamic_lookup -rpath @loader_path/../../../../shared-api8") + "-undefined dynamic_lookup -rpath @loader_path/../../../../shared-api9") - 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) endif() #create filters for vs and xcode From b4c7aef6167131c0055e68eb9e08f7424952f616 Mon Sep 17 00:00:00 2001 From: Anjal Doshi Date: Tue, 7 Jan 2025 12:50:19 -0800 Subject: [PATCH 3/9] Refactor to use parameter and parameter editors --- Source/EphysSocket.cpp | 65 +++++++++++-- Source/EphysSocket.h | 6 ++ Source/EphysSocketEditor.cpp | 180 +++-------------------------------- Source/EphysSocketEditor.h | 34 +------ Source/SocketThread.cpp | 19 ++-- Source/SocketThread.h | 9 +- 6 files changed, 92 insertions(+), 221 deletions(-) diff --git a/Source/EphysSocket.cpp b/Source/EphysSocket.cpp index a6917ad..b0bf352 100644 --- a/Source/EphysSocket.cpp +++ b/Source/EphysSocket.cpp @@ -12,7 +12,7 @@ DataThread* EphysSocket::createDataThread(SourceNode* sn) return new EphysSocket(sn); } -EphysSocket::EphysSocket(SourceNode* sn) : DataThread(sn), socket("socket_thread") +EphysSocket::EphysSocket(SourceNode* sn) : DataThread(sn), socket("socket_thread", this) { port = DEFAULT_PORT; sample_rate = DEFAULT_SAMPLE_RATE; @@ -29,8 +29,6 @@ EphysSocket::EphysSocket(SourceNode* sn) : DataThread(sn), socket("socket_thread std::unique_ptr EphysSocket::createEditor(SourceNode* sn) { std::unique_ptr editor = std::make_unique(sn, this); - socket.setEditor(editor.get()); - return editor; } @@ -38,14 +36,43 @@ EphysSocket::~EphysSocket() { } +void EphysSocket::registerParameters() +{ + addIntParameter (Parameter::PROCESSOR_SCOPE, "port", "Port", "Port number to connect to", DEFAULT_PORT, MIN_PORT, MAX_PORT); + addFloatParameter(Parameter::PROCESSOR_SCOPE, "sample_rate", "Sample Rate", "Sample rate of incoming data", "Hz", DEFAULT_SAMPLE_RATE, MIN_SAMPLE_RATE, MAX_SAMPLE_RATE, 1.0f); + addFloatParameter(Parameter::PROCESSOR_SCOPE, "data_scale", "Scale", "Scale of incoming data", "", DEFAULT_DATA_SCALE, MIN_DATA_SCALE, MAX_DATA_SCALE, 0.1f); + addFloatParameter(Parameter::PROCESSOR_SCOPE, "data_offset", "Offset", "Offset of incoming data", "", DEFAULT_DATA_OFFSET, MIN_DATA_OFFSET, MAX_DATA_OFFSET, 1.0f); +} + void EphysSocket::disconnectSocket() { socket.disconnectSocket(); + + getParameter("port")->setEnabled(true); + getParameter("sample_rate")->setEnabled(true); + getParameter("data_scale")->setEnabled(true); + getParameter("data_offset")->setEnabled(true); + + if (sn->getEditor() != nullptr) // check if headless + static_cast(sn->getEditor())->disconnected(); } bool EphysSocket::connectSocket(bool printOutput) { - return socket.connectSocket(port, printOutput); + if (socket.connectSocket(port, printOutput)) + { + getParameter("port")->setEnabled(false); + getParameter("sample_rate")->setEnabled(false); + getParameter("data_scale")->setEnabled(false); + getParameter("data_offset")->setEnabled(false); + + if (sn->getEditor() != nullptr) // check if headless + static_cast(sn->getEditor())->connected(); + + return true; + } + + return false; } bool EphysSocket::errorFlag() @@ -128,6 +155,28 @@ bool EphysSocket::isReady() return socket.isConnected(); } +void EphysSocket::parameterValueChanged(Parameter* parameter) +{ + if (parameter->getName() == "port") + { + port = (int)parameter->getValue(); + } + else if (parameter->getName() == "sample_rate") + { + sample_rate = (float)parameter->getValue(); + CoreServices::updateSignalChain (sn); // Update the signal chain to reflect the new sample rate + } + else if (parameter->getName() == "data_scale") + { + data_scale = (float)parameter->getValue(); + CoreServices::updateSignalChain (sn); // Update the signal chain to reflect the new data scale + } + else if (parameter->getName() == "data_offset") + { + data_offset = (float)parameter->getValue(); + } +} + bool EphysSocket::startAcquisition() { resizeBuffers(); @@ -247,7 +296,7 @@ String EphysSocket::handleConfigMessage(const String& msg) if (scale > MIN_DATA_SCALE && scale < MAX_DATA_SCALE) { - data_scale = scale; + getParameter("data_scale")->setNextValue(scale); LOGC("Scale updated to: ", scale); return "SUCCESS"; } @@ -260,7 +309,7 @@ String EphysSocket::handleConfigMessage(const String& msg) if (offset >= MIN_DATA_OFFSET && offset < MAX_DATA_OFFSET) { - data_offset = offset; + getParameter("data_offset")->setNextValue(offset); LOGC("Offset updated to: ", offset); return "SUCCESS"; } @@ -273,7 +322,7 @@ String EphysSocket::handleConfigMessage(const String& msg) if (_port > MIN_PORT && _port < MAX_PORT) { - port = _port; + getParameter("port")->setNextValue(_port); LOGC("Port updated to: ", _port); return "SUCCESS"; } @@ -286,7 +335,7 @@ String EphysSocket::handleConfigMessage(const String& msg) if (frequency > MIN_SAMPLE_RATE && frequency < MAX_SAMPLE_RATE) { - sample_rate = frequency; + getParameter("sample_rate")->setNextValue(frequency); LOGC("Frequency updated to: ", sample_rate); return "SUCCESS"; } diff --git a/Source/EphysSocket.h b/Source/EphysSocket.h index 79fd901..2f4b026 100644 --- a/Source/EphysSocket.h +++ b/Source/EphysSocket.h @@ -41,6 +41,9 @@ namespace EphysSocketNode /** Create the DataThread object*/ static DataThread* createDataThread(SourceNode* sn); + /** Registers the parameters for the DataThread */ + void registerParameters() override; + /** Returns true if socket is connected */ bool foundInputSource() override; @@ -52,6 +55,9 @@ namespace EphysSocketNode OwnedArray* devices, OwnedArray* configurationObjects); + /** Handles parameter value changes */ + void parameterValueChanged(Parameter* parameter) override; + /** Resizes buffers when input parameters are changed*/ void resizeBuffers(); diff --git a/Source/EphysSocketEditor.cpp b/Source/EphysSocketEditor.cpp index f076a87..eb09bf4 100644 --- a/Source/EphysSocketEditor.cpp +++ b/Source/EphysSocketEditor.cpp @@ -28,118 +28,15 @@ EphysSocketEditor::EphysSocketEditor(GenericProcessor* parentNode, EphysSocket* addAndMakeVisible(disconnectButton.get()); disconnectButton->setVisible(false); - // Port - portLabel = std::make_unique