annotate src/AudioEventMatcher.h @ 32:4be22a1a0e24

added in chroma comparison for fourth channel (guitar)
author Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk>
date Mon, 02 Apr 2012 17:19:22 +0100
parents 24c413f0f2c5
children 6fb77b20413c
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@0 46
andrew@6 47 void newPitchEvent(const int& channel, const double& pitchIn, const double& timeIn);
andrew@2 48 void newKickEvent(const double& timeIn);
andrew@6 49 void newKickEvent(const int& channel, const double& timeIn);
andrew@2 50 void newSnareEvent(const double& timeIn);
andrew@7 51 void newSnareEvent(const int& channel, const double& timeIn);
andrew@2 52
andrew@32 53 void newChromaEvent(const int& channel, float* chromaIn, const double& timeIn);
andrew@32 54
andrew@32 55
andrew@2 56 void matchNewPitchEvent(const int& channel, const double& pitchIn, const double& timeIn);
andrew@2 57 void matchNewOnsetEvent(const int& channel, const double& timeIn);
andrew@32 58 void matchNewChromaEvent(const int& channel, float* chroma, const double& timeIn);
andrew@32 59 double getChromaDistance(float* chromaOne, float* chromaTwo);
andrew@1 60
andrew@0 61 BayesianArrayStructure bayesianStruct;//hold the probability distriubtions
andrew@0 62
andrew@0 63 LiveAudioInput liveInput;//hold the new events that come in
andrew@1 64 RecordedMultitrackAudio recordedTracks;
andrew@1 65
andrew@16 66 void loadAudioFiles();
andrew@22 67 void rescue();//flat prior
andrew@1 68 void windowResized(const int& w, const int& h);
andrew@0 69
andrew@0 70 ofxWindowRegion bayesTempoWindow;
andrew@3 71 ofxWindowRegion bayesPositionWindow;
andrew@3 72 ofxWindowRegion bayesLikelihoodWindow;
andrew@0 73
andrew@3 74 bool checkMatch(const double& recordedPitch, const double& livePitch);
andrew@3 75 double getPitchDistance(const double& pitchOne, const double& pitchTwo, const double& scale);
andrew@3 76
andrew@3 77 void startPlaying();
andrew@15 78 void stopPlaying();
andrew@15 79 bool startedPlaying;
andrew@3 80
andrew@3 81 bool usingRealTime;
andrew@7 82 double recentPitch, recentTime;
andrew@7 83
andrew@32 84 DynamicVector likelihoodVisualisation[numberOfChannels];
andrew@32 85 DynamicVector recentPriors[numberOfChannels];
andrew@13 86 //DynamicVector recentPrior;
andrew@10 87 DynamicVector projectedPrior;
andrew@8 88
andrew@8 89 double currentAlignmentPosition;
andrew@8 90 double lastAlignmentTime;
andrew@8 91
andrew@32 92 double recentEventTime[numberOfChannels];
andrew@10 93 int startTime;
andrew@11 94 int currentAlignmentTime;
andrew@9 95
andrew@9 96 double screenStartTimeMillis, screenEndTimeMillis, screenWidthMillis;
andrew@9 97 bool followingLiveInput;
andrew@9 98 void setScreenDisplayTimes();
andrew@14 99
andrew@16 100 AccompanimentSynchroniser synchroniser;
andrew@16 101
andrew@14 102 //params
andrew@14 103 double onsetLikelihoodWidth;
andrew@15 104 double onsetLikelihoodToNoise;
andrew@15 105 double pitchLikelihoodToNoise;//more noise
andrew@32 106 double chromaLikelihoodToNoise;
andrew@18 107
andrew@18 108 double pitchOfNearestMatch;//for viz purposes
andrew@18 109 double distanceOfNearestMatch;
andrew@19 110
andrew@32 111 double chromaLikelihoodWidth;
andrew@19 112
andrew@19 113 TempoFollower temporal;
andrew@20 114 TempoFollower recordedTempoData;
andrew@20 115 void calculateRecordedTempoData();
andrew@20 116 void setTempoPrior(double tempo);
andrew@20 117
andrew@20 118 void setNextOnsetTime(const int&channel, int& time, int* indexForOnsets);
andrew@20 119 int recordedTempoIndex;
andrew@20 120 double recordedTempo;
andrew@20 121 void updateRecordedTempo();
andrew@20 122 void drawRecordedTempo();
andrew@20 123 double currentSpeedRatio;
andrew@20 124 void drawPlayingTempo();
andrew@20 125 void setSpeedRatioDistribution(const double& speedRatio);
andrew@0 126 };
andrew@0 127 #endif