summaryrefslogtreecommitdiff
path: root/libs/ardour/audio_unit.cc
diff options
context:
space:
mode:
authornick_m <mainsbridge@gmail.com>2016-08-18 05:42:30 +1000
committernick_m <mainsbridge@gmail.com>2016-08-18 05:42:30 +1000
commit97020209296453f02590cce82b6160ce122aad08 (patch)
tree2aa9e9e53adeb7b1e8f31683e0faa24c902cb2bc /libs/ardour/audio_unit.cc
parent6d0208613db9dc6d93559392d227fa1a600d0030 (diff)
Report quarter note rather than beat position to AU plugins.
Diffstat (limited to 'libs/ardour/audio_unit.cc')
-rw-r--r--libs/ardour/audio_unit.cc68
1 files changed, 11 insertions, 57 deletions
diff --git a/libs/ardour/audio_unit.cc b/libs/ardour/audio_unit.cc
index 85bfc51a6d..dbcb697578 100644
--- a/libs/ardour/audio_unit.cc
+++ b/libs/ardour/audio_unit.cc
@@ -1803,29 +1803,12 @@ AUPlugin::get_beat_and_tempo_callback (Float64* outCurrentBeat,
DEBUG_TRACE (DEBUG::AudioUnits, "AU calls ardour beat&tempo callback\n");
- /* more than 1 meter or more than 1 tempo means that a simplistic computation
- (and interpretation) of a beat position will be incorrect. So refuse to
- offer the value.
- */
-
- if (tmap.n_tempos() > 1 || tmap.n_meters() > 1) {
- return kAudioUnitErr_CannotDoInCurrentContext;
- }
-
- TempoMetric metric = tmap.metric_at (transport_frame + input_offset);
- Timecode::BBT_Time bbt = _session.tempo_map().bbt_at_frame (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);
- beat += (bbt.beats - 1);
- beat += bbt.ticks / Timecode::BBT_Time::ticks_per_beat;
- *outCurrentBeat = beat * ppq_scaling;
+ *outCurrentBeat = tmap.quarter_note_at_frame (transport_frame + input_offset);
}
if (outCurrentTempo) {
- *outCurrentTempo = floor (session->tempo_map().tempo_at_frame (transport_frame + input_offset).beats_per_minute());
+ *outCurrentTempo = tmap.tempo_at_frame (transport_frame + input_offset).beats_per_minute();
}
return noErr;
@@ -1842,15 +1825,6 @@ AUPlugin::get_musical_time_location_callback (UInt32* outDeltaSampleOffsetToNe
DEBUG_TRACE (DEBUG::AudioUnits, "AU calls ardour music time location callback\n");
- /* more than 1 meter or more than 1 tempo means that a simplistic computation
- (and interpretation) of a beat position will be incorrect. So refuse to
- offer the value.
- */
-
- if (tmap.n_tempos() > 1 || tmap.n_meters() > 1) {
- return kAudioUnitErr_CannotDoInCurrentContext;
- }
-
TempoMetric metric = tmap.metric_at (transport_frame + input_offset);
Timecode::BBT_Time bbt = _session.tempo_map().bbt_at_frame (transport_frame + input_offset);
@@ -1859,8 +1833,10 @@ AUPlugin::get_musical_time_location_callback (UInt32* outDeltaSampleOffsetToNe
/* on the beat */
*outDeltaSampleOffsetToNextBeat = 0;
} else {
- 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 (transport_frame + input_offset) + beat_frac_to_next);
+ double const next_beat = cail (tmap.quarter_note_at_frame (transport_frame + input_offset));
+ framepos_t const next_beat_frame = tmap.frame_at_quarter_note (next_beat);
+
+ *outDeltaSampleOffsetToNextBeat = next_beat_frame - (transport_frame + input_offset);
}
}
@@ -1879,8 +1855,10 @@ AUPlugin::get_musical_time_location_callback (UInt32* outDeltaSampleOffsetToNe
3|1|0 -> 1 + (2 * divisions_per_bar)
etc.
*/
+ bbt.beats = 1;
+ bbt.ticks = 0;
- *outCurrentMeasureDownBeat = 1 + metric.meter().divisions_per_bar() * (bbt.bars - 1);
+ *outCurrentMeasureDownBeat = tmap..pulse_at_bbt (bbt) * 4.0;
}
return noErr;
@@ -1933,38 +1911,14 @@ AUPlugin::get_transport_state_callback (Boolean* outIsPlaying,
TempoMap& tmap (_session.tempo_map());
- /* more than 1 meter means that a simplistic computation (and interpretation) of
- a beat position will be incorrect. so refuse to offer the value.
- */
-
- if (tmap.n_meters() > 1) {
- return kAudioUnitErr_CannotDoInCurrentContext;
- }
-
Timecode::BBT_Time bbt;
if (outCycleStartBeat) {
- TempoMetric metric = tmap.metric_at (loc->start() + input_offset);
- bbt = _session.tempo_map().bbt_at_frame (loc->start() + input_offset);
-
- float beat;
- beat = metric.meter().divisions_per_bar() * bbt.bars;
- beat += bbt.beats;
- beat += bbt.ticks / Timecode::BBT_Time::ticks_per_beat;
-
- *outCycleStartBeat = beat;
+ *outCycleStartBeat = tmap.quarter_note_at_frame (loc->start() + input_offset);
}
if (outCycleEndBeat) {
- TempoMetric metric = tmap.metric_at (loc->end() + input_offset);
- bbt = _session.tempo_map().bbt_at_frame (loc->end() + input_offset);
-
- float beat;
- beat = metric.meter().divisions_per_bar() * bbt.bars;
- beat += bbt.beats;
- beat += bbt.ticks / Timecode::BBT_Time::ticks_per_beat;
-
- *outCycleEndBeat = beat;
+ *outCycleEndBeat = tmap.quarter_note_at_frame (loc->end() + input_offset);
}
}
}