13
0

use new CubicInterpolation API

This commit is contained in:
Paul Davis 2017-10-02 12:43:20 -04:00
parent 45b1f6f6b8
commit 3f48d00081
4 changed files with 35 additions and 28 deletions

View File

@ -240,7 +240,7 @@ DiskIOProcessor::add_channel_to (boost::shared_ptr<ChannelList> c, uint32_t how_
{ {
while (how_many--) { while (how_many--) {
c->push_back (new ChannelInfo (_session.butler()->audio_diskstream_playback_buffer_size())); c->push_back (new ChannelInfo (_session.butler()->audio_diskstream_playback_buffer_size()));
interpolation.add_channel_to (_session.butler()->audio_diskstream_playback_buffer_size(), speed_buffer_size); interpolation.add_channel ();
DEBUG_TRACE (DEBUG::DiskIO, string_compose ("%1: new channel, write space = %2 read = %3\n", DEBUG_TRACE (DEBUG::DiskIO, string_compose ("%1: new channel, write space = %2 read = %3\n",
name(), name(),
c->back()->buf->write_space(), c->back()->buf->write_space(),
@ -265,7 +265,7 @@ DiskIOProcessor::remove_channel_from (boost::shared_ptr<ChannelList> c, uint32_t
while (how_many-- && !c->empty()) { while (how_many-- && !c->empty()) {
delete c->back(); delete c->back();
c->pop_back(); c->pop_back();
interpolation.remove_channel_from (); interpolation.remove_channel ();
} }
return 0; return 0;

View File

@ -265,8 +265,7 @@ DiskReader::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp
if (speed != 1.0f && speed != -1.0f) { if (speed != 1.0f && speed != -1.0f) {
interpolation.set_speed (speed); interpolation.set_speed (speed);
midi_interpolation.set_speed (speed); disk_samples_to_consume = interpolation.distance (nframes);
disk_samples_to_consume = midi_interpolation.distance (nframes);
if (speed < 0.0) { if (speed < 0.0) {
disk_samples_to_consume = -disk_samples_to_consume; disk_samples_to_consume = -disk_samples_to_consume;
} }
@ -321,12 +320,19 @@ DiskReader::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp
disk_signal = output.data (); disk_signal = output.data ();
} }
if (start_sample < playback_sample) { if (speed > 0) {
cerr << owner()->name() << " SS = " << start_sample << " PS = " << playback_sample << endl; if (start_sample < playback_sample) {
abort (); cerr << owner()->name() << " SS = " << start_sample << " PS = " << playback_sample << endl;
abort ();
}
} else if (speed < 0) {
if (playback_sample < start_sample) {
cerr << owner()->name() << " SS = " << start_sample << " PS = " << playback_sample << " REVERSE" << endl;
abort ();
}
} }
if (start_sample != playback_sample) { if ((speed > 0) && (start_sample != playback_sample)) {
cerr << owner()->name() << " playback not aligned, jump ahead " << (start_sample - playback_sample) << endl; cerr << owner()->name() << " playback not aligned, jump ahead " << (start_sample - playback_sample) << endl;
if (can_internal_playback_seek (start_sample - playback_sample)) { if (can_internal_playback_seek (start_sample - playback_sample)) {
@ -342,10 +348,9 @@ DiskReader::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp
if (disk_samples_to_consume <= (samplecnt_t) chaninfo->rw_vector.len[0]) { if (disk_samples_to_consume <= (samplecnt_t) chaninfo->rw_vector.len[0]) {
if (fabsf (speed) != 1.0f) { if (fabsf (speed) != 1.0f) {
(void) interpolation.interpolate ( samplecnt_t ocnt = nframes;
n, disk_samples_to_consume, samplecnt_t icnt = chaninfo->rw_vector.len[0];
chaninfo->rw_vector.buf[0], (void) interpolation.interpolate (n, icnt, chaninfo->rw_vector.buf[0], ocnt, disk_signal);
disk_signal);
} else if (speed != 0.0) { } else if (speed != 0.0) {
memcpy (disk_signal, chaninfo->rw_vector.buf[0], sizeof (Sample) * disk_samples_to_consume); memcpy (disk_signal, chaninfo->rw_vector.buf[0], sizeof (Sample) * disk_samples_to_consume);
} }
@ -356,18 +361,18 @@ DiskReader::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp
if (disk_samples_to_consume <= total) { if (disk_samples_to_consume <= total) {
/* We have enough samples, but not in one lump.
*/
if (fabsf (speed) != 1.0f) { if (fabsf (speed) != 1.0f) {
interpolation.interpolate (n, chaninfo->rw_vector.len[0], samplecnt_t ocnt = nframes;
chaninfo->rw_vector.buf[0], samplecnt_t icnt = interpolation.interpolate (n, chaninfo->rw_vector.len[0], chaninfo->rw_vector.buf[0], ocnt, disk_signal);
disk_signal);
disk_signal += chaninfo->rw_vector.len[0]; if (ocnt < nframes) {
interpolation.interpolate (n, disk_samples_to_consume - chaninfo->rw_vector.len[0], disk_signal += ocnt;
chaninfo->rw_vector.buf[1], ocnt = nframes - ocnt;
disk_signal); icnt = interpolation.interpolate (n, chaninfo->rw_vector.len[1], chaninfo->rw_vector.buf[1], ocnt, disk_signal);
}
} else if (speed != 0.0) { } else if (speed != 0.0) {
memcpy (disk_signal, memcpy (disk_signal,
chaninfo->rw_vector.buf[0], chaninfo->rw_vector.buf[0],
chaninfo->rw_vector.len[0] * sizeof (Sample)); chaninfo->rw_vector.len[0] * sizeof (Sample));

View File

@ -436,9 +436,12 @@ Session::process_with_events (pframes_t nframes)
if (_transport_speed == 1.0) { if (_transport_speed == 1.0) {
samples_moved = (samplecnt_t) nframes; samples_moved = (samplecnt_t) nframes;
} else { } else {
interpolation.set_target_speed (_target_transport_speed); /* use a cubic midi interpolation to compute the number of
interpolation.set_speed (_transport_speed); * samples we will move at the current speed.
samples_moved = (samplecnt_t) interpolation.interpolate (0, nframes, 0, 0); */
CubicInterpolation interp;
interp.set_speed (_transport_speed);
samples_moved = interp.distance (nframes);
} }
end_sample = _transport_sample + samples_moved; end_sample = _transport_sample + samples_moved;
@ -887,9 +890,8 @@ Session::process_without_events (pframes_t nframes)
if (_transport_speed == 1.0) { if (_transport_speed == 1.0) {
samples_moved = (samplecnt_t) nframes; samples_moved = (samplecnt_t) nframes;
} else { } else {
interpolation.set_target_speed (_target_transport_speed);
interpolation.set_speed (_transport_speed); interpolation.set_speed (_transport_speed);
samples_moved = (samplecnt_t) interpolation.interpolate (0, nframes, 0, 0); samples_moved = interpolation.distance (nframes);
} }
if (!_exporting && !timecode_transmission_suspended()) { if (!_exporting && !timecode_transmission_suspended()) {

View File

@ -184,7 +184,7 @@ Session::pre_engine_init (string fullpath)
g_atomic_int_set (&_capture_load, 100); g_atomic_int_set (&_capture_load, 100);
set_next_event (); set_next_event ();
_all_route_group->set_active (true, this); _all_route_group->set_active (true, this);
interpolation.add_channel_to (0, 0); interpolation.add_channel ();
if (config.get_use_video_sync()) { if (config.get_use_video_sync()) {
waiting_for_sync_offset = true; waiting_for_sync_offset = true;