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@45
|
44 void drawAlignmentTimes();
|
andrew@32
|
45
|
andrew@7
|
46 void setWindowDimensions();
|
andrew@37
|
47 int getScreenWidthIndexOfEventTime(const double& time);
|
andrew@45
|
48 int getTimeNow();
|
andrew@0
|
49
|
andrew@6
|
50 void newPitchEvent(const int& channel, const double& pitchIn, const double& timeIn);
|
andrew@2
|
51 void newKickEvent(const double& timeIn);
|
andrew@6
|
52 void newKickEvent(const int& channel, const double& timeIn);
|
andrew@2
|
53 void newSnareEvent(const double& timeIn);
|
andrew@7
|
54 void newSnareEvent(const int& channel, const double& timeIn);
|
andrew@2
|
55
|
andrew@32
|
56 void newChromaEvent(const int& channel, float* chromaIn, const double& timeIn);
|
andrew@32
|
57
|
andrew@32
|
58
|
andrew@2
|
59 void matchNewPitchEvent(const int& channel, const double& pitchIn, const double& timeIn);
|
andrew@2
|
60 void matchNewOnsetEvent(const int& channel, const double& timeIn);
|
andrew@32
|
61 void matchNewChromaEvent(const int& channel, float* chroma, const double& timeIn);
|
andrew@35
|
62
|
andrew@35
|
63 double getChromaDotProductDistance(float* chromaOne, float* chromaTwo);
|
andrew@35
|
64 double getChromaEuclideanDistance(float* chromaOne, float* chromaTwo);
|
andrew@35
|
65 bool useChromaDotProduct;
|
andrew@1
|
66
|
andrew@0
|
67 BayesianArrayStructure bayesianStruct;//hold the probability distriubtions
|
andrew@0
|
68
|
andrew@0
|
69 LiveAudioInput liveInput;//hold the new events that come in
|
andrew@1
|
70 RecordedMultitrackAudio recordedTracks;
|
andrew@1
|
71
|
andrew@16
|
72 void loadAudioFiles();
|
andrew@22
|
73 void rescue();//flat prior
|
andrew@1
|
74 void windowResized(const int& w, const int& h);
|
andrew@0
|
75
|
andrew@0
|
76 ofxWindowRegion bayesTempoWindow;
|
andrew@3
|
77 ofxWindowRegion bayesPositionWindow;
|
andrew@3
|
78 ofxWindowRegion bayesLikelihoodWindow;
|
andrew@0
|
79
|
andrew@3
|
80 bool checkMatch(const double& recordedPitch, const double& livePitch);
|
andrew@3
|
81 double getPitchDistance(const double& pitchOne, const double& pitchTwo, const double& scale);
|
andrew@3
|
82
|
andrew@3
|
83 void startPlaying();
|
andrew@15
|
84 void stopPlaying();
|
andrew@15
|
85 bool startedPlaying;
|
andrew@3
|
86
|
andrew@3
|
87 bool usingRealTime;
|
andrew@37
|
88 double recentPitch, recentPitchEventTime;
|
andrew@7
|
89
|
andrew@32
|
90 DynamicVector likelihoodVisualisation[numberOfChannels];
|
andrew@32
|
91 DynamicVector recentPriors[numberOfChannels];
|
andrew@13
|
92 //DynamicVector recentPrior;
|
andrew@10
|
93 DynamicVector projectedPrior;
|
andrew@8
|
94
|
andrew@8
|
95 double currentAlignmentPosition;
|
andrew@8
|
96 double lastAlignmentTime;
|
andrew@8
|
97
|
andrew@32
|
98 double recentEventTime[numberOfChannels];
|
andrew@10
|
99 int startTime;
|
andrew@11
|
100 int currentAlignmentTime;
|
andrew@9
|
101
|
andrew@9
|
102 double screenStartTimeMillis, screenEndTimeMillis, screenWidthMillis;
|
andrew@9
|
103 bool followingLiveInput;
|
andrew@9
|
104 void setScreenDisplayTimes();
|
andrew@14
|
105
|
andrew@16
|
106 AccompanimentSynchroniser synchroniser;
|
andrew@16
|
107
|
andrew@14
|
108 //params
|
andrew@14
|
109 double onsetLikelihoodWidth;
|
andrew@15
|
110 double onsetLikelihoodToNoise;
|
andrew@15
|
111 double pitchLikelihoodToNoise;//more noise
|
andrew@32
|
112 double chromaLikelihoodToNoise;
|
andrew@18
|
113
|
andrew@18
|
114 double pitchOfNearestMatch;//for viz purposes
|
andrew@18
|
115 double distanceOfNearestMatch;
|
andrew@19
|
116
|
andrew@32
|
117 double chromaLikelihoodWidth;
|
andrew@19
|
118
|
andrew@19
|
119 TempoFollower temporal;
|
andrew@20
|
120 TempoFollower recordedTempoData;
|
andrew@20
|
121 void calculateRecordedTempoData();
|
andrew@20
|
122 void setTempoPrior(double tempo);
|
andrew@20
|
123
|
andrew@20
|
124 void setNextOnsetTime(const int&channel, int& time, int* indexForOnsets);
|
andrew@20
|
125 int recordedTempoIndex;
|
andrew@20
|
126 double recordedTempo;
|
andrew@20
|
127 void updateRecordedTempo();
|
andrew@20
|
128 void drawRecordedTempo();
|
andrew@20
|
129 double currentSpeedRatio;
|
andrew@20
|
130 void drawPlayingTempo();
|
andrew@20
|
131 void setSpeedRatioDistribution(const double& speedRatio);
|
andrew@37
|
132
|
andrew@37
|
133 double euclideanMaximumDistance;
|
andrew@37
|
134 bool printingData;
|
andrew@0
|
135 };
|
andrew@0
|
136 #endif
|