Mercurial > hg > midi-score-follower
view jnmr/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 | 158f5f38e9d3 |
children |
line wrap: on
line source
/* * midiEventHolder.h * midiCannamReader3 * * Created by Andrew on 19/07/2011. * Copyright 2011 QMUL. All rights reserved. * */ #ifndef MIDI_EVENT_HOLDER #define MIDI_EVENT_HOLDER #include "ofMain.h" #include "BayesianArrayStructure.h" #include "Annotations.h" #include "OutputDataWriter.h" class midiEventHolder{ public: midiEventHolder(); void printNotes(); typedef std::vector<int> IntVector; typedef std::vector<IntVector> IntMatrix; typedef std::vector<bool> BoolVector; typedef std::vector<double> DoubleVector; typedef std::vector<DoubleVector> DoubleMatrix; //the rehearsal version IntMatrix recordedNoteOnMatrix;//note, velocity, duration DoubleVector recordedEventTimes; IntVector matchesFound; BoolVector noteOnMatches; void drawMidiFile(IntMatrix& midiFileToDraw); // int recordedNoteOnIndex; IntMatrix playedNoteOnMatrix; DoubleVector playedEventTimes; int playedNoteIndex; IntMatrix matchMatrix; IntVector bestMatchFound; IntVector measureVector; IntVector recordedTotalNoteCounterByPitch; int totalNoteCounterIndex; DoubleMatrix matchConfidence; double totalConfidence; double mouseX; void clearAllEvents(); bool drawTempoMode, drawPhaseMode; double minimumMatchSpeed , maximumMatchSpeed; double period, pulsesPerQuarternote; double getEventTimeMillis(double ticks); double getEventTimeTicks(double millis); // int getLocationFromTicks(double tickPosition); int getLocationFromMillis(double millisPosition); double getTimeNow(double eventTime); bool runningInRealTime; double windowStartTime; //functions for finding match to incoming note void newNoteOnEvent(int pitch, int velocity, double timePlayed); int findLocalMatches(int notePitch); bool checkIfMatchedNote(const int& tmpIndex); int findMatch(const int& notePitch, const int& startTime, const int& endTime); void updateTempo(); void findLocalTempoPairs(); void findLocalTempoPairsWeightedForConfidence(); void findOptimumTempoPairsToCurrentBestMatch(); double getBestSpeedEstimate(const int& currentPlayedIndex, const int& equivalentRecordedIndex); void calcuateNewInterNoteIntervals(); double likelihoodWidth; double likelihoodToNoiseRatio; void printMatchMatrix(); void printRecordedEvents(); void printNoteCounter(); void updateNoteCounter(); void setMatchLikelihoods(int numberOfMatches); void setStartPlayingTimes(); void setSpeedPrior(double speedPriorValue); int width, height; ///// string matchString; void updatePlayPosition(); DoubleMatrix beatPeriodMatrix; void drawFile(); void drawMidiFile(); void reset(); void setMatchedNotesBackToFalse(); int ticksPerScreen; int tickLocation; int numberOfScreensIn; int noteArrayIndex; int matchWindowWidth; int noteMinimum, noteMaximum; int* screenWidth; int* screenHeight; float noteHeight; float tempo; double startPlayingTime; int lastPlayedPitch; //double playPositionInMillis; double timeOffsetForScreen; double recentNoteOnTime; // void exampleCrossUpdate(); BayesianArrayStructure bayesStruct; double speedPriorValue; int bestMatchIndex; string timeString; //double startTime; int speedWindowWidthMillis; bool confidenceWeightingUsed; double minimumMatchError;//recent best error between observed note and aligned midi file void reorderMatrixFromNoteTimes(IntMatrix& noteOnMatrix); int getIndexOfMinimumAboveTime(const double& time, IntMatrix& noteOnMatrix); void correctTiming(IntMatrix& noteOnMatrix); void doublecheckOrder(IntMatrix& noteOnMatrix); int getIndexOfMinimumAboveIndex(const int& index, IntMatrix& noteOnMatrix); bool useTempoPrior; string tempoSpeedString; int minimumTimeIntervalForTempoUpdate; double ticksFactor; bool newOptimalMethod; DoubleMatrix interNoteIntervals; IntVector intervalsToCheck; void checkForCorrectInterval(const double& playedTimeDifference, DoubleVector* v); void drawInterNoteIntervals(); void printInterNoteIntervals(); int interNoteRange; DoubleMatrix periodValues; // int periodCounter; // void updatePeriodValue(const double& miupdatesllis); double smoothPlayPosition; // double storedSmoothPlayPosition; // double lastSmoothUpdateTime; // double relativeSpeedForSmooth; // void updateSmoothPlaySpeed();; //best alignment double alignmentPosition; double firstEventOffsetTimeMillis; double causalPlayPosition; void updateCausalPlayPosition(const double& timeNow); void updateCausalSpeed(); double lastCausalUpdateTime ; double causalSpeed; void updateOutputPositionTo(const double& newPosition); int outputIndex; DoubleVector beatPositions; ofstream *fileOutput; Annotations myNotation; ofstream *differenceOutput; double timeProjectionToMeet;///ms in future they will intersect double smoothDifference; double lastUpdatePosition, lastUpdatePlayingTime; double outputPosition;//debug variable void testSpeedPriorSetting(); bool printInfo; OutputDataWriter dataWriter; void writeAllDistributions(); void writeDistribution(DynamicVector& distribution, std::string file); ofImage img; void saveImageFile(std::string file); bool saveImage; }; #endif