コード例 #1
0
        /// <summary>
        ///     Forms polylines that show input and output audio samples
        /// </summary>
        private void SetPolylines()
        {
            if (Input.Points is null || Output.Points is null)
            {
                return;
            }

            // clear polylines
            Input.Points.Clear();
            Output.Points.Clear();
            // calculate position in audio track to show click
            //in the center of this CW
            var cwStartPos = (int)(
                _audioClickBinded.StartPosition +
                _audioClickBinded.Length / 2 -
                MainGrid.Width / 2);

            // set Input polyline
            for (var i = 0; i < MainGrid.Width; i++)
            {
                var    s = _audio.GetInputSample(_channelType, cwStartPos + i);
                double y = 100 * (-s + 1) / 2;
                Input.Points.Add(new Point(i, y));
            }

            // set Output polyline two samples wider than click
            for (var i = _audioClickBinded.StartPosition - cwStartPos - 1;
                 i <= _audioClickBinded.StartPosition - cwStartPos + _audioClickBinded.Length + 1;
                 i++)
            {
                var    s = _audio.GetOutputSample(_channelType, cwStartPos + i);
                double y = 100 * (-s + 1) / 2;
                Output.Points.Add(new Point(i, y));
            }
        }