- const Tempo& t (session->tempo_map().tempo_at (session->transport_frame()));
- _timeInfo.tempo = t.beats_per_minute ();
- _timeInfo.flags |= (kVstTempoValid);
+ const Tempo& t (session->tempo_map().tempo_at_sample (now));
+ timeinfo->tempo = t.quarter_notes_per_minute ();
+ newflags |= (kVstTempoValid);
+ }
+ if (value & (kVstTimeSigValid)) {
+ const MeterSection& ms (session->tempo_map().meter_section_at_sample (now));
+ timeinfo->timeSigNumerator = ms.divisions_per_bar ();
+ timeinfo->timeSigDenominator = ms.note_divisor ();
+ newflags |= (kVstTimeSigValid);
+ }
+ if ((value & (kVstPpqPosValid)) || (value & (kVstBarsValid))) {
+ Timecode::BBT_Time bbt;
+
+ try {
+ bbt = session->tempo_map().bbt_at_sample_rt (now);
+ bbt.beats = 1;
+ bbt.ticks = 0;
+ /* exact quarter note */
+ double ppqBar = session->tempo_map().quarter_note_at_bbt_rt (bbt);
+ /* quarter note at sample position (not rounded to note subdivision) */
+ double ppqPos = session->tempo_map().quarter_note_at_sample_rt (now);
+ if (value & (kVstPpqPosValid)) {
+ timeinfo->ppqPos = ppqPos;
+ newflags |= kVstPpqPosValid;
+ }
+
+ if (value & (kVstBarsValid)) {
+ timeinfo->barStartPos = ppqBar;
+ newflags |= kVstBarsValid;
+ }
+
+ } catch (...) {
+ /* relax */
+ }