From 13a6c22f7477864909348c4ab46986ee3f03fd3d Mon Sep 17 00:00:00 2001 From: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Mon, 11 Oct 2021 10:53:19 -0700 Subject: [PATCH] audio: optimized setting silence I don't know why I thought we'd ever need a "fill" function for samples, but now that I've accepted we don't, this is so much faster. --- app/codec/samplebuffer.cpp | 10 ++++------ app/codec/samplebuffer.h | 4 ++-- app/render/renderprocessor.cpp | 4 ++-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/app/codec/samplebuffer.cpp b/app/codec/samplebuffer.cpp index df00e0f7f..1753e80c1 100644 --- a/app/codec/samplebuffer.cpp +++ b/app/codec/samplebuffer.cpp @@ -208,12 +208,12 @@ void SampleBuffer::transform_volume_for_sample_on_channel(int sample_index, int data_[channel][sample_index] *= volume; } -void SampleBuffer::fill(const float &f) +void SampleBuffer::silence() { - fill(f, 0, sample_count_per_channel_); + silence(0, sample_count_per_channel_); } -void SampleBuffer::fill(const float &f, int start_sample, int end_sample) +void SampleBuffer::silence(int start_sample, int end_sample) { if (!is_allocated()) { qWarning() << "Tried to fill an unallocated sample buffer"; @@ -221,9 +221,7 @@ void SampleBuffer::fill(const float &f, int start_sample, int end_sample) } for (int i=0;ifill(0); + block_range_buffer->silence(); NodeValueTable merged_table; @@ -284,7 +284,7 @@ NodeValueTable RenderProcessor::GenerateBlockTable(const Track *track, const Tim if (qIsNull(speed_value)) { // Just silence, don't think there's any other practical application of 0 speed audio - samples_from_this_block->fill(0); + samples_from_this_block->silence(); } else if (!qFuzzyCompare(speed_value, 1.0)) { // Multiply time samples_from_this_block->speed(speed_value);