Esempio n. 1
0
        /// <summary>
        /// creates a cascade of MinMax filters
        /// </summary>
        /// <param name="_zoomLevels">dividers by which to divide the initial samples by</param>
        /// <param name="initialSize">number of samples before dividing</param>
        /// <returns></returns>
        public static IMinMaxCache[] CreateCascade(int[] _zoomLevels, long initialSize)
        {
            var cascade = new IMinMaxCache[_zoomLevels.Length];

            cascade    = new IMinMaxCache[_zoomLevels.Length];
            cascade[0] = new MinMaxCacheFirstStage(_zoomLevels[0], (int)(initialSize / _zoomLevels[0]));
            for (int i = 1; i < _zoomLevels.Length; i++)
            {
                cascade[i] = new MinMaxCache(_zoomLevels[i], _zoomLevels[i - 1], (int)(initialSize / _zoomLevels[i]));
                cascade[i - 1].NextMinMaxCache = cascade[i];
            }
            return(cascade);
        }
Esempio n. 2
0
        private void ReadFile()
        {
            _minMax    = MinMaxCache.CreateCascade(_zoomLevels, _reader.SampleCount);
            _minMaxFst = (MinMaxCacheFirstStage)_minMax[0];

            double[] buffer  = new double[1000];
            float[]  toFloat = new float[buffer.Length];

            var read = 0L;

            while ((read = _reader.ReadSamples(buffer, 0, buffer.Length)) > 0)
            {
                for (int i = 0; i < read; i++)
                {
                    toFloat[i] = (float)buffer[i];
                }
                _minMaxFst.ConsumeSamples(toFloat, 0, (int)read);
            }

            _reader.Seek(0, System.IO.SeekOrigin.Begin);
        }
Esempio n. 3
0
        /// <summary>
        /// Continuous-time stream of data
        /// </summary>
        /// <param name="size">number of samples the buffer can hold</param>
        public DataLine1D(string name, int size, int samplerate)
        {
            _zoomLevels = new[] {
                1 << 6,
                    1 << 7,
                    1 << 8,
                    1 << 9,
                    1 << 10,
                    1 << 11,
                    1 << 12,
                    1 << 13,
                    1 << 14,
                    1 << 15,
                    1 << 16
            };



            _ringBuffer    = new VertexRingBuffer(size);
            _ringBufferMax = new VertexRingBuffer(size);
            _ringBufferMin = new VertexRingBuffer(size);
            _floatTemp     = new float[size];
            _minMaxTemp    = new MinMax[size];

            Name = name;

            SamplesPerSecond = samplerate;
            _signalBuffer    = new GenericRingBuffer <float>(size)
            {
                FixedSize = true
            };
            _minMax    = MinMaxCache.CreateCascade(_zoomLevels, size);
            _minMaxFst = (MinMaxCacheFirstStage)_minMax[0];

            // init as -2 because -1 is for fully zoomed in and 0-.. is for other zoom levels.
            // -2 so that in Render() a level change occurs
            _level = -2;
        }