@@ -115,6 +115,7 @@ -(id) init
115
115
116
116
[osc addHandler: self forAddress: @" /esp/clock/q" ];
117
117
[osc addHandler: self forAddress: @" /esp/tempo/q" ];
118
+ [osc addHandler: self forAddress: @" /esp/tempoCPU/q" ];
118
119
[osc addHandler: [EspBeat beat ] forAddress: @" /esp/beat/on" ];
119
120
[osc addHandler: [EspBeat beat ] forAddress: @" /esp/beat/tempo" ];
120
121
[osc addHandler: [EspChat chat ] forAddress: @" /esp/chat/send" ];
@@ -222,13 +223,7 @@ -(BOOL) handleOsc:(NSString*)address withParameters:(NSArray*)d fromHost:(NSStri
222
223
float tempo = [[beat tempo ] floatValue ];
223
224
EspTimeType time = [beat adjustedDownbeatTime ];
224
225
EspTimeType monotonicToSystem = systemTime () - monotonicTime ();
225
- // NSLog(@"beat time on HPC is %lld",time);
226
- // NSLog(@"system time is approx. %lld",systemTime());
227
- // NSLog(@"HPC time is approx %lld",monotonicTime());
228
- // NSLog(@"diff is %lld",monotonicToSystem);
229
226
time += monotonicToSystem; // translate high performance time into epoch of normal system clock
230
- // NSLog(@"adjusted beat time is %lld",time);
231
- // later there should be a variant of /esp/tempo/q that requests high performance time
232
227
int seconds = (int )(time / 1000000000 );
233
228
int nanoseconds = (int )(time % 1000000000 );
234
229
long n = [[beat downbeatNumber ] longValue ];
@@ -244,6 +239,28 @@ -(BOOL) handleOsc:(NSString*)address withParameters:(NSArray*)d fromHost:(NSStri
244
239
else { postProblem (@" received /esp/tempo/q with too many parameters" , self); }
245
240
return YES ;
246
241
}
242
+
243
+ else if ([address isEqual: @" /esp/tempoCPU/q" ])
244
+ {
245
+ EspBeat* beat = [EspBeat beat ];
246
+ BOOL on = [[beat on ] boolValue ];
247
+ float tempo = [[beat tempo ] floatValue ];
248
+ EspTimeType time = [beat adjustedDownbeatTime ];
249
+ int seconds = (int )(time / 1000000000 );
250
+ int nanoseconds = (int )(time % 1000000000 );
251
+ long n = [[beat downbeatNumber ] longValue ];
252
+ NSArray * msg = [NSArray arrayWithObjects: @" /esp/tempoCPU/r" ,
253
+ [NSNumber numberWithInt: on],
254
+ [NSNumber numberWithFloat: tempo],
255
+ [NSNumber numberWithInt: seconds],
256
+ [NSNumber numberWithInt: nanoseconds],
257
+ [NSNumber numberWithInt: (int )n],nil ];
258
+ if ([d count ] == 0 ) [osc transmit: msg toHost: h port: p log :NO ]; // respond directly to host and port of incoming msg
259
+ else if ([d count ] == 1 ) [osc transmit: msg toHost: h port: [[d objectAtIndex: 0 ] intValue ] log :NO ]; // explicit port, deduced host
260
+ else if ([d count ] == 2 ) [osc transmit: msg toHost: [d objectAtIndex: 1 ] port: [[d objectAtIndex: 0 ] intValue ] log :NO ]; // explicit port+host
261
+ else { postProblem (@" received /esp/tempo/q with too many parameters" , self); }
262
+ return YES ;
263
+ }
247
264
248
265
else if ([address isEqual: @" /esp/clock/q" ])
249
266
{
0 commit comments