annotate hackday/midiEventHolder.h @ 52:13194a9dca77 tip

Added exporting of image and text data
author Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk>
date Tue, 17 Jul 2012 22:13:10 +0100
parents 9a70d9abdc8b
children
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@29 80 void updateTempo();
andrew@24 81 void findLocalTempoPairs();
andrew@24 82 void findLocalTempoPairsWeightedForConfidence();
andrew@29 83 void findOptimumTempoPairsToCurrentBestMatch();
andrew@29 84 double getBestSpeedEstimate(const int& currentPlayedIndex, const int& equivalentRecordedIndex);
andrew@24 85
andrew@30 86
andrew@30 87 void calcuateNewInterNoteIntervals();
andrew@30 88
andrew@24 89 double likelihoodWidth;
andrew@24 90 double likelihoodToNoiseRatio;
andrew@24 91
andrew@24 92 void printMatchMatrix();
andrew@24 93 void printRecordedEvents();
andrew@26 94 void printNoteCounter();
andrew@26 95 void updateNoteCounter();
andrew@24 96
andrew@24 97 void setMatchLikelihoods(int numberOfMatches);
andrew@24 98
andrew@24 99 void setStartPlayingTimes();
andrew@24 100 void setSpeedPrior(double speedPriorValue);
andrew@24 101
andrew@24 102 int width, height;
andrew@24 103 /////
andrew@24 104 string matchString;
andrew@24 105 void updatePlayPosition();
andrew@24 106
andrew@24 107 DoubleMatrix beatPeriodMatrix;
andrew@24 108
andrew@24 109 void drawFile();
andrew@24 110 void drawMidiFile();
andrew@24 111 void reset();
andrew@24 112 void setMatchedNotesBackToFalse();
andrew@24 113
andrew@24 114 int ticksPerScreen;
andrew@24 115 int tickLocation;
andrew@24 116 int numberOfScreensIn;
andrew@24 117 int noteArrayIndex;
andrew@24 118
andrew@24 119 int matchWindowWidth;
andrew@24 120
andrew@24 121 int noteMinimum, noteMaximum;
andrew@24 122 int* screenWidth;
andrew@24 123 int* screenHeight;
andrew@24 124 float noteHeight;
andrew@24 125 float tempo;
andrew@24 126 double lastPeriodUpdateTime;
andrew@25 127 int lastPlayedPitch;
andrew@24 128
andrew@24 129 double playPositionInMillis;
andrew@24 130
andrew@24 131 double timeOffsetForScreen;
andrew@24 132
andrew@24 133 double recentNoteOnTime;
andrew@24 134
andrew@24 135 void exampleCrossUpdate();
andrew@24 136 BayesianArrayStructure bayesStruct;
andrew@24 137
andrew@24 138 double speedPriorValue;
andrew@24 139 int bestMatchIndex;
andrew@24 140 string timeString;
andrew@24 141 double startTime;
andrew@24 142 int speedWindowWidthMillis;
andrew@24 143
andrew@24 144 bool confidenceWeightingUsed;
andrew@24 145
andrew@24 146 double minimumMatchError;//recent best error between observed note and aligned midi file
andrew@24 147
andrew@24 148 void reorderMatrixFromNoteTimes(IntMatrix& noteOnMatrix);
andrew@24 149 int getIndexOfMinimumAboveTime(const double& time, IntMatrix& noteOnMatrix);
andrew@24 150 void correctTiming(IntMatrix& noteOnMatrix);
andrew@24 151 void doublecheckOrder(IntMatrix& noteOnMatrix);
andrew@24 152 int getIndexOfMinimumAboveIndex(const int& index, IntMatrix& noteOnMatrix);
andrew@24 153 bool useTempoPrior;
andrew@24 154 string tempoSpeedString;
andrew@24 155 int minimumTimeIntervalForTempoUpdate;
andrew@24 156
andrew@24 157 double ticksFactor;
andrew@29 158
andrew@30 159 bool newOptimalMethod;
andrew@30 160 DoubleMatrix interNoteIntervals;
andrew@30 161 IntVector intervalsToCheck;
andrew@30 162 void checkForCorrectInterval(const double& playedTimeDifference, DoubleVector* v);
andrew@30 163 void drawInterNoteIntervals();
andrew@30 164 void printInterNoteIntervals();
andrew@30 165 int interNoteRange;
andrew@31 166 DoubleMatrix periodValues;
andrew@31 167
andrew@24 168 };
andrew@24 169 #endif