Skip to content

Commit 8f13d6b

Browse files
committed
added /esp/tempoCPU/q and r to external protocol
1 parent 9933273 commit 8f13d6b

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

EspGrid/EspGrid.m

+23-6
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ -(id) init
115115

116116
[osc addHandler:self forAddress:@"/esp/clock/q"];
117117
[osc addHandler:self forAddress:@"/esp/tempo/q"];
118+
[osc addHandler:self forAddress:@"/esp/tempoCPU/q"];
118119
[osc addHandler:[EspBeat beat] forAddress:@"/esp/beat/on"];
119120
[osc addHandler:[EspBeat beat] forAddress:@"/esp/beat/tempo"];
120121
[osc addHandler:[EspChat chat] forAddress:@"/esp/chat/send"];
@@ -222,13 +223,7 @@ -(BOOL) handleOsc:(NSString*)address withParameters:(NSArray*)d fromHost:(NSStri
222223
float tempo = [[beat tempo] floatValue];
223224
EspTimeType time = [beat adjustedDownbeatTime];
224225
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);
229226
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
232227
int seconds = (int)(time / 1000000000);
233228
int nanoseconds = (int)(time % 1000000000);
234229
long n = [[beat downbeatNumber] longValue];
@@ -244,6 +239,28 @@ -(BOOL) handleOsc:(NSString*)address withParameters:(NSArray*)d fromHost:(NSStri
244239
else { postProblem(@"received /esp/tempo/q with too many parameters", self); }
245240
return YES;
246241
}
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+
}
247264

248265
else if([address isEqual:@"/esp/clock/q"])
249266
{

EspGrid/EspGridDefs.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#define ESPGRID_MAJORVERSION 0
2323
#define ESPGRID_MINORVERSION 56 // changes to external/internal protocol MUST increment MINORVERSION
24-
#define ESPGRID_SUBVERSION 2
24+
#define ESPGRID_SUBVERSION 3
2525

2626
#define ESP_NUMBER_OF_OPCODES 10
2727
#define ESP_OPCODE_BEACON 0

EspGridOSX/EspGrid-Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<key>CFBundlePackageType</key>
2222
<string>APPL</string>
2323
<key>CFBundleShortVersionString</key>
24-
<string>0.56.2</string>
24+
<string>0.56.3</string>
2525
<key>CFBundleSignature</key>
2626
<string>????</string>
2727
<key>CFBundleVersion</key>

0 commit comments

Comments
 (0)