Mercurial > hg > multitrack-audio-matcher
diff src/AudioEventMatcher.cpp @ 19:1a62561bd72d
Added in tempo follower class that models the tempo of played events
author | Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk> |
---|---|
date | Thu, 09 Feb 2012 18:09:34 +0000 |
parents | 4ded82fe318d |
children | 4f6006cac9de |
line wrap: on
line diff
--- a/src/AudioEventMatcher.cpp Tue Feb 07 02:37:04 2012 +0000 +++ b/src/AudioEventMatcher.cpp Thu Feb 09 18:09:34 2012 +0000 @@ -31,13 +31,17 @@ followingLiveInput = true; startedPlaying = false; + + temporal.setUpEventTimeMatrix(); } + + void AudioEventMatcher::setWindowDimensions(){ double startHeight = recordedTracks.numberOfAudioTracks * recordedTracks.trackScreenHeight; double heightAvailable = 1 - startHeight; - heightAvailable /= 3.0; + heightAvailable /= NUMBER_OF_CHANNELS; bayesPositionWindow.setToRelativeSize(0, startHeight, 1, heightAvailable); bayesLikelihoodWindow.setToRelativeSize(0, startHeight + 1*heightAvailable, 1, heightAvailable); @@ -71,6 +75,7 @@ projectedPrior = bayesianStruct.prior; startedPlaying = true; synchroniser.reset(); + temporal.reset(); //bayesianStruct.posterior.printArray(); } @@ -78,15 +83,21 @@ void AudioEventMatcher::stopPlaying(){ startedPlaying = false; + temporal.printEventTimes(); } void AudioEventMatcher::updatePosition(){ + + if (startedPlaying){ if (!followingLiveInput) recordedTracks.updatePosition(); - else if (startedPlaying) + else recordedTracks.updatePositionToMillis(currentAlignmentPosition); updateBestAlignmentPosition(); + } + + temporal.tempoPosterior.addGaussianShape(temporal.tempoPosterior.MAPestimate, temporal.tempoArraySize / 4, 0.5 ); } void AudioEventMatcher::updateBestAlignmentPosition(){ @@ -223,6 +234,8 @@ ofSetColor(255,0,0); projectedPrior.drawConstrainedVector(bayesianStruct.prior.getRealTermsAsIndex(screenStartTimeMillis), bayesianStruct.prior.getRealTermsAsIndex(screenEndTimeMillis), 0, ofGetWidth(), bayesPositionWindow); + temporal.drawTempoArray(bayesLikelihoodWindow); + } void AudioEventMatcher::newPitchEvent(const int& channel, const double& pitchIn, const double& timeIn){ @@ -306,6 +319,9 @@ recentPriors[channel] = bayesianStruct.prior; projectedPrior = bayesianStruct.prior; + + + temporal.updateTempo(channel, timeIn); } @@ -372,6 +388,8 @@ recentPriors[channel] = bayesianStruct.prior; projectedPrior = bayesianStruct.prior; + + temporal.eventTimes[channel].push_back(timeIn); }