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.
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")),
solo_alert_button (_("SOLO")),
shown_flag (false)
{
using namespace Gtk::Menu_Helpers;

View file

@ -268,11 +268,6 @@ ARDOUR_UI::install_actions ()
ActionManager::session_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));
ActionManager::session_sensitive_actions.push_back (act);
ActionManager::transport_sensitive_actions.push_back (act);

View file

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

View file

@ -55,9 +55,9 @@ Editor::handle_new_route (boost::shared_ptr<Route> route)
// FIXME
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);
else
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)
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 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];
snprintf(buf,32,"%dhz",rate_at_pos);

View file

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

View file

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

View file

@ -48,25 +48,27 @@ using namespace Editing;
StreamView::StreamView (RouteTimeAxisView& 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 */
canvas_group = new ArdourCanvas::Group(*_trackview.canvas_display);
canvas_rect = new ArdourCanvas::SimpleRect (*canvas_group);
canvas_rect->property_x1() = 0.0;
canvas_rect->property_y1() = 0.0;
canvas_rect->property_x2() = 1000000.0;
canvas_rect->property_y2() = (double) tv.height;
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));
_samples_per_unit = _trackview.editor.get_current_zoom();
if (_trackview.is_track()) {
_trackview.track()->DiskstreamChanged.connect (mem_fun (*this, &StreamView::diskstream_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));
}
rec_updating = false;
rec_active = false;
use_rec_regions = tv.editor.show_waveforms_recording ();
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) {
(*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;
case StreamBaseColor:
// 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);
stream_base_color = RGBA_TO_UINT (
color.get_red_p(), color.get_green_p(), color.get_blue_p(), 255);
canvas_rect->property_fill_color_rgba() = stream_base_color;
break;
}
}

View file

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

View file

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

View file

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

View file

@ -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 <cstdlib> // for posix_memalign
#include <cassert>
#include <ardour/types.h>
#include <jack/jack.h>
#include <ardour/data_type.h>
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
};

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/curve.h>
#include <ardour/types.h>
#include <ardour/data_type.h>
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);

View file

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

View file

@ -8,6 +8,8 @@
#include <boost/shared_ptr.hpp>
#include <ardour/types.h>
#include <ardour/plugin.h>
#include <ardour/audio_unit.h>
namespace ARDOUR {
@ -21,24 +23,24 @@ class PluginManager {
PluginManager (ARDOUR::AudioEngine&);
~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; }
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<Plugin> load (ARDOUR::Session& s, PluginInfo* info);
boost::shared_ptr<Plugin> load (ARDOUR::Session& s, PluginInfoPtr info);
static PluginManager* the_manager() { return _manager; }
private:
ARDOUR::AudioEngine& _engine;
std::list<PluginInfo*> _vst_plugin_info;
std::list<PluginInfo*> _ladspa_plugin_info;
std::list<PluginInfo*> _au_plugin_info;
ARDOUR::PluginInfoList _vst_plugin_info;
ARDOUR::PluginInfoList _ladspa_plugin_info;
ARDOUR::PluginInfoList _au_plugin_info;
std::map<uint32_t, std::string> rdf_type;
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,
Flag flags = Flag(0), DataType default_type = AUDIO);
Flag flags = Flag(0), DataType default_type = DataType::AUDIO);
Route (Session&, const XMLNode&);
virtual ~Route();

View file

@ -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<void> 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;

View file

@ -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);

View file

@ -17,3 +17,96 @@
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(),
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;

View file

@ -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;

View file

@ -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;

View file

@ -27,6 +27,7 @@
#include <ardour/auditioner.h>
#include <ardour/audioplaylist.h>
#include <ardour/panner.h>
#include <ardour/data_type.h>
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 ();

View file

@ -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);

View file

@ -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);
}

View file

@ -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;
{

View file

@ -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);

View file

@ -22,6 +22,7 @@
#include <ardour/types.h>
#include <ardour/utils.h>
#include <ardour/mix.h>
#include <stdint.h>
#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, &current, nsamples);
return current;
float tmpmax = 0.0f;
vDSP_maxmgv(buf, 1, &tmpmax, nsamples);
return f_max(current, tmpmax);
}
void

View file

@ -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<Panner::Output>::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));
}

View file

@ -37,15 +37,11 @@
#include <ardour/plugin.h>
#include <ardour/ladspa_plugin.h>
#include <ardour/vst_plugin.h>
#include <ardour/audio_unit.h>
#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;
@ -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<PluginInfo*>::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<Plugin>
PluginManager::load (Session& session, PluginInfo *info)
PluginManager::load (Session& session, PluginInfoPtr info)
{
void *module;
@ -339,8 +330,7 @@ boost::shared_ptr<Plugin>
ARDOUR::find_plugin(Session& session, string name, long unique_id, PluginInfo::Type type)
{
PluginManager *mgr = PluginManager::the_manager();
list<PluginInfo *>::iterator i;
list<PluginInfo *>* 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> ((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<PluginInfo*>::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<char *> (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<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("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) {

View file

@ -69,6 +69,7 @@
#include <ardour/crossfade.h>
#include <ardour/playlist.h>
#include <ardour/click.h>
#include <ardour/data_type.h>
#ifdef HAVE_LIBLO
#include <ardour/osc.h>
@ -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<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)) {
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<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)) {
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<space_and_path>::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;
}

View file

@ -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<Route> ret (new AudioTrack (*this, node));
return ret;
} else {