comparison src/Modules/Input/ModuleFileInput.h @ 3:decdac21cfc2

- Imported file input using libsndfile from old AIM-C and updated to the new API - Modified the Module base class to propogate Reset() calls down the module chain. - This required changing all Reset() functions in subclasses to ResetInternal() - Removed some unneeded imports from the Gaussians test
author tomwalters
date Tue, 16 Feb 2010 18:00:16 +0000
parents
children 1a1988ec40e7
comparison
equal deleted inserted replaced
2:e91769e84be1 3:decdac21cfc2
1 // Copyright 2006-2010, Willem van Engen, Thomas Walters
2 //
3 // AIM-C: A C++ implementation of the Auditory Image Model
4 // http://www.acousticscale.org/AIMC
5 //
6 // This program is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19 /*! \file
20 * \brief Audio file input
21 *
22 * \author Willem van Engen <cnbh@willem.engen.nl>
23 * \author Thomas Walters <tom@acousticscale.org>
24 * \date created 2006/09/21
25 * \version \$Id$
26 */
27
28 #ifndef _AIMC_MODULES_INPUT_FILE_H_
29 #define _AIMC_MODULES_INPUT_FILE_H_
30
31 #include <sndfile.h>
32
33 #include "Support/Module.h"
34 #include "Support/Parameters.h"
35 #include "Support/SignalBank.h"
36
37 namespace aimc {
38 class ModuleFileInput : public Module {
39 public:
40 ModuleFileInput(Parameters *pParam);
41 virtual ~ModuleFileInput();
42
43 /*! \brief Initializes this input device using an audio file
44 * \param sFilename Path of the file to load
45 * \return true on success, false on error
46 */
47 bool LoadFile(const char *sFilename);
48
49 //! \brief Process the loaded file.
50 void Process();
51
52 //! \brief Dummy Initialize function. Call LoadFile instead.
53 virtual bool Initialize(const SignalBank &input);
54
55 //! \brief Dummy funciton to comply with the Module specification. Gives an
56 // error message when called.
57 virtual void Process(const SignalBank &input);
58
59 private:
60 //! \brief Prepare the module
61 //! \param input Input SignalBank
62 //! \param output true on success false on failure
63 virtual bool InitializeInternal(const SignalBank &input);
64
65 //! \brief Rewind to the start of the file
66 virtual void ResetInternal();
67
68 //! \brief File descriptor
69 SNDFILE *file_handle_;
70
71 //! \brief Current position in time of the file
72 int file_position_samples_;
73 bool file_loaded_;
74 int audio_channels_;
75 int buffer_length_;
76 float sample_rate_;
77 };
78 } // namespace aimc
79
80 #endif // _AIMC_MODULES_INPUT_FILE_H_