diff --git a/extras/audio plugins/wrapper/AU/juce_AU_Wrapper.mm b/extras/audio plugins/wrapper/AU/juce_AU_Wrapper.mm index e573993159..6358d47ed3 100644 --- a/extras/audio plugins/wrapper/AU/juce_AU_Wrapper.mm +++ b/extras/audio plugins/wrapper/AU/juce_AU_Wrapper.mm @@ -30,6 +30,7 @@ #include "AUMIDIEffectBase.h" #include "MusicDeviceBase.h" #include "../juce_PluginHeaders.h" +#include "../juce_PluginHostType.h" #if JucePlugin_Build_AU diff --git a/extras/audio plugins/wrapper/VST/juce_VST_Wrapper.cpp b/extras/audio plugins/wrapper/VST/juce_VST_Wrapper.cpp index 1f0f055e56..c1ab2a687a 100644 --- a/extras/audio plugins/wrapper/VST/juce_VST_Wrapper.cpp +++ b/extras/audio plugins/wrapper/VST/juce_VST_Wrapper.cpp @@ -133,6 +133,7 @@ #endif #include "../juce_PluginHeaders.h" +#include "../juce_PluginHostType.h" #ifdef _MSC_VER diff --git a/extras/audio plugins/wrapper/juce_PluginHostType.h b/extras/audio plugins/wrapper/juce_PluginHostType.h new file mode 100644 index 0000000000..f9518b0b92 --- /dev/null +++ b/extras/audio plugins/wrapper/juce_PluginHostType.h @@ -0,0 +1,139 @@ +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-9 by Raw Material Software Ltd. + + ------------------------------------------------------------------------------ + + JUCE can be redistributed and/or modified under the terms of the GNU General + Public License (Version 2), as published by the Free Software Foundation. + A copy of the license is included in the JUCE distribution, or can be found + online at www.gnu.org/licenses. + + 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. + + ------------------------------------------------------------------------------ + + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.rawmaterialsoftware.com/juce for more information. + + ============================================================================== +*/ + +#if JUCE_MAC + #include +#endif + +//============================================================================== +class PluginHostType +{ +public: + //============================================================================== + PluginHostType() throw() : type (getHostType()) + { + } + + //============================================================================== + enum HostType + { + UnknownHost, + AbletonLive6, + AbletonLive7, + AbletonLive8, + AbletonLiveGeneric, + AppleLogic, + DigidesignProTools, + CakewalkSonar8, + CakewalkSonarGeneric, + Reaper, + MackieTracktion3, + MackieTracktionGeneric, + SteinbergCubase4, + SteinbergCubase5, + SteinbergCubaseGeneric, + }; + + const HostType type; + + //============================================================================== + bool isAbletonLive() const throw() + { + return type == AbletonLive6 || type == AbletonLive7 || type == AbletonLive8 || type == AbletonLiveGeneric; + } + + bool isCubase() const throw() + { + return type == SteinbergCubase4 || type == SteinbergCubase5 || type == SteinbergCubaseGeneric; + } + + bool isTracktion() const throw() + { + return type == MackieTracktion3 || type == MackieTracktionGeneric; + } + + bool isSonar() const throw() + { + return type == CakewalkSonar8 || type == CakewalkSonarGeneric; + } + + //============================================================================== +private: + static HostType getHostType() throw() + { + const String hostPath (getHostPath()); + const String hostFilename (File (hostPath).getFileName()); + +#if JUCE_MAC + if (hostPath.containsIgnoreCase ("Live 6.")) return AbletonLive6; + if (hostPath.containsIgnoreCase ("Live 7.")) return AbletonLive7; + if (hostPath.containsIgnoreCase ("Live 8.")) return AbletonLive8; + if (hostFilename.containsIgnoreCase ("Live")) return AbletonLiveGeneric; + if (hostFilename.containsIgnoreCase ("Pro Tools")) return DigidesignProTools; + if (hostFilename.containsIgnoreCase ("Cubase 4")) return SteinbergCubase4; + if (hostFilename.containsIgnoreCase ("Cubase 5")) return SteinbergCubase5; + if (hostFilename.contains ("Logic")) return AppleLogic; + +#elif JUCE_WINDOWS + if (hostFilename.containsIgnoreCase ("Live 6.")) return AbletonLive6; + if (hostFilename.containsIgnoreCase ("Live 7.")) return AbletonLive7; + if (hostFilename.containsIgnoreCase ("Live 8.")) return AbletonLive8; + if (hostFilename.containsIgnoreCase ("Live ")) return AbletonLiveGeneric; + if (hostFilename.containsIgnoreCase ("ProTools")) return DigidesignProTools; + if (hostPath.containsIgnoreCase ("SONAR 8")) return CakewalkSonar8; + if (hostFilename.containsIgnoreCase ("SONAR")) return CakewalkSonarGeneric; + if (hostPath.containsIgnoreCase ("Tracktion 3")) return MackieTracktion3; + if (hostFilename.containsIgnoreCase ("Tracktion")) return MackieTracktionGeneric; + if (hostFilename.containsIgnoreCase ("Cubase4")) return SteinbergCubase4; + if (hostFilename.containsIgnoreCase ("Cubase5")) return SteinbergCubase5; + if (hostFilename.containsIgnoreCase ("Cubase")) return SteinbergCubaseGeneric; + if (hostFilename.containsIgnoreCase ("reaper")) return Reaper; + +#elif JUCE_LINUX + jassertfalse // not yet done! +#else + #error +#endif + return UnknownHost; + } + + static const String getHostPath() throw() + { + unsigned int size = 8192; + MemoryBlock buffer (size + 8); + buffer.fillWith (0); + +#if JUCE_WINDOWS + GetModuleFileNameW (0, (WCHAR*) buffer.getData(), size / sizeof (WCHAR)); +#elif JUCE_MAC + _NSGetExecutablePath ((char*) buffer.getData(), &size); +#elif JUCE_LINUX + readlink ("/proc/self/exe", (char*) buffer.getData(), size); +#else + #error +#endif + return String::fromUTF8 ((const juce::uint8*) buffer.getData(), size); + } +};