From a323d4d7972b3cc450881c4f1c9484f045464533 Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 19 Aug 2014 15:37:00 +0100 Subject: [PATCH] Clarified the example code that's generated in the plugin template process method. --- .../Introjucer/JuceLibraryCode/BinaryData.cpp | 19 ++++++++++--------- .../Introjucer/JuceLibraryCode/BinaryData.h | 2 +- .../jucer_AudioPluginFilterTemplate.cpp | 17 +++++++++-------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/extras/Introjucer/JuceLibraryCode/BinaryData.cpp b/extras/Introjucer/JuceLibraryCode/BinaryData.cpp index 904658ce46..6171b1ec27 100644 --- a/extras/Introjucer/JuceLibraryCode/BinaryData.cpp +++ b/extras/Introjucer/JuceLibraryCode/BinaryData.cpp @@ -382,6 +382,15 @@ static const unsigned char temp_binary_data_6[] = "\r\n" "void FILTERCLASSNAME::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)\r\n" "{\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" +" // 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" +" buffer.clear (i, 0, buffer.getNumSamples());\r\n" +"\r\n" " // This is the place where you'd normally do the guts of your plugin's\r\n" " // audio processing...\r\n" " for (int channel = 0; channel < getNumInputChannels(); ++channel)\r\n" @@ -390,14 +399,6 @@ static const unsigned char temp_binary_data_6[] = "\r\n" " // ..do something to the data...\r\n" " }\r\n" -"\r\n" -" // In case we have more outputs than inputs, we'll clear any output\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" -" for (int i = getNumInputChannels(); i < getNumOutputChannels(); ++i)\r\n" -" {\r\n" -" buffer.clear (i, 0, buffer.getNumSamples());\r\n" -" }\r\n" "}\r\n" "\r\n" "//==============================================================================\r\n" @@ -1234,7 +1235,7 @@ const char* getNamedResource (const char* resourceNameUTF8, int& numBytes) throw case 0xe8b08520: numBytes = 1050; return colourscheme_light_xml; case 0x27c5a93a: numBytes = 1008; return jucer_AudioPluginEditorTemplate_cpp; case 0x4d0721bf: numBytes = 799; return jucer_AudioPluginEditorTemplate_h; - case 0x51b49ac5: numBytes = 4640; return jucer_AudioPluginFilterTemplate_cpp; + case 0x51b49ac5: numBytes = 4849; return jucer_AudioPluginFilterTemplate_cpp; case 0x488afa0a: numBytes = 2488; return jucer_AudioPluginFilterTemplate_h; case 0xabad7041: numBytes = 2083; return jucer_ComponentTemplate_cpp; case 0xfc72fe86: numBytes = 2156; return jucer_ComponentTemplate_h; diff --git a/extras/Introjucer/JuceLibraryCode/BinaryData.h b/extras/Introjucer/JuceLibraryCode/BinaryData.h index 070811e363..89624672c5 100644 --- a/extras/Introjucer/JuceLibraryCode/BinaryData.h +++ b/extras/Introjucer/JuceLibraryCode/BinaryData.h @@ -28,7 +28,7 @@ namespace BinaryData const int jucer_AudioPluginEditorTemplate_hSize = 799; extern const char* jucer_AudioPluginFilterTemplate_cpp; - const int jucer_AudioPluginFilterTemplate_cppSize = 4640; + const int jucer_AudioPluginFilterTemplate_cppSize = 4849; extern const char* jucer_AudioPluginFilterTemplate_h; const int jucer_AudioPluginFilterTemplate_hSize = 2488; diff --git a/extras/Introjucer/Source/BinaryData/jucer_AudioPluginFilterTemplate.cpp b/extras/Introjucer/Source/BinaryData/jucer_AudioPluginFilterTemplate.cpp index fad44550da..51148f8cdb 100644 --- a/extras/Introjucer/Source/BinaryData/jucer_AudioPluginFilterTemplate.cpp +++ b/extras/Introjucer/Source/BinaryData/jucer_AudioPluginFilterTemplate.cpp @@ -136,6 +136,15 @@ void FILTERCLASSNAME::releaseResources() void FILTERCLASSNAME::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages) { + // In case we have more outputs than inputs, this code clears any output + // channels that didn't contain input data, (because these aren't + // 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) + buffer.clear (i, 0, buffer.getNumSamples()); + // This is the place where you'd normally do the guts of your plugin's // audio processing... for (int channel = 0; channel < getNumInputChannels(); ++channel) @@ -144,14 +153,6 @@ void FILTERCLASSNAME::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiM // ..do something to the data... } - - // 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 = getNumInputChannels(); i < getNumOutputChannels(); ++i) - { - buffer.clear (i, 0, buffer.getNumSamples()); - } } //==============================================================================