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@275
|
6 // This program is free software: you can redistribute it and/or modify
|
tomwalters@275
|
7 // it under the terms of the GNU General Public License as published by
|
tomwalters@275
|
8 // the Free Software Foundation, either version 3 of the License, or
|
tomwalters@275
|
9 // (at your option) any later version.
|
tomwalters@275
|
10 //
|
tomwalters@275
|
11 // This program is distributed in the hope that it will be useful,
|
tomwalters@275
|
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
tomwalters@275
|
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
tomwalters@275
|
14 // GNU General Public License for more details.
|
tomwalters@275
|
15 //
|
tomwalters@275
|
16 // You should have received a copy of the GNU General Public License
|
tomwalters@275
|
17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
|
tomwalters@275
|
18
|
tomwalters@275
|
19 /*! \file
|
tomwalters@275
|
20 * \brief Audio file input
|
tomwalters@275
|
21 *
|
tomwalters@275
|
22 * \author Willem van Engen <cnbh@willem.engen.nl>
|
tomwalters@275
|
23 * \author Thomas Walters <tom@acousticscale.org>
|
tomwalters@275
|
24 * \date created 2006/09/21
|
tomwalters@275
|
25 * \version \$Id$
|
tomwalters@275
|
26 */
|
tomwalters@275
|
27
|
tomwalters@275
|
28 #ifndef _AIMC_MODULES_INPUT_FILE_H_
|
tomwalters@275
|
29 #define _AIMC_MODULES_INPUT_FILE_H_
|
tomwalters@275
|
30
|
tomwalters@275
|
31 #include <sndfile.h>
|
tomwalters@275
|
32
|
tomwalters@275
|
33 #include "Support/Module.h"
|
tomwalters@275
|
34 #include "Support/Parameters.h"
|
tomwalters@275
|
35 #include "Support/SignalBank.h"
|
tomwalters@275
|
36
|
tomwalters@275
|
37 namespace aimc {
|
tomwalters@275
|
38 class ModuleFileInput : public Module {
|
tomwalters@275
|
39 public:
|
tomwalters@280
|
40 explicit ModuleFileInput(Parameters *pParam);
|
tomwalters@279
|
41 virtual ~ModuleFileInput();
|
tomwalters@275
|
42
|
tomwalters@279
|
43 /*! \brief Initializes this input device using an audio file
|
tomwalters@279
|
44 * \param sFilename Path of the file to load
|
tomwalters@279
|
45 * \return true on success, false on error
|
tomwalters@279
|
46 */
|
tomwalters@279
|
47 bool LoadFile(const char *sFilename);
|
tomwalters@275
|
48
|
tomwalters@280
|
49 /*! \brief Process the loaded file.
|
tomwalters@280
|
50 */
|
tomwalters@275
|
51 void Process();
|
tomwalters@275
|
52
|
tomwalters@280
|
53 /*! \brief Dummy Initialize function. Call LoadFile instead.
|
tomwalters@280
|
54 */
|
tomwalters@275
|
55 virtual bool Initialize(const SignalBank &input);
|
tomwalters@275
|
56
|
tomwalters@280
|
57 /*! \brief Dummy funciton to comply with the Module specification. Gives an
|
tomwalters@280
|
58 * error message when called.
|
tomwalters@280
|
59 */
|
tomwalters@275
|
60 virtual void Process(const SignalBank &input);
|
tomwalters@275
|
61
|
tomwalters@275
|
62 private:
|
tomwalters@280
|
63 /*! \brief Prepare the module
|
tomwalters@280
|
64 * \param input Input SignalBank
|
tomwalters@280
|
65 * \param output true on success false on failure
|
tomwalters@280
|
66 */
|
tomwalters@275
|
67 virtual bool InitializeInternal(const SignalBank &input);
|
tomwalters@275
|
68
|
tomwalters@280
|
69 /*! \brief Rewind to the start of the file
|
tomwalters@280
|
70 */
|
tomwalters@275
|
71 virtual void ResetInternal();
|
tomwalters@275
|
72
|
tomwalters@280
|
73 /*! \brief File descriptor
|
tomwalters@280
|
74 */
|
tomwalters@279
|
75 SNDFILE *file_handle_;
|
tomwalters@275
|
76
|
tomwalters@280
|
77 /*! \brief Current position in time of the file
|
tomwalters@280
|
78 */
|
tomwalters@275
|
79 int file_position_samples_;
|
tomwalters@275
|
80 bool file_loaded_;
|
tomwalters@275
|
81 int audio_channels_;
|
tomwalters@275
|
82 int buffer_length_;
|
tomwalters@275
|
83 float sample_rate_;
|
tomwalters@275
|
84 };
|
tomwalters@275
|
85 } // namespace aimc
|
tomwalters@275
|
86
|
tomwalters@280
|
87 #endif // _AIMC_MODULES_INPUT_FILE_H_
|