friend class AudioTrack;
int process (BufferSet&, framepos_t transport_frame, pframes_t nframes, framecnt_t &, bool need_disk_signal);
+ frameoffset_t calculate_playback_distance (pframes_t nframes);
bool commit (framecnt_t);
private:
friend class Track;
virtual int process (BufferSet&, framepos_t transport_frame, pframes_t nframes, framecnt_t &, bool need_disk_signal) = 0;
+ virtual frameoffset_t calculate_playback_distance (pframes_t nframes) = 0;
virtual bool commit (framecnt_t) = 0;
//private:
friend class MidiTrack;
int process (BufferSet&, framepos_t transport_frame, pframes_t nframes, framecnt_t &, bool need_diskstream);
+ frameoffset_t calculate_playback_distance (pframes_t nframes);
bool commit (framecnt_t nframes);
static framecnt_t midi_readahead;
return 0;
}
+frameoffset_t
+AudioDiskstream::calculate_playback_distance (pframes_t nframes)
+{
+ frameoffset_t playback_distance = nframes;
+
+ if (record_enabled()) {
+ playback_distance = nframes;
+ } else if (_actual_speed != 1.0f && _actual_speed != -1.0f) {
+ interpolation.set_speed (_target_speed);
+ boost::shared_ptr<ChannelList> c = channels.reader();
+ int channel = 0;
+ for (ChannelList::iterator chan = c->begin(); chan != c->end(); ++chan, ++channel) {
+ playback_distance = interpolation.interpolate (channel, nframes, NULL, NULL);
+ }
+ } else {
+ playback_distance = nframes;
+ }
+
+ if (_actual_speed < 0.0) {
+ return -playback_distance;
+ } else {
+ return playback_distance;
+ }
+}
+
/** Update various things including playback_sample, read pointer on each channel's playback_buf
* and write pointer on each channel's capture_buf. Also wout whether the butler is needed.
* @return true if the butler is required.
boost::shared_ptr<ChannelList> c = channels.reader();
for (chan = c->begin(); chan != c->end(); ++chan) {
- (*chan)->playback_buf->increment_read_ptr (distance);
+ (*chan)->playback_buf->increment_read_ptr (llabs(distance));
}
if (first_recordable_frame < max_framepos) {
Glib::Threads::RWLock::ReaderLock lm (_processor_lock, Glib::Threads::TRY_LOCK);
if (!lm.locked()) {
+ boost::shared_ptr<AudioDiskstream> diskstream = audio_diskstream();
+ framecnt_t playback_distance = diskstream->calculate_playback_distance(nframes);
+ if (can_internal_playback_seek(llabs(playback_distance))) {
+ /* TODO should declick */
+ internal_playback_seek(playback_distance);
+ }
return 0;
}
return 0;
}
+frameoffset_t
+MidiDiskstream::calculate_playback_distance (pframes_t nframes)
+{
+ frameoffset_t playback_distance = nframes;
+
+ /* XXX: should be doing varispeed stuff once it's implemented in ::process() above */
+
+ if (_actual_speed < 0.0) {
+ return -playback_distance;
+ } else {
+ return playback_distance;
+ }
+}
+
bool
MidiDiskstream::commit (framecnt_t playback_distance)
{
{
Glib::Threads::RWLock::ReaderLock lm (_processor_lock, Glib::Threads::TRY_LOCK);
if (!lm.locked()) {
+ boost::shared_ptr<MidiDiskstream> diskstream = midi_diskstream();
+ framecnt_t playback_distance = diskstream->calculate_playback_distance(nframes);
+ if (can_internal_playback_seek(llabs(playback_distance))) {
+ /* TODO should declick, and/or note-off */
+ internal_playback_seek(playback_distance);
+ }
return 0;
}
{
Glib::Threads::RWLock::ReaderLock lm (_processor_lock, Glib::Threads::TRY_LOCK);
if (!lm.locked()) {
+ framecnt_t playback_distance = _diskstream->calculate_playback_distance(nframes);
+ if (can_internal_playback_seek(playback_distance)) {
+ internal_playback_seek(playback_distance);
+ }
return 0;
}