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@3: #ifndef _AIMC_MODULES_INPUT_FILE_H_
tomwalters@3: #define _AIMC_MODULES_INPUT_FILE_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@3: ModuleFileInput(Parameters *pParam);
tomwalters@3: virtual ~ModuleFileInput();
tomwalters@3:
tomwalters@3: /*! \brief Initializes this input device using an audio file
tomwalters@3: * \param sFilename Path of the file to load
tomwalters@3: * \return true on success, false on error
tomwalters@3: */
tomwalters@3: bool LoadFile(const char *sFilename);
tomwalters@3:
tomwalters@3: //! \brief Process the loaded file.
tomwalters@3: void Process();
tomwalters@3:
tomwalters@3: //! \brief Dummy Initialize function. Call LoadFile instead.
tomwalters@3: virtual bool Initialize(const SignalBank &input);
tomwalters@3:
tomwalters@3: //! \brief Dummy funciton to comply with the Module specification. Gives an
tomwalters@3: // error message when called.
tomwalters@3: virtual void Process(const SignalBank &input);
tomwalters@3:
tomwalters@3: private:
tomwalters@3: //! \brief Prepare the module
tomwalters@3: //! \param input Input SignalBank
tomwalters@3: //! \param output true on success false on failure
tomwalters@3: virtual bool InitializeInternal(const SignalBank &input);
tomwalters@3:
tomwalters@3: //! \brief Rewind to the start of the file
tomwalters@3: virtual void ResetInternal();
tomwalters@3:
tomwalters@3: //! \brief File descriptor
tomwalters@3: SNDFILE *file_handle_;
tomwalters@3:
tomwalters@3: //! \brief Current position in time of the file
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@3: #endif // _AIMC_MODULES_INPUT_FILE_H_