noise.h

Go to the documentation of this file.
00001 /*
00002  * SpanDSP - a series of DSP components for telephony
00003  *
00004  * noise.h - A low complexity audio noise generator, suitable for
00005  *           real time generation (current just approx AWGN)
00006  *
00007  * Written by Steve Underwood <steveu@coppice.org>
00008  *
00009  * Copyright (C) 2005 Steve Underwood
00010  *
00011  * All rights reserved.
00012  *
00013  * This program is free software; you can redistribute it and/or modify
00014  * it under the terms of the GNU Lesser General Public License version 2.1,
00015  * as published by the Free Software Foundation.
00016  *
00017  * This program is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  * GNU Lesser General Public License for more details.
00021  *
00022  * You should have received a copy of the GNU Lesser General Public
00023  * License along with this program; if not, write to the Free Software
00024  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00025  *
00026  * $Id: noise.h,v 1.13 2008/04/17 14:27:00 steveu Exp $
00027  */
00028 
00029 /*! \file */
00030 
00031 #if !defined(_SPANDSP_NOISE_H_)
00032 #define _SPANDSP_NOISE_H_
00033 
00034 /*! \page noise_page Noise generation
00035 
00036 \section noise_page_sec_1 What does it do?
00037 It generates audio noise. Currently it only generates reasonable quality
00038 AWGN. It is designed to be of sufficiently low complexity to generate large
00039 volumes of reasonable quality noise, in real time.
00040 
00041 Hoth noise is used to model indoor ambient noise when evaluating communications
00042 systems such as telephones. It is named after D.F. Hoth, who made the first 
00043 systematic study of this. The official definition of Hoth noise is IEEE
00044 standard 269-2001 (revised from 269-1992), "Draft Standard Methods for Measuring
00045 Transmission Performance of Analog and Digital Telephone Sets, Handsets and Headsets."
00046 
00047 The table below gives the spectral density of Hoth noise, adjusted in level to produce
00048 a reading of 50 dBA.
00049 
00050 Freq (Hz)  Spectral     Bandwidth       Total power in
00051            density      10 log_f        each 1/3 octave band
00052            (dB SPL/Hz)  (dB)            (dB SPL)
00053  100        32.4        13.5            45.9
00054  125        30.9        14.7            45.5
00055  160        29.1        15.7            44.9
00056  200        27.6        16.5            44.1
00057  250        26.0        17.6            43.6
00058  315        24.4        18.7            43.1
00059  400        22.7        19.7            42.3
00060  500        21.1        20.6            41.7
00061  630        19.5        21.7            41.2
00062  800        17.8        22.7            40.4
00063 1000        16.2        23.5            39.7
00064 1250        14.6        24.7            39.3
00065 1600        12.9        25.7            38.7
00066 2000        11.3        26.5            37.8
00067 2500         9.6        27.6            37.2
00068 3150         7.8        28.7            36.5
00069 4000         5.4        29.7            34.8
00070 5000         2.6        30.6            33.2
00071 6300        -1.3        31.7            30.4
00072 8000        -6.6        32.7            26.0
00073 
00074 The tolerance for each 1/3rd octave band is กำ3dB.
00075 
00076 \section awgn_page_sec_2 How does it work?
00077 The central limit theorem says if you add a few random numbers together,
00078 the result starts to look Gaussian. In this case we sum 8 random numbers.
00079 The result is fast, and perfectly good as a noise source for many purposes.
00080 It should not be trusted as a high quality AWGN generator, for elaborate
00081 modelling purposes.
00082 */
00083 
00084 enum
00085 {
00086     NOISE_CLASS_AWGN = 1,
00087     NOISE_CLASS_HOTH
00088 };
00089 
00090 /*!
00091     Noise generator descriptor. This contains all the state information for an instance
00092     of the noise generator.
00093  */
00094 typedef struct
00095 {
00096     int class_of_noise;
00097     int quality;
00098     int32_t rms;
00099     uint32_t rndnum;
00100     int32_t state;
00101 } noise_state_t;
00102 
00103 #if defined(__cplusplus)
00104 extern "C"
00105 {
00106 #endif
00107 
00108 /*! Initialise an audio noise generator.
00109     \brief Initialise an audio noise generator.
00110     \param s The noise generator context.
00111     \param seed A seed for the underlying random number generator.
00112     \param level The noise power level in dBmO.
00113     \param class_of_noise The class of noise (e.g. AWGN).
00114     \param quality A parameter which permits speed and accuracy of the noise
00115            generation to be adjusted.
00116     \return A pointer to the noise generator context.
00117 */
00118 noise_state_t *noise_init_dbm0(noise_state_t *s, int seed, float level, int class_of_noise, int quality);
00119 
00120 noise_state_t *noise_init_dbov(noise_state_t *s, int seed, float level, int class_of_noise, int quality);
00121 
00122 /*! Generate a sample of audio noise.
00123     \brief Generate a sample of audio noise.
00124     \param s The noise generator context.
00125     \return The generated sample.
00126 */
00127 int16_t noise(noise_state_t *s);
00128 
00129 #if defined(__cplusplus)
00130 }
00131 #endif
00132 
00133 #endif
00134 /*- End of file ------------------------------------------------------------*/

Generated on Tue Oct 7 20:25:47 2008 for spandsp by  doxygen 1.5.6