andrew@0
|
1 /*
|
andrew@0
|
2 * AudioEventMatcher.h
|
andrew@0
|
3 * MultipleAudioMathcher
|
andrew@0
|
4 *
|
andrew@0
|
5 * Created by Andrew on 31/01/2012.
|
andrew@0
|
6 * Copyright 2012 QMUL. All rights reserved.
|
andrew@0
|
7 *
|
andrew@0
|
8 */
|
andrew@0
|
9
|
andrew@0
|
10
|
andrew@0
|
11
|
andrew@0
|
12 #ifndef AUDIO_EVENT_MATCHER_H
|
andrew@0
|
13 #define AUDIO_EVENT_MATCHER_H
|
andrew@0
|
14
|
andrew@32
|
15
|
andrew@0
|
16
|
andrew@0
|
17 #include "ofMain.h"
|
andrew@0
|
18 #include "ChromaOnset.h"
|
andrew@0
|
19 #include "LiveAudioInput.h"
|
andrew@0
|
20 #include "ofxWindowRegion.h"
|
andrew@0
|
21 #include "BayesianArrayStructure.h"
|
andrew@1
|
22 #include "RecordedMultitrackAudio.h"
|
andrew@7
|
23 #include "DynamicVector.h"
|
andrew@16
|
24 #include "AccompanimentSynchroniser.h"
|
andrew@19
|
25 #include "TempoFollower.h"
|
andrew@0
|
26
|
andrew@32
|
27 static const int numberOfChannels = 4;
|
andrew@32
|
28
|
andrew@0
|
29 class AudioEventMatcher{
|
andrew@0
|
30
|
andrew@0
|
31 public:
|
andrew@0
|
32 AudioEventMatcher();
|
andrew@0
|
33
|
andrew@0
|
34 void setArraySizes();
|
andrew@0
|
35
|
andrew@9
|
36 void updatePosition();
|
andrew@8
|
37 void updateBestAlignmentPosition();
|
andrew@8
|
38
|
andrew@0
|
39 void draw();
|
andrew@32
|
40 void drawBayesianDistributions();
|
andrew@32
|
41 void drawPositionWindow();
|
andrew@32
|
42 void drawTrackLikelihoods();
|
andrew@32
|
43 void drawInfo();
|
andrew@32
|
44
|
andrew@7
|
45 void setWindowDimensions();
|
andrew@0
|
46
|
andrew@6
|
47 void newPitchEvent(const int& channel, const double& pitchIn, const double& timeIn);
|
andrew@2
|
48 void newKickEvent(const double& timeIn);
|
andrew@6
|
49 void newKickEvent(const int& channel, const double& timeIn);
|
andrew@2
|
50 void newSnareEvent(const double& timeIn);
|
andrew@7
|
51 void newSnareEvent(const int& channel, const double& timeIn);
|
andrew@2
|
52
|
andrew@32
|
53 void newChromaEvent(const int& channel, float* chromaIn, const double& timeIn);
|
andrew@32
|
54
|
andrew@32
|
55
|
andrew@2
|
56 void matchNewPitchEvent(const int& channel, const double& pitchIn, const double& timeIn);
|
andrew@2
|
57 void matchNewOnsetEvent(const int& channel, const double& timeIn);
|
andrew@32
|
58 void matchNewChromaEvent(const int& channel, float* chroma, const double& timeIn);
|
andrew@35
|
59
|
andrew@35
|
60 double getChromaDotProductDistance(float* chromaOne, float* chromaTwo);
|
andrew@35
|
61 double getChromaEuclideanDistance(float* chromaOne, float* chromaTwo);
|
andrew@35
|
62 bool useChromaDotProduct;
|
andrew@1
|
63
|
andrew@0
|
64 BayesianArrayStructure bayesianStruct;//hold the probability distriubtions
|
andrew@0
|
65
|
andrew@0
|
66 LiveAudioInput liveInput;//hold the new events that come in
|
andrew@1
|
67 RecordedMultitrackAudio recordedTracks;
|
andrew@1
|
68
|
andrew@16
|
69 void loadAudioFiles();
|
andrew@22
|
70 void rescue();//flat prior
|
andrew@1
|
71 void windowResized(const int& w, const int& h);
|
andrew@0
|
72
|
andrew@0
|
73 ofxWindowRegion bayesTempoWindow;
|
andrew@3
|
74 ofxWindowRegion bayesPositionWindow;
|
andrew@3
|
75 ofxWindowRegion bayesLikelihoodWindow;
|
andrew@0
|
76
|
andrew@3
|
77 bool checkMatch(const double& recordedPitch, const double& livePitch);
|
andrew@3
|
78 double getPitchDistance(const double& pitchOne, const double& pitchTwo, const double& scale);
|
andrew@3
|
79
|
andrew@3
|
80 void startPlaying();
|
andrew@15
|
81 void stopPlaying();
|
andrew@15
|
82 bool startedPlaying;
|
andrew@3
|
83
|
andrew@3
|
84 bool usingRealTime;
|
andrew@7
|
85 double recentPitch, recentTime;
|
andrew@7
|
86
|
andrew@32
|
87 DynamicVector likelihoodVisualisation[numberOfChannels];
|
andrew@32
|
88 DynamicVector recentPriors[numberOfChannels];
|
andrew@13
|
89 //DynamicVector recentPrior;
|
andrew@10
|
90 DynamicVector projectedPrior;
|
andrew@8
|
91
|
andrew@8
|
92 double currentAlignmentPosition;
|
andrew@8
|
93 double lastAlignmentTime;
|
andrew@8
|
94
|
andrew@32
|
95 double recentEventTime[numberOfChannels];
|
andrew@10
|
96 int startTime;
|
andrew@11
|
97 int currentAlignmentTime;
|
andrew@9
|
98
|
andrew@9
|
99 double screenStartTimeMillis, screenEndTimeMillis, screenWidthMillis;
|
andrew@9
|
100 bool followingLiveInput;
|
andrew@9
|
101 void setScreenDisplayTimes();
|
andrew@14
|
102
|
andrew@16
|
103 AccompanimentSynchroniser synchroniser;
|
andrew@16
|
104
|
andrew@14
|
105 //params
|
andrew@14
|
106 double onsetLikelihoodWidth;
|
andrew@15
|
107 double onsetLikelihoodToNoise;
|
andrew@15
|
108 double pitchLikelihoodToNoise;//more noise
|
andrew@32
|
109 double chromaLikelihoodToNoise;
|
andrew@18
|
110
|
andrew@18
|
111 double pitchOfNearestMatch;//for viz purposes
|
andrew@18
|
112 double distanceOfNearestMatch;
|
andrew@19
|
113
|
andrew@32
|
114 double chromaLikelihoodWidth;
|
andrew@19
|
115
|
andrew@19
|
116 TempoFollower temporal;
|
andrew@20
|
117 TempoFollower recordedTempoData;
|
andrew@20
|
118 void calculateRecordedTempoData();
|
andrew@20
|
119 void setTempoPrior(double tempo);
|
andrew@20
|
120
|
andrew@20
|
121 void setNextOnsetTime(const int&channel, int& time, int* indexForOnsets);
|
andrew@20
|
122 int recordedTempoIndex;
|
andrew@20
|
123 double recordedTempo;
|
andrew@20
|
124 void updateRecordedTempo();
|
andrew@20
|
125 void drawRecordedTempo();
|
andrew@20
|
126 double currentSpeedRatio;
|
andrew@20
|
127 void drawPlayingTempo();
|
andrew@20
|
128 void setSpeedRatioDistribution(const double& speedRatio);
|
andrew@0
|
129 };
|
andrew@0
|
130 #endif
|