summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaybin Rutkin <taybin@taybin.com>2006-08-08 04:17:26 +0000
committerTaybin Rutkin <taybin@taybin.com>2006-08-08 04:17:26 +0000
commitfb8903e443eadb265d049c9921afa23b2a672584 (patch)
treebe7bffa8441cba361815afb8f4fc31cebd8b5ddf
parentf961bbd941d1e9c90c13d53f62abd7de7878195b (diff)
AudioUnit work.
Filled in some stub functions. Started AUPluginUI class. git-svn-id: svn://localhost/ardour2/trunk@762 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--ardour.dox6
-rw-r--r--au_pluginui.cc45
-rw-r--r--gtk2_ardour/plugin_ui.h19
-rw-r--r--libs/ardour/ardour/audio_unit.h2
-rw-r--r--libs/ardour/audio_unit.cc80
5 files changed, 112 insertions, 40 deletions
diff --git a/ardour.dox b/ardour.dox
index a72ecbc588..f2036d352e 100644
--- a/ardour.dox
+++ b/ardour.dox
@@ -971,13 +971,13 @@ ENABLE_PREPROCESSING = YES
# compilation will be performed. Macro expansion can be done in a controlled
# way by setting EXPAND_ONLY_PREDEF to YES.
-MACRO_EXPANSION = NO
+MACRO_EXPANSION = YES
# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
# then the macro expansion is limited to the macros specified with the
# PREDEFINED and EXPAND_AS_DEFINED tags.
-EXPAND_ONLY_PREDEF = NO
+EXPAND_ONLY_PREDEF = YES
# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
# in the INCLUDE_PATH (see below) will be search if a #include is found.
@@ -1005,7 +1005,7 @@ INCLUDE_FILE_PATTERNS =
# undefined via #undef or recursively expanded use the := operator
# instead of the = operator.
-PREDEFINED =
+PREDEFINED = HAVE_COREAUDIO VST_SUPPORT HAVE_LIBLO FFT_ANALYSIS
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
# this tag can be used to specify a list of macro names that should be expanded.
diff --git a/au_pluginui.cc b/au_pluginui.cc
new file mode 100644
index 0000000000..cbf493a629
--- /dev/null
+++ b/au_pluginui.cc
@@ -0,0 +1,45 @@
+/*
+ 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.
+
+*/
+
+#include <ardour/insert.h>
+#include <ardour/audio_unit.h>
+
+#include "plugin_ui.h"
+
+using namespace ARDOUR;
+using namespace PBD;
+
+AUPluginUI::AUPluginUI (boost::shared_ptr<PluginInsert> pi, boost::shared_ptr<AUPlugin> ap)
+ : PlugUIBase (pi),
+ au (ap)
+{
+ info << "AUPluginUI created" << endmsg;
+}
+
+AUPluginUI::~AUPluginUI ()
+{
+ // nothing to do here - plugin destructor destroys the GUI
+}
+
+int
+AUPluginUI::get_preferred_height ()
+{
+ return -1;
+}
diff --git a/gtk2_ardour/plugin_ui.h b/gtk2_ardour/plugin_ui.h
index 570a224b66..0d0055fd47 100644
--- a/gtk2_ardour/plugin_ui.h
+++ b/gtk2_ardour/plugin_ui.h
@@ -50,6 +50,7 @@ namespace ARDOUR {
class Plugin;
class VSTPlugin;
class Redirect;
+ class AUPlugin;
}
namespace PBD {
@@ -231,6 +232,22 @@ class VSTPluginUI : public PlugUIBase, public Gtk::VBox
bool configure_handler (GdkEventConfigure*, Gtk::Socket*);
void save_plugin_setting ();
};
-#endif
+#endif // VST_SUPPORT
+
+#ifdef HAVE_COREAUDIO
+class AUPluginUI : public PlugUIBase
+{
+ public:
+ AUPluginUI (boost::shared_ptr<ARDOUR::PluginInsert>, boost::shared_ptr<ARDOUR::AUPlugin>);
+ ~AUPluginUI ();
+
+ gint get_preferred_height ();
+ bool start_updating(GdkEventAny*) {return false;}
+ bool stop_updating(GdkEventAny*) {return false;}
+
+ private:
+ boost::shared_ptr<ARDOUR::AUPlugin> au;
+};
+#endif // HAVE_COREAUDIO
#endif /* __ardour_plugin_ui_h__ */
diff --git a/libs/ardour/ardour/audio_unit.h b/libs/ardour/ardour/audio_unit.h
index f437ae053a..63522d8d5c 100644
--- a/libs/ardour/ardour/audio_unit.h
+++ b/libs/ardour/ardour/audio_unit.h
@@ -88,6 +88,8 @@ class AUPlugin : public ARDOUR::Plugin
private:
CAComponent* comp;
CAAudioUnit* unit;
+
+ std::vector<std::pair<uint32_t, uint32_t> > parameter_map;
};
class AUPluginInfo : public PluginInfo {
diff --git a/libs/ardour/audio_unit.cc b/libs/ardour/audio_unit.cc
index 0756f55a59..59797f3288 100644
--- a/libs/ardour/audio_unit.cc
+++ b/libs/ardour/audio_unit.cc
@@ -82,13 +82,13 @@ AUPlugin::unique_id () const
const char *
AUPlugin::label () const
{
- return "";
+ return "AUPlugin label";
}
const char *
AUPlugin::maker () const
{
- return "";
+ return "AUplugin maker";
}
uint32_t
@@ -100,25 +100,30 @@ AUPlugin::parameter_count () const
float
AUPlugin::default_value (uint32_t port)
{
- return 0.0;
+ // AudioUnits don't have default values. Maybe presets though?
+ return 0;
}
jack_nframes_t
AUPlugin::latency () const
{
- return 0;
+ return unit->Latency ();
}
void
AUPlugin::set_parameter (uint32_t which, float val)
{
-
+ unit->SetParameter (parameter_map[which].first, parameter_map[which].second, 0, val);
}
float
AUPlugin::get_parameter (uint32_t which) const
{
- return 0.0;
+ float outValue = 0.0;
+
+ unit->GetParameter(parameter_map[which].first, parameter_map[which].second, 0, outValue);
+
+ return outValue;
}
int
@@ -136,13 +141,13 @@ AUPlugin::nth_parameter (uint32_t which, bool& ok) const
void
AUPlugin::activate ()
{
-
+ unit->GlobalReset ();
}
void
AUPlugin::deactivate ()
{
-
+ // not needed. GlobalReset () takes care of it.
}
void
@@ -154,7 +159,19 @@ AUPlugin::set_block_size (jack_nframes_t nframes)
int
AUPlugin::connect_and_run (vector<Sample*>& bufs, uint32_t maxbuf, int32_t& in, int32_t& out, jack_nframes_t nframes, jack_nframes_t offset)
{
- return -1;
+ AudioUnitRenderActionFlags flags = 0;
+ AudioTimeStamp ts;
+
+ AudioBufferList abl;
+ abl.mNumberBuffers = 1;
+ abl.mBuffers[0].mNumberChannels = 1;
+ abl.mBuffers[0].mDataByteSize = nframes * sizeof(Sample);
+ abl.mBuffers[0].mData = &bufs[0];
+
+
+ unit->Render (&flags, &ts, 0, 0, &abl);
+
+ return 0;
}
set<uint32_t>
@@ -281,40 +298,31 @@ AUPluginInfo::discover ()
{
PluginInfoList plugs;
- int numTypes = 2; // this magic number was retrieved from the apple AUHost example.
-
CAComponentDescription desc;
desc.componentFlags = 0;
desc.componentFlagsMask = 0;
desc.componentSubType = 0;
desc.componentManufacturer = 0;
+ desc.componentType = kAudioUnitType_Effect;
- for (int i = 0; i < numTypes; ++i) {
- if (i == 1) {
- desc.componentType = kAudioUnitType_MusicEffect;
- } else {
- desc.componentType = kAudioUnitType_Effect;
- }
+ Component comp = 0;
- Component comp = 0;
-
- comp = FindNextComponent (NULL, &desc);
- while (comp != NULL) {
- CAComponentDescription temp;
- GetComponentInfo (comp, &temp, NULL, NULL, NULL);
-
- AUPluginInfoPtr plug(new AUPluginInfo);
- plug->name = AUPluginInfo::get_name (temp);
- plug->type = PluginInfo::AudioUnit;
- plug->n_inputs = 0;
- plug->n_outputs = 0;
- plug->category = "AudioUnit";
- plug->desc = new CAComponentDescription(temp);
-
- plugs.push_back(plug);
-
- comp = FindNextComponent (comp, &desc);
- }
+ comp = FindNextComponent (NULL, &desc);
+ while (comp != NULL) {
+ CAComponentDescription temp;
+ GetComponentInfo (comp, &temp, NULL, NULL, NULL);
+
+ AUPluginInfoPtr plug(new AUPluginInfo);
+ plug->name = AUPluginInfo::get_name (temp);
+ plug->type = PluginInfo::AudioUnit;
+ plug->n_inputs = 0;
+ plug->n_outputs = 0;
+ plug->category = "AudioUnit";
+ plug->desc = new CAComponentDescription(temp);
+
+ plugs.push_back(plug);
+
+ comp = FindNextComponent (comp, &desc);
}
return plugs;