A Hopf, Skip and a Jump
onsetdetector.h
1 #ifndef _ONSETDETECTOR_H_
2 #define _ONSETDETECTOR_H_
3 
4 #include <vector>
5 #include <deque>
6 #include <utility>
7 
8 #include <string>
9 #include <iostream>
10 #include <fstream>
11 
12 #include "detectorbank.h"
13 #include "detectorcache.h"
14 
15 
19 
20 public:
25  OnsetDetector(DetectorBank& db, const std::size_t offset,
26  std::string csvfile);
27 
33  void analyse(std::vector<std::size_t> &onsets, result_t threshold);//,
34 // double w0, double w1, double w2);
35 
36 // std::vector<std::size_t> analyse(result_t threshold, std::string outfile);
37 
38 protected:
42  const std::size_t offset;
44  const std::size_t chans;
46  const parameter_t sr;
48  std::unique_ptr<detectorcache::Producer> p;
50  const std::size_t seg_len;
52  const std::size_t num_segs;
54  std::unique_ptr<detectorcache::DetectorCache> cache;
56  std::size_t n;
58  std::size_t end;
60  result_t getSegAvg();
62  std::pair<bool, std::size_t> findExactTime(std::size_t incStart,
63  std::size_t incStop);
65  result_t logResult(std::size_t channel, std::size_t idx);
66  std::ofstream logfile;
67  std::ofstream segfile;
68 };
69 
70 
71 #endif
Onset detector.
Definition: onsetdetector.h:18
void analyse(std::vector< std::size_t > &onsets, result_t threshold)
Analyse the input and return any onsets.
Use multiple detectors to find note onsets at given frequencies (with multithreading).
Definition: detectorbank.h:25
std::size_t end
Total number of samples in cache.
Definition: onsetdetector.h:58
std::unique_ptr< detectorcache::DetectorCache > cache
DetectorCache from which to get abs(z) values.
Definition: onsetdetector.h:54
result_t logResult(std::size_t channel, std::size_t idx)
Get item from DetectorCache and calculate log.
const std::size_t offset
Number of pad samples at beginning of input buffer.
Definition: onsetdetector.h:42
result_t getSegAvg()
Get average of current segment.
std::size_t n
Current sample number.
Definition: onsetdetector.h:56
const std::size_t chans
Number of channels.
Definition: onsetdetector.h:44
const parameter_t sr
Sample rate.
Definition: onsetdetector.h:46
const std::size_t num_segs
Number of segments to be stored.
Definition: onsetdetector.h:52
std::pair< bool, std::size_t > findExactTime(std::size_t incStart, std::size_t incStop)
Verify or reject onsets found by analyse
OnsetDetector(DetectorBank &db, const std::size_t offset, std::string csvfile)
Construct an onset detector, given a DetectorBank.
const std::size_t seg_len
OnsetDetector and DetectorCache segment length.
Definition: onsetdetector.h:50
DetectorBank & db
The DetectorBank which produces the results.
Definition: onsetdetector.h:40
std::unique_ptr< detectorcache::Producer > p
DetectorCache Producer.
Definition: onsetdetector.h:48