comparison trunk/src/Support/SignalBank.h @ 268:e14c70d1b171

- Initial add of support code and modules. Not everything is working yet.
author tomwalters
date Fri, 12 Feb 2010 12:31:23 +0000
parents
children c26222c51fb7
comparison
equal deleted inserted replaced
-1:000000000000 268:e14c70d1b171
1 // Copyright 2010, 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 Basic data structure for a bank of signals with a common sample
21 * rate (in Hz), a centre frequency (in Hz) for each channel, a start time
22 * for the signal (in samples) and optionally, a set of strobe points in each
23 * channel (a vector of the indices of certain points). This is a struct
24 * rather than a class, and data members are accessed directly. Therefore is
25 * is up to the users of this structure to use it properly. Never assume that
26 * a SignalBank will be set up correctly when you receive it. A basic
27 * constructor and initialisation routines are provided.
28 */
29
30 /*! \author: Thomas Walters <tom@acousticscale.org>
31 * \date 2010/01/23
32 * \version \$Id: SignalBank.h 4 2010-02-03 18:44:58Z tcw $
33 */
34
35 #ifndef _AIMC_SUPPORT_SIGNALBANK_H_
36 #define _AIMC_SUPPORT_SIGNALBANK_H_
37
38 #include <deque>
39 #include <vector>
40
41 #include "Support/Common.h"
42
43 namespace aimc {
44 using std::deque;
45 using std::vector;
46 class SignalBank {
47 public:
48 SignalBank();
49 ~SignalBank();
50 bool Initialize(int channel_count, int signal_length, float sample_rate);
51
52 /* \brief Initialize the signal bank with the same parameters, buffer size
53 * and centre frequencies as the input signal bank
54 */
55 bool Initialize(const SignalBank &input);
56 bool Validate() const;
57 inline const vector<float> &operator[](int channel) const;
58 inline float sample(int channel, int index) const;
59 inline void set_sample(int channel, int index, float value);
60 const deque<int> &strobes(int channel) const;
61 float sample_rate() const;
62 int buffer_length() const;
63 int start_time() const;
64 void set_start_time(int start_time);
65 float get_centre_frequency(int i) const;
66 void set_centre_frequency(int i, float cf);
67 bool initialized() const;
68 int channel_count() const;
69 private:
70 int channel_count_;
71 int buffer_length_;
72 vector<vector<float> > signals_;
73 vector<deque<int> > strobes_;
74 vector<float> centre_frequencies_;
75 float sample_rate_;
76 int start_time_;
77 bool initialized_;
78 DISALLOW_COPY_AND_ASSIGN(SignalBank);
79 };
80 }
81
82 #endif // _AIMC_SUPPORT_SIGNALBANK_H_