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