tomwalters@46: // Copyright 2006-2010, Thomas Walters, Willem van Engen tomwalters@46: // tomwalters@46: // AIM-C: A C++ implementation of the Auditory Image Model tomwalters@46: // http://www.acousticscale.org/AIMC tomwalters@46: // tomwalters@46: // Licensed under the Apache License, Version 2.0 (the "License"); tomwalters@46: // you may not use this file except in compliance with the License. tomwalters@46: // You may obtain a copy of the License at tomwalters@46: // tomwalters@46: // http://www.apache.org/licenses/LICENSE-2.0 tomwalters@46: // tomwalters@46: // Unless required by applicable law or agreed to in writing, software tomwalters@46: // distributed under the License is distributed on an "AS IS" BASIS, tomwalters@46: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. tomwalters@46: // See the License for the specific language governing permissions and tomwalters@46: // limitations under the License. tomwalters@46: tomwalters@46: /*! tomwalters@46: * \file tomwalters@46: * \brief File output to AIMC format tomwalters@46: * tomwalters@46: * \author Thomas Walters tomwalters@46: * \author Willem van Engen tomwalters@46: * \date created 2006/10/30 tomwalters@46: * \version \$Header$ tomwalters@46: */ tomwalters@46: tomwalters@46: #ifndef AIMC_MODULES_OUTPUT_AIMC_H_ tomwalters@46: #define AIMC_MODULES_OUTPUT_AIMC_H_ tomwalters@46: tomwalters@46: #include "Support/Module.h" tomwalters@46: #include "Support/SignalBank.h" tomwalters@46: tomwalters@46: namespace aimc { tomwalters@46: class FileOutputAIMC : public Module { tomwalters@46: public: tomwalters@46: /*! \brief Create a new file output for an AIMC format file. tomwalters@46: */ tomwalters@46: explicit FileOutputAIMC(Parameters *pParam); tomwalters@46: ~FileOutputAIMC(); tomwalters@46: tomwalters@46: /*! \brief Initialize the output to AIMC. tomwalters@46: * \param *filename Filename of the ouptut file to be created. tomwalters@46: * If the file exists it will be overwritten tomwalters@46: * \return Returns true on success of initialization. tomwalters@46: */ tomwalters@157: bool OpenFile(const char *filename, float frame_period_ms); tomwalters@46: bool CloseFile(); tomwalters@46: virtual void Process(const SignalBank &input); tomwalters@46: private: tomwalters@46: virtual bool InitializeInternal(const SignalBank &input); tomwalters@46: virtual void ResetInternal(); tomwalters@46: tomwalters@46: void WriteHeader(); tomwalters@46: tomwalters@46: /*! \brief Whether initialization is done or not tomwalters@46: */ tomwalters@46: bool header_written_; tomwalters@46: tomwalters@46: /*! \brief Internal pointer to the output file tomwalters@46: */ tomwalters@46: FILE *file_handle_; tomwalters@46: tomwalters@46: /*! \brief Count of the number of samples in the file, written on close tomwalters@46: */ tomwalters@159: int frame_count_; tomwalters@46: tomwalters@46: int channel_count_; tomwalters@46: int buffer_length_; tomwalters@228: float sample_rate_; tomwalters@46: float frame_period_ms_; tomwalters@46: }; tomwalters@46: } // namespace aimc tomwalters@46: tomwalters@46: #endif // AIMC_MODULES_OUTPUT_AIMC_H_ tomwalters@46: