Merged from trunk R743

git-svn-id: svn://localhost/ardour2/branches/midi@744 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
David Robillard 2006-08-02 00:22:16 +00:00
parent 0565c75ce8
commit e51e31dca2
35 changed files with 378 additions and 298 deletions

View file

@ -6,3 +6,6 @@ export LD_LIBRARY_PATH=../libs/surfaces/control_protocol:../libs/ardour:../libs/
# DYLD_LIBRARY_PATH is for darwin. # DYLD_LIBRARY_PATH is for darwin.
export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH
# LADSPA_PATH for OSX
export LADSPA_PATH=$LADSPA_PATH:/Library/Audio/Plug-Ins/LADSPA

View file

@ -126,7 +126,6 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], string rcfile)
auditioning_alert_button (_("AUDITION")), auditioning_alert_button (_("AUDITION")),
solo_alert_button (_("SOLO")), solo_alert_button (_("SOLO")),
shown_flag (false) shown_flag (false)
{ {
using namespace Gtk::Menu_Helpers; using namespace Gtk::Menu_Helpers;

View file

@ -268,11 +268,6 @@ ARDOUR_UI::install_actions ()
ActionManager::session_sensitive_actions.push_back (act); ActionManager::session_sensitive_actions.push_back (act);
ActionManager::transport_sensitive_actions.push_back (act); ActionManager::transport_sensitive_actions.push_back (act);
/* XXX the newline in the displayed names of these action is really wrong, but its because we want the button
that proxies for these action to be more compact. It would be nice to find a way to override the action
name appearance on the buttons.
*/
act = ActionManager::register_toggle_action (transport_actions, X_("TogglePunchIn"), _("Punch In"), mem_fun(*this, &ARDOUR_UI::toggle_punch_in)); act = ActionManager::register_toggle_action (transport_actions, X_("TogglePunchIn"), _("Punch In"), mem_fun(*this, &ARDOUR_UI::toggle_punch_in));
ActionManager::session_sensitive_actions.push_back (act); ActionManager::session_sensitive_actions.push_back (act);
ActionManager::transport_sensitive_actions.push_back (act); ActionManager::transport_sensitive_actions.push_back (act);

View file

@ -61,6 +61,7 @@ AudioStreamView::AudioStreamView (AudioTimeAxisView& tv)
else else
stream_base_color = color_map[cAudioBusBase]; stream_base_color = color_map[cAudioBusBase];
canvas_rect->property_fill_color_rgba() = stream_base_color;
canvas_rect->property_outline_color_rgba() = color_map[cAudioTrackOutline]; canvas_rect->property_outline_color_rgba() = color_map[cAudioTrackOutline];
_amplitude_above_axis = 1.0; _amplitude_above_axis = 1.0;
@ -679,12 +680,12 @@ AudioStreamView::color_handler (ColorID id, uint32_t val)
{ {
switch (id) { switch (id) {
case cAudioTrackBase: case cAudioTrackBase:
if (_trackview.is_audio_track()) { if (_trackview.is_track()) {
canvas_rect->property_fill_color_rgba() = val; canvas_rect->property_fill_color_rgba() = val;
} }
break; break;
case cAudioBusBase: case cAudioBusBase:
if (!_trackview.is_audio_track()) { if (!_trackview.is_track()) {
canvas_rect->property_fill_color_rgba() = val; canvas_rect->property_fill_color_rgba() = val;
} }
break; break;
@ -696,3 +697,4 @@ AudioStreamView::color_handler (ColorID id, uint32_t val)
break; break;
} }
} }

View file

@ -55,9 +55,9 @@ Editor::handle_new_route (boost::shared_ptr<Route> route)
// FIXME // FIXME
DataType type = route->default_type(); DataType type = route->default_type();
assert(type == ARDOUR::AUDIO || type == ARDOUR::MIDI); assert(type == ARDOUR::DataType::AUDIO || type == ARDOUR::DataType::MIDI);
if (type == ARDOUR::AUDIO) if (type == ARDOUR::DataType::AUDIO)
tv = new AudioTimeAxisView (*this, *session, route, track_canvas); tv = new AudioTimeAxisView (*this, *session, route, track_canvas);
else else
tv = new MidiTimeAxisView (*this, *session, route, track_canvas); tv = new MidiTimeAxisView (*this, *session, route, track_canvas);

View file

@ -234,11 +234,11 @@ FFTGraph::draw_scales(Glib::RefPtr<Gdk::Window> window)
while (_logScale[logscale_pos] < position_on_scale) while (_logScale[logscale_pos] < position_on_scale)
logscale_pos++; logscale_pos++;
int coord = v_margin + 1.0 + position_on_scale; int coord = (int)(v_margin + 1.0 + position_on_scale);
int SR = 44100; int SR = 44100;
int rate_at_pos = (double)(SR/2) * (double)logscale_pos / (double)_dataSize; int rate_at_pos = (int)((double)(SR/2) * (double)logscale_pos / (double)_dataSize);
char buf[32]; char buf[32];
snprintf(buf,32,"%dhz",rate_at_pos); snprintf(buf,32,"%dhz",rate_at_pos);

View file

@ -51,7 +51,7 @@ PluginSelector::PluginSelector (PluginManager *mgr)
o_selected_plug = -1; o_selected_plug = -1;
i_selected_plug = 0; i_selected_plug = 0;
current_selection = ARDOUR::PluginInfo::LADSPA; current_selection = PluginInfo::LADSPA;
lmodel = Gtk::ListStore::create(lcols); lmodel = Gtk::ListStore::create(lcols);
ladspa_display.set_model (lmodel); ladspa_display.set_model (lmodel);
@ -226,8 +226,8 @@ void
PluginSelector::input_refiller () PluginSelector::input_refiller ()
{ {
guint row; guint row;
list<PluginInfo *> &plugs = manager->ladspa_plugin_info (); PluginInfoList &plugs = manager->ladspa_plugin_info ();
list<PluginInfo *>::iterator i; PluginInfoList::iterator i;
char ibuf[16], obuf[16]; char ibuf[16], obuf[16];
lmodel->clear(); lmodel->clear();
@ -259,8 +259,8 @@ void
PluginSelector::vst_refiller () PluginSelector::vst_refiller ()
{ {
guint row; guint row;
list<PluginInfo *> &plugs = manager->vst_plugin_info (); PluginInfoList &plugs = manager->vst_plugin_info ();
list<PluginInfo *>::iterator i; PluginInfoList::iterator i;
char ibuf[16], obuf[16]; char ibuf[16], obuf[16];
vmodel->clear(); vmodel->clear();
@ -288,7 +288,7 @@ PluginSelector::vst_display_selection_changed()
btn_add->set_sensitive (false); btn_add->set_sensitive (false);
} }
current_selection = ARDOUR::PluginInfo::VST; current_selection = PluginInfo::VST;
} }
#endif //VST_SUPPORT #endif //VST_SUPPORT
@ -305,8 +305,8 @@ void
PluginSelector::au_refiller () PluginSelector::au_refiller ()
{ {
guint row; guint row;
list<PluginInfo *> &plugs = manager->au_plugin_info (); PluginInfoList &plugs = manager->au_plugin_info ();
list<PluginInfo *>::iterator i; PluginInfoList::iterator i;
char ibuf[16], obuf[16]; char ibuf[16], obuf[16];
aumodel->clear(); aumodel->clear();
@ -334,17 +334,15 @@ PluginSelector::au_display_selection_changed()
btn_add->set_sensitive (false); btn_add->set_sensitive (false);
} }
current_selection = ARDOUR::PluginInfo::AudioUnit; current_selection = PluginInfo::AudioUnit;
} }
#endif //HAVE_COREAUDIO #endif //HAVE_COREAUDIO
void void
PluginSelector::use_plugin (PluginInfo* pi) PluginSelector::use_plugin (PluginInfoPtr pi)
{ {
list<PluginInfo *>::iterator i; if (session == 0) {
if (pi == 0 || session == 0) {
return; return;
} }
@ -359,32 +357,29 @@ void
PluginSelector::btn_add_clicked() PluginSelector::btn_add_clicked()
{ {
std::string name; std::string name;
ARDOUR::PluginInfo *pi; PluginInfoPtr pi;
Gtk::TreeModel::Row newrow = *(amodel->append()); Gtk::TreeModel::Row newrow = *(amodel->append());
Gtk::TreeModel::Row row; Gtk::TreeModel::Row row;
switch (current_selection) { switch (current_selection) {
case ARDOUR::PluginInfo::LADSPA: case PluginInfo::LADSPA:
row = *(ladspa_display.get_selection()->get_selected()); row = *(ladspa_display.get_selection()->get_selected());
name = row[lcols.name]; name = row[lcols.name];
pi = row[lcols.plugin]; pi = row[lcols.plugin];
added_plugins.push_back (row[lcols.plugin]);
break; break;
case ARDOUR::PluginInfo::VST: case PluginInfo::VST:
#ifdef VST_SUPPORT #ifdef VST_SUPPORT
row = *(vst_display.get_selection()->get_selected()); row = *(vst_display.get_selection()->get_selected());
name = row[vcols.name]; name = row[vcols.name];
pi = row[vcols.plugin]; pi = row[vcols.plugin];
added_plugins.push_back (row[vcols.plugin]);
#endif #endif
break; break;
case ARDOUR::PluginInfo::AudioUnit: case PluginInfo::AudioUnit:
#ifdef HAVE_COREAUDIO #ifdef HAVE_COREAUDIO
row = *(au_display.get_selection()->get_selected()); row = *(au_display.get_selection()->get_selected());
name = row[aucols.name]; name = row[aucols.name];
pi = row[aucols.plugin]; pi = row[aucols.plugin];
added_plugins.push_back (row[aucols.plugin]);
#endif #endif
break; break;
default: default:
@ -403,17 +398,12 @@ PluginSelector::btn_add_clicked()
void void
PluginSelector::btn_remove_clicked() PluginSelector::btn_remove_clicked()
{ {
list<PluginInfo*>::iterator i;
Gtk::TreeModel::iterator iter = added_list.get_selection()->get_selected(); Gtk::TreeModel::iterator iter = added_list.get_selection()->get_selected();
for (i = added_plugins.begin(); (*i) != (*iter)[acols.plugin]; ++i);
added_plugins.erase(i);
amodel->erase(iter); amodel->erase(iter);
if (amodel->children().empty()) { if (amodel->children().empty()) {
set_response_sensitive (RESPONSE_APPLY, false); set_response_sensitive (RESPONSE_APPLY, false);
} }
} }
void void
@ -438,7 +428,7 @@ PluginSelector::ladspa_display_selection_changed()
btn_add->set_sensitive (false); btn_add->set_sensitive (false);
} }
current_selection = ARDOUR::PluginInfo::LADSPA; current_selection = PluginInfo::LADSPA;
} }
void void
@ -455,14 +445,14 @@ int
PluginSelector::run () PluginSelector::run ()
{ {
ResponseType r; ResponseType r;
list<PluginInfo*>::iterator i; TreeModel::Children::iterator i;
r = (ResponseType) Dialog::run (); r = (ResponseType) Dialog::run ();
switch (r) { switch (r) {
case RESPONSE_APPLY: case RESPONSE_APPLY:
for (i = added_plugins.begin(); i != added_plugins.end(); ++i){ for (i = amodel->children().begin(); i != amodel->children().end(); ++i) {
use_plugin (*i); use_plugin ((*i)[acols.plugin]);
} }
break; break;
@ -479,6 +469,5 @@ void
PluginSelector::cleanup () PluginSelector::cleanup ()
{ {
hide(); hide();
added_plugins.clear();
amodel->clear(); amodel->clear();
} }

View file

@ -66,7 +66,7 @@ class PluginSelector : public ArdourDialog
Gtk::TreeModelColumn<std::string> type; Gtk::TreeModelColumn<std::string> type;
Gtk::TreeModelColumn<std::string> ins; Gtk::TreeModelColumn<std::string> ins;
Gtk::TreeModelColumn<std::string> outs; Gtk::TreeModelColumn<std::string> outs;
Gtk::TreeModelColumn<ARDOUR::PluginInfo *> plugin; Gtk::TreeModelColumn<ARDOUR::PluginInfoPtr> plugin;
}; };
LadspaColumns lcols; LadspaColumns lcols;
Glib::RefPtr<Gtk::ListStore> lmodel; Glib::RefPtr<Gtk::ListStore> lmodel;
@ -81,7 +81,7 @@ class PluginSelector : public ArdourDialog
add (plugin); add (plugin);
} }
Gtk::TreeModelColumn<std::string> text; Gtk::TreeModelColumn<std::string> text;
Gtk::TreeModelColumn<ARDOUR::PluginInfo *> plugin; Gtk::TreeModelColumn<ARDOUR::PluginInfoPtr> plugin;
}; };
AddedColumns acols; AddedColumns acols;
Glib::RefPtr<Gtk::ListStore> amodel; Glib::RefPtr<Gtk::ListStore> amodel;
@ -100,7 +100,7 @@ class PluginSelector : public ArdourDialog
Gtk::TreeModelColumn<std::string> name; Gtk::TreeModelColumn<std::string> name;
Gtk::TreeModelColumn<std::string> ins; Gtk::TreeModelColumn<std::string> ins;
Gtk::TreeModelColumn<std::string> outs; Gtk::TreeModelColumn<std::string> outs;
Gtk::TreeModelColumn<ARDOUR::PluginInfo *> plugin; Gtk::TreeModelColumn<ARDOUR::PluginInfoPtr> plugin;
}; };
VstColumns vcols; VstColumns vcols;
Glib::RefPtr<Gtk::ListStore> vmodel; Glib::RefPtr<Gtk::ListStore> vmodel;
@ -123,7 +123,7 @@ class PluginSelector : public ArdourDialog
Gtk::TreeModelColumn<std::string> name; Gtk::TreeModelColumn<std::string> name;
Gtk::TreeModelColumn<std::string> ins; Gtk::TreeModelColumn<std::string> ins;
Gtk::TreeModelColumn<std::string> outs; Gtk::TreeModelColumn<std::string> outs;
Gtk::TreeModelColumn<ARDOUR::PluginInfo *> plugin; Gtk::TreeModelColumn<ARDOUR::PluginInfoPtr> plugin;
}; };
AUColumns aucols; AUColumns aucols;
Glib::RefPtr<Gtk::ListStore> aumodel; Glib::RefPtr<Gtk::ListStore> aumodel;
@ -141,7 +141,6 @@ class PluginSelector : public ArdourDialog
gint o_selected_plug; gint o_selected_plug;
ARDOUR::PluginManager *manager; ARDOUR::PluginManager *manager;
list<ARDOUR::PluginInfo*> added_plugins;
static void _input_refiller (void *); static void _input_refiller (void *);
@ -153,7 +152,7 @@ class PluginSelector : public ArdourDialog
void added_list_selection_changed(); void added_list_selection_changed();
void ladspa_display_selection_changed(); void ladspa_display_selection_changed();
void btn_apply_clicked(); void btn_apply_clicked();
void use_plugin (ARDOUR::PluginInfo*); void use_plugin (ARDOUR::PluginInfoPtr);
void cleanup (); void cleanup ();
}; };

View file

@ -48,25 +48,27 @@ using namespace Editing;
StreamView::StreamView (RouteTimeAxisView& tv) StreamView::StreamView (RouteTimeAxisView& tv)
: _trackview (tv) : _trackview (tv)
, canvas_group(new ArdourCanvas::Group(*_trackview.canvas_display))
, canvas_rect(new ArdourCanvas::SimpleRect (*canvas_group))
, _samples_per_unit(_trackview.editor.get_current_zoom())
, rec_updating(false)
, rec_active(false)
, use_rec_regions(tv.editor.show_waveforms_recording())
, region_color(_trackview.color())
, stream_base_color(0xFFFFFFFF)
{ {
region_color = _trackview.color();
/* set_position() will position the group */ /* set_position() will position the group */
canvas_group = new ArdourCanvas::Group(*_trackview.canvas_display);
canvas_rect = new ArdourCanvas::SimpleRect (*canvas_group); canvas_rect = new ArdourCanvas::SimpleRect (*canvas_group);
canvas_rect->property_x1() = 0.0; canvas_rect->property_x1() = 0.0;
canvas_rect->property_y1() = 0.0; canvas_rect->property_y1() = 0.0;
canvas_rect->property_x2() = 1000000.0; canvas_rect->property_x2() = 1000000.0;
canvas_rect->property_y2() = (double) tv.height; canvas_rect->property_y2() = (double) tv.height;
canvas_rect->property_outline_what() = (guint32) (0x1|0x2|0x8); // outline ends and bottom canvas_rect->property_outline_what() = (guint32) (0x1|0x2|0x8); // outline ends and bottom
canvas_rect->property_fill_color_rgba() = stream_base_color; // (Fill/Outline colours set in derived classes)
canvas_rect->signal_event().connect (bind (mem_fun (_trackview.editor, &PublicEditor::canvas_stream_view_event), canvas_rect, &_trackview)); canvas_rect->signal_event().connect (bind (mem_fun (_trackview.editor, &PublicEditor::canvas_stream_view_event), canvas_rect, &_trackview));
_samples_per_unit = _trackview.editor.get_current_zoom();
if (_trackview.is_track()) { if (_trackview.is_track()) {
_trackview.track()->DiskstreamChanged.connect (mem_fun (*this, &StreamView::diskstream_changed)); _trackview.track()->DiskstreamChanged.connect (mem_fun (*this, &StreamView::diskstream_changed));
_trackview.session().TransportStateChange.connect (mem_fun (*this, &StreamView::transport_changed)); _trackview.session().TransportStateChange.connect (mem_fun (*this, &StreamView::transport_changed));
@ -74,10 +76,6 @@ StreamView::StreamView (RouteTimeAxisView& tv)
_trackview.session().RecordStateChanged.connect (mem_fun (*this, &StreamView::sess_rec_enable_changed)); _trackview.session().RecordStateChanged.connect (mem_fun (*this, &StreamView::sess_rec_enable_changed));
} }
rec_updating = false;
rec_active = false;
use_rec_regions = tv.editor.show_waveforms_recording ();
ColorChanged.connect (mem_fun (*this, &StreamView::color_handler)); ColorChanged.connect (mem_fun (*this, &StreamView::color_handler));
} }
@ -285,13 +283,12 @@ StreamView::apply_color (Gdk::Color& color, ColorTarget target)
for (i = region_views.begin(); i != region_views.end(); ++i) { for (i = region_views.begin(); i != region_views.end(); ++i) {
(*i)->set_color (region_color); (*i)->set_color (region_color);
} }
// stream_base_color = RGBA_TO_UINT (color.red/256, color.green/256, color.blue/256, 255);
// gnome_canvas_item_set (canvas_rect, "fill_color_rgba", stream_base_color, NULL);
break; break;
case StreamBaseColor: case StreamBaseColor:
// stream_base_color = RGBA_TO_UINT (color.red/256, color.green/256, color.blue/256, 255); stream_base_color = RGBA_TO_UINT (
// gnome_canvas_item_set (canvas_rect, "fill_color_rgba", stream_base_color, NULL); color.get_red_p(), color.get_green_p(), color.get_blue_p(), 255);
canvas_rect->property_fill_color_rgba() = stream_base_color;
break; break;
} }
} }

View file

@ -139,9 +139,8 @@ protected:
bool rec_active; bool rec_active;
bool use_rec_regions; bool use_rec_regions;
/* XXX why are these different? */ Gdk::Color region_color; ///< Contained region color
Gdk::Color region_color; uint32_t stream_base_color; ///< Background color
uint32_t stream_base_color;
vector<sigc::connection> playlist_connections; vector<sigc::connection> playlist_connections;
sigc::connection playlist_change_connection; sigc::connection playlist_change_connection;

View file

@ -21,15 +21,41 @@
#ifndef __ardour_audio_unit_h__ #ifndef __ardour_audio_unit_h__
#define __ardour_audio_unit_h__ #define __ardour_audio_unit_h__
#include <list>
#include <ardour/plugin.h> #include <ardour/plugin.h>
#include <boost/shared_ptr.hpp>
struct ComponentDescription;
namespace ARDOUR { 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<ComponentDescription> CompDescPtr;
AUPluginInfo () { };
~AUPluginInfo () { };
CompDescPtr desc;
static PluginInfoList discover ();
private:
friend class PluginManager;
};
typedef boost::shared_ptr<AUPluginInfo> AUPluginInfoPtr;
} // namespace ARDOUR } // namespace ARDOUR
#endif // __ardour_audio_unit_h__ #endif // __ardour_audio_unit_h__

View file

@ -35,6 +35,7 @@
#include <jack/jack.h> #include <jack/jack.h>
#include <jack/transport.h> #include <jack/transport.h>
#include <ardour/types.h> #include <ardour/types.h>
#include <ardour/data_type.h>
namespace ARDOUR { namespace ARDOUR {

View file

@ -1,6 +1,5 @@
/* /*
Copyright (C) 2006 Paul Davis Copyright (C) 2006 Paul Davis
Written by Dave Robillard, 2006
This program is free software; you can redistribute it and/or modify it 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 under the terms of the GNU General Public License as published by the Free
@ -24,7 +23,7 @@
#include <cstdlib> // for posix_memalign #include <cstdlib> // for posix_memalign
#include <cassert> #include <cassert>
#include <ardour/types.h> #include <ardour/types.h>
#include <jack/jack.h> #include <ardour/data_type.h>
namespace ARDOUR { namespace ARDOUR {
@ -60,44 +59,7 @@ public:
/** Type of this buffer. /** Type of this buffer.
* Based on this you can static cast a Buffer* to the desired type. */ * Based on this you can static cast a Buffer* to the desired type. */
virtual DataType type() const { return _type; } 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;
}
protected: protected:
DataType _type; DataType _type;
@ -114,12 +76,12 @@ class AudioBuffer : public Buffer
{ {
public: public:
AudioBuffer(size_t capacity) AudioBuffer(size_t capacity)
: Buffer(AUDIO, capacity) : Buffer(DataType::AUDIO, capacity)
, _data(NULL) , _data(NULL)
{ {
_size = capacity; // For audio buffers, size = capacity (always) _size = capacity; // For audio buffers, size = capacity (always)
#ifdef NO_POSIX_MEMALIGN #ifdef NO_POSIX_MEMALIGN
b = (Sample *) malloc(sizeof(Sample) * capacity); _data = (Sample *) malloc(sizeof(Sample) * capacity);
#else #else
posix_memalign((void**)_data, 16, sizeof(Sample) * capacity); posix_memalign((void**)_data, 16, sizeof(Sample) * capacity);
#endif #endif
@ -135,7 +97,7 @@ private:
AudioBuffer(const AudioBuffer& copy); AudioBuffer(const AudioBuffer& copy);
AudioBuffer& operator=(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: public:
MidiBuffer(size_t capacity) MidiBuffer(size_t capacity)
: Buffer(MIDI, capacity) : Buffer(DataType::MIDI, capacity)
, _data(NULL) , _data(NULL)
{ {
_size = capacity; // For audio buffers, size = capacity (always)
#ifdef NO_POSIX_MEMALIGN #ifdef NO_POSIX_MEMALIGN
b = (Sample *) malloc(sizeof(RawMidi) * capacity); _data = (RawMidi *) malloc(sizeof(RawMidi) * capacity);
#else #else
posix_memalign((void**)_data, 16, sizeof(RawMidi) * capacity); posix_memalign((void**)_data, 16, sizeof(RawMidi) * capacity);
#endif #endif
assert(_data); assert(_data);
assert(_size == 0); memset(_data, 0, sizeof(RawMidi) * capacity);
memset(_data, 0, sizeof(Sample) * capacity);
} }
const RawMidi* data() const { return _data; } const RawMidi* data() const { return _data; }
@ -166,7 +128,7 @@ private:
MidiBuffer(const MidiBuffer& copy); MidiBuffer(const MidiBuffer& copy);
MidiBuffer& operator=(const MidiBuffer& copy); MidiBuffer& operator=(const MidiBuffer& copy);
RawMidi* const _data; ///< Actual buffer contents RawMidi* _data; ///< Actual buffer contents
}; };

View file

@ -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 <jack/jack.h>
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__

View file

@ -39,6 +39,7 @@
#include <ardour/state_manager.h> #include <ardour/state_manager.h>
#include <ardour/curve.h> #include <ardour/curve.h>
#include <ardour/types.h> #include <ardour/types.h>
#include <ardour/data_type.h>
using std::string; using std::string;
using std::vector; using std::vector;
@ -67,7 +68,7 @@ class IO : public Stateful, public ARDOUR::StateManager
IO (Session&, string name, IO (Session&, string name,
int input_min = -1, int input_max = -1, int input_min = -1, int input_max = -1,
int output_min = -1, int output_max = -1, int output_min = -1, int output_max = -1,
DataType default_type = AUDIO); DataType default_type = DataType::AUDIO);
virtual ~IO(); virtual ~IO();
@ -116,8 +117,8 @@ class IO : public Stateful, public ARDOUR::StateManager
Connection *input_connection() const { return _input_connection; } Connection *input_connection() const { return _input_connection; }
Connection *output_connection() const { return _output_connection; } Connection *output_connection() const { return _output_connection; }
int add_input_port (string source, 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 = NIL); int add_output_port (string destination, void *src, DataType type = DataType::NIL);
int remove_input_port (Port *, void *src); int remove_input_port (Port *, void *src);
int remove_output_port (Port *, void *src); int remove_output_port (Port *, void *src);

View file

@ -73,6 +73,9 @@ class PluginInfo {
uint32_t index; uint32_t index;
}; };
typedef boost::shared_ptr<PluginInfo> PluginInfoPtr;
typedef std::list<PluginInfoPtr> PluginInfoList;
class Plugin : public Stateful, public sigc::trackable class Plugin : public Stateful, public sigc::trackable
{ {

View file

@ -8,6 +8,8 @@
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <ardour/types.h> #include <ardour/types.h>
#include <ardour/plugin.h>
#include <ardour/audio_unit.h>
namespace ARDOUR { namespace ARDOUR {
@ -21,24 +23,24 @@ class PluginManager {
PluginManager (ARDOUR::AudioEngine&); PluginManager (ARDOUR::AudioEngine&);
~PluginManager (); ~PluginManager ();
std::list<PluginInfo*> &vst_plugin_info () { return _vst_plugin_info; } ARDOUR::PluginInfoList &vst_plugin_info () { return _vst_plugin_info; }
std::list<PluginInfo*> &ladspa_plugin_info () { return _ladspa_plugin_info; } ARDOUR::PluginInfoList &ladspa_plugin_info () { return _ladspa_plugin_info; }
std::list<PluginInfo*> &au_plugin_info () { return _au_plugin_info; } ARDOUR::PluginInfoList &au_plugin_info () { return _au_plugin_info; }
void refresh (); void refresh ();
int add_ladspa_directory (std::string dirpath); int add_ladspa_directory (std::string dirpath);
int add_vst_directory (std::string dirpath); int add_vst_directory (std::string dirpath);
boost::shared_ptr<Plugin> load (ARDOUR::Session& s, PluginInfo* info); boost::shared_ptr<Plugin> load (ARDOUR::Session& s, PluginInfoPtr info);
static PluginManager* the_manager() { return _manager; } static PluginManager* the_manager() { return _manager; }
private: private:
ARDOUR::AudioEngine& _engine; ARDOUR::AudioEngine& _engine;
std::list<PluginInfo*> _vst_plugin_info; ARDOUR::PluginInfoList _vst_plugin_info;
std::list<PluginInfo*> _ladspa_plugin_info; ARDOUR::PluginInfoList _ladspa_plugin_info;
std::list<PluginInfo*> _au_plugin_info; ARDOUR::PluginInfoList _au_plugin_info;
std::map<uint32_t, std::string> rdf_type; std::map<uint32_t, std::string> rdf_type;
std::string ladspa_path; std::string ladspa_path;

View file

@ -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, 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&); Route (Session&, const XMLNode&);
virtual ~Route(); virtual ~Route();

View file

@ -31,7 +31,7 @@ class RouteGroup;
class Track : public Route class Track : public Route
{ {
public: 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 (); virtual ~Track ();
@ -91,7 +91,7 @@ class Track : public Route
sigc::signal<void> FreezeChange; sigc::signal<void> FreezeChange;
protected: 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; virtual XMLNode& state (bool full) = 0;

View file

@ -245,12 +245,6 @@ namespace ARDOUR {
PeakDatum min; PeakDatum min;
PeakDatum max; PeakDatum max;
}; };
enum DataType {
NIL = 0,
AUDIO,
MIDI
};
} }
std::istream& operator>>(std::istream& o, ARDOUR::SampleFormat& sf); std::istream& operator>>(std::istream& o, ARDOUR::SampleFormat& sf);

View file

@ -17,3 +17,96 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <ardour/audio_unit.h>
#include <ardour/utils.h>
#include <CoreServices/CoreServices.h>
#include <AudioUnit/AudioUnit.h>
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<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);
}
}
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;
}

View file

@ -401,7 +401,7 @@ AudioEngine::register_input_port (DataType type, const string& portname)
} }
jack_port_t *p = jack_port_register (_jack, portname.c_str(), 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) { if (p) {
@ -435,7 +435,7 @@ AudioEngine::register_output_port (DataType type, const string& portname)
jack_port_t *p; jack_port_t *p;
if ((p = jack_port_register (_jack, portname.c_str(), 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); Port *newport = new Port (p);
ports.insert (ports.begin(), newport); ports.insert (ports.begin(), newport);
return newport; return newport;

View file

@ -618,6 +618,12 @@ AudioFileSource::set_name (string newname, bool destructive)
return -1; 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) { if (rename (oldpath.c_str(), newpath.c_str()) != 0) {
error << string_compose (_("cannot rename audio file for %1 to %2"), _name, newpath) << endmsg; error << string_compose (_("cannot rename audio file for %1 to %2"), _name, newpath) << endmsg;
return -1; return -1;

View file

@ -644,7 +644,7 @@ AudioRegion::state (bool full)
snprintf (buf, sizeof (buf), "0x%x", (int) _flags); snprintf (buf, sizeof (buf), "0x%x", (int) _flags);
node.add_property ("flags", buf); 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); node.add_property ("scale-gain", buf);
for (uint32_t n=0; n < sources.size(); ++n) { for (uint32_t n=0; n < sources.size(); ++n) {
@ -1258,7 +1258,7 @@ AudioRegion::set_scale_amplitude (gain_t g)
void void
AudioRegion::normalize_to (float target_dB) AudioRegion::normalize_to (float target_dB)
{ {
const jack_nframes_t blocksize = 256 * 1048; const jack_nframes_t blocksize = 64 * 1024;
Sample buf[blocksize]; Sample buf[blocksize];
char workbuf[blocksize * 4]; char workbuf[blocksize * 4];
jack_nframes_t fpos; jack_nframes_t fpos;

View file

@ -27,6 +27,7 @@
#include <ardour/auditioner.h> #include <ardour/auditioner.h>
#include <ardour/audioplaylist.h> #include <ardour/audioplaylist.h>
#include <ardour/panner.h> #include <ardour/panner.h>
#include <ardour/data_type.h>
using namespace std; using namespace std;
using namespace ARDOUR; using namespace ARDOUR;
@ -44,12 +45,12 @@ Auditioner::Auditioner (Session& s)
defer_pan_reset (); defer_pan_reset ();
if (left.length()) { if (left.length()) {
add_output_port (left, this, AUDIO); add_output_port (left, this, DataType::AUDIO);
} }
if (right.length()) { if (right.length()) {
audio_diskstream().add_channel(); audio_diskstream().add_channel();
add_output_port (right, this, AUDIO); add_output_port (right, this, DataType::AUDIO);
} }
allow_pan_reset (); allow_pan_reset ();

View file

@ -1211,7 +1211,7 @@ AutomationList::store_state (XMLNode& node) const
snprintf (buf, sizeof (buf), "%" PRIu32, (jack_nframes_t) floor ((*i)->when)); snprintf (buf, sizeof (buf), "%" PRIu32, (jack_nframes_t) floor ((*i)->when));
pointnode->add_property ("x", buf); pointnode->add_property ("x", buf);
snprintf (buf, sizeof (buf), "%f", (*i)->value); snprintf (buf, sizeof (buf), "%.12g", (*i)->value);
pointnode->add_property ("y", buf); pointnode->add_property ("y", buf);
node.add_child_nocopy (*pointnode); node.add_child_nocopy (*pointnode);

View file

@ -702,7 +702,7 @@ Crossfade::get_state ()
snprintf (buf, sizeof (buf), "%" PRIu32, (jack_nframes_t) floor ((*ii)->when)); snprintf (buf, sizeof (buf), "%" PRIu32, (jack_nframes_t) floor ((*ii)->when));
pnode->add_property ("x", buf); pnode->add_property ("x", buf);
snprintf (buf, sizeof (buf), "%f", (*ii)->value); snprintf (buf, sizeof (buf), "%.12g", (*ii)->value);
pnode->add_property ("y", buf); pnode->add_property ("y", buf);
child->add_child_nocopy (*pnode); child->add_child_nocopy (*pnode);
} }
@ -716,7 +716,7 @@ Crossfade::get_state ()
snprintf (buf, sizeof (buf), "%" PRIu32, (jack_nframes_t) floor ((*ii)->when)); snprintf (buf, sizeof (buf), "%" PRIu32, (jack_nframes_t) floor ((*ii)->when));
pnode->add_property ("x", buf); pnode->add_property ("x", buf);
snprintf (buf, sizeof (buf), "%f", (*ii)->value); snprintf (buf, sizeof (buf), "%.12g", (*ii)->value);
pnode->add_property ("y", buf); pnode->add_property ("y", buf);
child->add_child_nocopy (*pnode); child->add_child_nocopy (*pnode);
} }

View file

@ -797,7 +797,7 @@ IO::add_output_port (string destination, void* src, DataType type)
Port* our_port; Port* our_port;
char name[64]; char name[64];
if (type == NIL) if (type == DataType::NIL)
type = _default_type; type = _default_type;
{ {
@ -909,7 +909,7 @@ IO::add_input_port (string source, void* src, DataType type)
Port* our_port; Port* our_port;
char name[64]; char name[64];
if (type == NIL) if (type == DataType::NIL)
type = _default_type; type = _default_type;
{ {

View file

@ -40,7 +40,7 @@ using namespace ARDOUR;
using namespace PBD; using namespace PBD;
MidiTrack::MidiTrack (Session& sess, string name, Route::Flag flag, TrackMode mode) 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); MidiDiskstream::Flag dflags = MidiDiskstream::Flag (0);

View file

@ -22,6 +22,7 @@
#include <ardour/types.h> #include <ardour/types.h>
#include <ardour/utils.h> #include <ardour/utils.h>
#include <ardour/mix.h> #include <ardour/mix.h>
#include <stdint.h>
#if defined (ARCH_X86) && defined (BUILD_SSE_OPTIMIZATIONS) #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 float
veclib_compute_peak (ARDOUR::Sample *buf, jack_nframes_t nsamples, float current) veclib_compute_peak (ARDOUR::Sample *buf, jack_nframes_t nsamples, float current)
{ {
vDSP_maxv(buf, 1, &current, nsamples); float tmpmax = 0.0f;
return current; vDSP_maxmgv(buf, 1, &tmpmax, nsamples);
return f_max(current, tmpmax);
} }
void void

View file

@ -529,7 +529,7 @@ EqualPowerStereoPanner::state (bool full_state)
char buf[64]; char buf[64];
LocaleGuard lg (X_("POSIX")); 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_("x"), buf);
root->add_property (X_("type"), EqualPowerStereoPanner::name); root->add_property (X_("type"), EqualPowerStereoPanner::name);
if (full_state) { if (full_state) {
@ -763,9 +763,9 @@ Multi2dPanner::state (bool full_state)
char buf[64]; char buf[64];
LocaleGuard lg (X_("POSIX")); 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_("x"), buf);
snprintf (buf, sizeof (buf), "%f", y); snprintf (buf, sizeof (buf), "%.12g", y);
root->add_property (X_("y"), buf); root->add_property (X_("y"), buf);
root->add_property (X_("type"), Multi2dPanner::name); root->add_property (X_("type"), Multi2dPanner::name);
@ -1207,9 +1207,9 @@ Panner::state (bool full)
for (vector<Panner::Output>::iterator o = outputs.begin(); o != outputs.end(); ++o) { for (vector<Panner::Output>::iterator o = outputs.begin(); o != outputs.end(); ++o) {
XMLNode* onode = new XMLNode (X_("Output")); 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); 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); onode->add_property (X_("y"), buf);
root->add_child_nocopy (*onode); root->add_child_nocopy (*onode);
} }
@ -1258,10 +1258,10 @@ Panner::set_state (const XMLNode& node)
float x, y; float x, y;
prop = (*niter)->property (X_("x")); prop = (*niter)->property (X_("x"));
sscanf (prop->value().c_str(), "%f", &x); sscanf (prop->value().c_str(), "%.12g", &x);
prop = (*niter)->property (X_("y")); 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)); outputs.push_back (Output (x, y));
} }

View file

@ -37,15 +37,11 @@
#include <ardour/plugin.h> #include <ardour/plugin.h>
#include <ardour/ladspa_plugin.h> #include <ardour/ladspa_plugin.h>
#include <ardour/vst_plugin.h> #include <ardour/vst_plugin.h>
#include <ardour/audio_unit.h>
#include <pbd/error.h> #include <pbd/error.h>
#include <pbd/stl_delete.h> #include <pbd/stl_delete.h>
#ifdef HAVE_COREAUDIO
#include <CoreServices/CoreServices.h>
#include <AudioUnit/AudioUnit.h>
#endif // HAVE_COREAUDIO
#include "i18n.h" #include "i18n.h"
using namespace ARDOUR; using namespace ARDOUR;
@ -103,17 +99,13 @@ PluginManager::refresh ()
#endif // VST_SUPPORT #endif // VST_SUPPORT
#ifdef HAVE_COREAUDIO #ifdef HAVE_COREAUDIO
au_discover (); _au_plugin_info = AUPluginInfo::discover ();
#endif // HAVE_COREAUDIO #endif // HAVE_COREAUDIO
} }
void void
PluginManager::ladspa_refresh () PluginManager::ladspa_refresh ()
{ {
for (std::list<PluginInfo*>::iterator i = _ladspa_plugin_info.begin(); i != _ladspa_plugin_info.end(); ++i) {
delete *i;
}
_ladspa_plugin_info.clear (); _ladspa_plugin_info.clear ();
if (ladspa_path.length() == 0) { if (ladspa_path.length() == 0) {
@ -234,7 +226,6 @@ PluginManager::add_lrdf_data (const string &path)
int int
PluginManager::ladspa_discover (string path) PluginManager::ladspa_discover (string path)
{ {
PluginInfo *info;
void *module; void *module;
const LADSPA_Descriptor *descriptor; const LADSPA_Descriptor *descriptor;
LADSPA_Descriptor_Function dfunc; LADSPA_Descriptor_Function dfunc;
@ -259,7 +250,7 @@ PluginManager::ladspa_discover (string path)
break; break;
} }
info = new PluginInfo; PluginInfoPtr info(new PluginInfo);
info->name = descriptor->Name; info->name = descriptor->Name;
info->category = get_ladspa_category(descriptor->UniqueID); info->category = get_ladspa_category(descriptor->UniqueID);
info->path = path; info->path = path;
@ -290,7 +281,7 @@ PluginManager::ladspa_discover (string path)
} }
boost::shared_ptr<Plugin> boost::shared_ptr<Plugin>
PluginManager::load (Session& session, PluginInfo *info) PluginManager::load (Session& session, PluginInfoPtr info)
{ {
void *module; void *module;
@ -339,8 +330,7 @@ boost::shared_ptr<Plugin>
ARDOUR::find_plugin(Session& session, string name, long unique_id, PluginInfo::Type type) ARDOUR::find_plugin(Session& session, string name, long unique_id, PluginInfo::Type type)
{ {
PluginManager *mgr = PluginManager::the_manager(); PluginManager *mgr = PluginManager::the_manager();
list<PluginInfo *>::iterator i; PluginInfoList* plugs = 0;
list<PluginInfo *>* plugs = 0;
switch (type) { switch (type) {
case PluginInfo::LADSPA: case PluginInfo::LADSPA:
@ -358,6 +348,7 @@ ARDOUR::find_plugin(Session& session, string name, long unique_id, PluginInfo::T
return boost::shared_ptr<Plugin> ((Plugin *) 0); return boost::shared_ptr<Plugin> ((Plugin *) 0);
} }
PluginInfoList::iterator i;
for (i = plugs->begin(); i != plugs->end(); ++i) { 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)) { (unique_id == 0 || (*i)->unique_id == unique_id)) {
@ -409,10 +400,6 @@ PluginManager::get_ladspa_category (uint32_t plugin_id)
void void
PluginManager::vst_refresh () PluginManager::vst_refresh ()
{ {
for (std::list<PluginInfo*>::iterator i = _vst_plugin_info.begin(); i != _vst_plugin_info.end(); ++i) {
delete *i;
}
_vst_plugin_info.clear (); _vst_plugin_info.clear ();
if (vst_path.length() == 0) { if (vst_path.length() == 0) {
@ -466,7 +453,6 @@ int
PluginManager::vst_discover (string path) PluginManager::vst_discover (string path)
{ {
FSTInfo* finfo; FSTInfo* finfo;
PluginInfo* info;
if ((finfo = fst_get_info (const_cast<char *> (path.c_str()))) == 0) { if ((finfo = fst_get_info (const_cast<char *> (path.c_str()))) == 0) {
return -1; return -1;
@ -478,7 +464,7 @@ PluginManager::vst_discover (string path)
<< endl; << endl;
} }
info = new PluginInfo; PluginInfoPtr info(new PluginInfo);
/* what a goddam joke freeware VST is */ /* what a goddam joke freeware VST is */
@ -502,94 +488,3 @@ PluginManager::vst_discover (string path)
} }
#endif // VST_SUPPORT #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

View file

@ -1333,7 +1333,7 @@ Route::state(bool full_state)
node->add_property("flags", buf); 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("active", _active?"yes":"no");
node->add_property("muted", _muted?"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) { if ((prop = node.property ("default-type")) != 0) {
_default_type = Buffer::type_from_string(prop->value()); _default_type = DataType(prop->value());
assert(_default_type != NIL); assert(_default_type != DataType::NIL);
} }
if ((prop = node.property ("phase-invert")) != 0) { if ((prop = node.property ("phase-invert")) != 0) {

View file

@ -69,6 +69,7 @@
#include <ardour/crossfade.h> #include <ardour/crossfade.h>
#include <ardour/playlist.h> #include <ardour/playlist.h>
#include <ardour/click.h> #include <ardour/click.h>
#include <ardour/data_type.h>
#ifdef HAVE_LIBLO #ifdef HAVE_LIBLO
#include <ardour/osc.h> #include <ardour/osc.h>
@ -728,7 +729,7 @@ Session::when_engine_running ()
_master_out->defer_pan_reset (); _master_out->defer_pan_reset ();
while ((int) _master_out->n_inputs() < _master_out->input_maximum()) { 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") error << _("cannot setup master inputs")
<< endmsg; << endmsg;
break; break;
@ -736,7 +737,7 @@ Session::when_engine_running ()
} }
n = 0; n = 0;
while ((int) _master_out->n_outputs() < _master_out->output_maximum()) { 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") error << _("cannot setup master outputs")
<< endmsg; << endmsg;
break; break;
@ -1808,7 +1809,7 @@ Session::new_midi_route ()
} while (n < (UINT_MAX-1)); } while (n < (UINT_MAX-1));
try { try {
shared_ptr<Route> bus (new Route (*this, bus_name, -1, -1, -1, -1, Route::Flag(0), MIDI)); shared_ptr<Route> bus (new Route (*this, bus_name, -1, -1, -1, -1, Route::Flag(0), DataType::MIDI));
if (bus->ensure_io (1, 1, false, this)) { if (bus->ensure_io (1, 1, false, this)) {
error << (_("cannot configure 1 in/1 out configuration for new midi track")) 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)); } while (n < (UINT_MAX-1));
try { try {
shared_ptr<Route> bus (new Route (*this, bus_name, -1, -1, -1, -1, Route::Flag(0), AUDIO)); shared_ptr<Route> 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)) { if (bus->ensure_io (input_channels, output_channels, false, this)) {
error << string_compose (_("cannot configure %1 in/%2 out configuration for new audio track"), 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. the task here is to replace NAME with the new name.
*/ */
/* find last slash */
string dir; string dir;
string suffix; string suffix;
string::size_type slash; string::size_type slash;
string::size_type dash; string::size_type dash;
string::size_type postfix;
/* find last slash */
if ((slash = path.find_last_of ('/')) == string::npos) { if ((slash = path.find_last_of ('/')) == string::npos) {
return ""; return "";
@ -2993,11 +2995,41 @@ Session::change_audio_path_by_name (string path, string oldname, string newname,
return ""; 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; return path;

View file

@ -1743,15 +1743,15 @@ Session::XMLRouteFactory (const XMLNode& node)
bool has_diskstream = (node.property ("diskstream") != 0 || node.property ("diskstream-id") != 0); 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"); const XMLProperty* prop = node.property("default-type");
if (prop) if (prop)
type = Buffer::type_from_string(prop->value()); type = DataType(prop->value());
assert(type != NIL); assert(type != DataType::NIL);
if (has_diskstream) { if (has_diskstream) {
if (type == AUDIO) { if (type == DataType::AUDIO) {
boost::shared_ptr<Route> ret (new AudioTrack (*this, node)); boost::shared_ptr<Route> ret (new AudioTrack (*this, node));
return ret; return ret;
} else { } else {