I am trying to use the fadeout function in NAudio. However, I cannot understand the meaning of signatures of function. I have no idea about buffer, offset and sourceSamplesRead.
private void FadeOut(float[] buffer, int offset, int sourceSamplesRead)
{
int sample = 0;
while (sample < sourceSamplesRead)
{
float multiplier = 1.0f - (fadeSamplePosition / (float)fadeSampleCount);
for (int ch = 0; ch < source.WaveFormat.Channels; ch++)
{
buffer[offset + sample++] *= multiplier;
}
fadeSamplePosition++;
if (fadeSamplePosition > fadeSampleCount)
{
fadeState = FadeState.Silence;
// clear out the end
ClearBuffer(buffer, sample + offset, sourceSamplesRead - sample);
break;
}
}
}
The documentation of NAudio is here. I find the explanation of the parameters in other functions, but still cannot understand them.
Can anyone explain it to me? An example of using it can be perfect.