annotate src/Modules/SNR/ModuleNoise.h @ 611:0fbaf443ec82

Carfac C++ revision 3, indluding more style improvements. The output structs are now classes again, and have separate storage methods for each output structure along with flags in the Run and RunSegment methods to allow for only storing NAPs if desired.
author alexbrandmeyer
date Fri, 17 May 2013 19:52:45 +0000
parents bee31e7ebf4b
children
rev   line source
tomwalters@32 1 // Copyright 2010, Thomas Walters
tomwalters@32 2 //
tomwalters@32 3 // AIM-C: A C++ implementation of the Auditory Image Model
tomwalters@32 4 // http://www.acousticscale.org/AIMC
tomwalters@32 5 //
tomwalters@45 6 // Licensed under the Apache License, Version 2.0 (the "License");
tomwalters@45 7 // you may not use this file except in compliance with the License.
tomwalters@45 8 // You may obtain a copy of the License at
tomwalters@32 9 //
tomwalters@45 10 // http://www.apache.org/licenses/LICENSE-2.0
tomwalters@32 11 //
tomwalters@45 12 // Unless required by applicable law or agreed to in writing, software
tomwalters@45 13 // distributed under the License is distributed on an "AS IS" BASIS,
tomwalters@45 14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
tomwalters@45 15 // See the License for the specific language governing permissions and
tomwalters@45 16 // limitations under the License.
tomwalters@32 17
tomwalters@32 18 /*!
tomwalters@32 19 * \author Thomas Walters <tom@acousticscale.org>
tomwalters@32 20 * \date created 2010/02/24
tomwalters@32 21 * \version \$Id$
tomwalters@32 22 */
tomwalters@32 23
tomwalters@32 24 #ifndef AIMC_MODULES_SNR_NOISE_H_
tomwalters@32 25 #define AIMC_MODULES_SNR_NOISE_H_
tomwalters@32 26
tomwalters@32 27 #include <boost/random.hpp>
tomwalters@32 28
tomwalters@32 29 #include "Support/Module.h"
tomwalters@32 30
tomwalters@32 31 namespace aimc {
tomwalters@32 32 class ModuleNoise : public Module {
tomwalters@32 33 public:
tomwalters@32 34 explicit ModuleNoise(Parameters *pParam);
tomwalters@32 35 virtual ~ModuleNoise();
tomwalters@32 36
tomwalters@32 37 /*! \brief Process a buffer
tomwalters@32 38 */
tomwalters@32 39 virtual void Process(const SignalBank &input);
tomwalters@32 40
tomwalters@32 41 private:
tomwalters@32 42 /*! \brief Reset the internal state of the module
tomwalters@32 43 */
tomwalters@32 44 virtual void ResetInternal();
tomwalters@32 45
tomwalters@32 46 /*! \brief Prepare the module
tomwalters@32 47 * \param input Input signal
tomwalters@32 48 * \param output true on success false on failure
tomwalters@32 49 */
tomwalters@32 50 virtual bool InitializeInternal(const SignalBank &input);
tomwalters@32 51
tomwalters@32 52 float sample_rate_;
tomwalters@32 53 int buffer_length_;
tomwalters@32 54 int channel_count_;
tomwalters@32 55
tomwalters@84 56 // True to generate pink noise, otherwise white noise
tomwalters@84 57 bool pink_;
tomwalters@84 58
tomwalters@84 59 // Filter state variables
tomwalters@84 60 float s0_;
tomwalters@84 61 float s1_;
tomwalters@84 62 float s2_;
tomwalters@84 63
tomwalters@32 64 float multiplier_;
tomwalters@32 65
tomwalters@84 66 // Mersenne twister random number generator fed into a transform which
tomwalters@84 67 // yeilds Gaussian-distributed values
tomwalters@32 68 boost::variate_generator<boost::mt19937,
tomwalters@32 69 boost::normal_distribution<float> >
tomwalters@32 70 gaussian_variate_;
tomwalters@32 71 };
tomwalters@32 72 } // namespace aimc
tomwalters@32 73
tomwalters@32 74 #endif // AIMC_MODULES_SNR_NOISE_H_