@@ -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
5858void 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
6875void AudioNode::updateBufferSize ()
@@ -94,7 +101,7 @@ void AudioNode::setChannel(const DataChannel* ch)
94101void 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
117124void 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
133136void AudioNode::updatePlaybackBuffer ()
134137{
135- setPlayConfigDetails (dataChannelArray. size (), 0 , 44100.0 , 128 );
138+ setPlayConfigDetails (getNumInputs (), 2 , 44100.0 , 128 );
136139}
137140
138141void 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 ())
0 commit comments