annotate src/AudioEventMatcher.h @ 52:e359b9bad811

Added exporting of image and text data
author Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk>
date Tue, 17 Jul 2012 22:12:20 +0100
parents 93d21c20cfbc
children 5274e3b5479d
rev   line source
andrew@0 1 /*
andrew@0 2 * AudioEventMatcher.h
andrew@0 3 * MultipleAudioMathcher
andrew@0 4 *
andrew@0 5 * Created by Andrew on 31/01/2012.
andrew@0 6 * Copyright 2012 QMUL. All rights reserved.
andrew@0 7 *
andrew@0 8 */
andrew@0 9
andrew@0 10
andrew@0 11
andrew@0 12 #ifndef AUDIO_EVENT_MATCHER_H
andrew@0 13 #define AUDIO_EVENT_MATCHER_H
andrew@0 14
andrew@32 15
andrew@0 16
andrew@0 17 #include "ofMain.h"
andrew@0 18 #include "ChromaOnset.h"
andrew@0 19 #include "LiveAudioInput.h"
andrew@0 20 #include "ofxWindowRegion.h"
andrew@0 21 #include "BayesianArrayStructure.h"
andrew@1 22 #include "RecordedMultitrackAudio.h"
andrew@7 23 #include "DynamicVector.h"
andrew@16 24 #include "AccompanimentSynchroniser.h"
andrew@19 25 #include "TempoFollower.h"
andrew@50 26 #include "MatchMarkers.h"
andrew@0 27
andrew@52 28 #include "OutputDataWriter.h"
andrew@52 29
andrew@32 30 static const int numberOfChannels = 4;
andrew@32 31
andrew@0 32 class AudioEventMatcher{
andrew@0 33
andrew@0 34 public:
andrew@0 35 AudioEventMatcher();
andrew@0 36
andrew@0 37 void setArraySizes();
andrew@0 38
andrew@9 39 void updatePosition();
andrew@8 40 void updateBestAlignmentPosition();
andrew@8 41
andrew@50 42
andrew@0 43 void draw();
andrew@32 44 void drawBayesianDistributions();
andrew@32 45 void drawPositionWindow();
andrew@32 46 void drawTrackLikelihoods();
andrew@32 47 void drawInfo();
andrew@45 48 void drawAlignmentTimes();
andrew@50 49 void drawMarkers();
andrew@32 50
andrew@7 51 void setWindowDimensions();
andrew@37 52 int getScreenWidthIndexOfEventTime(const double& time);
andrew@45 53 int getTimeNow();
andrew@0 54
andrew@50 55 void addMarkerNow();
andrew@50 56 void deleteMarkers();
andrew@50 57 void deleteNearestMarker();
andrew@50 58 void moveToNextMarker();
andrew@50 59 void moveToPreviousMarker();
andrew@50 60 void goToMarker(const int& markerID);
andrew@50 61 void setToPosition(const double& position);//for Bayesian distbn
andrew@50 62 void setPlaybackPosition(const double& millis);
andrew@50 63 void mousePressed(const int& x);
andrew@50 64
andrew@6 65 void newPitchEvent(const int& channel, const double& pitchIn, const double& timeIn);
andrew@2 66 void newKickEvent(const double& timeIn);
andrew@6 67 void newKickEvent(const int& channel, const double& timeIn);
andrew@2 68 void newSnareEvent(const double& timeIn);
andrew@7 69 void newSnareEvent(const int& channel, const double& timeIn);
andrew@2 70
andrew@32 71 void newChromaEvent(const int& channel, float* chromaIn, const double& timeIn);
andrew@32 72
andrew@32 73
andrew@2 74 void matchNewPitchEvent(const int& channel, const double& pitchIn, const double& timeIn);
andrew@2 75 void matchNewOnsetEvent(const int& channel, const double& timeIn);
andrew@32 76 void matchNewChromaEvent(const int& channel, float* chroma, const double& timeIn);
andrew@35 77
andrew@35 78 double getChromaDotProductDistance(float* chromaOne, float* chromaTwo);
andrew@35 79 double getChromaEuclideanDistance(float* chromaOne, float* chromaTwo);
andrew@35 80 bool useChromaDotProduct;
andrew@52 81 float quantisedChromagramReceived[12];
andrew@52 82 void makeQuantisedChroma(float* chromaIn);
andrew@1 83
andrew@0 84 BayesianArrayStructure bayesianStruct;//hold the probability distriubtions
andrew@0 85
andrew@0 86 LiveAudioInput liveInput;//hold the new events that come in
andrew@1 87 RecordedMultitrackAudio recordedTracks;
andrew@1 88
andrew@16 89 void loadAudioFiles();
andrew@22 90 void rescue();//flat prior
andrew@1 91 void windowResized(const int& w, const int& h);
andrew@0 92
andrew@0 93 ofxWindowRegion bayesTempoWindow;
andrew@3 94 ofxWindowRegion bayesPositionWindow;
andrew@3 95 ofxWindowRegion bayesLikelihoodWindow;
andrew@0 96
andrew@3 97 bool checkMatch(const double& recordedPitch, const double& livePitch);
andrew@3 98 double getPitchDistance(const double& pitchOne, const double& pitchTwo, const double& scale);
andrew@3 99
andrew@3 100 void startPlaying();
andrew@15 101 void stopPlaying();
andrew@15 102 bool startedPlaying;
andrew@3 103
andrew@3 104 bool usingRealTime;
andrew@37 105 double recentPitch, recentPitchEventTime;
andrew@7 106
andrew@32 107 DynamicVector likelihoodVisualisation[numberOfChannels];
andrew@32 108 DynamicVector recentPriors[numberOfChannels];
andrew@13 109 //DynamicVector recentPrior;
andrew@10 110 DynamicVector projectedPrior;
andrew@8 111
andrew@8 112 double currentAlignmentPosition;
andrew@8 113 double lastAlignmentTime;
andrew@8 114
andrew@32 115 double recentEventTime[numberOfChannels];
andrew@10 116 int startTime;
andrew@11 117 int currentAlignmentTime;
andrew@9 118
andrew@9 119 double screenStartTimeMillis, screenEndTimeMillis, screenWidthMillis;
andrew@9 120 bool followingLiveInput;
andrew@9 121 void setScreenDisplayTimes();
andrew@14 122
andrew@16 123 AccompanimentSynchroniser synchroniser;
andrew@16 124
andrew@14 125 //params
andrew@14 126 double onsetLikelihoodWidth;
andrew@15 127 double onsetLikelihoodToNoise;
andrew@15 128 double pitchLikelihoodToNoise;//more noise
andrew@32 129 double chromaLikelihoodToNoise;
andrew@18 130
andrew@18 131 double pitchOfNearestMatch;//for viz purposes
andrew@18 132 double distanceOfNearestMatch;
andrew@19 133
andrew@32 134 double chromaLikelihoodWidth;
andrew@19 135
andrew@19 136 TempoFollower temporal;
andrew@20 137 TempoFollower recordedTempoData;
andrew@20 138 void calculateRecordedTempoData();
andrew@20 139 void setTempoPrior(double tempo);
andrew@20 140
andrew@20 141 void setNextOnsetTime(const int&channel, int& time, int* indexForOnsets);
andrew@20 142 int recordedTempoIndex;
andrew@20 143 double recordedTempo;
andrew@20 144 void updateRecordedTempo();
andrew@20 145 void drawRecordedTempo();
andrew@20 146 double currentSpeedRatio;
andrew@20 147 void drawPlayingTempo();
andrew@20 148 void setSpeedRatioDistribution(const double& speedRatio);
andrew@37 149
andrew@37 150 double euclideanMaximumDistance;
andrew@37 151 bool printingData;
andrew@50 152
andrew@50 153 bool drawLikelihoods;
andrew@50 154 bool drawPosterior;
andrew@50 155
andrew@50 156 MatchMarkers markedPoints;
andrew@50 157 double markerPlaybackPosition;
andrew@52 158
andrew@52 159 OutputDataWriter testDistributionOutput;
andrew@52 160 void writeAllDistributions();
andrew@52 161 void writeDistribution(DynamicVector& distribution, std::string filename);
andrew@52 162 ofImage img;
andrew@0 163 };
andrew@0 164 #endif