| @@ -374,18 +374,21 @@ static const unsigned char temp_binary_data_4[] = | |||||
| "\r\n" | "\r\n" | ||||
| "void FILTERCLASSNAME::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)\r\n" | "void FILTERCLASSNAME::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)\r\n" | ||||
| "{\r\n" | "{\r\n" | ||||
| " const int totalNumInputChannels = getTotalNumInputChannels();\r\n" | |||||
| " const int totalNumOutputChannels = getTotalNumOutputChannels();\r\n" | |||||
| "\r\n" | |||||
| " // In case we have more outputs than inputs, this code clears any output\r\n" | " // In case we have more outputs than inputs, this code clears any output\r\n" | ||||
| " // channels that didn't contain input data, (because these aren't\r\n" | " // channels that didn't contain input data, (because these aren't\r\n" | ||||
| " // guaranteed to be empty - they may contain garbage).\r\n" | " // guaranteed to be empty - they may contain garbage).\r\n" | ||||
| " // I've added this to avoid people getting screaming feedback\r\n" | |||||
| " // when they first compile the plugin, but obviously you don't need to\r\n" | |||||
| " // this code if your algorithm already fills all the output channels.\r\n" | |||||
| " for (int i = getNumInputChannels(); i < getNumOutputChannels(); ++i)\r\n" | |||||
| " // This is here to avoid people getting screaming feedback\r\n" | |||||
| " // when they first compile a plugin, but obviously you don't need to keep\r\n" | |||||
| " // this code if your algorithm always overwrites all the output channels.\r\n" | |||||
| " for (int i = totalNumInputChannels; i < totalNumOutputChannels; ++i)\r\n" | |||||
| " buffer.clear (i, 0, buffer.getNumSamples());\r\n" | " buffer.clear (i, 0, buffer.getNumSamples());\r\n" | ||||
| "\r\n" | "\r\n" | ||||
| " // This is the place where you'd normally do the guts of your plugin's\r\n" | " // This is the place where you'd normally do the guts of your plugin's\r\n" | ||||
| " // audio processing...\r\n" | " // audio processing...\r\n" | ||||
| " for (int channel = 0; channel < getNumInputChannels(); ++channel)\r\n" | |||||
| " for (int channel = 0; channel < totalNumInputChannels; ++channel)\r\n" | |||||
| " {\r\n" | " {\r\n" | ||||
| " float* channelData = buffer.getWritePointer (channel);\r\n" | " float* channelData = buffer.getWritePointer (channel);\r\n" | ||||
| "\r\n" | "\r\n" | ||||
| @@ -3813,7 +3816,7 @@ const char* getNamedResource (const char* resourceNameUTF8, int& numBytes) throw | |||||
| case 0xafccbd3f: numBytes = 3189; return jucer_AudioComponentTemplate_cpp; | case 0xafccbd3f: numBytes = 3189; return jucer_AudioComponentTemplate_cpp; | ||||
| case 0x27c5a93a: numBytes = 1180; return jucer_AudioPluginEditorTemplate_cpp; | case 0x27c5a93a: numBytes = 1180; return jucer_AudioPluginEditorTemplate_cpp; | ||||
| case 0x4d0721bf: numBytes = 1012; return jucer_AudioPluginEditorTemplate_h; | case 0x4d0721bf: numBytes = 1012; return jucer_AudioPluginEditorTemplate_h; | ||||
| case 0x51b49ac5: numBytes = 4216; return jucer_AudioPluginFilterTemplate_cpp; | |||||
| case 0x51b49ac5: numBytes = 4359; return jucer_AudioPluginFilterTemplate_cpp; | |||||
| case 0x488afa0a: numBytes = 2188; return jucer_AudioPluginFilterTemplate_h; | case 0x488afa0a: numBytes = 2188; return jucer_AudioPluginFilterTemplate_h; | ||||
| case 0xabad7041: numBytes = 2161; return jucer_ComponentTemplate_cpp; | case 0xabad7041: numBytes = 2161; return jucer_ComponentTemplate_cpp; | ||||
| case 0xfc72fe86: numBytes = 2141; return jucer_ComponentTemplate_h; | case 0xfc72fe86: numBytes = 2141; return jucer_ComponentTemplate_h; | ||||
| @@ -22,7 +22,7 @@ namespace BinaryData | |||||
| const int jucer_AudioPluginEditorTemplate_hSize = 1012; | const int jucer_AudioPluginEditorTemplate_hSize = 1012; | ||||
| extern const char* jucer_AudioPluginFilterTemplate_cpp; | extern const char* jucer_AudioPluginFilterTemplate_cpp; | ||||
| const int jucer_AudioPluginFilterTemplate_cppSize = 4216; | |||||
| const int jucer_AudioPluginFilterTemplate_cppSize = 4359; | |||||
| extern const char* jucer_AudioPluginFilterTemplate_h; | extern const char* jucer_AudioPluginFilterTemplate_h; | ||||
| const int jucer_AudioPluginFilterTemplate_hSize = 2188; | const int jucer_AudioPluginFilterTemplate_hSize = 2188; | ||||
| @@ -93,18 +93,21 @@ void FILTERCLASSNAME::releaseResources() | |||||
| void FILTERCLASSNAME::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages) | void FILTERCLASSNAME::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages) | ||||
| { | { | ||||
| const int totalNumInputChannels = getTotalNumInputChannels(); | |||||
| const int totalNumOutputChannels = getTotalNumOutputChannels(); | |||||
| // In case we have more outputs than inputs, this code clears any output | // In case we have more outputs than inputs, this code clears any output | ||||
| // channels that didn't contain input data, (because these aren't | // channels that didn't contain input data, (because these aren't | ||||
| // guaranteed to be empty - they may contain garbage). | // guaranteed to be empty - they may contain garbage). | ||||
| // I've added this to avoid people getting screaming feedback | |||||
| // when they first compile the plugin, but obviously you don't need to | |||||
| // this code if your algorithm already fills all the output channels. | |||||
| for (int i = getNumInputChannels(); i < getNumOutputChannels(); ++i) | |||||
| // This is here to avoid people getting screaming feedback | |||||
| // when they first compile a plugin, but obviously you don't need to keep | |||||
| // this code if your algorithm always overwrites all the output channels. | |||||
| for (int i = totalNumInputChannels; i < totalNumOutputChannels; ++i) | |||||
| buffer.clear (i, 0, buffer.getNumSamples()); | buffer.clear (i, 0, buffer.getNumSamples()); | ||||
| // This is the place where you'd normally do the guts of your plugin's | // This is the place where you'd normally do the guts of your plugin's | ||||
| // audio processing... | // audio processing... | ||||
| for (int channel = 0; channel < getNumInputChannels(); ++channel) | |||||
| for (int channel = 0; channel < totalNumInputChannels; ++channel) | |||||
| { | { | ||||
| float* channelData = buffer.getWritePointer (channel); | float* channelData = buffer.getWritePointer (channel); | ||||
| @@ -498,8 +498,8 @@ public: | |||||
| midiTransport = new CEffectMIDITransport (&mMIDIWorld); | midiTransport = new CEffectMIDITransport (&mMIDIWorld); | ||||
| midiEvents.ensureSize (2048); | midiEvents.ensureSize (2048); | ||||
| channels.calloc (jmax (juceFilter->getNumInputChannels(), | |||||
| juceFilter->getNumOutputChannels())); | |||||
| channels.calloc (jmax (juceFilter->getTotalNumInputChannels(), | |||||
| juceFilter->getTotalNumOutputChannels())); | |||||
| juceFilter->setPlayHead (this); | juceFilter->setPlayHead (this); | ||||
| juceFilter->addListener (this); | juceFilter->addListener (this); | ||||
| @@ -539,14 +539,14 @@ public: | |||||
| #if JUCE_DEBUG || JUCE_LOG_ASSERTIONS | #if JUCE_DEBUG || JUCE_LOG_ASSERTIONS | ||||
| const int numMidiEventsComingIn = midiEvents.getNumEvents(); | const int numMidiEventsComingIn = midiEvents.getNumEvents(); | ||||
| (void) numMidiEventsComingIn; | |||||
| ignoreUnused (numMidiEventsComingIn); | |||||
| #endif | #endif | ||||
| { | { | ||||
| const ScopedLock sl (juceFilter->getCallbackLock()); | const ScopedLock sl (juceFilter->getCallbackLock()); | ||||
| const int numIn = juceFilter->getNumInputChannels(); | |||||
| const int numOut = juceFilter->getNumOutputChannels(); | |||||
| const int numIn = juceFilter->getTotalNumInputChannels(); | |||||
| const int numOut = juceFilter->getTotalNumOutputChannels(); | |||||
| const int totalChans = jmax (numIn, numOut); | const int totalChans = jmax (numIn, numOut); | ||||
| if (juceFilter->isSuspended()) | if (juceFilter->isSuspended()) | ||||
| @@ -379,8 +379,8 @@ public: | |||||
| desc.category = AudioUnitFormatHelpers::getCategory (componentDesc.componentType); | desc.category = AudioUnitFormatHelpers::getCategory (componentDesc.componentType); | ||||
| desc.manufacturerName = manufacturer; | desc.manufacturerName = manufacturer; | ||||
| desc.version = version; | desc.version = version; | ||||
| desc.numInputChannels = getNumInputChannels(); | |||||
| desc.numOutputChannels = getNumOutputChannels(); | |||||
| desc.numInputChannels = getTotalNumInputChannels(); | |||||
| desc.numOutputChannels = getTotalNumOutputChannels(); | |||||
| desc.isInstrument = (componentDesc.componentType == kAudioUnitType_MusicDevice); | desc.isInstrument = (componentDesc.componentType == kAudioUnitType_MusicDevice); | ||||
| } | } | ||||
| @@ -578,7 +578,7 @@ public: | |||||
| else | else | ||||
| { | { | ||||
| // Plugin not working correctly, so just bypass.. | // Plugin not working correctly, so just bypass.. | ||||
| for (int i = 0; i < getNumOutputChannels(); ++i) | |||||
| for (int i = getTotalNumOutputChannels(); --i >= 0;) | |||||
| buffer.clear (i, 0, buffer.getNumSamples()); | buffer.clear (i, 0, buffer.getNumSamples()); | ||||
| } | } | ||||
| @@ -597,7 +597,7 @@ public: | |||||
| //============================================================================== | //============================================================================== | ||||
| const String getInputChannelName (int index) const override | const String getInputChannelName (int index) const override | ||||
| { | { | ||||
| if (isPositiveAndBelow (index, getNumInputChannels())) | |||||
| if (isPositiveAndBelow (index, getTotalNumInputChannels())) | |||||
| return "Input " + String (index + 1); | return "Input " + String (index + 1); | ||||
| return String(); | return String(); | ||||
| @@ -605,14 +605,14 @@ public: | |||||
| const String getOutputChannelName (int index) const override | const String getOutputChannelName (int index) const override | ||||
| { | { | ||||
| if (isPositiveAndBelow (index, getNumOutputChannels())) | |||||
| if (isPositiveAndBelow (index, getTotalNumOutputChannels())) | |||||
| return "Output " + String (index + 1); | return "Output " + String (index + 1); | ||||
| return String(); | return String(); | ||||
| } | } | ||||
| bool isInputChannelStereoPair (int index) const override { return isPositiveAndBelow (index, getNumInputChannels()); } | |||||
| bool isOutputChannelStereoPair (int index) const override { return isPositiveAndBelow (index, getNumOutputChannels()); } | |||||
| bool isInputChannelStereoPair (int index) const override { return isPositiveAndBelow (index, getTotalNumInputChannels()); } | |||||
| bool isOutputChannelStereoPair (int index) const override { return isPositiveAndBelow (index, getTotalNumOutputChannels()); } | |||||
| //============================================================================== | //============================================================================== | ||||
| int getNumParameters() override { return parameters.size(); } | int getNumParameters() override { return parameters.size(); } | ||||
| @@ -225,8 +225,8 @@ public: | |||||
| desc.category = getCategory(); | desc.category = getCategory(); | ||||
| desc.manufacturerName = plugin != nullptr ? String (plugin->Maker) : String(); | desc.manufacturerName = plugin != nullptr ? String (plugin->Maker) : String(); | ||||
| desc.version = getVersion(); | desc.version = getVersion(); | ||||
| desc.numInputChannels = getNumInputChannels(); | |||||
| desc.numOutputChannels = getNumOutputChannels(); | |||||
| desc.numInputChannels = getTotalNumInputChannels(); | |||||
| desc.numOutputChannels = getTotalNumOutputChannels(); | |||||
| desc.isInstrument = false; | desc.isInstrument = false; | ||||
| } | } | ||||
| @@ -327,16 +327,16 @@ public: | |||||
| jassertfalse; // no callback to use? | jassertfalse; // no callback to use? | ||||
| } | } | ||||
| for (int i = getNumInputChannels(); i < getNumOutputChannels(); ++i) | |||||
| for (int i = getTotalNumInputChannels(), e = getTotalNumOutputChannels(); i < e; ++i) | |||||
| buffer.clear (i, 0, numSamples); | buffer.clear (i, 0, numSamples); | ||||
| } | } | ||||
| bool isInputChannelStereoPair (int index) const { return isPositiveAndBelow (index, getNumInputChannels()); } | |||||
| bool isOutputChannelStereoPair (int index) const { return isPositiveAndBelow (index, getNumInputChannels()); } | |||||
| bool isInputChannelStereoPair (int index) const { return isPositiveAndBelow (index, getTotalNumInputChannels()); } | |||||
| bool isOutputChannelStereoPair (int index) const { return isPositiveAndBelow (index, getTotalNumOutputChannels()); } | |||||
| const String getInputChannelName (const int index) const | const String getInputChannelName (const int index) const | ||||
| { | { | ||||
| if (isPositiveAndBelow (index, getNumInputChannels())) | |||||
| if (isPositiveAndBelow (index, getTotalNumInputChannels())) | |||||
| return String (plugin->PortNames [inputs [index]]).trim(); | return String (plugin->PortNames [inputs [index]]).trim(); | ||||
| return String(); | return String(); | ||||
| @@ -344,7 +344,7 @@ public: | |||||
| const String getOutputChannelName (const int index) const | const String getOutputChannelName (const int index) const | ||||
| { | { | ||||
| if (isPositiveAndBelow (index, getNumInputChannels())) | |||||
| if (isPositiveAndBelow (index, getTotalNumInputChannels())) | |||||
| return String (plugin->PortNames [outputs [index]]).trim(); | return String (plugin->PortNames [outputs [index]]).trim(); | ||||
| return String(); | return String(); | ||||
| @@ -1665,8 +1665,8 @@ public: | |||||
| createPluginDescription (description, module->file, | createPluginDescription (description, module->file, | ||||
| company, module->name, | company, module->name, | ||||
| *info, info2, infoW, | *info, info2, infoW, | ||||
| getNumInputChannels(), | |||||
| getNumOutputChannels()); | |||||
| getTotalNumInputChannels(), | |||||
| getTotalNumOutputChannels()); | |||||
| } | } | ||||
| void* getPlatformSpecificData() override { return component; } | void* getPlatformSpecificData() override { return component; } | ||||
| @@ -1808,7 +1808,7 @@ public: | |||||
| updateTimingInformation (data, getSampleRate()); | updateTimingInformation (data, getSampleRate()); | ||||
| for (int i = getNumInputChannels(); i < buffer.getNumChannels(); ++i) | |||||
| for (int i = getTotalNumInputChannels(); i < buffer.getNumChannels(); ++i) | |||||
| buffer.clear (i, 0, numSamples); | buffer.clear (i, 0, numSamples); | ||||
| associateTo (data, buffer); | associateTo (data, buffer); | ||||
| @@ -1845,18 +1845,14 @@ public: | |||||
| bool isInputChannelStereoPair (int channelIndex) const override | bool isInputChannelStereoPair (int channelIndex) const override | ||||
| { | { | ||||
| if (channelIndex < 0 || channelIndex >= getNumInputChannels()) | |||||
| return false; | |||||
| return getBusInfo (true, true).channelCount == 2; | |||||
| return isPositiveAndBelow (channelIndex, getTotalNumInputChannels()) | |||||
| && getBusInfo (true, true).channelCount == 2; | |||||
| } | } | ||||
| bool isOutputChannelStereoPair (int channelIndex) const override | bool isOutputChannelStereoPair (int channelIndex) const override | ||||
| { | { | ||||
| if (channelIndex < 0 || channelIndex >= getNumOutputChannels()) | |||||
| return false; | |||||
| return getBusInfo (false, true).channelCount == 2; | |||||
| return isPositiveAndBelow (channelIndex, getTotalNumOutputChannels()) | |||||
| && getBusInfo (false, true).channelCount == 2; | |||||
| } | } | ||||
| bool acceptsMidi() const override { return getBusInfo (true, false).channelCount > 0; } | bool acceptsMidi() const override { return getBusInfo (true, false).channelCount > 0; } | ||||
| @@ -815,8 +815,8 @@ public: | |||||
| } | } | ||||
| desc.version = getVersion(); | desc.version = getVersion(); | ||||
| desc.numInputChannels = getNumInputChannels(); | |||||
| desc.numOutputChannels = getNumOutputChannels(); | |||||
| desc.numInputChannels = getTotalNumInputChannels(); | |||||
| desc.numOutputChannels = getTotalNumOutputChannels(); | |||||
| desc.isInstrument = (effect != nullptr && (effect->flags & effFlagsIsSynth) != 0); | desc.isInstrument = (effect != nullptr && (effect->flags & effFlagsIsSynth) != 0); | ||||
| } | } | ||||
| @@ -1017,7 +1017,7 @@ public: | |||||
| //============================================================================== | //============================================================================== | ||||
| const String getInputChannelName (int index) const override | const String getInputChannelName (int index) const override | ||||
| { | { | ||||
| if (index >= 0 && index < getNumInputChannels()) | |||||
| if (isValidChannel (index, true)) | |||||
| { | { | ||||
| VstPinProperties pinProps; | VstPinProperties pinProps; | ||||
| if (dispatch (effGetInputProperties, index, 0, &pinProps, 0.0f) != 0) | if (dispatch (effGetInputProperties, index, 0, &pinProps, 0.0f) != 0) | ||||
| @@ -1029,7 +1029,7 @@ public: | |||||
| bool isInputChannelStereoPair (int index) const override | bool isInputChannelStereoPair (int index) const override | ||||
| { | { | ||||
| if (index < 0 || index >= getNumInputChannels()) | |||||
| if (! isValidChannel (index, true)) | |||||
| return false; | return false; | ||||
| VstPinProperties pinProps; | VstPinProperties pinProps; | ||||
| @@ -1041,7 +1041,7 @@ public: | |||||
| const String getOutputChannelName (int index) const override | const String getOutputChannelName (int index) const override | ||||
| { | { | ||||
| if (index >= 0 && index < getNumOutputChannels()) | |||||
| if (isValidChannel (index, false)) | |||||
| { | { | ||||
| VstPinProperties pinProps; | VstPinProperties pinProps; | ||||
| if (dispatch (effGetOutputProperties, index, 0, &pinProps, 0.0f) != 0) | if (dispatch (effGetOutputProperties, index, 0, &pinProps, 0.0f) != 0) | ||||
| @@ -1053,7 +1053,7 @@ public: | |||||
| bool isOutputChannelStereoPair (int index) const override | bool isOutputChannelStereoPair (int index) const override | ||||
| { | { | ||||
| if (index < 0 || index >= getNumOutputChannels()) | |||||
| if (! isValidChannel (index, false)) | |||||
| return false; | return false; | ||||
| VstPinProperties pinProps; | VstPinProperties pinProps; | ||||
| @@ -1063,9 +1063,10 @@ public: | |||||
| return true; | return true; | ||||
| } | } | ||||
| bool isValidChannel (int index, bool isInput) const | |||||
| bool isValidChannel (int index, bool isInput) const noexcept | |||||
| { | { | ||||
| return isPositiveAndBelow (index, isInput ? getNumInputChannels() : getNumOutputChannels()); | |||||
| return isPositiveAndBelow (index, isInput ? getTotalNumInputChannels() | |||||
| : getTotalNumOutputChannels()); | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -1686,7 +1687,7 @@ private: | |||||
| else | else | ||||
| { | { | ||||
| // Not initialised, so just bypass.. | // Not initialised, so just bypass.. | ||||
| for (int i = 0; i < getNumOutputChannels(); ++i) | |||||
| for (int i = getTotalNumOutputChannels(); --i >= 0;) | |||||
| buffer.clear (i, 0, buffer.getNumSamples()); | buffer.clear (i, 0, buffer.getNumSamples()); | ||||
| } | } | ||||