tomwalters@268: // Copyright 2006-2010, Thomas Walters tomwalters@268: // tomwalters@268: // AIM-C: A C++ implementation of the Auditory Image Model tomwalters@268: // http://www.acousticscale.org/AIMC tomwalters@268: // tomwalters@268: // This program is free software: you can redistribute it and/or modify tomwalters@268: // it under the terms of the GNU General Public License as published by tomwalters@268: // the Free Software Foundation, either version 3 of the License, or tomwalters@268: // (at your option) any later version. tomwalters@268: // tomwalters@268: // This program is distributed in the hope that it will be useful, tomwalters@268: // but WITHOUT ANY WARRANTY; without even the implied warranty of tomwalters@268: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the tomwalters@268: // GNU General Public License for more details. tomwalters@268: // tomwalters@268: // You should have received a copy of the GNU General Public License tomwalters@268: // along with this program. If not, see . tomwalters@268: tomwalters@268: /*! \file tomwalters@268: * \brief SAI module tomwalters@268: */ tomwalters@268: tomwalters@268: /*! \author Thomas Walters tomwalters@268: * \date created 2007/08/29 tomwalters@268: * \version \$Id: ModuleSAI.h 4 2010-02-03 18:44:58Z tcw $ tomwalters@268: */ tomwalters@268: #ifndef _AIMC_MODULE_SAI_H_ tomwalters@268: #define _AIMC_MODULE_SAI_H_ tomwalters@268: tomwalters@268: #include tomwalters@268: tomwalters@268: #include "Support/Module.h" tomwalters@268: #include "Support/SignalBank.h" tomwalters@268: #include "Support/StrobeList.h" tomwalters@268: tomwalters@268: namespace aimc { tomwalters@268: using std::vector; tomwalters@268: class ModuleSAI : public Module { tomwalters@268: public: tomwalters@268: ModuleSAI(Parameters *parameters); tomwalters@268: virtual ~ModuleSAI(); tomwalters@268: void Process(const SignalBank &input); tomwalters@268: void Reset(); tomwalters@268: tomwalters@268: private: tomwalters@268: /*! \brief Prepare the module tomwalters@268: * \param input Input signal bank tomwalters@268: * \param output true on success false on failure tomwalters@268: */ tomwalters@268: bool InitializeInternal(const SignalBank &input); tomwalters@268: tomwalters@268: //! \brief Temporary buffer for constructing the current SAI frame tomwalters@268: SignalBank sai_temp_; tomwalters@268: tomwalters@268: //! \brief List of strobes for each channel tomwalters@268: vector active_strobes_; tomwalters@268: tomwalters@268: //! \brief Buffer decay parameter tomwalters@268: float buffer_memory_decay_; tomwalters@268: tomwalters@268: //! \brief Sample index of minimum strobe delay tomwalters@268: int min_strobe_delay_idx_; tomwalters@268: tomwalters@268: //! \brief Sample index of maximum strobe delay tomwalters@268: int max_strobe_delay_idx_; tomwalters@268: tomwalters@268: //! \brief Factor with which the SAI should be decayed tomwalters@268: float sai_decay_factor_; tomwalters@268: tomwalters@268: //! \brief Precomputed 1/n^alpha values for strobe weighting tomwalters@268: vector strobe_weights_; tomwalters@268: tomwalters@268: //! \brief Next Strobe for each channels tomwalters@268: vector next_strobes_; tomwalters@268: tomwalters@268: float strobe_weight_alpha_; tomwalters@268: tomwalters@268: /*! \brief The maximum number strobes that can be active at the same time. tomwalters@268: * tomwalters@268: * A strobe lasts for strobe.maxdelay, there can only be a certain number tomwalters@268: * of strobes active at the same time, that's this value. It's used for tomwalters@268: * allocating memory buffers, like m_pUnfinishedStrobeCount and tomwalters@268: * m_pStrobeWeights. tomwalters@268: */ tomwalters@268: int max_concurrent_strobes_; tomwalters@268: tomwalters@268: int fire_period_samples_; tomwalters@268: int fire_counter_; tomwalters@268: tomwalters@268: //! \brief Period in milliseconds between output frames tomwalters@268: float output_frame_period_ms_; tomwalters@268: tomwalters@268: //! \brief Time of the last frame output tomwalters@268: float last_output_frame_time_ms_; tomwalters@268: }; tomwalters@268: } // namespace aimc tomwalters@268: tomwalters@268: #endif // _AIMC_MODULE_SAI_H_