mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-03 12:19:33 +01:00
Start of AudioUnit work. COREAUDIO=y is a little destable for now.
git-svn-id: svn://localhost/ardour2/trunk@724 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
4be1ccc43f
commit
2e2e20563c
11 changed files with 309 additions and 41 deletions
|
|
@ -97,7 +97,7 @@ arch_specific_objects = [ ]
|
|||
|
||||
osc_files = [ 'osc.cc' ]
|
||||
vst_files = [ 'vst_plugin.cc', 'session_vst.cc' ]
|
||||
coreaudio_files = [ 'coreaudiosource.cc' ]
|
||||
coreaudio_files = [ 'audio_unit.cc', 'coreaudiosource.cc' ]
|
||||
extra_sources = [ ]
|
||||
|
||||
if ardour['VST']:
|
||||
|
|
|
|||
35
libs/ardour/ardour/audio_unit.h
Normal file
35
libs/ardour/ardour/audio_unit.h
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
Copyright (C) 2006 Paul Davis
|
||||
Written by Taybin Rutkin
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it 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.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __ardour_audio_unit_h__
|
||||
#define __ardour_audio_unit_h__
|
||||
|
||||
#include <ardour/plugin.h>
|
||||
|
||||
namespace ARDOUR {
|
||||
|
||||
class AudioUnit : public ARDOUR::Plugin
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
} // namespace ARDOUR
|
||||
|
||||
#endif // __ardour_audio_unit_h__
|
||||
|
|
@ -23,6 +23,8 @@ class PluginManager {
|
|||
|
||||
std::list<PluginInfo*> &vst_plugin_info () { return _vst_plugin_info; }
|
||||
std::list<PluginInfo*> &ladspa_plugin_info () { return _ladspa_plugin_info; }
|
||||
std::list<PluginInfo*> &au_plugin_info () { return _au_plugin_info; }
|
||||
|
||||
void refresh ();
|
||||
|
||||
int add_ladspa_directory (std::string dirpath);
|
||||
|
|
@ -36,6 +38,7 @@ class PluginManager {
|
|||
ARDOUR::AudioEngine& _engine;
|
||||
std::list<PluginInfo*> _vst_plugin_info;
|
||||
std::list<PluginInfo*> _ladspa_plugin_info;
|
||||
std::list<PluginInfo*> _au_plugin_info;
|
||||
std::map<uint32_t, std::string> rdf_type;
|
||||
|
||||
std::string ladspa_path;
|
||||
|
|
@ -55,6 +58,8 @@ class PluginManager {
|
|||
int ladspa_discover_from_path (std::string path);
|
||||
int ladspa_discover (std::string path);
|
||||
|
||||
int au_discover ();
|
||||
|
||||
std::string get_ladspa_category (uint32_t id);
|
||||
|
||||
static PluginManager* _manager; // singleton
|
||||
|
|
@ -63,3 +68,4 @@ class PluginManager {
|
|||
} /* namespace ARDOUR */
|
||||
|
||||
#endif /* __ardour_plugin_manager_h__ */
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,10 @@
|
|||
#include <string>
|
||||
#include <cmath>
|
||||
|
||||
#ifdef HAVE_COREAUDIO
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#endif
|
||||
|
||||
#include "ardour.h"
|
||||
|
||||
class XMLNode;
|
||||
|
|
@ -53,4 +57,8 @@ int touch_file(std::string path);
|
|||
std::string region_name_from_path (std::string path);
|
||||
std::string path_expand (std::string);
|
||||
|
||||
#ifdef HAVE_COREAUDIO
|
||||
std::string CFStringRefToStdString(CFStringRef stringRef);
|
||||
#endif // HAVE_COREAUDIO
|
||||
|
||||
#endif /* __ardour_utils_h__ */
|
||||
|
|
|
|||
19
libs/ardour/audio_unit.cc
Normal file
19
libs/ardour/audio_unit.cc
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
Copyright (C) 2006 Paul Davis
|
||||
Written by Taybin Rutkin
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it 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.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
*/
|
||||
|
|
@ -238,25 +238,6 @@ AudioFileSource::create (const string& idstr, Flag flags)
|
|||
|
||||
#endif // HAVE_COREAUDIO
|
||||
|
||||
#ifdef HAVE_COREAUDIO
|
||||
std::string
|
||||
CFStringRefToStdString(CFStringRef stringRef)
|
||||
{
|
||||
CFIndex size =
|
||||
CFStringGetMaximumSizeForEncoding(CFStringGetLength(stringRef) ,
|
||||
kCFStringEncodingASCII);
|
||||
char *buf = new char[size];
|
||||
|
||||
std::string result;
|
||||
|
||||
if(CFStringGetCString(stringRef, buf, size, kCFStringEncodingASCII)) {
|
||||
result = buf;
|
||||
}
|
||||
delete [] buf;
|
||||
return result;
|
||||
}
|
||||
#endif // HAVE_COREAUDIO
|
||||
|
||||
bool
|
||||
AudioFileSource::get_soundfile_info (string path, SoundFileInfo& _info, string& error_msg)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
#include <fst.h>
|
||||
#include <pbd/basename.h>
|
||||
#include <string.h>
|
||||
#endif
|
||||
#endif // VST_SUPPORT
|
||||
|
||||
#include <pbd/pathscanner.h>
|
||||
|
||||
|
|
@ -41,6 +41,11 @@
|
|||
#include <pbd/error.h>
|
||||
#include <pbd/stl_delete.h>
|
||||
|
||||
#ifdef HAVE_COREAUDIO
|
||||
#include <CoreServices/CoreServices.h>
|
||||
#include <AudioUnit/AudioUnit.h>
|
||||
#endif // HAVE_COREAUDIO
|
||||
|
||||
#include "i18n.h"
|
||||
|
||||
using namespace ARDOUR;
|
||||
|
|
@ -95,7 +100,11 @@ PluginManager::refresh ()
|
|||
if (Config->get_use_vst()) {
|
||||
vst_refresh ();
|
||||
}
|
||||
#endif
|
||||
#endif // VST_SUPPORT
|
||||
|
||||
#ifdef HAVE_COREAUDIO
|
||||
au_discover ();
|
||||
#endif // HAVE_COREAUDIO
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -302,10 +311,10 @@ PluginManager::load (Session& session, PluginInfo *info)
|
|||
} else {
|
||||
error << _("You asked ardour to not use any VST plugins") << endmsg;
|
||||
}
|
||||
#else
|
||||
#else // !VST_SUPPORT
|
||||
error << _("This version of ardour has no support for VST plugins") << endmsg;
|
||||
return boost::shared_ptr<Plugin> ((Plugin*) 0);
|
||||
#endif
|
||||
#endif // !VST_SUPPORT
|
||||
|
||||
} else {
|
||||
|
||||
|
|
@ -342,12 +351,15 @@ ARDOUR::find_plugin(Session& session, string name, long unique_id, PluginInfo::T
|
|||
unique_id = 0; // VST plugins don't have a unique id.
|
||||
break;
|
||||
case PluginInfo::AudioUnit:
|
||||
plugs = &mgr->au_plugin_info();
|
||||
unique_id = 0;
|
||||
break;
|
||||
default:
|
||||
return boost::shared_ptr<Plugin> ((Plugin *) 0);
|
||||
}
|
||||
|
||||
for (i = plugs->begin(); i != plugs->end(); ++i) {
|
||||
if ((name == "" || (*i)->name == name) &&
|
||||
if ((name == "" || (*i)->name == name) &&
|
||||
(unique_id == 0 || (*i)->unique_id == unique_id)) {
|
||||
return mgr->load (session, *i);
|
||||
}
|
||||
|
|
@ -489,4 +501,102 @@ PluginManager::vst_discover (string path)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // VST_SUPPORT
|
||||
|
||||
#ifdef HAVE_COREAUDIO
|
||||
|
||||
int
|
||||
PluginManager::au_discover ()
|
||||
{
|
||||
int mNumUnits = 0;
|
||||
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;
|
||||
|
||||
for (int i = 0; i < numTypes; ++i) {
|
||||
if (i == 1) {
|
||||
desc.componentType = kAudioUnitType_MusicEffect;
|
||||
} else {
|
||||
desc.componentType = kAudioUnitType_Effect;
|
||||
}
|
||||
|
||||
int n = CountComponents (&desc);
|
||||
|
||||
mNumUnits += n;
|
||||
}
|
||||
cout << "Number of AU plugins: " << mNumUnits << endl;
|
||||
|
||||
ComponentDescription* mCompDescs = new ComponentDescription[mNumUnits];
|
||||
|
||||
int n = 0;
|
||||
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);
|
||||
mCompDescs[n++] = temp;
|
||||
comp = FindNextComponent (comp, &desc);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < mNumUnits; ++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, &(mCompDescs[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(mCompDescs[i].componentType);
|
||||
CFStringRef compSubTypeString = UTCreateStringForOSType(mCompDescs[i].componentSubType);
|
||||
CFStringRef compManufacturerString = UTCreateStringForOSType(mCompDescs[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);
|
||||
cout << realname << endl;
|
||||
}
|
||||
|
||||
delete[] mCompDescs;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // HAVE_COREAUDIO
|
||||
|
||||
|
|
|
|||
|
|
@ -253,3 +253,21 @@ path_expand (string path)
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAVE_COREAUDIO
|
||||
string
|
||||
CFStringRefToStdString(CFStringRef stringRef)
|
||||
{
|
||||
CFIndex size =
|
||||
CFStringGetMaximumSizeForEncoding(CFStringGetLength(stringRef) ,
|
||||
kCFStringEncodingASCII);
|
||||
char *buf = new char[size];
|
||||
|
||||
std::string result;
|
||||
|
||||
if(CFStringGetCString(stringRef, buf, size, kCFStringEncodingASCII)) {
|
||||
result = buf;
|
||||
}
|
||||
delete [] buf;
|
||||
return result;
|
||||
}
|
||||
#endif // HAVE_COREAUDIO
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue