trigger: add method to get position while playing as a fraction

This commit is contained in:
Paul Davis 2021-10-03 22:44:03 -06:00
parent a1699ff612
commit 5caed9b0a6
2 changed files with 14 additions and 0 deletions

View File

@ -79,6 +79,8 @@ class LIBARDOUR_API Trigger : public PBD::Stateful {
/* this accepts timepos_t because the origin is assumed to be the start */
virtual void set_length (timepos_t const &) = 0;
virtual double position_as_fraction() const = 0;
void set_use_follow (bool yn);
bool use_follow() const { return _use_follow; }
@ -210,6 +212,8 @@ class LIBARDOUR_API AudioTrigger : public Trigger {
timepos_t current_length() const; /* offset from start of data */
timepos_t natural_length() const; /* offset from start of data */
double position_as_fraction() const;
int set_region (boost::shared_ptr<Region>);
void startup ();
void jump_start ();

View File

@ -434,6 +434,16 @@ AudioTrigger::jump_stop ()
retrigger ();
}
double
AudioTrigger::position_as_fraction () const
{
if (!active()) {
return 0.0;
}
return read_index / (double) usable_length;
}
XMLNode&
AudioTrigger::get_state (void)
{