libxputty  0.1
A damn tiny abstraction Layer to create X11 window/widgets with cairo surfaces
xmeter.h File Reference
#include "xputty.h"
Include dependency graph for xmeter.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define XMETER_H_
 

Functions

float power2db (Widget_t *w, float power)
 power2db - power (db) input to db output consider falloff More...
 
Widget_tadd_vmeter (Widget_t *parent, const char *label, bool show_scale, int x, int y, int width, int height)
 add_vmeter - add a vumeter to a Widget_t connect to func.value_changed_callback to implement your actions More...
 
Widget_tadd_hmeter (Widget_t *parent, const char *label, bool show_scale, int x, int y, int width, int height)
 add_hmeter - add a vumeter to a Widget_t connect to func.value_changed_callback to implement your actions More...
 

Macro Definition Documentation

◆ XMETER_H_

#define XMETER_H_

Definition at line 24 of file xmeter.h.

Function Documentation

◆ add_hmeter()

Widget_t* add_hmeter ( Widget_t parent,
const char *  label,
bool  show_scale,
int  x,
int  y,
int  width,
int  height 
)

add_hmeter - add a vumeter to a Widget_t connect to func.value_changed_callback to implement your actions

Parameters
*parent- pointer to the Widget_t request the vumeter
*label- Label to show on the vumeter
x,y,width,height- the position/geometry to create the vumeter
Returns
Widget_t* - pointer to the Widget_t meter struct

Definition at line 66 of file xmeter.c.

67  {
68 
69  Widget_t *wid = create_widget(parent->app, parent, x, y, width, height);
70  _create_horizontal_meter_image(wid, width, height);
71  wid->label = label;
72  wid->adj_x = add_adjustment(wid,-70.0, -70.0, -70.0, 6.0,0.001, CL_METER);
73  wid->adj = wid->adj_x;
74  wid->flags &= ~USE_TRANSPARENCY;
75  wid->scale.gravity = ASPECT;
77  if (show_scale) {
78  Widget_t *wid2 = create_widget(parent->app, parent, x, y+height, width, height);
79  wid2->scale.gravity = ASPECT;
81  }
82  return wid;
83 }

References _create_horizontal_meter_image(), _draw_h_meter(), _draw_hmeter_scale(), add_adjustment(), Widget_t::adj, Widget_t::adj_x, Widget_t::app, ASPECT, CL_METER, create_widget(), Func_t::expose_callback, Widget_t::flags, Widget_t::func, Resize_t::gravity, Widget_t::label, Widget_t::scale, and USE_TRANSPARENCY.

◆ add_vmeter()

Widget_t* add_vmeter ( Widget_t parent,
const char *  label,
bool  show_scale,
int  x,
int  y,
int  width,
int  height 
)

add_vmeter - add a vumeter to a Widget_t connect to func.value_changed_callback to implement your actions

Parameters
*parent- pointer to the Widget_t request the vumeter
*label- Label to show on the vumeter
x,y,width,height- the position/geometry to create the vumeter
Returns
Widget_t* - pointer to the Widget_t mete struct

Definition at line 47 of file xmeter.c.

48  {
49 
50  Widget_t *wid = create_widget(parent->app, parent, x, y, width, height);
51  _create_vertical_meter_image(wid, width, height);
52  wid->label = label;
53  wid->adj_y = add_adjustment(wid,-70.0, -70.0, -70.0, 6.0,0.001, CL_METER);
54  wid->adj = wid->adj_y;
55  wid->flags &= ~USE_TRANSPARENCY;
56  wid->scale.gravity = ASPECT;
58  if (show_scale) {
59  Widget_t *wid2 = create_widget(parent->app, parent, x+width, y, width, height);
60  wid2->scale.gravity = ASPECT;
62  }
63  return wid;
64 }

References _create_vertical_meter_image(), _draw_v_meter(), _draw_vmeter_scale(), add_adjustment(), Widget_t::adj, Widget_t::adj_y, Widget_t::app, ASPECT, CL_METER, create_widget(), Func_t::expose_callback, Widget_t::flags, Widget_t::func, Resize_t::gravity, Widget_t::label, Widget_t::scale, and USE_TRANSPARENCY.

◆ power2db()

float power2db ( Widget_t w,
float  power 
)

power2db - power (db) input to db output consider falloff

Parameters
power- mesured power
Returns
float - calculated db

Definition at line 26 of file xmeter.c.

26  {
27  const float falloff = 27 * 60 * 0.0005;
28  const float fallsoft = 6 * 60 * 0.0005;
29  //power = 20.*log10(power);
30  if (power <= 20.*log10(0.00021)) { // -70db
31  power = 20.*log10(0.00000000001); //-137db
32  w->adj->start_value = min(0.0,w->adj->start_value - fallsoft);
33  }
34  // retrieve old meter value and consider falloff
35  if (power < w->adj->std_value) {
36  power = max(power, w->adj->std_value - falloff);
37  w->adj->start_value = min(0.0,w->adj->start_value - fallsoft);
38  }
39  if (power > w->adj->start_value) {
40  w->adj->start_value = power ;
41  }
42 
43  w->adj->std_value = power;
44  return power;
45 }

References Widget_t::adj, max, min, Adjustment_t::start_value, and Adjustment_t::std_value.

Adjustment_t::std_value
float std_value
Definition: xadjustment.h:84
Resize_t::gravity
Gravity gravity
Definition: xwidget.h:192
_draw_vmeter_scale
void _draw_vmeter_scale(void *w_, void *user_data)
_draw_meter_scale - draw a meter scale beside the meter widget
Definition: xmeter_private.c:25
min
#define min(x, y)
min - set a maximal value (x) as return value
Definition: xputty.h:78
_draw_h_meter
void _draw_h_meter(void *w_, void *user_data)
_draw_h_meter - internal draw the meter to the buffer
Definition: xmeter_private.c:270
create_widget
Widget_t * create_widget(Xputty *app, Widget_t *win, int x, int y, int width, int height)
*create_widget - create a widget A Widget_t could only be created as child of a other Widget_t To...
Definition: xwidget.c:268
Func_t::expose_callback
xevfunc expose_callback
Definition: xwidget.h:80
Widget_t::flags
long long flags
Definition: xwidget.h:324
Widget_t::adj
Adjustment_t * adj
Definition: xwidget.h:334
Widget_t::scale
Resize_t scale
Definition: xwidget.h:356
_create_vertical_meter_image
void _create_vertical_meter_image(Widget_t *w, int width, int height)
_create_vertical_meter_image - internal draw the meter image to the cairo image surface
Definition: xmeter_private.c:138
_create_horizontal_meter_image
void _create_horizontal_meter_image(Widget_t *w, int width, int height)
_create_horizontal_meter_image - internal draw the meter image to the cairo image surface
Definition: xmeter_private.c:194
Widget_t::app
Xputty * app
Definition: xwidget.h:300
USE_TRANSPARENCY
@ USE_TRANSPARENCY
Definition: xwidget.h:243
_draw_v_meter
void _draw_v_meter(void *w_, void *user_data)
_draw_v_meter - internal draw the meter to the buffer
Definition: xmeter_private.c:250
Widget_t
Widget_t - struct to hold the basic Widget_t info.
Definition: xwidget.h:298
ASPECT
@ ASPECT
Definition: xwidget.h:167
_draw_hmeter_scale
void _draw_hmeter_scale(void *w_, void *user_data)
_draw_hmeter_scale - draw a hmeter scale beside the meter widget
Definition: xmeter_private.c:69
CL_METER
@ CL_METER
Definition: xadjustment.h:59
Widget_t::adj_y
Adjustment_t * adj_y
Definition: xwidget.h:332
Widget_t::func
Func_t func
Definition: xwidget.h:310
add_adjustment
Adjustment_t * add_adjustment(Widget_t *w, float std_value, float value, float min_value, float max_value, float step, CL_type type)
*add_adjustment - adding a adjustment to a Widget_t
Definition: xadjustment.c:25
Adjustment_t::start_value
float start_value
Definition: xadjustment.h:94
max
#define max(x, y)
max - set a minimal value (x) as return value
Definition: xputty.h:86
Widget_t::label
const char * label
Definition: xwidget.h:326
Widget_t::adj_x
Adjustment_t * adj_x
Definition: xwidget.h:330