spgramf

Variants: spgramcf, spgramf

Spectral periodogram object for computing power spectral density estimates of various signals

Public Functions

spgramf spgramf_create(unsigned int _nfft, int _wtype, unsigned int _window_len, unsigned int _delay)
spgramf spgramf_create_default(unsigned int _nfft)
spgramf spgramf_copy(spgramf _q)
int spgramf_destroy(spgramf _q)
int spgramf_clear(spgramf _q)
int spgramf_reset(spgramf _q)
int spgramf_print(spgramf _q)
int spgramf_set_alpha(spgramf _q, float _alpha)
float spgramf_get_alpha(spgramf _q)
int spgramf_set_freq(spgramf _q, float _freq)
int spgramf_set_rate(spgramf _q, float _rate)
unsigned int spgramf_get_nfft(spgramf _q)
unsigned int spgramf_get_window_len(spgramf _q)
unsigned int spgramf_get_delay(spgramf _q)
int spgramf_get_wtype(spgramf _q)
unsigned long long int spgramf_get_num_samples(spgramf _q)
unsigned long long int spgramf_get_num_samples_total(spgramf _q)
unsigned long long int spgramf_get_num_transforms(spgramf _q)
unsigned long long int spgramf_get_num_transforms_total(spgramf _q)
int spgramf_push(spgramf _q, float _x)
int spgramf_write(spgramf _q, float * _x, unsigned int _n)
int spgramf_get_psd_mag(spgramf _q, float * _psd)
int spgramf_get_psd(spgramf _q, float * _psd)
int spgramf_export_gnuplot(spgramf _q, const char * _filename)
int spgramf_estimate_psd(unsigned int _nfft, float * _x, unsigned int _n, float * _psd)

Interfaces

spgramf spgramf_create(unsigned int _nfft, int _wtype, unsigned int _window_len, unsigned int _delay)

Create spgram object, fully defined

  • _nfft : transform (FFT) size, 2 <= _nfft
  • _wtype : window type, e.g. LIQUID_WINDOW_HAMMING
  • _window_len : window length, 1 <= _window_len <= _nfft
  • _delay : delay between transforms, 0 < _delay

spgramf spgramf_create_default(unsigned int _nfft)

Create default spgram object of a particular transform size using the Kaiser-Bessel window (LIQUID_WINDOW_KAISER), a window length equal to _nfft/2, and a delay of _nfft/4

  • _nfft : FFT size, 2 <= _nfft

spgramf spgramf_copy(spgramf _q)

Copy object including all internal objects and state

int spgramf_destroy(spgramf _q)

Destroy spgram object, freeing all internally-allocated memory

int spgramf_clear(spgramf _q)

Clears the internal state of the object, but not the internal buffer

int spgramf_reset(spgramf _q)

Reset the object to its original state completely. This effectively executes the clear() method and then resets the internal buffer

int spgramf_print(spgramf _q)

Print internal state of the object to stdout

int spgramf_set_alpha(spgramf _q, float _alpha)

Set the filter bandwidth for accumulating independent transform squared magnitude outputs. This is used to compute a running time-average power spectral density output. The value of _alpha determines how the power spectral estimate is accumulated across transforms and can range from 0 to 1 with a special case of -1 to accumulate infinitely. Setting _alpha to 0 minimizes the bandwidth and the PSD estimate will never update. Setting _alpha to 1 forces the object to always use the most recent spectral estimate. Setting _alpha to -1 is a special case to enable infinite spectral accumulation.

  • _q : spectral periodogram object
  • _alpha : forgetting factor, set to -1 for infinite, 0 <= _alpha <= 1

float spgramf_get_alpha(spgramf _q)

Get the filter bandwidth for accumulating independent transform squared magnitude outputs.

int spgramf_set_freq(spgramf _q, float _freq)

Set the center frequency of the received signal. This is for display purposes only when generating the output image.

  • _q : spectral periodogram object
  • _freq : center frequency [Hz]

int spgramf_set_rate(spgramf _q, float _rate)

Set the sample rate (frequency) of the received signal. This is for display purposes only when generating the output image.

  • _q : spectral periodogram object
  • _rate : sample rate [Hz]

unsigned int spgramf_get_nfft(spgramf _q)

Get transform (FFT) size

unsigned int spgramf_get_window_len(spgramf _q)

Get window length

unsigned int spgramf_get_delay(spgramf _q)

Get delay between transforms

int spgramf_get_wtype(spgramf _q)

Get window type used for spectral estimation

unsigned long long int spgramf_get_num_samples(spgramf _q)

Get number of samples processed since reset

unsigned long long int spgramf_get_num_samples_total(spgramf _q)

Get number of samples processed since object was created

unsigned long long int spgramf_get_num_transforms(spgramf _q)

Get number of transforms processed since reset

unsigned long long int spgramf_get_num_transforms_total(spgramf _q)

Get number of transforms processed since object was created

int spgramf_push(spgramf _q, float _x)

Push a single sample into the object, executing internal transform as necessary.

  • _q : spgram object
  • _x : input sample

int spgramf_write(spgramf _q, float * _x, unsigned int _n)

Write a block of samples to the object, executing internal transform as necessary.

  • _q : spgram object
  • _x : input buffer, shape: (_n, 1)
  • _n : input buffer length

int spgramf_get_psd_mag(spgramf _q, float * _psd)

Compute spectral periodogram output (fft-shifted values, linear) from current buffer contents

  • _q : spgram object
  • _psd : output spectrum (linear), shape: (_nfft, 1)

int spgramf_get_psd(spgramf _q, float * _psd)

Compute spectral periodogram output (fft-shifted values in dB) from current buffer contents

  • _q : spgram object
  • _psd : output spectrum (dB), shape: (_nfft, 1)

int spgramf_export_gnuplot(spgramf _q, const char * _filename)

Export stand-alone gnuplot file for plotting output spectrum, returning 0 on success, anything other than 0 for failure

  • _q : spgram object
  • _filename : input buffer, shape: (_n, 1)

int spgramf_estimate_psd(unsigned int _nfft, float * _x, unsigned int _n, float * _psd)

Estimate spectrum on input signal (create temporary object for convenience

  • _nfft : FFT size
  • _x : input signal, shape: (_n, 1)
  • _n : input signal length
  • _psd : output spectrum, shape: (_nfft, 1)