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

Add some logic to the ChannelMappingNode

parent 4c183d86
No related branches found
No related tags found
No related merge requests found
......@@ -30,7 +30,8 @@
ChannelMappingNode::ChannelMappingNode()
: GenericProcessor("Channel Mapping"), channelBuffer(1,10000)
{
referenceArray.resize(1024); // make room for 1024 channels
channelArray.resize(1024);
}
ChannelMappingNode::~ChannelMappingNode()
......@@ -51,18 +52,20 @@ AudioProcessorEditor* ChannelMappingNode::createEditor()
void ChannelMappingNode::updateSettings()
{
channelBuffer.setSize(getNumInputs(), 10000);
}
void ChannelMappingNode::setParameter(int parameterIndex, float newValue)
{
// editor->updateParameterButtons(parameterIndex);
// referenceChannel = (int) newValue;
// std::cout << "Reference set to " << referenceChannel << std::endl;
if (parameterIndex == 1)
{
referenceArray.set(currentChannel, (int) newValue);
} else
{
channelArray.set(currentChannel, (int) newValue);
}
}
......@@ -71,33 +74,45 @@ void ChannelMappingNode::process(AudioSampleBuffer& buffer,
int& nSamples)
{
// if (referenceChannel > -1)
// {
// referenceBuffer.clear(0, 0, nSamples);
// referenceBuffer.addFrom(0, // destChannel
// 0, // destStartSample
// buffer, // source
// referenceChannel, // sourceChannel
// 0, // sourceStartSample
// nSamples, // numSamples
// -1.0f // gain to apply to source
// );
// for (int i = 0; i < buffer.getNumChannels(); i++)
// {
// buffer.addFrom(i, // destChannel
// 0, // destStartSample
// referenceBuffer, // source
// 0, // sourceChannel
// 0, // sourceStartSample
// nSamples, // numSamples
// 1.0f // gain to apply to source
// );
// }
// }
// copy everything into the channel buffer
channelBuffer.setDataToReferTo(buffer.getArrayOfChannels(),
buffer.getNumChannels(),
buffer.getNumSamples());
// copy it back into the buffer according to the channel mapping
buffer.clear();
for (int i = 0; i < buffer.getNumChannels(); i++)
{
buffer.addFrom(i, // destChannel
0, // destStartSample
channelBuffer, // source
channelArray[i], // sourceChannel
0, // sourceStartSample
nSamples, // numSamples
1.0f // gain to apply to source (positive)
);
}
// now do the referencing
for (int i = 0; i < buffer.getNumChannels(); i++)
{
if (referenceArray[i] > -1)
{
buffer.addFrom(i, // destChannel
0, // destStartSample
channelBuffer, // source
referenceArray[i], // sourceChannel
0, // sourceStartSample
nSamples, // numSamples
-1.0f // gain to apply to source (negative for reference)
);
}
}
}
......@@ -97,6 +97,11 @@ void ChannelMappingEditor::createElectrodeButtons(int numNeeded)
button->addListener(this);
referenceArray.add(-1);
getProcessor()->setCurrentChannel(i);
getProcessor()->setParameter(0,i); // set channel mapping to standard channel
getProcessor()->setParameter(1,-1); // set reference to none
channelArray.add(i+1);
if (column%8 == 0)
......@@ -167,18 +172,20 @@ void ChannelMappingEditor::channelChanged(int chan)
electrodeButtons[i]->setChannelNum(chan);
electrodeButtons[i]->repaint();
getProcessor()->setCurrentChannel(i);
if (electrodeEditorButtons[1]->getToggleState()) // reference
{
referenceArray.set(i,chan);
getProcessor()->setParameter(1,chan-1); // set reference
} else {
channelArray.set(i,chan);
}
getProcessor()->setParameter(0,chan-1); // set mapping
}
// SpikeDetector* processor = (SpikeDetector*) getProcessor();
// processor->setChannel(electrodeList->getSelectedItemIndex(),
// i,
// chan-1);
}
}
}
......
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