1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-15 00:24:19 +00:00

Added some plugin host type detection code.

This commit is contained in:
Julian Storer 2009-11-30 20:19:25 +00:00
parent 95fcc168d8
commit 317af16782
3 changed files with 141 additions and 0 deletions

View file

@ -30,6 +30,7 @@
#include "AUMIDIEffectBase.h"
#include "MusicDeviceBase.h"
#include "../juce_PluginHeaders.h"
#include "../juce_PluginHostType.h"
#if JucePlugin_Build_AU

View file

@ -133,6 +133,7 @@
#endif
#include "../juce_PluginHeaders.h"
#include "../juce_PluginHostType.h"
#ifdef _MSC_VER

View file

@ -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 <mach-o/dyld.h>
#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);
}
};