change Source segment descriptor API (and triggerbox use of it)
This commit is contained in:
@@ -146,7 +146,7 @@ public:
|
||||
void set_captured_for (std::string str) { _captured_for = str; }
|
||||
std::string captured_for() const { return _captured_for; }
|
||||
|
||||
SegmentDescriptor* get_segment_descriptor (TimelineRange const &);
|
||||
bool get_segment_descriptor (TimelineRange const &, SegmentDescriptor&);
|
||||
int set_segment_descriptor (SegmentDescriptor const &);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -515,10 +515,10 @@ Source::empty () const
|
||||
return _length == timecnt_t();
|
||||
}
|
||||
|
||||
SegmentDescriptor*
|
||||
Source::get_segment_descriptor (TimelineRange const & range)
|
||||
bool
|
||||
Source::get_segment_descriptor (TimelineRange const & range, SegmentDescriptor& segment)
|
||||
{
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@@ -1073,12 +1073,15 @@ AudioTrigger::determine_tempo ()
|
||||
TempoMap::SharedPtr tm (TempoMap::use());
|
||||
|
||||
TimelineRange range (_region->start(), _region->start() + _region->length(), 0);
|
||||
SegmentDescriptor* segment = _region->source (0)->get_segment_descriptor (range);
|
||||
SegmentDescriptor segment;
|
||||
bool have_segment;
|
||||
|
||||
if (segment) {
|
||||
have_segment = _region->source (0)->get_segment_descriptor (range, segment);
|
||||
|
||||
_apparent_tempo = segment->tempo().quarter_notes_per_minute ();
|
||||
_meter = segment->meter();
|
||||
if (have_segment) {
|
||||
|
||||
_apparent_tempo = segment.tempo().quarter_notes_per_minute ();
|
||||
_meter = segment.meter();
|
||||
|
||||
} else {
|
||||
/* not a great guess, but what else can we do? */
|
||||
@@ -1149,6 +1152,16 @@ AudioTrigger::determine_tempo ()
|
||||
return;
|
||||
}
|
||||
|
||||
if (!have_segment) {
|
||||
segment.set_extent (_region->start_sample(), _region->length_samples());
|
||||
}
|
||||
|
||||
segment.set_tempo (Temporal::Tempo (_apparent_tempo, 4));
|
||||
|
||||
for (auto & src : _region->sources()) {
|
||||
src->set_segment_descriptor (segment);
|
||||
}
|
||||
|
||||
cerr << name() << " Estimated bpm " << _apparent_tempo << " from " << (double) data.length / _box.session().sample_rate() << " seconds\n";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user