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
Branches
Tags
No related merge requests found
File added
......@@ -70,7 +70,7 @@ bool FileReaderThread::updateBuffer()
if (input->isExhausted())
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
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
if (!processorWithSameNameExists(subProcessorType)) {
......
......@@ -26,18 +26,16 @@
SpikeDetector::SpikeDetector()
: GenericProcessor("Spike Detector"),
sampleRate (40000.0), threshold(5000.0), prePeakMs(0.2), postPeakMs(0.6),
accumulator(0)
threshold(5000.0), prePeakMs(0.2), postPeakMs(0.6),
accumulator(0), overflowBuffer(2,100)
{
spikeBuffer = new MidiBuffer();
}
SpikeDetector::~SpikeDetector()
{
deleteAndZero(spikeBuffer);
}
......@@ -53,14 +51,26 @@ AudioProcessorEditor* SpikeDetector::createEditor()
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)
{
//std::cout << "Message received." << std::endl;
if (parameterIndex == 0) {
for (int n = 0; n < getNumOutputs(); n++)
{
thresh.set(n,newValue);
}
if (parameterIndex == 0)
{
thresh.set(currentChannel,newValue);
}
}
......@@ -85,22 +95,6 @@ bool SpikeDetector::enable()
}
// 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;
......@@ -118,15 +112,13 @@ bool SpikeDetector::disable()
}
void SpikeDetector::process(AudioSampleBuffer &buffer,
MidiBuffer &midiMessages,
MidiBuffer &events,
int& nSamples)
{
int maxSamples = nSamples;//getNumSamples(midiMessages);
int spikeSize = 2 + prePeakSamples*2 + postPeakSamples*2;
spikeBuffer->clear();
for (int sample = prePeakSamples + 1; sample < maxSamples - postPeakSamples - 1; sample++)
{
for (int chan = 0; chan < getNumOutputs(); chan++)
......@@ -164,7 +156,7 @@ void SpikeDetector::process(AudioSampleBuffer &buffer,
}
// broadcast spike
spikeBuffer->addEvent(data, // spike data
events.addEvent(data, // spike data
sizeof(data), // total bytes
sample); // sample index
......
......@@ -25,12 +25,14 @@
#define __SPIKEDETECTOR_H_3F920F95__
#include "../../JuceLibraryCode/JuceHeader.h"
#include "GenericProcessor.h"
#include "Editors/SpikeDetectorEditor.h"
#include "../UI/Configuration.h"
/**
== UNDER CONSTRUCTION ==
Detects spikes in a continuous signal and outputs events containing the spike data.
@see GenericProcessor, SpikeDetectorEditor
......@@ -38,7 +40,6 @@
*/
class SpikeDetectorEditor;
class FilterViewport;
class SpikeDetector : public GenericProcessor
......@@ -48,20 +49,20 @@ public:
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 updateSettings();
bool enable();
bool disable();
MidiBuffer* getEventBuffer() {return spikeBuffer;}
AudioProcessorEditor* createEditor();
bool hasEditor() const {return true;}
AudioSampleBuffer overflowBuffer;
private:
double sampleRate, threshold;
double threshold;
double prePeakMs, postPeakMs;
int prePeakSamples, postPeakSamples;
int accumulator;
......@@ -72,10 +73,6 @@ private:
Array<bool> isActive;
Array<int> lastSpike;
MidiBuffer* spikeBuffer;
//AudioData::ConverterInstance<AudioData::Float32, AudioData::Int16> converter;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SpikeDetector);
};
......
......@@ -40,7 +40,7 @@ ProcessorList::ProcessorList() : isDragging(false),
sources->addSubItem(new ProcessorListItem("Intan Demo Board"));
sources->addSubItem(new ProcessorListItem("Signal Generator"));
//sources->addSubItem(new ProcessorListItem("Custom FPGA"));
//sources->addSubItem(new ProcessorListItem("File Reader"));
sources->addSubItem(new ProcessorListItem("File Reader"));
sources->addSubItem(new ProcessorListItem("Event Generator"));
ProcessorListItem* filters = new ProcessorListItem("Filters");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment