Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

NoiseGenerator.h

00001 #ifndef NOISEGENERATOR_H
00002 #define NOISEGENERATOR_H
00003 /*
00004  * This is the Loris C++ Class Library, implementing analysis, 
00005  * manipulation, and synthesis of digitized sounds using the Reassigned 
00006  * Bandwidth-Enhanced Additive Sound Model.
00007  *
00008  * Loris is Copyright (c) 1999-2004 by Kelly Fitz and Lippold Haken
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY, without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  *
00024  *
00025  * NoiseGenerator.h
00026  *
00027  * Definition of a class representing a filtered noise generator, used 
00028  * as a modulator in bandwidth-enhanced synthesis.
00029  *
00030  * Kelly Fitz, 5 June 2003
00031  * loris@cerlsoundgroup.org
00032  *
00033  * http://www.cerlsoundgroup.org/Loris/
00034  *
00035  */
00036 
00037 #include "Filter.h"
00038 
00039 //  begin namespace
00040 namespace Loris {
00041 
00042 // ---------------------------------------------------------------------------
00043 //  class NoiseGenerator
00044 //
00045 class NoiseGenerator
00046 {
00047 //  --- interface ---
00048 public:
00049     //  construction
00050     //  copy and assign are free
00051     explicit NoiseGenerator( double initSeed = 1.0 );
00052     NoiseGenerator( const Filter & f, double initSeed = 1.0 );
00053 
00054     //  seed the random number generator and clear the filter's
00055     //  delay line:
00056     void reset( double newSeed );
00057     
00058     //  return the most-recently generated sample:
00059     double current( void ) const { return sample; }
00060     
00061     //  generate and return a new sample of 
00062     //  filtered noise:
00063     double next( void );
00064     double operator() ( void ) { return next(); }
00065     
00066     double next( double mean, double stddev = 1. );
00067     double operator() ( double mean, double stddev = 1. ) { return next( mean, stddev ); }
00068 
00069 
00070 //  --- implementation ---
00071 private:
00072     //  random number 
00073     inline double uniform( void );
00074     inline double gaussian_normal( void );
00075 
00076     double sample;  //  the most recently-computed noise sample
00077     Filter filter;  //  filter applied to random number generator
00078 
00079     // random number generator implementation:
00080     double u_seed;
00081     double gset;
00082     bool iset;
00083     
00084 };
00085 
00086 
00087 }   //  end of namespace Loris
00088 
00089 #endif  /* ndef NOISEGENERATOR_H */

Generated on Thu Apr 14 22:01:55 2005 for Loris by doxygen 1.3.4