From 33d6d0f311b410a5a5a6acb1838a41ec3e91c25b Mon Sep 17 00:00:00 2001 From: ferreum Date: Tue, 8 Aug 2023 12:50:39 +0200 Subject: af_scaletempo2: fix audio artifact on initial WSOLA iteration The first WSOLA iteration overlapped audio with whatever was in the `wsola_output` buffer. This was either silence (if not run before), or old frames (if switching to 1x and back to a different speed). Track the state of the output buffer and memcpy the whole window for the first iteration instead. --- audio/filter/af_scaletempo2_internals.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'audio/filter/af_scaletempo2_internals.h') diff --git a/audio/filter/af_scaletempo2_internals.h b/audio/filter/af_scaletempo2_internals.h index b062159966..64f4104019 100644 --- a/audio/filter/af_scaletempo2_internals.h +++ b/audio/filter/af_scaletempo2_internals.h @@ -80,6 +80,9 @@ struct mp_scaletempo2 { // them and can be copied to output if fill_buffer() is called. It also // specifies the index where the next WSOLA window has to overlap-and-add. int num_complete_frames; + // Whether |wsola_output| contains an additional |ola_hop_size| of overlap + // frames for the next iteration. + bool wsola_output_started; // Overlap-and-add window. float *ola_window; // Transition window, used to update |optimal_block| by a weighted sum of -- cgit v1.2.3