# HG changeset patch # User Andrew N Robertson # Date 1328582224 0 # Node ID 4ded82fe318def99af5b1000fa107d482157ebf8 # Parent c96b18dd0f4843f00b4172d4c7827a48d1aa74e9 added pitch info at top of page diff -r c96b18dd0f48 -r 4ded82fe318d src/AudioEventMatcher.cpp --- a/src/AudioEventMatcher.cpp Mon Feb 06 13:38:19 2012 +0000 +++ b/src/AudioEventMatcher.cpp Tue Feb 07 02:37:04 2012 +0000 @@ -129,8 +129,13 @@ //bayesianStruct.posterior.drawVector(0, bayesianStruct.posterior.getRealTermsAsIndex(screenWidthMillis), bayesPositionWindow); //bayesianStruct.posterior.drawVector(bayesianStruct.posterior.getRealTermsAsIndex(0), bayesianStruct.posterior.getRealTermsAsIndex(screenWidthMillis), bayesPositionWindow); //bayesianStruct.relativeSpeedPosterior.drawVector(0, bayesianStruct.relativeSpeedPosterior.getRealTermsAsIndex(2), bayesTempoWindow); - - ofDrawBitmapString("pitch "+ofToString(recentPitch, 2)+", Time "+ofToString(recentTime, 0), 20, 20); + string tmpStr = "pitch "+ofToString(recentPitch, 2); + tmpStr += " Nearest "+ofToString(pitchOfNearestMatch,2); + tmpStr += " dist "+ofToString(distanceOfNearestMatch, 2); + tmpStr += ", Time "+ofToString(recentTime, 0); + ofDrawBitmapString(tmpStr, 20, 20); + + string alignString = " align "+ofToString(currentAlignmentPosition, 2); alignString += " playing "+ofToString(synchroniser.playingPositionRatio, 5); @@ -323,13 +328,16 @@ int numberOfMatches = 0; bayesianStruct.likelihood.zero();//set to zero + double newOnsetTime; + double closestDistance = INFINITY; double quantity = 0; if (channel <= recordedTracks.numberOfAudioTracks){ for (int i = 0;i < recordedTracks.loadedAudioFiles[channel].fileLoader.onsetDetect.chromaOnsets.size();i++){ if (checkMatch(recordedTracks.loadedAudioFiles[channel].fileLoader.onsetDetect.chromaOnsets[i].aubioPitch, pitchIn)) { - quantity = getPitchDistance(recordedTracks.loadedAudioFiles[channel].fileLoader.onsetDetect.chromaOnsets[i].aubioPitch, pitchIn, 16); + quantity = getPitchDistance(recordedTracks.loadedAudioFiles[channel].fileLoader.onsetDetect.chromaOnsets[i].aubioPitch, pitchIn, 8); + bayesianStruct.likelihood.addGaussianShapeFromRealTime(recordedTracks.loadedAudioFiles[channel].fileLoader.onsetDetect.chromaOnsets[i].millisTime, 30, quantity); recordedTracks.loadedAudioFiles[channel].fileLoader.onsetDetect.chromaOnsets[i].matched = true; numberOfMatches++; @@ -337,6 +345,13 @@ else{ recordedTracks.loadedAudioFiles[channel].fileLoader.onsetDetect.chromaOnsets[i].matched = false; } + //checking nearest pitch + newOnsetTime = recordedTracks.loadedAudioFiles[channel].fileLoader.onsetDetect.chromaOnsets[i].millisTime; + if (abs(newOnsetTime - currentAlignmentPosition) < closestDistance){ + closestDistance = abs(newOnsetTime - currentAlignmentPosition); + pitchOfNearestMatch = recordedTracks.loadedAudioFiles[channel].fileLoader.onsetDetect.chromaOnsets[i].aubioPitch; + distanceOfNearestMatch = quantity; + } } } @@ -364,10 +379,14 @@ double AudioEventMatcher::getPitchDistance(const double& pitchOne, const double& pitchTwo, const double& scale){ - double scaleFactor = scale ;//* pitchOne / 110.0; + double scaleFactor = scale * pitchOne / 110.0; + int multiplicationFactor = 1; + if (pitchTwo > 0){ + int multiplicationFactor = round(pitchOne/pitchTwo); + } - double distance = abs(pitchOne - pitchTwo); + double distance = abs(pitchOne - pitchTwo*multiplicationFactor); if (distance < scaleFactor) distance = 1 - (distance/scaleFactor); else @@ -380,10 +399,18 @@ bool AudioEventMatcher::checkMatch(const double& recordedPitch, const double& livePitch){ - if (abs(recordedPitch - livePitch) < 16) + + if (livePitch > 0){ + int multiplicationFactor = (int)(round(recordedPitch/livePitch)); + + if (abs(recordedPitch - livePitch * multiplicationFactor) < 16) return true; else return false; + }else { + return false; + } + } diff -r c96b18dd0f48 -r 4ded82fe318d src/AudioEventMatcher.h --- a/src/AudioEventMatcher.h Mon Feb 06 13:38:19 2012 +0000 +++ b/src/AudioEventMatcher.h Tue Feb 07 02:37:04 2012 +0000 @@ -90,5 +90,8 @@ double onsetLikelihoodWidth; double onsetLikelihoodToNoise; double pitchLikelihoodToNoise;//more noise + + double pitchOfNearestMatch;//for viz purposes + double distanceOfNearestMatch; }; #endif diff -r c96b18dd0f48 -r 4ded82fe318d src/RecordedMultitrackAudio.cpp --- a/src/RecordedMultitrackAudio.cpp Mon Feb 06 13:38:19 2012 +0000 +++ b/src/RecordedMultitrackAudio.cpp Tue Feb 07 02:37:04 2012 +0000 @@ -13,18 +13,18 @@ void RecordedMultitrackAudio::loadTestAudio(){ -// const char *kickfilename = "../../../data/sound/LiveDues/kick_liveDues.wav"; -// const char *bassfilename = "../../../data/sound/LiveDues/bass_upsideLive.wav"; -// const char *snarefilename = "../../../data/sound/LiveDues/snare_liveDues.wav"; +/* const char *kickfilename = "../../../data/sound/LiveDues/kick_liveDues.wav"; + const char *bassfilename = "../../../data/sound/LiveDues/bass_upsideLive.wav"; + const char *snarefilename = "../../../data/sound/LiveDues/snare_liveDues.wav"; +*/ + const char *kickfilename = "../../../data/sound/DiamondMatch1/kick_bip.wav"; + const char *bassfilename = "../../../data/sound/DiamondMatch1/bass_bip.wav"; + const char *snarefilename = "../../../data/sound/DiamondMatch1/snare_bip.wav"; -// const char *kickfilename = "../../../data/sound/DiamondMatch1/kick_bip.wav"; -// const char *bassfilename = "../../../data/sound/DiamondMatch1/bass_bip.wav"; -// const char *snarefilename = "../../../data/sound/DiamondMatch1/snare_bip.wav"; - - const char *kickfilename = "../../../data/sound/LiveIdiot2/02kick_bip.wav"; +/* const char *kickfilename = "../../../data/sound/LiveIdiot2/02kick_bip.wav"; const char *bassfilename = "../../../data/sound/LiveIdiot2/01bass_bip.wav"; const char *snarefilename = "../../../data/sound/LiveIdiot2/03snare_bip.wav"; - +*/ /* const char *kickfilename = "../../../data/sound/UistLive1/02kick_bip.wav"; const char *bassfilename = "../../../data/sound/UistLive1/01bass_bip.wav"; const char *snarefilename = "../../../data/sound/UistLive1/03snare_bip.wav";