tomwalters@275: // Copyright 2006-2010, Willem van Engen, Thomas Walters tomwalters@275: // tomwalters@275: // AIM-C: A C++ implementation of the Auditory Image Model tomwalters@275: // http://www.acousticscale.org/AIMC tomwalters@275: // tomwalters@275: // This program is free software: you can redistribute it and/or modify tomwalters@275: // it under the terms of the GNU General Public License as published by tomwalters@275: // the Free Software Foundation, either version 3 of the License, or tomwalters@275: // (at your option) any later version. tomwalters@275: // tomwalters@275: // This program is distributed in the hope that it will be useful, tomwalters@275: // but WITHOUT ANY WARRANTY; without even the implied warranty of tomwalters@275: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the tomwalters@275: // GNU General Public License for more details. tomwalters@275: // tomwalters@275: // You should have received a copy of the GNU General Public License tomwalters@275: // along with this program. If not, see . tomwalters@275: tomwalters@275: /*! \file tomwalters@275: * \brief Audio file input tomwalters@275: * tomwalters@275: * \author Willem van Engen tomwalters@275: * \author Thomas Walters tomwalters@275: * \date created 2006/09/21 tomwalters@275: * \version \$Id$ tomwalters@275: */ tomwalters@275: tomwalters@275: #ifndef _AIMC_MODULES_INPUT_FILE_H_ tomwalters@275: #define _AIMC_MODULES_INPUT_FILE_H_ tomwalters@275: tomwalters@275: #include tomwalters@275: tomwalters@275: #include "Support/Module.h" tomwalters@275: #include "Support/Parameters.h" tomwalters@275: #include "Support/SignalBank.h" tomwalters@275: tomwalters@275: namespace aimc { tomwalters@275: class ModuleFileInput : public Module { tomwalters@275: public: tomwalters@280: explicit ModuleFileInput(Parameters *pParam); tomwalters@279: virtual ~ModuleFileInput(); tomwalters@275: tomwalters@279: /*! \brief Initializes this input device using an audio file tomwalters@279: * \param sFilename Path of the file to load tomwalters@279: * \return true on success, false on error tomwalters@279: */ tomwalters@279: bool LoadFile(const char *sFilename); tomwalters@275: tomwalters@280: /*! \brief Process the loaded file. tomwalters@280: */ tomwalters@275: void Process(); tomwalters@275: tomwalters@280: /*! \brief Dummy Initialize function. Call LoadFile instead. tomwalters@280: */ tomwalters@275: virtual bool Initialize(const SignalBank &input); tomwalters@275: tomwalters@280: /*! \brief Dummy funciton to comply with the Module specification. Gives an tomwalters@280: * error message when called. tomwalters@280: */ tomwalters@275: virtual void Process(const SignalBank &input); tomwalters@275: tomwalters@275: private: tomwalters@280: /*! \brief Prepare the module tomwalters@280: * \param input Input SignalBank tomwalters@280: * \param output true on success false on failure tomwalters@280: */ tomwalters@275: virtual bool InitializeInternal(const SignalBank &input); tomwalters@275: tomwalters@280: /*! \brief Rewind to the start of the file tomwalters@280: */ tomwalters@275: virtual void ResetInternal(); tomwalters@275: tomwalters@280: /*! \brief File descriptor tomwalters@280: */ tomwalters@279: SNDFILE *file_handle_; tomwalters@275: tomwalters@280: /*! \brief Current position in time of the file tomwalters@280: */ tomwalters@275: int file_position_samples_; tomwalters@275: bool file_loaded_; tomwalters@275: int audio_channels_; tomwalters@275: int buffer_length_; tomwalters@275: float sample_rate_; tomwalters@275: }; tomwalters@275: } // namespace aimc tomwalters@275: tomwalters@280: #endif // _AIMC_MODULES_INPUT_FILE_H_