annotate hackday/midiEventHolder.h @ 26:179365726f07

live input, calculates score rating
author Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk>
date Sun, 04 Dec 2011 00:02:26 +0000
parents 2a025ea7c793
children 69083ce48b83
rev   line source
andrew@24 1 /*
andrew@24 2 * midiEventHolder.h
andrew@24 3 * midiCannamReader3
andrew@24 4 *
andrew@24 5 * Created by Andrew on 19/07/2011.
andrew@24 6 * Copyright 2011 QMUL. All rights reserved.
andrew@24 7 *
andrew@24 8 */
andrew@24 9 #ifndef MIDI_EVENT_HOLDER
andrew@24 10 #define MIDI_EVENT_HOLDER
andrew@24 11
andrew@24 12 #include "ofMain.h"
andrew@24 13 #include "BayesianArrayStructure.h"
andrew@24 14
andrew@24 15 class midiEventHolder{
andrew@24 16
andrew@24 17 public:
andrew@24 18
andrew@24 19 midiEventHolder();
andrew@24 20 void printNotes();
andrew@24 21
andrew@24 22 typedef std::vector<int> IntVector;
andrew@24 23 typedef std::vector<IntVector> IntMatrix;
andrew@24 24
andrew@24 25 typedef std::vector<bool> BoolVector;
andrew@24 26
andrew@24 27 typedef std::vector<double> DoubleVector;
andrew@24 28 typedef std::vector<DoubleVector> DoubleMatrix;
andrew@24 29
andrew@24 30 //the rehearsal version
andrew@24 31 IntMatrix recordedNoteOnMatrix;//note, velocity, duration
andrew@24 32 DoubleVector recordedEventTimes;
andrew@24 33
andrew@24 34 IntVector matchesFound;
andrew@24 35 BoolVector noteOnMatches;
andrew@24 36
andrew@24 37 void drawMidiFile(IntMatrix& midiFileToDraw);
andrew@24 38
andrew@24 39 // int recordedNoteOnIndex;
andrew@24 40
andrew@24 41
andrew@24 42 IntMatrix playedNoteOnMatrix;
andrew@24 43 DoubleVector playedEventTimes;
andrew@24 44 int playedNoteIndex;
andrew@24 45 IntMatrix matchMatrix;
andrew@24 46 IntVector bestMatchFound;
andrew@25 47 IntVector measureVector;
andrew@24 48
andrew@26 49 IntVector recordedTotalNoteCounterByPitch;
andrew@26 50 int totalNoteCounterIndex;
andrew@26 51
andrew@24 52 DoubleMatrix matchConfidence;
andrew@24 53 double totalConfidence;
andrew@24 54
andrew@24 55 double mouseX;
andrew@24 56
andrew@24 57 void clearAllEvents();
andrew@24 58 bool drawTempoMode, drawPhaseMode;
andrew@24 59
andrew@24 60 double minimumMatchSpeed , maximumMatchSpeed;
andrew@24 61
andrew@24 62 double period, pulsesPerQuarternote;
andrew@24 63 double getEventTimeMillis(double ticks);
andrew@24 64 double getEventTimeTicks(double millis);
andrew@24 65
andrew@24 66 int getLocationFromTicks(double tickPosition);
andrew@24 67 int getLocationFromMillis(double millisPosition);
andrew@24 68
andrew@24 69 double getTimeNow(double eventTime);
andrew@24 70 bool runningInRealTime;
andrew@24 71
andrew@24 72 double windowStartTime;
andrew@24 73
andrew@24 74 //functions for finding match to incoming note
andrew@24 75 void newNoteOnEvent(int pitch, int velocity, double timePlayed);
andrew@24 76 int findLocalMatches(int notePitch);
andrew@24 77 bool checkIfMatchedNote(const int& tmpIndex);
andrew@24 78 int findMatch(const int& notePitch, const int& startTime, const int& endTime);
andrew@24 79
andrew@24 80
andrew@24 81 void findLocalTempoPairs();
andrew@24 82 void findLocalTempoPairsWeightedForConfidence();
andrew@24 83
andrew@24 84 double likelihoodWidth;
andrew@24 85 double likelihoodToNoiseRatio;
andrew@24 86
andrew@24 87 void printMatchMatrix();
andrew@24 88 void printRecordedEvents();
andrew@26 89 void printNoteCounter();
andrew@26 90 void updateNoteCounter();
andrew@24 91
andrew@24 92 void setMatchLikelihoods(int numberOfMatches);
andrew@24 93
andrew@24 94 void setStartPlayingTimes();
andrew@24 95 void setSpeedPrior(double speedPriorValue);
andrew@24 96
andrew@24 97 int width, height;
andrew@24 98 /////
andrew@24 99 string matchString;
andrew@24 100 void updatePlayPosition();
andrew@24 101
andrew@24 102 DoubleMatrix beatPeriodMatrix;
andrew@24 103
andrew@24 104 void drawFile();
andrew@24 105 void drawMidiFile();
andrew@24 106 void reset();
andrew@24 107 void setMatchedNotesBackToFalse();
andrew@24 108
andrew@24 109 int ticksPerScreen;
andrew@24 110 int tickLocation;
andrew@24 111 int numberOfScreensIn;
andrew@24 112 int noteArrayIndex;
andrew@24 113
andrew@24 114 int matchWindowWidth;
andrew@24 115
andrew@24 116 int noteMinimum, noteMaximum;
andrew@24 117 int* screenWidth;
andrew@24 118 int* screenHeight;
andrew@24 119 float noteHeight;
andrew@24 120 float tempo;
andrew@24 121 double lastPeriodUpdateTime;
andrew@25 122 int lastPlayedPitch;
andrew@24 123
andrew@24 124 double playPositionInMillis;
andrew@24 125
andrew@24 126 double timeOffsetForScreen;
andrew@24 127
andrew@24 128 double recentNoteOnTime;
andrew@24 129
andrew@24 130 void exampleCrossUpdate();
andrew@24 131 BayesianArrayStructure bayesStruct;
andrew@24 132
andrew@24 133 double speedPriorValue;
andrew@24 134 int bestMatchIndex;
andrew@24 135 string timeString;
andrew@24 136 double startTime;
andrew@24 137 int speedWindowWidthMillis;
andrew@24 138
andrew@24 139 bool confidenceWeightingUsed;
andrew@24 140
andrew@24 141 double minimumMatchError;//recent best error between observed note and aligned midi file
andrew@24 142
andrew@24 143 void reorderMatrixFromNoteTimes(IntMatrix& noteOnMatrix);
andrew@24 144 int getIndexOfMinimumAboveTime(const double& time, IntMatrix& noteOnMatrix);
andrew@24 145 void correctTiming(IntMatrix& noteOnMatrix);
andrew@24 146 void doublecheckOrder(IntMatrix& noteOnMatrix);
andrew@24 147 int getIndexOfMinimumAboveIndex(const int& index, IntMatrix& noteOnMatrix);
andrew@24 148 bool useTempoPrior;
andrew@24 149 string tempoSpeedString;
andrew@24 150 int minimumTimeIntervalForTempoUpdate;
andrew@24 151
andrew@24 152 double ticksFactor;
andrew@24 153 };
andrew@24 154 #endif