Mercurial > hg > multitrack-audio-matcher
comparison src/AudioEventMatcher.cpp @ 15:780def3a1f36
Changed to have any definition - re midi matcher bug fix - and bringing in start and stop functions
author | Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk> |
---|---|
date | Sun, 05 Feb 2012 22:08:50 +0000 |
parents | 0a52258accec |
children | 680ba08e9925 |
comparison
equal
deleted
inserted
replaced
14:0a52258accec | 15:780def3a1f36 |
---|---|
12 | 12 |
13 const int matchWindowWidth = 6000; | 13 const int matchWindowWidth = 6000; |
14 | 14 |
15 AudioEventMatcher::AudioEventMatcher(){ | 15 AudioEventMatcher::AudioEventMatcher(){ |
16 | 16 |
17 | |
18 pitchLikelihoodToNoise = 0.4;//more noise | |
19 onsetLikelihoodToNoise = 0.3; | |
20 onsetLikelihoodWidth = 20;//in ms | |
21 | |
17 setArraySizes(); | 22 setArraySizes(); |
18 | 23 |
19 usingRealTime = false; | 24 usingRealTime = false; |
20 bayesianStruct.realTimeMode = &usingRealTime; | 25 bayesianStruct.realTimeMode = &usingRealTime; |
21 recentPitch = 0; | 26 recentPitch = 0; |
22 currentAlignmentPosition = 0; | 27 currentAlignmentPosition = 0; |
23 | 28 |
24 onsetLikelihoodWidth = 20; | 29 |
25 | 30 |
26 followingLiveInput = true; | 31 followingLiveInput = true; |
32 startedPlaying = false; | |
27 } | 33 } |
28 | 34 |
29 | 35 |
30 void AudioEventMatcher::setWindowDimensions(){ | 36 void AudioEventMatcher::setWindowDimensions(){ |
31 double startHeight = recordedTracks.numberOfAudioTracks * recordedTracks.trackScreenHeight; | 37 double startHeight = recordedTracks.numberOfAudioTracks * recordedTracks.trackScreenHeight; |
54 bayesianStruct.setStartPlaying(); | 60 bayesianStruct.setStartPlaying(); |
55 currentAlignmentPosition = 0; | 61 currentAlignmentPosition = 0; |
56 startTime = ofGetElapsedTimeMillis(); | 62 startTime = ofGetElapsedTimeMillis(); |
57 | 63 |
58 projectedPrior = bayesianStruct.prior; | 64 projectedPrior = bayesianStruct.prior; |
65 startedPlaying = true; | |
59 //bayesianStruct.posterior.printArray(); | 66 //bayesianStruct.posterior.printArray(); |
60 } | 67 } |
61 | 68 |
69 | |
70 void AudioEventMatcher::stopPlaying(){ | |
71 startedPlaying = false; | |
72 } | |
62 | 73 |
63 void AudioEventMatcher::updatePosition(){ | 74 void AudioEventMatcher::updatePosition(){ |
64 if (!followingLiveInput) | 75 if (!followingLiveInput) |
65 recordedTracks.updatePosition(); | 76 recordedTracks.updatePosition(); |
66 else | 77 else if (startedPlaying) |
67 recordedTracks.updatePositionToMillis(currentAlignmentPosition); | 78 recordedTracks.updatePositionToMillis(currentAlignmentPosition); |
68 | 79 |
69 updateBestAlignmentPosition(); | 80 updateBestAlignmentPosition(); |
70 } | 81 } |
71 | 82 |
226 void AudioEventMatcher::matchNewOnsetEvent(const int& channel, const double& timeIn){ | 237 void AudioEventMatcher::matchNewOnsetEvent(const int& channel, const double& timeIn){ |
227 | 238 |
228 bayesianStruct.updateBayesianDistributions(timeIn);//moves the posterior up into prior given the time interval and calculates new offsets | 239 bayesianStruct.updateBayesianDistributions(timeIn);//moves the posterior up into prior given the time interval and calculates new offsets |
229 | 240 |
230 //start at beginning but OPTIMISE later | 241 //start at beginning but OPTIMISE later |
231 double onsetLikelihoodToNoise = 0.3; | 242 |
232 | 243 |
233 bayesianStruct.likelihood.offset = bayesianStruct.prior.offset; | 244 bayesianStruct.likelihood.offset = bayesianStruct.prior.offset; |
234 bayesianStruct.likelihood.zero();//set to zero | 245 bayesianStruct.likelihood.zero();//set to zero |
235 | 246 |
236 double quantity = 1;//likelihoodToNoiseRatio / numberOfMatches; | 247 double quantity = 1;//likelihoodToNoiseRatio / numberOfMatches; |
280 */ | 291 */ |
281 bayesianStruct.updateBayesianDistributions(timeIn);//moves the posterior up into prior given the time interval and calculates new offsets | 292 bayesianStruct.updateBayesianDistributions(timeIn);//moves the posterior up into prior given the time interval and calculates new offsets |
282 | 293 |
283 //set the lielihoods by matching the pitched note | 294 //set the lielihoods by matching the pitched note |
284 | 295 |
285 double pitchLikelihoodToNoise = 0.7;//more noise | 296 |
286 int numberOfMatches = 0; | 297 int numberOfMatches = 0; |
287 bayesianStruct.likelihood.zero();//set to zero | 298 bayesianStruct.likelihood.zero();//set to zero |
288 | 299 |
289 double quantity = 0; | 300 double quantity = 0; |
290 if (channel <= recordedTracks.numberOfAudioTracks){ | 301 if (channel <= recordedTracks.numberOfAudioTracks){ |