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); }
/// <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; }