spandsp: noise.h Source File

spandsp 0.0.6

noise.h
Go to the documentation of this file.
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 Lesser General Public License version 2.1,
15 * as 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 Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */
26
27/*! \file */
28
29#if !defined(_SPANDSP_NOISE_H_)
30#define _SPANDSP_NOISE_H_
31
32/*! \page noise_page Noise generation
33
34\section noise_page_sec_1 What does it do?
35It generates audio noise. Currently it only generates reasonable quality
36AWGN. It is designed to be of sufficiently low complexity to generate large
37volumes of reasonable quality noise, in real time.
38
39Hoth noise is used to model indoor ambient noise when evaluating communications
40systems such as telephones. It is named after D.F. Hoth, who made the first
41systematic study of this. The official definition of Hoth noise is IEEE
42standard 269-2001 (revised from 269-1992), "Draft Standard Methods for Measuring
43Transmission Performance of Analog and Digital Telephone Sets, Handsets and Headsets."
44
45The table below gives the spectral density of Hoth noise, adjusted in level to produce
46a reading of 50 dBA.
47
48Freq (Hz) Spectral Bandwidth Total power in
49 density 10 log_f each 1/3 octave band
50 (dB SPL/Hz) (dB) (dB SPL)
51 100 32.4 13.5 45.9
52 125 30.9 14.7 45.5
53 160 29.1 15.7 44.9
54 200 27.6 16.5 44.1
55 250 26.0 17.6 43.6
56 315 24.4 18.7 43.1
57 400 22.7 19.7 42.3
58 500 21.1 20.6 41.7
59 630 19.5 21.7 41.2
60 800 17.8 22.7 40.4
611000 16.2 23.5 39.7
621250 14.6 24.7 39.3
631600 12.9 25.7 38.7
642000 11.3 26.5 37.8
652500 9.6 27.6 37.2
663150 7.8 28.7 36.5
674000 5.4 29.7 34.8
685000 2.6 30.6 33.2
696300 -1.3 31.7 30.4
708000 -6.6 32.7 26.0
71
72The tolerance for each 1/3rd octave band is กำ3dB.
73
74\section awgn_page_sec_2 How does it work?
75The central limit theorem says if you add a few random numbers together,
76the result starts to look Gaussian. In this case we sum 8 random numbers.
77The result is fast, and perfectly good as a noise source for many purposes.
78It should not be trusted as a high quality AWGN generator, for elaborate
79modelling purposes.
80*/
81
82enum
83{
84 NOISE_CLASS_AWGN = 1,
85 NOISE_CLASS_HOTH
86};
87
88/*!
89 Noise generator descriptor. This contains all the state information for an instance
90 of the noise generator.
91 */
92 typedef struct noise_state_s noise_state_t;
93
94#if defined(__cplusplus)
95extern "C"
96{
97#endif
98
99/*! Initialise an audio noise generator.
100 \brief Initialise an audio noise generator.
101 \param s The noise generator context.
102 \param seed A seed for the underlying random number generator.
103 \param level The noise power level in dBmO.
104 \param class_of_noise The class of noise (e.g. AWGN).
105 \param quality A parameter which permits speed and accuracy of the noise
106 generation to be adjusted.
107 \return A pointer to the noise generator context.
108*/
109SPAN_DECLARE(noise_state_t *) noise_init_dbm0(noise_state_t *s, int seed, float level, int class_of_noise, int quality);
110
111SPAN_DECLARE(noise_state_t *) noise_init_dbov(noise_state_t *s, int seed, float level, int class_of_noise, int quality);
112
113SPAN_DECLARE(int) noise_release(noise_state_t *s);
114
115SPAN_DECLARE(int) noise_free(noise_state_t *s);
116
117/*! Generate a sample of audio noise.
118 \brief Generate a sample of audio noise.
119 \param s The noise generator context.
120 \return The generated sample.
121*/
122SPAN_DECLARE(int16_t) noise(noise_state_t *s);
123
124#if defined(__cplusplus)
125}
126#endif
127
128#endif
129/*- End of file ------------------------------------------------------------*/
noise_state_t
struct noise_state_s noise_state_t
Definition noise.h:92
noise_init_dbm0
noise_state_t * noise_init_dbm0(noise_state_t *s, int seed, float level, int class_of_noise, int quality)
Initialise an audio noise generator.
Definition noise.c:110
noise
int16_t noise(noise_state_t *s)
Generate a sample of audio noise.
Definition noise.c:52
noise_state_s
Definition private/noise.h:37