I'm trying to debug a C++ program that I use (but didn't write). I can read plain C reasonably well but the C++ syntax below has me stumped:
pbuf [ j ].min *= gain;
i is an int, gain is a float and min is part of std::min. The part I'm not familiar with is the array subscript operator immediately followed by the '.' operator, ie. '[ j ].min'. If someone could explain what that means I'd appreciate it.
pbuf is a pointer to an array of objects of type Peak. min and max here are member variables of the Peak class/struct. Most likely they are of type float.
Those two float variables have their existing value multiplied by the scale factor gain.
The for-loop at line 48 to 52 does that same scaling for all the objects in the array.
In the context of a WAV file, it seems the array contains a series of min and max peak values (indicating the top and bottom of the waveform).
The definition of pbuf (class Peak) is in Engine/Peak.h. The pbuf[ j ].min is syntax pointing to the "jth" offset of the array of Peak objects. In particular:
1 2 3 4
pbuf[ j ].min *= gain;
is multiplying the min variable of the "jth" object by gain and assigning the result back to min.
Thanks for the replies. They answer my question perfectly. (Now feeling a little stupid as I should have realised 'min' had nothing to do with std::min).