Cleanup: improve some variable names.
authorCarl Hetherington <cth@carlh.net>
Tue, 19 Apr 2022 11:09:49 +0000 (13:09 +0200)
committerCarl Hetherington <cth@carlh.net>
Wed, 20 Apr 2022 20:12:46 +0000 (22:12 +0200)
src/lib/audio_buffers.cc
src/lib/audio_buffers.h

index 1d3598270121b48f91fd3303f877cd6f2df0176f..51f6c6c337846cd49bbf3eb5267a31b25c4bc300 100644 (file)
@@ -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>
-AudioBuffers::channel (int c) const
+AudioBuffers::channel (int channel) const
 {
-       auto o = make_shared<AudioBuffers>(1, frames());
-       o->copy_channel_from (this, c, 0);
-       return o;
+       auto output = make_shared<AudioBuffers>(1, frames());
+       output->copy_channel_from (this, channel, 0);
+       return output;
 }
 
 
index 146d5bd3e2d8f88c260b3f7776d0104cd66d8c0b..1f0f5f28aa3d904b9fedb7d68220b6ef982c38f3 100644 (file)
@@ -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);