return kAudioUnitErr_CannotDoInCurrentContext;
}
- Timecode::BBT_Time bbt;
TempoMetric metric = tmap.metric_at (_session.transport_frame() + input_offset);
- tmap.bbt_time (_session.transport_frame() + input_offset, bbt);
+ Timecode::BBT_Time bbt = _session.tempo_map().bbt_at_frame (_session.transport_frame() + input_offset);
if (outCurrentBeat) {
const double ppq_scaling = metric.meter().note_divisor() / 4.0;
float beat;
- beat = metric.meter().divisions_per_bar() * (bbt.bars - 1) * ppq_scaling;
- beat += (bbt.beats - 1) * ppq_scaling;;
+ beat = metric.meter().divisions_per_bar() * (bbt.bars - 1);
+ beat += (bbt.beats - 1);
beat += bbt.ticks / Timecode::BBT_Time::ticks_per_beat;
- *outCurrentBeat = beat;
+ *outCurrentBeat = beat * ppq_scaling;
}
if (outCurrentTempo) {
return kAudioUnitErr_CannotDoInCurrentContext;
}
- Timecode::BBT_Time bbt;
TempoMetric metric = tmap.metric_at (_session.transport_frame() + input_offset);
- tmap.bbt_time (_session.transport_frame() + input_offset, bbt);
+ Timecode::BBT_Time bbt = _session.tempo_map().bbt_at_frame (_session.transport_frame() + input_offset);
if (outDeltaSampleOffsetToNextBeat) {
if (bbt.ticks == 0) {
/* on the beat */
*outDeltaSampleOffsetToNextBeat = 0;
} else {
- *outDeltaSampleOffsetToNextBeat = (UInt32)
- floor (((Timecode::BBT_Time::ticks_per_beat - bbt.ticks)/Timecode::BBT_Time::ticks_per_beat) * // fraction of a beat to next beat
- metric.tempo().frames_per_beat (_session.frame_rate())); // frames per beat
+ double const beat_frac_to_next = (Timecode::BBT_Time::ticks_per_beat - bbt.ticks) / Timecode::BBT_Time::ticks_per_beat;
+ *outDeltaSampleOffsetToNextBeat = tmap.frame_at_beat (tmap.beat_at_frame (_session.transport_frame() + input_offset) + beat_frac_to_next);
}
}
if (outCycleStartBeat) {
TempoMetric metric = tmap.metric_at (loc->start() + input_offset);
- _session.tempo_map().bbt_time (loc->start(), bbt);
+ bbt = _session.tempo_map().bbt_at_frame (loc->start() + input_offset);
float beat;
beat = metric.meter().divisions_per_bar() * bbt.bars;
if (outCycleEndBeat) {
TempoMetric metric = tmap.metric_at (loc->end() + input_offset);
- _session.tempo_map().bbt_time (loc->end(), bbt);
+ bbt = _session.tempo_map().bbt_at_frame (loc->end() + input_offset);
float beat;
beat = metric.meter().divisions_per_bar() * bbt.bars;