forked from i3thuan5/FaNT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sv-p56.h
78 lines (67 loc) · 3.51 KB
/
sv-p56.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
============================================================================
File: SV-P56.H 01.SEP.1995 v2.2
============================================================================
UGST/CCITT SPEECH VOLTMETER MODULE
GLOBAL FUNCTION PROTOTYPES
=============================================================
COPYRIGHT NOTE: This source code, and all of its derivations,
is subject to the "CCITT General Public License". Please have
it read in the distribution disk, or in the CCITT
Recommendation G.191 on "SOFTWARE TOOLS FOR SPEECH AND AUDIO
CODING STANDARDS".
=============================================================
History:
28.Feb.92 v1.0 First version <tdsimao@venus.cpqd.ansp.br>
18.May.92 v1.1 Prototype of new init_speech_voltmeter;
removal of `init` parameter in speech_voltmeter;
macros for accessing SVP56_state statistics.
<tdsimao@venus.cpqd.ansp.br>
01.Sep.95 v2.2 Updated version number to match sv-p56.c and added
smart prototypes <simao@ctd.comsat.com>
============================================================================
*/
#ifndef SPEECH_VOLTMETER_defined
#define SPEECH_VOLTMETER_defined 220
/* DEFINITION FOR SMART PROTOTYPES */
#ifndef ARGS
#if defined(MSDOS) || defined(__MSDOS__) || defined(__STDC__) || defined(VMS)
#define ARGS(x) x
#else /* Unix: no parameters in prototype! */
#define ARGS(x) ()
#endif
#endif
/* State for speech voltmeter function */
typedef struct
{
float f; /* sampling frequency, in Hz */
unsigned long a[15]; /* activity count */
double c[15]; /* threshold level; 15 is the no.of thres. */
unsigned long hang[15]; /* hangover count */
unsigned long n; /* number of samples read since last reset */
double s; /* sum of all samples since last reset */
double sq; /* squared sum of samples since last reset */
double p; /* intermediate quantities */
double q; /* envelope */
double max; /* max absolute value found since last reset */
double refdB; /* 0 dB reference point, in [dB] */
double rmsdB; /* rms value found since last reset */
double maxP, maxN; /* maximum pos/neg.values since last reset */
double DClevel; /* average level since last reset */
double ActivityFactor; /* Activity factor since last reset */
} SVP56_state;
/* Speech voltmeter prototypes */
double bin_interp ARGS((double upcount, double lwcount, double upthr,
double lwthr, double Margin, double tol));
void init_speech_voltmeter ARGS((SVP56_state *state, double sampl_freq));
double speech_voltmeter ARGS((float *buffer, long smpno, SVP56_state *state));
/* Definitions for getting statistics from a `SVP56_state' variable */
#define SVP56_get_rms_dB(state) (state.rmsdB)
#define SVP56_get_DC_level(state) ((state).DClevel)
#define SVP56_get_activity(state) ((state.ActivityFactor) * 100.0)
#define SVP56_get_pos_max(state) ((state).maxP)
#define SVP56_get_neg_max(state) ((state).maxN)
#define SVP56_get_abs_max(state) ((state).max)
#define SVP56_get_smpno(state) ((state).n)
#endif /* SPEECH_VOLTMETER_defined */
/* ........................ End of SVP56.H .......................... */