gtkIOStream  1.7.0
GTK+ << C++ IOStream operators for GTK+. Now with ORBing, numerical computation, audio client and more ...
AudioMasker.H
Go to the documentation of this file.
1 /*
2  libaudiomask - hybrid simultaneous audio masking threshold evaluation library
3  Copyright (C) 2000-2018 Dr Matthew Raphael Flax
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #ifndef AUDIOMASKER_H_
20 #define AUDIOMASKER_H_
21 
22 #ifdef _MSC_VER
23 #ifndef rint
24 #define rint round
25 #endif
26 #endif
27 
28 #include <Debug.H>
29 #include <Eigen/Dense>
30 using namespace Eigen;
31 
32 #define AUDIOMASKER_MULTICHANNEL_ERROR AUDIOMASKER_ERROR_OFFSET-1
33 #define AUDIOMASKER_SAMPLECOUNT_ERROR AUDIOMASKER_ERROR_OFFSET-2
34 
35 
37 class AudioMaskerDebug : virtual public Debug {
38 public:
42 #ifndef NDEBUG
43  errors[AUDIOMASKER_MULTICHANNEL_ERROR]=std::string("AudioMasker: Can not handle more then one channel of audio. Please provide audio in a single column");
44  errors[AUDIOMASKER_SAMPLECOUNT_ERROR]=std::string("AudioMasker: Please supply a sufficient number audio samples, try to provide at least 10*AudioMasker.getBankCount(). Please provide audio in a single column");
45 #endif
46  }
47 
49  virtual ~AudioMaskerDebug() {}
50 };
51 
52 #include "AudioMask/AudioMask.H"
53 #include "AudioMask/depukfb.H"
54 #include <fft/RealFFT.H>
55 #include <stdlib.h>
56 
57 #define DEFAULT_FBCOUNT 100
58 #define DEFAULT_SAMPLECOUNT 512
59 #define DEFAULT_SAMPLEFREQ 44100
60 //#define DEFAULT_LOWFERQ 25
61 
62 // Recurse defines the number of times we recurse the output to input >=2
63 //#define RECURSE 7
64 
100 class AudioMasker : public AudioMask {
101  double **output;
102  double **powOutput;
103  double *input;
105  int bankCount;
106 
109 
110  void FBDeMalloc(void);
111 
112  void FBMalloc(void);
113 
114  void process(void);
115 public:
117  // GTFB *gtfb; //!< gammatone filters
118 
124  AudioMasker(int sampFreq, int fBankCount);
125  AudioMasker(void);
126  ~AudioMasker(void);
127 
133  void excite(short int *Input, int sCount);
134 
140  void excite(double *Input, int sCount);
141 
147  template<typename Derived>
148  int excite(const Eigen::DenseBase<Derived> &Input) {
149  if (Input.cols()>Input.rows() || Input.cols()>1)
151  if (Input.rows() < 10*bankCount)
153 
154  if (Input.rows() != sampleCount)// Check for matrix re-size
155  FBDeMalloc();
156 
157  sampleCount=Input.rows();
158 
159  if (!output) // Check for null matrix
160  FBMalloc();
161 
162  for (int i=0;i<sampleCount;i++) //copy the input as double
163  input[i]=Input(i,0);
164 
165  process(); //Do the processing
166  return NO_ERROR;
167  }
168 
173  double findThreshold(double freq);
174 
177  int getBankCount(void){return bankCount;}
178 };
179 #endif //AUDIOMASKER_H_
180 
int getBankCount(void)
Definition: AudioMasker.H:177
RealFFTData * fftData
The FFT data.
Definition: AudioMasker.H:107
RealFFT * fft
The FFT.
Definition: AudioMasker.H:108
#define AUDIOMASKER_MULTICHANNEL_ERROR
Error when the user passes in multichannel audio, currently not handled.
Definition: AudioMasker.H:32
int bankCount
The filter bank count.
Definition: AudioMasker.H:105
double * input
Filter bank input.
Definition: AudioMasker.H:103
virtual ~AudioMaskerDebug()
Destructor.
Definition: AudioMasker.H:49
double ** FBMalloc(int fCount, int sCount)
#define NO_ERROR
There is no error.
Definition: Debug.H:33
int excite(const Eigen::DenseBase< Derived > &Input)
Definition: AudioMasker.H:148
void FBDeMalloc(double **outputGT, int fCount)
int sampleCount
The sample count.
Definition: AudioMasker.H:104
class RealFFTData controls and manipulates fft data
Definition: RealFFTData.H:24
double ** powOutput
Filter bank output power.
Definition: AudioMasker.H:102
double ** output
Filter bank output.
Definition: AudioMasker.H:101
Definition: Debug.H:112
#define AUDIOMASKER_SAMPLECOUNT_ERROR
Error when the user passes in audio with too few samples, currently not handled.
Definition: AudioMasker.H:33
DepUKFB * pfb
roex filters
Definition: AudioMasker.H:116
class RealFFT controls fftw plans and executes fwd/inv transforms
Definition: RealFFT.H:24
gtkIOStream: /tmp/gtkiostream/include/AudioMask/AudioMasker.H Source File
GTK+ IOStream  Beta