From ea9ea68c9dc55f837a15dcd8c421033e804c9417 Mon Sep 17 00:00:00 2001 From: Ben Loftis Date: Sat, 13 Oct 2018 08:36:43 -0500 Subject: [PATCH] Take-ID: new (working) implementation. --- libs/ardour/ardour/file_source.h | 2 -- libs/ardour/ardour/source.h | 5 +++++ libs/ardour/disk_writer.cc | 8 ++++++++ libs/ardour/source.cc | 5 +++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/libs/ardour/ardour/file_source.h b/libs/ardour/ardour/file_source.h index 7452e9fb5b..976a28bee0 100644 --- a/libs/ardour/ardour/file_source.h +++ b/libs/ardour/ardour/file_source.h @@ -56,7 +56,6 @@ public: void mark_immutable_except_write(); void mark_nonremovable (); - const std::string& take_id () const { return _take_id; } bool within_session () const { return _within_session; } uint16_t channel() const { return _channel; } float gain() const { return _gain; } @@ -110,7 +109,6 @@ public: void set_within_session_from_path (const std::string&); std::string _path; - std::string _take_id; bool _file_is_new; uint16_t _channel; bool _within_session; diff --git a/libs/ardour/ardour/source.h b/libs/ardour/ardour/source.h index 1e1fde2f89..e3a386b97a 100644 --- a/libs/ardour/ardour/source.h +++ b/libs/ardour/ardour/source.h @@ -68,6 +68,9 @@ public: virtual samplecnt_t length (samplepos_t pos) const = 0; virtual void update_length (samplecnt_t cnt) = 0; + void set_take_id (std::string id) { _take_id =id; } + const std::string& take_id () const { return _take_id; } + virtual samplepos_t natural_position() const { return 0; } void mark_for_remove(); @@ -120,6 +123,7 @@ protected: DataType _type; Flag _flags; time_t _timestamp; + std::string _take_id; samplepos_t _timeline_position; bool _analysed; @@ -131,6 +135,7 @@ protected: std::string _ancestor_name; private: + void fix_writable_flags (); }; diff --git a/libs/ardour/disk_writer.cc b/libs/ardour/disk_writer.cc index 541d5ff3cb..e8c380f8d4 100644 --- a/libs/ardour/disk_writer.cc +++ b/libs/ardour/disk_writer.cc @@ -1216,6 +1216,10 @@ DiskWriter::transport_stopped_wallclock (struct tm& when, time_t twhen, bool abo as->set_captured_for (_name.val()); as->mark_immutable (); + char buf[128]; + strftime (buf, sizeof(buf), "%F %H.%M.%S", &when); + as->set_take_id ( buf ); + if (Config->get_auto_analyse_audio()) { Analyser::queue_source_for_analysis (as, true); } @@ -1258,6 +1262,10 @@ DiskWriter::transport_stopped_wallclock (struct tm& when, time_t twhen, bool abo _midi_write_source->set_timeline_position (capture_info.front()->start); _midi_write_source->set_captured_for (_name); + char buf[128]; + strftime (buf, sizeof(buf), "%F %H.%M.%S", &when); + _midi_write_source->set_take_id ( buf ); + /* set length in beats to entire capture length */ BeatsSamplesConverter converter (_session.tempo_map(), capture_info.front()->start); diff --git a/libs/ardour/source.cc b/libs/ardour/source.cc index 6ae1aca1ca..412f78c886 100644 --- a/libs/ardour/source.cc +++ b/libs/ardour/source.cc @@ -102,6 +102,7 @@ Source::get_state () XMLNode *node = new XMLNode ("Source"); node->set_property ("name", name()); + node->set_property ("take-id", take_id()); node->set_property ("type", _type); node->set_property (X_("flags"), _flags); node->set_property ("id", id()); @@ -137,6 +138,10 @@ Source::set_state (const XMLNode& node, int version) if (!node.get_property (X_("flags"), _flags)) { _flags = Flag (0); } + + if (!node.get_property (X_("take-id"), _take_id)) { + _take_id = ""; + } /* old style, from the period when we had DestructiveFileSource */ if (node.get_property (X_("destructive"), str)) {