From f2a596669e79ac0aad6d5b656b22bcdcda4234e3 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 23 May 2022 11:24:31 -0600 Subject: [PATCH] temporal: set speed *and* tempo when setting tempo --- libs/temporal/tempo.cc | 13 +++++++++++-- libs/temporal/temporal/tempo.h | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/libs/temporal/tempo.cc b/libs/temporal/tempo.cc index da850a1ce7..92895a7965 100644 --- a/libs/temporal/tempo.cc +++ b/libs/temporal/tempo.cc @@ -121,11 +121,20 @@ Tempo::Tempo (XMLNode const & node) } } +void +Tempo::set_note_types_per_minute (double npm) +{ + _npm = npm; + _superclocks_per_note_type = double_npm_to_scpn (_npm); + _super_note_type_per_second = double_npm_to_snps (_npm); +} + void Tempo::set_end_npm (double npm) { - _end_super_note_type_per_second = double_npm_to_snps (npm); - _end_superclocks_per_note_type = double_npm_to_scpn (npm); + _enpm = npm; + _end_super_note_type_per_second = double_npm_to_snps (_enpm); + _end_superclocks_per_note_type = double_npm_to_scpn (_enpm); } void diff --git a/libs/temporal/temporal/tempo.h b/libs/temporal/temporal/tempo.h index 3edd6f4dfe..19b3793784 100644 --- a/libs/temporal/temporal/tempo.h +++ b/libs/temporal/temporal/tempo.h @@ -203,7 +203,7 @@ class LIBTEMPORAL_API Tempo { double samples_per_note_type(samplecnt_t sr) const { return superclock_to_samples (superclocks_per_note_type (), sr); } double samples_per_quarter_note(samplecnt_t sr) const { return superclock_to_samples (superclocks_per_quarter_note(), sr); } - void set_note_types_per_minute (double npm) { _superclocks_per_note_type = double_npm_to_scpn (npm); } + void set_note_types_per_minute (double npm); int note_type () const { return _note_type; } Beats note_type_as_beats () const { return Beats (0, (1920 * 4) / _note_type); }