0

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.

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Jieke Wei
  • 173
  • 2
  • 13

1 Answers1

0

The answer is use beginfadeout method with period of 0

Jieke Wei
  • 173
  • 2
  • 13