annotate src/AudioEventMatcher.h @ 37:9806a4f22fd0

Fixed bugs in the likelohoods that caused some to zero when no events found.
author Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk>
date Tue, 24 Apr 2012 14:16:01 +0100
parents 6fb77b20413c
children d23685b9e766
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@0 26
andrew@32 27 static const int numberOfChannels = 4;
andrew@32 28
andrew@0 29 class AudioEventMatcher{
andrew@0 30
andrew@0 31 public:
andrew@0 32 AudioEventMatcher();
andrew@0 33
andrew@0 34 void setArraySizes();
andrew@0 35
andrew@9 36 void updatePosition();
andrew@8 37 void updateBestAlignmentPosition();
andrew@8 38
andrew@0 39 void draw();
andrew@32 40 void drawBayesianDistributions();
andrew@32 41 void drawPositionWindow();
andrew@32 42 void drawTrackLikelihoods();
andrew@32 43 void drawInfo();
andrew@32 44
andrew@7 45 void setWindowDimensions();
andrew@37 46 int getScreenWidthIndexOfEventTime(const double& time);
andrew@0 47
andrew@6 48 void newPitchEvent(const int& channel, const double& pitchIn, const double& timeIn);
andrew@2 49 void newKickEvent(const double& timeIn);
andrew@6 50 void newKickEvent(const int& channel, const double& timeIn);
andrew@2 51 void newSnareEvent(const double& timeIn);
andrew@7 52 void newSnareEvent(const int& channel, const double& timeIn);
andrew@2 53
andrew@32 54 void newChromaEvent(const int& channel, float* chromaIn, const double& timeIn);
andrew@32 55
andrew@32 56
andrew@2 57 void matchNewPitchEvent(const int& channel, const double& pitchIn, const double& timeIn);
andrew@2 58 void matchNewOnsetEvent(const int& channel, const double& timeIn);
andrew@32 59 void matchNewChromaEvent(const int& channel, float* chroma, const double& timeIn);
andrew@35 60
andrew@35 61 double getChromaDotProductDistance(float* chromaOne, float* chromaTwo);
andrew@35 62 double getChromaEuclideanDistance(float* chromaOne, float* chromaTwo);
andrew@35 63 bool useChromaDotProduct;
andrew@1 64
andrew@0 65 BayesianArrayStructure bayesianStruct;//hold the probability distriubtions
andrew@0 66
andrew@0 67 LiveAudioInput liveInput;//hold the new events that come in
andrew@1 68 RecordedMultitrackAudio recordedTracks;
andrew@1 69
andrew@16 70 void loadAudioFiles();
andrew@22 71 void rescue();//flat prior
andrew@1 72 void windowResized(const int& w, const int& h);
andrew@0 73
andrew@0 74 ofxWindowRegion bayesTempoWindow;
andrew@3 75 ofxWindowRegion bayesPositionWindow;
andrew@3 76 ofxWindowRegion bayesLikelihoodWindow;
andrew@0 77
andrew@3 78 bool checkMatch(const double& recordedPitch, const double& livePitch);
andrew@3 79 double getPitchDistance(const double& pitchOne, const double& pitchTwo, const double& scale);
andrew@3 80
andrew@3 81 void startPlaying();
andrew@15 82 void stopPlaying();
andrew@15 83 bool startedPlaying;
andrew@3 84
andrew@3 85 bool usingRealTime;
andrew@37 86 double recentPitch, recentPitchEventTime;
andrew@7 87
andrew@32 88 DynamicVector likelihoodVisualisation[numberOfChannels];
andrew@32 89 DynamicVector recentPriors[numberOfChannels];
andrew@13 90 //DynamicVector recentPrior;
andrew@10 91 DynamicVector projectedPrior;
andrew@8 92
andrew@8 93 double currentAlignmentPosition;
andrew@8 94 double lastAlignmentTime;
andrew@8 95
andrew@32 96 double recentEventTime[numberOfChannels];
andrew@10 97 int startTime;
andrew@11 98 int currentAlignmentTime;
andrew@9 99
andrew@9 100 double screenStartTimeMillis, screenEndTimeMillis, screenWidthMillis;
andrew@9 101 bool followingLiveInput;
andrew@9 102 void setScreenDisplayTimes();
andrew@14 103
andrew@16 104 AccompanimentSynchroniser synchroniser;
andrew@16 105
andrew@14 106 //params
andrew@14 107 double onsetLikelihoodWidth;
andrew@15 108 double onsetLikelihoodToNoise;
andrew@15 109 double pitchLikelihoodToNoise;//more noise
andrew@32 110 double chromaLikelihoodToNoise;
andrew@18 111
andrew@18 112 double pitchOfNearestMatch;//for viz purposes
andrew@18 113 double distanceOfNearestMatch;
andrew@19 114
andrew@32 115 double chromaLikelihoodWidth;
andrew@19 116
andrew@19 117 TempoFollower temporal;
andrew@20 118 TempoFollower recordedTempoData;
andrew@20 119 void calculateRecordedTempoData();
andrew@20 120 void setTempoPrior(double tempo);
andrew@20 121
andrew@20 122 void setNextOnsetTime(const int&channel, int& time, int* indexForOnsets);
andrew@20 123 int recordedTempoIndex;
andrew@20 124 double recordedTempo;
andrew@20 125 void updateRecordedTempo();
andrew@20 126 void drawRecordedTempo();
andrew@20 127 double currentSpeedRatio;
andrew@20 128 void drawPlayingTempo();
andrew@20 129 void setSpeedRatioDistribution(const double& speedRatio);
andrew@37 130
andrew@37 131 double euclideanMaximumDistance;
andrew@37 132 bool printingData;
andrew@0 133 };
andrew@0 134 #endif