fosphor.h
Go to the documentation of this file.
/*
* fosphor.h
*
* Main fosphor entry point
*
* Copyright (C) 2013-2021 Sylvain Munaut
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#pragma once
/*! \defgroup fosphor
* @{
*/
/*! \file fosphor.h
* \brief Main fosphor entry point
*/
struct fosphor;
struct fosphor_render;
/* Main API */
struct fosphor *fosphor_init(void);
void fosphor_release(struct fosphor *self);
int fosphor_process(struct fosphor *self, void *samples, int len);
void fosphor_draw(struct fosphor *self, struct fosphor_render *render);
void fosphor_set_fft_window_default(struct fosphor *self);
void fosphor_set_fft_window(struct fosphor *self, float *win);
void fosphor_set_power_range(struct fosphor *self, int db_ref, int db_per_div);
void fosphor_set_frequency_range(struct fosphor *self,
double center, double span);
/* Render */
#define FOSPHOR_MAX_CHANNELS 8
struct fosphor_channel
{
int enabled; /*!< \brief Showed (1) or hidden (0) */
float center; /*!< \brief Normalized center frequency */
float width; /*!< \brief Normalized bandwidth */
};
#define FRO_LIVE (1<<0) /*!< \brief Display live spectrum */
#define FRO_MAX_HOLD (1<<1) /*!< \brief Display max-hold spectrum */
#define FRO_HISTO (1<<2) /*!< \brief Display histogram */
#define FRO_WATERFALL (1<<3) /*!< \brief Display waterfall */
#define FRO_LABEL_FREQ (1<<4) /*!< \brief Display frequency labels */
#define FRO_LABEL_PWR (1<<5) /*!< \brief Display power labels */
#define FRO_LABEL_TIME (1<<6) /*!< \brief Display time labels */
#define FRO_CHANNELS (1<<7) /*!< \brief Display channels */
#define FRO_COLOR_SCALE (1<<8) /*!< \brief Display intensity color scale */
/*! \brief fosphor render options */
struct fosphor_render
{
/* User fields */
int pos_x; /*!< \brief X origin (lower left corner) */
int pos_y; /*!< \brief Y origin (lower left corner) */
int width; /*!< \brief Width */
int height; /*!< \brief Height */
int options; /*!< \brief Options (See FRO_??? constants) */
float histo_wf_ratio; /*!< \brief Ratio histogram/waterfall ]0,1[ */
int freq_n_div; /*!< \brief Number of frequency divisions */
float freq_center; /*!< \brief Frequency zoom center ]0,1[ */
float freq_span; /*!< \brief Frequency zoom span ]0,1] */
float wf_span; /*!< \brief Waterfall time zoom ]0,1] */
/*! \brief Displayed channels */
struct fosphor_channel channels[FOSPHOR_MAX_CHANNELS];
/* Private fields */
int _wf_pos; /*!< \brief (private) Waterfall position */
float _x_div; /*!< \brief (private) X divisions width */
float _x[2]; /*!< \brief (private) X endpoints */
float _x_label; /*!< \brief (private) X location for labels */
float _y_histo_div; /*!< \brief (private) Y histogram divisions height */
float _y_histo[2]; /*!< \brief (private) Y histogram endpoints */
float _y_wf[2]; /*!< \brief (private) Y waterfall endpoints */
float _y_label; /*!< \brief (private) Y location for label */
};
void fosphor_render_defaults(struct fosphor_render *render);
void fosphor_render_refresh(struct fosphor_render *render);
/* Position Mapping */
double fosphor_pos2freq(struct fosphor *self, struct fosphor_render *render, int x);
float fosphor_pos2pwr (struct fosphor *self, struct fosphor_render *render, int y);
int fosphor_pos2samp(struct fosphor *self, struct fosphor_render *render, int y);
int fosphor_freq2pos(struct fosphor *self, struct fosphor_render *render, double freq);
int fosphor_pwr2pos (struct fosphor *self, struct fosphor_render *render, float pwr);
int fosphor_samp2pos(struct fosphor *self, struct fosphor_render *render, int time);
int fosphor_render_pos_inside(struct fosphor_render *render, int x, int y);
/*! @} */
fosphor_set_power_range
void fosphor_set_power_range(struct fosphor *self, int db_ref, int db_per_div)
fosphor_pwr2pos
int fosphor_pwr2pos(struct fosphor *self, struct fosphor_render *render, float pwr)
fosphor_set_fft_window
void fosphor_set_fft_window(struct fosphor *self, float *win)
fosphor_draw
void fosphor_draw(struct fosphor *self, struct fosphor_render *render)
fosphor_render_defaults
void fosphor_render_defaults(struct fosphor_render *render)
fosphor_pos2samp
int fosphor_pos2samp(struct fosphor *self, struct fosphor_render *render, int y)
fosphor_samp2pos
int fosphor_samp2pos(struct fosphor *self, struct fosphor_render *render, int time)
fosphor_set_fft_window_default
void fosphor_set_fft_window_default(struct fosphor *self)
fosphor_set_frequency_range
void fosphor_set_frequency_range(struct fosphor *self, double center, double span)
fosphor_release
void fosphor_release(struct fosphor *self)
fosphor_pos2pwr
float fosphor_pos2pwr(struct fosphor *self, struct fosphor_render *render, int y)
fosphor_init
struct fosphor * fosphor_init(void)
fosphor_pos2freq
double fosphor_pos2freq(struct fosphor *self, struct fosphor_render *render, int x)
fosphor_process
int fosphor_process(struct fosphor *self, void *samples, int len)
FOSPHOR_MAX_CHANNELS
#define FOSPHOR_MAX_CHANNELS
Definition fosphor.h:42
fosphor_render_pos_inside
int fosphor_render_pos_inside(struct fosphor_render *render, int x, int y)
fosphor_render_refresh
void fosphor_render_refresh(struct fosphor_render *render)
fosphor_freq2pos
int fosphor_freq2pos(struct fosphor *self, struct fosphor_render *render, double freq)
fosphor_channel
Definition fosphor.h:45
fosphor_channel::enabled
int enabled
Showed (1) or hidden (0).
Definition fosphor.h:46
fosphor_channel::width
float width
Normalized bandwidth.
Definition fosphor.h:48
fosphor_channel::center
float center
Normalized center frequency.
Definition fosphor.h:47
fosphor_render
fosphor render options
Definition fosphor.h:63
fosphor_render::histo_wf_ratio
float histo_wf_ratio
Ratio histogram/waterfall ]0,1[.
Definition fosphor.h:70
fosphor_render::freq_center
float freq_center
Frequency zoom center ]0,1[.
Definition fosphor.h:72
fosphor_render::_wf_pos
int _wf_pos
(private) Waterfall position
Definition fosphor.h:80
fosphor_render::_x_label
float _x_label
(private) X location for labels
Definition fosphor.h:84
fosphor_render::_y_histo_div
float _y_histo_div
(private) Y histogram divisions height
Definition fosphor.h:86
fosphor_render::width
int width
Width.
Definition fosphor.h:67
fosphor_render::_y_histo
float _y_histo[2]
(private) Y histogram endpoints
Definition fosphor.h:87
fosphor_render::_y_wf
float _y_wf[2]
(private) Y waterfall endpoints
Definition fosphor.h:88
fosphor_render::channels
struct fosphor_channel channels[FOSPHOR_MAX_CHANNELS]
Displayed channels.
Definition fosphor.h:77
fosphor_render::_x
float _x[2]
(private) X endpoints
Definition fosphor.h:83
fosphor_render::pos_x
int pos_x
X origin (lower left corner).
Definition fosphor.h:65
fosphor_render::freq_span
float freq_span
Frequency zoom span ]0,1].
Definition fosphor.h:73
fosphor_render::pos_y
int pos_y
Y origin (lower left corner).
Definition fosphor.h:66
fosphor_render::_y_label
float _y_label
(private) Y location for label
Definition fosphor.h:89
fosphor_render::freq_n_div
int freq_n_div
Number of frequency divisions.
Definition fosphor.h:71
fosphor_render::height
int height
Height.
Definition fosphor.h:68
fosphor_render::_x_div
float _x_div
(private) X divisions width
Definition fosphor.h:82
fosphor_render::options
int options
Options (See FRO_??? constants).
Definition fosphor.h:69
fosphor_render::wf_span
float wf_span
Waterfall time zoom ]0,1].
Definition fosphor.h:74
fosphor
Definition private.h:31
fosphor::db_per_div
int db_per_div
Definition private.h:46
fosphor::center
double center
Definition private.h:52
fosphor::span
double span
Definition private.h:53
fosphor::db_ref
int db_ref
Definition private.h:45