00001 /* 00002 * SpanDSP - a series of DSP components for telephony 00003 * 00004 * awgn.h - An additive Gaussian white noise generator 00005 * 00006 * Written by Steve Underwood <steveu@coppice.org> 00007 * 00008 * Copyright (C) 2001 Steve Underwood 00009 * 00010 * All rights reserved. 00011 * 00012 * This program is free software; you can redistribute it and/or modify 00013 * it under the terms of the GNU Lesser General Public License version 2.1, 00014 * as published by the Free Software Foundation. 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Lesser General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Lesser General Public 00022 * License along with this program; if not, write to the Free Software 00023 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00024 * 00025 * $Id: awgn.h,v 1.14 2008/04/17 14:26:59 steveu Exp $ 00026 */ 00027 00028 /*! \file */ 00029 00030 /* This code is based on some demonstration code in a research 00031 paper somewhere. I can't track down where I got the original from, 00032 so that due recognition can be given. The original had no explicit 00033 copyright notice, and I hope nobody objects to its use here. 00034 00035 Having a reasonable Gaussian noise generator is pretty important for 00036 telephony testing (in fact, pretty much any DSP testing), and this 00037 one seems to have served me OK. Since the generation of Gaussian 00038 noise is only for test purposes, and not a core system component, 00039 I don't intend to worry excessively about copyright issues, unless 00040 someone worries me. 00041 00042 The non-core nature of this code also explains why it is unlikely 00043 to ever be optimised. */ 00044 00045 #if !defined(_SPANDSP_AWGN_H_) 00046 #define _SPANDSP_AWGN_H_ 00047 00048 /*! \page awgn_page Additive white gaussian noise (AWGN) generation 00049 00050 \section awgn_page_sec_1 What does it do? 00051 Adding noise is not the most useful thing in most DSP applications, but it is 00052 awfully useful for test suites. 00053 00054 \section awgn_page_sec_2 How does it work? 00055 00056 This code is based on some demonstration code in a research paper somewhere. I 00057 can't track down where I got the original from, so that due recognition can be 00058 given. The original had no explicit copyright notice, and I hope nobody objects 00059 to its use here. 00060 00061 Having a reasonable Gaussian noise generator is pretty important for telephony 00062 testing (in fact, pretty much any DSP testing), and this one seems to have 00063 served me OK. Since the generation of Gaussian noise is only for test purposes, 00064 and not a core system component, I don't intend to worry excessively about 00065 copyright issues, unless someone worries me. 00066 00067 The non-core nature of this code also explains why it is unlikely to ever be 00068 optimised. 00069 */ 00070 00071 /*! 00072 AWGN generator descriptor. This contains all the state information for an AWGN generator. 00073 */ 00074 typedef struct 00075 { 00076 double rms; 00077 long int ix1; 00078 long int ix2; 00079 long int ix3; 00080 double r[98]; 00081 double gset; 00082 int iset; 00083 } awgn_state_t; 00084 00085 #if defined(__cplusplus) 00086 extern "C" 00087 { 00088 #endif 00089 00090 awgn_state_t *awgn_init_dbm0(awgn_state_t *s, int idum, float level); 00091 00092 awgn_state_t *awgn_init_dbov(awgn_state_t *s, int idum, float level); 00093 00094 int16_t awgn(awgn_state_t *s); 00095 00096 #if defined(__cplusplus) 00097 } 00098 #endif 00099 00100 #endif 00101 /*- End of file ------------------------------------------------------------*/