Mercurial > hg > audiostuff
comparison spandsp-0.0.3/spandsp-0.0.3/src/spandsp/power_meter.h @ 5:f762bf195c4b
import spandsp-0.0.3
author | Peter Meerwald <pmeerw@cosy.sbg.ac.at> |
---|---|
date | Fri, 25 Jun 2010 16:00:21 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
4:26cd8f1ef0b1 | 5:f762bf195c4b |
---|---|
1 /* | |
2 * SpanDSP - a series of DSP components for telephony | |
3 * | |
4 * power_meter.h | |
5 * | |
6 * Written by Steve Underwood <steveu@coppice.org> | |
7 * | |
8 * Copyright (C) 2003 Steve Underwood | |
9 * | |
10 * All rights reserved. | |
11 * | |
12 * This program is free software; you can redistribute it and/or modify | |
13 * it under the terms of the GNU General Public License version 2, as | |
14 * published by the Free Software Foundation. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
24 * | |
25 * $Id: power_meter.h,v 1.8 2006/10/24 13:45:28 steveu Exp $ | |
26 */ | |
27 | |
28 #if !defined(_POWER_METER_H_) | |
29 #define _POWER_METER_H_ | |
30 | |
31 /*! \page power_meter_page Power metering | |
32 | |
33 \section power_meter_page_sec_1 What does it do? | |
34 The power metering module implements a simple IIR type running power meter. The damping | |
35 factor of the IIR is selectable when the meter instance is created. | |
36 | |
37 Note that the definition of dBOv is quite vague in most places - is it peak since wave, | |
38 peak square wave, etc.? This code is based on the well defined wording in RFC3389: | |
39 | |
40 "For example, in the case of a u-law system, the reference would be a square wave with | |
41 values +/-8031, and this square wave represents 0dBov. This translates into 6.18dBm0". | |
42 | |
43 \section power_meter_page_sec_2 How does it work? | |
44 */ | |
45 | |
46 /*! | |
47 Power meter descriptor. This defines the working state for a | |
48 single instance of a power measurement device. | |
49 */ | |
50 typedef struct | |
51 { | |
52 int shift; | |
53 | |
54 int32_t reading; | |
55 } power_meter_t; | |
56 | |
57 #ifdef __cplusplus | |
58 extern "C" { | |
59 #endif | |
60 | |
61 /*! Initialise a power meter context. | |
62 \brief Initialise a power meter context. | |
63 \param s The power meter context. | |
64 \param shift The shift to be used by the IIR filter. | |
65 \return The power meter context. */ | |
66 power_meter_t *power_meter_init(power_meter_t *s, int shift); | |
67 | |
68 /*! Change the damping factor of a power meter context. | |
69 \brief Change the damping factor of a power meter context. | |
70 \param s The power meter context. | |
71 \param shift The new shift to be used by the IIR filter. | |
72 \return The power meter context. */ | |
73 power_meter_t *power_meter_damping(power_meter_t *s, int shift); | |
74 | |
75 /*! Update a power meter. | |
76 \brief Update a power meter. | |
77 \param s The power meter context. | |
78 \param amp The amplitude of the new audio sample. | |
79 \return The current power meter reading. */ | |
80 int32_t power_meter_update(power_meter_t *s, int16_t amp); | |
81 | |
82 /*! Get the current power meter reading, in dBm0. | |
83 \brief Get the current power meter reading, in dBm0. | |
84 \param s The power meter context. | |
85 \return The current power meter reading, in dBm0. */ | |
86 float power_meter_dbm0(power_meter_t *s); | |
87 | |
88 /*! Get the current power meter reading, in dBOv. | |
89 \brief Get the current power meter reading, in dBOv. | |
90 \param s The power meter context. | |
91 \return The current power meter reading, in dBOv. */ | |
92 float power_meter_dbov(power_meter_t *s); | |
93 | |
94 /*! Get the power meter reading which represents a specified power level in dBm0. | |
95 \brief Get the current power meter reading, in dBm0. | |
96 \param level A power level, in dB0m. | |
97 \return The equivalent power meter reading. */ | |
98 int32_t power_meter_level_dbm0(float level); | |
99 | |
100 /*! Get the power meter reading which represents a specified power level in dBOv. | |
101 \brief Get the current power meter reading, in dBOv. | |
102 \param level A power level, in dBOv. | |
103 \return The equivalent power meter reading. */ | |
104 int32_t power_meter_level_dbov(float level); | |
105 | |
106 #ifdef __cplusplus | |
107 } | |
108 #endif | |
109 | |
110 #endif | |
111 /*- End of file ------------------------------------------------------------*/ |