annotate trunk/src/Support/SignalBank.h @ 305:ed91095d9240

-New AIMCopy main for the SSI features (temporary hack till I get a working module load system) -LocalMax strobe criterion. This is faster and better than the parabola version, which still seems buggy. -Noise generator module. Adds noise to a signal. Uses boost for the random number generator. -New options for the SSI -Slice now respects all its flags (oops!). -MATLAB functions for visualisation -Scripts for generating data to view in MATLAB -Script to download and build HTK - useful for running experiments
author tomwalters
date Thu, 25 Feb 2010 22:02:00 +0000
parents fe5ce00a64f5
children 30dde71d0230
rev   line source
tomwalters@268 1 // Copyright 2010, Thomas Walters
tomwalters@268 2 //
tomwalters@268 3 // AIM-C: A C++ implementation of the Auditory Image Model
tomwalters@268 4 // http://www.acousticscale.org/AIMC
tomwalters@268 5 //
tomwalters@268 6 // This program is free software: you can redistribute it and/or modify
tomwalters@268 7 // it under the terms of the GNU General Public License as published by
tomwalters@268 8 // the Free Software Foundation, either version 3 of the License, or
tomwalters@268 9 // (at your option) any later version.
tomwalters@268 10 //
tomwalters@268 11 // This program is distributed in the hope that it will be useful,
tomwalters@268 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
tomwalters@268 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
tomwalters@268 14 // GNU General Public License for more details.
tomwalters@268 15 //
tomwalters@268 16 // You should have received a copy of the GNU General Public License
tomwalters@268 17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
tomwalters@268 18
tomwalters@268 19 /*! \file
tomwalters@268 20 * \brief Basic data structure for a bank of signals with a common sample
tomwalters@268 21 * rate (in Hz), a centre frequency (in Hz) for each channel, a start time
tomwalters@268 22 * for the signal (in samples) and optionally, a set of strobe points in each
tomwalters@268 23 * channel (a vector of the indices of certain points). This is a struct
tomwalters@268 24 * rather than a class, and data members are accessed directly. Therefore is
tomwalters@268 25 * is up to the users of this structure to use it properly. Never assume that
tomwalters@268 26 * a SignalBank will be set up correctly when you receive it. A basic
tomwalters@268 27 * constructor and initialisation routines are provided.
tomwalters@268 28 */
tomwalters@268 29
tomwalters@268 30 /*! \author: Thomas Walters <tom@acousticscale.org>
tomwalters@268 31 * \date 2010/01/23
tomwalters@296 32 * \version \$Id$
tomwalters@268 33 */
tomwalters@268 34
tomwalters@283 35 #ifndef AIMC_SUPPORT_SIGNALBANK_H_
tomwalters@283 36 #define AIMC_SUPPORT_SIGNALBANK_H_
tomwalters@268 37
tomwalters@268 38 #include <deque>
tomwalters@268 39 #include <vector>
tomwalters@268 40
tomwalters@268 41 #include "Support/Common.h"
tomwalters@268 42
tomwalters@268 43 namespace aimc {
tomwalters@268 44 using std::deque;
tomwalters@268 45 using std::vector;
tomwalters@268 46 class SignalBank {
tomwalters@268 47 public:
tomwalters@268 48 SignalBank();
tomwalters@268 49 ~SignalBank();
tomwalters@268 50 bool Initialize(int channel_count, int signal_length, float sample_rate);
tomwalters@268 51
tomwalters@268 52 /* \brief Initialize the signal bank with the same parameters, buffer size
tomwalters@268 53 * and centre frequencies as the input signal bank
tomwalters@268 54 */
tomwalters@268 55 bool Initialize(const SignalBank &input);
tomwalters@268 56 bool Validate() const;
tomwalters@273 57
tomwalters@273 58 inline const vector<float> &operator[](int channel) const {
tomwalters@273 59 return signals_[channel];
tomwalters@273 60 };
tomwalters@273 61
tomwalters@305 62 inline float sample(int channel, int index) const {
tomwalters@305 63 return signals_[channel][index];
tomwalters@305 64 }
tomwalters@305 65
tomwalters@305 66 inline void set_sample(int channel, int index, float value) {
tomwalters@305 67 signals_[channel][index] = value;
tomwalters@305 68 }
tomwalters@305 69
tomwalters@277 70 int strobe(int channel, int index) const;
tomwalters@277 71 int strobe_count(int channel) const;
tomwalters@277 72 void AddStrobe(int channel, int time);
tomwalters@277 73 void ResetStrobes(int channel);
tomwalters@268 74 float sample_rate() const;
tomwalters@268 75 int buffer_length() const;
tomwalters@268 76 int start_time() const;
tomwalters@268 77 void set_start_time(int start_time);
tomwalters@277 78 float centre_frequency(int i) const;
tomwalters@268 79 void set_centre_frequency(int i, float cf);
tomwalters@268 80 bool initialized() const;
tomwalters@268 81 int channel_count() const;
tomwalters@268 82 private:
tomwalters@268 83 int channel_count_;
tomwalters@268 84 int buffer_length_;
tomwalters@268 85 vector<vector<float> > signals_;
tomwalters@277 86 vector<vector<int> > strobes_;
tomwalters@268 87 vector<float> centre_frequencies_;
tomwalters@268 88 float sample_rate_;
tomwalters@268 89 int start_time_;
tomwalters@268 90 bool initialized_;
tomwalters@268 91 DISALLOW_COPY_AND_ASSIGN(SignalBank);
tomwalters@268 92 };
tomwalters@268 93 }
tomwalters@268 94
tomwalters@283 95 #endif // AIMC_SUPPORT_SIGNALBANK_H_