annotate hackday/midiEventHolder.h @ 24:5a11b19906c7

hackday code is added.
author Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk>
date Sat, 03 Dec 2011 17:19:43 +0000
parents
children 2a025ea7c793
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@24 47
andrew@24 48 DoubleMatrix matchConfidence;
andrew@24 49 double totalConfidence;
andrew@24 50
andrew@24 51 double mouseX;
andrew@24 52
andrew@24 53 void clearAllEvents();
andrew@24 54 bool drawTempoMode, drawPhaseMode;
andrew@24 55
andrew@24 56 double minimumMatchSpeed , maximumMatchSpeed;
andrew@24 57
andrew@24 58 double period, pulsesPerQuarternote;
andrew@24 59 double getEventTimeMillis(double ticks);
andrew@24 60 double getEventTimeTicks(double millis);
andrew@24 61
andrew@24 62 int getLocationFromTicks(double tickPosition);
andrew@24 63 int getLocationFromMillis(double millisPosition);
andrew@24 64
andrew@24 65 double getTimeNow(double eventTime);
andrew@24 66 bool runningInRealTime;
andrew@24 67
andrew@24 68 double windowStartTime;
andrew@24 69
andrew@24 70 //functions for finding match to incoming note
andrew@24 71 void newNoteOnEvent(int pitch, int velocity, double timePlayed);
andrew@24 72 int findLocalMatches(int notePitch);
andrew@24 73 bool checkIfMatchedNote(const int& tmpIndex);
andrew@24 74 int findMatch(const int& notePitch, const int& startTime, const int& endTime);
andrew@24 75
andrew@24 76
andrew@24 77 void findLocalTempoPairs();
andrew@24 78 void findLocalTempoPairsWeightedForConfidence();
andrew@24 79
andrew@24 80 double likelihoodWidth;
andrew@24 81 double likelihoodToNoiseRatio;
andrew@24 82
andrew@24 83 void printMatchMatrix();
andrew@24 84 void printRecordedEvents();
andrew@24 85
andrew@24 86 void setMatchLikelihoods(int numberOfMatches);
andrew@24 87
andrew@24 88 void setStartPlayingTimes();
andrew@24 89 void setSpeedPrior(double speedPriorValue);
andrew@24 90
andrew@24 91 int width, height;
andrew@24 92 /////
andrew@24 93 string matchString;
andrew@24 94 void updatePlayPosition();
andrew@24 95
andrew@24 96 DoubleMatrix beatPeriodMatrix;
andrew@24 97
andrew@24 98 void drawFile();
andrew@24 99 void drawMidiFile();
andrew@24 100 void reset();
andrew@24 101 void setMatchedNotesBackToFalse();
andrew@24 102
andrew@24 103 int ticksPerScreen;
andrew@24 104 int tickLocation;
andrew@24 105 int numberOfScreensIn;
andrew@24 106 int noteArrayIndex;
andrew@24 107
andrew@24 108 int matchWindowWidth;
andrew@24 109
andrew@24 110 int noteMinimum, noteMaximum;
andrew@24 111 int* screenWidth;
andrew@24 112 int* screenHeight;
andrew@24 113 float noteHeight;
andrew@24 114 float tempo;
andrew@24 115 double lastPeriodUpdateTime;
andrew@24 116
andrew@24 117 double playPositionInMillis;
andrew@24 118
andrew@24 119 double timeOffsetForScreen;
andrew@24 120
andrew@24 121 double recentNoteOnTime;
andrew@24 122
andrew@24 123 void exampleCrossUpdate();
andrew@24 124 BayesianArrayStructure bayesStruct;
andrew@24 125
andrew@24 126 double speedPriorValue;
andrew@24 127 int bestMatchIndex;
andrew@24 128 string timeString;
andrew@24 129 double startTime;
andrew@24 130 int speedWindowWidthMillis;
andrew@24 131
andrew@24 132 bool confidenceWeightingUsed;
andrew@24 133
andrew@24 134 double minimumMatchError;//recent best error between observed note and aligned midi file
andrew@24 135
andrew@24 136 void reorderMatrixFromNoteTimes(IntMatrix& noteOnMatrix);
andrew@24 137 int getIndexOfMinimumAboveTime(const double& time, IntMatrix& noteOnMatrix);
andrew@24 138 void correctTiming(IntMatrix& noteOnMatrix);
andrew@24 139 void doublecheckOrder(IntMatrix& noteOnMatrix);
andrew@24 140 int getIndexOfMinimumAboveIndex(const int& index, IntMatrix& noteOnMatrix);
andrew@24 141 bool useTempoPrior;
andrew@24 142 string tempoSpeedString;
andrew@24 143 int minimumTimeIntervalForTempoUpdate;
andrew@24 144
andrew@24 145 double ticksFactor;
andrew@24 146 };
andrew@24 147 #endif