diff options
author | Taybin Rutkin <taybin@taybin.com> | 2006-08-01 21:11:55 +0000 |
---|---|---|
committer | Taybin Rutkin <taybin@taybin.com> | 2006-08-01 21:11:55 +0000 |
commit | 14f461218121d2b0d68158d7061cbaa375d827e8 (patch) | |
tree | 9c492828fe932dd7fdf3eae581117f92a338a32f /libs/ardour/audio_unit.cc | |
parent | c37b6417021e3ddb3a9f690d2dc04580af8d3dee (diff) |
Added LADSPA_PATH to ardev_common.sh
Removed redundent added_plugins list from PluginSelector
Started refactoring of PluginManager into PluginInfo
PluginManager now uses shared_ptr<PluginInfo>
git-svn-id: svn://localhost/ardour2/trunk@738 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/audio_unit.cc')
-rw-r--r-- | libs/ardour/audio_unit.cc | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/libs/ardour/audio_unit.cc b/libs/ardour/audio_unit.cc index 5d7e7ae90c..52cfc187af 100644 --- a/libs/ardour/audio_unit.cc +++ b/libs/ardour/audio_unit.cc @@ -17,3 +17,96 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include <ardour/audio_unit.h> +#include <ardour/utils.h> + +#include <CoreServices/CoreServices.h> +#include <AudioUnit/AudioUnit.h> + +using namespace ARDOUR; + +PluginInfoList +AUPluginInfo::discover () +{ + PluginInfoList plugs; + + int numTypes = 2; // this magic number was retrieved from the apple AUHost example. + + ComponentDescription desc; + desc.componentFlags = 0; + desc.componentFlagsMask = 0; + desc.componentSubType = 0; + desc.componentManufacturer = 0; + + vector<ComponentDescription> vCompDescs; + + for (int i = 0; i < numTypes; ++i) { + if (i == 1) { + desc.componentType = kAudioUnitType_MusicEffect; + } else { + desc.componentType = kAudioUnitType_Effect; + } + + Component comp = 0; + + comp = FindNextComponent (NULL, &desc); + while (comp != NULL) { + ComponentDescription temp; + GetComponentInfo (comp, &temp, NULL, NULL, NULL); + vCompDescs.push_back(temp); + comp = FindNextComponent (comp, &desc); + } + } + + for (unsigned int i = 0; i < vCompDescs.size(); ++i) { + + // the following large block is just for determining the name of the plugin. + CFStringRef itemName = NULL; + // Marc Poirier -style item name + Component auComponent = FindNextComponent (0, &(vCompDescs[i])); + if (auComponent != NULL) { + ComponentDescription dummydesc; + Handle nameHandle = NewHandle(sizeof(void*)); + if (nameHandle != NULL) { + OSErr err = GetComponentInfo(auComponent, &dummydesc, nameHandle, NULL, NULL); + if (err == noErr) { + ConstStr255Param nameString = (ConstStr255Param) (*nameHandle); + if (nameString != NULL) { + itemName = CFStringCreateWithPascalString(kCFAllocatorDefault, nameString, CFStringGetSystemEncoding()); + } + } + DisposeHandle(nameHandle); + } + } + + // if Marc-style fails, do the original way + if (itemName == NULL) { + CFStringRef compTypeString = UTCreateStringForOSType(vCompDescs[i].componentType); + CFStringRef compSubTypeString = UTCreateStringForOSType(vCompDescs[i].componentSubType); + CFStringRef compManufacturerString = UTCreateStringForOSType(vCompDescs[i].componentManufacturer); + + itemName = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("%@ - %@ - %@"), + compTypeString, compManufacturerString, compSubTypeString); + + if (compTypeString != NULL) + CFRelease(compTypeString); + if (compSubTypeString != NULL) + CFRelease(compSubTypeString); + if (compManufacturerString != NULL) + CFRelease(compManufacturerString); + } + string realname = CFStringRefToStdString(itemName); + + AUPluginInfoPtr plug(new AUPluginInfo); + plug->name = realname; + plug->type = PluginInfo::AudioUnit; + plug->n_inputs = 0; + plug->n_outputs = 0; + plug->category = "AudioUnit"; + + plugs.push_back(plug); + } + + return plugs; +} |