NO-OP session-property comments
[ardour.git] / libs / ardour / session_vst.cc
index ad732e052a185f632a77233b7e0af7e68c08e84f..7b52b3cdf49b868073574ac5c70df6228e6fc7e0 100644 (file)
@@ -34,7 +34,7 @@
 #include <fst.h>
 #endif
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace ARDOUR;
 
@@ -200,8 +200,8 @@ intptr_t Session::vst_callback (
 
                timeinfo->nanoSeconds = g_get_monotonic_time () * 1000;
 
-               if (session) {
-                       framepos_t now = session->transport_frame();
+               if (plug && session) {
+                       framepos_t now = plug->transport_frame();
 
                        timeinfo->samplePos = now;
                        timeinfo->sampleRate = session->frame_rate();
@@ -223,29 +223,10 @@ intptr_t Session::vst_callback (
                                Timecode::BBT_Time bbt;
 
                                try {
-                                       session->tempo_map().bbt_time (now, bbt);
-
-                                       /* PPQ = pulse per quarter
-                                        * VST's "pulse" is our "division".
-                                        *
-                                        * 8 divisions per bar, 1 division = quarter, so 8 quarters per bar, ppq = 1
-                                        * 8 divisions per bar, 1 division = eighth, so  4 quarters per bar, ppq = 2
-                                        * 4 divisions per bar, 1 division = quarter, so  4 quarters per bar, ppq = 1
-                                        * 4 divisions per bar, 1 division = half, so 8 quarters per bar, ppq = 0.5
-                                        * 4 divisions per bar, 1 division = fifth, so (4 * 5/4) quarters per bar, ppq = 5/4
-                                        *
-                                        * general: divs_per_bar / (note_type / 4.0)
-                                        */
-                                       double ppq_scaling =  tm.meter().note_divisor() / 4.0;
-
-                                       /* Note that this assumes constant meter/tempo throughout the session. Stupid VST */
-                                       double ppqBar = double(bbt.bars - 1) * tm.meter().divisions_per_bar();
-                                       double ppqBeat = double(bbt.beats - 1);
-                                       double ppqTick = double(bbt.ticks) / Timecode::BBT_Time::ticks_per_beat;
-
-                                       ppqBar *= ppq_scaling;
-                                       ppqBeat *= ppq_scaling;
-                                       ppqTick *= ppq_scaling;
+                                       bbt = session->tempo_map().bbt_at_frame_rt (now);
+
+                                       double ppqBar;
+                                       double ppqPos = vst_ppq (tm, bbt, ppqBar);
 
                                        if (value & (kVstPpqPosValid)) {
                                                timeinfo->ppqPos = ppqPos;
@@ -299,7 +280,7 @@ intptr_t Session::vst_callback (
                                newflags |= kVstTransportRecording;
                        }
 
-                       if (session->transport_speed () != 0.0f) {
+                       if (plug->transport_speed () != 0.0f) {
                                newflags |= kVstTransportPlaying;
                        }
 
@@ -310,10 +291,10 @@ intptr_t Session::vst_callback (
                                        double ppqBar;
                                        Timecode::BBT_Time bbt;
 
-                                       session->tempo_map().bbt_time_rt (looploc->start (), bbt);
+                                       bbt = session->tempo_map ().bbt_at_frame_rt (looploc->start ());
                                        timeinfo->cycleStartPos = vst_ppq (tm, bbt, ppqBar);
 
-                                       session->tempo_map().bbt_time_rt (looploc->end (), bbt);
+                                       bbt = session->tempo_map ().bbt_at_frame_rt (looploc->end ());
                                        timeinfo->cycleEndPos = vst_ppq (tm, bbt, ppqBar);
 
                                        newflags |= kVstCyclePosValid;
@@ -568,4 +549,3 @@ intptr_t Session::vst_callback (
 
        return 0;
 }
-