Beispiel #1
0
        public TimeLocatedBuffer(TimeLocatedBuffer cp)
        {
            _buffer         = new double[cp._buffer.Length];
            _writtenSamples = cp._writtenSamples;
            CurrentTime     = cp.CurrentTime;
            Samplerate      = cp.Samplerate;

            Array.Copy(
                destinationArray:   _buffer,
                sourceArray:        cp._buffer,
                length:             cp._buffer.Length
                );
        }
Beispiel #2
0
        public int Dequeue(TimeLocatedBuffer buffer, int length = -1)
        {
            lock (this) {
                if (length == -1)
                {
                    length = buffer.GetSamples().Length;
                }
                if (buffer.Samplerate != _rate)
                {
                    throw new InvalidOperationException();
                }

                var result = Dequeue(buffer.GetSamples(), 0, length);
                buffer.SetWritten(result);
                return(result);
            }
        }
Beispiel #3
0
        public void Enqueue(TimeLocatedBuffer buffer)
        {
            lock (this) {
                if (buffer.Samplerate != _rate)
                {
                    throw new InvalidOperationException();
                }
                Enqueue(buffer.GetSamples(), 0, buffer.WrittenSamples);
                _timeBufEnd = _timeBufEnd.Add(buffer.WrittenSamples, _rate);

                if (buffer.CurrentTime.Value != _timeBufEnd.Value)
                {
                    GlobalSettings.Instance.Errors.Add(
                        new Error($"Ring Buffer: Missing samples. Buffer Timestamp: { buffer.CurrentTime.Value } \t Ring Timestamp: { _timeBufEnd.Value}")
                        );
                    _timeBufEnd = new TimeStamp(buffer.CurrentTime);
                }
            }
        }