From b4462b3d22f57f3fe7f4e933b2df0e2c89148e78 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 17 Jan 2014 00:20:58 +0100 Subject: add seeking to sfdb auditioner --- libs/ardour/ardour/auditioner.h | 10 ++++++++++ libs/ardour/auditioner.cc | 43 +++++++++++++++++++++++++++++++++++++---- libs/ardour/butler.cc | 8 ++++++++ 3 files changed, 57 insertions(+), 4 deletions(-) (limited to 'libs') diff --git a/libs/ardour/ardour/auditioner.h b/libs/ardour/ardour/auditioner.h index 5ce3ddaddf..7e772fe194 100644 --- a/libs/ardour/ardour/auditioner.h +++ b/libs/ardour/ardour/auditioner.h @@ -44,6 +44,9 @@ class Auditioner : public AudioTrack void audition_region (boost::shared_ptr); + void seek_to_frame (frameoffset_t pos) { if (_seek_frame < 0 && !_seeking) { _seek_frame = pos; }} + void seek_to_percent (float const pos) { if (_seek_frame < 0 && !_seeking) { _seek_frame = floorf(length * pos / 100.0); }} + ARDOUR::AudioPlaylist& prepare_playlist (); int play_audition (framecnt_t nframes); @@ -59,12 +62,19 @@ class Auditioner : public AudioTrack virtual ChanCount input_streams () const; + frameoffset_t seek_frame() const { return _seeking ? _seek_frame : -1;} + void seek_response(frameoffset_t pos) { _seek_complete = true; if (_seeking) { current_frame = pos; _seek_complete = true;} } + PBD::Signal2 AuditionProgress; + private: boost::shared_ptr the_region; framepos_t current_frame; mutable gint _auditioning; Glib::Threads::Mutex lock; framecnt_t length; + frameoffset_t _seek_frame; + bool _seeking; + bool _seek_complete; bool via_monitor; void drop_ports (); diff --git a/libs/ardour/auditioner.cc b/libs/ardour/auditioner.cc index 73670798d8..75a40f142d 100644 --- a/libs/ardour/auditioner.cc +++ b/libs/ardour/auditioner.cc @@ -44,6 +44,9 @@ Auditioner::Auditioner (Session& s) , current_frame (0) , _auditioning (0) , length (0) + , _seek_frame (-1) + , _seeking (false) + , _seek_complete (false) , via_monitor (false) { } @@ -203,6 +206,8 @@ Auditioner::audition_region (boost::shared_ptr region) _main_outs->reset_panner(); + _seek_frame = -1; + _seeking = false; length = the_region->length(); int dir; @@ -232,14 +237,44 @@ Auditioner::play_audition (framecnt_t nframes) return 0; } - this_nframes = min (nframes, length - current_frame); +#if 0 // TODO + if (_seeking && _seek_complete) { + // set FADE-IN + } else if (_seek_frame >= 0 && _seek_frame < length && !_seeking) { + // set FADE-OUT -- use/override amp? || use region-gain ? + } +#endif + + if (_seeking && _seek_complete) { + _seek_complete = false; + _seeking = false; + _seek_frame = -1; + } + + if(!_seeking) { + /* process audio */ + this_nframes = min (nframes, length - current_frame); + + if ((ret = roll (this_nframes, current_frame, current_frame + nframes, false, need_butler)) != 0) { + silence (nframes); + return ret; + } - if ((ret = roll (this_nframes, current_frame, current_frame + nframes, false, need_butler)) != 0) { + current_frame += this_nframes; + + } else { silence (nframes); - return ret; } - current_frame += this_nframes; + if (_seek_frame >= 0 && _seek_frame < length && !_seeking) { + _seek_complete = false; + _seeking = true; + need_butler = true; + } + + if (!_seeking) { + AuditionProgress(current_frame, length); /* emit */ + } if (current_frame >= length) { _session.cancel_audition (); diff --git a/libs/ardour/butler.cc b/libs/ardour/butler.cc index 89b2cc1303..e37734f261 100644 --- a/libs/ardour/butler.cc +++ b/libs/ardour/butler.cc @@ -212,6 +212,14 @@ restart: _session.butler_transport_work (); } + frameoffset_t audition_seek; + if (should_run && _session.is_auditioning() + && (audition_seek = _session.the_auditioner()->seek_frame()) > 0) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (_session.the_auditioner()); + tr->seek(audition_seek); + _session.the_auditioner()->seek_response(audition_seek); + } + boost::shared_ptr rl = _session.get_routes(); RouteList rl_with_auditioner = *rl; -- cgit v1.2.3 From 0479405e2f0cd44b75ba789cd620cb43bb9f9ffb Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 17 Jan 2014 00:25:32 +0100 Subject: fix typo in auditioner-seek --- libs/ardour/butler.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libs') diff --git a/libs/ardour/butler.cc b/libs/ardour/butler.cc index e37734f261..03ae7867db 100644 --- a/libs/ardour/butler.cc +++ b/libs/ardour/butler.cc @@ -214,7 +214,7 @@ restart: frameoffset_t audition_seek; if (should_run && _session.is_auditioning() - && (audition_seek = _session.the_auditioner()->seek_frame()) > 0) { + && (audition_seek = _session.the_auditioner()->seek_frame()) >= 0) { boost::shared_ptr tr = boost::dynamic_pointer_cast (_session.the_auditioner()); tr->seek(audition_seek); _session.the_auditioner()->seek_response(audition_seek); -- cgit v1.2.3