andrew@0
|
1 /*
|
andrew@0
|
2 * ChromaOnset.h
|
andrew@0
|
3 * fileLoaderAndOnsetDetection
|
andrew@0
|
4 *
|
andrew@0
|
5 * Created by Andrew on 17/01/2012.
|
andrew@0
|
6 * Copyright 2012 QMUL. All rights reserved.
|
andrew@0
|
7 *
|
andrew@0
|
8 */
|
andrew@0
|
9
|
andrew@0
|
10 #ifndef CHROMA_ONSET_H
|
andrew@0
|
11 #define CHROMA_ONSET_H
|
andrew@0
|
12
|
andrew@0
|
13 #include "ofMain.h"
|
andrew@0
|
14 #include "chromaGram.h"
|
andrew@0
|
15 //#include "AubioPitch.h"
|
andrew@0
|
16 #include "FrameHolder.h"
|
andrew@0
|
17
|
andrew@0
|
18 /*
|
andrew@0
|
19 //could switch to a struct to hold this?
|
andrew@0
|
20
|
andrew@0
|
21 struct OnsetEvent{
|
andrew@0
|
22 double millisTime;
|
andrew@0
|
23 int frameTime;
|
andrew@0
|
24
|
andrew@0
|
25 bool chromaCalculated;
|
andrew@0
|
26 float chromaValues[12];
|
andrew@0
|
27
|
andrew@0
|
28 bool aubioPitchFound;
|
andrew@0
|
29 float aubioPitch;
|
andrew@0
|
30 };
|
andrew@0
|
31 */
|
andrew@0
|
32
|
andrew@0
|
33 class ChromaOnset {
|
andrew@0
|
34 public:
|
andrew@0
|
35 ChromaOnset();
|
andrew@0
|
36
|
andrew@0
|
37 double millisTime;
|
andrew@0
|
38 int frameTime;
|
andrew@0
|
39 //chromagram chroma;
|
andrew@0
|
40 bool chromaCalculated;
|
andrew@0
|
41 int chromaSize;
|
andrew@0
|
42 int pitchFrameCounter;
|
andrew@0
|
43
|
andrew@0
|
44 //move chromagram out of this class
|
andrew@0
|
45 //Chromagram cgram;
|
andrew@0
|
46
|
andrew@0
|
47 typedef std::vector<float> FloatVector;
|
andrew@0
|
48 FloatVector chromaValues;
|
andrew@0
|
49 FloatVector quantisedChromaValues;
|
andrew@0
|
50
|
andrew@0
|
51 double getQuantisedDistance(ChromaOnset& secondChromaOnset);
|
andrew@0
|
52 double getChromaQuantisedDistance(float* quantisedChromagramTwo);
|
andrew@0
|
53 //also do pitch detection using this class
|
andrew@0
|
54 //AubioPitch *aubioPitchDetector;
|
andrew@0
|
55 bool aubioPitchFound;
|
andrew@0
|
56 float aubioPitch;
|
andrew@0
|
57
|
andrew@0
|
58 bool matched;//just for drawing
|
andrew@0
|
59
|
andrew@0
|
60
|
andrew@0
|
61 bool processFrame(float* frame, const int& length);
|
andrew@0
|
62 // void calculateChroma(float* frame, const int& length);
|
andrew@0
|
63
|
andrew@0
|
64 double timeDistanceMillis(const ChromaOnset& secondChromaOnset);
|
andrew@0
|
65 double pitchDistance(const ChromaOnset& secondChromaOnset);
|
andrew@0
|
66 double chromaDotProductDistance(const ChromaOnset& secondChromaOnset);
|
andrew@0
|
67
|
andrew@0
|
68
|
andrew@0
|
69 Chromagram* cgramPtr;
|
andrew@0
|
70 void deleteChromagram();
|
andrew@0
|
71
|
andrew@0
|
72 FrameHolder onsetFrame;
|
andrew@0
|
73
|
andrew@0
|
74 int onsetIndex;//in terms of our onset detection fn - ofxAubioOnsetDetector
|
andrew@0
|
75 void printInfo();
|
andrew@0
|
76 };
|
andrew@0
|
77 #endif
|