summaryrefslogtreecommitdiff
path: root/libs/ardour
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2014-01-17 00:20:58 +0100
committerRobin Gareus <robin@gareus.org>2014-01-17 00:20:58 +0100
commitb4462b3d22f57f3fe7f4e933b2df0e2c89148e78 (patch)
tree114d4c04b6206b199c1c627900a2cbfe1d31007d /libs/ardour
parent10933e200369ecceb2c8b3a52be41b930955d269 (diff)
add seeking to sfdb auditioner
Diffstat (limited to 'libs/ardour')
-rw-r--r--libs/ardour/ardour/auditioner.h10
-rw-r--r--libs/ardour/auditioner.cc43
-rw-r--r--libs/ardour/butler.cc8
3 files changed, 57 insertions, 4 deletions
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<Region>);
+ 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<void, ARDOUR::framecnt_t, ARDOUR::framecnt_t> AuditionProgress;
+
private:
boost::shared_ptr<AudioRegion> 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> 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<Track> tr = boost::dynamic_pointer_cast<Track> (_session.the_auditioner());
+ tr->seek(audition_seek);
+ _session.the_auditioner()->seek_response(audition_seek);
+ }
+
boost::shared_ptr<RouteList> rl = _session.get_routes();
RouteList rl_with_auditioner = *rl;