From 2c1b03cbf131f1ea05faced913522fb8353ebd63 Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 14 Aug 2007 15:39:10 +0000 Subject: [PATCH] --- .../mac/PluginHost.xcodeproj/project.pbxproj | 6 + .../build/win32/PluginHost.vcproj | 8 + .../src/host/FilterGraph.cpp | 11 +- .../plugins/juce_GenericAudioFilterEditor.cpp | 146 ++++++++++++++++++ .../plugins/juce_GenericAudioFilterEditor.h | 68 ++++++++ .../plugins/vst/juce_VSTPluginInstance.cpp | 5 +- 6 files changed, 238 insertions(+), 6 deletions(-) create mode 100644 extras/audio plugin host/src/plugins/juce_GenericAudioFilterEditor.cpp create mode 100644 extras/audio plugin host/src/plugins/juce_GenericAudioFilterEditor.h diff --git a/extras/audio plugin host/build/mac/PluginHost.xcodeproj/project.pbxproj b/extras/audio plugin host/build/mac/PluginHost.xcodeproj/project.pbxproj index a9a4d6ff35..3500b2543b 100644 --- a/extras/audio plugin host/build/mac/PluginHost.xcodeproj/project.pbxproj +++ b/extras/audio plugin host/build/mac/PluginHost.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 84E5BB970C7203B70088E799 /* juce_GenericAudioFilterEditor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84E5BB950C7203B70088E799 /* juce_GenericAudioFilterEditor.cpp */; }; 84FFAEAC0C6C8A6F009F6E72 /* FilterGraph.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84FFAE920C6C8A6F009F6E72 /* FilterGraph.cpp */; }; 84FFAEAD0C6C8A6F009F6E72 /* GraphEditorPanel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84FFAE940C6C8A6F009F6E72 /* GraphEditorPanel.cpp */; }; 84FFAEAE0C6C8A6F009F6E72 /* InternalFilters.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84FFAE960C6C8A6F009F6E72 /* InternalFilters.cpp */; }; @@ -43,6 +44,8 @@ 4A9504C8FFE6A3BC11CA0CBA /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = /System/Library/Frameworks/ApplicationServices.framework; sourceTree = ""; }; 4A9504CAFFE6A41611CA0CBA /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = /System/Library/Frameworks/CoreServices.framework; sourceTree = ""; }; 508344B209E5C41E0093A071 /* Juce Plugin Host.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Juce Plugin Host.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 84E5BB950C7203B70088E799 /* juce_GenericAudioFilterEditor.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = juce_GenericAudioFilterEditor.cpp; sourceTree = ""; }; + 84E5BB960C7203B70088E799 /* juce_GenericAudioFilterEditor.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = juce_GenericAudioFilterEditor.h; sourceTree = ""; }; 84FFAE920C6C8A6F009F6E72 /* FilterGraph.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = FilterGraph.cpp; path = ../../src/host/FilterGraph.cpp; sourceTree = SOURCE_ROOT; }; 84FFAE930C6C8A6F009F6E72 /* FilterGraph.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = FilterGraph.h; path = ../../src/host/FilterGraph.h; sourceTree = SOURCE_ROOT; }; 84FFAE940C6C8A6F009F6E72 /* GraphEditorPanel.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = GraphEditorPanel.cpp; path = ../../src/host/GraphEditorPanel.cpp; sourceTree = SOURCE_ROOT; }; @@ -171,6 +174,8 @@ 84FFAE9D0C6C8A6F009F6E72 /* juce_AudioPluginFormat.h */, 84FFAE9E0C6C8A6F009F6E72 /* juce_AudioPluginInstance.cpp */, 84FFAE9F0C6C8A6F009F6E72 /* juce_AudioPluginInstance.h */, + 84E5BB950C7203B70088E799 /* juce_GenericAudioFilterEditor.cpp */, + 84E5BB960C7203B70088E799 /* juce_GenericAudioFilterEditor.h */, 84FFAEA00C6C8A6F009F6E72 /* juce_KnownPluginList.cpp */, 84FFAEA10C6C8A6F009F6E72 /* juce_KnownPluginList.h */, 84FFAEA20C6C8A6F009F6E72 /* juce_PluginDescription.cpp */, @@ -282,6 +287,7 @@ 84FFAEB50C6C8A6F009F6E72 /* juce_PluginDirectoryScanner.cpp in Sources */, 84FFAEB60C6C8A6F009F6E72 /* juce_PluginListComponent.cpp in Sources */, 84FFAEB70C6C8A6F009F6E72 /* juce_VSTPluginInstance.cpp in Sources */, + 84E5BB970C7203B70088E799 /* juce_GenericAudioFilterEditor.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/extras/audio plugin host/build/win32/PluginHost.vcproj b/extras/audio plugin host/build/win32/PluginHost.vcproj index a3081568d1..a48639a0a7 100644 --- a/extras/audio plugin host/build/win32/PluginHost.vcproj +++ b/extras/audio plugin host/build/win32/PluginHost.vcproj @@ -233,6 +233,14 @@ RelativePath="..\..\src\plugins\juce_AudioPluginInstance.h" > + + + + diff --git a/extras/audio plugin host/src/host/FilterGraph.cpp b/extras/audio plugin host/src/host/FilterGraph.cpp index 9ba3e5dcd3..a91e9f61f1 100644 --- a/extras/audio plugin host/src/host/FilterGraph.cpp +++ b/extras/audio plugin host/src/host/FilterGraph.cpp @@ -31,6 +31,7 @@ #include "FilterGraph.h" #include "InternalFilters.h" +#include "../plugins/juce_GenericAudioFilterEditor.h" //============================================================================== @@ -123,11 +124,11 @@ void FilterInGraph::showUI() { Component* ui = filter->createEditorIfNeeded(); - if (ui != 0) - { - ui->setName (filter->getName()); - activeUI = new PluginWindow (ui, *this); - } + if (ui == 0) + ui = new GenericAudioFilterEditor (filter); + + ui->setName (filter->getName()); + activeUI = new PluginWindow (ui, *this); } if (activeUI != 0) diff --git a/extras/audio plugin host/src/plugins/juce_GenericAudioFilterEditor.cpp b/extras/audio plugin host/src/plugins/juce_GenericAudioFilterEditor.cpp new file mode 100644 index 0000000000..c22b23563b --- /dev/null +++ b/extras/audio plugin host/src/plugins/juce_GenericAudioFilterEditor.cpp @@ -0,0 +1,146 @@ +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-7 by Raw Material Software ltd. + + ------------------------------------------------------------------------------ + + JUCE can be redistributed and/or modified under the terms of the + GNU General Public License, as published by the Free Software Foundation; + either version 2 of the License, or (at your option) any later version. + + JUCE is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with JUCE; if not, visit www.gnu.org/licenses or write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + ------------------------------------------------------------------------------ + + If you'd like to release a closed-source product which uses JUCE, commercial + licenses are also available: visit www.rawmaterialsoftware.com/juce for + more information. + + ============================================================================== +*/ + +#include "../../../../juce.h" +#include "juce_GenericAudioFilterEditor.h" + + +//============================================================================== +class FilterParameterPropertyComp : public PropertyComponent +{ +public: + FilterParameterPropertyComp (AudioPluginInstance* const filter_, + const int index_) + : PropertyComponent (filter_->getParameterName (index_)), + filter (filter_), + index (index_) + { + addAndMakeVisible (slider = new PluginSlider (filter_, index_)); + } + + ~FilterParameterPropertyComp() + { + deleteAllChildren(); + } + + void refresh() + { + slider->setValue (filter->getParameter (index), false); + } + + //============================================================================== + juce_UseDebuggingNewOperator + +private: + AudioPluginInstance* const filter; + const int index; + Slider* slider; + + //============================================================================== + class PluginSlider : public Slider + { + public: + PluginSlider (AudioPluginInstance* const filter_, const int index_) + : Slider (String::empty), + filter (filter_), + index (index_) + { + setRange (0.0, 1.0, 0.0); + setSliderStyle (Slider::LinearBar); + setTextBoxIsEditable (false); + } + + ~PluginSlider() + { + } + + void valueChanged() + { + const float newVal = (float) getValue(); + + if (filter->getParameter (index) != newVal) + filter->setParameter (index, newVal); + } + + const String getTextFromValue (double /*value*/) + { + return filter->getParameterText (index); + } + + //============================================================================== + juce_UseDebuggingNewOperator + + private: + AudioPluginInstance* const filter; + const int index; + }; +}; + + +//============================================================================== +GenericAudioFilterEditor::GenericAudioFilterEditor (AudioPluginInstance* const filter) + : AudioFilterEditor (filter) +{ + setOpaque (true); + + addAndMakeVisible (panel = new PropertyPanel()); + + Array params; + + const int numParams = filter->getNumParameters(); + int totalHeight = 0; + + for (int i = 0; i < numParams; ++i) + { + FilterParameterPropertyComp* const pc = new FilterParameterPropertyComp (filter, i); + params.add (pc); + totalHeight += pc->getPreferredHeight(); + } + + panel->addProperties (params); + + setSize (400, jlimit (25, 400, totalHeight)); +} + +GenericAudioFilterEditor::~GenericAudioFilterEditor() +{ + deleteAllChildren(); +} + +void GenericAudioFilterEditor::paint (Graphics& g) +{ + g.fillAll (Colours::white); +} + +void GenericAudioFilterEditor::resized() +{ + panel->setSize (getWidth(), getHeight()); +} diff --git a/extras/audio plugin host/src/plugins/juce_GenericAudioFilterEditor.h b/extras/audio plugin host/src/plugins/juce_GenericAudioFilterEditor.h new file mode 100644 index 0000000000..b632932c88 --- /dev/null +++ b/extras/audio plugin host/src/plugins/juce_GenericAudioFilterEditor.h @@ -0,0 +1,68 @@ +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-7 by Raw Material Software ltd. + + ------------------------------------------------------------------------------ + + JUCE can be redistributed and/or modified under the terms of the + GNU General Public License, as published by the Free Software Foundation; + either version 2 of the License, or (at your option) any later version. + + JUCE is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with JUCE; if not, visit www.gnu.org/licenses or write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + ------------------------------------------------------------------------------ + + If you'd like to release a closed-source product which uses JUCE, commercial + licenses are also available: visit www.rawmaterialsoftware.com/juce for + more information. + + ============================================================================== +*/ + +#ifndef __JUCE_GENERICFILTERUI_JUCEHEADER__ +#define __JUCE_GENERICFILTERUI_JUCEHEADER__ + +#include "juce_AudioPluginInstance.h" + + +//============================================================================== +/** + A type of UI component that displays the parameters of an AudioFilterInstance as + a simple list of sliders. + + This can be used for showing an editor for plugins that don't supply their own + editor. + + @see AudioFilterBase, AudioPluginFormat +*/ +class GenericAudioFilterEditor : public AudioFilterEditor +{ +public: + //============================================================================== + GenericAudioFilterEditor (AudioPluginInstance* const ownerFilter); + ~GenericAudioFilterEditor(); + + //============================================================================== + void paint (Graphics& g); + void resized(); + + + //============================================================================== + juce_UseDebuggingNewOperator + +private: + PropertyPanel* panel; +}; + + +#endif diff --git a/extras/audio plugin host/src/plugins/vst/juce_VSTPluginInstance.cpp b/extras/audio plugin host/src/plugins/vst/juce_VSTPluginInstance.cpp index 0713ac0059..f60beccca1 100644 --- a/extras/audio plugin host/src/plugins/vst/juce_VSTPluginInstance.cpp +++ b/extras/audio plugin host/src/plugins/vst/juce_VSTPluginInstance.cpp @@ -1399,7 +1399,10 @@ private: //============================================================================== AudioFilterEditor* JUCE_CALLTYPE VSTPluginInstance::createEditor() { - return new VSTPluginWindow (*this); + if (hasEditor()) + return new VSTPluginWindow (*this); + + return 0; }