X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fdelay_line.cc;h=b0180800a4625795823697c2dd5c9d1bfd2fcfff;hb=af671aa256ae0d2fa38a6740cea7fc0f6b45b5b8;hp=45d8e9d9d36b86f1d79beb9f7db6dca8589e6032;hpb=70447e72a5595fa03eb0a82b5e93247fcc5cad2b;p=dcpomatic.git diff --git a/src/lib/delay_line.cc b/src/lib/delay_line.cc index 45d8e9d9d..b0180800a 100644 --- a/src/lib/delay_line.cc +++ b/src/lib/delay_line.cc @@ -27,76 +27,31 @@ using std::min; using boost::shared_ptr; -/** @param channels Number of channels of audio. - * @param frames Delay in frames, +ve to move audio later. +/* @param seconds Delay in seconds, +ve to move audio later. */ -DelayLine::DelayLine (Log* log, int channels, int frames) - : AudioProcessor (log) - , _negative_delay_remaining (0) - , _frames (frames) +DelayLine::DelayLine (shared_ptr log, double seconds) + : TimedAudioVideoProcessor (log) + , _seconds (seconds) { - if (_frames > 0) { - /* We need a buffer to keep some data in */ - _buffers.reset (new AudioBuffers (channels, _frames)); - _buffers->make_silent (); - } else if (_frames < 0) { - /* We can do -ve delays just by chopping off - the start, so no buffer needed. - */ - _negative_delay_remaining = -_frames; - } + } void -DelayLine::process_audio (shared_ptr data) +DelayLine::process_audio (shared_ptr data, double t) { - if (_buffers) { - /* We have some buffers, so we are moving the audio later */ - - /* Copy the input data */ - AudioBuffers input (*data.get ()); - - int to_do = data->frames (); - - /* Write some of our buffer to the output */ - int const from_buffer = min (to_do, _buffers->frames()); - data->copy_from (_buffers.get(), from_buffer, 0, 0); - to_do -= from_buffer; - - /* Write some of the input to the output */ - int const from_input = to_do; - data->copy_from (&input, from_input, 0, from_buffer); - - int const left_in_buffer = _buffers->frames() - from_buffer; - - /* Shuffle our buffer down */ - _buffers->move (from_buffer, 0, left_in_buffer); - - /* Copy remaining input data to our buffer */ - _buffers->copy_from (&input, input.frames() - from_input, from_input, left_in_buffer); - - } else { - - /* Chop the initial data off until _negative_delay_remaining - is zero, then just pass data. - */ - - int const to_do = min (data->frames(), _negative_delay_remaining); - if (to_do) { - data->move (to_do, 0, data->frames() - to_do); - data->set_frames (data->frames() - to_do); - _negative_delay_remaining -= to_do; - } + if (_seconds > 0) { + t += _seconds; } - Audio (data); + Audio (data, t); } void -DelayLine::process_end () +DelayLine::process_video (shared_ptr image, bool same, boost::shared_ptr sub, double t) { - if (_frames < 0) { - _buffers->make_silent (); - Audio (_buffers); + if (_seconds < 0) { + t += _seconds; } + + Video (image, same, sub, t); }