Mercurial > hg > audiostuff
comparison spandsp-0.0.3/spandsp-0.0.3/src/spandsp/noise.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 * noise.h - A low complexity audio noise generator, suitable for | |
5 * real time generation (current just approx AWGN) | |
6 * | |
7 * Written by Steve Underwood <steveu@coppice.org> | |
8 * | |
9 * Copyright (C) 2005 Steve Underwood | |
10 * | |
11 * All rights reserved. | |
12 * | |
13 * This program is free software; you can redistribute it and/or modify | |
14 * it under the terms of the GNU General Public License version 2, as | |
15 * published by the Free Software Foundation. | |
16 * | |
17 * This program is distributed in the hope that it will be useful, | |
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 * GNU General Public License for more details. | |
21 * | |
22 * You should have received a copy of the GNU General Public License | |
23 * along with this program; if not, write to the Free Software | |
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
25 * | |
26 * $Id: noise.h,v 1.8 2006/10/24 13:45:28 steveu Exp $ | |
27 */ | |
28 | |
29 /*! \file */ | |
30 | |
31 #if !defined(_NOISE_H_) | |
32 #define _NOISE_H_ | |
33 | |
34 /*! \page noise_page Noise generation | |
35 | |
36 \section noise_page_sec_1 What does it do? | |
37 It generates audio noise. Currently it only generates reasonable quality | |
38 AWGN. It is designed to be of sufficiently low complexity to generate large | |
39 volumes of reasonable quality noise, in real time. | |
40 | |
41 Hoth noise is used to model indoor ambient noise when evaluating communications | |
42 systems such as telephones. It is named after D.F. Hoth, who made the first | |
43 systematic study of this. The official definition of Hoth noise is IEEE | |
44 standard 269-2001 (revised from 269-1992), "Draft Standard Methods for Measuring | |
45 Transmission Performance of Analog and Digital Telephone Sets, Handsets and Headsets." | |
46 | |
47 The table below gives the spectral density of Hoth noise, adjusted in level to produce | |
48 a reading of 50 dBA. | |
49 | |
50 Freq (Hz) Spectral Bandwidth Total power in | |
51 density 10 log_f each 1/3 octave band | |
52 (dB SPL/Hz) (dB) (dB SPL) | |
53 100 32.4 13.5 45.9 | |
54 125 30.9 14.7 45.5 | |
55 160 29.1 15.7 44.9 | |
56 200 27.6 16.5 44.1 | |
57 250 26.0 17.6 43.6 | |
58 315 24.4 18.7 43.1 | |
59 400 22.7 19.7 42.3 | |
60 500 21.1 20.6 41.7 | |
61 630 19.5 21.7 41.2 | |
62 800 17.8 22.7 40.4 | |
63 1000 16.2 23.5 39.7 | |
64 1250 14.6 24.7 39.3 | |
65 1600 12.9 25.7 38.7 | |
66 2000 11.3 26.5 37.8 | |
67 2500 9.6 27.6 37.2 | |
68 3150 7.8 28.7 36.5 | |
69 4000 5.4 29.7 34.8 | |
70 5000 2.6 30.6 33.2 | |
71 6300 -1.3 31.7 30.4 | |
72 8000 -6.6 32.7 26.0 | |
73 | |
74 The tolerance for each 1/3rd octave band is กำ3dB. | |
75 | |
76 \section awgn_page_sec_2 How does it work? | |
77 The central limit theorem says if you add a few random numbers together, | |
78 the result starts to look Gaussian. In this case we sum 8 random numbers. | |
79 The result is fast, and perfectly good as a noise source for many purposes. | |
80 It should not be trusted as a high quality AWGN generator, for elaborate | |
81 modelling purposes. | |
82 */ | |
83 | |
84 enum | |
85 { | |
86 NOISE_CLASS_AWGN = 1, | |
87 NOISE_CLASS_HOTH | |
88 }; | |
89 | |
90 /*! | |
91 Noise generator descriptor. This contains all the state information for an instance | |
92 of the noise generator. | |
93 */ | |
94 typedef struct | |
95 { | |
96 int class_of_noise; | |
97 int quality; | |
98 int32_t rms; | |
99 uint32_t rndnum; | |
100 int32_t state; | |
101 } noise_state_t; | |
102 | |
103 #ifdef __cplusplus | |
104 extern "C" { | |
105 #endif | |
106 | |
107 /*! Initialise an audio noise generator. | |
108 \brief Initialise an audio noise generator. | |
109 \param s The noise generator context. | |
110 \param seed A seed for the underlying random number generator. | |
111 \param level The noise power level in dBmO. | |
112 \param class_of_noise The class of noise (e.g. AWGN). | |
113 \param quality A parameter which permits speed and accuracy of the noise | |
114 generation to be adjusted. | |
115 \return A pointer to the noise generator context. | |
116 */ | |
117 noise_state_t *noise_init_dbm0(noise_state_t *s, int seed, float level, int class_of_noise, int quality); | |
118 | |
119 noise_state_t *noise_init_dbov(noise_state_t *s, int seed, float level, int class_of_noise, int quality); | |
120 | |
121 /*! Generate a sample of audio noise. | |
122 \brief Generate a sample of audio noise. | |
123 \param s The noise generator context. | |
124 \return The generated sample. | |
125 */ | |
126 int16_t noise(noise_state_t *s); | |
127 | |
128 #ifdef __cplusplus | |
129 } | |
130 #endif | |
131 | |
132 #endif | |
133 /*- End of file ------------------------------------------------------------*/ |