Пример #1
0
        private void FadeIn(float[] buffer, int offset, int sourceSamplesRead)
        {
            int   sample     = 0;
            float multiplier = 0.0f;

            while (sample < sourceSamplesRead)
            {
                if (_crossFadeInstance != null)
                {
                    var fadeinX = (fadeSamplePosition / (float)fadeSampleCount);
                    multiplier = _crossFadeInstance.FadeInVolume(fadeinX);
                }
                else
                {
                    multiplier = (fadeSamplePosition / (float)fadeSampleCount);
                }
                for (int ch = 0; ch < source.WaveFormat.Channels; ch++)
                {
                    buffer[offset + sample] *= multiplier;
                    sample++;
                }
                fadeSamplePosition++;
                if (fadeSamplePosition >= fadeSampleCount)
                {
                    fadeState = FadeState.FullVolume;
                    break;
                }
            }
        }
Пример #2
0
        private void CalculateFadeInOutVolumes()
        {
            int   sample     = 0;
            float multiplier = 0.0f;

            // Calculate Fade-out Volumes
            while (sample < fadeSampleCount)
            {
                if (_settingsObject.XVFades == true)
                {
                    var fadeoutX = (sample / (float)fadeSampleCount);
                    multiplier = _crossFadeInstance.FadeOutVolume(fadeoutX);
                }
                else
                {
                    multiplier = 1.0f - (sample / (float)fadeSampleCount);
                }

                _fadeoutVolumes[sample] = multiplier;
                sample++;
            }
            sample     = 0;
            multiplier = 0.0f;
            // Calculate Fade-in Volumes
            while (sample < fadeSampleCount)
            {
                if (_settingsObject.XVFades == true)
                {
                    var fadeinX = (sample / (float)fadeSampleCount);
                    multiplier = _crossFadeInstance.FadeInVolume(fadeinX);
                }
                else
                {
                    multiplier = (sample / (float)fadeSampleCount);
                }

                _fadeinVolumes[sample] = multiplier;
                sample++;
            }
        }