annotate src/Support/SignalBank.h @ 16:2a5354042241

-Updated the Slaney IIR gammatone to use a cascase of four second-order filters as per the implementtion in Slaney's auditory toolbox. This is more numerically stable at high sample rates and low centre frequencies.
author tomwalters
date Sat, 20 Feb 2010 17:56:40 +0000
parents bd370910aa05
children 491b1b1d1dc5
rev   line source
tomwalters@0 1 // Copyright 2010, Thomas Walters
tomwalters@0 2 //
tomwalters@0 3 // AIM-C: A C++ implementation of the Auditory Image Model
tomwalters@0 4 // http://www.acousticscale.org/AIMC
tomwalters@0 5 //
tomwalters@0 6 // This program is free software: you can redistribute it and/or modify
tomwalters@0 7 // it under the terms of the GNU General Public License as published by
tomwalters@0 8 // the Free Software Foundation, either version 3 of the License, or
tomwalters@0 9 // (at your option) any later version.
tomwalters@0 10 //
tomwalters@0 11 // This program is distributed in the hope that it will be useful,
tomwalters@0 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
tomwalters@0 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
tomwalters@0 14 // GNU General Public License for more details.
tomwalters@0 15 //
tomwalters@0 16 // You should have received a copy of the GNU General Public License
tomwalters@0 17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
tomwalters@0 18
tomwalters@0 19 /*! \file
tomwalters@0 20 * \brief Basic data structure for a bank of signals with a common sample
tomwalters@0 21 * rate (in Hz), a centre frequency (in Hz) for each channel, a start time
tomwalters@0 22 * for the signal (in samples) and optionally, a set of strobe points in each
tomwalters@0 23 * channel (a vector of the indices of certain points). This is a struct
tomwalters@0 24 * rather than a class, and data members are accessed directly. Therefore is
tomwalters@0 25 * is up to the users of this structure to use it properly. Never assume that
tomwalters@0 26 * a SignalBank will be set up correctly when you receive it. A basic
tomwalters@0 27 * constructor and initialisation routines are provided.
tomwalters@0 28 */
tomwalters@0 29
tomwalters@0 30 /*! \author: Thomas Walters <tom@acousticscale.org>
tomwalters@0 31 * \date 2010/01/23
tomwalters@0 32 * \version \$Id: SignalBank.h 4 2010-02-03 18:44:58Z tcw $
tomwalters@0 33 */
tomwalters@0 34
tomwalters@11 35 #ifndef AIMC_SUPPORT_SIGNALBANK_H_
tomwalters@11 36 #define AIMC_SUPPORT_SIGNALBANK_H_
tomwalters@0 37
tomwalters@0 38 #include <deque>
tomwalters@0 39 #include <vector>
tomwalters@0 40
tomwalters@0 41 #include "Support/Common.h"
tomwalters@0 42
tomwalters@0 43 namespace aimc {
tomwalters@0 44 using std::deque;
tomwalters@0 45 using std::vector;
tomwalters@0 46 class SignalBank {
tomwalters@0 47 public:
tomwalters@0 48 SignalBank();
tomwalters@0 49 ~SignalBank();
tomwalters@0 50 bool Initialize(int channel_count, int signal_length, float sample_rate);
tomwalters@0 51
tomwalters@0 52 /* \brief Initialize the signal bank with the same parameters, buffer size
tomwalters@0 53 * and centre frequencies as the input signal bank
tomwalters@0 54 */
tomwalters@0 55 bool Initialize(const SignalBank &input);
tomwalters@0 56 bool Validate() const;
tomwalters@1 57
tomwalters@1 58 inline const vector<float> &operator[](int channel) const {
tomwalters@1 59 return signals_[channel];
tomwalters@1 60 };
tomwalters@1 61
tomwalters@1 62 float sample(int channel, int index) const;
tomwalters@1 63 void set_sample(int channel, int index, float value);
tomwalters@5 64 int strobe(int channel, int index) const;
tomwalters@5 65 int strobe_count(int channel) const;
tomwalters@5 66 void AddStrobe(int channel, int time);
tomwalters@5 67 void ResetStrobes(int channel);
tomwalters@0 68 float sample_rate() const;
tomwalters@0 69 int buffer_length() const;
tomwalters@0 70 int start_time() const;
tomwalters@0 71 void set_start_time(int start_time);
tomwalters@5 72 float centre_frequency(int i) const;
tomwalters@0 73 void set_centre_frequency(int i, float cf);
tomwalters@0 74 bool initialized() const;
tomwalters@0 75 int channel_count() const;
tomwalters@0 76 private:
tomwalters@0 77 int channel_count_;
tomwalters@0 78 int buffer_length_;
tomwalters@0 79 vector<vector<float> > signals_;
tomwalters@5 80 vector<vector<int> > strobes_;
tomwalters@0 81 vector<float> centre_frequencies_;
tomwalters@0 82 float sample_rate_;
tomwalters@0 83 int start_time_;
tomwalters@0 84 bool initialized_;
tomwalters@0 85 DISALLOW_COPY_AND_ASSIGN(SignalBank);
tomwalters@0 86 };
tomwalters@0 87 }
tomwalters@0 88
tomwalters@11 89 #endif // AIMC_SUPPORT_SIGNALBANK_H_