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@19
|
15 #define NUMBER_OF_CHANNELS 3
|
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@0
|
27 class AudioEventMatcher{
|
andrew@0
|
28
|
andrew@0
|
29 public:
|
andrew@0
|
30 AudioEventMatcher();
|
andrew@0
|
31
|
andrew@0
|
32 void setArraySizes();
|
andrew@0
|
33
|
andrew@9
|
34 void updatePosition();
|
andrew@8
|
35 void updateBestAlignmentPosition();
|
andrew@8
|
36
|
andrew@0
|
37 void draw();
|
andrew@6
|
38 void drawBayesianDistributions();;
|
andrew@7
|
39 void setWindowDimensions();
|
andrew@0
|
40
|
andrew@6
|
41 void newPitchEvent(const int& channel, const double& pitchIn, const double& timeIn);
|
andrew@2
|
42 void newKickEvent(const double& timeIn);
|
andrew@6
|
43 void newKickEvent(const int& channel, const double& timeIn);
|
andrew@2
|
44 void newSnareEvent(const double& timeIn);
|
andrew@7
|
45 void newSnareEvent(const int& channel, const double& timeIn);
|
andrew@2
|
46
|
andrew@2
|
47 void matchNewPitchEvent(const int& channel, const double& pitchIn, const double& timeIn);
|
andrew@2
|
48 void matchNewOnsetEvent(const int& channel, const double& timeIn);
|
andrew@1
|
49
|
andrew@0
|
50 BayesianArrayStructure bayesianStruct;//hold the probability distriubtions
|
andrew@0
|
51
|
andrew@0
|
52 LiveAudioInput liveInput;//hold the new events that come in
|
andrew@1
|
53 RecordedMultitrackAudio recordedTracks;
|
andrew@1
|
54
|
andrew@16
|
55 void loadAudioFiles();
|
andrew@22
|
56 void rescue();//flat prior
|
andrew@1
|
57 void windowResized(const int& w, const int& h);
|
andrew@0
|
58
|
andrew@0
|
59 ofxWindowRegion bayesTempoWindow;
|
andrew@3
|
60 ofxWindowRegion bayesPositionWindow;
|
andrew@3
|
61 ofxWindowRegion bayesLikelihoodWindow;
|
andrew@0
|
62
|
andrew@3
|
63 bool checkMatch(const double& recordedPitch, const double& livePitch);
|
andrew@3
|
64 double getPitchDistance(const double& pitchOne, const double& pitchTwo, const double& scale);
|
andrew@3
|
65
|
andrew@3
|
66 void startPlaying();
|
andrew@15
|
67 void stopPlaying();
|
andrew@15
|
68 bool startedPlaying;
|
andrew@3
|
69
|
andrew@3
|
70 bool usingRealTime;
|
andrew@7
|
71 double recentPitch, recentTime;
|
andrew@7
|
72
|
andrew@19
|
73 DynamicVector likelihoodVisualisation[NUMBER_OF_CHANNELS];
|
andrew@19
|
74 DynamicVector recentPriors[NUMBER_OF_CHANNELS];
|
andrew@13
|
75 //DynamicVector recentPrior;
|
andrew@10
|
76 DynamicVector projectedPrior;
|
andrew@8
|
77
|
andrew@8
|
78 double currentAlignmentPosition;
|
andrew@8
|
79 double lastAlignmentTime;
|
andrew@8
|
80
|
andrew@19
|
81 double recentEventTime[NUMBER_OF_CHANNELS];
|
andrew@10
|
82 int startTime;
|
andrew@11
|
83 int currentAlignmentTime;
|
andrew@9
|
84
|
andrew@9
|
85 double screenStartTimeMillis, screenEndTimeMillis, screenWidthMillis;
|
andrew@9
|
86 bool followingLiveInput;
|
andrew@9
|
87 void setScreenDisplayTimes();
|
andrew@14
|
88
|
andrew@16
|
89 AccompanimentSynchroniser synchroniser;
|
andrew@16
|
90
|
andrew@14
|
91 //params
|
andrew@14
|
92 double onsetLikelihoodWidth;
|
andrew@15
|
93 double onsetLikelihoodToNoise;
|
andrew@15
|
94 double pitchLikelihoodToNoise;//more noise
|
andrew@18
|
95
|
andrew@18
|
96 double pitchOfNearestMatch;//for viz purposes
|
andrew@18
|
97 double distanceOfNearestMatch;
|
andrew@19
|
98
|
andrew@19
|
99
|
andrew@19
|
100
|
andrew@19
|
101 TempoFollower temporal;
|
andrew@20
|
102 TempoFollower recordedTempoData;
|
andrew@20
|
103 void calculateRecordedTempoData();
|
andrew@20
|
104 void setTempoPrior(double tempo);
|
andrew@20
|
105
|
andrew@20
|
106 void setNextOnsetTime(const int&channel, int& time, int* indexForOnsets);
|
andrew@20
|
107 int recordedTempoIndex;
|
andrew@20
|
108 double recordedTempo;
|
andrew@20
|
109 void updateRecordedTempo();
|
andrew@20
|
110 void drawRecordedTempo();
|
andrew@20
|
111 double currentSpeedRatio;
|
andrew@20
|
112 void drawPlayingTempo();
|
andrew@20
|
113 void setSpeedRatioDistribution(const double& speedRatio);
|
andrew@0
|
114 };
|
andrew@0
|
115 #endif
|