procedure ReadFromCircularBuffer(Buffer: TVec; Dst: TVec; var State: TCircularBufferState; ForwardStep: Integer);
Copy data from circular buffer.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Buffer | TVec | source TVec |
| 2 | Dst | TVec | source TVec |
| 3 | State | TCircularBufferState | |
| 4 | ForwardStep | Integer |
Result: stored in self (calling object)
Remarks:
Copies Dst.Length samples from Buffer to Dst. If there is not Dst.Length samples available, the BufferUnderflow flag will be set in the State variable. The routine advances ReadPosition of the buffer to the position where the next data is to be read from. ForwardStep defines the number of samples to advance the read cursor. If the ForwardStep is -1, the read cursor is advanced Dst.Length samples.
Examples
uses MtxExpr, Math387, MtxVec, SignalUtils, MtxVecTee, MtxVecEdit;
procedure TForm1.Button1Click(Sender: TObject);
var h1,h,c,b: Vector;
i,n: integer;
State: TCircularBufferState;
begin
h1 := Ramp(30, mvDouble, 0,1);
c.Size(h1);
c.SetZero;
h.Size(h1);
h.SetZero;
n := 6;
InitCircularBuffer(11,2,State);
for i := 0 to (h1.Length div n) - 1 do
begin
h1.SetSubRange(i*n,n);
h.SetSubRange(i*n,n);
c.SetSubRange(i*n,n);
WriteToCircularBuffer(b,h1,State);
n := PeekCircularBuffer(State);
MonitorCircularBuffer(b,h,State);
ReadFromCircularBuffer(b,c,State);
end;
h1.SetFullRange;
h.SetFullRange;
c.SetFullRange;
DrawIt([h1,h,c],['Original','Monitored','Read']);
//must be all equal, if right
end;