From 0f020e59b8c5c6c63af2a3891ddb431e5d99bf12 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 19 Jan 2017 12:39:15 +0100 Subject: [PATCH] Move preroll duration calc into libardour --- libs/ardour/ardour/session.h | 1 + libs/ardour/session.cc | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 49ee8cbb7d..a295f11297 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -1001,6 +1001,7 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop void request_preroll_record (framepos_t); framepos_t preroll_record_in () const { return _preroll_record_in; } bool preroll_record_enabled () const { return _preroll_record_in >= 0; } + framecnt_t preroll_samples (framepos_t) const; /* temporary hacks to allow selection to be pushed from GUI into backend. Whenever we move the selection object into libardour, these will go away. diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 27a3e63112..086edf2b45 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -2105,6 +2105,22 @@ Session::audible_frame () const return std::max ((framepos_t)0, ret); } + +framecnt_t +Session::preroll_samples (framepos_t pos) const +{ + const float pr = Config->get_preroll_seconds(); + if (pos >= 0 && pr < 0) { + const Tempo& tempo = _tempo_map->tempo_at_frame (pos); + const Meter& meter = _tempo_map->meter_at_frame (pos); + return meter.frames_per_bar (tempo, frame_rate()) * -pr; + } + if (pr < 0) { + return 0; + } + return pr * frame_rate(); +} + void Session::set_frame_rate (framecnt_t frames_per_second) {