72 printf(
"controlport_stats:\n");
73 printf(
"Reporting of audio volume via control port\n");
77 auto s = std::make_unique<state_controlport_stats>(
parent);
79 if(strcmp(cfg,
"help") == 0){
89 int in_bps,
int in_ch_count,
int in_sample_rate)
94 s->ch_count = in_ch_count;
95 s->sample_rate = in_sample_rate;
111 if(bps) *bps = s->
bps;
112 if(ch_count) *ch_count = s->ch_count;
121 if(f->bps != s->bps || f->ch_count != s->ch_count){
130 std::string report =
"ASEND";
131 for(
int i = 0; i < f->ch_count; i++){
134 double rms_dbfs0 = 20 * log(rms) / log(10);
135 double peak_dbfs0 = 20 * log(peak) / log(10);
136 report +=
" volrms" + std::to_string(i) +
" " + std::to_string(rms_dbfs0);
137 report +=
" volpeak" + std::to_string(i) +
" " + std::to_string(peak_dbfs0);
145 .name =
"controlport_stats",
struct video_frame * frame
This file contains definition of some common audio types.
#define AUDIO_FILTER_ABI_VERSION
bool control_stats_enabled(struct control_state *s)
void control_report_stats(struct control_state *s, const std::string &report_line)
static const struct audio_filter_info audio_filter_controlport_stats
static af_result_code filter(void *state, struct audio_frame **frame)
static void get_configured(void *state, int *bps, int *ch_count, int *sample_rate)
static af_result_code init(struct module *parent, const char *cfg, void **state)
static af_result_code configure(void *state, int in_bps, int in_ch_count, int in_sample_rate)
static void done(void *state)
struct module * get_module(struct module *root, const char *const_path)
struct module * get_root_module(struct module *node)
@ LIBRARY_CLASS_AUDIO_FILTER
#define REGISTER_MODULE(name, info, lclass, abi)
Registers module to global modules' registry.
struct used to comunicate with audio capture/playback device
state_controlport_stats(struct module *mod)
double calculate_rms(audio_frame2 *frame, int channel, double *peak)
Calculates mean and peak RMS from audio samples.