summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk2_ardour/plugin_selector.cc93
-rw-r--r--gtk2_ardour/plugin_selector.h26
-rw-r--r--gtk2_ardour/sfdb_ui.cc2
-rw-r--r--libs/ardour/SConscript2
-rw-r--r--libs/ardour/ardour/audio_unit.h35
-rw-r--r--libs/ardour/ardour/plugin_manager.h6
-rw-r--r--libs/ardour/ardour/utils.h8
-rw-r--r--libs/ardour/audio_unit.cc19
-rw-r--r--libs/ardour/audiofilesource.cc19
-rw-r--r--libs/ardour/plugin_manager.cc122
-rw-r--r--libs/ardour/utils.cc18
11 files changed, 309 insertions, 41 deletions
diff --git a/gtk2_ardour/plugin_selector.cc b/gtk2_ardour/plugin_selector.cc
index a762a0b186..db63c285f1 100644
--- a/gtk2_ardour/plugin_selector.cc
+++ b/gtk2_ardour/plugin_selector.cc
@@ -196,6 +196,10 @@ PluginSelector::input_refiller ()
#ifdef VST_SUPPORT
vmodel->clear();
#endif
+
+#ifdef HAVE_COREAUDIO
+ aumodel->clear();
+#endif
// Insert into GTK list
for (row = 0, i=plugs.begin(); i != plugs.end(); ++i, ++row) {
snprintf (ibuf, sizeof(ibuf)-1, "%d", (*i)->n_inputs);
@@ -242,7 +246,40 @@ PluginSelector::vst_refiller ()
}
vmodel->set_sort_column (0, Gtk::SORT_ASCENDING);
}
-#endif
+#endif //VST_SUPPORT
+
+#ifdef HAVE_COREAUDIO
+
+void
+PluginSelector::_au_refiller (void *arg)
+{
+ ((PluginSelector *) arg)->au_refiller ();
+}
+
+void
+PluginSelector::au_refiller ()
+{
+ guint row;
+// list<PluginInfo *> &plugs = manager->au_plugin_info ();
+ list<PluginInfo *> &plugs;
+ list<PluginInfo *>::iterator i;
+ char ibuf[16], obuf[16];
+
+ // Insert into GTK list
+ for (row = 0, i=plugs.begin(); i != plugs.end(); ++i, ++row) {
+
+ snprintf (ibuf, sizeof(ibuf)-1, "%d", (*i)->n_inputs);
+ snprintf (obuf, sizeof(obuf)-1, "%d", (*i)->n_outputs);
+
+ Gtk::TreeModel::Row newrow = *(amodel->append());
+ newrow[acols.name] = (*i)->name.c_str();
+ newrow[acols.ins] = ibuf;
+ newrow[acols.outs] = obuf;
+ newrow[acols.plugin] = *i;
+ }
+ amodel->set_sort_column (0, Gtk::SORT_ASCENDING);
+}
+#endif //HAVE_COREAUDIO
void
PluginSelector::use_plugin (PluginInfo* pi)
@@ -263,29 +300,44 @@ PluginSelector::use_plugin (PluginInfo* pi)
void
PluginSelector::btn_add_clicked()
{
- bool vst = notebook.get_current_page(); // 0 = LADSPA, 1 = VST
+ // 0 = LADSPA, 1 = VST, 2 = AU
+ unsigned int page = notebook.get_current_page();
std::string name;
ARDOUR::PluginInfo *pi;
Gtk::TreeModel::Row newrow = *(amodel->append());
- if (vst) {
+ Gtk::TreeModel::Row row;
+
+ switch (page) {
+ case 0:
+ row = *(ladspa_display.get_selection()->get_selected());
+ name = row[lcols.name];
+ pi = row[lcols.plugin];
+ added_plugins.push_back (row[lcols.plugin]);
+ break;
+ case 1:
#ifdef VST_SUPPORT
- Gtk::TreeModel::Row row = *(vst_display.get_selection()->get_selected());
- name = row[vcols.name];
- pi = row[vcols.plugin];
- added_plugins.push_back (row[vcols.plugin]);
+ row = *(vst_display.get_selection()->get_selected());
+ name = row[vcols.name];
+ pi = row[vcols.plugin];
+ added_plugins.push_back (row[vcols.plugin]);
#endif
- } else {
- Gtk::TreeModel::Row row = *(ladspa_display.get_selection()->get_selected());
- name = row[lcols.name];
- pi = row[lcols.plugin];
- added_plugins.push_back (row[lcols.plugin]);
+ break;
+ case 2:
+#ifdef HAVE_COREAUDIO
+ row = *(au_display.get_selection()->get_selected());
+ name = row[aucols.name];
+ pi = row[aucols.plugin];
+ added_plugins.push_back (row[aucols.plugin]);
+#endif
+ break;
}
+
newrow[acols.text] = name;
newrow[acols.plugin] = pi;
if (!amodel->children().empty()) {
- set_response_sensitive (RESPONSE_APPLY, true);
+ set_response_sensitive (RESPONSE_APPLY, true);
}
}
@@ -313,6 +365,9 @@ PluginSelector::btn_update_clicked()
#ifdef VST_SUPPORT
vst_refiller ();
#endif
+#ifdef HAVE_COREAUDIO
+// au_refiller ();
+#endif
}
#ifdef VST_SUPPORT
@@ -327,6 +382,18 @@ PluginSelector::vst_display_selection_changed()
}
#endif
+#ifdef HAVE_COREAUDIO
+void
+PluginSelector::vst_display_selection_changed()
+{
+ if (au_display.get_selection()->count_selected_rows() != 0) {
+ btn_add->set_sensitive (true);
+ } else {
+ btn_add->set_sensitive (false);
+ }
+}
+#endif
+
void
PluginSelector::ladspa_display_selection_changed()
{
diff --git a/gtk2_ardour/plugin_selector.h b/gtk2_ardour/plugin_selector.h
index 220de74871..25cba998df 100644
--- a/gtk2_ardour/plugin_selector.h
+++ b/gtk2_ardour/plugin_selector.h
@@ -104,7 +104,30 @@ class PluginSelector : public ArdourDialog
static void _vst_refiller (void *);
void vst_refiller ();
void vst_display_selection_changed();
-#endif
+#endif // VST_SUPPORT
+
+#ifdef HAVE_COREAUDIO
+ // page 3
+ struct AUColumns : public Gtk::TreeModel::ColumnRecord {
+ AUColumns () {
+ add (name);
+ add (ins);
+ add (outs);
+ add (plugin);
+ }
+ Gtk::TreeModelColumn<std::string> name;
+ Gtk::TreeModelColumn<std::string> ins;
+ Gtk::TreeModelColumn<std::string> outs;
+ Gtk::TreeModelColumn<ARDOUR::PluginInfo *> plugin;
+ };
+ AUColumns aucols;
+ Glib::RefPtr<Gtk::ListStore> aumodel;
+ Glib::RefPtr<Gtk::TreeSelection> auselection;
+ Gtk::TreeView au_display;
+ static void _au_refiller (void *);
+ void au_refiller ();
+ void au_display_selection_changed();
+#endif //HAVE_COREAUDIO
ARDOUR::PluginInfo* i_selected_plug;
@@ -130,3 +153,4 @@ class PluginSelector : public ArdourDialog
};
#endif // __ardour_plugin_selector_h__
+
diff --git a/gtk2_ardour/sfdb_ui.cc b/gtk2_ardour/sfdb_ui.cc
index 4948525b15..d9ded04d2b 100644
--- a/gtk2_ardour/sfdb_ui.cc
+++ b/gtk2_ardour/sfdb_ui.cc
@@ -98,7 +98,7 @@ SoundFileBox::SoundFileBox ()
remove_field_btn.signal_clicked().connect
(mem_fun (*this, &SoundFileBox::remove_field_clicked));
- Gtk::CellRendererText* cell(static_cast<Gtk::CellRendererText*>(field_view.get_column_cell_renderer(1)));
+ Gtk::CellRendererText* cell(dynamic_cast<Gtk::CellRendererText*>(field_view.get_column_cell_renderer(1)));
cell->signal_edited().connect (mem_fun (*this, &SoundFileBox::field_edited));
field_view.get_selection()->signal_changed().connect (mem_fun (*this, &SoundFileBox::field_selected));
diff --git a/libs/ardour/SConscript b/libs/ardour/SConscript
index bca0a83d1e..1c30921353 100644
--- a/libs/ardour/SConscript
+++ b/libs/ardour/SConscript
@@ -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']:
diff --git a/libs/ardour/ardour/audio_unit.h b/libs/ardour/ardour/audio_unit.h
new file mode 100644
index 0000000000..88d311be44
--- /dev/null
+++ b/libs/ardour/ardour/audio_unit.h
@@ -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__ \ No newline at end of file
diff --git a/libs/ardour/ardour/plugin_manager.h b/libs/ardour/ardour/plugin_manager.h
index cc9a04738e..ca378dee98 100644
--- a/libs/ardour/ardour/plugin_manager.h
+++ b/libs/ardour/ardour/plugin_manager.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__ */
+
diff --git a/libs/ardour/ardour/utils.h b/libs/ardour/ardour/utils.h
index ad471085b5..ee4482d260 100644
--- a/libs/ardour/ardour/utils.h
+++ b/libs/ardour/ardour/utils.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__ */
diff --git a/libs/ardour/audio_unit.cc b/libs/ardour/audio_unit.cc
new file mode 100644
index 0000000000..5d7e7ae90c
--- /dev/null
+++ b/libs/ardour/audio_unit.cc
@@ -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.
+
+*/
diff --git a/libs/ardour/audiofilesource.cc b/libs/ardour/audiofilesource.cc
index 29736a8677..d3d870865f 100644
--- a/libs/ardour/audiofilesource.cc
+++ b/libs/ardour/audiofilesource.cc
@@ -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)
{
diff --git a/libs/ardour/plugin_manager.cc b/libs/ardour/plugin_manager.cc
index c8787a7d34..4be9b19468 100644
--- a/libs/ardour/plugin_manager.cc
+++ b/libs/ardour/plugin_manager.cc
@@ -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
+
diff --git a/libs/ardour/utils.cc b/libs/ardour/utils.cc
index f021639028..a7da7a914e 100644
--- a/libs/ardour/utils.cc
+++ b/libs/ardour/utils.cc
@@ -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