@@ -31,11 +31,9 @@ AudioNode::AudioNode()
3131
3232 settings.numInputs = 4096 ;
3333 settings.numOutputs = 2 ;
34+ nextAvailableChannel = 2 ;
3435
35- // 128 inputs, 2 outputs (left and right channel)
36- setPlayConfigDetails (getNumInputs (), getNumOutputs (), 44100.0 , 128 );
37-
38- nextAvailableChannel = 2 ; // keep first two channels empty
36+ updatePlaybackBuffer ();
3937
4038 tempBuffer = new AudioSampleBuffer (16 , 1024 );
4139
@@ -57,12 +55,18 @@ AudioProcessorEditor* AudioNode::createEditor()
5755
5856void AudioNode::resetConnections ()
5957{
60-
61- nextAvailableChannel = 2 ; // start connections at channel 2
62- wasConnected = false ;
58+ settings.numInputs = 2 ; // "dummy" inputs that are actually just outputs
59+ nextAvailableChannel = 2 ;
6360
6461 dataChannelArray.clear ();
6562
63+ updatePlaybackBuffer ();
64+ }
65+
66+ void AudioNode::registerProcessor (const GenericProcessor* sourceNode)
67+ {
68+ settings.numInputs += sourceNode->getNumOutputs ();
69+ updatePlaybackBuffer ();
6670}
6771
6872void AudioNode::updateBufferSize ()
@@ -94,7 +98,7 @@ void AudioNode::setChannel(const DataChannel* ch)
9498void AudioNode::setChannelStatus (const DataChannel* chan, bool status)
9599{
96100
97- setChannel (chan); // add 2 to account for 2 output channels
101+ setChannel (chan);
98102
99103 enableCurrentChannel (status);
100104
@@ -116,12 +120,8 @@ void AudioNode::enableCurrentChannel(bool state)
116120
117121void AudioNode::addInputChannel (GenericProcessor* sourceNode, int chan)
118122{
119-
120-
121123 int channelIndex = getNextChannel (false );
122124
123- // setPlayConfigDetails(channelIndex+1,0,44100.0,128);
124-
125125 auto dataChannel = sourceNode->getDataChannel (chan);
126126 auto dataChannelCopy = new DataChannel (*dataChannel);
127127 dataChannelCopy->setMonitored (dataChannel->isMonitored ());
@@ -132,7 +132,7 @@ void AudioNode::addInputChannel(GenericProcessor* sourceNode, int chan)
132132
133133void AudioNode::updatePlaybackBuffer ()
134134{
135- setPlayConfigDetails (dataChannelArray. size (), 0 , 44100.0 , 128 );
135+ setPlayConfigDetails (getNumInputs (), 2 , 44100.0 , 128 );
136136}
137137
138138void AudioNode::setParameter (int parameterIndex, float newValue)
@@ -256,12 +256,13 @@ void AudioNode::process(AudioSampleBuffer& buffer)
256256 AudioSampleBuffer* overflowBuffer;
257257 AudioSampleBuffer* backupBuffer;
258258
259- if (dataChannelArray.size () > 0 ) // we have some channels
259+ int nInputs = dataChannelArray.size ();
260+ if (nInputs > 0 ) // we have some channels
260261 {
261262
262263// tempBuffer->clear();
263264
264- for (int i = 0 ; i < buffer. getNumChannels ()- 2 ; i++) // cycle through them all
265+ for (int i = 0 ; i < nInputs ; i++) // cycle through them all
265266 {
266267
267268 if (dataChannelArray[i]->isMonitored ())
0 commit comments