Copiste  0.1
 All Classes Functions Variables Enumerations Friends Pages
hzcrr.h
1 /*
2  * This file is part of Copiste.
3  *
4  * Copiste is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * Copiste is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with Copiste. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 
19 #ifndef INCLUDED_HZCRRH
20 #define INCLUDED_HZCRRH
21 
23 class HZCRRExtr;
24 
25 #include "features/extractor.h"
26 #include "features/zcr.h"
27 #include "core/streamplayer.h" // for DEFAULT_AUDIO_CHUNK_SIZE
28 
29 const float DEFAULT_ZCR_BOUND = 2.0;
30 const int DEFAULT_HZCRR_CHUNKS_NUMBER = (44100 / DEFAULT_AUDIO_CHUNK_SIZE);
31 
40 {
41  public:
43  HZCRRExtr(int chunkSize = 0);
44 
46  ~HZCRRExtr();
47 
50 
52  bool extract(std::deque<uint16_t> data, int size);
53 
55  float value(int index = 0) { return mHZCRR; };
56 
58  int size() { return 1; }
60  float min() { return 0; }
62  float max() { return 1; }
63 
65  void setFloat(string key, float value);
67  void setInt(string key, int value);
69  float getFloat(string key);
71  int getInt(string key);
72 
73  private:
74  ZCRExtr* mZcrExtr;
75  float* mHistory;
76  int mCurrentFrame;
77 
78  float mHZCRR;
79  float mBound;
80  int mChunksNumber;
81 };
82 
83 #endif