comparison src/AudioEventMatcher.cpp @ 17:c96b18dd0f48

adjusting sync parameters
author Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk>
date Mon, 06 Feb 2012 13:38:19 +0000
parents 680ba08e9925
children 4ded82fe318d
comparison
equal deleted inserted replaced
16:680ba08e9925 17:c96b18dd0f48
13 const int matchWindowWidth = 6000; 13 const int matchWindowWidth = 6000;
14 14
15 AudioEventMatcher::AudioEventMatcher(){ 15 AudioEventMatcher::AudioEventMatcher(){
16 16
17 17
18 pitchLikelihoodToNoise = 0.9;//more noise 18 pitchLikelihoodToNoise = 0.7;//more noise
19 19
20 onsetLikelihoodToNoise = 0.4; 20 onsetLikelihoodToNoise = 0.5;
21 onsetLikelihoodWidth = 20;//in ms 21 onsetLikelihoodWidth = 10;//in ms
22 22
23 setArraySizes(); 23 setArraySizes();
24 24
25 usingRealTime = false; 25 usingRealTime = false;
26 bayesianStruct.realTimeMode = &usingRealTime; 26 bayesianStruct.realTimeMode = &usingRealTime;
68 currentAlignmentPosition = 0; 68 currentAlignmentPosition = 0;
69 startTime = ofGetElapsedTimeMillis(); 69 startTime = ofGetElapsedTimeMillis();
70 70
71 projectedPrior = bayesianStruct.prior; 71 projectedPrior = bayesianStruct.prior;
72 startedPlaying = true; 72 startedPlaying = true;
73 synchroniser.reset();
74
73 //bayesianStruct.posterior.printArray(); 75 //bayesianStruct.posterior.printArray();
74 } 76 }
75 77
76 78
77 void AudioEventMatcher::stopPlaying(){ 79 void AudioEventMatcher::stopPlaying(){
98 // currentAlignmentTime = newTime; 100 // currentAlignmentTime = newTime;
99 currentAlignmentPosition = bayesianStruct.posterior.getIndexInRealTerms(bayesianStruct.posterior.MAPestimate); 101 currentAlignmentPosition = bayesianStruct.posterior.getIndexInRealTerms(bayesianStruct.posterior.MAPestimate);
100 currentAlignmentPosition += (newTime - lastAlignmentTime) * bayesianStruct.relativeSpeedPosterior.getIndexInRealTerms(bayesianStruct.relativeSpeedPosterior.MAPestimate); 102 currentAlignmentPosition += (newTime - lastAlignmentTime) * bayesianStruct.relativeSpeedPosterior.getIndexInRealTerms(bayesianStruct.relativeSpeedPosterior.MAPestimate);
101 103
102 104
103 synchroniser.updateRecordedPosition(currentAlignmentPosition); 105 synchroniser.updateRecordedPosition(currentAlignmentPosition, newTime);
104 106
105 synchroniser.updateOutputSpeed(); 107 synchroniser.updateOutputSpeed();
106 108
107 bayesianStruct.projectDistribution(newTime, currentAlignmentPosition, projectedPrior);//prior gets updated to where we are now 109 bayesianStruct.projectDistribution(newTime, currentAlignmentPosition, projectedPrior);//prior gets updated to where we are now
108 110
130 132
131 ofDrawBitmapString("pitch "+ofToString(recentPitch, 2)+", Time "+ofToString(recentTime, 0), 20, 20); 133 ofDrawBitmapString("pitch "+ofToString(recentPitch, 2)+", Time "+ofToString(recentTime, 0), 20, 20);
132 134
133 string alignString = " align "+ofToString(currentAlignmentPosition, 2); 135 string alignString = " align "+ofToString(currentAlignmentPosition, 2);
134 alignString += " playing "+ofToString(synchroniser.playingPositionRatio, 5); 136 alignString += " playing "+ofToString(synchroniser.playingPositionRatio, 5);
135 alignString += " "+ofToString(synchroniser.playingPositionMillis)+" ms"; 137 alignString += " pos "+ofToString(synchroniser.playingPositionMillis,0)+" ms";
138 alignString += " rec pos "+ofToString(synchroniser.recordedPositionMillis,0)+" ms";
136 ofDrawBitmapString(alignString, 20, 50); 139 ofDrawBitmapString(alignString, 20, 50);
137 140
138 ofDrawBitmapString("pos "+ofToString(recordedTracks.loadedAudioFiles[0].fileLoader.onsetDetect.playPosition), 200,600); 141 ofDrawBitmapString("pos "+ofToString(recordedTracks.loadedAudioFiles[0].fileLoader.onsetDetect.playPosition), 200,600);
139 } 142 }
140 143