diff --git a/libs/ardour/midi_diskstream.cc b/libs/ardour/midi_diskstream.cc index 7b196e1fd0..ae0828a3a4 100644 --- a/libs/ardour/midi_diskstream.cc +++ b/libs/ardour/midi_diskstream.cc @@ -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 {