Skip to content
Snippets Groups Projects
Commit e37ab550 authored by jsiegle's avatar jsiegle
Browse files

Added 16 channels of sample data to use for testing spike detection

parent fc9a0cb2
No related branches found
No related tags found
No related merge requests found
File added
...@@ -70,7 +70,7 @@ bool FileReaderThread::updateBuffer() ...@@ -70,7 +70,7 @@ bool FileReaderThread::updateBuffer()
if (input->isExhausted()) if (input->isExhausted())
input->setPosition(0); input->setPosition(0);
thisSample[ch%numChannels] = float(input->readShort()); thisSample[ch%numChannels] = float(input->readShort())/80000.0f;
} }
......
...@@ -315,7 +315,8 @@ GenericProcessor* ProcessorGraph::createProcessorFromDescription(String& descrip ...@@ -315,7 +315,8 @@ GenericProcessor* ProcessorGraph::createProcessorFromDescription(String& descrip
if (processorType.equalsIgnoreCase("Sources")) { if (processorType.equalsIgnoreCase("Sources")) {
if (subProcessorType.equalsIgnoreCase("Intan Demo Board")) { if (subProcessorType.equalsIgnoreCase("Intan Demo Board") ||
subProcessorType.equalsIgnoreCase("File Reader")) {
// only one Intan Demo Board at a time, please // only one Intan Demo Board at a time, please
if (!processorWithSameNameExists(subProcessorType)) { if (!processorWithSameNameExists(subProcessorType)) {
......
...@@ -26,18 +26,16 @@ ...@@ -26,18 +26,16 @@
SpikeDetector::SpikeDetector() SpikeDetector::SpikeDetector()
: GenericProcessor("Spike Detector"), : GenericProcessor("Spike Detector"),
sampleRate (40000.0), threshold(5000.0), prePeakMs(0.2), postPeakMs(0.6), threshold(5000.0), prePeakMs(0.2), postPeakMs(0.6),
accumulator(0) accumulator(0), overflowBuffer(2,100)
{ {
spikeBuffer = new MidiBuffer();
} }
SpikeDetector::~SpikeDetector() SpikeDetector::~SpikeDetector()
{ {
deleteAndZero(spikeBuffer);
} }
...@@ -53,14 +51,26 @@ AudioProcessorEditor* SpikeDetector::createEditor() ...@@ -53,14 +51,26 @@ AudioProcessorEditor* SpikeDetector::createEditor()
return editor; return editor;
} }
void SpikeDetector::updateSettings()
{
overflowBuffer.setSize(getNumInputs(),100);
thresh.clear();
for (int i = 0; i < getNumInputs(); i++)
{
thresh.add(threshold);
}
}
void SpikeDetector::setParameter (int parameterIndex, float newValue) void SpikeDetector::setParameter (int parameterIndex, float newValue)
{ {
//std::cout << "Message received." << std::endl; //std::cout << "Message received." << std::endl;
if (parameterIndex == 0) { if (parameterIndex == 0)
for (int n = 0; n < getNumOutputs(); n++) {
{ thresh.set(currentChannel,newValue);
thresh.set(n,newValue);
}
} }
} }
...@@ -85,22 +95,6 @@ bool SpikeDetector::enable() ...@@ -85,22 +95,6 @@ bool SpikeDetector::enable()
} }
// check configuration // check configuration
for (int ds = 0; ds < getConfiguration()->numDataSources(); ds++)
{
for (int tt = 0; tt < getConfiguration()->getSource(ds)->numTetrodes(); tt++)
{
Trode* t = getConfiguration()->getSource(ds)->getTetrode(tt);
for (int ch = 0; ch < t->numChannels(); ch++)
{
thresh.set(t->getChannel(ch),t->getThreshold(ch));
channels.set(t->getChannel(ch),t->getRawDataPointer());
nChans.set(t->getChannel(ch),t->numChannels());
isActive.set(t->getChannel(ch),t->getState(ch));
}
}
}
return true; return true;
...@@ -118,15 +112,13 @@ bool SpikeDetector::disable() ...@@ -118,15 +112,13 @@ bool SpikeDetector::disable()
} }
void SpikeDetector::process(AudioSampleBuffer &buffer, void SpikeDetector::process(AudioSampleBuffer &buffer,
MidiBuffer &midiMessages, MidiBuffer &events,
int& nSamples) int& nSamples)
{ {
int maxSamples = nSamples;//getNumSamples(midiMessages); int maxSamples = nSamples;//getNumSamples(midiMessages);
int spikeSize = 2 + prePeakSamples*2 + postPeakSamples*2; int spikeSize = 2 + prePeakSamples*2 + postPeakSamples*2;
spikeBuffer->clear();
for (int sample = prePeakSamples + 1; sample < maxSamples - postPeakSamples - 1; sample++) for (int sample = prePeakSamples + 1; sample < maxSamples - postPeakSamples - 1; sample++)
{ {
for (int chan = 0; chan < getNumOutputs(); chan++) for (int chan = 0; chan < getNumOutputs(); chan++)
...@@ -164,7 +156,7 @@ void SpikeDetector::process(AudioSampleBuffer &buffer, ...@@ -164,7 +156,7 @@ void SpikeDetector::process(AudioSampleBuffer &buffer,
} }
// broadcast spike // broadcast spike
spikeBuffer->addEvent(data, // spike data events.addEvent(data, // spike data
sizeof(data), // total bytes sizeof(data), // total bytes
sample); // sample index sample); // sample index
......
...@@ -25,12 +25,14 @@ ...@@ -25,12 +25,14 @@
#define __SPIKEDETECTOR_H_3F920F95__ #define __SPIKEDETECTOR_H_3F920F95__
#include "../../JuceLibraryCode/JuceHeader.h" #include "../../JuceLibraryCode/JuceHeader.h"
#include "GenericProcessor.h" #include "GenericProcessor.h"
#include "Editors/SpikeDetectorEditor.h" #include "Editors/SpikeDetectorEditor.h"
#include "../UI/Configuration.h"
/** /**
== UNDER CONSTRUCTION ==
Detects spikes in a continuous signal and outputs events containing the spike data. Detects spikes in a continuous signal and outputs events containing the spike data.
@see GenericProcessor, SpikeDetectorEditor @see GenericProcessor, SpikeDetectorEditor
...@@ -38,7 +40,6 @@ ...@@ -38,7 +40,6 @@
*/ */
class SpikeDetectorEditor; class SpikeDetectorEditor;
class FilterViewport;
class SpikeDetector : public GenericProcessor class SpikeDetector : public GenericProcessor
...@@ -48,20 +49,20 @@ public: ...@@ -48,20 +49,20 @@ public:
SpikeDetector(); SpikeDetector();
~SpikeDetector(); ~SpikeDetector();
void process(AudioSampleBuffer &buffer, MidiBuffer &midiMessages, int& nSamples); void process(AudioSampleBuffer &buffer, MidiBuffer &events, int& nSamples);
void setParameter (int parameterIndex, float newValue); void setParameter (int parameterIndex, float newValue);
void updateSettings();
bool enable(); bool enable();
bool disable(); bool disable();
MidiBuffer* getEventBuffer() {return spikeBuffer;}
AudioProcessorEditor* createEditor(); AudioProcessorEditor* createEditor();
bool hasEditor() const {return true;} AudioSampleBuffer overflowBuffer;
private: private:
double sampleRate, threshold; double threshold;
double prePeakMs, postPeakMs; double prePeakMs, postPeakMs;
int prePeakSamples, postPeakSamples; int prePeakSamples, postPeakSamples;
int accumulator; int accumulator;
...@@ -72,10 +73,6 @@ private: ...@@ -72,10 +73,6 @@ private:
Array<bool> isActive; Array<bool> isActive;
Array<int> lastSpike; Array<int> lastSpike;
MidiBuffer* spikeBuffer;
//AudioData::ConverterInstance<AudioData::Float32, AudioData::Int16> converter;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SpikeDetector); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SpikeDetector);
}; };
......
...@@ -40,7 +40,7 @@ ProcessorList::ProcessorList() : isDragging(false), ...@@ -40,7 +40,7 @@ ProcessorList::ProcessorList() : isDragging(false),
sources->addSubItem(new ProcessorListItem("Intan Demo Board")); sources->addSubItem(new ProcessorListItem("Intan Demo Board"));
sources->addSubItem(new ProcessorListItem("Signal Generator")); sources->addSubItem(new ProcessorListItem("Signal Generator"));
//sources->addSubItem(new ProcessorListItem("Custom FPGA")); //sources->addSubItem(new ProcessorListItem("Custom FPGA"));
//sources->addSubItem(new ProcessorListItem("File Reader")); sources->addSubItem(new ProcessorListItem("File Reader"));
sources->addSubItem(new ProcessorListItem("Event Generator")); sources->addSubItem(new ProcessorListItem("Event Generator"));
ProcessorListItem* filters = new ProcessorListItem("Filters"); ProcessorListItem* filters = new ProcessorListItem("Filters");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment