예제 #1
0
        public void Update(double dt, double playerPosition)
        {
            double mul = 1 / Math.Pow(AmplitudeReduction, dt);

            for (int i = 0; i < BufferSize; i++)
            {
                _buffer[i] *= mul;
            }

            bool gotChanges = false;

            _unreadTime += 1 / 60.0;// dt;
            while (_unreadTime > 1 / 60.0)
            {
                gotChanges      = true;
                _unreadTime    -= 1 / 60.0;
                playerPosition %= _buffer.Length;
                int pos = (int)Math.Round(playerPosition - DistanceFromPlayer);
                _buffer[(pos % _buffer.Length + _buffer.Length) % _buffer.Length] = _microphone.GetTickValue();
                pos -= 500;
                _buffer[(pos % _buffer.Length + _buffer.Length) % _buffer.Length] = 0;
            }

            if (gotChanges)
            {
                Smooth();
            }
        }