From 65e1eabca3cc654d4c94de986ad375f9fa012c51 Mon Sep 17 00:00:00 2001 From: jules Date: Mon, 11 May 2009 09:57:40 +0000 Subject: [PATCH] Small fix to audio plugin host demo; updated plugin characteristics file to allow a standalone build flag; added VST speaker arrangement fixes as suggested by Andy; added some options for ignoring hidden files to the file browser comp; minor update to the Variant class. --- .../src/host/GraphEditorPanel.cpp | 4 +- .../demo/src/JucePluginCharacteristics.h | 11 +- .../wrapper/VST/juce_VST_Wrapper.cpp | 100 ++++++++++++------ .../wrapper/juce_IncludeCharacteristics.h | 2 +- juce_amalgamated.cpp | 15 +++ juce_amalgamated.h | 9 +- .../filebrowser/juce_DirectoryContentsList.h | 5 + .../filebrowser/juce_FileBrowserComponent.cpp | 15 +++ .../filebrowser/juce_FileBrowserComponent.h | 4 +- src/juce_core/containers/juce_Variant.cpp | 7 ++ src/juce_core/containers/juce_Variant.h | 2 + 11 files changed, 129 insertions(+), 45 deletions(-) diff --git a/extras/audio plugin host/src/host/GraphEditorPanel.cpp b/extras/audio plugin host/src/host/GraphEditorPanel.cpp index a689d5c9b0..ce908b0b59 100644 --- a/extras/audio plugin host/src/host/GraphEditorPanel.cpp +++ b/extras/audio plugin host/src/host/GraphEditorPanel.cpp @@ -1050,14 +1050,14 @@ GraphDocumentComponent::GraphDocumentComponent (AudioDeviceManager* deviceManage addAndMakeVisible (statusBar = new TooltipBar()); - deviceManager->setAudioCallback (&graphPlayer); + deviceManager->addAudioCallback (&graphPlayer); graphPanel->updateComponents(); } GraphDocumentComponent::~GraphDocumentComponent() { - deviceManager->setAudioCallback (0); + deviceManager->removeAudioCallback (&graphPlayer); deleteAllChildren(); graphPlayer.setProcessor (0); diff --git a/extras/audio plugins/demo/src/JucePluginCharacteristics.h b/extras/audio plugins/demo/src/JucePluginCharacteristics.h index 4281ed171b..dc20b243e7 100644 --- a/extras/audio plugins/demo/src/JucePluginCharacteristics.h +++ b/extras/audio plugins/demo/src/JucePluginCharacteristics.h @@ -44,10 +44,15 @@ //============================================================================== /* Plugin Formats to build */ -#define JucePlugin_Build_VST 1 -#define JucePlugin_Build_RTAS 0 -#define JucePlugin_Build_AU 1 +// If your project is building a standalone app to run your plugin, you should +// set the JucePlugin_Build_Standalone flag in the project's settings.. +#if ! JucePlugin_Build_Standalone + // You should turn on these flags to enable the different types of plugin.. + #define JucePlugin_Build_VST 1 + #define JucePlugin_Build_RTAS 0 + #define JucePlugin_Build_AU 1 +#endif //============================================================================== /* Generic settings */ diff --git a/extras/audio plugins/wrapper/VST/juce_VST_Wrapper.cpp b/extras/audio plugins/wrapper/VST/juce_VST_Wrapper.cpp index 2feb111cd2..882f51d7a2 100644 --- a/extras/audio plugins/wrapper/VST/juce_VST_Wrapper.cpp +++ b/extras/audio plugins/wrapper/VST/juce_VST_Wrapper.cpp @@ -352,6 +352,10 @@ public: firstProcessCallback = true; shouldDeleteEditor = false; channels = 0; + speakerIn = kSpeakerArrEmpty; + speakerOut = kSpeakerArrEmpty; + speakerInChans = 0; + speakerOutChans = 0; numInChans = JucePlugin_MaxNumInputChannels; numOutChans = JucePlugin_MaxNumOutputChannels; @@ -513,40 +517,56 @@ public: bool getInputProperties (VstInt32 index, VstPinProperties* properties) { - if (filter == 0 || index >= filter->getNumInputChannels()) + if (filter == 0 || index >= JucePlugin_MaxNumInputChannels) return false; - + const String name (filter->getInputChannelName ((int) index)); - + name.copyToBuffer (properties->label, kVstMaxLabelLen - 1); name.copyToBuffer (properties->shortLabel, kVstMaxShortLabelLen - 1); - - properties->flags = kVstPinIsActive; - - if (filter->isInputChannelStereoPair ((int) index)) - properties->flags |= kVstPinIsStereo; - - properties->arrangementType = 0; + + if (speakerIn != kSpeakerArrEmpty) + { + properties->flags = kVstPinUseSpeaker; + properties->arrangementType = speakerIn; + } + else + { + properties->flags = kVstPinIsActive; + + if (filter->isInputChannelStereoPair ((int) index)) + properties->flags |= kVstPinIsStereo; + + properties->arrangementType = 0; + } return true; } - + bool getOutputProperties (VstInt32 index, VstPinProperties* properties) { - if (filter == 0 || index >= filter->getNumOutputChannels()) + if (filter == 0 || index >= JucePlugin_MaxNumOutputChannels) return false; - + const String name (filter->getOutputChannelName ((int) index)); - + name.copyToBuffer (properties->label, kVstMaxLabelLen - 1); name.copyToBuffer (properties->shortLabel, kVstMaxShortLabelLen - 1); - - properties->flags = kVstPinIsActive; - - if (filter->isOutputChannelStereoPair ((int) index)) - properties->flags |= kVstPinIsStereo; - - properties->arrangementType = 0; + + if (speakerOut != kSpeakerArrEmpty) + { + properties->flags = kVstPinUseSpeaker; + properties->arrangementType = speakerOut; + } + else + { + properties->flags = kVstPinIsActive; + + if (filter->isOutputChannelStereoPair ((int) index)) + properties->flags |= kVstPinIsStereo; + + properties->arrangementType = 0; + } return true; } @@ -969,25 +989,33 @@ public: return filter != 0 && filter->isParameterAutomatable ((int) index); } - bool setSpeakerArrangement (VstSpeakerArrangement* pluginInput, + bool setSpeakerArrangement (VstSpeakerArrangement* pluginInput, VstSpeakerArrangement* pluginOutput) { - if (numInChans != pluginInput->numChannels - || numOutChans != pluginOutput->numChannels) + const short channelConfigs[][2] = { JucePlugin_PreferredChannelConfigurations }; + + for (int i = 0; i < numElementsInArray (channelConfigs); ++i) { - setNumInputs (pluginInput->numChannels); - setNumOutputs (pluginOutput->numChannels); - ioChanged(); + bool configMono = (channelConfigs[i][1] == 1) && (pluginOutput->type == kSpeakerArrMono); + bool configStereo = (channelConfigs[i][1] == 2) && (pluginOutput->type == kSpeakerArrStereo); + bool inCountMatches = (channelConfigs[i][0] == pluginInput->numChannels); + bool outCountMatches = (channelConfigs[i][1] == pluginOutput->numChannels); + + if ((configMono || configStereo) && inCountMatches && outCountMatches) + { + speakerIn = pluginInput->type; + speakerOut = pluginOutput->type; + speakerInChans = pluginInput->numChannels; + speakerOutChans = pluginOutput->numChannels; + + filter->setPlayConfigDetails (speakerInChans, speakerOutChans, + filter->getSampleRate(), + filter->getBlockSize()); + return true; + } } - numInChans = pluginInput->numChannels; - numOutChans = pluginOutput->numChannels; - - filter->setPlayConfigDetails (numInChans, numOutChans, - filter->getSampleRate(), - filter->getBlockSize()); - - return true; + return false; } //============================================================================== @@ -1329,6 +1357,8 @@ private: bool hasShutdown; bool firstProcessCallback; int diffW, diffH; + VstSpeakerArrangementType speakerIn, speakerOut; + int speakerInChans, speakerOutChans; int numInChans, numOutChans; float** channels; VoidArray tempChannels; // see note in processReplacing() diff --git a/extras/audio plugins/wrapper/juce_IncludeCharacteristics.h b/extras/audio plugins/wrapper/juce_IncludeCharacteristics.h index 78a5181b3a..2f12f2f489 100644 --- a/extras/audio plugins/wrapper/juce_IncludeCharacteristics.h +++ b/extras/audio plugins/wrapper/juce_IncludeCharacteristics.h @@ -92,7 +92,7 @@ #error "You need to define the JucePlugin_EditorRequiresKeyboardFocus value in your JucePluginCharacteristics.h file!" #endif -#if ! (JucePlugin_Build_VST || JucePlugin_Build_AU || JucePlugin_Build_RTAS) +#if ! (JucePlugin_Build_VST || JucePlugin_Build_AU || JucePlugin_Build_RTAS || JucePlugin_Build_Standalone) #error "You need to define at least one plugin format value in your JucePluginCharacteristics.h file!" #endif diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 87c79c3d9e..94d2e407e1 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -54146,6 +54146,21 @@ void FileBrowserComponent::fileDoubleClicked (const File& f) } } +bool FileBrowserComponent::keyPressed (const KeyPress& key) +{ +#if JUCE_LINUX || JUCE_WIN32 + if (key.getModifiers().isCommandDown() + && (key.getKeyCode() == 'H' || key.getKeyCode() == 'h')) + { + fileList->setIgnoresHiddenFiles (! fileList->ignoresHiddenFiles()); + fileList->refresh(); + return true; + } +#endif + + return false; +} + void FileBrowserComponent::textEditorTextChanged (TextEditor&) { sendListenerChangeMessage(); diff --git a/juce_amalgamated.h b/juce_amalgamated.h index f5f221a3ed..5e12802f33 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -49587,6 +49587,11 @@ public: */ void setIgnoresHiddenFiles (const bool shouldIgnoreHiddenFiles); + /** Returns true if hidden files are ignored. + @see setIgnoresHiddenFiles + */ + bool ignoresHiddenFiles() const throw() { return ignoreHiddenFiles; } + /** Contains cached information about one of the files in a DirectoryContentsList. */ struct FileInfo @@ -49965,7 +49970,6 @@ public: void buttonClicked (Button* b); /** @internal */ void comboBoxChanged (ComboBox*); - /** @internal */ void textEditorTextChanged (TextEditor& editor); /** @internal */ @@ -49974,7 +49978,8 @@ public: void textEditorEscapeKeyPressed (TextEditor& editor); /** @internal */ void textEditorFocusLost (TextEditor& editor); - + /** @internal */ + bool keyPressed (const KeyPress& key); /** @internal */ void selectionChanged(); /** @internal */ diff --git a/src/juce_appframework/gui/components/filebrowser/juce_DirectoryContentsList.h b/src/juce_appframework/gui/components/filebrowser/juce_DirectoryContentsList.h index 530d4caa85..a17d3aab94 100644 --- a/src/juce_appframework/gui/components/filebrowser/juce_DirectoryContentsList.h +++ b/src/juce_appframework/gui/components/filebrowser/juce_DirectoryContentsList.h @@ -106,6 +106,11 @@ public: By default these are ignored. */ void setIgnoresHiddenFiles (const bool shouldIgnoreHiddenFiles); + + /** Returns true if hidden files are ignored. + @see setIgnoresHiddenFiles + */ + bool ignoresHiddenFiles() const throw() { return ignoreHiddenFiles; } //============================================================================== /** Contains cached information about one of the files in a DirectoryContentsList. diff --git a/src/juce_appframework/gui/components/filebrowser/juce_FileBrowserComponent.cpp b/src/juce_appframework/gui/components/filebrowser/juce_FileBrowserComponent.cpp index 36e8584583..1f5995da3a 100644 --- a/src/juce_appframework/gui/components/filebrowser/juce_FileBrowserComponent.cpp +++ b/src/juce_appframework/gui/components/filebrowser/juce_FileBrowserComponent.cpp @@ -346,6 +346,21 @@ void FileBrowserComponent::fileDoubleClicked (const File& f) } } +bool FileBrowserComponent::keyPressed (const KeyPress& key) +{ +#if JUCE_LINUX || JUCE_WIN32 + if (key.getModifiers().isCommandDown() + && (key.getKeyCode() == 'H' || key.getKeyCode() == 'h')) + { + fileList->setIgnoresHiddenFiles (! fileList->ignoresHiddenFiles()); + fileList->refresh(); + return true; + } +#endif + + return false; +} + //============================================================================== void FileBrowserComponent::textEditorTextChanged (TextEditor&) { diff --git a/src/juce_appframework/gui/components/filebrowser/juce_FileBrowserComponent.h b/src/juce_appframework/gui/components/filebrowser/juce_FileBrowserComponent.h index af8ceda2a3..18f3d68433 100644 --- a/src/juce_appframework/gui/components/filebrowser/juce_FileBrowserComponent.h +++ b/src/juce_appframework/gui/components/filebrowser/juce_FileBrowserComponent.h @@ -162,7 +162,6 @@ public: void buttonClicked (Button* b); /** @internal */ void comboBoxChanged (ComboBox*); - /** @internal */ void textEditorTextChanged (TextEditor& editor); /** @internal */ @@ -171,7 +170,8 @@ public: void textEditorEscapeKeyPressed (TextEditor& editor); /** @internal */ void textEditorFocusLost (TextEditor& editor); - + /** @internal */ + bool keyPressed (const KeyPress& key); /** @internal */ void selectionChanged(); /** @internal */ diff --git a/src/juce_core/containers/juce_Variant.cpp b/src/juce_core/containers/juce_Variant.cpp index ae19e9c688..4e140308d8 100644 --- a/src/juce_core/containers/juce_Variant.cpp +++ b/src/juce_core/containers/juce_Variant.cpp @@ -337,6 +337,13 @@ const var var::call (const var::identifier& method, const var& arg1, const var& return invoke (method, args, 4); } +const var var::call (const var::identifier& method, const var& arg1, const var& arg2, const var& arg3, const var& arg4, const var& arg5) const +{ + var args[] = { arg1, arg2, arg3, arg4, arg5 }; + return invoke (method, args, 5); +} + + //============================================================================== var::identifier::identifier (const String& name_) throw() : name (name_), diff --git a/src/juce_core/containers/juce_Variant.h b/src/juce_core/containers/juce_Variant.h index 19c06806df..e770d8f486 100644 --- a/src/juce_core/containers/juce_Variant.h +++ b/src/juce_core/containers/juce_Variant.h @@ -124,6 +124,8 @@ public: const var call (const identifier& method, const var& arg1, const var& arg2, const var& arg3); /** If this variant is an object, this invokes one of its methods with 4 arguments. */ const var call (const identifier& method, const var& arg1, const var& arg2, const var& arg3, const var& arg4) const; + /** If this variant is an object, this invokes one of its methods with 5 arguments. */ + const var call (const identifier& method, const var& arg1, const var& arg2, const var& arg3, const var& arg4, const var& arg5) const; /** If this variant is an object, this invokes one of its methods with a list of arguments. */ const var invoke (const identifier& method, const var* arguments, int numArguments) const;