annotate trunk/src/Modules/Input/ModuleFileInput.h @ 318:30dde71d0230

- Modified licence from GPL 3 to Apache v2
author tomwalters
date Tue, 30 Mar 2010 22:06:24 +0000
parents ef14c9f2c1d2
children 69466da9745e
rev   line source
tomwalters@275 1 // Copyright 2006-2010, Willem van Engen, Thomas Walters
tomwalters@275 2 //
tomwalters@275 3 // AIM-C: A C++ implementation of the Auditory Image Model
tomwalters@275 4 // http://www.acousticscale.org/AIMC
tomwalters@275 5 //
tomwalters@318 6 // Licensed under the Apache License, Version 2.0 (the "License");
tomwalters@318 7 // you may not use this file except in compliance with the License.
tomwalters@318 8 // You may obtain a copy of the License at
tomwalters@275 9 //
tomwalters@318 10 // http://www.apache.org/licenses/LICENSE-2.0
tomwalters@275 11 //
tomwalters@318 12 // Unless required by applicable law or agreed to in writing, software
tomwalters@318 13 // distributed under the License is distributed on an "AS IS" BASIS,
tomwalters@318 14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
tomwalters@318 15 // See the License for the specific language governing permissions and
tomwalters@318 16 // limitations under the License.
tomwalters@275 17
tomwalters@275 18 /*! \file
tomwalters@275 19 * \brief Audio file input
tomwalters@275 20 *
tomwalters@275 21 * \author Willem van Engen <cnbh@willem.engen.nl>
tomwalters@275 22 * \author Thomas Walters <tom@acousticscale.org>
tomwalters@275 23 * \date created 2006/09/21
tomwalters@275 24 * \version \$Id$
tomwalters@275 25 */
tomwalters@275 26
tomwalters@283 27 #ifndef AIMC_MODULES_INPUT_FILEINPUT_H_
tomwalters@283 28 #define AIMC_MODULES_INPUT_FILEINPUT_H_
tomwalters@275 29
tomwalters@275 30 #include <sndfile.h>
tomwalters@275 31
tomwalters@275 32 #include "Support/Module.h"
tomwalters@275 33 #include "Support/Parameters.h"
tomwalters@275 34 #include "Support/SignalBank.h"
tomwalters@275 35
tomwalters@275 36 namespace aimc {
tomwalters@275 37 class ModuleFileInput : public Module {
tomwalters@275 38 public:
tomwalters@280 39 explicit ModuleFileInput(Parameters *pParam);
tomwalters@279 40 virtual ~ModuleFileInput();
tomwalters@275 41
tomwalters@279 42 /*! \brief Initializes this input device using an audio file
tomwalters@279 43 * \param sFilename Path of the file to load
tomwalters@279 44 * \return true on success, false on error
tomwalters@279 45 */
tomwalters@279 46 bool LoadFile(const char *sFilename);
tomwalters@275 47
tomwalters@280 48 /*! \brief Process the loaded file.
tomwalters@280 49 */
tomwalters@275 50 void Process();
tomwalters@275 51
tomwalters@280 52 /*! \brief Dummy Initialize function. Call LoadFile instead.
tomwalters@280 53 */
tomwalters@275 54 virtual bool Initialize(const SignalBank &input);
tomwalters@275 55
tomwalters@280 56 /*! \brief Dummy funciton to comply with the Module specification. Gives an
tomwalters@280 57 * error message when called.
tomwalters@280 58 */
tomwalters@275 59 virtual void Process(const SignalBank &input);
tomwalters@275 60
tomwalters@275 61 private:
tomwalters@280 62 /*! \brief Prepare the module
tomwalters@280 63 * \param input Input SignalBank
tomwalters@280 64 * \param output true on success false on failure
tomwalters@280 65 */
tomwalters@275 66 virtual bool InitializeInternal(const SignalBank &input);
tomwalters@275 67
tomwalters@280 68 /*! \brief Rewind to the start of the file
tomwalters@280 69 */
tomwalters@275 70 virtual void ResetInternal();
tomwalters@275 71
tomwalters@280 72 /*! \brief File descriptor
tomwalters@280 73 */
tomwalters@279 74 SNDFILE *file_handle_;
tomwalters@275 75
tomwalters@280 76 /*! \brief Current position in time of the file
tomwalters@280 77 */
tomwalters@275 78 int file_position_samples_;
tomwalters@275 79 bool file_loaded_;
tomwalters@275 80 int audio_channels_;
tomwalters@275 81 int buffer_length_;
tomwalters@275 82 float sample_rate_;
tomwalters@275 83 };
tomwalters@275 84 } // namespace aimc
tomwalters@275 85
tomwalters@283 86 #endif // AIMC_MODULES_INPUT_FILEINPUT_H_