diff options
author | Robin Gareus <robin@gareus.org> | 2016-06-17 22:17:19 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2016-06-17 22:17:58 +0200 |
commit | 425c40ff08f56f9a719e1ee6ba0f1b5897974447 (patch) | |
tree | 075f13615022737e258cb1e44a54f0b75995ce82 /libs | |
parent | f4047b9a2656cbdc3e5cb3e943c6bdb421dccbfa (diff) |
fix upsampling import of X-channel files where buffersize % X != 0
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/import.cc | 8 | ||||
-rw-r--r-- | libs/ardour/resampled_source.cc | 5 |
2 files changed, 7 insertions, 6 deletions
diff --git a/libs/ardour/import.cc b/libs/ardour/import.cc index dbb3db6285..fd5d3bf98a 100644 --- a/libs/ardour/import.cc +++ b/libs/ardour/import.cc @@ -265,14 +265,14 @@ write_audio_data_to_new_files (ImportableSource* source, ImportStatus& status, uint32_t read_count = 0; while (!status.cancel) { - framecnt_t const nread = source->read (data.get(), nframes); + framecnt_t const nread = source->read (data.get(), nframes * channels); if (nread == 0) { break; } - peak = compute_peak (data.get(), nread, peak); + peak = compute_peak (data.get(), nread * channels, peak); - read_count += nread; + read_count += nread / channels; status.progress = 0.5 * read_count / (source->ratio() * source->length() * channels); } @@ -294,7 +294,7 @@ write_audio_data_to_new_files (ImportableSource* source, ImportStatus& status, uint32_t x; uint32_t chn; - if ((nread = source->read (data.get(), nframes)) == 0) { + if ((nread = source->read (data.get(), nframes * channels)) == 0) { #ifdef PLATFORM_WINDOWS /* Flush the data once we've finished importing the file. Windows can */ /* cache the data for very long periods of time (perhaps not writing */ diff --git a/libs/ardour/resampled_source.cc b/libs/ardour/resampled_source.cc index 5c811706d0..ca59d20b58 100644 --- a/libs/ardour/resampled_source.cc +++ b/libs/ardour/resampled_source.cc @@ -73,14 +73,15 @@ framecnt_t ResampledImportableSource::read (Sample* output, framecnt_t nframes) { int err; + size_t bs = floor (blocksize / source->channels()) * source->channels(); /* If the input buffer is empty, refill it. */ if (_src_data.input_frames == 0) { - _src_data.input_frames = source->read (_input, blocksize); + _src_data.input_frames = source->read (_input, bs); /* The last read will not be a full buffer, so set end_of_input. */ - if ((framecnt_t) _src_data.input_frames < blocksize) { + if ((framecnt_t) _src_data.input_frames < bs) { _end_of_input = true; } |