Exemplo n.º 1
0
        private void FadeOut(float[] buffer, int offset, int sourceSamplesRead)
        {
            int i = 0;

            while (i < sourceSamplesRead)
            {
                float num = 1f - (float)this.fadeSamplePosition / (float)this.fadeSampleCount;
                for (int j = 0; j < this.source.WaveFormat.Channels; j++)
                {
                    buffer[offset + i++] *= num;
                }
                this.fadeSamplePosition++;
                if (this.fadeSamplePosition > this.fadeSampleCount)
                {
                    this.fadeState = FadeInOutSampleProvider.FadeState.Silence;
                    FadeInOutSampleProvider.ClearBuffer(buffer, i + offset, sourceSamplesRead - i);
                    return;
                }
            }
        }
Exemplo n.º 2
0
        public int Read(float[] buffer, int offset, int count)
        {
            int num = this.source.Read(buffer, offset, count);

            lock (this.lockObject)
            {
                if (this.fadeState == FadeInOutSampleProvider.FadeState.FadingIn)
                {
                    this.FadeIn(buffer, offset, num);
                }
                else if (this.fadeState == FadeInOutSampleProvider.FadeState.FadingOut)
                {
                    this.FadeOut(buffer, offset, num);
                }
                else if (this.fadeState == FadeInOutSampleProvider.FadeState.Silence)
                {
                    FadeInOutSampleProvider.ClearBuffer(buffer, offset, count);
                }
            }
            return(num);
        }