AlphaTab.Audio.Generator.MidiFileGenerator.GenerateVibratorWithParams C# (CSharp) Метод

GenerateVibratorWithParams() приватный Метод

private GenerateVibratorWithParams ( AlphaTab.Model.Track track, int noteStart, int noteDuration, int phaseLength, int bendAmplitude ) : void
track AlphaTab.Model.Track
noteStart int
noteDuration int
phaseLength int
bendAmplitude int
Результат void
        private void GenerateVibratorWithParams(Track track, int noteStart, int noteDuration, int phaseLength, int bendAmplitude)
        {
            const int resolution = 16;

            int phaseHalf = phaseLength / 2;
            // 1st Phase stays at bend 0,
            // then we have a sine wave with the given amplitude and phase length

            noteStart += phaseLength;
            var noteEnd = noteStart + noteDuration;

            while (noteStart < noteEnd)
            {
                var phase = 0;
                var phaseDuration = noteStart + phaseLength < noteEnd ? phaseLength : noteEnd - noteStart;
                while (phase < phaseDuration)
                {
                    var bend = bendAmplitude * Math.Sin(phase * Math.PI / phaseHalf);

                    _handler.AddBend(track.Index, noteStart + phase, (byte)track.PlaybackInfo.PrimaryChannel, (byte)(DefaultBend + bend));

                    phase += resolution;
                }

                noteStart += phaseLength;
            }
        }