diff --git a/libs/ardour/ardour/audioregion.h b/libs/ardour/ardour/audioregion.h index bb078ef2f7..7f0723f5f1 100644 --- a/libs/ardour/ardour/audioregion.h +++ b/libs/ardour/ardour/audioregion.h @@ -291,6 +291,8 @@ class LIBARDOUR_API AudioRegion : public Region, public AudioReadable int _set_state (const XMLNode&, int version, PBD::PropertyChange& what_changed, bool send_signal); void send_change (const PBD::PropertyChange&); void ensure_length_sanity (); + + void set_tempo_stuff_from_source (); }; } /* namespace ARDOUR */ diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc index 3010687d38..0637e91126 100644 --- a/libs/ardour/audioregion.cc +++ b/libs/ardour/audioregion.cc @@ -433,6 +433,21 @@ AudioRegion::~AudioRegion () } } +void +AudioRegion::set_tempo_stuff_from_source () +{ + samplecnt_t data_size = _session.sample_rate() * 10; + std::unique_ptr data (new Sample[data_size]); + + if (read (data.get(), 0, data_size, 0) == data_size) { + double tempo; + double beatcount; + + estimate_audio_tempo (shared_from_this(), data.get(), data_size, _session.sample_rate(), tempo, _meter, beatcount); + _tempo = Temporal::Tempo (tempo, 4); + } +} + void AudioRegion::post_set (const PropertyChange& /*ignored*/) { @@ -2740,4 +2755,3 @@ AudioRegion::ensure_length_sanity () _length = timecnt_t (timepos_t (_length.val().samples()), _length.val().position()); } } -