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

Greatly simplified process of updating settings

Processors used to have their sample rate and inputs/outputs set when
their source/dest nodes were set. Now, this step doesn't occur until
after the signal chains are constructed. So far, this seems to make
things run much more smoothly.
parent 619424e5
Branches
No related tags found
No related merge requests found
......@@ -80,18 +80,18 @@ void FilterEditor::buttonClicked (Button* button)
String value = button->getName();
float val;
if (value.getLastCharacter() == juce_wchar('k')) {
val = value.dropLastCharacters(1).getFloatValue() * 1000.0f;
}
else {
val = value.getFloatValue();
}
//if (button->getRadioGroupId() == 1)
/// //getAudioProcessor()->setParameter(0,val);
//else
//getAudioProcessor()->setParameter(1,val);
//std::cout << button->getRadioGroupId() << " " << val << std::endl;
// if (value.getLastCharacter() == juce_wchar('k')) {
// val = value.dropLastCharacters(1).getFloatValue() * 1000.0f;
// }
// else {
val = value.getFloatValue();
// }
if (button->getRadioGroupId() == 1)
getAudioProcessor()->setParameter(0,val);
else
getAudioProcessor()->setParameter(1,val*1000.0f);
std::cout << button->getRadioGroupId() << " " << val << std::endl;
}
\ No newline at end of file
......@@ -27,13 +27,13 @@
FilterNode::FilterNode()
: GenericProcessor("Bandpass Filter"), filter(0),
highCut(6000.0), lowCut(600.0)
highCut(6000.0), lowCut(1.0)
{
setNumInputs(16);
setSampleRate(25000.0);
//setNumInputs(16);
//setSampleRate(25000.0);
// set up default configuration
setPlayConfigDetails(16, 16, 44100.0, 128);
//setPlayConfigDetails(16, 16, 44100.0, 128);
// each family of filters is given its own namespace
// RBJ: filters from the RBJ cookbook
......@@ -121,18 +121,24 @@ void FilterNode::setNumInputs(int inputs)
(1024); // number of samples over which to fade
// parameter changes
} else if (nChans == 10) {
filter = new Dsp::SmoothedFilterDesign
<Dsp::Butterworth::Design::BandPass // design type
<4>, // order
10 , // number of channels (must be const)
Dsp::DirectFormII> // realization
(1024); // number of samples over which to fade
// parameter changes
} else {
// send a message saying this is not implemented
}
//std::cout << "Filter created with " << getNumInputs() << " channels." << std::endl;
setFilterParameters();
setPlayConfigDetails(getNumInputs(), getNumOutputs(), 44100.0, 128);
}
//AudioProcessorEditor* FilterNode::createEditor(AudioProcessorEditor* const editor)
......
......@@ -164,8 +164,8 @@ void GenericProcessor::setSourceNode(GenericProcessor* sn)
std::cout << " The source is new and named " << sn->getName() << std::endl;
sourceNode = sn;
sn->setDestNode(this);
setNumInputs(sn->getNumOutputs());
setSampleRate(sn->getSampleRate());
//setNumInputs(sn->getNumOutputs());
//setSampleRate(sn->getSampleRate());
} else {
std::cout << " The source node is not new." << std::endl;
}
......@@ -212,8 +212,8 @@ void GenericProcessor::setDestNode(GenericProcessor* dn)
destNode = dn;
dn->setSourceNode(this);
dn->setNumInputs(getNumOutputs());
dn->setSampleRate(getSampleRate());
//dn->setNumInputs(getNumOutputs());
//dn->setSampleRate(getSampleRate());
} else {
std::cout << " The dest node is not new." << std::endl;
}
......@@ -236,6 +236,23 @@ void GenericProcessor::setDestNode(GenericProcessor* dn)
}
}
void GenericProcessor::updateSettings()
{
if (sourceNode != 0)
{
setSampleRate(sourceNode->getSampleRate());
setNumInputs(sourceNode->getNumOutputs());
} else {
setSampleRate(getDefaultSampleRate());
setNumInputs(0);
setNumOutputs(getDefaultNumOutputs());
}
setPlayConfigDetails(getNumInputs(), getNumOutputs(), 44100.0, 128);
}
int GenericProcessor::getNumInputs()
{
......
......@@ -121,14 +121,27 @@ public:
virtual float getSampleRate();
virtual void setSampleRate(float sr);
virtual float getDefaultSampleRate() {return 44100.0;}
virtual int getNumInputs();
virtual void setNumInputs(int);
virtual void setNumInputs();
virtual int getNumOutputs();
virtual void setNumOutputs(int);
virtual void setNumOutputs();
virtual int getDefaultNumOutputs()
{
if (!isSink())
{
return 10;
} else {
return 0;
}
}
virtual void updateSettings();
int getNodeId() {return nodeId;}
void setNodeId(int id) {nodeId = id;}
......
......@@ -81,6 +81,22 @@ float SourceNode::getSampleRate()
return 44100.0;
}
float SourceNode::getDefaultSampleRate()
{
if (dataThread != 0)
return dataThread->getSampleRate();
else
return 44100.0;
}
int SourceNode::getDefaultNumOutputs()
{
if (dataThread != 0)
return dataThread->getNumChannels();
else
return 0;
}
void SourceNode::enabledState(bool t)
{
if (t && !dataThread->foundInputSource())
......@@ -90,7 +106,6 @@ void SourceNode::enabledState(bool t)
isEnabled = t;
}
}
void SourceNode::setConfiguration(Configuration* cf)
......
......@@ -63,6 +63,8 @@ public:
void setConfiguration(Configuration* cf);
float getSampleRate();
float getDefaultSampleRate();
int getDefaultNumOutputs();
// void setSourceNode(GenericProcessor* sn);
// void setDestNode(GenericProcessor* dn);
......
......@@ -532,9 +532,28 @@ void FilterViewport::updateVisibleEditors(GenericEditor* activeEditor, int actio
}
}
// Step 7: update all settings
std::cout << "Updating settings." << std::endl;
for (int n = 0; n < signalChainArray.size(); n++)
{
GenericEditor* source = (GenericEditor*) signalChainArray[n]->getEditor();
GenericProcessor* p = (GenericProcessor*) source->getProcessor();
p->updateSettings();
GenericProcessor* dest = p->getDestNode();
while (dest != 0)
{
dest->updateSettings();
dest = dest->getDestNode();
}
}
// std::cout << "OK2." << std::endl;
// Step 7: make sure all editors are visible, and refresh
// Step 8: make sure all editors are visible, and refresh
for (int n = 0; n < editorArray.size(); n++)
{
// std::cout << "Editor " << n << ": " << editorArray[n]->getName() << std::endl;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment