From e51e31dca20d1e636508c61d93a740fdb48eeebd Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 2 Aug 2006 00:22:16 +0000 Subject: Merged from trunk R743 git-svn-id: svn://localhost/ardour2/branches/midi@744 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/audio_unit.h | 30 ++++++++- libs/ardour/ardour/audioengine.h | 1 + libs/ardour/ardour/buffer.h | 58 +++--------------- libs/ardour/ardour/data_type.h | 79 ++++++++++++++++++++++++ libs/ardour/ardour/io.h | 7 ++- libs/ardour/ardour/plugin.h | 3 + libs/ardour/ardour/plugin_manager.h | 16 ++--- libs/ardour/ardour/route.h | 2 +- libs/ardour/ardour/track.h | 4 +- libs/ardour/ardour/types.h | 8 +-- libs/ardour/audio_unit.cc | 93 ++++++++++++++++++++++++++++ libs/ardour/audioengine.cc | 4 +- libs/ardour/audiofilesource.cc | 6 ++ libs/ardour/audioregion.cc | 4 +- libs/ardour/auditioner.cc | 5 +- libs/ardour/automation_event.cc | 2 +- libs/ardour/crossfade.cc | 4 +- libs/ardour/io.cc | 4 +- libs/ardour/midi_track.cc | 2 +- libs/ardour/mix.cc | 6 +- libs/ardour/panner.cc | 14 ++--- libs/ardour/plugin_manager.cc | 119 +++--------------------------------- libs/ardour/route.cc | 6 +- libs/ardour/session.cc | 68 +++++++++++++++------ libs/ardour/session_state.cc | 8 +-- 25 files changed, 325 insertions(+), 228 deletions(-) create mode 100644 libs/ardour/ardour/data_type.h (limited to 'libs/ardour') diff --git a/libs/ardour/ardour/audio_unit.h b/libs/ardour/ardour/audio_unit.h index 88d311be44..ec437109a4 100644 --- a/libs/ardour/ardour/audio_unit.h +++ b/libs/ardour/ardour/audio_unit.h @@ -21,15 +21,41 @@ #ifndef __ardour_audio_unit_h__ #define __ardour_audio_unit_h__ +#include + #include +#include + +struct ComponentDescription; + namespace ARDOUR { -class AudioUnit : public ARDOUR::Plugin +class AUPlugin : public ARDOUR::Plugin { + public: + AUPlugin (AudioEngine& engine, Session& session) : Plugin(engine, session) {}; + virtual ~AUPlugin () {}; +}; + +class AUPluginInfo : public PluginInfo { + public: + typedef boost::shared_ptr CompDescPtr; + AUPluginInfo () { }; + ~AUPluginInfo () { }; + + CompDescPtr desc; + + static PluginInfoList discover (); + + private: + friend class PluginManager; }; +typedef boost::shared_ptr AUPluginInfoPtr; + } // namespace ARDOUR -#endif // __ardour_audio_unit_h__ \ No newline at end of file +#endif // __ardour_audio_unit_h__ + diff --git a/libs/ardour/ardour/audioengine.h b/libs/ardour/ardour/audioengine.h index 81370e379c..e7500fc7a2 100644 --- a/libs/ardour/ardour/audioengine.h +++ b/libs/ardour/ardour/audioengine.h @@ -35,6 +35,7 @@ #include #include #include +#include namespace ARDOUR { diff --git a/libs/ardour/ardour/buffer.h b/libs/ardour/ardour/buffer.h index cd36a06e36..1321f6c107 100644 --- a/libs/ardour/ardour/buffer.h +++ b/libs/ardour/ardour/buffer.h @@ -1,6 +1,5 @@ /* Copyright (C) 2006 Paul Davis - Written by Dave Robillard, 2006 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 @@ -24,7 +23,7 @@ #include // for posix_memalign #include #include -#include +#include namespace ARDOUR { @@ -60,44 +59,7 @@ public: /** Type of this buffer. * Based on this you can static cast a Buffer* to the desired type. */ - virtual DataType type() const { return _type; } - - /** Jack type (eg JACK_DEFAULT_AUDIO_TYPE) */ - const char* jack_type() const { return type_to_jack_type(type()); } - - /** String type as saved in session XML files (eg "audio" or "midi") */ - const char* type_string() const { return type_to_string(type()); } - - /* The below static methods need to be separate from the above methods - * because the conversion is needed in places where there's no Buffer. - * These should probably live somewhere else... - */ - - static const char* type_to_jack_type(DataType t) { - switch (t) { - case AUDIO: return JACK_DEFAULT_AUDIO_TYPE; - case MIDI: return JACK_DEFAULT_MIDI_TYPE; - default: return ""; - } - } - - static const char* type_to_string(DataType t) { - switch (t) { - case AUDIO: return "audio"; - case MIDI: return "midi"; - default: return "unknown"; // reeeally shouldn't ever happen - } - } - - /** Used for loading from XML (route default types etc) */ - static DataType type_from_string(const string& str) { - if (str == "audio") - return AUDIO; - else if (str == "midi") - return MIDI; - else - return NIL; - } + DataType type() const { return _type; } protected: DataType _type; @@ -114,12 +76,12 @@ class AudioBuffer : public Buffer { public: AudioBuffer(size_t capacity) - : Buffer(AUDIO, capacity) + : Buffer(DataType::AUDIO, capacity) , _data(NULL) { _size = capacity; // For audio buffers, size = capacity (always) #ifdef NO_POSIX_MEMALIGN - b = (Sample *) malloc(sizeof(Sample) * capacity); + _data = (Sample *) malloc(sizeof(Sample) * capacity); #else posix_memalign((void**)_data, 16, sizeof(Sample) * capacity); #endif @@ -135,7 +97,7 @@ private: AudioBuffer(const AudioBuffer& copy); AudioBuffer& operator=(const AudioBuffer& copy); - Sample* const _data; ///< Actual buffer contents + Sample* _data; ///< Actual buffer contents }; @@ -145,17 +107,17 @@ class MidiBuffer : public Buffer { public: MidiBuffer(size_t capacity) - : Buffer(MIDI, capacity) + : Buffer(DataType::MIDI, capacity) , _data(NULL) { + _size = capacity; // For audio buffers, size = capacity (always) #ifdef NO_POSIX_MEMALIGN - b = (Sample *) malloc(sizeof(RawMidi) * capacity); + _data = (RawMidi *) malloc(sizeof(RawMidi) * capacity); #else posix_memalign((void**)_data, 16, sizeof(RawMidi) * capacity); #endif assert(_data); - assert(_size == 0); - memset(_data, 0, sizeof(Sample) * capacity); + memset(_data, 0, sizeof(RawMidi) * capacity); } const RawMidi* data() const { return _data; } @@ -166,7 +128,7 @@ private: MidiBuffer(const MidiBuffer& copy); MidiBuffer& operator=(const MidiBuffer& copy); - RawMidi* const _data; ///< Actual buffer contents + RawMidi* _data; ///< Actual buffer contents }; diff --git a/libs/ardour/ardour/data_type.h b/libs/ardour/ardour/data_type.h new file mode 100644 index 0000000000..d49ed108cd --- /dev/null +++ b/libs/ardour/ardour/data_type.h @@ -0,0 +1,79 @@ +/* + Copyright (C) 2006 Paul Davis + + 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_data_type_h__ +#define __ardour_data_type_h__ + +#include + +namespace ARDOUR { + +class DataType +{ +public: + enum Symbol { + NIL = 0, + AUDIO, + MIDI + }; + + DataType(const Symbol& symbol) + : _symbol(symbol) + {} + + /** Construct from a string (Used for loading from XML) */ + DataType(const string& str) { + if (str == "audio") + _symbol = AUDIO; + //else if (str == "midi") + // _symbol = MIDI; + else + _symbol = NIL; + } + + bool operator==(const Symbol symbol) { return _symbol == symbol; } + bool operator!=(const Symbol symbol) { return _symbol != symbol; } + + /** Get the Jack type this DataType corresponds to */ + const char* to_jack_type() { + switch (_symbol) { + case AUDIO: return JACK_DEFAULT_AUDIO_TYPE; + //case MIDI: return JACK_DEFAULT_MIDI_TYPE; + default: return ""; + } + } + + /** Inverse of the from-string constructor */ + const char* to_string() { + switch (_symbol) { + case AUDIO: return "audio"; + //case MIDI: return "midi"; + default: return "unknown"; // reeeally shouldn't ever happen + } + } + +private: + Symbol _symbol; +}; + + + +} // namespace ARDOUR + +#endif // __ardour_data_type_h__ + diff --git a/libs/ardour/ardour/io.h b/libs/ardour/ardour/io.h index 35b20f655e..b116a58b97 100644 --- a/libs/ardour/ardour/io.h +++ b/libs/ardour/ardour/io.h @@ -39,6 +39,7 @@ #include #include #include +#include using std::string; using std::vector; @@ -67,7 +68,7 @@ class IO : public Stateful, public ARDOUR::StateManager IO (Session&, string name, int input_min = -1, int input_max = -1, int output_min = -1, int output_max = -1, - DataType default_type = AUDIO); + DataType default_type = DataType::AUDIO); virtual ~IO(); @@ -116,8 +117,8 @@ class IO : public Stateful, public ARDOUR::StateManager Connection *input_connection() const { return _input_connection; } Connection *output_connection() const { return _output_connection; } - int add_input_port (string source, void *src, DataType type = NIL); - int add_output_port (string destination, void *src, DataType type = NIL); + int add_input_port (string source, void *src, DataType type = DataType::NIL); + int add_output_port (string destination, void *src, DataType type = DataType::NIL); int remove_input_port (Port *, void *src); int remove_output_port (Port *, void *src); diff --git a/libs/ardour/ardour/plugin.h b/libs/ardour/ardour/plugin.h index 97708065e4..86666c19af 100644 --- a/libs/ardour/ardour/plugin.h +++ b/libs/ardour/ardour/plugin.h @@ -73,6 +73,9 @@ class PluginInfo { uint32_t index; }; +typedef boost::shared_ptr PluginInfoPtr; +typedef std::list PluginInfoList; + class Plugin : public Stateful, public sigc::trackable { diff --git a/libs/ardour/ardour/plugin_manager.h b/libs/ardour/ardour/plugin_manager.h index ca378dee98..8543ad5285 100644 --- a/libs/ardour/ardour/plugin_manager.h +++ b/libs/ardour/ardour/plugin_manager.h @@ -8,6 +8,8 @@ #include #include +#include +#include namespace ARDOUR { @@ -21,24 +23,24 @@ class PluginManager { PluginManager (ARDOUR::AudioEngine&); ~PluginManager (); - std::list &vst_plugin_info () { return _vst_plugin_info; } - std::list &ladspa_plugin_info () { return _ladspa_plugin_info; } - std::list &au_plugin_info () { return _au_plugin_info; } + ARDOUR::PluginInfoList &vst_plugin_info () { return _vst_plugin_info; } + ARDOUR::PluginInfoList &ladspa_plugin_info () { return _ladspa_plugin_info; } + ARDOUR::PluginInfoList &au_plugin_info () { return _au_plugin_info; } void refresh (); int add_ladspa_directory (std::string dirpath); int add_vst_directory (std::string dirpath); - boost::shared_ptr load (ARDOUR::Session& s, PluginInfo* info); + boost::shared_ptr load (ARDOUR::Session& s, PluginInfoPtr info); static PluginManager* the_manager() { return _manager; } private: ARDOUR::AudioEngine& _engine; - std::list _vst_plugin_info; - std::list _ladspa_plugin_info; - std::list _au_plugin_info; + ARDOUR::PluginInfoList _vst_plugin_info; + ARDOUR::PluginInfoList _ladspa_plugin_info; + ARDOUR::PluginInfoList _au_plugin_info; std::map rdf_type; std::string ladspa_path; diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h index ea4a2374d4..8271c1cf6a 100644 --- a/libs/ardour/ardour/route.h +++ b/libs/ardour/ardour/route.h @@ -70,7 +70,7 @@ class Route : public IO Route (Session&, std::string name, int input_min, int input_max, int output_min, int output_max, - Flag flags = Flag(0), DataType default_type = AUDIO); + Flag flags = Flag(0), DataType default_type = DataType::AUDIO); Route (Session&, const XMLNode&); virtual ~Route(); diff --git a/libs/ardour/ardour/track.h b/libs/ardour/ardour/track.h index 707ead1573..f16e9d29d9 100644 --- a/libs/ardour/ardour/track.h +++ b/libs/ardour/ardour/track.h @@ -31,7 +31,7 @@ class RouteGroup; class Track : public Route { public: - Track (Session&, string name, Route::Flag f = Route::Flag (0), TrackMode m = Normal, DataType default_type = AUDIO); + Track (Session&, string name, Route::Flag f = Route::Flag (0), TrackMode m = Normal, DataType default_type = DataType::AUDIO); virtual ~Track (); @@ -91,7 +91,7 @@ class Track : public Route sigc::signal FreezeChange; protected: - Track (Session& sess, const XMLNode& node, DataType default_type = AUDIO); + Track (Session& sess, const XMLNode& node, DataType default_type = DataType::AUDIO); virtual XMLNode& state (bool full) = 0; diff --git a/libs/ardour/ardour/types.h b/libs/ardour/ardour/types.h index eb86470ebc..c30c103d3f 100644 --- a/libs/ardour/ardour/types.h +++ b/libs/ardour/ardour/types.h @@ -195,7 +195,7 @@ namespace ARDOUR { Splice }; - enum RegionPoint { + enum RegionPoint { Start, End, SyncPoint @@ -245,12 +245,6 @@ namespace ARDOUR { PeakDatum min; PeakDatum max; }; - - enum DataType { - NIL = 0, - AUDIO, - MIDI - }; } std::istream& operator>>(std::istream& o, ARDOUR::SampleFormat& sf); 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 +#include + +#include +#include + +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 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; +} diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc index 5618c7ef5f..982a7c5971 100644 --- a/libs/ardour/audioengine.cc +++ b/libs/ardour/audioengine.cc @@ -401,7 +401,7 @@ AudioEngine::register_input_port (DataType type, const string& portname) } jack_port_t *p = jack_port_register (_jack, portname.c_str(), - Buffer::type_to_jack_type(type), JackPortIsInput, 0); + type.to_jack_type(), JackPortIsInput, 0); if (p) { @@ -435,7 +435,7 @@ AudioEngine::register_output_port (DataType type, const string& portname) jack_port_t *p; if ((p = jack_port_register (_jack, portname.c_str(), - Buffer::type_to_jack_type(type), JackPortIsOutput, 0)) != 0) { + type.to_jack_type(), JackPortIsOutput, 0)) != 0) { Port *newport = new Port (p); ports.insert (ports.begin(), newport); return newport; diff --git a/libs/ardour/audiofilesource.cc b/libs/ardour/audiofilesource.cc index b3b672713f..46079ef9a5 100644 --- a/libs/ardour/audiofilesource.cc +++ b/libs/ardour/audiofilesource.cc @@ -618,6 +618,12 @@ AudioFileSource::set_name (string newname, bool destructive) return -1; } + // Test whether newpath exists, if yes notify the user but continue. + if (access(newpath.c_str(),F_OK) == 0) { + error << _("Programming error! Ardour tried to rename a file over another file! It's safe to continue working, but please report this to the developers.") << endmsg; + return -1; + } + if (rename (oldpath.c_str(), newpath.c_str()) != 0) { error << string_compose (_("cannot rename audio file for %1 to %2"), _name, newpath) << endmsg; return -1; diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc index fff1c99598..51c7612137 100644 --- a/libs/ardour/audioregion.cc +++ b/libs/ardour/audioregion.cc @@ -644,7 +644,7 @@ AudioRegion::state (bool full) snprintf (buf, sizeof (buf), "0x%x", (int) _flags); node.add_property ("flags", buf); - snprintf (buf, sizeof(buf), "%f", _scale_amplitude); + snprintf (buf, sizeof(buf), "%.12g", _scale_amplitude); node.add_property ("scale-gain", buf); for (uint32_t n=0; n < sources.size(); ++n) { @@ -1258,7 +1258,7 @@ AudioRegion::set_scale_amplitude (gain_t g) void AudioRegion::normalize_to (float target_dB) { - const jack_nframes_t blocksize = 256 * 1048; + const jack_nframes_t blocksize = 64 * 1024; Sample buf[blocksize]; char workbuf[blocksize * 4]; jack_nframes_t fpos; diff --git a/libs/ardour/auditioner.cc b/libs/ardour/auditioner.cc index 81f64d2671..e48f103b9f 100644 --- a/libs/ardour/auditioner.cc +++ b/libs/ardour/auditioner.cc @@ -27,6 +27,7 @@ #include #include #include +#include using namespace std; using namespace ARDOUR; @@ -44,12 +45,12 @@ Auditioner::Auditioner (Session& s) defer_pan_reset (); if (left.length()) { - add_output_port (left, this, AUDIO); + add_output_port (left, this, DataType::AUDIO); } if (right.length()) { audio_diskstream().add_channel(); - add_output_port (right, this, AUDIO); + add_output_port (right, this, DataType::AUDIO); } allow_pan_reset (); diff --git a/libs/ardour/automation_event.cc b/libs/ardour/automation_event.cc index 3df7dd94f7..63492b375b 100644 --- a/libs/ardour/automation_event.cc +++ b/libs/ardour/automation_event.cc @@ -1211,7 +1211,7 @@ AutomationList::store_state (XMLNode& node) const snprintf (buf, sizeof (buf), "%" PRIu32, (jack_nframes_t) floor ((*i)->when)); pointnode->add_property ("x", buf); - snprintf (buf, sizeof (buf), "%f", (*i)->value); + snprintf (buf, sizeof (buf), "%.12g", (*i)->value); pointnode->add_property ("y", buf); node.add_child_nocopy (*pointnode); diff --git a/libs/ardour/crossfade.cc b/libs/ardour/crossfade.cc index bbe0c63b0a..dc4c074844 100644 --- a/libs/ardour/crossfade.cc +++ b/libs/ardour/crossfade.cc @@ -702,7 +702,7 @@ Crossfade::get_state () snprintf (buf, sizeof (buf), "%" PRIu32, (jack_nframes_t) floor ((*ii)->when)); pnode->add_property ("x", buf); - snprintf (buf, sizeof (buf), "%f", (*ii)->value); + snprintf (buf, sizeof (buf), "%.12g", (*ii)->value); pnode->add_property ("y", buf); child->add_child_nocopy (*pnode); } @@ -716,7 +716,7 @@ Crossfade::get_state () snprintf (buf, sizeof (buf), "%" PRIu32, (jack_nframes_t) floor ((*ii)->when)); pnode->add_property ("x", buf); - snprintf (buf, sizeof (buf), "%f", (*ii)->value); + snprintf (buf, sizeof (buf), "%.12g", (*ii)->value); pnode->add_property ("y", buf); child->add_child_nocopy (*pnode); } diff --git a/libs/ardour/io.cc b/libs/ardour/io.cc index a70bf8abd3..2dfd735a6b 100644 --- a/libs/ardour/io.cc +++ b/libs/ardour/io.cc @@ -797,7 +797,7 @@ IO::add_output_port (string destination, void* src, DataType type) Port* our_port; char name[64]; - if (type == NIL) + if (type == DataType::NIL) type = _default_type; { @@ -909,7 +909,7 @@ IO::add_input_port (string source, void* src, DataType type) Port* our_port; char name[64]; - if (type == NIL) + if (type == DataType::NIL) type = _default_type; { diff --git a/libs/ardour/midi_track.cc b/libs/ardour/midi_track.cc index bdf242bed0..f37ba9f190 100644 --- a/libs/ardour/midi_track.cc +++ b/libs/ardour/midi_track.cc @@ -40,7 +40,7 @@ using namespace ARDOUR; using namespace PBD; MidiTrack::MidiTrack (Session& sess, string name, Route::Flag flag, TrackMode mode) - : Track (sess, name, flag, mode, MIDI) + : Track (sess, name, flag, mode, DataType::MIDI) { MidiDiskstream::Flag dflags = MidiDiskstream::Flag (0); diff --git a/libs/ardour/mix.cc b/libs/ardour/mix.cc index ab0d1dde59..c6e234d87b 100644 --- a/libs/ardour/mix.cc +++ b/libs/ardour/mix.cc @@ -22,6 +22,7 @@ #include #include #include +#include #if defined (ARCH_X86) && defined (BUILD_SSE_OPTIMIZATIONS) @@ -119,8 +120,9 @@ mix_buffers_no_gain (ARDOUR::Sample *dst, ARDOUR::Sample *src, jack_nframes_t nf float veclib_compute_peak (ARDOUR::Sample *buf, jack_nframes_t nsamples, float current) { - vDSP_maxv(buf, 1, ¤t, nsamples); - return current; + float tmpmax = 0.0f; + vDSP_maxmgv(buf, 1, &tmpmax, nsamples); + return f_max(current, tmpmax); } void diff --git a/libs/ardour/panner.cc b/libs/ardour/panner.cc index 4984e13fa9..8336c4697c 100644 --- a/libs/ardour/panner.cc +++ b/libs/ardour/panner.cc @@ -529,7 +529,7 @@ EqualPowerStereoPanner::state (bool full_state) char buf[64]; LocaleGuard lg (X_("POSIX")); - snprintf (buf, sizeof (buf), "%f", x); + snprintf (buf, sizeof (buf), "%.12g", x); root->add_property (X_("x"), buf); root->add_property (X_("type"), EqualPowerStereoPanner::name); if (full_state) { @@ -763,9 +763,9 @@ Multi2dPanner::state (bool full_state) char buf[64]; LocaleGuard lg (X_("POSIX")); - snprintf (buf, sizeof (buf), "%f", x); + snprintf (buf, sizeof (buf), "%.12g", x); root->add_property (X_("x"), buf); - snprintf (buf, sizeof (buf), "%f", y); + snprintf (buf, sizeof (buf), "%.12g", y); root->add_property (X_("y"), buf); root->add_property (X_("type"), Multi2dPanner::name); @@ -1207,9 +1207,9 @@ Panner::state (bool full) for (vector::iterator o = outputs.begin(); o != outputs.end(); ++o) { XMLNode* onode = new XMLNode (X_("Output")); - snprintf (buf, sizeof (buf), "%f", (*o).x); + snprintf (buf, sizeof (buf), "%.12g", (*o).x); onode->add_property (X_("x"), buf); - snprintf (buf, sizeof (buf), "%f", (*o).y); + snprintf (buf, sizeof (buf), "%.12g", (*o).y); onode->add_property (X_("y"), buf); root->add_child_nocopy (*onode); } @@ -1258,10 +1258,10 @@ Panner::set_state (const XMLNode& node) float x, y; prop = (*niter)->property (X_("x")); - sscanf (prop->value().c_str(), "%f", &x); + sscanf (prop->value().c_str(), "%.12g", &x); prop = (*niter)->property (X_("y")); - sscanf (prop->value().c_str(), "%f", &y); + sscanf (prop->value().c_str(), "%.12g", &y); outputs.push_back (Output (x, y)); } diff --git a/libs/ardour/plugin_manager.cc b/libs/ardour/plugin_manager.cc index af7bc0f906..06a944189a 100644 --- a/libs/ardour/plugin_manager.cc +++ b/libs/ardour/plugin_manager.cc @@ -37,15 +37,11 @@ #include #include #include +#include #include #include -#ifdef HAVE_COREAUDIO -#include -#include -#endif // HAVE_COREAUDIO - #include "i18n.h" using namespace ARDOUR; @@ -103,17 +99,13 @@ PluginManager::refresh () #endif // VST_SUPPORT #ifdef HAVE_COREAUDIO - au_discover (); + _au_plugin_info = AUPluginInfo::discover (); #endif // HAVE_COREAUDIO } void PluginManager::ladspa_refresh () { - for (std::list::iterator i = _ladspa_plugin_info.begin(); i != _ladspa_plugin_info.end(); ++i) { - delete *i; - } - _ladspa_plugin_info.clear (); if (ladspa_path.length() == 0) { @@ -234,7 +226,6 @@ PluginManager::add_lrdf_data (const string &path) int PluginManager::ladspa_discover (string path) { - PluginInfo *info; void *module; const LADSPA_Descriptor *descriptor; LADSPA_Descriptor_Function dfunc; @@ -259,7 +250,7 @@ PluginManager::ladspa_discover (string path) break; } - info = new PluginInfo; + PluginInfoPtr info(new PluginInfo); info->name = descriptor->Name; info->category = get_ladspa_category(descriptor->UniqueID); info->path = path; @@ -290,7 +281,7 @@ PluginManager::ladspa_discover (string path) } boost::shared_ptr -PluginManager::load (Session& session, PluginInfo *info) +PluginManager::load (Session& session, PluginInfoPtr info) { void *module; @@ -339,8 +330,7 @@ boost::shared_ptr ARDOUR::find_plugin(Session& session, string name, long unique_id, PluginInfo::Type type) { PluginManager *mgr = PluginManager::the_manager(); - list::iterator i; - list* plugs = 0; + PluginInfoList* plugs = 0; switch (type) { case PluginInfo::LADSPA: @@ -358,6 +348,7 @@ ARDOUR::find_plugin(Session& session, string name, long unique_id, PluginInfo::T return boost::shared_ptr ((Plugin *) 0); } + PluginInfoList::iterator i; for (i = plugs->begin(); i != plugs->end(); ++i) { if ((name == "" || (*i)->name == name) && (unique_id == 0 || (*i)->unique_id == unique_id)) { @@ -409,10 +400,6 @@ PluginManager::get_ladspa_category (uint32_t plugin_id) void PluginManager::vst_refresh () { - for (std::list::iterator i = _vst_plugin_info.begin(); i != _vst_plugin_info.end(); ++i) { - delete *i; - } - _vst_plugin_info.clear (); if (vst_path.length() == 0) { @@ -466,7 +453,6 @@ int PluginManager::vst_discover (string path) { FSTInfo* finfo; - PluginInfo* info; if ((finfo = fst_get_info (const_cast (path.c_str()))) == 0) { return -1; @@ -478,7 +464,7 @@ PluginManager::vst_discover (string path) << endl; } - info = new PluginInfo; + PluginInfoPtr info(new PluginInfo); /* what a goddam joke freeware VST is */ @@ -502,94 +488,3 @@ PluginManager::vst_discover (string path) } #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 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/route.cc b/libs/ardour/route.cc index 713eed1b82..58647be439 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -1333,7 +1333,7 @@ Route::state(bool full_state) node->add_property("flags", buf); } - node->add_property("default-type", Buffer::type_to_string(_default_type)); + node->add_property("default-type", _default_type.to_string()); node->add_property("active", _active?"yes":"no"); node->add_property("muted", _muted?"yes":"no"); @@ -1510,8 +1510,8 @@ Route::set_state (const XMLNode& node) } if ((prop = node.property ("default-type")) != 0) { - _default_type = Buffer::type_from_string(prop->value()); - assert(_default_type != NIL); + _default_type = DataType(prop->value()); + assert(_default_type != DataType::NIL); } if ((prop = node.property ("phase-invert")) != 0) { diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 40457c33db..902da43d91 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -69,6 +69,7 @@ #include #include #include +#include #ifdef HAVE_LIBLO #include @@ -728,7 +729,7 @@ Session::when_engine_running () _master_out->defer_pan_reset (); while ((int) _master_out->n_inputs() < _master_out->input_maximum()) { - if (_master_out->add_input_port ("", this, AUDIO)) { + if (_master_out->add_input_port ("", this, DataType::AUDIO)) { error << _("cannot setup master inputs") << endmsg; break; @@ -736,7 +737,7 @@ Session::when_engine_running () } n = 0; while ((int) _master_out->n_outputs() < _master_out->output_maximum()) { - if (_master_out->add_output_port (_engine.get_nth_physical_output (n), this, AUDIO)) { + if (_master_out->add_output_port (_engine.get_nth_physical_output (n), this, DataType::AUDIO)) { error << _("cannot setup master outputs") << endmsg; break; @@ -1808,7 +1809,7 @@ Session::new_midi_route () } while (n < (UINT_MAX-1)); try { - shared_ptr bus (new Route (*this, bus_name, -1, -1, -1, -1, Route::Flag(0), MIDI)); + shared_ptr bus (new Route (*this, bus_name, -1, -1, -1, -1, Route::Flag(0), DataType::MIDI)); if (bus->ensure_io (1, 1, false, this)) { error << (_("cannot configure 1 in/1 out configuration for new midi track")) @@ -2016,7 +2017,7 @@ Session::new_audio_route (int input_channels, int output_channels) } while (n < (UINT_MAX-1)); try { - shared_ptr bus (new Route (*this, bus_name, -1, -1, -1, -1, Route::Flag(0), AUDIO)); + shared_ptr bus (new Route (*this, bus_name, -1, -1, -1, -1, Route::Flag(0), DataType::AUDIO)); if (bus->ensure_io (input_channels, output_channels, false, this)) { error << string_compose (_("cannot configure %1 in/%2 out configuration for new audio track"), @@ -2974,12 +2975,13 @@ Session::change_audio_path_by_name (string path, string oldname, string newname, the task here is to replace NAME with the new name. */ - /* find last slash */ - string dir; string suffix; string::size_type slash; string::size_type dash; + string::size_type postfix; + + /* find last slash */ if ((slash = path.find_last_of ('/')) == string::npos) { return ""; @@ -2993,11 +2995,41 @@ Session::change_audio_path_by_name (string path, string oldname, string newname, return ""; } - suffix = path.substr (dash); + suffix = path.substr (dash+1); + + // Suffix is now everything after the dash. Now we need to eliminate + // the nnnnn part, which is done by either finding a '%' or a '.' + + postfix = suffix.find_last_of ("%"); + if (postfix == string::npos) { + postfix = suffix.find_last_of ('.'); + } + + if (postfix != string::npos) { + suffix = suffix.substr (postfix); + } else { + error << "Logic error in Session::change_audio_path_by_name(), please report to the developers" << endl; + return ""; + } + + const uint32_t limit = 10000; + char buf[PATH_MAX+1]; + + for (uint32_t cnt = 1; cnt <= limit; ++cnt) { + + snprintf (buf, sizeof(buf), "%s%s-%u%s", dir.c_str(), newname.c_str(), cnt, suffix.c_str()); + + if (access (buf, F_OK) != 0) { + path = buf; + break; + } + path = ""; + } + + if (path == "") { + error << "FATAL ERROR! Could not find a " << endl; + } - path = dir; - path += new_legalized; - path += suffix; } return path; @@ -3020,20 +3052,20 @@ Session::audio_path_from_name (string name, uint32_t nchan, uint32_t chan, bool */ for (cnt = (destructive ? ++destructive_index : 1); cnt <= limit; ++cnt) { - + vector::iterator i; uint32_t existing = 0; - + for (i = session_dirs.begin(); i != session_dirs.end(); ++i) { - + spath = (*i).path; - + if (destructive) { spath += tape_dir_name; } else { spath += sound_dir_name; } - + if (destructive) { if (nchan < 2) { snprintf (buf, sizeof(buf), "%s/T%04d-%s.wav", spath.c_str(), cnt, legalized.c_str()); @@ -3049,10 +3081,10 @@ Session::audio_path_from_name (string name, uint32_t nchan, uint32_t chan, bool snprintf (buf, sizeof(buf), "%s/T%04d-%s.wav", spath.c_str(), cnt, legalized.c_str()); } } else { - + spath += '/'; spath += legalized; - + if (nchan < 2) { snprintf (buf, sizeof(buf), "%s-%u.wav", spath.c_str(), cnt); } else if (nchan == 2) { @@ -3072,7 +3104,7 @@ Session::audio_path_from_name (string name, uint32_t nchan, uint32_t chan, bool existing++; } } - + if (existing == 0) { break; } diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index f5bf0cc173..8d11fd3b3f 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -1743,15 +1743,15 @@ Session::XMLRouteFactory (const XMLNode& node) bool has_diskstream = (node.property ("diskstream") != 0 || node.property ("diskstream-id") != 0); - DataType type = AUDIO; + DataType type = DataType::AUDIO; const XMLProperty* prop = node.property("default-type"); if (prop) - type = Buffer::type_from_string(prop->value()); + type = DataType(prop->value()); - assert(type != NIL); + assert(type != DataType::NIL); if (has_diskstream) { - if (type == AUDIO) { + if (type == DataType::AUDIO) { boost::shared_ptr ret (new AudioTrack (*this, node)); return ret; } else { -- cgit v1.2.3