summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2006-08-01 19:18:12 +0000
committerDavid Robillard <d@drobilla.net>2006-08-01 19:18:12 +0000
commit0565c75ce8344ecd2e4b42edeabc9cace5f3c091 (patch)
tree57e1bf946652dc22c9426351996c4bb18a8e05cf /libs
parent79fc27de2ef9db51a8c7c69764b663a9921c5a40 (diff)
Merged up to trunk R732
git-svn-id: svn://localhost/ardour2/branches/midi@735 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-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/coreaudiosource.cc33
-rw-r--r--libs/ardour/plugin_manager.cc115
-rw-r--r--libs/ardour/utils.cc18
-rw-r--r--libs/surfaces/tranzport/tranzport_control_protocol.cc2
10 files changed, 222 insertions, 35 deletions
diff --git a/libs/ardour/SConscript b/libs/ardour/SConscript
index 394df05f04..fc94a13888 100644
--- a/libs/ardour/SConscript
+++ b/libs/ardour/SConscript
@@ -105,7 +105,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 e7264b9cf3..b3b672713f 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/coreaudiosource.cc b/libs/ardour/coreaudiosource.cc
index 55409a8524..5e9de225d4 100644
--- a/libs/ardour/coreaudiosource.cc
+++ b/libs/ardour/coreaudiosource.cc
@@ -68,13 +68,13 @@ CoreAudioSource::init (const string& idstr)
FSRef fsr;
err = FSPathMakeRef ((UInt8*)file.c_str(), &fsr, 0);
if (err != noErr) {
- cerr << "FSPathMakeRef " << err << endl;
+ error << string_compose (_("Could not make reference to file: %1"), name()) << endmsg;
throw failed_constructor();
}
err = ExtAudioFileOpen (&fsr, &af);
if (err != noErr) {
- cerr << "ExtAudioFileOpen " << err << endl;
+ error << string_compose (_("Could not open file: %1"), name()) << endmsg;
ExtAudioFileDispose (af);
throw failed_constructor();
}
@@ -85,7 +85,7 @@ CoreAudioSource::init (const string& idstr)
err = ExtAudioFileGetProperty(af,
kExtAudioFileProperty_FileDataFormat, &asbd_size, &file_asbd);
if (err != noErr) {
- cerr << "ExtAudioFileGetProperty1 " << err << endl;
+ error << string_compose (_("Could not get file data format for file: %1"), name()) << endmsg;
ExtAudioFileDispose (af);
throw failed_constructor();
}
@@ -104,7 +104,7 @@ CoreAudioSource::init (const string& idstr)
err = ExtAudioFileGetProperty(af, kExtAudioFileProperty_FileLengthFrames, &prop_size, &ca_frames);
if (err != noErr) {
- cerr << "ExtAudioFileGetProperty2 " << err << endl;
+ error << string_compose (_("Could not get file length for file: %1"), name()) << endmsg;
ExtAudioFileDispose (af);
throw failed_constructor();
}
@@ -125,14 +125,14 @@ CoreAudioSource::init (const string& idstr)
err = ExtAudioFileSetProperty (af, kExtAudioFileProperty_ClientDataFormat, asbd_size, &client_asbd);
if (err != noErr) {
- cerr << "ExtAudioFileSetProperty3 " << err << endl;
+ error << string_compose (_("Could not set client data format for file: %1"), name()) << endmsg;
ExtAudioFileDispose (af);
throw failed_constructor ();
}
if (_build_peakfiles) {
if (initialize_peakfile (false, file)) {
- error << "initialize peakfile failed" << endmsg;
+ error << string_compose(_("initialize peakfile failed for file %1"), name()) << endmsg;
ExtAudioFileDispose (af);
throw failed_constructor ();
}
@@ -212,7 +212,24 @@ CoreAudioSource::read_unlocked (Sample *dst, jack_nframes_t start, jack_nframes_
float
CoreAudioSource::sample_rate() const
{
- /* XXX taybin fill me in please */
+ AudioStreamBasicDescription client_asbd;
+ memset(&client_asbd, 0, sizeof(AudioStreamBasicDescription));
- return 44100.0f;
+ OSStatus err = noErr;
+ size_t asbd_size = sizeof(AudioStreamBasicDescription);
+
+ err = ExtAudioFileSetProperty (af, kExtAudioFileProperty_ClientDataFormat, asbd_size, &client_asbd);
+ if (err != noErr) {
+ error << string_compose(_("Could not detect samplerate for: %1"), name()) << endmsg;
+ return 0.0;
+ }
+
+ return client_asbd.mSampleRate;
}
+
+int
+CoreAudioSource::update_header (jack_nframes_t when, struct tm&, time_t)
+{
+ return 0;
+}
+
diff --git a/libs/ardour/plugin_manager.cc b/libs/ardour/plugin_manager.cc
index c8787a7d34..af7bc0f906 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,95 @@ PluginManager::vst_discover (string path)
return 0;
}
-#endif
+#endif // VST_SUPPORT
+
+#ifdef HAVE_COREAUDIO
+
+int
+PluginManager::au_discover ()
+{
+ _au_plugin_info.clear ();
+
+ 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);
+ }
+ }
+
+ PluginInfo* plug;
+ 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);
+
+ plug = new PluginInfo;
+ plug->name = realname;
+ plug->type = PluginInfo::AudioUnit;
+ plug->n_inputs = 0;
+ plug->n_outputs = 0;
+ plug->category = "AudioUnit";
+
+ _au_plugin_info.push_back(plug);
+ }
+
+ return 0;
+}
+
+#endif // HAVE_COREAUDIO
+
diff --git a/libs/ardour/utils.cc b/libs/ardour/utils.cc
index f021639028..78e5572a3d 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) ,
+ kCFStringEncodingUTF8);
+ char *buf = new char[size];
+
+ std::string result;
+
+ if(CFStringGetCString(stringRef, buf, size, kCFStringEncodingUTF8)) {
+ result = buf;
+ }
+ delete [] buf;
+ return result;
+}
+#endif // HAVE_COREAUDIO
diff --git a/libs/surfaces/tranzport/tranzport_control_protocol.cc b/libs/surfaces/tranzport/tranzport_control_protocol.cc
index 1fe9b7231a..426c837b2f 100644
--- a/libs/surfaces/tranzport/tranzport_control_protocol.cc
+++ b/libs/surfaces/tranzport/tranzport_control_protocol.cc
@@ -693,7 +693,7 @@ TranzportControlProtocol::update_state ()
/* per track */
if (route_table[0]) {
- AudioTrack* at = dynamic_cast<AudioTrack*> (route_table[0]);
+ boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack> (route_table[0]);
if (at && at->record_enabled()) {
pending_lights[LightTrackrec] = true;
} else {