コード例 #1
0
        public void Recreate()
        {
            if (Track == null)
            {
                return;
            }
            float vol = Layer.Volume;

            // Set the layer volume to 1 as we don't want it affecting the waveform.
            Layer.Volume = 1.0f;

            float interval    = Track.File.Duration / _cacheWidth;
            var   sampleCount = (int)(1f / interval);

            _cache = new Vector2[sampleCount];
            for (var i = 0; i < sampleCount; i++)
            {
                float location = i == sampleCount - 1 ? 1 : i * interval;
                float sample   = Track.GetSampleAsFloat((int)((Track.SourceSamples - 1) * location));
                _cache[i] = new Vector2(_cacheWidth * location, _cacheHeight * ((1.0f + sample) / 2f));
            }

            Layer.Volume = vol;
        }