Skip to content

Commit b0370b8

Browse files
committed
Merge branch 'tne-lab-fix-audio-node' into testing
2 parents 47f0fae + eb33540 commit b0370b8

4 files changed

Lines changed: 30 additions & 24 deletions

File tree

Source/Processors/AudioNode/AudioNode.cpp

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ AudioNode::AudioNode()
2929
: GenericProcessor("Audio Node"), audioEditor(0), volume(0.00001f), noiseGateLevel(0.0f)
3030
{
3131

32-
settings.numInputs = 4096;
32+
// settings.numInputs = 4096;
3333
settings.numOutputs = 2;
3434

35-
// 128 inputs, 2 outputs (left and right channel)
36-
setPlayConfigDetails(getNumInputs(), getNumOutputs(), 44100.0, 128);
35+
//updatePlaybackBuffer();
3736

38-
nextAvailableChannel = 2; // keep first two channels empty
37+
//nextAvailableChannel = 2; // keep first two channels empty
38+
resetConnections();
3939

4040
tempBuffer = new AudioSampleBuffer(16, 1024);
4141

@@ -57,12 +57,19 @@ AudioProcessorEditor* AudioNode::createEditor()
5757

5858
void AudioNode::resetConnections()
5959
{
60-
60+
settings.numInputs = 2; // "dummy" inputs that are actually just outputs
6161
nextAvailableChannel = 2; // start connections at channel 2
6262
wasConnected = false;
6363

6464
dataChannelArray.clear();
6565

66+
updatePlaybackBuffer();
67+
}
68+
69+
void AudioNode::registerProcessor(const GenericProcessor* sourceNode)
70+
{
71+
settings.numInputs += sourceNode->getNumOutputs();
72+
updatePlaybackBuffer();
6673
}
6774

6875
void AudioNode::updateBufferSize()
@@ -94,7 +101,7 @@ void AudioNode::setChannel(const DataChannel* ch)
94101
void AudioNode::setChannelStatus(const DataChannel* chan, bool status)
95102
{
96103

97-
setChannel(chan); // add 2 to account for 2 output channels
104+
setChannel(chan);
98105

99106
enableCurrentChannel(status);
100107

@@ -116,12 +123,8 @@ void AudioNode::enableCurrentChannel(bool state)
116123

117124
void AudioNode::addInputChannel(GenericProcessor* sourceNode, int chan)
118125
{
119-
120-
121126
int channelIndex = getNextChannel(false);
122127

123-
//setPlayConfigDetails(channelIndex+1,0,44100.0,128);
124-
125128
auto dataChannel = sourceNode->getDataChannel(chan);
126129
auto dataChannelCopy = new DataChannel(*dataChannel);
127130
dataChannelCopy->setMonitored(dataChannel->isMonitored());
@@ -132,7 +135,7 @@ void AudioNode::addInputChannel(GenericProcessor* sourceNode, int chan)
132135

133136
void AudioNode::updatePlaybackBuffer()
134137
{
135-
setPlayConfigDetails(dataChannelArray.size(), 0, 44100.0, 128);
138+
setPlayConfigDetails(getNumInputs(), 2, 44100.0, 128);
136139
}
137140

138141
void AudioNode::setParameter(int parameterIndex, float newValue)
@@ -256,12 +259,13 @@ void AudioNode::process(AudioSampleBuffer& buffer)
256259
AudioSampleBuffer* overflowBuffer;
257260
AudioSampleBuffer* backupBuffer;
258261

259-
if (dataChannelArray.size() > 0) // we have some channels
262+
int nInputs = dataChannelArray.size();
263+
if (nInputs > 0) // we have some channels
260264
{
261265

262266
// tempBuffer->clear();
263267

264-
for (int i = 0; i < buffer.getNumChannels()-2; i++) // cycle through them all
268+
for (int i = 0; i < nInputs; i++) // cycle through them all
265269
{
266270

267271
if (dataChannelArray[i]->isMonitored())

Source/Processors/AudioNode/AudioNode.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ class AudioNode : public GenericProcessor
129129
//Called by ProcessorGraph
130130
void updateRecordChannelIndexes();
131131

132+
// expand # of inputs for each connected processor
133+
void registerProcessor(const GenericProcessor* sourceNode);
134+
132135
private:
133136
void recreateBuffers();
134137

Source/Processors/GenericProcessor/GenericProcessor.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,11 +364,15 @@ void GenericProcessor::update()
364364

365365
for (int i = 0; i < dataChannelArray.size(); i++)
366366
{
367-
if (i < m_recordStatus.size())
368-
dataChannelArray[i]->setRecordState(m_recordStatus[i]);
369-
else
370-
if (isSource())
371-
dataChannelArray[i]->setRecordState(true);
367+
if (i < m_recordStatus.size())
368+
{
369+
dataChannelArray[i]->setRecordState(m_recordStatus[i]);
370+
dataChannelArray[i]->setMonitored(m_monitorStatus[i]);
371+
}
372+
else if (isSource())
373+
{
374+
dataChannelArray[i]->setRecordState(true);
375+
}
372376
}
373377
}
374378

Source/Processors/ProcessorGraph/ProcessorGraph.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -476,19 +476,14 @@ void ProcessorGraph::connectProcessorToAudioAndRecordNodes(GenericProcessor* sou
476476
if (source == nullptr)
477477
return;
478478

479+
getAudioNode()->registerProcessor(source);
479480
getRecordNode()->registerProcessor(source);
480481

481482
for (int chan = 0; chan < source->getNumOutputs(); chan++)
482483
{
483484

484485
getAudioNode()->addInputChannel(source, chan);
485486

486-
// THIS IS A HACK TO MAKE SURE AUDIO NODE KNOWS WHAT THE SAMPLE RATE SHOULD BE
487-
// IT CAN CAUSE PROBLEMS IF THE SAMPLE RATE VARIES ACROSS PROCESSORS
488-
489-
//TODO: See if this causes problems with the newer architectures
490-
//getAudioNode()->settings.sampleRate = source->getSampleRate();
491-
492487
addConnection(source->getNodeId(), // sourceNodeID
493488
chan, // sourceNodeChannelIndex
494489
AUDIO_NODE_ID, // destNodeID

0 commit comments

Comments
 (0)