diff options
Diffstat (limited to 'libs')
41 files changed, 240 insertions, 639 deletions
diff --git a/libs/ardour/ardour/ardour.h b/libs/ardour/ardour/ardour.h index 7358a7bddb..630bde675c 100644 --- a/libs/ardour/ardour/ardour.h +++ b/libs/ardour/ardour/ardour.h @@ -29,7 +29,6 @@ #include "pbd/error.h" #include "pbd/failed_constructor.h" -#include "ardour/configuration.h" #include "ardour/types.h" // #include <jack/jack.h> need this to inline jack_get_microseconds diff --git a/libs/ardour/ardour/audio_diskstream.h b/libs/ardour/ardour/audio_diskstream.h index be95d737fb..187c97b3e6 100644 --- a/libs/ardour/ardour/audio_diskstream.h +++ b/libs/ardour/ardour/audio_diskstream.h @@ -35,7 +35,6 @@ #include "pbd/rcu.h" #include "ardour/ardour.h" -#include "ardour/configuration.h" #include "ardour/utils.h" #include "ardour/diskstream.h" #include "ardour/audioplaylist.h" diff --git a/libs/ardour/ardour/broadcast_info.h b/libs/ardour/ardour/broadcast_info.h index 8dfb697d08..39ea96c590 100644 --- a/libs/ardour/ardour/broadcast_info.h +++ b/libs/ardour/ardour/broadcast_info.h @@ -68,7 +68,7 @@ class BroadcastInfo void set_time_reference (int64_t when); void set_origination_time (struct tm * now = 0); // if 0, use time generated at construction void set_originator (std::string const & str = ""); - void set_originator_ref (std::string const & str = ""); + void set_originator_ref (Session const &, std::string const & str = ""); /* State info */ diff --git a/libs/ardour/ardour/configuration.h b/libs/ardour/ardour/configuration.h index e8d2685aa1..68944e92e6 100644 --- a/libs/ardour/ardour/configuration.h +++ b/libs/ardour/ardour/configuration.h @@ -1,5 +1,5 @@ /* - Copyright (C) 1999 Paul Davis + Copyright (C) 2009 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 @@ -20,16 +20,7 @@ #ifndef __ardour_configuration_h__ #define __ardour_configuration_h__ -#include <map> -#include <vector> - -#include <sys/types.h> -#include <string> - -#include "pbd/stateful.h" - -#include "ardour/types.h" -#include "ardour/utils.h" +#include "pbd/stateful.h" #include "ardour/configuration_variable.h" class XMLNode; @@ -42,65 +33,15 @@ class Configuration : public PBD::Stateful Configuration(); virtual ~Configuration(); - std::map<std::string,XMLNode> midi_ports; - - void map_parameters (sigc::slot<void,const char*> theSlot); - - int load_state (); - int save_state (); - - /// calls Stateful::*instant_xml methods using - /// ARDOUR::user_config_directory for the directory argument - void add_instant_xml (XMLNode&); - XMLNode * instant_xml (const std::string& str); - - int set_state (const XMLNode&); - XMLNode& get_state (void); - XMLNode& get_variables (sigc::slot<bool,ConfigVariableBase::Owner>, std::string which_node = "Config"); - void set_variables (const XMLNode&, ConfigVariableBase::Owner owner); - - void set_current_owner (ConfigVariableBase::Owner); - - XMLNode* control_protocol_state () { return _control_protocol_state; } + virtual void map_parameters (sigc::slot<void, const char *> s) = 0; + virtual int set_state (XMLNode const &) = 0; + virtual XMLNode & get_state () = 0; + virtual XMLNode & get_variables () = 0; + virtual void set_variables (XMLNode const &) = 0; sigc::signal<void,const char*> ParameterChanged; - - /* define accessor methods */ - -#undef CONFIG_VARIABLE -#undef CONFIG_VARIABLE_SPECIAL -#define CONFIG_VARIABLE(Type,var,name,value) \ - Type get_##var () const { return var.get(); } \ - bool set_##var (Type val) { bool ret = var.set (val, current_owner); if (ret) { ParameterChanged (name); } return ret; } -#define CONFIG_VARIABLE_SPECIAL(Type,var,name,value,mutator) \ - Type get_##var () const { return var.get(); } \ - bool set_##var (Type val) { bool ret = var.set (val, current_owner); if (ret) { ParameterChanged (name); } return ret; } -#include "ardour/configuration_vars.h" -#undef CONFIG_VARIABLE -#undef CONFIG_VARIABLE_SPECIAL - - private: - - /* declare variables */ - -#undef CONFIG_VARIABLE -#undef CONFIG_VARIABLE_SPECIAL -#define CONFIG_VARIABLE(Type,var,name,value) ConfigVariable<Type> var; -#define CONFIG_VARIABLE_SPECIAL(Type,var,name,value,mutator) ConfigVariableWithMutation<Type> var; -#include "ardour/configuration_vars.h" -#undef CONFIG_VARIABLE -#undef CONFIG_VARIABLE_SPECIAL - - ConfigVariableBase::Owner current_owner; - XMLNode* _control_protocol_state; - - XMLNode& state (sigc::slot<bool,ConfigVariableBase::Owner>); - bool save_config_options_predicate (ConfigVariableBase::Owner owner); }; -extern Configuration *Config; -extern gain_t speed_quietning; /* see comment in configuration.cc */ - } // namespace ARDOUR #endif /* __ardour_configuration_h__ */ diff --git a/libs/ardour/ardour/configuration_variable.h b/libs/ardour/ardour/configuration_variable.h index 57db525017..6282da2c54 100644 --- a/libs/ardour/ardour/configuration_variable.h +++ b/libs/ardour/ardour/configuration_variable.h @@ -30,29 +30,23 @@ namespace ARDOUR { class ConfigVariableBase { public: - enum Owner { - Default = 0x1, - System = 0x2, - Config = 0x4, - Session = 0x8, - Interface = 0x10 - }; - - ConfigVariableBase (std::string str) : _name (str), _owner (Default) {} - virtual ~ConfigVariableBase() {} - std::string name() const { return _name; } - Owner owner() const { return _owner; } + ConfigVariableBase (std::string str) : _name (str) {} + virtual ~ConfigVariableBase() {} - virtual void add_to_node (XMLNode& node) = 0; - virtual bool set_from_node (const XMLNode& node, Owner owner) = 0; + std::string name () const { return _name; } + void add_to_node (XMLNode&); + bool set_from_node (XMLNode const &); + + virtual std::string get_as_string () const = 0; + virtual void set_from_string (std::string const &) = 0; void show_stored_value (const std::string&); - static void set_show_stored_values (bool yn); + + static void set_show_stored_values (bool); protected: std::string _name; - Owner _owner; static bool show_stores; void notify (); @@ -63,94 +57,34 @@ template<class T> class ConfigVariable : public ConfigVariableBase { public: + ConfigVariable (std::string str) : ConfigVariableBase (str) {} ConfigVariable (std::string str, T val) : ConfigVariableBase (str), value (val) {} - virtual bool set (T val, Owner owner = ARDOUR::ConfigVariableBase::Config) { + T get() const { + return value; + } + + std::string get_as_string () const { + std::stringstream ss; + ss << value; + return ss.str (); + } + + virtual bool set (T val) { if (val == value) { miss (); return false; } value = val; - _owner = (ConfigVariableBase::Owner)(_owner |owner); notify (); return true; } - T get() const { - return value; - } - - void add_to_node (XMLNode& node) { + void set_from_string (std::string const & s) { std::stringstream ss; - ss << value; - show_stored_value (ss.str()); - XMLNode* child = new XMLNode ("Option"); - child->add_property ("name", _name); - child->add_property ("value", ss.str()); - node.add_child_nocopy (*child); - } - - bool set_from_node (const XMLNode& node, Owner owner) { - - if (node.name() == "Config") { - - /* ardour.rc */ - - const XMLProperty* prop; - XMLNodeList nlist; - XMLNodeConstIterator niter; - XMLNode* child; - - nlist = node.children(); - - for (niter = nlist.begin(); niter != nlist.end(); ++niter) { - - child = *niter; - - if (child->name() == "Option") { - if ((prop = child->property ("name")) != 0) { - if (prop->value() == _name) { - if ((prop = child->property ("value")) != 0) { - std::stringstream ss; - ss << prop->value(); - ss >> value; - _owner = (ConfigVariableBase::Owner)(_owner |owner); - return true; - } - } - } - } - } - - } else if (node.name() == "Options") { - - /* session file */ - - XMLNodeList olist; - XMLNodeConstIterator oiter; - XMLNode* option; - const XMLProperty* opt_prop; - - olist = node.children(); - - for (oiter = olist.begin(); oiter != olist.end(); ++oiter) { - - option = *oiter; - - if (option->name() == _name) { - if ((opt_prop = option->property ("val")) != 0) { - std::stringstream ss; - ss << opt_prop->value(); - ss >> value; - _owner = (ConfigVariableBase::Owner)(_owner |owner); - return true; - } - } - } - } - - return false; + ss << s; + ss >> value; } protected: @@ -165,10 +99,10 @@ class ConfigVariableWithMutation : public ConfigVariable<T> ConfigVariableWithMutation (std::string name, T val, T (*m)(T)) : ConfigVariable<T> (name, val), mutator (m) {} - bool set (T val, ConfigVariableBase::Owner owner) { + bool set (T val) { if (unmutated_value != val) { unmutated_value = val; - return ConfigVariable<T>::set (mutator (val), owner); + return ConfigVariable<T>::set (mutator (val)); } return false; } diff --git a/libs/ardour/ardour/diskstream.h b/libs/ardour/ardour/diskstream.h index a78f2e23a7..f6471e300a 100644 --- a/libs/ardour/ardour/diskstream.h +++ b/libs/ardour/ardour/diskstream.h @@ -39,7 +39,6 @@ #include "pbd/statefuldestructible.h" #include "ardour/ardour.h" -#include "ardour/configuration.h" #include "ardour/location.h" #include "ardour/session_object.h" #include "ardour/types.h" diff --git a/libs/ardour/ardour/midi_diskstream.h b/libs/ardour/ardour/midi_diskstream.h index d5c2d0cdb3..872ffb78e3 100644 --- a/libs/ardour/ardour/midi_diskstream.h +++ b/libs/ardour/ardour/midi_diskstream.h @@ -36,7 +36,6 @@ #include "pbd/ringbufferNPT.h" #include "ardour/ardour.h" -#include "ardour/configuration.h" #include "ardour/diskstream.h" #include "ardour/midi_playlist.h" #include "ardour/midi_ring_buffer.h" diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 344b79bcd1..fc879b45a3 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -51,7 +51,8 @@ #include "ardour/ardour.h" #include "ardour/chan_count.h" -#include "ardour/configuration.h" +#include "ardour/rc_configuration.h" +#include "ardour/session_configuration.h" #include "ardour/location.h" #include "ardour/smpte.h" @@ -388,7 +389,7 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable void goto_end () { request_locate (end_location->start(), false);} void goto_start () { request_locate (start_location->start(), false); } void set_session_start (nframes_t start) { start_location->set_start(start); } - void set_session_end (nframes_t end) { end_location->set_start(end); _end_location_is_free = false; } + void set_session_end (nframes_t end) { end_location->set_start(end); config.set_end_marker_is_free (false); } void use_rf_shuttle_speed (); void allow_auto_play (bool yn); void request_transport_speed (double speed); @@ -967,6 +968,8 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable SessionMetadata & metadata () { return *_metadata; } + SessionConfiguration config; + protected: friend class AudioEngine; void set_block_size (nframes_t nframes); @@ -1038,7 +1041,6 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable bool _have_captured; float _meter_hold; float _meter_falloff; - bool _end_location_is_free; void set_worst_io_latencies (); void set_worst_io_latencies_x (IOChange asifwecare, void *ignored) { @@ -1111,7 +1113,7 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable if (actively_recording()) { return true; } else { - if (Config->get_auto_input()) { + if (config.get_auto_input()) { return false; } else { return true; @@ -1173,9 +1175,7 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable void auto_save(); int load_options (const XMLNode&); - XMLNode& get_options () const; int load_state (std::string snapshot_name); - bool save_config_options_predicate (ConfigVariableBase::Owner owner) const; nframes_t _last_roll_location; nframes_t _last_record_location; diff --git a/libs/ardour/ardour/session_object.h b/libs/ardour/ardour/session_object.h index 1a6a79ceee..7a05ab16b0 100644 --- a/libs/ardour/ardour/session_object.h +++ b/libs/ardour/ardour/session_object.h @@ -27,7 +27,6 @@ namespace ARDOUR { class Session; - /** An object associated with a Session. * * This is a few common things factored out of IO which weren't IO specific diff --git a/libs/ardour/ardour/sndfilesource.h b/libs/ardour/ardour/sndfilesource.h index d50dbad664..7d04e7de25 100644 --- a/libs/ardour/ardour/sndfilesource.h +++ b/libs/ardour/ardour/sndfilesource.h @@ -57,7 +57,7 @@ class SndFileSource : public AudioFileSource { bool one_of_several_channels () const; - static void setup_standard_crossfades (nframes_t sample_rate); + static void setup_standard_crossfades (Session const &, nframes_t sample_rate); static const Source::Flag default_writable_flags; static int get_soundfile_info (const Glib::ustring& path, SoundFileInfo& _info, std::string& error_msg); diff --git a/libs/ardour/ardour/types.h b/libs/ardour/ardour/types.h index 2ed5e0e365..cdec0c5fab 100644 --- a/libs/ardour/ardour/types.h +++ b/libs/ardour/ardour/types.h @@ -336,6 +336,7 @@ namespace ARDOUR { }; enum AutoConnectOption { + ManualConnect = 0x0, AutoConnectPhysical = 0x1, AutoConnectMaster = 0x2 }; diff --git a/libs/ardour/ardour/utils.h b/libs/ardour/ardour/utils.h index eecde2e85f..fc5d98115f 100644 --- a/libs/ardour/ardour/utils.h +++ b/libs/ardour/ardour/utils.h @@ -63,6 +63,20 @@ ARDOUR::SlaveSource string_to_slave_source (std::string str); const char* edit_mode_to_string (ARDOUR::EditMode); ARDOUR::EditMode string_to_edit_mode (std::string); + +/* I don't really like hard-coding these falloff rates here + * Probably should use a map of some kind that could be configured + * These rates are db/sec. +*/ + +#define METER_FALLOFF_OFF 0.0f +#define METER_FALLOFF_SLOWEST 6.6f // BBC standard +#define METER_FALLOFF_SLOW 8.6f // BBC standard +#define METER_FALLOFF_MEDIUM 20.0f +#define METER_FALLOFF_FAST 32.0f +#define METER_FALLOFF_FASTER 46.0f +#define METER_FALLOFF_FASTEST 70.0f + float meter_falloff_to_float (ARDOUR::MeterFalloff); ARDOUR::MeterFalloff meter_falloff_from_float (float); float meter_falloff_to_db_per_sec (float); diff --git a/libs/ardour/audio_diskstream.cc b/libs/ardour/audio_diskstream.cc index bb74d5fc16..910239f630 100644 --- a/libs/ardour/audio_diskstream.cc +++ b/libs/ardour/audio_diskstream.cc @@ -438,7 +438,7 @@ AudioDiskstream::check_record_status (nframes_t transport_frame, nframes_t nfram if (_alignment_style == ExistingMaterial) { - if (!Config->get_punch_in()) { + if (!_session.config.get_punch_in()) { /* manual punch in happens at the correct transport frame because the user hit a button. but to get alignment correct @@ -467,7 +467,7 @@ AudioDiskstream::check_record_status (nframes_t transport_frame, nframes_t nfram } else { - if (Config->get_punch_in()) { + if (_session.config.get_punch_in()) { first_recordable_frame += _roll_delay; } else { capture_start_frame -= _roll_delay; @@ -570,7 +570,7 @@ AudioDiskstream::process (nframes_t transport_frame, nframes_t nframes, bool can (*chan)->current_playback_buffer = 0; } - if (nominally_recording || (_session.get_record_enabled() && Config->get_punch_in())) { + if (nominally_recording || (_session.get_record_enabled() && _session.config.get_punch_in())) { OverlapType ot; // Safeguard against situations where process() goes haywire when autopunching and last_recordable_frame < first_recordable_frame @@ -1867,7 +1867,7 @@ AudioDiskstream::engage_record_enable () for (ChannelList::iterator chan = c->begin(); chan != c->end(); ++chan) { if ((*chan)->source) { - (*chan)->source->ensure_monitor_input (!(Config->get_auto_input() && rolling)); + (*chan)->source->ensure_monitor_input (!(_session.config.get_auto_input() && rolling)); } capturing_sources.push_back ((*chan)->write_source); (*chan)->write_source->mark_streaming_write_started (); @@ -1936,7 +1936,7 @@ AudioDiskstream::get_state () Location* pi; - if (Config->get_punch_in() && ((pi = _session.locations()->auto_punch_location()) != 0)) { + if (_session.config.get_punch_in() && ((pi = _session.locations()->auto_punch_location()) != 0)) { snprintf (buf, sizeof (buf), "%" PRIu32, pi->start()); } else { snprintf (buf, sizeof (buf), "%" PRIu32, _session.transport_frame()); diff --git a/libs/ardour/audio_playlist.cc b/libs/ardour/audio_playlist.cc index ef2cf281ef..6439c1b917 100644 --- a/libs/ardour/audio_playlist.cc +++ b/libs/ardour/audio_playlist.cc @@ -368,7 +368,7 @@ AudioPlaylist::check_dependents (boost::shared_ptr<Region> r, bool norefresh) } - if (!Config->get_auto_xfade()) { + if (!_session.config.get_auto_xfade()) { return; } @@ -450,19 +450,19 @@ AudioPlaylist::check_dependents (boost::shared_ptr<Region> r, bool norefresh) * [---- bottom -------------------] */ - if (Config->get_xfade_model() == FullCrossfade) { + if (_session.config.get_xfade_model() == FullCrossfade) { touched_regions = regions_touched (top->first_frame(), bottom->last_frame()); if (touched_regions->size() <= 2) { - xfade = boost::shared_ptr<Crossfade> (new Crossfade (region, other, Config->get_xfade_model(), Config->get_xfades_active())); + xfade = boost::shared_ptr<Crossfade> (new Crossfade (region, other, _session.config.get_xfade_model(), _session.config.get_xfades_active())); add_crossfade (xfade); } } else { touched_regions = regions_touched (top->first_frame(), - top->first_frame() + min ((nframes_t)Config->get_short_xfade_seconds() * _session.frame_rate(), + top->first_frame() + min ((nframes_t)_session.config.get_short_xfade_seconds() * _session.frame_rate(), top->length())); if (touched_regions->size() <= 2) { - xfade = boost::shared_ptr<Crossfade> (new Crossfade (region, other, Config->get_xfade_model(), Config->get_xfades_active())); + xfade = boost::shared_ptr<Crossfade> (new Crossfade (region, other, _session.config.get_xfade_model(), _session.config.get_xfades_active())); add_crossfade (xfade); } } @@ -474,28 +474,28 @@ AudioPlaylist::check_dependents (boost::shared_ptr<Region> r, bool norefresh) * { ==== bottom ============ } */ - if (Config->get_xfade_model() == FullCrossfade) { + if (_session.config.get_xfade_model() == FullCrossfade) { touched_regions = regions_touched (bottom->first_frame(), top->last_frame()); if (touched_regions->size() <= 2) { xfade = boost::shared_ptr<Crossfade> (new Crossfade (region, other, - Config->get_xfade_model(), Config->get_xfades_active())); + _session.config.get_xfade_model(), _session.config.get_xfades_active())); add_crossfade (xfade); } } else { touched_regions = regions_touched (bottom->first_frame(), - bottom->first_frame() + min ((nframes_t)Config->get_short_xfade_seconds() * _session.frame_rate(), + bottom->first_frame() + min ((nframes_t)_session.config.get_short_xfade_seconds() * _session.frame_rate(), bottom->length())); if (touched_regions->size() <= 2) { - xfade = boost::shared_ptr<Crossfade> (new Crossfade (region, other, Config->get_xfade_model(), Config->get_xfades_active())); + xfade = boost::shared_ptr<Crossfade> (new Crossfade (region, other, _session.config.get_xfade_model(), _session.config.get_xfades_active())); add_crossfade (xfade); } } break; default: xfade = boost::shared_ptr<Crossfade> (new Crossfade (region, other, - Config->get_xfade_model(), Config->get_xfades_active())); + _session.config.get_xfade_model(), _session.config.get_xfades_active())); add_crossfade (xfade); } } diff --git a/libs/ardour/audio_track.cc b/libs/ardour/audio_track.cc index 4a3fa04d1c..878ad1118f 100644 --- a/libs/ardour/audio_track.cc +++ b/libs/ardour/audio_track.cc @@ -509,7 +509,7 @@ AudioTrack::roll (nframes_t nframes, sframes_t start_frame, sframes_t end_frame, just_meter_input (start_frame, end_frame, nframes); } - if (diskstream->record_enabled() && !can_record && !Config->get_auto_input()) { + if (diskstream->record_enabled() && !can_record && !_session.config.get_auto_input()) { /* not actually recording, but we want to hear the input material anyway, at least potentially (depending on monitoring options) diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc index f3fbbe6c1c..197af86d13 100644 --- a/libs/ardour/audioregion.cc +++ b/libs/ardour/audioregion.cc @@ -434,7 +434,7 @@ AudioRegion::_read_at (const SourceList& srcs, nframes_t limit, /* fade in */ - if ((_flags & FadeIn) && Config->get_use_region_fades()) { + if ((_flags & FadeIn) && _session.config.get_use_region_fades()) { nframes_t fade_in_length = (nframes_t) _fade_in->back()->when; @@ -457,7 +457,7 @@ AudioRegion::_read_at (const SourceList& srcs, nframes_t limit, /* fade out */ - if ((_flags & FadeOut) && Config->get_use_region_fades()) { + if ((_flags & FadeOut) && _session.config.get_use_region_fades()) { /* see if some part of this read is within the fade out */ diff --git a/libs/ardour/auditioner.cc b/libs/ardour/auditioner.cc index a0abe860fb..b62d0f3406 100644 --- a/libs/ardour/auditioner.cc +++ b/libs/ardour/auditioner.cc @@ -41,8 +41,8 @@ using namespace PBD; Auditioner::Auditioner (Session& s) : AudioTrack (s, "auditioner", Route::Hidden) { - string left = Config->get_auditioner_output_left(); - string right = Config->get_auditioner_output_right(); + string left = _session.config.get_auditioner_output_left(); + string right = _session.config.get_auditioner_output_right(); if (left == "default") { left = _session.engine().get_nth_physical_output (DataType::AUDIO, 0); @@ -209,12 +209,12 @@ Auditioner::output_changed (IOChange change, void* src) if (output (0)->get_connections (connections)) { phys = _session.engine().get_nth_physical_output (DataType::AUDIO, 0); if (phys != connections[0]) { - Config->set_auditioner_output_left (connections[0]); + _session.config.set_auditioner_output_left (connections[0]); } else { - Config->set_auditioner_output_left ("default"); + _session.config.set_auditioner_output_left ("default"); } } else { - Config->set_auditioner_output_left (""); + _session.config.set_auditioner_output_left (""); } connections.clear (); @@ -222,12 +222,12 @@ Auditioner::output_changed (IOChange change, void* src) if (output (1)->get_connections (connections)) { phys = _session.engine().get_nth_physical_output (DataType::AUDIO, 1); if (phys != connections[0]) { - Config->set_auditioner_output_right (connections[0]); + _session.config.set_auditioner_output_right (connections[0]); } else { - Config->set_auditioner_output_right ("default"); + _session.config.set_auditioner_output_right ("default"); } } else { - Config->set_auditioner_output_right (""); + _session.config.set_auditioner_output_right (""); } } } diff --git a/libs/ardour/broadcast_info.cc b/libs/ardour/broadcast_info.cc index bb8aedae88..1144aaa2cd 100644 --- a/libs/ardour/broadcast_info.cc +++ b/libs/ardour/broadcast_info.cc @@ -77,7 +77,7 @@ BroadcastInfo::set_from_session (Session const & session, int64_t time_ref) set_time_reference (time_ref); set_origination_time (); set_originator (); - set_originator_ref (); + set_originator_ref (session); } bool @@ -242,7 +242,7 @@ BroadcastInfo::set_originator (std::string const & str) } void -BroadcastInfo::set_originator_ref (std::string const & str) +BroadcastInfo::set_originator_ref (Session const & session, std::string const & str) { _has_info = true; @@ -261,8 +261,8 @@ BroadcastInfo::set_originator_ref (std::string const & str) serial_number << "ARDOUR" << "r" << std::setfill('0') << std::right << std::setw(5) << svn_revision; snprintf_bounded_null_filled (info->originator_reference, sizeof (info->originator_reference), "%2s%3s%12s%02d%02d%02d%9d", - Config->get_bwf_country_code().c_str(), - Config->get_bwf_organization_code().c_str(), + session.config.get_bwf_country_code().c_str(), + session.config.get_bwf_organization_code().c_str(), serial_number.str().c_str(), _time.tm_hour, _time.tm_min, diff --git a/libs/ardour/configuration.cc b/libs/ardour/configuration.cc index bff9fb16d6..79f36c86d8 100644 --- a/libs/ardour/configuration.cc +++ b/libs/ardour/configuration.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 1999-2006 Paul Davis + Copyright (C) 1999-2009 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 @@ -17,332 +17,90 @@ */ -#include <unistd.h> -#include <cstdio> /* for snprintf, grrr */ - -#include <glib.h> -#include <glib/gstdio.h> /* for g_stat() */ -#include <glibmm/miscutils.h> - -#include "pbd/failed_constructor.h" -#include "pbd/xml++.h" -#include "pbd/filesystem.h" -#include "pbd/file_utils.h" - -#include "midi++/manager.h" - -#include "ardour/ardour.h" #include "ardour/configuration.h" -#include "ardour/audio_diskstream.h" -#include "ardour/control_protocol_manager.h" -#include "ardour/filesystem_paths.h" - -#include "i18n.h" using namespace ARDOUR; using namespace std; using namespace PBD; -/* this is global so that we do not have to indirect through an object pointer - to reference it. -*/ - -namespace ARDOUR { - float speed_quietning = 0.251189; // -12dB reduction for ffwd or rewind -} - Configuration::Configuration () - : -/* construct variables */ -#undef CONFIG_VARIABLE -#undef CONFIG_VARIABLE_SPECIAL -#define CONFIG_VARIABLE(Type,var,name,value) var (name,value), -#define CONFIG_VARIABLE_SPECIAL(Type,var,name,value,mutator) var (name,value,mutator), -#include "ardour/configuration_vars.h" -#undef CONFIG_VARIABLE -#undef CONFIG_VARIABLE_SPECIAL - - - current_owner (ConfigVariableBase::Default) { - _control_protocol_state = 0; } Configuration::~Configuration () { } +bool ConfigVariableBase::show_stores = false; + void -Configuration::set_current_owner (ConfigVariableBase::Owner owner) +ConfigVariableBase::add_to_node (XMLNode& node) { - current_owner = owner; + std::string const v = get_as_string (); + show_stored_value (v); + XMLNode* child = new XMLNode ("Option"); + child->add_property ("name", _name); + child->add_property ("value", v); + node.add_child_nocopy (*child); } -int -Configuration::load_state () +bool +ConfigVariableBase::set_from_node (XMLNode const & node) { - bool found = false; - - sys::path system_rc_file; - struct stat statbuf; - - /* load system configuration first */ - - if (find_file_in_search_path (ardour_search_path() + system_config_search_path(), - "ardour_system.rc", system_rc_file) ) - { - XMLTree tree; - found = true; - - string rcfile = system_rc_file.to_string(); - - /* stupid XML Parser hates empty files */ + if (node.name() == "Config" || node.name() == "Canvas" || node.name() == "UI") { - if (g_stat (rcfile.c_str(), &statbuf)) { - return -1; - } - - if (statbuf.st_size != 0) { - cerr << string_compose (_("Loading system configuration file %1"), rcfile) << endl; - - if (!tree.read (rcfile.c_str())) { - error << string_compose(_("Ardour: cannot read system configuration file \"%1\""), rcfile) << endmsg; - return -1; - } + /* ardour.rc */ + + const XMLProperty* prop; + XMLNodeList nlist; + XMLNodeConstIterator niter; + XMLNode* child; + + nlist = node.children(); + + for (niter = nlist.begin(); niter != nlist.end(); ++niter) { - current_owner = ConfigVariableBase::System; + child = *niter; - if (set_state (*tree.root())) { - error << string_compose(_("Ardour: system configuration file \"%1\" not loaded successfully."), rcfile) << endmsg; - return -1; + if (child->name() == "Option") { + if ((prop = child->property ("name")) != 0) { + if (prop->value() == _name) { + if ((prop = child->property ("value")) != 0) { + set_from_string (prop->value()); + return true; + } + } + } } - } else { - error << _("your system Ardour configuration file is empty. This probably means that there as an error installing Ardour") << endmsg; } - } - - /* now load configuration file for user */ - - sys::path user_rc_file; - - if (find_file_in_search_path (ardour_search_path() + user_config_directory(), - "ardour.rc", user_rc_file)) - { - XMLTree tree; - found = true; - - string rcfile = user_rc_file.to_string(); - - /* stupid XML parser hates empty files */ + + } else if (node.name() == "Options") { - if (g_stat (rcfile.c_str(), &statbuf)) { - return -1; - } + /* session file */ - if (statbuf.st_size != 0) { - cerr << string_compose (_("Loading user configuration file %1"), rcfile) << endl; - - if (!tree.read (rcfile)) { - error << string_compose(_("Ardour: cannot read configuration file \"%1\""), rcfile) << endmsg; - return -1; - } + XMLNodeList olist; + XMLNodeConstIterator oiter; + XMLNode* option; + const XMLProperty* opt_prop; + + olist = node.children(); + + for (oiter = olist.begin(); oiter != olist.end(); ++oiter) { - current_owner = ConfigVariableBase::Config; + option = *oiter; - if (set_state (*tree.root())) { - error << string_compose(_("Ardour: user configuration file \"%1\" not loaded successfully."), rcfile) << endmsg; - return -1; - } - } else { - warning << _("your Ardour configuration file is empty. This is not normal.") << endmsg; - } - } - - if (!found) - error << "Ardour: could not find configuration file (ardour.rc), canvas will look broken." << endmsg; - - return 0; -} - -int -Configuration::save_state() -{ - XMLTree tree; - - try - { - sys::create_directories (user_config_directory ()); - } - catch (const sys::filesystem_error& ex) - { - error << "Could not create user configuration directory" << endmsg; - return -1; - } - - sys::path rcfile_path(user_config_directory()); - - rcfile_path /= "ardour.rc"; - const string rcfile = rcfile_path.to_string(); - - // this test seems bogus? - if (rcfile.length()) { - tree.set_root (&get_state()); - if (!tree.write (rcfile.c_str())){ - error << string_compose (_("Config file %1 not saved"), rcfile) << endmsg; - return -1; - } - } - - return 0; -} - -void -Configuration::add_instant_xml(XMLNode& node) -{ - Stateful::add_instant_xml (node, user_config_directory ()); -} - -XMLNode* -Configuration::instant_xml(const string& node_name) -{ - return Stateful::instant_xml (node_name, user_config_directory ()); -} - - -bool -Configuration::save_config_options_predicate (ConfigVariableBase::Owner owner) -{ - /* only save things that were in the config file to start with */ - return owner & ConfigVariableBase::Config; -} - -XMLNode& -Configuration::get_state () -{ - XMLNode* root; - LocaleGuard lg (X_("POSIX")); - - root = new XMLNode("Ardour"); - - MIDI::Manager::PortMap::const_iterator i; - const MIDI::Manager::PortMap& ports = MIDI::Manager::instance()->get_midi_ports(); - - for (i = ports.begin(); i != ports.end(); ++i) { - root->add_child_nocopy(i->second->get_state()); - } - - root->add_child_nocopy (get_variables (sigc::mem_fun (*this, &Configuration::save_config_options_predicate), "Config")); - - if (_extra_xml) { - root->add_child_copy (*_extra_xml); - } - - root->add_child_nocopy (ControlProtocolManager::instance().get_state()); - - return *root; -} - -XMLNode& -Configuration::get_variables (sigc::slot<bool,ConfigVariableBase::Owner> predicate, std::string which_node) -{ - XMLNode* node; - LocaleGuard lg (X_("POSIX")); - - node = new XMLNode(which_node); - -#undef CONFIG_VARIABLE -#undef CONFIG_VARIABLE_SPECIAL -#define CONFIG_VARIABLE(type,var,Name,value) \ - if (node->name() == "Config") { if (predicate (var.owner())) { var.add_to_node (*node); }} -#define CONFIG_VARIABLE_SPECIAL(type,var,Name,value,mutator) \ - if (node->name() == "Config") { if (predicate (var.owner())) { var.add_to_node (*node); }} -#include "ardour/configuration_vars.h" -#undef CONFIG_VARIABLE -#undef CONFIG_VARIABLE_SPECIAL - - return *node; -} - -int -Configuration::set_state (const XMLNode& root) -{ - if (root.name() != "Ardour") { - return -1; - } - - XMLNodeList nlist = root.children(); - XMLNodeConstIterator niter; - XMLNode *node; - - for (niter = nlist.begin(); niter != nlist.end(); ++niter) { - - node = *niter; - - if (node->name() == "MIDI-port") { - - try { - - MIDI::Port::Descriptor desc (*node); - map<string,XMLNode>::iterator x; - if ((x = midi_ports.find (desc.tag)) != midi_ports.end()) { - midi_ports.erase (x); + if (option->name() == _name) { + if ((opt_prop = option->property ("val")) != 0) { + set_from_string (opt_prop->value()); + return true; } - midi_ports.insert (pair<string,XMLNode>(desc.tag,*node)); } - - catch (failed_constructor& err) { - warning << _("ill-formed MIDI port specification in ardour rcfile (ignored)") << endmsg; - } - - } else if (node->name() == "Config") { - - set_variables (*node, ConfigVariableBase::Config); - - } else if (node->name() == "Extra") { - _extra_xml = new XMLNode (*node); - - } else if (node->name() == ControlProtocolManager::state_node_name) { - _control_protocol_state = new XMLNode (*node); } } - - Diskstream::set_disk_io_chunk_frames (minimum_disk_io_bytes.get() / sizeof (Sample)); - - return 0; -} - -void -Configuration::set_variables (const XMLNode& node, ConfigVariableBase::Owner owner) -{ -#undef CONFIG_VARIABLE -#undef CONFIG_VARIABLE_SPECIAL -#define CONFIG_VARIABLE(type,var,name,value) \ - if (var.set_from_node (node, owner)) { \ - ParameterChanged (name); \ - } -#define CONFIG_VARIABLE_SPECIAL(type,var,name,value,mutator) \ - if (var.set_from_node (node, owner)) { \ - ParameterChanged (name); \ - } - -#include "ardour/configuration_vars.h" -#undef CONFIG_VARIABLE -#undef CONFIG_VARIABLE_SPECIAL -} -void -Configuration::map_parameters (sigc::slot<void,const char*> theSlot) -{ -#undef CONFIG_VARIABLE -#undef CONFIG_VARIABLE_SPECIAL -#define CONFIG_VARIABLE(type,var,name,value) theSlot (name); -#define CONFIG_VARIABLE_SPECIAL(type,var,name,value,mutator) theSlot (name); -#include "ardour/configuration_vars.h" -#undef CONFIG_VARIABLE -#undef CONFIG_VARIABLE_SPECIAL + return false; } -bool ConfigVariableBase::show_stores = false; void ConfigVariableBase::set_show_stored_values (bool yn) diff --git a/libs/ardour/crossfade.cc b/libs/ardour/crossfade.cc index c258a9bf73..62169a48df 100644 --- a/libs/ardour/crossfade.cc +++ b/libs/ardour/crossfade.cc @@ -83,7 +83,7 @@ Crossfade::Crossfade (boost::shared_ptr<AudioRegion> in, boost::shared_ptr<Audio _anchor_point = ap; _follow_overlap = false; - _active = Config->get_xfades_active (); + _active = _session.config.get_xfades_active (); _fixed = true; initialize (); @@ -428,7 +428,7 @@ Crossfade::refresh () if (_follow_overlap) { try { - compute (_in, _out, Config->get_xfade_model()); + compute (_in, _out, _session.config.get_xfade_model()); } catch (NoCrossfadeHere& err) { diff --git a/libs/ardour/globals.cc b/libs/ardour/globals.cc index 722c0fad49..1e17b3aeb9 100644 --- a/libs/ardour/globals.cc +++ b/libs/ardour/globals.cc @@ -56,7 +56,7 @@ #include "ardour/ardour.h" #include "ardour/analyser.h" #include "ardour/audio_library.h" -#include "ardour/configuration.h" +#include "ardour/rc_configuration.h" #include "ardour/profile.h" #include "ardour/plugin_manager.h" #include "ardour/audiosource.h" @@ -76,7 +76,7 @@ #include "i18n.h" -ARDOUR::Configuration* ARDOUR::Config = 0; +ARDOUR::RCConfiguration* ARDOUR::Config = 0; ARDOUR::RuntimeProfile* ARDOUR::Profile = 0; ARDOUR::AudioLibrary* ARDOUR::Library = 0; @@ -303,7 +303,7 @@ ARDOUR::init (bool use_vst, bool try_optimization) BootMessage (_("Loading configuration")); - Config = new Configuration; + Config = new RCConfiguration; if (Config->load_state ()) { return -1; diff --git a/libs/ardour/midi_diskstream.cc b/libs/ardour/midi_diskstream.cc index 6eaf01c819..30b1542974 100644 --- a/libs/ardour/midi_diskstream.cc +++ b/libs/ardour/midi_diskstream.cc @@ -367,7 +367,7 @@ MidiDiskstream::check_record_status (nframes_t transport_frame, nframes_t nframe if (_alignment_style == ExistingMaterial) { - if (!Config->get_punch_in()) { + if (!_session.config.get_punch_in()) { /* manual punch in happens at the correct transport frame because the user hit a button. but to get alignment correct @@ -396,7 +396,7 @@ MidiDiskstream::check_record_status (nframes_t transport_frame, nframes_t nframe } else { - if (Config->get_punch_in()) { + if (_session.config.get_punch_in()) { first_recordable_frame += _roll_delay; } else { capture_start_frame -= _roll_delay; @@ -634,7 +634,7 @@ MidiDiskstream::process (nframes_t transport_frame, nframes_t nframes, bool can_ commit_should_unlock = true; adjust_capture_position = 0; - if (nominally_recording || (_session.get_record_enabled() && Config->get_punch_in())) { + if (nominally_recording || (_session.get_record_enabled() && _session.config.get_punch_in())) { OverlapType ot; ot = coverage (first_recordable_frame, last_recordable_frame, transport_frame, transport_frame + nframes); @@ -1325,7 +1325,7 @@ MidiDiskstream::engage_record_enable () g_atomic_int_set (&_record_enabled, 1); if (_source_port && Config->get_monitoring_model() == HardwareMonitoring) { - _source_port->request_monitor_input (!(Config->get_auto_input() && rolling)); + _source_port->request_monitor_input (!(_session.config.get_auto_input() && rolling)); } // FIXME: Why is this necessary? Isn't needed for AudioDiskstream... @@ -1387,7 +1387,7 @@ MidiDiskstream::get_state () Location* pi; - if (Config->get_punch_in() && ((pi = _session.locations()->auto_punch_location()) != 0)) { + if (_session.config.get_punch_in() && ((pi = _session.locations()->auto_punch_location()) != 0)) { snprintf (buf, sizeof (buf), "%" PRIu32, pi->start()); } else { snprintf (buf, sizeof (buf), "%" PRIu32, _session.transport_frame()); diff --git a/libs/ardour/midi_track.cc b/libs/ardour/midi_track.cc index 6697e3b704..6feb3253ce 100644 --- a/libs/ardour/midi_track.cc +++ b/libs/ardour/midi_track.cc @@ -414,7 +414,7 @@ MidiTrack::roll (nframes_t nframes, sframes_t start_frame, sframes_t end_frame, just_meter_input (start_frame, end_frame, nframes); } - if (diskstream->record_enabled() && !can_record && !Config->get_auto_input()) { + if (diskstream->record_enabled() && !can_record && !_session.config.get_auto_input()) { /* not actually recording, but we want to hear the input material anyway, at least potentially (depending on monitoring options) diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc index a78addf481..4942485a70 100644 --- a/libs/ardour/playlist.cc +++ b/libs/ardour/playlist.cc @@ -421,8 +421,7 @@ Playlist::flush_notifications () // pending_bounds.sort (cmp); for (RegionList::iterator r = pending_bounds.begin(); r != pending_bounds.end(); ++r) { - - if (Config->get_layer_model() == MoveAddHigher) { + if (_session.config.get_layer_model() == MoveAddHigher) { timestamp_layer_op (*r); } @@ -1277,7 +1276,7 @@ Playlist::region_bounds_changed (Change what_changed, boost::shared_ptr<Region> if (holding_state ()) { pending_bounds.push_back (region); } else { - if (Config->get_layer_model() == MoveAddHigher) { + if (_session.config.get_layer_model() == MoveAddHigher) { /* it moved or changed length, so change the timestamp */ timestamp_layer_op (region); } @@ -1964,7 +1963,7 @@ Playlist::relayer () /* sort according to the model */ - if (Config->get_layer_model() == MoveAddHigher || Config->get_layer_model() == AddHigher) { + if (_session.config.get_layer_model() == MoveAddHigher || _session.config.get_layer_model() == AddHigher) { RegionSortByLastLayerOp cmp; copy.sort (cmp); } @@ -2054,8 +2053,8 @@ void Playlist::raise_region_to_top (boost::shared_ptr<Region> region) { /* does nothing useful if layering mode is later=higher */ - if ((Config->get_layer_model() == MoveAddHigher) || - (Config->get_layer_model() == AddHigher)) { + if ((_session.config.get_layer_model() == MoveAddHigher) || + (_session.config.get_layer_model() == AddHigher)) { timestamp_layer_op (region); relayer (); } @@ -2065,8 +2064,8 @@ void Playlist::lower_region_to_bottom (boost::shared_ptr<Region> region) { /* does nothing useful if layering mode is later=higher */ - if ((Config->get_layer_model() == MoveAddHigher) || - (Config->get_layer_model() == AddHigher)) { + if ((_session.config.get_layer_model() == MoveAddHigher) || + (_session.config.get_layer_model() == AddHigher)) { region->set_last_layer_op (0); relayer (); } diff --git a/libs/ardour/playlist_factory.cc b/libs/ardour/playlist_factory.cc index 4da4c1b192..7088fa67a3 100644 --- a/libs/ardour/playlist_factory.cc +++ b/libs/ardour/playlist_factory.cc @@ -18,6 +18,7 @@ */ #include "pbd/error.h" +#include "pbd/xml++.h" #include "ardour/playlist.h" #include "ardour/audioplaylist.h" diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index db06368371..06b9308d35 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -325,7 +325,7 @@ Route::process_output_buffers (BufferSet& bufs, declick = _pending_declick; const bool recording_without_monitoring = no_monitor && record_enabled() - && (!Config->get_auto_input() || _session.actively_recording()); + && (!_session.config.get_auto_input() || _session.actively_recording()); /* ------------------------------------------------------------------------------------------- diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 3105b776dc..02f868a4c0 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -865,7 +865,7 @@ Session::reset_input_monitor_state () for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { if ((*i)->record_enabled ()) { //cerr << "switching to input = " << !auto_input << __FILE__ << __LINE__ << endl << endl; - (*i)->monitor_input (Config->get_monitoring_model() == HardwareMonitoring && !Config->get_auto_input()); + (*i)->monitor_input (Config->get_monitoring_model() == HardwareMonitoring && !config.get_auto_input()); } } } else { @@ -885,7 +885,7 @@ Session::auto_punch_start_changed (Location* location) { replace_event (Event::PunchIn, location->start()); - if (get_record_enabled() && Config->get_punch_in()) { + if (get_record_enabled() && config.get_punch_in()) { /* capture start has been changed, so save new pending state */ save_state ("", true); } @@ -1091,7 +1091,7 @@ Session::enable_record () _last_record_location = _transport_frame; deliver_mmc(MIDI::MachineControl::cmdRecordStrobe, _last_record_location); - if (Config->get_monitoring_model() == HardwareMonitoring && Config->get_auto_input()) { + if (Config->get_monitoring_model() == HardwareMonitoring && config.get_auto_input()) { boost::shared_ptr<DiskstreamList> dsl = diskstreams.reader(); for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { if ((*i)->record_enabled ()) { @@ -1125,7 +1125,7 @@ Session::disable_record (bool rt_context, bool force) if (rt_context) deliver_mmc (MIDI::MachineControl::cmdRecordExit, _transport_frame); - if (Config->get_monitoring_model() == HardwareMonitoring && Config->get_auto_input()) { + if (Config->get_monitoring_model() == HardwareMonitoring && config.get_auto_input()) { boost::shared_ptr<DiskstreamList> dsl = diskstreams.reader(); for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { @@ -1150,7 +1150,7 @@ Session::step_back_from_record () if (g_atomic_int_get (&_record_status) == Recording) { g_atomic_int_set (&_record_status, Enabled); - if (Config->get_monitoring_model() == HardwareMonitoring && Config->get_auto_input()) { + if (Config->get_monitoring_model() == HardwareMonitoring && config.get_auto_input()) { boost::shared_ptr<DiskstreamList> dsl = diskstreams.reader(); for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { @@ -1175,7 +1175,7 @@ Session::maybe_enable_record () save_state ("", true); if (_transport_speed) { - if (!Config->get_punch_in()) { + if (!config.get_punch_in()) { enable_record (); } } else { @@ -3726,7 +3726,7 @@ Session::available_capture_duration () { float sample_bytes_on_disk = 4.0; // keep gcc happy - switch (Config->get_native_file_data_format()) { + switch (config.get_native_file_data_format()) { case FormatFloat: sample_bytes_on_disk = 4.0; break; diff --git a/libs/ardour/session_events.cc b/libs/ardour/session_events.cc index 06f4598af7..d631eda710 100644 --- a/libs/ardour/session_events.cc +++ b/libs/ardour/session_events.cc @@ -366,7 +366,7 @@ Session::process_event (Event* ev) case Event::PunchIn: // cerr << "PunchIN at " << transport_frame() << endl; - if (Config->get_punch_in() && record_status() == Enabled) { + if (config.get_punch_in() && record_status() == Enabled) { enable_record (); } remove = false; @@ -375,7 +375,7 @@ Session::process_event (Event* ev) case Event::PunchOut: // cerr << "PunchOUT at " << transport_frame() << endl; - if (Config->get_punch_out()) { + if (config.get_punch_out()) { step_back_from_record (); } remove = false; diff --git a/libs/ardour/session_midi.cc b/libs/ardour/session_midi.cc index b0d6ed9347..6c0c48f50e 100644 --- a/libs/ardour/session_midi.cc +++ b/libs/ardour/session_midi.cc @@ -801,7 +801,7 @@ Session::send_full_time_code(nframes_t nframes) // I don't understand this bit yet.. [DR] if (((mtc_smpte_bits >> 5) != MIDI::MTC_25_FPS) && (transmitting_smpte_time.frames % 2)) { // start MTC quarter frame transmission on an even frame - SMPTE::increment( transmitting_smpte_time ); + SMPTE::increment( transmitting_smpte_time, config.get_subframes_per_frame() ); outbound_mtc_smpte_frame += (nframes_t) _frames_per_smpte_frame; } @@ -928,8 +928,8 @@ Session::send_midi_time_code_for_cycle(nframes_t nframes) // Wrap quarter frame counter next_quarter_frame_to_send = 0; // Increment smpte time twice - SMPTE::increment( transmitting_smpte_time ); - SMPTE::increment( transmitting_smpte_time ); + SMPTE::increment( transmitting_smpte_time, config.get_subframes_per_frame() ); + SMPTE::increment( transmitting_smpte_time, config.get_subframes_per_frame() ); // Re-calculate timing of first quarter frame //smpte_to_sample( transmitting_smpte_time, outbound_mtc_smpte_frame, true /* use_offset */, false ); outbound_mtc_smpte_frame += 8 * quarter_frame_duration; diff --git a/libs/ardour/session_process.cc b/libs/ardour/session_process.cc index eb192f6dc9..eb986a3d83 100644 --- a/libs/ardour/session_process.cc +++ b/libs/ardour/session_process.cc @@ -508,7 +508,7 @@ Session::follow_slave (nframes_t nframes) slave_speed = 0.0f; } - if (_slave->is_always_synced() || Config->get_timecode_source_is_synced()) { + if (_slave->is_always_synced() || config.get_timecode_source_is_synced()) { /* if the TC source is synced, then we assume that its speed is binary: 0.0 or 1.0 @@ -530,7 +530,7 @@ Session::follow_slave (nframes_t nframes) track_slave_state(slave_speed, slave_transport_frame, this_delta, starting); - if (slave_state == Running && !_slave->is_always_synced() && !Config->get_timecode_source_is_synced()) { + if (slave_state == Running && !_slave->is_always_synced() && !config.get_timecode_source_is_synced()) { if (_transport_speed != 0.0f) { diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 7d14035c93..c7cb3fc5a1 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -163,7 +163,6 @@ Session::first_stage_init (string fullpath, string snapshot_name) _transport_frame = 0; end_location = new Location (0, 0, _("end"), Location::Flags ((Location::IsMark|Location::IsEnd))); start_location = new Location (0, 0, _("start"), Location::Flags ((Location::IsMark|Location::IsStart))); - _end_location_is_free = true; g_atomic_int_set (&_record_status, Disabled); loop_changing = false; play_loop = false; @@ -214,8 +213,8 @@ Session::first_stage_init (string fullpath, string snapshot_name) /* default short fade = 15ms */ - Crossfade::set_short_xfade_length ((nframes_t) floor (Config->get_short_xfade_seconds() * frame_rate())); - SndFileSource::setup_standard_crossfades (frame_rate()); + Crossfade::set_short_xfade_length ((nframes_t) floor (config.get_short_xfade_seconds() * frame_rate())); + SndFileSource::setup_standard_crossfades (*this, frame_rate()); last_mmc_step.tv_sec = 0; last_mmc_step.tv_usec = 0; @@ -363,11 +362,7 @@ Session::second_stage_init (bool new_session) ControlProtocolManager::instance().set_session (*this); - if (new_session) { - _end_location_is_free = true; - } else { - _end_location_is_free = false; - } + config.set_end_marker_is_free (new_session); _state_of_the_state = Clean; @@ -861,7 +856,7 @@ Session::load_options (const XMLNode& node) XMLProperty* prop; LocaleGuard lg (X_("POSIX")); - Config->set_variables (node, ConfigVariableBase::Session); + config.set_variables (node); /* now reset MIDI ports because the session can have its own MIDI configuration. @@ -869,38 +864,9 @@ Session::load_options (const XMLNode& node) setup_midi (); - if ((child = find_named_node (node, "end-marker-is-free")) != 0) { - if ((prop = child->property ("val")) != 0) { - _end_location_is_free = (prop->value() == "yes"); - } - } - return 0; } -bool -Session::save_config_options_predicate (ConfigVariableBase::Owner owner) const -{ - const ConfigVariableBase::Owner modified_by_session_or_user = (ConfigVariableBase::Owner) - (ConfigVariableBase::Session|ConfigVariableBase::Interface); - - return owner & modified_by_session_or_user; -} - -XMLNode& -Session::get_options () const -{ - XMLNode* child; - LocaleGuard lg (X_("POSIX")); - - XMLNode& option_root = Config->get_variables (mem_fun (*this, &Session::save_config_options_predicate)); - - child = option_root.add_child ("end-marker-is-free"); - child->add_property ("val", _end_location_is_free ? "yes" : "no"); - - return option_root; -} - XMLNode& Session::get_state() { @@ -976,7 +942,7 @@ Session::state(bool full_state) /* various options */ - node->add_child_nocopy (get_options()); + node->add_child_nocopy (config.get_variables ()); node->add_child_nocopy (_metadata->get_state()); @@ -3055,7 +3021,7 @@ Session::config_changed (const char* parameter_name) for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { if ((*i)->record_enabled ()) { - (*i)->monitor_input (!Config->get_auto_input()); + (*i)->monitor_input (!config.get_auto_input()); } } } @@ -3066,7 +3032,7 @@ Session::config_changed (const char* parameter_name) if ((location = _locations.auto_punch_location()) != 0) { - if (Config->get_punch_in ()) { + if (config.get_punch_in ()) { replace_event (Event::PunchIn, location->start()); } else { remove_event (location->start(), Event::PunchIn); @@ -3079,7 +3045,7 @@ Session::config_changed (const char* parameter_name) if ((location = _locations.auto_punch_location()) != 0) { - if (Config->get_punch_out()) { + if (config.get_punch_out()) { replace_event (Event::PunchOut, location->end()); } else { clear_events (Event::PunchOut); @@ -3120,7 +3086,7 @@ Session::config_changed (const char* parameter_name) } else if (PARAM_IS ("raid-path")) { - setup_raid_path (Config->get_raid_path()); + setup_raid_path (config.get_raid_path()); } else if (PARAM_IS ("smpte-format")) { diff --git a/libs/ardour/session_time.cc b/libs/ardour/session_time.cc index 264ce10c82..223c30bd1a 100644 --- a/libs/ardour/session_time.cc +++ b/libs/ardour/session_time.cc @@ -52,7 +52,7 @@ Session::bbt_time (nframes_t when, BBT_Time& bbt) float Session::smpte_frames_per_second() const { - switch (Config->get_smpte_format()) { + switch (config.get_smpte_format()) { case smpte_23976: return 23.976; @@ -101,7 +101,7 @@ Session::smpte_frames_per_second() const bool Session::smpte_drop_frames() const { - switch (Config->get_smpte_format()) { + switch (config.get_smpte_format()) { case smpte_23976: return false; @@ -185,7 +185,7 @@ int Session::set_smpte_format (SmpteFormat format) { /* this will trigger any other changes needed */ - Config->set_smpte_format (format); + config.set_smpte_format (format); return 0; } @@ -272,7 +272,7 @@ Session::smpte_to_sample( SMPTE::Time& smpte, nframes_t& sample, bool use_offset } if (use_subframes) { - sample += (long) (((double)smpte.subframes * _frames_per_smpte_frame) / Config->get_subframes_per_frame()); + sample += (long) (((double)smpte.subframes * _frames_per_smpte_frame) / config.get_subframes_per_frame()); } if (use_offset) { @@ -334,10 +334,10 @@ Session::sample_to_smpte( nframes_t sample, SMPTE::Time& smpte, bool use_offset, // Calculate exact number of (exceeding) smpte frames and fractional frames smpte_frames_left_exact = (double) offset_sample / _frames_per_smpte_frame; smpte_frames_fraction = smpte_frames_left_exact - floor( smpte_frames_left_exact ); - smpte.subframes = (long) rint(smpte_frames_fraction * Config->get_subframes_per_frame()); + smpte.subframes = (long) rint(smpte_frames_fraction * config.get_subframes_per_frame()); // XXX Not sure if this is necessary anymore... - if (smpte.subframes == Config->get_subframes_per_frame()) { + if (smpte.subframes == config.get_subframes_per_frame()) { // This can happen with 24 fps (and 29.97 fps ?) smpte_frames_left_exact = ceil( smpte_frames_left_exact ); smpte.subframes = 0; diff --git a/libs/ardour/session_transport.cc b/libs/ardour/session_transport.cc index 790d990bc2..ccdbbb3ef6 100644 --- a/libs/ardour/session_transport.cc +++ b/libs/ardour/session_transport.cc @@ -184,7 +184,7 @@ Session::realtime_stop (bool abort) waiting_for_sync_offset = true; } - transport_sub_state = ((Config->get_slave_source() == None && Config->get_auto_return()) ? AutoReturning : 0); + transport_sub_state = ((Config->get_slave_source() == None && config.get_auto_return()) ? AutoReturning : 0); } void @@ -345,7 +345,7 @@ Session::non_realtime_stop (bool abort, int on_entry, bool& finished) /* stopped recording before current end */ - if (_end_location_is_free) { + if (config.get_end_marker_is_free()) { /* first capture for this session, move end back to where we are */ @@ -366,7 +366,7 @@ Session::non_realtime_stop (bool abort, int on_entry, bool& finished) add_command (new MementoCommand<Location>(*loc, &before, &after)); } - _end_location_is_free = false; + config.set_end_marker_is_free (false); _have_captured = true; } @@ -391,7 +391,7 @@ Session::non_realtime_stop (bool abort, int on_entry, bool& finished) } bool const auto_return_enabled = - (Config->get_slave_source() == None && Config->get_auto_return()); + (Config->get_slave_source() == None && config.get_auto_return()); if (auto_return_enabled || (post_transport_work & PostTransportLocate) || @@ -705,7 +705,7 @@ Session::locate (nframes_t target_frame, bool with_roll, bool with_flush, bool w } } - if (transport_rolling() && (!auto_play_legal || !Config->get_auto_play()) && !with_roll && !(synced_to_jack() && play_loop)) { + if (transport_rolling() && (!auto_play_legal || !config.get_auto_play()) && !with_roll && !(synced_to_jack() && play_loop)) { realtime_stop (false); } @@ -744,7 +744,7 @@ Session::locate (nframes_t target_frame, bool with_roll, bool with_flush, bool w for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { if ((*i)->record_enabled ()) { //cerr << "switching from input" << __FILE__ << __LINE__ << endl << endl; - (*i)->monitor_input (!Config->get_auto_input()); + (*i)->monitor_input (!config.get_auto_input()); } } } @@ -851,7 +851,7 @@ Session::set_transport_speed (double speed, bool abort) boost::shared_ptr<DiskstreamList> dsl = diskstreams.reader(); for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - if (Config->get_auto_input() && (*i)->record_enabled ()) { + if (config.get_auto_input() && (*i)->record_enabled ()) { //cerr << "switching from input" << __FILE__ << __LINE__ << endl << endl; (*i)->monitor_input (false); } @@ -969,7 +969,7 @@ Session::start_transport () switch (record_status()) { case Enabled: - if (!Config->get_punch_in()) { + if (!config.get_punch_in()) { enable_record (); } break; @@ -1022,7 +1022,7 @@ Session::post_transport () if (post_transport_work & PostTransportLocate) { - if (((Config->get_slave_source() == None && (auto_play_legal && Config->get_auto_play())) && !_exporting) || (post_transport_work & PostTransportRoll)) { + if (((Config->get_slave_source() == None && (auto_play_legal && config.get_auto_play())) && !_exporting) || (post_transport_work & PostTransportRoll)) { start_transport (); } else { diff --git a/libs/ardour/sndfilesource.cc b/libs/ardour/sndfilesource.cc index 6002f95cb9..234f55f30b 100644 --- a/libs/ardour/sndfilesource.cc +++ b/libs/ardour/sndfilesource.cc @@ -32,6 +32,8 @@ #include "ardour/sndfile_helpers.h" #include "ardour/utils.h" #include "ardour/version.h" +#include "ardour/rc_configuration.h" +#include "ardour/session.h" #include "i18n.h" @@ -517,7 +519,7 @@ SndFileSource::setup_broadcast_info (sframes_t when, struct tm& now, time_t tnow return 0; } - _broadcast_info->set_originator_ref (); + _broadcast_info->set_originator_ref (_session); _broadcast_info->set_origination_time (&now); /* now update header position taking header offset into account */ @@ -773,13 +775,13 @@ SndFileSource::handle_header_position_change () } void -SndFileSource::setup_standard_crossfades (nframes_t rate) +SndFileSource::setup_standard_crossfades (Session const & s, nframes_t rate) { /* This static method is assumed to have been called by the Session before any DFS's are created. */ - xfade_frames = (nframes_t) floor ((Config->get_destructive_xfade_msecs () / 1000.0) * rate); + xfade_frames = (nframes_t) floor ((s.config.get_destructive_xfade_msecs () / 1000.0) * rate); delete [] out_coefficient; delete [] in_coefficient; diff --git a/libs/ardour/source_factory.cc b/libs/ardour/source_factory.cc index d6ce7ba033..544b04e1c7 100644 --- a/libs/ardour/source_factory.cc +++ b/libs/ardour/source_factory.cc @@ -26,8 +26,9 @@ #include "ardour/source_factory.h" #include "ardour/sndfilesource.h" #include "ardour/silentfilesource.h" -#include "ardour/configuration.h" +#include "ardour/rc_configuration.h" #include "ardour/smf_source.h" +#include "ardour/session.h" #ifdef HAVE_COREAUDIO #define USE_COREAUDIO_FOR_FILES @@ -246,8 +247,8 @@ SourceFactory::createWritable (DataType type, Session& s, const std::string& pat if (type == DataType::AUDIO) { boost::shared_ptr<Source> ret (new SndFileSource (s, path, embedded, - Config->get_native_file_data_format(), - Config->get_native_file_header_format(), + s.config.get_native_file_data_format(), + s.config.get_native_file_header_format(), rate, (destructive ? Source::Flag (SndFileSource::default_writable_flags | Source::Destructive) diff --git a/libs/ardour/track.cc b/libs/ardour/track.cc index fd9267ede4..fa3193cba3 100644 --- a/libs/ardour/track.cc +++ b/libs/ardour/track.cc @@ -275,7 +275,7 @@ Track::no_roll (nframes_t nframes, sframes_t start_frame, sframes_t end_frame, they monitor input always when stopped.and auto-input is engaged. */ if ((Config->get_monitoring_model() == SoftwareMonitoring) - && (Config->get_auto_input () || _diskstream->record_enabled())) { + && (_session.config.get_auto_input () || _diskstream->record_enabled())) { send_silence = false; } else { send_silence = true; diff --git a/libs/ardour/utils.cc b/libs/ardour/utils.cc index 7320f3c7f3..052d583976 100644 --- a/libs/ardour/utils.cc +++ b/libs/ardour/utils.cc @@ -378,19 +378,6 @@ slave_source_to_string (SlaveSource src) } } -/* I don't really like hard-coding these falloff rates here - * Probably should use a map of some kind that could be configured - * These rates are db/sec. -*/ - -#define METER_FALLOFF_OFF 0.0f -#define METER_FALLOFF_SLOWEST 6.6f // BBC standard -#define METER_FALLOFF_SLOW 8.6f // BBC standard -#define METER_FALLOFF_MEDIUM 20.0f -#define METER_FALLOFF_FAST 32.0f -#define METER_FALLOFF_FASTER 46.0f -#define METER_FALLOFF_FASTEST 70.0f - float meter_falloff_to_float (MeterFalloff falloff) { diff --git a/libs/ardour/wscript b/libs/ardour/wscript index 85187680d8..7079a64a08 100644 --- a/libs/ardour/wscript +++ b/libs/ardour/wscript @@ -171,6 +171,7 @@ def build(bld): port_set.cc processor.cc quantize.cc + rc_configuration.cc recent_sessions.cc region.cc region_factory.cc @@ -184,6 +185,7 @@ def build(bld): session_butler.cc session_click.cc session_command.cc + session_configuration.cc session_directory.cc session_events.cc session_export.cc diff --git a/libs/surfaces/control_protocol/basic_ui.cc b/libs/surfaces/control_protocol/basic_ui.cc index a0eeda5a96..2eda08acf7 100644 --- a/libs/surfaces/control_protocol/basic_ui.cc +++ b/libs/surfaces/control_protocol/basic_ui.cc @@ -220,13 +220,13 @@ BasicUI::toggle_all_rec_enables () void BasicUI::toggle_punch_in () { - Config->set_punch_in (!Config->get_punch_in()); + session->config.set_punch_in (!session->config.get_punch_in()); } void BasicUI::toggle_punch_out () { - Config->set_punch_out (!Config->get_punch_out()); + session->config.set_punch_out (!session->config.get_punch_out()); } bool diff --git a/libs/surfaces/control_protocol/control_protocol/smpte.h b/libs/surfaces/control_protocol/control_protocol/smpte.h index b25a268aac..7493ccf85f 100644 --- a/libs/surfaces/control_protocol/control_protocol/smpte.h +++ b/libs/surfaces/control_protocol/control_protocol/smpte.h @@ -53,13 +53,13 @@ struct Time { } }; -Wrap increment( Time& smpte ); -Wrap decrement( Time& smpte ); -Wrap increment_subframes( Time& smpte ); -Wrap decrement_subframes( Time& smpte ); -Wrap increment_seconds( Time& smpte ); -Wrap increment_minutes( Time& smpte ); -Wrap increment_hours( Time& smpte ); +Wrap increment( Time& smpte, uint32_t ); +Wrap decrement( Time& smpte, uint32_t ); +Wrap increment_subframes( Time& smpte, uint32_t ); +Wrap decrement_subframes( Time& smpte, uint32_t ); +Wrap increment_seconds( Time& smpte, uint32_t ); +Wrap increment_minutes( Time& smpte, uint32_t ); +Wrap increment_hours( Time& smpte, uint32_t ); void frames_floor( Time& smpte ); void seconds_floor( Time& smpte ); void minutes_floor( Time& smpte ); diff --git a/libs/surfaces/control_protocol/smpte.cc b/libs/surfaces/control_protocol/smpte.cc index 5df159a52b..969c3385bc 100644 --- a/libs/surfaces/control_protocol/smpte.cc +++ b/libs/surfaces/control_protocol/smpte.cc @@ -19,8 +19,8 @@ #define SMPTE_IS_AROUND_ZERO( sm ) (!(sm).frames && !(sm).seconds && !(sm).minutes && !(sm).hours) #define SMPTE_IS_ZERO( sm ) (!(sm).frames && !(sm).seconds && !(sm).minutes && !(sm).hours && !(sm.subframes)) -#include <control_protocol/smpte.h> -#include <ardour/configuration.h> +#include "control_protocol/smpte.h" +#include "ardour/rc_configuration.h" namespace SMPTE { @@ -32,20 +32,20 @@ float Time::default_rate = 30.0; * @return true if seconds wrap. */ Wrap -increment( Time& smpte ) +increment( Time& smpte, uint32_t subframes_per_frame ) { Wrap wrap = NONE; if (smpte.negative) { if (SMPTE_IS_AROUND_ZERO(smpte) && smpte.subframes) { // We have a zero transition involving only subframes - smpte.subframes = ARDOUR::Config->get_subframes_per_frame() - smpte.subframes; + smpte.subframes = subframes_per_frame - smpte.subframes; smpte.negative = false; return SECONDS; } smpte.negative = false; - wrap = decrement( smpte ); + wrap = decrement( smpte, subframes_per_frame ); if (!SMPTE_IS_ZERO( smpte )) { smpte.negative = true; } @@ -118,19 +118,19 @@ increment( Time& smpte ) * Realtime safe. * @return true if seconds wrap. */ Wrap -decrement( Time& smpte ) +decrement( Time& smpte, uint32_t subframes_per_frame ) { Wrap wrap = NONE; if (smpte.negative || SMPTE_IS_ZERO(smpte)) { smpte.negative = false; - wrap = increment( smpte ); + wrap = increment( smpte, subframes_per_frame ); smpte.negative = true; return wrap; } else if (SMPTE_IS_AROUND_ZERO(smpte) && smpte.subframes) { // We have a zero transition involving only subframes - smpte.subframes = ARDOUR::Config->get_subframes_per_frame() - smpte.subframes; + smpte.subframes = subframes_per_frame - smpte.subframes; smpte.negative = true; return SECONDS; } @@ -215,13 +215,13 @@ frames_floor( Time& smpte ) /** Increment @a smpte by one subframe */ Wrap -increment_subframes( Time& smpte ) +increment_subframes( Time& smpte, uint32_t subframes_per_frame ) { Wrap wrap = NONE; if (smpte.negative) { smpte.negative = false; - wrap = decrement_subframes( smpte ); + wrap = decrement_subframes( smpte, subframes_per_frame ); if (!SMPTE_IS_ZERO(smpte)) { smpte.negative = true; } @@ -229,9 +229,9 @@ increment_subframes( Time& smpte ) } smpte.subframes++; - if (smpte.subframes >= ARDOUR::Config->get_subframes_per_frame()) { + if (smpte.subframes >= subframes_per_frame) { smpte.subframes = 0; - increment( smpte ); + increment( smpte, subframes_per_frame ); return FRAMES; } return NONE; @@ -240,13 +240,13 @@ increment_subframes( Time& smpte ) /** Decrement @a smpte by one subframe */ Wrap -decrement_subframes( Time& smpte ) +decrement_subframes( Time& smpte, uint32_t subframes_per_frame ) { Wrap wrap = NONE; if (smpte.negative) { smpte.negative = false; - wrap = increment_subframes( smpte ); + wrap = increment_subframes( smpte, subframes_per_frame ); smpte.negative = true; return wrap; } @@ -258,7 +258,7 @@ decrement_subframes( Time& smpte ) smpte.subframes = 1; return FRAMES; } else { - decrement( smpte ); + decrement( smpte, subframes_per_frame ); smpte.subframes = 79; return FRAMES; } @@ -274,7 +274,7 @@ decrement_subframes( Time& smpte ) /** Go to next whole second (frames == 0 or frames == 2) */ Wrap -increment_seconds( Time& smpte ) +increment_seconds( Time& smpte, uint32_t subframes_per_frame ) { Wrap wrap = NONE; @@ -283,7 +283,7 @@ increment_seconds( Time& smpte ) if (smpte.negative) { // Wrap second if on second boundary - wrap = increment(smpte); + wrap = increment(smpte, subframes_per_frame); // Go to lowest absolute frame value seconds_floor( smpte ); if (SMPTE_IS_ZERO(smpte)) { @@ -307,7 +307,7 @@ increment_seconds( Time& smpte ) } // Increment by one frame - wrap = increment( smpte ); + wrap = increment( smpte, subframes_per_frame ); } return wrap; @@ -349,7 +349,7 @@ seconds_floor( Time& smpte ) /** Go to next whole minute (seconds == 0, frames == 0 or frames == 2) */ Wrap -increment_minutes( Time& smpte ) +increment_minutes( Time& smpte, uint32_t subframes_per_frame ) { Wrap wrap = NONE; @@ -358,14 +358,14 @@ increment_minutes( Time& smpte ) if (smpte.negative) { // Wrap if on minute boundary - wrap = increment_seconds( smpte ); + wrap = increment_seconds( smpte, subframes_per_frame ); // Go to lowest possible value in this minute minutes_floor( smpte ); } else { // Go to highest possible second smpte.seconds = 59; // Wrap minute by incrementing second - wrap = increment_seconds( smpte ); + wrap = increment_seconds( smpte, subframes_per_frame ); } return wrap; @@ -389,7 +389,7 @@ minutes_floor( Time& smpte ) /** Go to next whole hour (minute = 0, second = 0, frame = 0) */ Wrap -increment_hours( Time& smpte ) +increment_hours( Time& smpte, uint32_t subframes_per_frame ) { Wrap wrap = NONE; @@ -398,12 +398,12 @@ increment_hours( Time& smpte ) if (smpte.negative) { // Wrap if on hour boundary - wrap = increment_minutes( smpte ); + wrap = increment_minutes( smpte, subframes_per_frame ); // Go to lowest possible value in this hour hours_floor( smpte ); } else { smpte.minutes = 59; - wrap = increment_minutes( smpte ); + wrap = increment_minutes( smpte, subframes_per_frame ); } return wrap; |