prototype basic midi varispeed
authorRobin Gareus <robin@gareus.org>
Tue, 10 Mar 2015 18:33:05 +0000 (19:33 +0100)
committerRobin Gareus <robin@gareus.org>
Tue, 10 Mar 2015 21:15:44 +0000 (22:15 +0100)
libs/ardour/midi_diskstream.cc

index 7b196e1fd0db6ab8cd0111870cab8c1f737b6bf8..ae0828a3a495703899c5dd076ae1a00c23aafbd6 100644 (file)
@@ -528,18 +528,38 @@ MidiDiskstream::process (BufferSet& bufs, framepos_t transport_frame, pframes_t
 
                playback_distance = nframes;
 
+#ifndef NO_SIMPLE_MIDI_VARISPEED
+               if (_target_speed > 0) {
+                       playback_distance = nframes * _target_speed;
+               }
+#endif
+
        }
 
        if (need_disk_signal) {
                /* copy the diskstream data to all output buffers */
                
                MidiBuffer& mbuf (bufs.get_midi (0));
+#ifndef NO_SIMPLE_MIDI_VARISPEED
+               get_playback (mbuf, nframes * _target_speed);
+#else
                get_playback (mbuf, nframes);
-               
+#endif
+
                /* leave the audio count alone */
                ChanCount cnt (DataType::MIDI, 1);
                cnt.set (DataType::AUDIO, bufs.count().n_audio());
                bufs.set_count (cnt);
+
+#ifndef NO_SIMPLE_MIDI_VARISPEED
+               if (_target_speed > 0 && playback_distance != nframes) {
+                       MidiBuffer& mbuf (bufs.get_midi (0));
+                       for (MidiBuffer::iterator i = mbuf.begin(); i != mbuf.end(); ++i) {
+                               MidiBuffer::TimeType *tme = i.timeptr();
+                               *tme = (*tme) / _target_speed;
+                       }
+               }
+#endif
        }
 
        return 0;
@@ -548,10 +568,14 @@ MidiDiskstream::process (BufferSet& bufs, framepos_t transport_frame, pframes_t
 frameoffset_t
 MidiDiskstream::calculate_playback_distance (pframes_t nframes)
 {
+#ifndef NO_SIMPLE_MIDI_VARISPEED
+       frameoffset_t playback_distance = nframes * _target_speed;
+#else
        frameoffset_t playback_distance = nframes;
 
        /* XXX: should be doing varispeed stuff once it's implemented in ::process() above */
 
+#endif
        if (_actual_speed < 0.0) {
                return -playback_distance;
        } else {