From a4d7b45fe00996fd37a1af6d5be8c913a0b3bbf4 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 25 Feb 2020 21:35:07 -0700 Subject: remove destructive/tape mode tracks --- libs/ardour/ardour/audiofilesource.h | 5 +- libs/ardour/ardour/disk_io.h | 1 - libs/ardour/ardour/disk_writer.h | 4 - libs/ardour/ardour/file_source.h | 2 +- libs/ardour/ardour/session.h | 8 +- libs/ardour/ardour/session_configuration_vars.h | 1 - libs/ardour/ardour/silentfilesource.h | 1 - libs/ardour/ardour/sndfilesource.h | 24 +- libs/ardour/ardour/source.h | 3 +- libs/ardour/ardour/source_factory.h | 2 +- libs/ardour/ardour/srcfilesource.h | 1 - libs/ardour/ardour/track.h | 2 - libs/ardour/ardour/types.h | 1 - libs/ardour/audio_playlist_source.cc | 4 +- libs/ardour/audioregion.cc | 5 - libs/ardour/disk_writer.cc | 269 +--------------- libs/ardour/enums.cc | 3 - libs/ardour/file_source.cc | 18 +- libs/ardour/filter.cc | 2 +- libs/ardour/import.cc | 4 +- libs/ardour/lua_api.cc | 2 +- libs/ardour/luabindings.cc | 2 - libs/ardour/midi_playlist_source.cc | 4 +- libs/ardour/playlist_source.cc | 8 +- libs/ardour/region.cc | 8 +- libs/ardour/session.cc | 17 +- libs/ardour/session_state.cc | 11 +- libs/ardour/sndfilesource.cc | 351 +-------------------- libs/ardour/source.cc | 12 +- libs/ardour/source_factory.cc | 79 ++--- .../2 Track-template/2 Track-template.template | 1 - .../data/sessions/rec_enabled/rec_enabled.ardour | 1 - .../test/profiling/sessions/0tracks/0tracks.ardour | 1 - .../test/profiling/sessions/1region/1region.ardour | 1 - .../profiling/sessions/32tracks/32tracks.ardour | 1 - libs/ardour/track.cc | 24 -- libs/widgets/ardour_icon.cc | 70 ---- libs/widgets/widgets/ardour_icon.h | 1 - 38 files changed, 101 insertions(+), 853 deletions(-) (limited to 'libs') diff --git a/libs/ardour/ardour/audiofilesource.h b/libs/ardour/ardour/audiofilesource.h index 6ee2a93c46..df0bb96755 100644 --- a/libs/ardour/ardour/audiofilesource.h +++ b/libs/ardour/ardour/audiofilesource.h @@ -51,9 +51,6 @@ public: return safe_audio_file_extension(path); } - /* this block of methods do nothing for regular file sources, but are significant - for files used in destructive recording. - */ virtual samplepos_t last_capture_start_sample() const { return 0; } virtual void mark_capture_start (samplepos_t) {} virtual void mark_capture_end () {} @@ -72,7 +69,7 @@ public: XMLNode& get_state (); int set_state (const XMLNode&, int version); - bool can_truncate_peaks() const { return !destructive(); } + bool can_truncate_peaks() const { return true; } bool can_be_analysed() const { return _length > 0; } static bool safe_audio_file_extension (const std::string& path); diff --git a/libs/ardour/ardour/disk_io.h b/libs/ardour/ardour/disk_io.h index 1ae7cbfa94..83e5dd3f9b 100644 --- a/libs/ardour/ardour/disk_io.h +++ b/libs/ardour/ardour/disk_io.h @@ -54,7 +54,6 @@ public: enum Flag { Recordable = 0x1, Hidden = 0x2, - Destructive = 0x4, NonLayered = 0x8 // deprecated (kept only for enum compat) }; diff --git a/libs/ardour/ardour/disk_writer.h b/libs/ardour/ardour/disk_writer.h index fab54e2404..1d5820dbf5 100644 --- a/libs/ardour/ardour/disk_writer.h +++ b/libs/ardour/ardour/disk_writer.h @@ -97,8 +97,6 @@ public: void set_record_enabled (bool yn); void set_record_safe (bool yn); - bool destructive () const { return _flags & Destructive; } - /** @return Start position of currently-running capture (in session samples) */ samplepos_t current_capture_start () const { return _capture_start_sample; } samplepos_t current_capture_end () const { return _capture_start_sample + _capture_captured; } @@ -149,8 +147,6 @@ private: static samplecnt_t _chunk_samples; void prepare_record_status (samplepos_t /*capture_start_sample*/); - void setup_destructive_playlist (); - void use_destructive_playlist (); int add_channel_to (boost::shared_ptr, uint32_t how_many); diff --git a/libs/ardour/ardour/file_source.h b/libs/ardour/ardour/file_source.h index a5c4111d1c..265b2e14ee 100644 --- a/libs/ardour/ardour/file_source.h +++ b/libs/ardour/ardour/file_source.h @@ -66,7 +66,7 @@ public: int set_state (const XMLNode&, int version); - int set_source_name (const std::string& newname, bool destructive); + int set_source_name (const std::string& newname); static bool find (Session&, DataType type, const std::string& path, bool must_exist, bool& is_new, uint16_t& chan, diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index dad45a4480..f70f10a774 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -262,9 +262,9 @@ public: std::string construct_peak_filepath (const std::string& audio_path, const bool in_session = false, const bool old_peak_name = false) const; bool audio_source_name_is_unique (const std::string& name); - std::string format_audio_source_name (const std::string& legalized_base, uint32_t nchan, uint32_t chan, bool destructive, bool take_required, uint32_t cnt, bool related_exists); + std::string format_audio_source_name (const std::string& legalized_base, uint32_t nchan, uint32_t chan, bool take_required, uint32_t cnt, bool related_exists); std::string new_audio_source_path_for_embedded (const std::string& existing_path); - std::string new_audio_source_path (const std::string&, uint32_t nchans, uint32_t chan, bool destructive, bool take_required); + std::string new_audio_source_path (const std::string&, uint32_t nchans, uint32_t chan, bool take_required); std::string new_midi_source_path (const std::string&, bool need_source_lock = true); /** create a new track or bus from a template (XML path) @@ -841,7 +841,7 @@ public: static PBD::Signal0 AskAboutPendingState; boost::shared_ptr create_audio_source_for_session ( - size_t, std::string const &, uint32_t, bool destructive); + size_t, std::string const &, uint32_t); boost::shared_ptr create_midi_source_for_session (std::string const &); boost::shared_ptr create_midi_source_by_stealing_name (boost::shared_ptr); @@ -1761,8 +1761,6 @@ private: bool _reconnecting_routes_in_progress; bool _route_deletion_in_progress; - uint32_t destructive_index; - boost::shared_ptr XMLRouteFactory (const XMLNode&, int); boost::shared_ptr XMLRouteFactory_2X (const XMLNode&, int); boost::shared_ptr XMLRouteFactory_3X (const XMLNode&, int); diff --git a/libs/ardour/ardour/session_configuration_vars.h b/libs/ardour/ardour/session_configuration_vars.h index b481ef2f4a..3fa5a9776b 100644 --- a/libs/ardour/ardour/session_configuration_vars.h +++ b/libs/ardour/ardour/session_configuration_vars.h @@ -28,7 +28,6 @@ the value of the variable. *****************************************************/ -CONFIG_VARIABLE (uint32_t, destructive_xfade_msecs, "destructive-xfade-msecs", 2) CONFIG_VARIABLE (bool, use_region_fades, "use-region-fades", true) CONFIG_VARIABLE (bool, use_transport_fades, "use-transport-fades", true) CONFIG_VARIABLE (bool, use_monitor_fades, "use-monitor-fades", true) diff --git a/libs/ardour/ardour/silentfilesource.h b/libs/ardour/ardour/silentfilesource.h index 3be92bbf84..f0a32dc22f 100644 --- a/libs/ardour/ardour/silentfilesource.h +++ b/libs/ardour/ardour/silentfilesource.h @@ -37,7 +37,6 @@ public: void set_length (samplecnt_t len) { _length = len; } void flush () {} - bool destructive() const { return false; } bool can_be_analysed() const { return false; } bool clamped_at_unity() const { return false; } diff --git a/libs/ardour/ardour/sndfilesource.h b/libs/ardour/ardour/sndfilesource.h index a63f222f8a..be14e758c3 100644 --- a/libs/ardour/ardour/sndfilesource.h +++ b/libs/ardour/ardour/sndfilesource.h @@ -65,17 +65,11 @@ class LIBARDOUR_API SndFileSource : public AudioFileSource { int flush_header (); void flush (); - samplepos_t last_capture_start_sample() const; - void mark_capture_start (samplepos_t); - void mark_capture_end (); - void clear_capture_marks(); - bool one_of_several_channels () const; - uint32_t channel_count () const { return _info.channels; } + uint32_t channel_count () const { return _info.channels; } bool clamped_at_unity () const; - static void setup_standard_crossfades (Session const &, samplecnt_t sample_rate); static const Source::Flag default_writable_flags; static int get_soundfile_info (const std::string& path, SoundFileInfo& _info, std::string& error_msg); @@ -100,24 +94,8 @@ class LIBARDOUR_API SndFileSource : public AudioFileSource { int setup_broadcast_info (samplepos_t when, struct tm&, time_t); void file_closed (); - /* destructive */ - - static samplecnt_t xfade_samples; - - static gain_t* out_coefficient; - static gain_t* in_coefficient; - - bool _capture_start; - bool _capture_end; - samplepos_t capture_start_sample; - samplepos_t file_pos; // unit is samples - Sample* xfade_buf; - - samplecnt_t crossfade (Sample* data, samplecnt_t cnt, int dir); void set_natural_position (samplepos_t); - samplecnt_t destructive_write_unlocked (Sample *dst, samplecnt_t cnt); samplecnt_t nondestructive_write_unlocked (Sample *dst, samplecnt_t cnt); - void handle_header_position_change (); PBD::ScopedConnection header_position_connection; }; diff --git a/libs/ardour/ardour/source.h b/libs/ardour/ardour/source.h index 9604062b8e..e8dadf57bd 100644 --- a/libs/ardour/ardour/source.h +++ b/libs/ardour/ardour/source.h @@ -53,7 +53,7 @@ public: RemovableIfEmpty = 0x10, RemoveAtDestroy = 0x20, NoPeakFile = 0x40, - Destructive = 0x80, + /* 0x80 was Destructive */ Empty = 0x100, /* used for MIDI only */ RF64_RIFF = 0x200, Missing = 0x400, /* used for MIDI only */ @@ -88,7 +88,6 @@ public: XMLNode& get_state (); int set_state (const XMLNode&, int version); - bool destructive() const { return (_flags & Destructive); } bool writable () const; virtual bool length_mutable() const { return false; } diff --git a/libs/ardour/ardour/source_factory.h b/libs/ardour/ardour/source_factory.h index a85cb634ca..21a2d8a988 100644 --- a/libs/ardour/ardour/source_factory.h +++ b/libs/ardour/ardour/source_factory.h @@ -54,7 +54,7 @@ class LIBARDOUR_API SourceFactory { static boost::shared_ptr createWritable (DataType type, Session&, const std::string& path, - bool destructive, samplecnt_t rate, bool announce = true, bool async = false); + samplecnt_t rate, bool announce = true, bool async = false); static boost::shared_ptr createForRecovery diff --git a/libs/ardour/ardour/srcfilesource.h b/libs/ardour/ardour/srcfilesource.h index 241703c0b3..c110ac634a 100644 --- a/libs/ardour/ardour/srcfilesource.h +++ b/libs/ardour/ardour/srcfilesource.h @@ -46,7 +46,6 @@ public: samplecnt_t readable_length() const { return _source->readable_length() * _ratio; } samplecnt_t length (samplepos_t pos) const { return _source->length(pos) * _ratio; } - bool destructive() const { return false; } bool can_be_analysed() const { return false; } bool clamped_at_unity() const { return false; } diff --git a/libs/ardour/ardour/track.h b/libs/ardour/ardour/track.h index 2ab9b8ef9a..3d92811d13 100644 --- a/libs/ardour/ardour/track.h +++ b/libs/ardour/ardour/track.h @@ -129,7 +129,6 @@ public: boost::shared_ptr playlist (); void request_input_monitoring (bool); void ensure_input_monitoring (bool); - bool destructive () const; std::list > & last_capture_sources (); std::string steal_write_source_name (); void reset_write_sources (bool, bool force = false); @@ -208,7 +207,6 @@ protected: FreezeRecord _freeze_record; XMLNode* pending_state; - bool _destructive; boost::shared_ptr _record_enable_control; boost::shared_ptr _record_safe_control; diff --git a/libs/ardour/ardour/types.h b/libs/ardour/ardour/types.h index b55e245282..60943c1d28 100644 --- a/libs/ardour/ardour/types.h +++ b/libs/ardour/ardour/types.h @@ -227,7 +227,6 @@ enum MeterType { enum TrackMode { Normal, NonLayered, - Destructive }; enum NoteMode { diff --git a/libs/ardour/audio_playlist_source.cc b/libs/ardour/audio_playlist_source.cc index f0334a584d..5e96409602 100644 --- a/libs/ardour/audio_playlist_source.cc +++ b/libs/ardour/audio_playlist_source.cc @@ -60,8 +60,8 @@ AudioPlaylistSource::AudioPlaylistSource (Session& s, const XMLNode& node) , PlaylistSource (s, node) , AudioSource (s, node) { - /* PlaylistSources are never writable, renameable, removable or destructive */ - _flags = Flag (_flags & ~(Writable|CanRename|Removable|RemovableIfEmpty|RemoveAtDestroy|Destructive)); + /* PlaylistSources are never writable, renameable or removable */ + _flags = Flag (_flags & ~(Writable|CanRename|Removable|RemovableIfEmpty|RemoveAtDestroy)); /* ancestors have already called ::set_state() in their XML-based constructors. diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc index bf9b981681..c4d06be17d 100644 --- a/libs/ardour/audioregion.cc +++ b/libs/ardour/audioregion.cc @@ -1587,11 +1587,6 @@ AudioRegion::source_offset_changed () } boost::shared_ptr afs = boost::dynamic_pointer_cast(_sources.front()); - - if (afs && afs->destructive()) { - // set_start (source()->natural_position(), this); - set_position (source()->natural_position()); - } } boost::shared_ptr diff --git a/libs/ardour/disk_writer.cc b/libs/ardour/disk_writer.cc index 260507f50d..51b91b5617 100644 --- a/libs/ardour/disk_writer.cc +++ b/libs/ardour/disk_writer.cc @@ -349,27 +349,8 @@ DiskWriter::non_realtime_locate (samplepos_t position) void DiskWriter::prepare_record_status (samplepos_t _capture_start_sample) { - if (recordable() && destructive()) { - boost::shared_ptr c = channels.reader (); - for (ChannelList::iterator chan = c->begin(); chan != c->end(); ++chan) { - - RingBufferNPT::rw_vector transitions; - (*chan)->capture_transition_buf->get_write_vector (&transitions); - - if (transitions.len[0] > 0) { - transitions.buf[0]->type = CaptureStart; - transitions.buf[0]->capture_val = _capture_start_sample; - (*chan)->capture_transition_buf->increment_write_ptr(1); - } else { - // bad! - fatal << X_("programming error: capture_transition_buf is full on rec start! inconceivable!") - << endmsg; - } - } - } } - /** Do some record stuff [not described in this comment!] * * Also: @@ -675,25 +656,6 @@ DiskWriter::finish_capture (boost::shared_ptr c) return; } - if (recordable() && destructive()) { - for (ChannelList::iterator chan = c->begin(); chan != c->end(); ++chan) { - - RingBufferNPT::rw_vector transvec; - (*chan)->capture_transition_buf->get_write_vector(&transvec); - - if (transvec.len[0] > 0) { - transvec.buf[0]->type = CaptureEnd; - transvec.buf[0]->capture_val = _capture_captured; - (*chan)->capture_transition_buf->increment_write_ptr(1); - } - else { - // bad! - fatal << string_compose (_("programmer error: %1"), X_("capture_transition_buf is full when stopping record! inconceivable!")) << endmsg; - } - } - } - - CaptureInfo* ci = new CaptureInfo; ci->start = _capture_start_sample; @@ -744,12 +706,6 @@ DiskWriter::set_record_enabled (bool yn) return; } - /* can't rec-enable in destructive mode if transport is before start */ - - if (destructive() && yn && _session.transport_sample() < _session.current_start_sample()) { - return; - } - /* yes, i know that this not proof against race conditions, but its good enough. i think. */ @@ -772,13 +728,6 @@ DiskWriter::set_record_safe (bool yn) return; } - /* can't rec-safe in destructive mode if transport is before start ???? - REQUIRES REVIEW */ - - if (destructive() && yn && _session.transport_sample() < _session.current_start_sample()) { - return; - } - /* yes, i know that this not proof against race conditions, but its good enough. i think. */ @@ -801,12 +750,6 @@ DiskWriter::prep_record_enable () return false; } - /* can't rec-enable in destructive mode if transport is before start */ - - if (destructive() && _session.transport_sample() < _session.current_start_sample()) { - return false; - } - boost::shared_ptr c = channels.reader(); capturing_sources.clear (); @@ -872,12 +815,6 @@ DiskWriter::seek (samplepos_t sample, bool complete_refill) g_atomic_int_set(&_samples_read_from_ringbuffer, 0); g_atomic_int_set(&_samples_written_to_ringbuffer, 0); - /* can't rec-enable in destructive mode if transport is before start */ - - if (destructive() && record_enabled() && sample < _session.current_start_sample()) { - disengage_record_enable (); - } - playback_sample = sample; return 0; @@ -925,56 +862,6 @@ DiskWriter::do_flush (RunContext ctxt, bool force_flush) to_write = min (_chunk_samples, (samplecnt_t) vector.len[0]); - // check the transition buffer when recording destructive - // important that we get this after the capture buf - - if (destructive()) { - (*chan)->capture_transition_buf->get_read_vector(&transvec); - size_t transcount = transvec.len[0] + transvec.len[1]; - size_t ti; - - for (ti=0; ti < transcount; ++ti) { - CaptureTransition & captrans = (ti < transvec.len[0]) ? transvec.buf[0][ti] : transvec.buf[1][ti-transvec.len[0]]; - - if (captrans.type == CaptureStart) { - // by definition, the first data we got above represents the given capture pos - - (*chan)->write_source->mark_capture_start (captrans.capture_val); - (*chan)->curr_capture_cnt = 0; - - } else if (captrans.type == CaptureEnd) { - - // capture end, the capture_val represents total samples in capture - - if (captrans.capture_val <= (*chan)->curr_capture_cnt + to_write) { - - // shorten to make the write a perfect fit - uint32_t nto_write = (captrans.capture_val - (*chan)->curr_capture_cnt); - - if (nto_write < to_write) { - ret = 1; // should we? - } - to_write = nto_write; - - (*chan)->write_source->mark_capture_end (); - - // increment past this transition, but go no further - ++ti; - break; - } - else { - // actually ends just beyond this chunk, so force more work - ret = 1; - break; - } - } - } - - if (ti > 0) { - (*chan)->capture_transition_buf->increment_read_ptr(ti); - } - } - if ((!(*chan)->write_source) || (*chan)->write_source->write (vector.buf[0], to_write) != to_write) { error << string_compose(_("AudioDiskstream %1: cannot write to disk"), id()) << endmsg; return -1; @@ -983,7 +870,7 @@ DiskWriter::do_flush (RunContext ctxt, bool force_flush) (*chan)->wbuf->increment_read_ptr (to_write); (*chan)->curr_capture_cnt += to_write; - if ((to_write == vector.len[0]) && (total > to_write) && (to_write < _chunk_samples) && !destructive()) { + if ((to_write == vector.len[0]) && (total > to_write) && (to_write < _chunk_samples)) { /* we wrote all of vector.len[0] but it wasn't an entire disk_write_chunk_samples of data, so arrange for some part @@ -1068,35 +955,26 @@ DiskWriter::reset_write_sources (bool mark_write_complete, bool /*force*/) for (chan = c->begin(), n = 0; chan != c->end(); ++chan, ++n) { - if (!destructive()) { - - if ((*chan)->write_source) { + if ((*chan)->write_source) { - if (mark_write_complete) { - Source::Lock lock((*chan)->write_source->mutex()); - (*chan)->write_source->mark_streaming_write_completed (lock); - (*chan)->write_source->done_with_peakfile_writes (); - } - - if ((*chan)->write_source->removable()) { - (*chan)->write_source->mark_for_remove (); - (*chan)->write_source->drop_references (); - } - - (*chan)->write_source.reset (); + if (mark_write_complete) { + Source::Lock lock((*chan)->write_source->mutex()); + (*chan)->write_source->mark_streaming_write_completed (lock); + (*chan)->write_source->done_with_peakfile_writes (); } - use_new_write_source (DataType::AUDIO, n); - - if (record_enabled()) { - capturing_sources.push_back ((*chan)->write_source); + if ((*chan)->write_source->removable()) { + (*chan)->write_source->mark_for_remove (); + (*chan)->write_source->drop_references (); } - } else { + (*chan)->write_source.reset (); + } - if ((*chan)->write_source == 0) { - use_new_write_source (DataType::AUDIO, n); - } + use_new_write_source (DataType::AUDIO, n); + + if (record_enabled()) { + capturing_sources.push_back ((*chan)->write_source); } } @@ -1110,17 +988,6 @@ DiskWriter::reset_write_sources (bool mark_write_complete, bool /*force*/) if (_playlists[DataType::MIDI]) { use_new_write_source (DataType::MIDI); } - - if (destructive() && !c->empty ()) { - - /* we now have all our write sources set up, so create the - playlist's single region. - */ - - if (_playlists[DataType::MIDI]->empty()) { - setup_destructive_playlist (); - } - } } int @@ -1161,7 +1028,7 @@ DiskWriter::use_new_write_source (DataType dt, uint32_t n) try { if ((chan->write_source = _session.create_audio_source_for_session ( - c->size(), write_source_name(), n, destructive())) == 0) { + c->size(), write_source_name(), n)) == 0) { throw failed_constructor(); } } @@ -1172,9 +1039,7 @@ DiskWriter::use_new_write_source (DataType dt, uint32_t n) return -1; } - /* do not remove destructive files even if they are empty */ - - chan->write_source->set_allow_remove_if_empty (!destructive()); + chan->write_source->set_allow_remove_if_empty (true); } return 0; @@ -1223,10 +1088,6 @@ DiskWriter::transport_stopped_wallclock (struct tm& when, time_t twhen, bool abo if (abort_capture) { - if (destructive()) { - goto outout; - } - for (ChannelList::iterator chan = c->begin(); chan != c->end(); ++chan) { if ((*chan)->write_source) { @@ -1380,26 +1241,6 @@ DiskWriter::loop (samplepos_t transport_sample) _first_recordable_sample = transport_sample; // mild lie _last_recordable_sample = max_samplepos; _was_recording = true; - - if (recordable() && destructive()) { - for (ChannelList::iterator chan = c->begin(); chan != c->end(); ++chan) { - - RingBufferNPT::rw_vector transvec; - (*chan)->capture_transition_buf->get_write_vector(&transvec); - - if (transvec.len[0] > 0) { - transvec.buf[0]->type = CaptureStart; - transvec.buf[0]->capture_val = _capture_start_sample; - (*chan)->capture_transition_buf->increment_write_ptr(1); - } - else { - // bad! - fatal << X_("programming error: capture_transition_buf is full on rec loop! inconceivable!") - << endmsg; - } - } - } - } /* Here we only keep track of the number of captured loops so monotonic @@ -1414,82 +1255,6 @@ DiskWriter::loop (samplepos_t transport_sample) } } -void -DiskWriter::setup_destructive_playlist () -{ - SourceList srcs; - boost::shared_ptr c = channels.reader(); - - for (ChannelList::iterator chan = c->begin(); chan != c->end(); ++chan) { - srcs.push_back ((*chan)->write_source); - } - - /* a single full-sized region */ - - assert (!srcs.empty ()); - - PropertyList plist; - plist.add (Properties::name, _name.val()); - plist.add (Properties::start, 0); - plist.add (Properties::length, max_samplepos - srcs.front()->natural_position()); - - boost::shared_ptr region (RegionFactory::create (srcs, plist)); - _playlists[DataType::AUDIO]->add_region (region, srcs.front()->natural_position()); - - /* apply region properties and update write sources */ - use_destructive_playlist(); -} - -void -DiskWriter::use_destructive_playlist () -{ - /* this is called from the XML-based constructor or ::set_destructive. when called, - we already have a playlist and a region, but we need to - set up our sources for write. we use the sources associated - with the (presumed single, full-extent) region. - */ - - boost::shared_ptr rp; - { - const RegionList& rl (_playlists[DataType::AUDIO]->region_list_property().rlist()); - if (rl.size() > 0) { - /* this can happen when dragging a region onto a tape track */ - assert((rl.size() == 1)); - rp = rl.front(); - } - } - - if (!rp) { - reset_write_sources (false, true); - return; - } - - boost::shared_ptr region = boost::dynamic_pointer_cast (rp); - - if (region == 0) { - throw failed_constructor(); - } - - /* be sure to stretch the region out to the maximum length (non-musical)*/ - - region->set_length (max_samplepos - region->position(), 0); - - uint32_t n; - ChannelList::iterator chan; - boost::shared_ptr c = channels.reader(); - - for (n = 0, chan = c->begin(); chan != c->end(); ++chan, ++n) { - (*chan)->write_source = boost::dynamic_pointer_cast(region->source (n)); - assert((*chan)->write_source); - (*chan)->write_source->set_allow_remove_if_empty (false); - - // should be set when creating the source or loading the state - assert ((*chan)->write_source->destructive()); - } - - /* the source list will never be reset for a destructive track */ -} - void DiskWriter::adjust_buffering () { diff --git a/libs/ardour/enums.cc b/libs/ardour/enums.cc index c01b519e0c..3b174cc7cb 100644 --- a/libs/ardour/enums.cc +++ b/libs/ardour/enums.cc @@ -248,7 +248,6 @@ setup_enum_writer () REGISTER_ENUM (Normal); REGISTER_ENUM (NonLayered); - REGISTER_ENUM (Destructive); REGISTER (_TrackMode); REGISTER_ENUM (Sustained); @@ -520,7 +519,6 @@ setup_enum_writer () REGISTER_CLASS_ENUM (Source, RemovableIfEmpty); REGISTER_CLASS_ENUM (Source, RemoveAtDestroy); REGISTER_CLASS_ENUM (Source, NoPeakFile); - REGISTER_CLASS_ENUM (Source, Destructive); REGISTER_CLASS_ENUM (Source, Empty); REGISTER_BITS (_Source_Flag); @@ -544,7 +542,6 @@ setup_enum_writer () REGISTER_CLASS_ENUM (DiskIOProcessor, Recordable); REGISTER_CLASS_ENUM (DiskIOProcessor, Hidden); - REGISTER_CLASS_ENUM (DiskIOProcessor, Destructive); REGISTER_BITS (_DiskIOProcessor_Flag); REGISTER_CLASS_ENUM (Location, IsMark); diff --git a/libs/ardour/file_source.cc b/libs/ardour/file_source.cc index c5d9088ac5..4deece2f49 100644 --- a/libs/ardour/file_source.cc +++ b/libs/ardour/file_source.cc @@ -99,11 +99,7 @@ FileSource::existence_check () void FileSource::prevent_deletion () { - if (!(_flags & Destructive)) { - mark_immutable (); - } else { - _flags = Flag (_flags & ~(Removable|RemovableIfEmpty|RemoveAtDestroy)); - } + mark_immutable (); } bool @@ -517,20 +513,14 @@ out: void FileSource::mark_immutable () { - /* destructive sources stay writable, and their other flags don't change. */ - if (!(_flags & Destructive)) { - _flags = Flag (_flags & ~(Writable|Removable|RemovableIfEmpty|RemoveAtDestroy|CanRename)); - close(); - } + _flags = Flag (_flags & ~(Writable|Removable|RemovableIfEmpty|RemoveAtDestroy|CanRename)); + close(); } void FileSource::mark_immutable_except_write () { - /* destructive sources stay writable, and their other flags don't change. */ - if (!(_flags & Destructive)) { - _flags = Flag (_flags & ~(Removable|RemovableIfEmpty|RemoveAtDestroy|CanRename)); - } + _flags = Flag (_flags & ~(Removable|RemovableIfEmpty|RemoveAtDestroy|CanRename)); } void diff --git a/libs/ardour/filter.cc b/libs/ardour/filter.cc index 07f83cb9c5..c5a0ff4282 100644 --- a/libs/ardour/filter.cc +++ b/libs/ardour/filter.cc @@ -62,7 +62,7 @@ Filter::make_new_sources (boost::shared_ptr region, SourceList& nsrcs, s const string path = (region->data_type() == DataType::MIDI) ? session.new_midi_source_path (name) - : session.new_audio_source_path (name, region->n_channels(), i, false, false); + : session.new_audio_source_path (name, region->n_channels(), i, false); if (path.empty()) { error << string_compose (_("filter: error creating name for new file based on %1"), region->name()) diff --git a/libs/ardour/import.cc b/libs/ardour/import.cc index e438d51bbe..cba5899db2 100644 --- a/libs/ardour/import.cc +++ b/libs/ardour/import.cc @@ -155,7 +155,7 @@ Session::get_paths_for_new_sources (bool /*allow_replacing*/, const string& impo } break; case DataType::AUDIO: - filepath = new_audio_source_path (basename, channels, n, false, false); + filepath = new_audio_source_path (basename, channels, n, false); break; } @@ -204,7 +204,7 @@ create_mono_sources_for_writing (const vector& new_paths, source = SourceFactory::createWritable (type, sess, i->c_str(), - false, // destructive + false, samplerate); } diff --git a/libs/ardour/lua_api.cc b/libs/ardour/lua_api.cc index 4715d405f2..1a398c6fa2 100644 --- a/libs/ardour/lua_api.cc +++ b/libs/ardour/lua_api.cc @@ -1049,7 +1049,7 @@ LuaAPI::Rubberband::process (luabridge::LuaRef cb) for (uint32_t c = 0; c < _n_channels; ++c) { string name = PBD::basename_nosuffix (names[c]) + "(rb)"; - const string path = session.new_audio_source_path (name, _n_channels, c, false, false); + const string path = session.new_audio_source_path (name, _n_channels, c, false); if (path.empty ()) { cleanup (true); return rv; diff --git a/libs/ardour/luabindings.cc b/libs/ardour/luabindings.cc index 6b8c0e90a7..773fa2169a 100644 --- a/libs/ardour/luabindings.cc +++ b/libs/ardour/luabindings.cc @@ -1310,7 +1310,6 @@ LuaBindings::common (lua_State* L) .addFunction ("empty", &Source::empty) .addFunction ("length", &Source::length) .addFunction ("natural_position", &Source::natural_position) - .addFunction ("destructive", &Source::destructive) .addFunction ("writable", &Source::writable) .addFunction ("has_been_analysed", &Source::has_been_analysed) .addFunction ("can_be_analysed", &Source::can_be_analysed) @@ -2032,7 +2031,6 @@ LuaBindings::common (lua_State* L) .beginNamespace ("TrackMode") .addConst ("Normal", ARDOUR::TrackMode(Start)) .addConst ("NonLayered", ARDOUR::TrackMode(NonLayered)) - .addConst ("Destructive", ARDOUR::TrackMode(Destructive)) .endNamespace () .beginNamespace ("TransportRequestSource") diff --git a/libs/ardour/midi_playlist_source.cc b/libs/ardour/midi_playlist_source.cc index 7339918b07..d9242bcf34 100644 --- a/libs/ardour/midi_playlist_source.cc +++ b/libs/ardour/midi_playlist_source.cc @@ -68,8 +68,8 @@ MidiPlaylistSource::MidiPlaylistSource (Session& s, const XMLNode& node) , MidiSource (s, node) , PlaylistSource (s, node) { - /* PlaylistSources are never writable, renameable, removable or destructive */ - _flags = Flag (_flags & ~(Writable|CanRename|Removable|RemovableIfEmpty|RemoveAtDestroy|Destructive)); + /* PlaylistSources are never writable, renameable or removable */ + _flags = Flag (_flags & ~(Writable|CanRename|Removable|RemovableIfEmpty|RemoveAtDestroy)); /* ancestors have already called ::set_state() in their XML-based constructors. diff --git a/libs/ardour/playlist_source.cc b/libs/ardour/playlist_source.cc index 0922d2e959..dbc74b41a6 100644 --- a/libs/ardour/playlist_source.cc +++ b/libs/ardour/playlist_source.cc @@ -49,8 +49,8 @@ PlaylistSource::PlaylistSource (Session& s, const ID& orig, const std::string& n , _original (orig) , _owner (0) /* zero is never a legal ID for an object */ { - /* PlaylistSources are never writable, renameable, removable or destructive */ - _flags = Flag (_flags & ~(Writable|CanRename|Removable|RemovableIfEmpty|RemoveAtDestroy|Destructive)); + /* PlaylistSources are never writable, renameable or removable */ + _flags = Flag (_flags & ~(Writable|CanRename|Removable|RemovableIfEmpty|RemoveAtDestroy)); _playlist = p; _playlist->use (); @@ -63,8 +63,8 @@ PlaylistSource::PlaylistSource (Session& s, const ID& orig, const std::string& n PlaylistSource::PlaylistSource (Session& s, const XMLNode& node) : Source (s, DataType::AUDIO, "toBeRenamed") { - /* PlaylistSources are never writable, renameable, removable or destructive */ - _flags = Flag (_flags & ~(Writable|CanRename|Removable|RemovableIfEmpty|RemoveAtDestroy|Destructive)); + /* PlaylistSources are never writable, renameable or removable */ + _flags = Flag (_flags & ~(Writable|CanRename|Removable|RemovableIfEmpty|RemoveAtDestroy)); if (set_state (node, Stateful::loading_state_version)) { diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc index 8725bf8343..1803315194 100644 --- a/libs/ardour/region.cc +++ b/libs/ardour/region.cc @@ -1730,7 +1730,7 @@ Region::source_length(uint32_t n) const bool Region::verify_length (samplecnt_t& len) { - if (source() && (source()->destructive() || source()->length_mutable())) { + if (source() && source()->length_mutable()) { return true; } @@ -1748,7 +1748,7 @@ Region::verify_length (samplecnt_t& len) bool Region::verify_start_and_length (samplepos_t new_start, samplecnt_t& new_length) { - if (source() && (source()->destructive() || source()->length_mutable())) { + if (source() && source()->length_mutable()) { return true; } @@ -1766,7 +1766,7 @@ Region::verify_start_and_length (samplepos_t new_start, samplecnt_t& new_length) bool Region::verify_start (samplepos_t pos) { - if (source() && (source()->destructive() || source()->length_mutable())) { + if (source() && source()->length_mutable()) { return true; } @@ -1781,7 +1781,7 @@ Region::verify_start (samplepos_t pos) bool Region::verify_start_mutable (samplepos_t& new_start) { - if (source() && (source()->destructive() || source()->length_mutable())) { + if (source() && source()->length_mutable()) { return true; } diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 92d62274f7..25fba565aa 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -278,7 +278,6 @@ Session::Session (AudioEngine &eng, , _adding_routes_in_progress (false) , _reconnecting_routes_in_progress (false) , _route_deletion_in_progress (false) - , destructive_index (0) , _track_number_decimals(1) , default_fade_steepness (0) , default_fade_msecs (0) @@ -4758,7 +4757,7 @@ Session::audio_source_name_is_unique (const string& name) } string -Session::format_audio_source_name (const string& legalized_base, uint32_t nchan, uint32_t chan, bool destructive, bool take_required, uint32_t cnt, bool related_exists) +Session::format_audio_source_name (const string& legalized_base, uint32_t nchan, uint32_t chan, bool take_required, uint32_t cnt, bool related_exists) { ostringstream sstr; const string ext = native_header_format_extension (config.get_native_file_header_format(), DataType::AUDIO); @@ -4794,7 +4793,7 @@ Session::format_audio_source_name (const string& legalized_base, uint32_t nchan, /** Return a unique name based on \a base for a new internal audio source */ string -Session::new_audio_source_path (const string& base, uint32_t nchan, uint32_t chan, bool destructive, bool take_required) +Session::new_audio_source_path (const string& base, uint32_t nchan, uint32_t chan, bool take_required) { uint32_t cnt; string possible_name; @@ -4806,9 +4805,9 @@ Session::new_audio_source_path (const string& base, uint32_t nchan, uint32_t cha // Find a "version" of the base name that doesn't exist in any of the possible directories. - for (cnt = (destructive ? ++destructive_index : 1); cnt <= limit; ++cnt) { + for (cnt = 1; cnt <= limit; ++cnt) { - possible_name = format_audio_source_name (legalized, nchan, chan, destructive, take_required, cnt, some_related_source_name_exists); + possible_name = format_audio_source_name (legalized, nchan, chan, take_required, cnt, some_related_source_name_exists); if (audio_source_name_is_unique (possible_name)) { break; @@ -4901,13 +4900,13 @@ Session::new_midi_source_path (const string& base, bool need_lock) /** Create a new within-session audio source */ boost::shared_ptr -Session::create_audio_source_for_session (size_t n_chans, string const & base, uint32_t chan, bool destructive) +Session::create_audio_source_for_session (size_t n_chans, string const & base, uint32_t chan) { - const string path = new_audio_source_path (base, n_chans, chan, destructive, true); + const string path = new_audio_source_path (base, n_chans, chan, true); if (!path.empty()) { return boost::dynamic_pointer_cast ( - SourceFactory::createWritable (DataType::AUDIO, *this, path, destructive, sample_rate(), true, true)); + SourceFactory::createWritable (DataType::AUDIO, *this, path, sample_rate(), true, true)); } else { throw failed_constructor (); } @@ -5717,7 +5716,7 @@ Session::write_one_track (Track& track, samplepos_t start, samplepos_t end, string base_name = string_compose ("%1-%2-bounce", playlist->name(), chan_n); string path = ((data_type == DataType::AUDIO) - ? new_audio_source_path (legal_playlist_name, diskstream_channels.n_audio(), chan_n, false, true) + ? new_audio_source_path (legal_playlist_name, diskstream_channels.n_audio(), chan_n, true) : new_midi_source_path (legal_playlist_name)); if (path.empty()) { diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 6159a7dfae..d85f8583d8 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -278,7 +278,6 @@ Session::post_engine_init () /* crossfades require sample rate knowledge */ - SndFileSource::setup_standard_crossfades (*this, sample_rate()); _engine.GraphReordered.connect_same_thread (*this, boost::bind (&Session::graph_reordered, this, true)); _engine.MidiSelectionPortsChanged.connect_same_thread (*this, boost::bind (&Session::rewire_midi_selection_ports, this)); @@ -1283,7 +1282,7 @@ Session::state (bool save_template, snapshot_t snapshot_type, bool only_used_ass for (SourceMap::iterator siter = sources.begin(); siter != sources.end(); ++siter) { /* Don't save information about non-file Sources, or - * about non-destructive file sources that are empty + * about file sources that are empty * and unused by any regions. */ boost::shared_ptr fs; @@ -1292,10 +1291,8 @@ Session::state (bool save_template, snapshot_t snapshot_type, bool only_used_ass continue; } - if (!fs->destructive()) { - if (fs->empty() && !fs->used()) { - continue; - } + if (fs->empty() && !fs->used()) { + continue; } if (only_used_assets) { @@ -2483,7 +2480,7 @@ retry: return -1; } /* Note that we do not announce the source just yet - we need to reset its ID before we do that */ - source = SourceFactory::createWritable (DataType::MIDI, *this, fullpath, false, _current_sample_rate, false, false); + source = SourceFactory::createWritable (DataType::MIDI, *this, fullpath, _current_sample_rate, false, false); /* reset ID to match the missing one */ source->set_id (**niter); /* Now we can announce it */ diff --git a/libs/ardour/sndfilesource.cc b/libs/ardour/sndfilesource.cc index 918e695f10..cdb91e8ccd 100644 --- a/libs/ardour/sndfilesource.cc +++ b/libs/ardour/sndfilesource.cc @@ -54,9 +54,6 @@ using namespace ARDOUR; using namespace PBD; using std::string; -gain_t* SndFileSource::out_coefficient = 0; -gain_t* SndFileSource::in_coefficient = 0; -samplecnt_t SndFileSource::xfade_samples = 64; const Source::Flag SndFileSource::default_writable_flags = Source::Flag ( Source::Writable | Source::Removable | @@ -68,10 +65,6 @@ SndFileSource::SndFileSource (Session& s, const XMLNode& node) , AudioFileSource (s, node) , _sndfile (0) , _broadcast_info (0) - , _capture_start (false) - , _capture_end (false) - , file_pos (0) - , xfade_buf (0) { init_sndfile (); @@ -92,10 +85,6 @@ SndFileSource::SndFileSource (Session& s, const string& path, int chn, Flag flag , AudioFileSource (s, path, Flag (flags & ~(Writable|Removable|RemovableIfEmpty|RemoveAtDestroy))) , _sndfile (0) , _broadcast_info (0) - , _capture_start (false) - , _capture_end (false) - , file_pos (0) - , xfade_buf (0) { _channel = chn; @@ -118,10 +107,6 @@ SndFileSource::SndFileSource (Session& s, const string& path, const string& orig , AudioFileSource (s, path, origin, flags, sfmt, hf) , _sndfile (0) , _broadcast_info (0) - , _capture_start (false) - , _capture_end (false) - , file_pos (0) - , xfade_buf (0) { int fmt = 0; @@ -144,7 +129,6 @@ SndFileSource::SndFileSource (Session& s, const string& path, const string& orig sfmt = FormatInt24; } _flags = Flag (_flags & ~Broadcast); - _flags = Flag (_flags & ~Destructive); // XXX or force WAV if destructive? break; case AIFF: @@ -209,14 +193,8 @@ SndFileSource::SndFileSource (Session& s, const string& path, const string& orig _info.samplerate = rate; _info.format = fmt; - if (_flags & Destructive) { - if (open()) { - throw failed_constructor(); - } - } else { - /* normal mode: do not open the file here - do that in {read,write}_unlocked() as needed - */ - } + /* normal mode: do not open the file here - do that in {read,write}_unlocked() as needed + */ } /** Constructor to be called for recovering files being used for @@ -230,10 +208,6 @@ SndFileSource::SndFileSource (Session& s, const string& path, int chn) , AudioFileSource (s, path, Flag (0)) , _sndfile (0) , _broadcast_info (0) - , _capture_start (false) - , _capture_end (false) - , file_pos (0) - , xfade_buf (0) { _channel = chn; @@ -253,10 +227,6 @@ SndFileSource::SndFileSource (Session& s, const AudioFileSource& other, const st , AudioFileSource (s, path, "", Flag ((other.flags () | default_writable_flags | NoPeakFile) & ~RF64_RIFF), /*unused*/ FormatFloat, /*unused*/ WAVE64) , _sndfile (0) , _broadcast_info (0) - , _capture_start (false) - , _capture_end (false) - , file_pos (0) - , xfade_buf (0) { if (other.readable_length () == 0) { throw failed_constructor(); @@ -353,11 +323,6 @@ SndFileSource::init_sndfile () memset (&_info, 0, sizeof(_info)); - if (destructive()) { - xfade_buf = new Sample[xfade_samples]; - _natural_position = header_position_offset; - } - AudioFileSource::HeaderPositionOffsetChanged.connect_same_thread (header_position_connection, boost::bind (&SndFileSource::handle_header_position_change, this)); } @@ -398,7 +363,6 @@ SndFileSource::open () } if ((_info.format & SF_FORMAT_TYPEMASK ) == SF_FORMAT_FLAC) { - assert (!destructive()); _sndfile = sf_open_fd (fd, writable () ? SFM_WRITE : SFM_READ, &_info, true); } else { _sndfile = sf_open_fd (fd, writable() ? SFM_RDWR : SFM_READ, &_info, true); @@ -445,16 +409,9 @@ SndFileSource::open () header_position_offset = _natural_position; } - if (destructive()) { - /* Set our timeline position to either the time reference from a BWF header or the current - start of the session. - */ - set_natural_position (bwf_info_exists ? _broadcast_info->get_time_reference() : header_position_offset); - } else { - /* If a BWF header exists, set our _natural_position from it */ - if (bwf_info_exists) { - set_natural_position (_broadcast_info->get_time_reference()); - } + /* If a BWF header exists, set our _natural_position from it */ + if (bwf_info_exists) { + set_natural_position (_broadcast_info->get_time_reference()); } if (_length != 0 && !bwf_info_exists) { @@ -501,7 +458,6 @@ SndFileSource::~SndFileSource () { close (); delete _broadcast_info; - delete [] xfade_buf; } float @@ -614,11 +570,7 @@ SndFileSource::write_unlocked (Sample *data, samplecnt_t cnt) return 0; // failure } - if (destructive()) { - return destructive_write_unlocked (data, cnt); - } else { - return nondestructive_write_unlocked (data, cnt); - } + return nondestructive_write_unlocked (data, cnt); } samplecnt_t @@ -650,95 +602,6 @@ SndFileSource::nondestructive_write_unlocked (Sample *data, samplecnt_t cnt) return cnt; } -samplecnt_t -SndFileSource::destructive_write_unlocked (Sample* data, samplecnt_t cnt) -{ - if (!writable()) { - warning << string_compose (_("attempt to write a non-writable audio file source (%1)"), _path) << endmsg; - return 0; - } - - if (_capture_start && _capture_end) { - - /* start and end of capture both occur within the data we are writing, - so do both crossfades. - */ - - _capture_start = false; - _capture_end = false; - - /* move to the correct location place */ - file_pos = capture_start_sample - _natural_position; - - // split cnt in half - samplecnt_t subcnt = cnt / 2; - samplecnt_t ofilepos = file_pos; - - // fade in - if (crossfade (data, subcnt, 1) != subcnt) { - return 0; - } - - file_pos += subcnt; - Sample * tmpdata = data + subcnt; - - // fade out - subcnt = cnt - subcnt; - if (crossfade (tmpdata, subcnt, 0) != subcnt) { - return 0; - } - - file_pos = ofilepos; // adjusted below - - } else if (_capture_start) { - - /* start of capture both occur within the data we are writing, - so do the fade in - */ - - _capture_start = false; - _capture_end = false; - - /* move to the correct location place */ - file_pos = capture_start_sample - _natural_position; - - if (crossfade (data, cnt, 1) != cnt) { - return 0; - } - - } else if (_capture_end) { - - /* end of capture both occur within the data we are writing, - so do the fade out - */ - - _capture_start = false; - _capture_end = false; - - if (crossfade (data, cnt, 0) != cnt) { - return 0; - } - - } else { - - /* in the middle of recording */ - - if (write_float (data, file_pos, cnt) != cnt) { - return 0; - } - } - - update_length (file_pos + cnt); - - if (_build_peakfiles) { - compute_and_write_peaks (data, file_pos, cnt, true, true); - } - - file_pos += cnt; - - return cnt; -} - int SndFileSource::update_header (samplepos_t when, struct tm& now, time_t tnow) { @@ -855,210 +718,10 @@ SndFileSource::write_float (Sample* data, samplepos_t sample_pos, samplecnt_t cn return cnt; } -void -SndFileSource::clear_capture_marks () -{ - _capture_start = false; - _capture_end = false; -} - -/** @param pos Capture start position in session samples */ -void -SndFileSource::mark_capture_start (samplepos_t pos) -{ - if (destructive()) { - if (pos < _natural_position) { - _capture_start = false; - } else { - _capture_start = true; - capture_start_sample = pos; - } - } -} - -void -SndFileSource::mark_capture_end() -{ - if (destructive()) { - _capture_end = true; - } -} - -samplecnt_t -SndFileSource::crossfade (Sample* data, samplecnt_t cnt, int fade_in) -{ - samplecnt_t xfade = min (xfade_samples, cnt); - samplecnt_t nofade = cnt - xfade; - Sample* fade_data = 0; - samplepos_t fade_position = 0; // in samples - ssize_t retval; - samplecnt_t file_cnt; - - if (fade_in) { - fade_position = file_pos; - fade_data = data; - } else { - fade_position = file_pos + nofade; - fade_data = data + nofade; - } - - if (fade_position > _length) { - - /* read starts beyond end of data, just memset to zero */ - - file_cnt = 0; - - } else if (fade_position + xfade > _length) { - - /* read ends beyond end of data, read some, memset the rest */ - - file_cnt = _length - fade_position; - - } else { - - /* read is entirely within data */ - - file_cnt = xfade; - } - - if (file_cnt) { - - if ((retval = read_unlocked (xfade_buf, fade_position, file_cnt)) != (ssize_t) file_cnt) { - if (retval >= 0 && errno == EAGAIN) { - /* XXX - can we really trust that errno is meaningful here? yes POSIX, i'm talking to you. - * short or no data there */ - memset (xfade_buf, 0, xfade * sizeof(Sample)); - } else { - error << string_compose(_("SndFileSource: \"%1\" bad read retval: %2 of %5 (%3: %4)"), _path, retval, errno, strerror (errno), xfade) << endmsg; - return 0; - } - } - } - - if (file_cnt != xfade) { - samplecnt_t delta = xfade - file_cnt; - memset (xfade_buf+file_cnt, 0, sizeof (Sample) * delta); - } - - if (nofade && !fade_in) { - if (write_float (data, file_pos, nofade) != nofade) { - error << string_compose(_("SndFileSource: \"%1\" bad write (%2)"), _path, strerror (errno)) << endmsg; - return 0; - } - } - - if (xfade == xfade_samples) { - - samplecnt_t n; - - /* use the standard xfade curve */ - - if (fade_in) { - - /* fade new material in */ - - for (n = 0; n < xfade; ++n) { - xfade_buf[n] = (xfade_buf[n] * out_coefficient[n]) + (fade_data[n] * in_coefficient[n]); - } - - } else { - - - /* fade new material out */ - - for (n = 0; n < xfade; ++n) { - xfade_buf[n] = (xfade_buf[n] * in_coefficient[n]) + (fade_data[n] * out_coefficient[n]); - } - } - - } else if (xfade < xfade_samples) { - - std::vector in(xfade); - std::vector out(xfade); - - /* short xfade, compute custom curve */ - - compute_equal_power_fades (xfade, &in[0], &out[0]); - - for (samplecnt_t n = 0; n < xfade; ++n) { - xfade_buf[n] = (xfade_buf[n] * out[n]) + (fade_data[n] * in[n]); - } - - } else if (xfade) { - - /* long xfade length, has to be computed across several calls */ - - } - - if (xfade) { - if (write_float (xfade_buf, fade_position, xfade) != xfade) { - error << string_compose(_("SndFileSource: \"%1\" bad write (%2)"), _path, strerror (errno)) << endmsg; - return 0; - } - } - - if (fade_in && nofade) { - if (write_float (data + xfade, file_pos + xfade, nofade) != nofade) { - error << string_compose(_("SndFileSource: \"%1\" bad write (%2)"), _path, strerror (errno)) << endmsg; - return 0; - } - } - - return cnt; -} - -samplepos_t -SndFileSource::last_capture_start_sample () const -{ - if (destructive()) { - return capture_start_sample; - } else { - return 0; - } -} - -void -SndFileSource::handle_header_position_change () -{ - if (destructive()) { - if ( _length != 0 ) { - error << string_compose(_("Filesource: start time is already set for existing file (%1): Cannot change start time."), _path ) << endmsg; - //in the future, pop up a dialog here that allows user to regenerate file with new start offset - } else if (writable()) { - _natural_position = header_position_offset; - set_header_natural_position (); //this will get flushed if/when the file is recorded to - } - } -} - -void -SndFileSource::setup_standard_crossfades (Session const & s, samplecnt_t rate) -{ - /* This static method is assumed to have been called by the Session - before any DFS's are created. - */ - - xfade_samples = (samplecnt_t) floor ((s.config.get_destructive_xfade_msecs () / 1000.0) * rate); - - delete [] out_coefficient; - delete [] in_coefficient; - - out_coefficient = new gain_t[xfade_samples]; - in_coefficient = new gain_t[xfade_samples]; - - compute_equal_power_fades (xfade_samples, in_coefficient, out_coefficient); -} - void SndFileSource::set_natural_position (samplepos_t pos) { - // destructive track timeline postion does not change - // except at instantion or when header_position_offset - // (session start) changes - - if (!destructive()) { - AudioFileSource::set_natural_position (pos); - } + AudioFileSource::set_natural_position (pos); } int diff --git a/libs/ardour/source.cc b/libs/ardour/source.cc index e5f98c171a..58459e9e24 100644 --- a/libs/ardour/source.cc +++ b/libs/ardour/source.cc @@ -173,7 +173,7 @@ Source::set_state (const XMLNode& node, int version) /* old style, from the period when we had DestructiveFileSource */ if (node.get_property (X_("destructive"), str)) { - _flags = Flag (_flags | Destructive); + throw (SessionException (_("This session uses destructive tracks, which are no longer supported. Please use an older version of Ardour to work with this session"))); } if (version < 3000) { @@ -181,9 +181,7 @@ Source::set_state (const XMLNode& node, int version) and therefore cannot be removable/writable etc. etc.; 2.X sometimes marks sources as removable which shouldn't be. */ - if (!(_flags & Destructive)) { - _flags = Flag (_flags & ~(Writable|Removable|RemovableIfEmpty|RemoveAtDestroy|CanRename)); - } + _flags = Flag (_flags & ~(Writable|Removable|RemovableIfEmpty|RemoveAtDestroy|CanRename)); } return 0; @@ -280,15 +278,11 @@ Source::check_for_analysis_data_on_disk () void Source::mark_for_remove () { - // This operation is not allowed for sources for destructive tracks or out-of-session files. + // This operation is not allowed for sources for out-of-session files. /* XXX need a way to detect _within_session() condition here - move it from FileSource? */ - if ((_flags & Destructive)) { - return; - } - _flags = Flag (_flags | Removable | RemoveAtDestroy); } diff --git a/libs/ardour/source_factory.cc b/libs/ardour/source_factory.cc index 4eaf0b40fd..74bf610cee 100644 --- a/libs/ardour/source_factory.cc +++ b/libs/ardour/source_factory.cc @@ -233,56 +233,47 @@ SourceFactory::createExternal (DataType type, Session& s, const string& path, { if (type == DataType::AUDIO) { - if (!(flags & Destructive)) { - - try { - Source* src = new SndFileSource (s, path, chn, flags); - boost::shared_ptr ret (src); - BOOST_MARK_SOURCE (ret); - if (setup_peakfile (ret, defer_peaks)) { - return boost::shared_ptr(); - } - ret->check_for_analysis_data_on_disk (); - if (announce) { - SourceCreated (ret); - } - return ret; - } catch (failed_constructor& err) { } + try { + Source* src = new SndFileSource (s, path, chn, flags); + boost::shared_ptr ret (src); + BOOST_MARK_SOURCE (ret); + if (setup_peakfile (ret, defer_peaks)) { + return boost::shared_ptr(); + } + ret->check_for_analysis_data_on_disk (); + if (announce) { + SourceCreated (ret); + } + return ret; + } catch (failed_constructor& err) { } #ifdef HAVE_COREAUDIO + try { + Source* src = new CoreAudioSource (s, path, chn, flags); + boost::shared_ptr ret (src); + BOOST_MARK_SOURCE (ret); + if (setup_peakfile (ret, defer_peaks)) { + return boost::shared_ptr(); + } + ret->check_for_analysis_data_on_disk (); + if (announce) { + SourceCreated (ret); + } + return ret; + } catch (...) { } +#endif + + /* only create mp3s for audition: no announce, no peaks */ + if (!announce && (!AudioFileSource::get_build_peakfiles () || defer_peaks)) { try { - Source* src = new CoreAudioSource (s, path, chn, flags); + Source* src = new Mp3FileSource (s, path, chn, flags); boost::shared_ptr ret (src); BOOST_MARK_SOURCE (ret); - if (setup_peakfile (ret, defer_peaks)) { - return boost::shared_ptr(); - } - ret->check_for_analysis_data_on_disk (); - if (announce) { - SourceCreated (ret); - } return ret; - } catch (...) { } -#endif - /* only create mp3s for audition: no announce, no peaks */ - if (!announce && (!AudioFileSource::get_build_peakfiles () || defer_peaks)) { - try { - Source* src = new Mp3FileSource (s, path, chn, flags); - boost::shared_ptr ret (src); - BOOST_MARK_SOURCE (ret); - return ret; - - } catch (failed_constructor& err) { } - } - - } else { - // eh? + } catch (failed_constructor& err) { } } - error << string_compose(_("AudioFileSource: cannot open file \"%1\" "), path) << endmsg; - throw failed_constructor (); - } else if (type == DataType::MIDI) { try { @@ -306,7 +297,7 @@ SourceFactory::createExternal (DataType type, Session& s, const string& path, boost::shared_ptr SourceFactory::createWritable (DataType type, Session& s, const std::string& path, - bool destructive, samplecnt_t rate, bool announce, bool defer_peaks) + samplecnt_t rate, bool announce, bool defer_peaks) { /* this might throw failed_constructor(), which is OK */ @@ -315,9 +306,7 @@ SourceFactory::createWritable (DataType type, Session& s, const std::string& pat s.config.get_native_file_data_format(), s.config.get_native_file_header_format(), rate, - (destructive - ? Source::Flag (SndFileSource::default_writable_flags | Source::Destructive) - : SndFileSource::default_writable_flags)); + SndFileSource::default_writable_flags); boost::shared_ptr ret (src); BOOST_MARK_SOURCE (ret); diff --git a/libs/ardour/test/data/2 Track-template/2 Track-template.template b/libs/ardour/test/data/2 Track-template/2 Track-template.template index 30033cc396..44c218bfd9 100644 --- a/libs/ardour/test/data/2 Track-template/2 Track-template.template +++ b/libs/ardour/test/data/2 Track-template/2 Track-template.template @@ -12,7 +12,6 @@ -