From aba8cb303255a5d72ee17ca072d3ae31b7832af4 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 19 Apr 2022 13:09:49 +0200 Subject: [PATCH] Cleanup: improve some variable names. --- src/lib/audio_buffers.cc | 47 ++++++++++++++++++---------------------- src/lib/audio_buffers.h | 2 +- 2 files changed, 22 insertions(+), 27 deletions(-) diff --git a/src/lib/audio_buffers.cc b/src/lib/audio_buffers.cc index 1d3598270..51f6c6c33 100644 --- a/src/lib/audio_buffers.cc +++ b/src/lib/audio_buffers.cc @@ -124,14 +124,14 @@ AudioBuffers::deallocate () } -/** @param c Channel index. +/** @param channel Channel index. * @return Buffer for this channel. */ float* -AudioBuffers::data (int c) const +AudioBuffers::data (int channel) const { - DCPOMATIC_ASSERT (c >= 0 && c < _channels); - return _data[c]; + DCPOMATIC_ASSERT (channel >= 0 && channel < _channels); + return _data[channel]; } @@ -141,14 +141,14 @@ AudioBuffers::data (int c) const * @param f Frames; must be less than or equal to the number of allocated frames. */ void -AudioBuffers::set_frames (int32_t f) +AudioBuffers::set_frames (int32_t frames) { - DCPOMATIC_ASSERT (f <= _allocated_frames); + DCPOMATIC_ASSERT (frames <= _allocated_frames); - if (f < _frames) { - make_silent (f, _frames - f); + if (frames < _frames) { + make_silent (frames, _frames - frames); } - _frames = f; + _frames = frames; } @@ -156,24 +156,22 @@ AudioBuffers::set_frames (int32_t f) void AudioBuffers::make_silent () { - for (int i = 0; i < _channels; ++i) { - make_silent (i); + for (int channel = 0; channel < _channels; ++channel) { + make_silent (channel); } } -/** Make all samples on a given channel silent. - * @param c Channel. - */ +/** Make all samples on a given channel silent */ void -AudioBuffers::make_silent (int c) +AudioBuffers::make_silent (int channel) { - DCPOMATIC_ASSERT (c >= 0 && c < _channels); + DCPOMATIC_ASSERT (channel >= 0 && channel < _channels); /* This isn't really allowed, as all-bits-0 is not guaranteed to mean a 0 float, but it seems that we can get away with it. */ - memset (_data[c], 0, _frames * sizeof(float)); + memset (_data[channel], 0, _frames * sizeof(float)); } @@ -186,11 +184,11 @@ AudioBuffers::make_silent (int32_t from, int32_t frames) { DCPOMATIC_ASSERT ((from + frames) <= _allocated_frames); - for (int c = 0; c < _channels; ++c) { + for (int channel = 0; channel < _channels; ++channel) { /* This isn't really allowed, as all-bits-0 is not guaranteed to mean a 0 float, but it seems that we can get away with it. */ - memset (_data[c] + from, 0, frames * sizeof(float)); + memset (_data[channel] + from, 0, frames * sizeof(float)); } } @@ -341,15 +339,12 @@ AudioBuffers::apply_gain (float dB) } -/** @param c Channel index. - * @return AudioBuffers object containing only channel `c' from this AudioBuffers. - */ shared_ptr -AudioBuffers::channel (int c) const +AudioBuffers::channel (int channel) const { - auto o = make_shared(1, frames()); - o->copy_channel_from (this, c, 0); - return o; + auto output = make_shared(1, frames()); + output->copy_channel_from (this, channel, 0); + return output; } diff --git a/src/lib/audio_buffers.h b/src/lib/audio_buffers.h index 146d5bd3e..1f0f5f28a 100644 --- a/src/lib/audio_buffers.h +++ b/src/lib/audio_buffers.h @@ -72,7 +72,7 @@ public: void set_frames (int32_t f); void make_silent (); - void make_silent (int c); + void make_silent (int channel); void make_silent (int32_t from, int32_t frames); void apply_gain (float); -- 2.30.2