ASCII Spectral Periodogram (asgram)¶
Attention
Work in progress
#include <liquid/liquid.h>
int main() {
// options
unsigned int nfft = 72; // FFT size (display)
unsigned int buf_len = 3456; // input buffer size
// create spectral periodogram and set scale
asgramcf q = asgramcf_create(nfft);
asgramcf_set_scale (q, -80.0f, 5.0f);
asgramcf_set_display(q, "...++++###"); // set custom display characters
// allocated memory arrays
float complex * buf = (float complex*) malloc(buf_len*sizeof(float complex));
// ... initialize input ...
// write block of samples to spectral periodogram object
asgramcf_write(q, buf, buf_len);
// print result to screen
asgramcf_print(q);
// destroy object and free memory arrays
asgramcf_destroy(q);
free(buf);
}
> .......,,,,--+*NN&+--,,,,....... < pk 14.1 dB [ 0.00]
> .......,,,,--+&NN*--,,,,........ < pk 14.1 dB [ 0.01]
> .......,,,,--+*&N&+--,,,,....... < pk 14.1 dB [ 0.02]
> .........,,,,--+*NN&+--,,,........ < pk 14.1 dB [ 0.04]
> .........,,,,,--+&NN*--,,,,...... < pk 14.1 dB [ 0.06]
> ..........,,,,--+*&N&+--,,,....... < pk 14.1 dB [ 0.09]
> ..........,,,,,--+*&NN*--,,,...... < pk 14.2 dB [ 0.12]
> ...........,,,,---+&NN*--,,,...... < pk 14.2 dB [ 0.15]
> ............,,,,,--+&NN*+-,,,...... < pk 14.2 dB [ 0.18]
> ............,,,,,--+&NN*+-,,,....... < pk 14.2 dB [ 0.21]
> .............,,,,,--+&NN*+--,,,..... < pk 14.1 dB [ 0.23]
> ...........,,,,,-+&NN&+--,,,...... < pk 13.9 dB [ 0.23]
> .........,,,,,-+*NN&*+--,,,...... < pk 13.5 dB [ 0.21]
> ..........,,,,-+&NN&*+--,,,....... < pk 13.2 dB [ 0.18]
> ........,,,,-+&NN&*+--,,,,....... < pk 12.7 dB [ 0.13]
> ..........,,,-*&NN&*++--,,,........ < pk 12.4 dB [ 0.07]
> ...........,,-*&NN&**+--,,,.......... < pk 12.2 dB [-0.01]
> ........,,,+*&N&&*++--,,,,...... < pk 12.1 dB [-0.09]
> . ......,,-+&NN&&*+--,,,,........ < pk 12.3 dB [-0.17]
> ........,,,+*NN&&*+--,,,,........ < pk 12.5 dB [-0.25]
> .....,,,-+&NN&*++--,,,,....... ... < pk 13.0 dB [-0.32]
> .,,,,-+&NN&*+--,,,,...... . ........ < pk 13.4 dB [-0.37]
> ,,,-+&NN*+--,,,,...... ........,, < pk 13.8 dB [-0.40]
> ,,--*NN&+--,,,,...... .........,, < pk 14.0 dB [-0.41]
> ,,--+&NN*+-,,,,..... .........,,, < pk 14.2 dB [-0.40]
> ,,,--+*&N&+--,,,...... ...........,, < pk 14.1 dB [-0.37]
> .,,,,,--+*NN&+-,,,...... ........... < pk 14.0 dB [-0.32]
> .....,,,,--+*&NN*--,,...... ........ < pk 13.8 dB [-0.27]
> ........,,,,,--+*&NN*-,,,....... ... < pk 13.7 dB [-0.21]
> .........,,,,---+*&NN+-,,,....... < pk 13.7 dB [-0.15]
> ...........,,,,,--+*&NN&+-,,,...... < pk 13.7 dB [-0.09]
> .........,,,,--+*&NN&+-,,,....... < pk 13.7 dB [-0.04]
> ........,,,,--+*&N&+--,,,........ < pk 13.9 dB [-0.01]
> .........,,,,--+*NN&+-,,,,....... < pk 14.0 dB [ 0.02]
> .......,,,,--+*NN&+-,,,,,.......... < pk 14.1 dB [ 0.03]
> .......,,,--+*&N&+--,,,,,........ < pk 14.1 dB [ 0.04]
> ........,,,,--*&N&+--,,,,.......... < pk 14.1 dB [ 0.04]
> ......,,,,-+*NN&+--,,,,.......... < pk 14.2 dB [ 0.04]
> .......,,,--+*NN&+--,,,,....... < pk 14.1 dB [ 0.03]
> ........,,,--+*NN&+--,,,,......... < pk 14.1 dB [ 0.03]
Interface¶
Listed below is the full interface to the asgram family of
objects.
create()¶
Create asgram object with size _nfft
asgramcf = asgramcf_create(unsigned int _nfft);
unsigned int _nfft: size of FFT taken for each transform (character width)returns new
asgramcfobject
asgramf = asgramf_create(unsigned int _nfft);
unsigned int _nfft: size of FFT taken for each transform (character width)returns new
asgramfobject
copy()¶
Copy object including all internal objects and state
asgramcf = asgramcf_copy(asgramcf _q);
asgramcf _q:returns new
asgramcfobject
asgramf = asgramf_copy(asgramf _q);
asgramf _q:returns new
asgramfobject
destroy()¶
Destroy asgram object, freeing all internally-allocated memory
int = asgramcf_destroy(asgramcf _q);
asgramcf _q:returns standard error code
int = asgramf_destroy(asgramf _q);
asgramf _q:returns standard error code
reset()¶
Reset the internal state of the asgram object
int = asgramcf_reset(asgramcf _q);
asgramcf _q:returns standard error code
int = asgramf_reset(asgramf _q);
asgramf _q:returns standard error code
set_scale()¶
Set the scale and offset for spectrogram in terms of dB for display purposes
int = asgramcf_set_scale(asgramcf _q, float _ref, float _div);
asgramcf _q: asgram objectfloat _ref: signal reference levelfloat _div: signal divisionreturns standard error code
int = asgramf_set_scale(asgramf _q, float _ref, float _div);
asgramf _q: asgram objectfloat _ref: signal reference levelfloat _div: signal divisionreturns standard error code
set_display()¶
Set the display’s 10 characters for output string starting from the weakest and ending with the strongest
int = asgramcf_set_display(asgramcf _q, const char * _ascii);
asgramcf _q: asgram objectconst char * _ascii: 10-character display, default: “ .,-+*&NM#”returns standard error code
int = asgramf_set_display(asgramf _q, const char * _ascii);
asgramf _q: asgram objectconst char * _ascii: 10-character display, default: “ .,-+*&NM#”returns standard error code
push()¶
Push a single sample into the asgram object, executing internal transform as necessary.
int = asgramcf_push(asgramcf _q, float complex _x);
asgramcf _q: asgram objectfloat complex _x: input samplereturns standard error code
int = asgramf_push(asgramf _q, float _x);
asgramf _q: asgram objectfloat _x: input samplereturns standard error code
write()¶
Write a block of samples to the asgram object, executing internal transforms as necessary.
int = asgramcf_write(asgramcf _q, float complex * _x, unsigned int _n);
asgramcf _q: asgram objectfloat complex * _x: input bufferunsigned int _n: input buffer lengthreturns standard error code
int = asgramf_write(asgramf _q, float * _x, unsigned int _n);
asgramf _q: asgram objectfloat * _x: input bufferunsigned int _n: input buffer lengthreturns standard error code
execute()¶
Compute spectral periodogram output from current buffer contents and return the ascii character string to display along with the peak value and its frequency location
int = asgramcf_execute(asgramcf _q, char * _ascii, float * _peakval, float * _peakfreq);
asgramcf _q: asgram objectchar * _ascii: output ASCII stringfloat * _peakval: peak power spectral density valuefloat * _peakfreq: peak power spectral density frequencyreturns standard error code
int = asgramf_execute(asgramf _q, char * _ascii, float * _peakval, float * _peakfreq);
asgramf _q: asgram objectchar * _ascii: output ASCII stringfloat * _peakval: peak power spectral density valuefloat * _peakfreq: peak power spectral density frequencyreturns standard error code
print()¶
Compute spectral periodogram output from current buffer contents and print standard format to stdout
int = asgramcf_print(asgramcf _q);
asgramcf _q:returns standard error code
int = asgramf_print(asgramf _q);
asgramf _q:returns standard error code