Mercurial > hg > multitrack-audio-matcher
diff src/AudioEventMatcher.cpp @ 2:179c09199b3c
bayesian vector now adding gaussians for kick onsets
author | Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk> |
---|---|
date | Tue, 31 Jan 2012 21:34:19 +0000 |
parents | 852173ca8365 |
children | 5e188c0035b6 |
line wrap: on
line diff
--- a/src/AudioEventMatcher.cpp Tue Jan 31 17:35:30 2012 +0000 +++ b/src/AudioEventMatcher.cpp Tue Jan 31 21:34:19 2012 +0000 @@ -10,7 +10,7 @@ #include "AudioEventMatcher.h" -const int matchWindowWidth = 1200; +const int matchWindowWidth = 6000; AudioEventMatcher::AudioEventMatcher(){ @@ -36,14 +36,66 @@ //ofRect(20, 20, 300, 200); recordedTracks.drawTracks(); - bayesianStruct.relativeSpeedPrior.drawVector(0, 200, bayesTempoWindow); + + ofSetColor(255); +// bayesianStruct.relativeSpeedPrior.drawVector(0, 200, bayesTempoWindow); + + double screenWidthMillis = recordedTracks.loadedAudioFiles[0].fileLoader.onsetDetect.framesToMillis(recordedTracks.loadedAudioFiles[0].fileLoader.onsetDetect.amplitudeNumber); + + + bayesianStruct.likelihood.drawVector(0, screenWidthMillis, bayesTempoWindow); } void AudioEventMatcher::newPitchEvent(const double& pitchIn, const double& timeIn){ liveInput.addPitchEvent(pitchIn, timeIn); - //matchNewPitchEvent(); + recordedTracks.matchNewPitchEvent(0, pitchIn, timeIn); +} + +void AudioEventMatcher::newKickEvent(const double& timeIn){ + matchNewOnsetEvent(0, timeIn); +} + + +void AudioEventMatcher::newSnareEvent(const double& timeIn){ + matchNewOnsetEvent(0, timeIn); +} + +//Needs just to set bounds for the matching process, not have TimeIn +void AudioEventMatcher::matchNewOnsetEvent(const int& channel, const double& timeIn){ + //start at beginning but OPTIMISE later + double likelihoodToNoise = 0.5; + + double likelihoodWidth = 40; + + bayesianStruct.likelihood.offset = bayesianStruct.prior.offset; + bayesianStruct.likelihood.zero();//set to zero + + double quantity = 1;//likelihoodToNoiseRatio / numberOfMatches; + int numberOfMatchesFound = 0; + + + double startTime = bayesianStruct.likelihood.offset; + double endTime = bayesianStruct.likelihood.offset + matchWindowWidth; + + if (channel <= recordedTracks.numberOfAudioTracks){ + for (int i = 0;i < recordedTracks.loadedAudioFiles[channel].fileLoader.onsetDetect.chromaOnsets.size();i++){ + double millisTime = recordedTracks.loadedAudioFiles[channel].fileLoader.onsetDetect.chromaOnsets[i].millisTime; + if (millisTime >= startTime && millisTime <= endTime){ + bayesianStruct.likelihood.addGaussianShapeFromRealTime(millisTime, likelihoodWidth, quantity); + numberOfMatchesFound++; + printf("Adding Gaussian for onset at time %f offset %f\n", millisTime, bayesianStruct.likelihood.offset); + + } + } + } + + bayesianStruct.likelihood.renormalise(); + + //bayesStruct.likelihood.addConstant((1-likelihoodToNoiseRatio)/bayesStruct.likelihood.length); + + }