tomwalters@268: // Copyright 2010, Thomas Walters
tomwalters@268: //
tomwalters@268: // AIM-C: A C++ implementation of the Auditory Image Model
tomwalters@268: // http://www.acousticscale.org/AIMC
tomwalters@268: //
tomwalters@268: // This program is free software: you can redistribute it and/or modify
tomwalters@268: // it under the terms of the GNU General Public License as published by
tomwalters@268: // the Free Software Foundation, either version 3 of the License, or
tomwalters@268: // (at your option) any later version.
tomwalters@268: //
tomwalters@268: // This program is distributed in the hope that it will be useful,
tomwalters@268: // but WITHOUT ANY WARRANTY; without even the implied warranty of
tomwalters@268: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
tomwalters@268: // GNU General Public License for more details.
tomwalters@268: //
tomwalters@268: // You should have received a copy of the GNU General Public License
tomwalters@268: // along with this program. If not, see .
tomwalters@268:
tomwalters@268: /*! \file
tomwalters@268: * \brief Basic data structure for a bank of signals with a common sample
tomwalters@268: * rate (in Hz), a centre frequency (in Hz) for each channel, a start time
tomwalters@268: * for the signal (in samples) and optionally, a set of strobe points in each
tomwalters@268: * channel (a vector of the indices of certain points). This is a struct
tomwalters@268: * rather than a class, and data members are accessed directly. Therefore is
tomwalters@268: * is up to the users of this structure to use it properly. Never assume that
tomwalters@268: * a SignalBank will be set up correctly when you receive it. A basic
tomwalters@268: * constructor and initialisation routines are provided.
tomwalters@268: */
tomwalters@268:
tomwalters@268: /*! \author: Thomas Walters
tomwalters@268: * \date 2010/01/23
tomwalters@268: * \version \$Id: SignalBank.h 4 2010-02-03 18:44:58Z tcw $
tomwalters@268: */
tomwalters@268:
tomwalters@268: #ifndef _AIMC_SUPPORT_SIGNALBANK_H_
tomwalters@268: #define _AIMC_SUPPORT_SIGNALBANK_H_
tomwalters@268:
tomwalters@268: #include
tomwalters@268: #include
tomwalters@268:
tomwalters@268: #include "Support/Common.h"
tomwalters@268:
tomwalters@268: namespace aimc {
tomwalters@268: using std::deque;
tomwalters@268: using std::vector;
tomwalters@268: class SignalBank {
tomwalters@268: public:
tomwalters@268: SignalBank();
tomwalters@268: ~SignalBank();
tomwalters@268: bool Initialize(int channel_count, int signal_length, float sample_rate);
tomwalters@268:
tomwalters@268: /* \brief Initialize the signal bank with the same parameters, buffer size
tomwalters@268: * and centre frequencies as the input signal bank
tomwalters@268: */
tomwalters@268: bool Initialize(const SignalBank &input);
tomwalters@268: bool Validate() const;
tomwalters@268: inline const vector &operator[](int channel) const;
tomwalters@268: inline float sample(int channel, int index) const;
tomwalters@268: inline void set_sample(int channel, int index, float value);
tomwalters@268: const deque &strobes(int channel) const;
tomwalters@268: float sample_rate() const;
tomwalters@268: int buffer_length() const;
tomwalters@268: int start_time() const;
tomwalters@268: void set_start_time(int start_time);
tomwalters@268: float get_centre_frequency(int i) const;
tomwalters@268: void set_centre_frequency(int i, float cf);
tomwalters@268: bool initialized() const;
tomwalters@268: int channel_count() const;
tomwalters@268: private:
tomwalters@268: int channel_count_;
tomwalters@268: int buffer_length_;
tomwalters@268: vector > signals_;
tomwalters@268: vector > strobes_;
tomwalters@268: vector centre_frequencies_;
tomwalters@268: float sample_rate_;
tomwalters@268: int start_time_;
tomwalters@268: bool initialized_;
tomwalters@268: DISALLOW_COPY_AND_ASSIGN(SignalBank);
tomwalters@268: };
tomwalters@268: }
tomwalters@268:
tomwalters@268: #endif // _AIMC_SUPPORT_SIGNALBANK_H_