| @@ -134,6 +134,12 @@ void JuceDemoPluginAudioProcessor::process (AudioBuffer<FloatType>& buffer, | |||||
| { | { | ||||
| const int numSamples = buffer.getNumSamples(); | const int numSamples = buffer.getNumSamples(); | ||||
| // In case we have more outputs than inputs, we'll clear any output | |||||
| // channels that didn't contain input data, (because these aren't | |||||
| // guaranteed to be empty - they may contain garbage). | |||||
| for (int i = getTotalNumInputChannels(); i < getTotalNumOutputChannels(); ++i) | |||||
| buffer.clear (i, 0, numSamples); | |||||
| // Now pass any incoming midi messages to our keyboard state object, and let it | // Now pass any incoming midi messages to our keyboard state object, and let it | ||||
| // add messages to the buffer if the user is clicking on the on-screen keys | // add messages to the buffer if the user is clicking on the on-screen keys | ||||
| keyboardState.processNextMidiBuffer (midiMessages, 0, numSamples, true); | keyboardState.processNextMidiBuffer (midiMessages, 0, numSamples, true); | ||||
| @@ -144,12 +150,6 @@ void JuceDemoPluginAudioProcessor::process (AudioBuffer<FloatType>& buffer, | |||||
| // Apply our delay effect to the new output.. | // Apply our delay effect to the new output.. | ||||
| applyDelay (buffer, delayBuffer); | applyDelay (buffer, delayBuffer); | ||||
| // In case we have more outputs than inputs, we'll clear any output | |||||
| // channels that didn't contain input data, (because these aren't | |||||
| // guaranteed to be empty - they may contain garbage). | |||||
| for (int i = getTotalNumInputChannels(); i < getTotalNumOutputChannels(); ++i) | |||||
| buffer.clear (i, 0, numSamples); | |||||
| applyGain (buffer, delayBuffer); // apply our gain-change to the outgoing data.. | applyGain (buffer, delayBuffer); // apply our gain-change to the outgoing data.. | ||||
| // Now ask the host for the current time so we can store it to be displayed later... | // Now ask the host for the current time so we can store it to be displayed later... | ||||
| @@ -523,13 +523,17 @@ public: | |||||
| const MidiBuffer& inputMidi, | const MidiBuffer& inputMidi, | ||||
| int startSample, | int startSample, | ||||
| int numSamples) | int numSamples) | ||||
| { processNextBlock (outputAudio, inputMidi, startSample, numSamples); } | |||||
| { | |||||
| processNextBlock (outputAudio, inputMidi, startSample, numSamples); | |||||
| } | |||||
| inline void renderNextBlock (AudioBuffer<double>& outputAudio, | inline void renderNextBlock (AudioBuffer<double>& outputAudio, | ||||
| const MidiBuffer& inputMidi, | const MidiBuffer& inputMidi, | ||||
| int startSample, | int startSample, | ||||
| int numSamples) | int numSamples) | ||||
| { processNextBlock (outputAudio, inputMidi, startSample, numSamples); } | |||||
| { | |||||
| processNextBlock (outputAudio, inputMidi, startSample, numSamples); | |||||
| } | |||||
| /** Returns the current target sample rate at which rendering is being done. | /** Returns the current target sample rate at which rendering is being done. | ||||
| Subclasses may need to know this so that they can pitch things correctly. | Subclasses may need to know this so that they can pitch things correctly. | ||||
| @@ -247,21 +247,40 @@ public: | |||||
| { | { | ||||
| DialogWindow::LaunchOptions o; | DialogWindow::LaunchOptions o; | ||||
| auto totalInChannels = processor->getMainBusNumInputChannels(); | |||||
| auto totalOutChannels = processor->getMainBusNumOutputChannels(); | |||||
| int minNumInputs = std::numeric_limits<int>::max(), maxNumInputs = 0, | |||||
| minNumOutputs = std::numeric_limits<int>::max(), maxNumOutputs = 0; | |||||
| if (channelConfiguration.size() > 0) | if (channelConfiguration.size() > 0) | ||||
| { | { | ||||
| auto defaultConfig = channelConfiguration.getReference (0); | auto defaultConfig = channelConfiguration.getReference (0); | ||||
| totalInChannels = defaultConfig.numIns; | |||||
| totalOutChannels = defaultConfig.numOuts; | |||||
| minNumInputs = jmin (minNumInputs, (int) defaultConfig.numIns); | |||||
| maxNumInputs = jmax (maxNumInputs, (int) defaultConfig.numIns); | |||||
| minNumOutputs = jmin (minNumOutputs, (int) defaultConfig.numOuts); | |||||
| maxNumOutputs = jmax (maxNumOutputs, (int) defaultConfig.numOuts); | |||||
| } | } | ||||
| if (auto* bus = processor->getBus (true, 0)) | |||||
| { | |||||
| auto defaultNumChannels = bus->getDefaultLayout().size(); | |||||
| minNumInputs = jmin (minNumInputs, defaultNumChannels); | |||||
| maxNumInputs = jmax (maxNumInputs, defaultNumChannels); | |||||
| } | |||||
| if (auto* bus = processor->getBus (false, 0)) | |||||
| { | |||||
| auto defaultNumChannels = bus->getDefaultLayout().size(); | |||||
| minNumOutputs = jmin (minNumOutputs, defaultNumChannels); | |||||
| maxNumOutputs = jmax (maxNumOutputs, defaultNumChannels); | |||||
| } | |||||
| minNumInputs = jmin (minNumInputs, maxNumInputs); | |||||
| minNumOutputs = jmin (minNumOutputs, maxNumOutputs); | |||||
| o.content.setOwned (new SettingsComponent (*this, deviceManager, | o.content.setOwned (new SettingsComponent (*this, deviceManager, | ||||
| totalInChannels, | |||||
| totalInChannels, | |||||
| totalOutChannels, | |||||
| totalOutChannels)); | |||||
| minNumInputs, | |||||
| maxNumInputs, | |||||
| minNumOutputs, | |||||
| maxNumOutputs)); | |||||
| o.content->setSize (500, 550); | o.content->setSize (500, 550); | ||||
| o.dialogTitle = TRANS("Audio/MIDI Settings"); | o.dialogTitle = TRANS("Audio/MIDI Settings"); | ||||
| @@ -357,7 +357,7 @@ public: | |||||
| //============================================================================== | //============================================================================== | ||||
| /** The bus's current layout. This will be AudioChannelSet::disabled() if the current | /** The bus's current layout. This will be AudioChannelSet::disabled() if the current | ||||
| layout is dfisabled. | |||||
| layout is disabled. | |||||
| @see AudioChannelSet | @see AudioChannelSet | ||||
| */ | */ | ||||
| const AudioChannelSet& getCurrentLayout() const noexcept { return layout; } | const AudioChannelSet& getCurrentLayout() const noexcept { return layout; } | ||||