Skip to content

Commit

Permalink
Compatibility updates for API9
Browse files Browse the repository at this point in the history
  • Loading branch information
anjaldoshi committed Oct 22, 2024
1 parent 5323b70 commit 7ac386a
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 167 deletions.
13 changes: 9 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ 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_XCODE_GENERATE_SCHEME YES)
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 @@ -70,7 +71,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 @@ -79,9 +80,13 @@ 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)
set_target_properties(${PLUGIN_NAME} PROPERTIES
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY ""
XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED NO)

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

#create filters for vs and xcode
Expand Down
5 changes: 3 additions & 2 deletions Source/SpectrumCanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <math.h>

SpectrumCanvas::SpectrumCanvas(SpectrumViewer* n)
: processor(n)
: Visualizer((GenericProcessor*)n)
, processor(n)
, displayType(POWER_SPECTRUM)
{
refreshRate = 60;
Expand Down Expand Up @@ -73,7 +74,7 @@ void SpectrumCanvas::paint(Graphics& g)
// g.fillAll(Colour(28,28,28));
}

void SpectrumCanvas::update()
void SpectrumCanvas::updateSettings()
{
canvasPlot->updateActiveChans();
}
Expand Down
2 changes: 1 addition & 1 deletion Source/SpectrumCanvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class SpectrumCanvas : public Visualizer
void refreshState();

/** Updates settings */
void update() override;
void updateSettings() override;

/** Called instead of repaint to avoid re-painting sub-components*/
void refresh() override;
Expand Down
70 changes: 39 additions & 31 deletions Source/SpectrumViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,22 @@ SpectrumViewer::SpectrumViewer()
tfrParams.alpha = 0;
tfrParams.nTimes = 1;

addIntParameter(Parameter::GLOBAL_SCOPE,
"active_stream", "Currently selected stream",
0, 0, 200000, true);
bufferResizer = std::make_unique<BufferResizer>(this);
}

void SpectrumViewer::registerParameters()
{
addSelectedStreamParameter (Parameter::PROCESSOR_SCOPE,
"active_stream",
"Display Stream",
"Currently selected stream",
{}, 0, true, true);

addSelectedChannelsParameter(Parameter::STREAM_SCOPE,
"Channels",
"Channels", "Channels",
"The channels to analyze",
MAX_CHANS,
false);

bufferResizer = std::make_unique<BufferResizer>(this);
}

AudioProcessorEditor* SpectrumViewer::createEditor()
Expand All @@ -68,27 +73,36 @@ void SpectrumViewer::parameterValueChanged(Parameter* param)
if (param->getName().equalsIgnoreCase("active_stream"))
{

uint16 candidateStream = (uint16) (int) param->getValue();
String streamKey = param->getValueAsString();

if (streamExists(candidateStream))
{
activeStream = candidateStream;
if (streamKey.isEmpty())
return;

tfrParams.Fs = getDataStream(activeStream)->getSampleRate();
tfrParams.freqStep = 1.0 / float(tfrParams.winLen * tfrParams.interpRatio);
tfrParams.nFreqs = int((tfrParams.freqEnd - tfrParams.freqStart) / tfrParams.freqStep);
LOGC("Setting active stream to: ", streamKey);

int bufferSize = int(tfrParams.Fs * tfrParams.winLen);
activeStream = getDataStream(streamKey)->getStreamId();

for (int i = 0; i < MAX_CHANS; i++)
{
powerBuffers[i].setBufferSize(bufferSize, tfrParams.stepLen * tfrParams.Fs);
powerBuffers[i].setNumFreqs(tfrParams.nFreqs);
}
tfrParams.Fs = getDataStream(activeStream)->getSampleRate();
tfrParams.freqStep = 1.0 / float(tfrParams.winLen * tfrParams.interpRatio);
tfrParams.nFreqs = int((tfrParams.freqEnd - tfrParams.freqStart) / tfrParams.freqStep);

int bufferSize = int(tfrParams.Fs * tfrParams.winLen);

for (int i = 0; i < MAX_CHANS; i++)
{
powerBuffers[i].setBufferSize(bufferSize, tfrParams.stepLen * tfrParams.Fs);
powerBuffers[i].setNumFreqs(tfrParams.nFreqs);
}

bufferResizer->resize();
bufferResizer->resize();

resetTFR();

resetTFR();
SelectedChannelsParameter* p = (SelectedChannelsParameter*) getDataStream(activeStream)->getParameter("Channels");
if (p != nullptr)
{
channels = p->getArrayValue();
getEditor()->updateVisualizer();
}

}
Expand All @@ -98,10 +112,7 @@ void SpectrumViewer::parameterValueChanged(Parameter* param)

SelectedChannelsParameter* p = (SelectedChannelsParameter*) param;

for (auto i : p->getArrayValue())
{
channels.add(int(i));
}
channels = p->getArrayValue();

getEditor()->updateVisualizer();
}
Expand Down Expand Up @@ -259,13 +270,10 @@ void SpectrumViewer::run()

void SpectrumViewer::updateSettings()
{

if(getDataStreams().size() == 0)
if (dataStreams.size() > 0)
{
activeStream = 0;
channels.clear();
parameterValueChanged(getDataStream(activeStream)->getParameter("Channels"));
}

}


Expand Down Expand Up @@ -318,7 +326,7 @@ bool SpectrumViewer::startAcquisition()
powerBuffers[i].reset();
}

startThread(THREAD_PRIORITY);
startThread();

}
return isEnabled;
Expand Down
3 changes: 3 additions & 0 deletions Source/SpectrumViewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ class SpectrumViewer :
/** Destructor */
~SpectrumViewer() { }

/** Register parameters for this processor */
void registerParameters() override;

/** Create SpectrumViewerEditor */
AudioProcessorEditor* createEditor() override;

Expand Down
Loading

0 comments on commit 7ac386a

Please sign in to comment.