annotate src/midiEventHolder.h @ 1:1a32ce016bb9

Changed bestEstimate timing to work via time sent from Max not the elapsed time. This had caused some problems, but this version now working surprisingly well on MIDI files with variable timing.
author Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk>
date Thu, 18 Aug 2011 23:27:42 +0100
parents b299a65a3ad0
children 5581023e0de4
rev   line source
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@0 9 #include "ofMain.h"
andrew@0 10 #include "BayesianArrayStructure.h"
andrew@0 11
andrew@0 12 class midiEventHolder{
andrew@0 13
andrew@0 14 public:
andrew@0 15
andrew@0 16 midiEventHolder();
andrew@0 17 void printNotes();
andrew@0 18
andrew@0 19 typedef std::vector<int> IntVector;
andrew@0 20 typedef std::vector<IntVector> IntMatrix;
andrew@0 21
andrew@0 22 typedef std::vector<bool> BoolVector;
andrew@0 23
andrew@0 24 typedef std::vector<double> DoubleVector;
andrew@0 25 typedef std::vector<DoubleVector> DoubleMatrix;
andrew@0 26
andrew@0 27 //the rehearsal version
andrew@0 28 IntMatrix recordedNoteOnMatrix;//note, velocity, duration
andrew@0 29 IntVector matchesFound;
andrew@0 30 BoolVector noteOnMatches;
andrew@1 31
andrew@0 32 // int recordedNoteOnIndex;
andrew@0 33 DoubleVector recordedEventTimes;
andrew@0 34
andrew@0 35 IntMatrix playedNoteOnMatrix;
andrew@0 36 DoubleVector playedEventTimes;
andrew@0 37 int playedNoteIndex;
andrew@0 38 IntMatrix matchMatrix;
andrew@1 39 DoubleMatrix matchConfidence;
andrew@1 40 double totalConfidence;
andrew@0 41
andrew@1 42 double mouseX;
andrew@1 43
andrew@1 44 void clearAllEvents();
andrew@1 45 bool drawTempoMode;
andrew@0 46
andrew@0 47 double minimumMatchSpeed , maximumMatchSpeed;
andrew@0 48
andrew@0 49 double period, pulsesPerQuarternote;
andrew@0 50 double getEventTimeMillis(double ticks);
andrew@0 51 double getEventTimeTicks(double millis);
andrew@0 52
andrew@0 53 int getLocationFromTicks(double tickPosition);
andrew@0 54 int getLocationFromMillis(double millisPosition);
andrew@0 55
andrew@0 56 double windowStartTime;
andrew@0 57
andrew@0 58 //functions for finding match to incoming note
andrew@0 59 void newNoteOnEvent(int pitch, int velocity, double timePlayed);
andrew@0 60 int findLocalMatches(int notePitch);
andrew@0 61 bool checkIfMatchedNote(const int& tmpIndex);
andrew@0 62 int findMatch(const int& notePitch, const int& startTime, const int& endTime);
andrew@0 63
andrew@0 64
andrew@0 65 void findLocalTempoPairs();
andrew@0 66
andrew@0 67
andrew@0 68 double likelihoodWidth;
andrew@0 69 double likelihoodToNoiseRatio;
andrew@0 70
andrew@0 71 void printMatchMatrix();
andrew@0 72
andrew@0 73 void setMatchLikelihoods(int numberOfMatches);
andrew@0 74
andrew@0 75 void setStartPlayingTimes();
andrew@0 76
andrew@0 77 int width, height;
andrew@0 78 /////
andrew@0 79 string matchString;
andrew@0 80 void updatePlayPosition();
andrew@0 81
andrew@0 82 DoubleMatrix beatPeriodMatrix;
andrew@0 83
andrew@0 84 void drawFile();
andrew@0 85 void reset();
andrew@0 86
andrew@0 87 int ticksPerScreen;
andrew@0 88 int tickLocation;
andrew@0 89 int numberOfScreensIn;
andrew@0 90 int noteArrayIndex;
andrew@0 91
andrew@0 92 int matchWindowWidth;
andrew@0 93
andrew@0 94 int noteMinimum, noteMaximum;
andrew@0 95 int* screenWidth;
andrew@0 96 int* screenHeight;
andrew@0 97 float noteHeight;
andrew@0 98 float tempo;
andrew@0 99 double lastPeriodUpdateTime;
andrew@0 100
andrew@0 101 double playPositionInMillis;
andrew@0 102
andrew@0 103 double timeOffsetForScreen;
andrew@0 104
andrew@0 105 double recentNoteOnTime;
andrew@0 106
andrew@0 107 void exampleCrossUpdate();
andrew@0 108 BayesianArrayStructure bayesStruct;
andrew@0 109
andrew@0 110 string timeString;
andrew@0 111 double startTime;
andrew@0 112
andrew@0 113 };