mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-09 16:24:57 +01:00
add a method to compute tempo & meter for an audio source (not used yet)
This commit is contained in:
parent
ff648b6720
commit
4586b39e8b
2 changed files with 17 additions and 1 deletions
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -433,6 +433,21 @@ AudioRegion::~AudioRegion ()
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
AudioRegion::set_tempo_stuff_from_source ()
|
||||
{
|
||||
samplecnt_t data_size = _session.sample_rate() * 10;
|
||||
std::unique_ptr<Sample> 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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue