diff options
author | David Robillard <d@drobilla.net> | 2007-09-06 02:30:39 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-09-06 02:30:39 +0000 |
commit | c190aca4a0debe1220558d14afb8f1ab4adb959f (patch) | |
tree | 1c2749473afe96f41cd99d1036533342db98a1ba /libs/ardour | |
parent | 7423ad46a742fbfd03ee4e54e78167c9006a2e8d (diff) |
Deep "automation regions" support.
Fix zoom/height/etc changing for automation region views.
Broke smooth automation region dragging (make omelette, break eggs, etc).
git-svn-id: svn://localhost/ardour2/trunk@2424 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour')
-rw-r--r-- | libs/ardour/ardour/audioregion.h | 2 | ||||
-rw-r--r-- | libs/ardour/ardour/midi_region.h | 12 | ||||
-rw-r--r-- | libs/ardour/ardour/region.h | 13 | ||||
-rw-r--r-- | libs/ardour/ardour/smf_source.h | 4 | ||||
-rw-r--r-- | libs/ardour/audio_library.cc | 8 | ||||
-rw-r--r-- | libs/ardour/audioregion.cc | 4 | ||||
-rw-r--r-- | libs/ardour/crossfade.cc | 6 | ||||
-rw-r--r-- | libs/ardour/midi_model.cc | 2 | ||||
-rw-r--r-- | libs/ardour/plugin_manager.cc | 4 | ||||
-rw-r--r-- | libs/ardour/region.cc | 31 | ||||
-rw-r--r-- | libs/ardour/smf_source.cc | 6 |
11 files changed, 53 insertions, 39 deletions
diff --git a/libs/ardour/ardour/audioregion.h b/libs/ardour/ardour/audioregion.h index ddda1f4321..ba2bbaee22 100644 --- a/libs/ardour/ardour/audioregion.h +++ b/libs/ardour/ardour/audioregion.h @@ -170,7 +170,7 @@ class AudioRegion : public Region protected: /* default constructor for derived (compound) types */ - AudioRegion (nframes_t, nframes_t, std::string name); + AudioRegion (Session& s, nframes_t, nframes_t, std::string name); AudioRegion (boost::shared_ptr<const AudioRegion>); int set_live_state (const XMLNode&, Change&, bool send); diff --git a/libs/ardour/ardour/midi_region.h b/libs/ardour/ardour/midi_region.h index 294c2d3291..869436e423 100644 --- a/libs/ardour/ardour/midi_region.h +++ b/libs/ardour/ardour/midi_region.h @@ -31,6 +31,7 @@ #include <ardour/gain.h> #include <ardour/logcurve.h> #include <ardour/export.h> +#include <ardour/midi_source.h> class XMLNode; @@ -69,6 +70,17 @@ class MidiRegion : public Region UndoAction get_memento() const; + // Act as a proxy for MidiModel automation stuff (for CC) + // Yep, this is pretty ugly... + Controls& controls() { return midi_source()->model()->controls(); } + const Controls& controls() const { return midi_source()->model()->controls(); } + + boost::shared_ptr<AutomationControl> control(Parameter id, bool create_if_missing=false) + { return midi_source()->model()->control(id, create_if_missing); } + + boost::shared_ptr<const AutomationControl> control(Parameter id) const + { return midi_source()->model()->control(id); } + private: friend class RegionFactory; diff --git a/libs/ardour/ardour/region.h b/libs/ardour/ardour/region.h index 496dc7874e..e62b59ca61 100644 --- a/libs/ardour/ardour/region.h +++ b/libs/ardour/ardour/region.h @@ -25,10 +25,10 @@ #include <boost/enable_shared_from_this.hpp> #include <pbd/undo.h> -#include <pbd/statefuldestructible.h> #include <ardour/ardour.h> #include <ardour/data_type.h> +#include <ardour/automatable.h> class XMLNode; @@ -43,7 +43,7 @@ enum RegionEditState { EditChangesID = 2 }; -class Region : public PBD::StatefulDestructible, public boost::enable_shared_from_this<Region> +class Region : public Automatable, public boost::enable_shared_from_this<Region> { public: typedef std::vector<boost::shared_ptr<Source> > SourceList; @@ -86,10 +86,8 @@ class Region : public PBD::StatefulDestructible, public boost::enable_shared_fro virtual ~Region(); - /* Note: changing the name of a Region does not constitute an edit */ - - string name() const { return _name; } - void set_name (string str); + /** Note: changing the name of a Region does not constitute an edit */ + bool set_name (const std::string& str); const DataType& data_type() const { return _type; } @@ -214,7 +212,7 @@ class Region : public PBD::StatefulDestructible, public boost::enable_shared_fro /* this one is for derived types of derived types */ - Region (nframes_t start, nframes_t length, const string& name, DataType, layer_t = 0, Flag flags = DefaultFlags); + Region (Session& s, nframes_t start, nframes_t length, const string& name, DataType, layer_t = 0, Flag flags = DefaultFlags); protected: XMLNode& get_short_state (); /* used only by Session */ @@ -234,7 +232,6 @@ class Region : public PBD::StatefulDestructible, public boost::enable_shared_fro virtual void recompute_at_start () = 0; virtual void recompute_at_end () = 0; - string _name; DataType _type; Flag _flags; nframes_t _start; diff --git a/libs/ardour/ardour/smf_source.h b/libs/ardour/ardour/smf_source.h index bf5618d57a..302fb15838 100644 --- a/libs/ardour/ardour/smf_source.h +++ b/libs/ardour/ardour/smf_source.h @@ -110,8 +110,8 @@ class SMFSource : public MidiSource { void seek_to_end(); void write_footer(); - void write_chunk_header(char id[4], uint32_t length); - void write_chunk(char id[4], uint32_t length, void* data); + void write_chunk_header(const char id[4], uint32_t length); + void write_chunk(const char id[4], uint32_t length, void* data); size_t write_var_len(uint32_t val); uint32_t read_var_len() const; int read_event(uint32_t* delta_t, uint32_t* size, Byte** buf) const; diff --git a/libs/ardour/audio_library.cc b/libs/ardour/audio_library.cc index c5240988a8..a35846ab29 100644 --- a/libs/ardour/audio_library.cc +++ b/libs/ardour/audio_library.cc @@ -40,7 +40,7 @@ namespace { const char* const sfdb_file_name = "sfdb"; } // anonymous namespace -static char* TAG = "http://ardour.org/ontology/Tag"; +static const char* TAG = "http://ardour.org/ontology/Tag"; AudioLibrary::AudioLibrary () { @@ -91,7 +91,7 @@ AudioLibrary::get_tags (string member) lrdf_statement pattern; pattern.subject = strdup(Glib::filename_to_uri(member).c_str()); - pattern.predicate = TAG; + pattern.predicate = (char*)TAG; pattern.object = 0; pattern.object_type = lrdf_literal; @@ -123,8 +123,8 @@ AudioLibrary::search_members_and (vector<string>& members, const vector<string> vector<string>::const_iterator i; for (i = tags.begin(); i != tags.end(); ++i){ pattern = new lrdf_statement; - pattern->subject = "?"; - pattern->predicate = TAG; + pattern->subject = (char*)"?"; + pattern->predicate = (char*)TAG; pattern->object = strdup((*i).c_str()); pattern->next = old; diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc index 58ece331c3..7ac14f1dda 100644 --- a/libs/ardour/audioregion.cc +++ b/libs/ardour/audioregion.cc @@ -70,8 +70,8 @@ AudioRegion::init () } /* constructor for use by derived types only */ -AudioRegion::AudioRegion (nframes_t start, nframes_t length, string name) - : Region (start, length, name, DataType::AUDIO) +AudioRegion::AudioRegion (Session& s, nframes_t start, nframes_t length, string name) + : Region (s, start, length, name, DataType::AUDIO) , _fade_in (new AutomationList(Parameter(FadeInAutomation), 0.0, 2.0, 1.0)) , _fade_out (new AutomationList(Parameter(FadeOutAutomation), 0.0, 2.0, 1.0)) , _envelope (new AutomationList(Parameter(EnvelopeAutomation), 0.0, 2.0, 1.0)) diff --git a/libs/ardour/crossfade.cc b/libs/ardour/crossfade.cc index f69ec99f8d..556f11125e 100644 --- a/libs/ardour/crossfade.cc +++ b/libs/ardour/crossfade.cc @@ -77,7 +77,7 @@ Crossfade::Crossfade (boost::shared_ptr<AudioRegion> in, boost::shared_ptr<Audio nframes_t length, nframes_t position, AnchorPoint ap) - : AudioRegion (position, length, "foobar"), + : AudioRegion (in->session(), position, length, "foobar"), _fade_in (Parameter(FadeInAutomation), 0.0, 2.0, 1.0), // linear (gain coefficient) => -inf..+6dB _fade_out (Parameter(FadeOutAutomation), 0.0, 2.0, 1.0) // linear (gain coefficient) => -inf..+6dB @@ -95,7 +95,7 @@ Crossfade::Crossfade (boost::shared_ptr<AudioRegion> in, boost::shared_ptr<Audio } Crossfade::Crossfade (boost::shared_ptr<AudioRegion> a, boost::shared_ptr<AudioRegion> b, CrossfadeModel model, bool act) - : AudioRegion (0, 0, "foobar"), + : AudioRegion (a->session(), 0, 0, "foobar"), _fade_in (Parameter(FadeInAutomation), 0.0, 2.0, 1.0), // linear (gain coefficient) => -inf..+6dB _fade_out (Parameter(FadeOutAutomation), 0.0, 2.0, 1.0) // linear (gain coefficient) => -inf..+6dB { @@ -114,7 +114,7 @@ Crossfade::Crossfade (boost::shared_ptr<AudioRegion> a, boost::shared_ptr<AudioR } Crossfade::Crossfade (const Playlist& playlist, XMLNode& node) - : AudioRegion (0, 0, "foobar"), + : AudioRegion (playlist.session(), 0, 0, "foobar"), _fade_in (Parameter(FadeInAutomation), 0.0, 2.0, 1.0), // linear (gain coefficient) => -inf..+6dB _fade_out (Parameter(FadeOutAutomation), 0.0, 2.0, 1.0) // linear (gain coefficient) => -inf..+6dB diff --git a/libs/ardour/midi_model.cc b/libs/ardour/midi_model.cc index 765d5f7cad..27910b44f5 100644 --- a/libs/ardour/midi_model.cc +++ b/libs/ardour/midi_model.cc @@ -223,7 +223,7 @@ MidiModel::read(MidiRingBuffer& dst, nframes_t start, nframes_t nframes, nframes if (start != _next_read) { _read_iter = const_iterator(*this, (double)start); - cerr << "Repositioning iterator from " << _next_read << " to " << start << endl; + // cerr << "Repositioning iterator from " << _next_read << " to " << start << endl; //} else { // cerr << "Using cached iterator at " << _next_read << endl; } diff --git a/libs/ardour/plugin_manager.cc b/libs/ardour/plugin_manager.cc index 3e7da5d9a2..dac8a9eead 100644 --- a/libs/ardour/plugin_manager.cc +++ b/libs/ardour/plugin_manager.cc @@ -287,7 +287,7 @@ PluginManager::get_ladspa_category (uint32_t plugin_id) snprintf(buf, sizeof(buf), "%s%" PRIu32, LADSPA_BASE, plugin_id); pattern.subject = buf; - pattern.predicate = RDF_TYPE; + pattern.predicate = (char*)RDF_TYPE; pattern.object = 0; pattern.object_type = lrdf_uri; @@ -298,7 +298,7 @@ PluginManager::get_ladspa_category (uint32_t plugin_id) } pattern.subject = matches1->object; - pattern.predicate = LADSPA_BASE "hasLabel"; + pattern.predicate = (char*)LADSPA_BASE "hasLabel"; pattern.object = 0; pattern.object_type = lrdf_literal; diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc index a828460bce..1809af671c 100644 --- a/libs/ardour/region.cc +++ b/libs/ardour/region.cc @@ -52,8 +52,8 @@ Change Region::HiddenChanged = ARDOUR::new_change (); /* derived-from-derived constructor (no sources in constructor) */ -Region::Region (nframes_t start, nframes_t length, const string& name, DataType type, layer_t layer, Region::Flag flags) - : _name(name) +Region::Region (Session& s, nframes_t start, nframes_t length, const string& name, DataType type, layer_t layer, Region::Flag flags) + : Automatable(s, name) , _type(type) , _flags(flags) , _start(start) @@ -73,7 +73,7 @@ Region::Region (nframes_t start, nframes_t length, const string& name, DataType /** Basic Region constructor (single source) */ Region::Region (boost::shared_ptr<Source> src, nframes_t start, nframes_t length, const string& name, DataType type, layer_t layer, Region::Flag flags) - : _name(name) + : Automatable(src->session(), name) , _type(type) , _flags(flags) , _start(start) @@ -97,7 +97,7 @@ Region::Region (boost::shared_ptr<Source> src, nframes_t start, nframes_t length /** Basic Region constructor (many sources) */ Region::Region (SourceList& srcs, nframes_t start, nframes_t length, const string& name, DataType type, layer_t layer, Region::Flag flags) - : _name(name) + : Automatable(srcs.front()->session(), name) , _type(type) , _flags(flags) , _start(start) @@ -132,7 +132,7 @@ Region::Region (SourceList& srcs, nframes_t start, nframes_t length, const strin /** Create a new Region from part of an existing one */ Region::Region (boost::shared_ptr<const Region> other, nframes_t offset, nframes_t length, const string& name, layer_t layer, Flag flags) - : _name(name) + : Automatable(other->session(), name) , _type(other->data_type()) , _flags(Flag(flags & ~(Locked|PositionLocked|WholeFile|Hidden))) , _start(other->_start + offset) @@ -173,7 +173,7 @@ Region::Region (boost::shared_ptr<const Region> other, nframes_t offset, nframes /** Pure copy constructor */ Region::Region (boost::shared_ptr<const Region> other) - : _name(other->_name) + : Automatable(other->session(), other->name()) , _type(other->data_type()) , _flags(Flag(other->_flags & ~(Locked|PositionLocked))) , _start(other->_start) @@ -214,7 +214,7 @@ Region::Region (boost::shared_ptr<const Region> other) } Region::Region (SourceList& srcs, const XMLNode& node) - : _name(X_("error: XML did not reset this")) + : Automatable(srcs.front()->session(), X_("error: XML did not reset this")) , _type(DataType::NIL) // to be loaded from XML , _flags(Flag(0)) , _start(0) @@ -252,7 +252,7 @@ Region::Region (SourceList& srcs, const XMLNode& node) } Region::Region (boost::shared_ptr<Source> src, const XMLNode& node) - : _name(X_("error: XML did not reset this")) + : Automatable(src->session(), X_("error: XML did not reset this")) , _type(DataType::NIL) , _flags(Flag(0)) , _start(0) @@ -323,13 +323,16 @@ Region::set_playlist (boost::weak_ptr<Playlist> wpl) } } -void -Region::set_name (string str) +bool +Region::set_name (const std::string& str) { if (_name != str) { - _name = str; - send_change (NameChanged); + SessionObject::set_name(str); // EMIT SIGNAL NameChanged() + assert(_name == str); + send_change (ARDOUR::NameChanged); } + + return true; } void @@ -383,7 +386,7 @@ Region::first_edit () _name = pl->session().new_region_name (_name); _first_edit = EditChangesNothing; - send_change (NameChanged); + send_change (ARDOUR::NameChanged); RegionFactory::CheckNewRegion (shared_from_this()); } } @@ -907,7 +910,7 @@ Region::state (bool full_state) { XMLNode *node = new XMLNode ("Region"); char buf[64]; - char* fe = NULL; + const char* fe = NULL; _id.print (buf, sizeof (buf)); node->add_property ("id", buf); diff --git a/libs/ardour/smf_source.cc b/libs/ardour/smf_source.cc index 0cfdd51feb..4ad8f80b4b 100644 --- a/libs/ardour/smf_source.cc +++ b/libs/ardour/smf_source.cc @@ -783,7 +783,7 @@ SMFSource::is_empty () const void -SMFSource::write_chunk_header(char id[4], uint32_t length) +SMFSource::write_chunk_header(const char id[4], uint32_t length) { const uint32_t length_be = GUINT32_TO_BE(length); @@ -792,7 +792,7 @@ SMFSource::write_chunk_header(char id[4], uint32_t length) } void -SMFSource::write_chunk(char id[4], uint32_t length, void* data) +SMFSource::write_chunk(const char id[4], uint32_t length, void* data) { write_chunk_header(id, length); @@ -857,6 +857,8 @@ SMFSource::load_model(bool lock, bool force_reload) //cerr << _name << " NOT reloading model " << _model.get() << " (" << _model->n_notes() // << " notes)" << endl; return; + } else { + cerr << _name << " loading model" << endl; } if (! _model) { |