andrew@0
|
1 /*
|
andrew@0
|
2 * midiEventHolder.h
|
andrew@0
|
3 * midiCannamReader3
|
andrew@0
|
4 *
|
andrew@0
|
5 * Created by Andrew on 19/07/2011.
|
andrew@0
|
6 * Copyright 2011 QMUL. All rights reserved.
|
andrew@0
|
7 *
|
andrew@0
|
8 */
|
andrew@2
|
9 #ifndef MIDI_EVENT_HOLDER
|
andrew@2
|
10 #define MIDI_EVENT_HOLDER
|
andrew@2
|
11
|
andrew@0
|
12 #include "ofMain.h"
|
andrew@0
|
13 #include "BayesianArrayStructure.h"
|
andrew@0
|
14
|
andrew@0
|
15 class midiEventHolder{
|
andrew@0
|
16
|
andrew@0
|
17 public:
|
andrew@0
|
18
|
andrew@0
|
19 midiEventHolder();
|
andrew@0
|
20 void printNotes();
|
andrew@0
|
21
|
andrew@0
|
22 typedef std::vector<int> IntVector;
|
andrew@0
|
23 typedef std::vector<IntVector> IntMatrix;
|
andrew@0
|
24
|
andrew@0
|
25 typedef std::vector<bool> BoolVector;
|
andrew@0
|
26
|
andrew@0
|
27 typedef std::vector<double> DoubleVector;
|
andrew@0
|
28 typedef std::vector<DoubleVector> DoubleMatrix;
|
andrew@0
|
29
|
andrew@0
|
30 //the rehearsal version
|
andrew@0
|
31 IntMatrix recordedNoteOnMatrix;//note, velocity, duration
|
andrew@2
|
32 DoubleVector recordedEventTimes;
|
andrew@2
|
33
|
andrew@0
|
34 IntVector matchesFound;
|
andrew@0
|
35 BoolVector noteOnMatches;
|
andrew@1
|
36
|
andrew@0
|
37 // int recordedNoteOnIndex;
|
andrew@2
|
38
|
andrew@0
|
39
|
andrew@0
|
40 IntMatrix playedNoteOnMatrix;
|
andrew@0
|
41 DoubleVector playedEventTimes;
|
andrew@0
|
42 int playedNoteIndex;
|
andrew@0
|
43 IntMatrix matchMatrix;
|
andrew@1
|
44 DoubleMatrix matchConfidence;
|
andrew@1
|
45 double totalConfidence;
|
andrew@0
|
46
|
andrew@1
|
47 double mouseX;
|
andrew@1
|
48
|
andrew@1
|
49 void clearAllEvents();
|
andrew@9
|
50 bool drawTempoMode, drawPhaseMode;
|
andrew@0
|
51
|
andrew@0
|
52 double minimumMatchSpeed , maximumMatchSpeed;
|
andrew@0
|
53
|
andrew@0
|
54 double period, pulsesPerQuarternote;
|
andrew@0
|
55 double getEventTimeMillis(double ticks);
|
andrew@0
|
56 double getEventTimeTicks(double millis);
|
andrew@0
|
57
|
andrew@0
|
58 int getLocationFromTicks(double tickPosition);
|
andrew@0
|
59 int getLocationFromMillis(double millisPosition);
|
andrew@0
|
60
|
andrew@14
|
61 double getTimeNow(double eventTime);
|
andrew@14
|
62 bool runningInRealTime;
|
andrew@14
|
63
|
andrew@0
|
64 double windowStartTime;
|
andrew@0
|
65
|
andrew@0
|
66 //functions for finding match to incoming note
|
andrew@0
|
67 void newNoteOnEvent(int pitch, int velocity, double timePlayed);
|
andrew@0
|
68 int findLocalMatches(int notePitch);
|
andrew@0
|
69 bool checkIfMatchedNote(const int& tmpIndex);
|
andrew@0
|
70 int findMatch(const int& notePitch, const int& startTime, const int& endTime);
|
andrew@0
|
71
|
andrew@0
|
72
|
andrew@0
|
73 void findLocalTempoPairs();
|
andrew@6
|
74 void findLocalTempoPairsWeightedForConfidence();
|
andrew@0
|
75
|
andrew@0
|
76 double likelihoodWidth;
|
andrew@0
|
77 double likelihoodToNoiseRatio;
|
andrew@0
|
78
|
andrew@0
|
79 void printMatchMatrix();
|
andrew@0
|
80
|
andrew@0
|
81 void setMatchLikelihoods(int numberOfMatches);
|
andrew@0
|
82
|
andrew@0
|
83 void setStartPlayingTimes();
|
andrew@3
|
84 void setSpeedPrior(double speedPriorValue);
|
andrew@0
|
85
|
andrew@0
|
86 int width, height;
|
andrew@0
|
87 /////
|
andrew@0
|
88 string matchString;
|
andrew@0
|
89 void updatePlayPosition();
|
andrew@0
|
90
|
andrew@0
|
91 DoubleMatrix beatPeriodMatrix;
|
andrew@0
|
92
|
andrew@0
|
93 void drawFile();
|
andrew@9
|
94 void drawMidiFile();
|
andrew@0
|
95 void reset();
|
andrew@5
|
96 void setMatchedNotesBackToFalse();
|
andrew@0
|
97
|
andrew@0
|
98 int ticksPerScreen;
|
andrew@0
|
99 int tickLocation;
|
andrew@0
|
100 int numberOfScreensIn;
|
andrew@0
|
101 int noteArrayIndex;
|
andrew@0
|
102
|
andrew@0
|
103 int matchWindowWidth;
|
andrew@0
|
104
|
andrew@0
|
105 int noteMinimum, noteMaximum;
|
andrew@0
|
106 int* screenWidth;
|
andrew@0
|
107 int* screenHeight;
|
andrew@0
|
108 float noteHeight;
|
andrew@0
|
109 float tempo;
|
andrew@0
|
110 double lastPeriodUpdateTime;
|
andrew@0
|
111
|
andrew@0
|
112 double playPositionInMillis;
|
andrew@0
|
113
|
andrew@0
|
114 double timeOffsetForScreen;
|
andrew@0
|
115
|
andrew@0
|
116 double recentNoteOnTime;
|
andrew@0
|
117
|
andrew@0
|
118 void exampleCrossUpdate();
|
andrew@0
|
119 BayesianArrayStructure bayesStruct;
|
andrew@0
|
120
|
andrew@3
|
121 double speedPriorValue;
|
andrew@5
|
122 int bestMatchIndex;
|
andrew@0
|
123 string timeString;
|
andrew@0
|
124 double startTime;
|
andrew@6
|
125 int speedWindowWidthMillis;
|
andrew@6
|
126
|
andrew@6
|
127 bool confidenceWeightingUsed;
|
andrew@0
|
128
|
andrew@10
|
129 double minimumMatchError;//recent best error between observed note and aligned midi file
|
andrew@14
|
130
|
andrew@2
|
131 };
|
andrew@2
|
132 #endif |