Skip to content

Commit

Permalink
resampler: delete flush()
Browse files Browse the repository at this point in the history
  • Loading branch information
hinto-janai committed Nov 28, 2023
1 parent 6861ac5 commit 5d49dd1
Showing 1 changed file with 12 additions and 21 deletions.
33 changes: 12 additions & 21 deletions shukusai/src/audio/resampler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,18 @@ where
convert_samples_any(&input, &mut self.input);

// Check if more samples are required.
//
// FIXME: This almost definitely makes audio
// clippy and makes "gapless playback" quite gappy
// as we're adding artificial silence in-between
// tracks with ending frames that have slightly
// less samples than the rest of the track.
//
// Realistically thogugh, this only affects windows
// users as macos/linux don't need resamplers.
//
// This code will be fixed... when sansan eventually
// gets finished and integrated in festival.
let len = self.input[0].len();
if len < self.duration {
let partial_len = len % self.duration;
Expand All @@ -112,27 +124,6 @@ where

self.resample_inner()
}

/// Resample any remaining samples in the resample buffer.
pub(super) fn flush(&mut self) -> Result<&[T], Error> {
let len = self.input[0].len();

if len == 0 {
bail!("len == 0")
}

let partial_len = len % self.duration;

if partial_len != 0 {
// Fill each input channel buffer with silence to the next multiple of the resampler
// duration.
for channel in self.input.iter_mut() {
channel.resize(len + (self.duration - partial_len), 0.0);
}
}

self.resample_inner()
}
}

fn convert_samples_any(input: &AudioBufferRef<'_>, output: &mut [Vec<f32>]) {
Expand Down

0 comments on commit 5d49dd1

Please sign in to comment.