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@50
|
26 #include "MatchMarkers.h"
|
andrew@0
|
27
|
andrew@32
|
28 static const int numberOfChannels = 4;
|
andrew@32
|
29
|
andrew@0
|
30 class AudioEventMatcher{
|
andrew@0
|
31
|
andrew@0
|
32 public:
|
andrew@0
|
33 AudioEventMatcher();
|
andrew@0
|
34
|
andrew@0
|
35 void setArraySizes();
|
andrew@0
|
36
|
andrew@9
|
37 void updatePosition();
|
andrew@8
|
38 void updateBestAlignmentPosition();
|
andrew@8
|
39
|
andrew@50
|
40
|
andrew@0
|
41 void draw();
|
andrew@32
|
42 void drawBayesianDistributions();
|
andrew@32
|
43 void drawPositionWindow();
|
andrew@32
|
44 void drawTrackLikelihoods();
|
andrew@32
|
45 void drawInfo();
|
andrew@45
|
46 void drawAlignmentTimes();
|
andrew@50
|
47 void drawMarkers();
|
andrew@32
|
48
|
andrew@7
|
49 void setWindowDimensions();
|
andrew@37
|
50 int getScreenWidthIndexOfEventTime(const double& time);
|
andrew@45
|
51 int getTimeNow();
|
andrew@0
|
52
|
andrew@50
|
53 void addMarkerNow();
|
andrew@50
|
54 void deleteMarkers();
|
andrew@50
|
55 void deleteNearestMarker();
|
andrew@50
|
56 void moveToNextMarker();
|
andrew@50
|
57 void moveToPreviousMarker();
|
andrew@50
|
58 void goToMarker(const int& markerID);
|
andrew@50
|
59 void setToPosition(const double& position);//for Bayesian distbn
|
andrew@50
|
60 void setPlaybackPosition(const double& millis);
|
andrew@50
|
61 void mousePressed(const int& x);
|
andrew@50
|
62
|
andrew@6
|
63 void newPitchEvent(const int& channel, const double& pitchIn, const double& timeIn);
|
andrew@2
|
64 void newKickEvent(const double& timeIn);
|
andrew@6
|
65 void newKickEvent(const int& channel, const double& timeIn);
|
andrew@2
|
66 void newSnareEvent(const double& timeIn);
|
andrew@7
|
67 void newSnareEvent(const int& channel, const double& timeIn);
|
andrew@2
|
68
|
andrew@32
|
69 void newChromaEvent(const int& channel, float* chromaIn, const double& timeIn);
|
andrew@32
|
70
|
andrew@32
|
71
|
andrew@2
|
72 void matchNewPitchEvent(const int& channel, const double& pitchIn, const double& timeIn);
|
andrew@2
|
73 void matchNewOnsetEvent(const int& channel, const double& timeIn);
|
andrew@32
|
74 void matchNewChromaEvent(const int& channel, float* chroma, const double& timeIn);
|
andrew@35
|
75
|
andrew@35
|
76 double getChromaDotProductDistance(float* chromaOne, float* chromaTwo);
|
andrew@35
|
77 double getChromaEuclideanDistance(float* chromaOne, float* chromaTwo);
|
andrew@35
|
78 bool useChromaDotProduct;
|
andrew@1
|
79
|
andrew@0
|
80 BayesianArrayStructure bayesianStruct;//hold the probability distriubtions
|
andrew@0
|
81
|
andrew@0
|
82 LiveAudioInput liveInput;//hold the new events that come in
|
andrew@1
|
83 RecordedMultitrackAudio recordedTracks;
|
andrew@1
|
84
|
andrew@16
|
85 void loadAudioFiles();
|
andrew@22
|
86 void rescue();//flat prior
|
andrew@1
|
87 void windowResized(const int& w, const int& h);
|
andrew@0
|
88
|
andrew@0
|
89 ofxWindowRegion bayesTempoWindow;
|
andrew@3
|
90 ofxWindowRegion bayesPositionWindow;
|
andrew@3
|
91 ofxWindowRegion bayesLikelihoodWindow;
|
andrew@0
|
92
|
andrew@3
|
93 bool checkMatch(const double& recordedPitch, const double& livePitch);
|
andrew@3
|
94 double getPitchDistance(const double& pitchOne, const double& pitchTwo, const double& scale);
|
andrew@3
|
95
|
andrew@3
|
96 void startPlaying();
|
andrew@15
|
97 void stopPlaying();
|
andrew@15
|
98 bool startedPlaying;
|
andrew@3
|
99
|
andrew@3
|
100 bool usingRealTime;
|
andrew@37
|
101 double recentPitch, recentPitchEventTime;
|
andrew@7
|
102
|
andrew@32
|
103 DynamicVector likelihoodVisualisation[numberOfChannels];
|
andrew@32
|
104 DynamicVector recentPriors[numberOfChannels];
|
andrew@13
|
105 //DynamicVector recentPrior;
|
andrew@10
|
106 DynamicVector projectedPrior;
|
andrew@8
|
107
|
andrew@8
|
108 double currentAlignmentPosition;
|
andrew@8
|
109 double lastAlignmentTime;
|
andrew@8
|
110
|
andrew@32
|
111 double recentEventTime[numberOfChannels];
|
andrew@10
|
112 int startTime;
|
andrew@11
|
113 int currentAlignmentTime;
|
andrew@9
|
114
|
andrew@9
|
115 double screenStartTimeMillis, screenEndTimeMillis, screenWidthMillis;
|
andrew@9
|
116 bool followingLiveInput;
|
andrew@9
|
117 void setScreenDisplayTimes();
|
andrew@14
|
118
|
andrew@16
|
119 AccompanimentSynchroniser synchroniser;
|
andrew@16
|
120
|
andrew@14
|
121 //params
|
andrew@14
|
122 double onsetLikelihoodWidth;
|
andrew@15
|
123 double onsetLikelihoodToNoise;
|
andrew@15
|
124 double pitchLikelihoodToNoise;//more noise
|
andrew@32
|
125 double chromaLikelihoodToNoise;
|
andrew@18
|
126
|
andrew@18
|
127 double pitchOfNearestMatch;//for viz purposes
|
andrew@18
|
128 double distanceOfNearestMatch;
|
andrew@19
|
129
|
andrew@32
|
130 double chromaLikelihoodWidth;
|
andrew@19
|
131
|
andrew@19
|
132 TempoFollower temporal;
|
andrew@20
|
133 TempoFollower recordedTempoData;
|
andrew@20
|
134 void calculateRecordedTempoData();
|
andrew@20
|
135 void setTempoPrior(double tempo);
|
andrew@20
|
136
|
andrew@20
|
137 void setNextOnsetTime(const int&channel, int& time, int* indexForOnsets);
|
andrew@20
|
138 int recordedTempoIndex;
|
andrew@20
|
139 double recordedTempo;
|
andrew@20
|
140 void updateRecordedTempo();
|
andrew@20
|
141 void drawRecordedTempo();
|
andrew@20
|
142 double currentSpeedRatio;
|
andrew@20
|
143 void drawPlayingTempo();
|
andrew@20
|
144 void setSpeedRatioDistribution(const double& speedRatio);
|
andrew@37
|
145
|
andrew@37
|
146 double euclideanMaximumDistance;
|
andrew@37
|
147 bool printingData;
|
andrew@50
|
148
|
andrew@50
|
149 bool drawLikelihoods;
|
andrew@50
|
150 bool drawPosterior;
|
andrew@50
|
151
|
andrew@50
|
152 MatchMarkers markedPoints;
|
andrew@50
|
153 double markerPlaybackPosition;
|
andrew@50
|
154
|
andrew@0
|
155 };
|
andrew@0
|
156 #endif
|