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

New method for updating settings

parent 7047bf8e
No related branches found
No related tags found
No related merge requests found
Showing
with 145 additions and 489 deletions
...@@ -71,7 +71,6 @@ OBJECTS := \ ...@@ -71,7 +71,6 @@ OBJECTS := \
$(OBJDIR)/LfpDisplayCanvas_4a58e87e.o \ $(OBJDIR)/LfpDisplayCanvas_4a58e87e.o \
$(OBJDIR)/OpenGLCanvas_3c775a41.o \ $(OBJDIR)/OpenGLCanvas_3c775a41.o \
$(OBJDIR)/SpikeDetector_300d85e7.o \ $(OBJDIR)/SpikeDetector_300d85e7.o \
$(OBJDIR)/FileReader_18023b0e.o \
$(OBJDIR)/AudioNode_94606ff3.o \ $(OBJDIR)/AudioNode_94606ff3.o \
$(OBJDIR)/EventNode_95c842b7.o \ $(OBJDIR)/EventNode_95c842b7.o \
$(OBJDIR)/MergerEditor_d1fcc0df.o \ $(OBJDIR)/MergerEditor_d1fcc0df.o \
...@@ -274,11 +273,6 @@ $(OBJDIR)/SpikeDetector_300d85e7.o: ../../Source/Processors/SpikeDetector.cpp ...@@ -274,11 +273,6 @@ $(OBJDIR)/SpikeDetector_300d85e7.o: ../../Source/Processors/SpikeDetector.cpp
@echo "Compiling SpikeDetector.cpp" @echo "Compiling SpikeDetector.cpp"
@$(CXX) $(CXXFLAGS) -o "$@" -c "$<" @$(CXX) $(CXXFLAGS) -o "$@" -c "$<"
$(OBJDIR)/FileReader_18023b0e.o: ../../Source/Processors/FileReader.cpp
-@mkdir -p $(OBJDIR)
@echo "Compiling FileReader.cpp"
@$(CXX) $(CXXFLAGS) -o "$@" -c "$<"
$(OBJDIR)/AudioNode_94606ff3.o: ../../Source/Processors/AudioNode.cpp $(OBJDIR)/AudioNode_94606ff3.o: ../../Source/Processors/AudioNode.cpp
-@mkdir -p $(OBJDIR) -@mkdir -p $(OBJDIR)
@echo "Compiling AudioNode.cpp" @echo "Compiling AudioNode.cpp"
......
...@@ -45,7 +45,6 @@ ...@@ -45,7 +45,6 @@
B13883377C9316B9603336B4 = { isa = PBXBuildFile; fileRef = 2E96DA81EE37A0ECE471A928; }; B13883377C9316B9603336B4 = { isa = PBXBuildFile; fileRef = 2E96DA81EE37A0ECE471A928; };
073B178E7EF1759BA0AACCCE = { isa = PBXBuildFile; fileRef = 0C5335B0E57C9DC92FC57E5F; }; 073B178E7EF1759BA0AACCCE = { isa = PBXBuildFile; fileRef = 0C5335B0E57C9DC92FC57E5F; };
4BE0DDA01B73223EF0BD934A = { isa = PBXBuildFile; fileRef = 3DD0741FCFBC7563EC722D9B; }; 4BE0DDA01B73223EF0BD934A = { isa = PBXBuildFile; fileRef = 3DD0741FCFBC7563EC722D9B; };
6656467170D2822949BD2F7F = { isa = PBXBuildFile; fileRef = 5AC4DD48CCB1AB4936A2DE4A; };
08B501E0D7764C6B613AF529 = { isa = PBXBuildFile; fileRef = B7750B27E4F3748ECCCCF69D; }; 08B501E0D7764C6B613AF529 = { isa = PBXBuildFile; fileRef = B7750B27E4F3748ECCCCF69D; };
9CBA3837CC8CAA03A03F2D9C = { isa = PBXBuildFile; fileRef = FA57CE4F63FF1592D6B3F9B5; }; 9CBA3837CC8CAA03A03F2D9C = { isa = PBXBuildFile; fileRef = FA57CE4F63FF1592D6B3F9B5; };
93A3E6284F2DAED3F491332B = { isa = PBXBuildFile; fileRef = AD73EA6B24378294003DC2D0; }; 93A3E6284F2DAED3F491332B = { isa = PBXBuildFile; fileRef = AD73EA6B24378294003DC2D0; };
...@@ -196,8 +195,6 @@ ...@@ -196,8 +195,6 @@
7738F51AE0EC63D76EE0F761 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OpenGLCanvas.h; path = ../../Source/Processors/Visualization/OpenGLCanvas.h; sourceTree = SOURCE_ROOT; }; 7738F51AE0EC63D76EE0F761 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OpenGLCanvas.h; path = ../../Source/Processors/Visualization/OpenGLCanvas.h; sourceTree = SOURCE_ROOT; };
3DD0741FCFBC7563EC722D9B = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = SpikeDetector.cpp; path = ../../Source/Processors/SpikeDetector.cpp; sourceTree = SOURCE_ROOT; }; 3DD0741FCFBC7563EC722D9B = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = SpikeDetector.cpp; path = ../../Source/Processors/SpikeDetector.cpp; sourceTree = SOURCE_ROOT; };
6E4B37AA4BFEB5A37E3AC250 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SpikeDetector.h; path = ../../Source/Processors/SpikeDetector.h; sourceTree = SOURCE_ROOT; }; 6E4B37AA4BFEB5A37E3AC250 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SpikeDetector.h; path = ../../Source/Processors/SpikeDetector.h; sourceTree = SOURCE_ROOT; };
5AC4DD48CCB1AB4936A2DE4A = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = FileReader.cpp; path = ../../Source/Processors/FileReader.cpp; sourceTree = SOURCE_ROOT; };
44E93A2D64EB5ADA54CB2CFB = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FileReader.h; path = ../../Source/Processors/FileReader.h; sourceTree = SOURCE_ROOT; };
B7750B27E4F3748ECCCCF69D = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = AudioNode.cpp; path = ../../Source/Processors/AudioNode.cpp; sourceTree = SOURCE_ROOT; }; B7750B27E4F3748ECCCCF69D = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = AudioNode.cpp; path = ../../Source/Processors/AudioNode.cpp; sourceTree = SOURCE_ROOT; };
12866D44BE115E8837468F48 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = AudioNode.h; path = ../../Source/Processors/AudioNode.h; sourceTree = SOURCE_ROOT; }; 12866D44BE115E8837468F48 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = AudioNode.h; path = ../../Source/Processors/AudioNode.h; sourceTree = SOURCE_ROOT; };
FA57CE4F63FF1592D6B3F9B5 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = EventNode.cpp; path = ../../Source/Processors/EventNode.cpp; sourceTree = SOURCE_ROOT; }; FA57CE4F63FF1592D6B3F9B5 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = EventNode.cpp; path = ../../Source/Processors/EventNode.cpp; sourceTree = SOURCE_ROOT; };
...@@ -434,8 +431,6 @@ ...@@ -434,8 +431,6 @@
15543D7982B26B70879960F4, 15543D7982B26B70879960F4,
3DD0741FCFBC7563EC722D9B, 3DD0741FCFBC7563EC722D9B,
6E4B37AA4BFEB5A37E3AC250, 6E4B37AA4BFEB5A37E3AC250,
5AC4DD48CCB1AB4936A2DE4A,
44E93A2D64EB5ADA54CB2CFB,
B7750B27E4F3748ECCCCF69D, B7750B27E4F3748ECCCCF69D,
12866D44BE115E8837468F48, 12866D44BE115E8837468F48,
FA57CE4F63FF1592D6B3F9B5, FA57CE4F63FF1592D6B3F9B5,
...@@ -621,7 +616,6 @@ ...@@ -621,7 +616,6 @@
B13883377C9316B9603336B4, B13883377C9316B9603336B4,
073B178E7EF1759BA0AACCCE, 073B178E7EF1759BA0AACCCE,
4BE0DDA01B73223EF0BD934A, 4BE0DDA01B73223EF0BD934A,
6656467170D2822949BD2F7F,
08B501E0D7764C6B613AF529, 08B501E0D7764C6B613AF529,
9CBA3837CC8CAA03A03F2D9C, 9CBA3837CC8CAA03A03F2D9C,
93A3E6284F2DAED3F491332B, 93A3E6284F2DAED3F491332B,
......
...@@ -28,8 +28,8 @@ AudioNode::AudioNode() ...@@ -28,8 +28,8 @@ AudioNode::AudioNode()
: GenericProcessor("Audio Node"), volume(5.0f), audioEditor(0) : GenericProcessor("Audio Node"), volume(5.0f), audioEditor(0)
{ {
numInputs = 64; settings.numInputs = 64;
numOutputs = 2; settings.numOutputs = 2;
// 64 inputs, 2 outputs (left and right channel) // 64 inputs, 2 outputs (left and right channel)
setPlayConfigDetails(getNumInputs(),getNumOutputs(),44100.0,128); setPlayConfigDetails(getNumInputs(),getNumOutputs(),44100.0,128);
......
...@@ -54,11 +54,10 @@ class GenericEditor : public AudioProcessorEditor, ...@@ -54,11 +54,10 @@ class GenericEditor : public AudioProcessorEditor,
{ {
public: public:
GenericEditor (GenericProcessor* owner);//, FilterViewport* vp); GenericEditor (GenericProcessor* owner);
virtual ~GenericEditor(); virtual ~GenericEditor();
void paint (Graphics& g); void paint (Graphics& g);
//void setViewport(FilterViewport*);
bool keyPressed (const KeyPress& key); bool keyPressed (const KeyPress& key);
...@@ -83,7 +82,7 @@ public: ...@@ -83,7 +82,7 @@ public:
virtual void switchSource(int) { } // needed for MergerEditor virtual void switchSource(int) { } // needed for MergerEditor
virtual void switchSource() { }; // needed for MergerEditor virtual void switchSource() { }; // needed for MergerEditor
AudioProcessor* getProcessor() const {return getAudioProcessor();} GenericProcessor* getProcessor() const {return (GenericProcessor*) getAudioProcessor();}
void createRadioButtons(int x, int y, int w, StringArray values, const String& name); void createRadioButtons(int x, int y, int w, StringArray values, const String& name);
......
...@@ -101,14 +101,14 @@ void MergerEditor::buttonClicked(Button* button) ...@@ -101,14 +101,14 @@ void MergerEditor::buttonClicked(Button* button)
pipelineSelectorA->setToggleState(true,false); pipelineSelectorA->setToggleState(true,false);
pipelineSelectorB->setToggleState(false,false); pipelineSelectorB->setToggleState(false,false);
Merger* processor = (Merger*) getProcessor(); Merger* processor = (Merger*) getProcessor();
processor->switchSource(0); processor->switchIO(0);
} else if (button == pipelineSelectorB) } else if (button == pipelineSelectorB)
{ {
pipelineSelectorB->setToggleState(true,false); pipelineSelectorB->setToggleState(true,false);
pipelineSelectorA->setToggleState(false,false); pipelineSelectorA->setToggleState(false,false);
Merger* processor = (Merger*) getProcessor(); Merger* processor = (Merger*) getProcessor();
processor->switchSource(1); processor->switchIO(1);
} }
} }
...@@ -120,14 +120,14 @@ void MergerEditor::switchSource(int source) ...@@ -120,14 +120,14 @@ void MergerEditor::switchSource(int source)
pipelineSelectorA->setToggleState(true,false); pipelineSelectorA->setToggleState(true,false);
pipelineSelectorB->setToggleState(false,false); pipelineSelectorB->setToggleState(false,false);
Merger* processor = (Merger*) getProcessor(); Merger* processor = (Merger*) getProcessor();
processor->switchSource(0); processor->switchIO(0);
} else if (source == 1) } else if (source == 1)
{ {
pipelineSelectorB->setToggleState(true,false); pipelineSelectorB->setToggleState(true,false);
pipelineSelectorA->setToggleState(false,false); pipelineSelectorA->setToggleState(false,false);
Merger* processor = (Merger*) getProcessor(); Merger* processor = (Merger*) getProcessor();
processor->switchSource(1); processor->switchIO(1);
} }
} }
...@@ -143,6 +143,6 @@ void MergerEditor::switchSource() ...@@ -143,6 +143,6 @@ void MergerEditor::switchSource()
pipelineSelectorA->setToggleState(!isAOn,false); pipelineSelectorA->setToggleState(!isAOn,false);
Merger* processor = (Merger*) getProcessor(); Merger* processor = (Merger*) getProcessor();
processor->switchSource(); processor->switchIO();
} }
\ No newline at end of file
...@@ -101,14 +101,14 @@ void SplitterEditor::buttonClicked(Button* button) ...@@ -101,14 +101,14 @@ void SplitterEditor::buttonClicked(Button* button)
pipelineSelectorA->setToggleState(true,false); pipelineSelectorA->setToggleState(true,false);
pipelineSelectorB->setToggleState(false,false); pipelineSelectorB->setToggleState(false,false);
Splitter* processor = (Splitter*) getProcessor(); Splitter* processor = (Splitter*) getProcessor();
processor->switchDest(0); processor->switchIO(0);
} else if (button == pipelineSelectorB) } else if (button == pipelineSelectorB)
{ {
pipelineSelectorB->setToggleState(true,false); pipelineSelectorB->setToggleState(true,false);
pipelineSelectorA->setToggleState(false,false); pipelineSelectorA->setToggleState(false,false);
Splitter* processor = (Splitter*) getProcessor(); Splitter* processor = (Splitter*) getProcessor();
processor->switchDest(1); processor->switchIO(1);
} }
} }
...@@ -120,14 +120,14 @@ void SplitterEditor::switchDest(int dest) ...@@ -120,14 +120,14 @@ void SplitterEditor::switchDest(int dest)
pipelineSelectorA->setToggleState(true,false); pipelineSelectorA->setToggleState(true,false);
pipelineSelectorB->setToggleState(false,false); pipelineSelectorB->setToggleState(false,false);
Splitter* processor = (Splitter*) getProcessor(); Splitter* processor = (Splitter*) getProcessor();
processor->switchDest(0); processor->switchIO(0);
} else if (dest == 1) } else if (dest == 1)
{ {
pipelineSelectorB->setToggleState(true,false); pipelineSelectorB->setToggleState(true,false);
pipelineSelectorA->setToggleState(false,false); pipelineSelectorA->setToggleState(false,false);
Splitter* processor = (Splitter*) getProcessor(); Splitter* processor = (Splitter*) getProcessor();
processor->switchDest(1); processor->switchIO(1);
} }
} }
\ No newline at end of file
...@@ -27,10 +27,6 @@ ...@@ -27,10 +27,6 @@
EventNode::EventNode() EventNode::EventNode()
: GenericProcessor("Event Generator"), Hz(1), accumulator(0) : GenericProcessor("Event Generator"), Hz(1), accumulator(0)
{ {
setNumOutputs(0);
setNumInputs(0);
setPlayConfigDetails(getNumInputs(), getNumOutputs(), 44100.0, 128);
} }
...@@ -42,25 +38,17 @@ EventNode::~EventNode() ...@@ -42,25 +38,17 @@ EventNode::~EventNode()
AudioProcessorEditor* EventNode::createEditor() AudioProcessorEditor* EventNode::createEditor()
{ {
editor = new EventNodeEditor(this); editor = new EventNodeEditor(this);
//setEditor(editor);
std::cout << "Creating editor." << std::endl;
return editor; return editor;
} }
void EventNode::updateSettings()
bool EventNode::canSendSignalTo(GenericProcessor* p)
{ {
if (p->getName().equalsIgnoreCase("WiFi Output")) // add event channels
{ settings.eventChannelIds.add(1);
return true; settings.eventChannelNames.add("Trigger");
} else {
return false;
}
} }
void EventNode::setParameter (int parameterIndex, float newValue) void EventNode::setParameter (int parameterIndex, float newValue)
{ {
std::cout << "Setting frequency to " << newValue << " Hz." << std::endl; std::cout << "Setting frequency to " << newValue << " Hz." << std::endl;
...@@ -81,11 +69,10 @@ void EventNode::process(AudioSampleBuffer &buffer, ...@@ -81,11 +69,10 @@ void EventNode::process(AudioSampleBuffer &buffer,
if (accumulator > getSampleRate()/Hz) if (accumulator > getSampleRate()/Hz)
{ {
//std::cout << "Adding message." << std::endl; //std::cout << "Adding message." << std::endl;
addMidiEvent(midiMessages, 10, i); addEvent(midiMessages, 10, i);
accumulator = 0; accumulator = 0;
} }
} }
} }
...@@ -36,8 +36,6 @@ ...@@ -36,8 +36,6 @@
*/ */
class FilterViewport;
class EventNode : public GenericProcessor class EventNode : public GenericProcessor
{ {
...@@ -50,11 +48,10 @@ public: ...@@ -50,11 +48,10 @@ public:
void setParameter (int parameterIndex, float newValue); void setParameter (int parameterIndex, float newValue);
bool isSource() {return true;} bool isSource() {return true;}
bool hasEditor() const {return true;}
float getSampleRate() {return 44100.0;} int getDefaultNumOutputs() {return 0;}
bool canSendSignalTo(GenericProcessor*); void updateSettings();
AudioProcessorEditor* createEditor(); AudioProcessorEditor* createEditor();
......
/*
------------------------------------------------------------------
This file is part of the Open Ephys GUI
Copyright (C) 2012 Open Ephys
------------------------------------------------------------------
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "FileReader.h"
FileReader::FileReader()
: GenericProcessor("File Reader"),
sampleRate (40000.0),
numChannels(16),
samplesPerBlock(1024)
{
setNumOutputs(numChannels);
setNumInputs(0);
}
FileReader::~FileReader()
{
}
//AudioProcessorEditor* FileReader::createEditor( )
//{
//filterEditor = new FilterEditor(this);
// std::cout << "Creating editor." << std::endl;
// sourceEditor = new SourceNodeEditor(this);
// return sourceEditor;
//}
void FileReader::setParameter (int parameterIndex, float newValue)
{
//std::cout << "Message received." << std::endl;
}
bool FileReader::enable () {
File file = File("./data_stream_16ch");
input = file.createInputStream();
std::cout << "File Reader received enable signal." << std::endl;
return true;
}
bool FileReader::disable() {
deleteAndZero(input);
std::cout << "File reader received disable signal." << std::endl;
return true;
}
void FileReader::process(AudioSampleBuffer &buffer,
MidiBuffer &midiMessages,
int& nSamples)
{
nSamples = samplesPerBlock;
//std::cout << buffer.getNumChannels() << std::endl;
for (int i = 0; i < samplesPerBlock; ++i)
{
for (int j = 0; j < numChannels; j++) {
if (input->isExhausted())
input->setPosition(0);
const float sample = float(input->readShort());
*buffer.getSampleData (j, i) = sample;
}
}
}
\ No newline at end of file
/*
------------------------------------------------------------------
This file is part of the Open Ephys GUI
Copyright (C) 2012 Open Ephys
------------------------------------------------------------------
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __FILEREADER_H_605BF4A__
#define __FILEREADER_H_605BF4A__
#include "../../JuceLibraryCode/JuceHeader.h"
#include "GenericProcessor.h"
/**
--UNDER CONSTRUCTION--
Reads data from a file with a specific format.
@see GenericProcessor
*/
class FileReader : public GenericProcessor
{
public:
// real member functions:
FileReader();
~FileReader();
void process(AudioSampleBuffer &buffer, MidiBuffer &midiMessages, int& nSamples);
void setParameter (int parameterIndex, float newValue);
//AudioProcessorEditor* createEditor();
bool hasEditor() const {return true;}
bool enable();
bool disable();
bool isSource() {return true;}
private:
float sampleRate;
int numChannels;
int samplesPerBlock;
FileInputStream* input;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileReader);
};
#endif // __FILEREADER_H_605BF4A__
...@@ -81,51 +81,34 @@ AudioProcessorEditor* FilterNode::createEditor() ...@@ -81,51 +81,34 @@ AudioProcessorEditor* FilterNode::createEditor()
// necessary to interoperate with the Filter virtual base class and its derived classes // necessary to interoperate with the Filter virtual base class and its derived classes
void FilterNode::setNumInputs(int inputs) void FilterNode::updateSettings()
{ {
numInputs = inputs;
setNumOutputs(inputs);
filters.clear(); filters.clear();
lowCuts.clear(); lowCuts.clear();
highCuts.clear(); highCuts.clear();
if (inputs < 100) { if (getNumInputs() < 100) {
for (int n = 0; n < getNumInputs(); n++)
{
std::cout << "Creating filter number " << n << std::endl;
filters.add(new Dsp::SmoothedFilterDesign
<Dsp::Butterworth::Design::BandPass // design type
<4>, // order
1, // number of channels (must be const)
Dsp::DirectFormII> // realization
(1024));
lowCuts.add(1.0f);
highCuts.add(1000.0f);
setFilterParameters(1.0f, 1000.0f, n);
}
}
}
void FilterNode::setSampleRate(float r)
{
sampleRate = r;
if (numInputs < 100) {
for (int n = 0; n < getNumInputs(); n++) for (int n = 0; n < getNumInputs(); n++)
{ {
setFilterParameters(lowCuts[n], highCuts[n], n); std::cout << "Creating filter number " << n << std::endl;
filters.add(new Dsp::SmoothedFilterDesign
<Dsp::Butterworth::Design::BandPass // design type
<4>, // order
1, // number of channels (must be const)
Dsp::DirectFormII> // realization
(1024));
lowCuts.add(1.0f);
highCuts.add(1000.0f);
setFilterParameters(1.0f, 1000.0f, n);
} }
} }
} }
void FilterNode::setFilterParameters(double lowCut, double highCut, int chan) void FilterNode::setFilterParameters(double lowCut, double highCut, int chan)
......
...@@ -52,9 +52,8 @@ public: ...@@ -52,9 +52,8 @@ public:
AudioProcessorEditor* createEditor(); AudioProcessorEditor* createEditor();
bool hasEditor() const {return true;} bool hasEditor() const {return true;}
void setNumInputs(int); void updateSettings();
void setSampleRate(float);
private: private:
......
...@@ -32,7 +32,6 @@ GenericProcessor::GenericProcessor(const String& name_) : ...@@ -32,7 +32,6 @@ GenericProcessor::GenericProcessor(const String& name_) :
nextAvailableChannel(0), currentChannel(-1), nextAvailableChannel(0), currentChannel(-1),
wasConnected(false) wasConnected(false)
{ {
} }
GenericProcessor::~GenericProcessor() GenericProcessor::~GenericProcessor()
...@@ -52,41 +51,6 @@ void GenericProcessor::setParameter (int parameterIndex, float newValue) ...@@ -52,41 +51,6 @@ void GenericProcessor::setParameter (int parameterIndex, float newValue)
} }
GenericProcessor* GenericProcessor::getOriginalSourceNode()
{
if (isSource())
{
return this;
} else {
GenericProcessor* source = getSourceNode();
if (source != 0)
{
while (!source->isSource() && source != 0)
{
source = source->getSourceNode();
}
return source;
} else {
return 0;
}
}
}
int GenericProcessor::getDefaultNumOutputs()
{
if (!isSink())
{
return 10;
} else {
return 0;
}
}
void GenericProcessor::prepareToPlay (double sampleRate_, int estimatedSamplesPerBlock) void GenericProcessor::prepareToPlay (double sampleRate_, int estimatedSamplesPerBlock)
{ {
// use the enable() function instead // use the enable() function instead
...@@ -101,15 +65,6 @@ void GenericProcessor::releaseResources() ...@@ -101,15 +65,6 @@ void GenericProcessor::releaseResources()
// disable() is only called by the ProcessorGraph at the end of acquisition // disable() is only called by the ProcessorGraph at the end of acquisition
} }
// void GenericProcessor::sendMessage(const String& msg)
// {
// std::cout << "Message: ";
// std::cout << msg << "...." << std::endl;
// UI->transmitMessage(msg);
// }
int GenericProcessor::getNextChannel(bool increment) int GenericProcessor::getNextChannel(bool increment)
{ {
int chan = nextAvailableChannel; int chan = nextAvailableChannel;
...@@ -278,80 +233,75 @@ void GenericProcessor::setDestNode(GenericProcessor* dn) ...@@ -278,80 +233,75 @@ void GenericProcessor::setDestNode(GenericProcessor* dn)
} }
} }
void GenericProcessor::updateSettings() void GenericProcessor::clearSettings()
{ {
settings.originalSource = 0;
settings.numInputs = 0;
settings.numOutputs = 0;
settings.inputChannelNames.clear();
settings.outputChannelNames.clear();
settings.bitVolts.clear();
settings.eventChannelIds.clear();
settings.eventChannelNames.clear();
}
void GenericProcessor::update()
{
clearSettings();
if (sourceNode != 0) if (sourceNode != 0)
{ {
setSampleRate(sourceNode->getSampleRate()); // everything is inherited except numOutputs
setNumInputs(sourceNode->getNumOutputs()); settings = sourceNode->settings;
settings.numOutputs = settings.numInputs;
} else { } else {
setSampleRate(getDefaultSampleRate());
setNumInputs(0);
setNumOutputs(getDefaultNumOutputs());
}
setPlayConfigDetails(getNumInputs(), getNumOutputs(), 44100.0, 128); settings.sampleRate = getDefaultSampleRate();
settings.numOutputs = getDefaultNumOutputs();
updateParameters(); for (int i = 0; i < getNumOutputs(); i++)
settings.bitVolts.add(getDefaultBitVolts());
GenericEditor* editor = (GenericEditor*) getEditor(); generateDefaultChannelNames(settings.outputChannelNames);
editor->update(); }
} if (this->isSink())
{
settings.numOutputs = 0;
settings.outputChannelNames.clear();
}
void GenericProcessor::updateParameters() updateSettings(); // custom settings code
{
}
// required for the ProcessorGraph to know the
// details of this processor:
setPlayConfigDetails(getNumInputs(), // numIns
getNumOutputs(), // numOuts
44100.0, // sampleRate
128); // blockSize
int GenericProcessor::getNumInputs() editor->update(); // update editor settings
{
return numInputs;
}
int GenericProcessor::getNumOutputs()
{
return numOutputs;
} }
void GenericProcessor::setNumInputs(int n) { void GenericProcessor::generateDefaultChannelNames(StringArray& names)
numInputs = n;
// if (destNode != 0)
// {
// destNode->setNumInputs();
// }
//setPlayConfigDetails(numInputs,numOutputs,44100.0,1024);
}
void GenericProcessor::setNumInputs() {
int n = getSourceNode()->getNumOutputs();
setNumInputs(n);
}
void GenericProcessor::setNumOutputs()
{ {
setNumOutputs(getNumInputs()); names.clear();
}
void GenericProcessor::setNumOutputs(int n) { for (int i = 0; i < settings.numOutputs; i++)
numOutputs = n; {
//setPlayConfigDetails(numInputs,numOutputs,44100.0,1024); String channelName = "CH";
} channelName += (i+1);
names.add(channelName);
}
float GenericProcessor::getSampleRate()
{
return sampleRate;
}
void GenericProcessor::setSampleRate(float sr)
{
sampleRate = sr;
} }
int GenericProcessor::checkForMidiEvents(MidiBuffer& midiMessages)
int GenericProcessor::checkForEvents(MidiBuffer& midiMessages)
{ {
if (midiMessages.getNumEvents() > 0) if (midiMessages.getNumEvents() > 0)
...@@ -388,7 +338,7 @@ int GenericProcessor::checkForMidiEvents(MidiBuffer& midiMessages) ...@@ -388,7 +338,7 @@ int GenericProcessor::checkForMidiEvents(MidiBuffer& midiMessages)
} }
void GenericProcessor::addMidiEvent(MidiBuffer& midiMessages, int numberToAdd, int sampleNum) void GenericProcessor::addEvent(MidiBuffer& midiMessages, int numberToAdd, int sampleNum)
{ {
uint8 data[2]; uint8 data[2];
......
...@@ -112,30 +112,19 @@ public: ...@@ -112,30 +112,19 @@ public:
GenericProcessor* sourceNode; GenericProcessor* sourceNode;
GenericProcessor* destNode; GenericProcessor* destNode;
int numInputs; virtual float getSampleRate() {return settings.sampleRate;}
int numOutputs;
float sampleRate;
virtual float getSampleRate();
virtual void setSampleRate(float sr);
virtual float getDefaultSampleRate() {return 44100.0;} virtual float getDefaultSampleRate() {return 44100.0;}
virtual int getNumInputs(); virtual int getNumInputs() {return settings.numInputs;}
virtual void setNumInputs(int); virtual int getNumOutputs() {return settings.numOutputs;}
virtual void setNumInputs(); virtual int getDefaultNumOutputs() {return 2;}
virtual int getNumOutputs(); //virtual float getBitVolts() {return settings.bitVolts;}
virtual void setNumOutputs(int); virtual float getDefaultBitVolts() {return 1.0;}
virtual void setNumOutputs();
virtual int getDefaultNumOutputs();
virtual int getNextChannel(bool); virtual int getNextChannel(bool);
virtual void resetConnections(); virtual void resetConnections();
virtual void updateSettings(); // updates sample rate and number of channels
virtual void updateParameters(); // called in updateSettings() to update params
virtual void setCurrentChannel(int chan) {currentChannel = chan;} virtual void setCurrentChannel(int chan) {currentChannel = chan;}
int getNodeId() {return nodeId;} int getNodeId() {return nodeId;}
...@@ -144,12 +133,9 @@ public: ...@@ -144,12 +133,9 @@ public:
// get/set source node functions // get/set source node functions
GenericProcessor* getSourceNode() {return sourceNode;} GenericProcessor* getSourceNode() {return sourceNode;}
GenericProcessor* getDestNode() {return destNode;} GenericProcessor* getDestNode() {return destNode;}
GenericProcessor* getOriginalSourceNode();
virtual void switchSource(int) { }; virtual void switchIO(int) { };
virtual void switchSource() { }; virtual void switchIO() { };
virtual void switchDest() { };
virtual void switchDest(int) { };
virtual void setSourceNode(GenericProcessor* sn); virtual void setSourceNode(GenericProcessor* sn);
virtual void setDestNode(GenericProcessor* dn); virtual void setDestNode(GenericProcessor* dn);
...@@ -177,8 +163,8 @@ public: ...@@ -177,8 +163,8 @@ public:
int nextAvailableChannel; int nextAvailableChannel;
int checkForMidiEvents(MidiBuffer& mb); int checkForEvents(MidiBuffer& mb);
void addMidiEvent(MidiBuffer& mb, int a, int b); void addEvent(MidiBuffer& mb, int a, int b);
bool isEnabled; bool isEnabled;
...@@ -192,6 +178,32 @@ public: ...@@ -192,6 +178,32 @@ public:
virtual GenericEditor* getEditor() {return editor;} virtual GenericEditor* getEditor() {return editor;}
ScopedPointer<GenericEditor> editor; ScopedPointer<GenericEditor> editor;
struct ProcessorSettings {
GenericProcessor* originalSource;
int numInputs;
int numOutputs;
StringArray inputChannelNames;
StringArray outputChannelNames;
float sampleRate;
Array<float> bitVolts;
Array<int> eventChannelIds;
StringArray eventChannelNames;
};
ProcessorSettings settings;
virtual void clearSettings();
virtual void generateDefaultChannelNames(StringArray&);
virtual void update(); // default node updating
virtual void updateSettings() {};
private: private:
void processBlock (AudioSampleBuffer &buffer, MidiBuffer &midiMessages); void processBlock (AudioSampleBuffer &buffer, MidiBuffer &midiMessages);
......
...@@ -30,64 +30,32 @@ LfpDisplayNode::LfpDisplayNode() ...@@ -30,64 +30,32 @@ LfpDisplayNode::LfpDisplayNode()
displayBufferIndex(0), abstractFifo(100) displayBufferIndex(0), abstractFifo(100)
{ {
displayBuffer = new AudioSampleBuffer(8, 100);
numInputs = 2;
numOutputs = 0;
sampleRate = 44100.0;
setPlayConfigDetails(2,0,44100.0,128);
displayBuffer = new AudioSampleBuffer (8, 100);
eventBuffer = new MidiBuffer(); eventBuffer = new MidiBuffer();
} }
LfpDisplayNode::~LfpDisplayNode() LfpDisplayNode::~LfpDisplayNode()
{ {
//deleteAndZero(displayBuffer);
deleteAndZero(displayBuffer); //deleteAndZero(eventBuffer);
deleteAndZero(eventBuffer);
} }
AudioProcessorEditor* LfpDisplayNode::createEditor() AudioProcessorEditor* LfpDisplayNode::createEditor()
{ {
editor = new LfpDisplayEditor(this); editor = new LfpDisplayEditor(this);
//editor->setBuffers (displayBuffer, eventBuffer);
//editor->setUIComponent (getUIComponent());
//editor->setConfiguration (config);
//editor->updateNumInputs(getNumInputs());
//editor->updateSampleRate(sampleRate);
//setEditor(editor);
return editor; return editor;
} }
void LfpDisplayNode::setNumInputs(int inputs) void LfpDisplayNode::updateSettings()
{
std::cout << "Setting num inputs on LfpDisplayNode to " << inputs << std::endl;
numInputs = inputs;
setNumOutputs(0);
setPlayConfigDetails(getNumInputs(),0,44100.0,128);
LfpDisplayEditor* editor = (LfpDisplayEditor*) getEditor();
editor->updateNumInputs(inputs);
}
void LfpDisplayNode::setSampleRate(float r)
{ {
sampleRate = r; std::cout << "Setting num inputs on LfpDisplayNode to " << getNumInputs() << std::endl;
LfpDisplayEditor* editor = (LfpDisplayEditor*) getEditor();
editor->updateSampleRate(r);
} }
bool LfpDisplayNode::resizeBuffer() bool LfpDisplayNode::resizeBuffer()
{ {
int nSamples = (int) sampleRate*bufferLength; int nSamples = (int) getSampleRate()*bufferLength;
int nInputs = getNumInputs(); int nInputs = getNumInputs();
std::cout << "Resizing buffer. Samples: " << nSamples << ", Inputs: " << nInputs << std::endl; std::cout << "Resizing buffer. Samples: " << nSamples << ", Inputs: " << nInputs << std::endl;
......
...@@ -56,8 +56,7 @@ public: ...@@ -56,8 +56,7 @@ public:
void setParameter(int, float); void setParameter(int, float);
void setNumInputs(int inputs); void updateSettings();
void setSampleRate(float r);
bool enable(); bool enable();
bool disable(); bool disable();
...@@ -67,10 +66,8 @@ public: ...@@ -67,10 +66,8 @@ public:
private: private:
DataViewport* dataViewport; ScopedPointer<AudioSampleBuffer> displayBuffer;
ScopedPointer<MidiBuffer> eventBuffer;
AudioSampleBuffer* displayBuffer;
MidiBuffer* eventBuffer;
int displayBufferIndex; int displayBufferIndex;
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include "AudioNode.h" #include "AudioNode.h"
#include "LfpDisplayNode.h" #include "LfpDisplayNode.h"
#include "EventNode.h" #include "EventNode.h"
#include "FileReader.h"
#include "FilterNode.h" #include "FilterNode.h"
#include "GenericProcessor.h" #include "GenericProcessor.h"
#include "RecordNode.h" #include "RecordNode.h"
...@@ -285,7 +284,7 @@ void ProcessorGraph::updateConnections(Array<SignalChainTabButton*, CriticalSect ...@@ -285,7 +284,7 @@ void ProcessorGraph::updateConnections(Array<SignalChainTabButton*, CriticalSect
{ {
dest = splitters.getFirst(); // dest is now the splitter dest = splitters.getFirst(); // dest is now the splitter
splitters.remove(0); // take it out of the splitters.remove(0); // take it out of the
dest->switchDest(); // switch to the other destination dest->switchIO(); // switch to the other destination
dest->wasConnected = true; // don't want to re-add splitter dest->wasConnected = true; // don't want to re-add splitter
source = dest->getSourceNode(); // splitter is now source source = dest->getSourceNode(); // splitter is now source
} }
......
...@@ -45,13 +45,8 @@ ...@@ -45,13 +45,8 @@
class GenericProcessor; class GenericProcessor;
class RecordNode; class RecordNode;
class SignalChainTabButton;
class AudioNode; class AudioNode;
//class SourceNode; class SignalChainTabButton;
//class EditorViewport;
//class UIComponent;
//class Configuration;
//class MessageCenter;
class ProcessorGraph : public AudioProcessorGraph, class ProcessorGraph : public AudioProcessorGraph,
public AccessClass public AccessClass
...@@ -71,11 +66,6 @@ public: ...@@ -71,11 +66,6 @@ public:
RecordNode* getRecordNode(); RecordNode* getRecordNode();
AudioNode* getAudioNode(); AudioNode* getAudioNode();
//void setUIComponent(UIComponent* ui);
//void setFilterViewport(FilterViewport *fv);
//void setMessageCenter(MessageCenter* mc);
//void setConfiguration(Configuration* config);
void updateConnections(Array<SignalChainTabButton*, CriticalSection>); void updateConnections(Array<SignalChainTabButton*, CriticalSection>);
bool processorWithSameNameExists(const String& name); bool processorWithSameNameExists(const String& name);
...@@ -83,9 +73,6 @@ public: ...@@ -83,9 +73,6 @@ public:
void saveState(); void saveState();
void loadState(); void loadState();
//int getNextFreeAudioChannel();
//int getNextFreeRecordChannel();
private: private:
int currentNodeId; int currentNodeId;
...@@ -100,14 +87,6 @@ private: ...@@ -100,14 +87,6 @@ private:
void createDefaultNodes(); void createDefaultNodes();
void clearConnections(); void clearConnections();
//UIComponent* UI;
//FilterViewport* filterViewport;
///Configuration* config;
//MessageCenter* messageCenter;
//int totalAudioConnections;
//int totalRecordConnections;
}; };
......
...@@ -33,11 +33,11 @@ ResamplingNode::ResamplingNode(bool destBufferType) ...@@ -33,11 +33,11 @@ ResamplingNode::ResamplingNode(bool destBufferType)
{ {
setNumInputs(2); settings.numInputs = 2;
setNumOutputs(2); settings.numOutputs = 2;
setPlayConfigDetails(2, // number of inputs setPlayConfigDetails(getNumInputs(), // number of inputs
2, // number of outputs getNumOutputs(), // number of outputs
44100.0, // sampleRate 44100.0, // sampleRate
128); // blockSize 128); // blockSize
......
...@@ -34,43 +34,21 @@ SignalGenerator::SignalGenerator() ...@@ -34,43 +34,21 @@ SignalGenerator::SignalGenerator()
{ {
setNumOutputs(10);
setNumInputs(0);
setPlayConfigDetails(getNumInputs(), getNumOutputs(), 44100.0, 128);
} }
SignalGenerator::~SignalGenerator() SignalGenerator::~SignalGenerator()
{ {
//config->removeDataSource(this);
}
}
// void SignalGenerator::setConfiguration(Configuration* cf)
// {
// config = cf;
// DataSource* d = new DataSource(this, config);
// // add a new data source to this configuration
// config->addDataSource(d);
// }
AudioProcessorEditor* SignalGenerator::createEditor( ) AudioProcessorEditor* SignalGenerator::createEditor( )
{ {
editor = new SignalGeneratorEditor(this); editor = new SignalGeneratorEditor(this);
//setEditor(ed);
//std::cout << "Creating editor." << std::endl;
//filterEditor = new FilterEditor(this);
return editor; return editor;
} }
void SignalGenerator::updateParameters() void SignalGenerator::updateSettings()
{ {
std::cout << "Signal generator updating parameters" << std::endl; std::cout << "Signal generator updating parameters" << std::endl;
...@@ -99,7 +77,7 @@ void SignalGenerator::setParameter (int parameterIndex, float newValue) ...@@ -99,7 +77,7 @@ void SignalGenerator::setParameter (int parameterIndex, float newValue)
amplitudes.set(currentChannel,newValue); amplitudes.set(currentChannel,newValue);
} else { } else {
frequencies.set(currentChannel,newValue); frequencies.set(currentChannel,newValue);
phasePerSample.set(currentChannel, double_Pi * 2.0 / (sampleRate / frequencies[currentChannel])); phasePerSample.set(currentChannel, double_Pi * 2.0 / (getSampleRate() / frequencies[currentChannel]));
} }
} }
......
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