Mercurial > hg > multitrack-audio-matcher
comparison src/AccompanimentSynchroniser.cpp @ 55:2eca10a31ae2
improving printing of information, looking at how tempo is modelled
author | Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk> |
---|---|
date | Mon, 10 Dec 2012 17:07:21 +0000 |
parents | 5274e3b5479d |
children |
comparison
equal
deleted
inserted
replaced
54:fe1aab366571 | 55:2eca10a31ae2 |
---|---|
19 reset(); | 19 reset(); |
20 } | 20 } |
21 | 21 |
22 void AccompanimentSynchroniser::reset(){ | 22 void AccompanimentSynchroniser::reset(){ |
23 | 23 |
24 printf("ACC SYNC RESET\n"); | |
24 | 25 |
25 playingPositionRatio = 0; | 26 playingPositionRatio = 0; |
26 playingPositionSamples = 0; | 27 playingPositionSamples = 0; |
27 playingPositionMillis = 0; | 28 playingPositionMillis = 0; |
28 playingPositionTimeSent = 0; | 29 playingPositionTimeSent = 0; |
29 | 30 |
30 recordedPositionMillis = 0; | 31 recordedPositionMillis = 0; |
31 recordedPositionTimeSent = 0; | 32 recordedPositionTimeSent = 0; |
32 | 33 |
33 speed = 1; | 34 speed = 1; |
34 smoothedSpeedOutput = 1; | 35 smoothedSpeedOutput = 1; |
35 difference = 0; | 36 difference = 0; |
37 | |
38 sendSpeed(smoothedSpeedOutput); | |
36 | 39 |
37 } | 40 } |
38 | 41 |
39 void AccompanimentSynchroniser::setPlayingRatio(const double& ratio, const double& timePlayed){ | 42 void AccompanimentSynchroniser::setPlayingRatio(const double& ratio, const double& timePlayed){ |
40 playingPositionRatio = ratio; | 43 playingPositionRatio = ratio; |
52 | 55 |
53 void AccompanimentSynchroniser::updateOutputSpeed(){ | 56 void AccompanimentSynchroniser::updateOutputSpeed(){ |
54 //we want the playing position to more closely align with the recordedPosition | 57 //we want the playing position to more closely align with the recordedPosition |
55 | 58 |
56 | 59 |
57 difference += 0.5*((recordedPositionMillis - playingPositionMillis)-difference); | 60 difference += 0.5*((recordedPositionMillis - playingPositionMillis) - difference); |
58 // difference -= (recordedPositionTimeSent - playingPositionTimeSent); | 61 // difference -= (recordedPositionTimeSent - playingPositionTimeSent); |
59 | 62 |
60 //suppose we project that we will align in 1 seconds time | 63 //suppose we project that we will align in 1 seconds time |
61 double projectedAlignmentTime = 1000; | 64 double projectedAlignmentTime = 1000; |
62 | 65 |
78 counter++; | 81 counter++; |
79 | 82 |
80 } | 83 } |
81 | 84 |
82 void AccompanimentSynchroniser::sendSpeed(double const& val){ | 85 void AccompanimentSynchroniser::sendSpeed(double const& val){ |
83 if (val > -3 && val < 4){ | 86 if (val > -2 && val < 2.){ |
84 ofxOscMessage m; | 87 ofxOscMessage m; |
85 m.setAddress( "/setSpeed" ); | 88 m.setAddress( "/setSpeed" ); |
86 m.addFloatArg( val ); | 89 m.addFloatArg( val ); |
87 sender.sendMessage( m ); | 90 sender.sendMessage( m ); |
88 | 91 |
89 ofxOscMessage z; | 92 ofxOscMessage z; |
90 z.setAddress( "/syncDifference" ); | 93 z.setAddress( "/syncDifference" ); |
91 z.addFloatArg( difference ); | 94 z.addFloatArg( difference ); |
92 sender.sendMessage( z ); | 95 sender.sendMessage( z ); |
96 } else { | |
97 printf("TRY TO SEND START rec pos %f play %f\n", recordedPositionMillis, playingPositionMillis); | |
98 ofxOscMessage z; | |
99 z.setAddress( "/setToSyncPlayingPosition" ); | |
100 z.addFloatArg( recordedPositionMillis ); | |
101 sender.sendMessage( z ); | |
102 sendSpeed(1); | |
103 smoothedSpeedOutput = 1; | |
104 difference = 0; | |
93 } | 105 } |
94 } | 106 } |