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