windowcf

Variants: windowcf, windowf

Sliding window first-in/first-out buffer with a fixed size

Public Functions

windowcf windowcf_create(unsigned int _n)
windowcf windowcf_recreate(windowcf _q, unsigned int _n)
windowcf windowcf_copy(windowcf _q)
int windowcf_destroy(windowcf _q)
int windowcf_print(windowcf _q)
int windowcf_debug_print(windowcf _q)
int windowcf_reset(windowcf _q)
int windowcf_read(windowcf _q, float complex ** _v)
int windowcf_index(windowcf _q, unsigned int _i, float complex * _v)
int windowcf_push(windowcf _q, float complex _v)
int windowcf_write(windowcf _q, float complex * _v, unsigned int _n)

Interfaces

windowcf windowcf_create(unsigned int _n)

Create window buffer object of a fixed length. Samples may be pushed into the buffer which retains the most recent \(n\) samples.

  • _n : length of the window buffer [samples]

windowcf windowcf_recreate(windowcf _q, unsigned int _n)

Recreate window buffer object with new length. This extends an existing window's size, similar to the standard C library's realloc() to n samples. If the size of the new window is larger than the old one, the newest values are retained at the beginning of the buffer and the oldest values are truncated. If the size of the new window is smaller than the old one, the oldest values are truncated.

  • _q : old window object
  • _n : new window length [samples]

windowcf windowcf_copy(windowcf _q)

Copy object including all internal objects and state

int windowcf_destroy(windowcf _q)

Destroy window object, freeing all internally memory

int windowcf_print(windowcf _q)

Print window object to stdout

int windowcf_debug_print(windowcf _q)

Print window object to stdout (with extra information)

int windowcf_reset(windowcf _q)

Reset window object (initialize to zeros)

int windowcf_read(windowcf _q, float complex ** _v)

Read the contents of the window by returning a pointer to the aligned internal memory array. This method guarantees that the elements are linearized. This method should only be used for reading; writing values to the buffer has unspecified results. Note that the returned pointer is only valid until another operation is performed on the window buffer object

  • _q : window object
  • _v : output pointer (set to internal array)

int windowcf_index(windowcf _q, unsigned int _i, float complex * _v)

Index single element in buffer at a particular index This retrieves the \(i^{th}\) sample in the window, storing the output value in _v. This is equivalent to first invoking read() and then indexing on the resulting pointer; however the result is obtained much faster. Therefore setting the index to 0 returns the oldest value in the window.

  • _q : window object
  • _i : index of element to read
  • _v : output value pointer

int windowcf_push(windowcf _q, float complex _v)

Shifts a single sample into the right side of the window, pushing the oldest (left-most) sample out of the end. Unlike stacks, the window object has no equivalent "pop" method, as values are retained in memory until they are overwritten.

  • _q : window object
  • _v : single input element

int windowcf_write(windowcf _q, float complex * _v, unsigned int _n)

Write array of elements onto window buffer Effectively, this is equivalent to pushing each sample one at a time, but executes much faster.

  • _q : window object
  • _v : input array of values to write
  • _n : number of input values to write