|
|
|
@ -12,13 +12,13 @@ dirTuples, dirAdjustRoutine, dirTuplesSeq;
|
|
|
|
|
|
|
|
|
|
// init global vars
|
|
|
|
|
imgPositions = 9.collect({nil});
|
|
|
|
|
imgIndexToAudioIndex = [0, 1, nil, 2, nil, 3, nil, 4, 5];
|
|
|
|
|
imgIndexToAudioIndex = [0, 1, -1, 2, -1, 3, -1, 4, 5];
|
|
|
|
|
curPos = Point.new(0, 0);
|
|
|
|
|
tarPos = Point.new(0, 0);
|
|
|
|
|
netAddress = NetAddr.new("127.0.0.1", 8080);
|
|
|
|
|
localAddress = NetAddr.new("127.0.0.1", 57120);
|
|
|
|
|
lastSelect = -1;
|
|
|
|
|
trackerOffsetBaseDist = 16000;
|
|
|
|
|
trackerOffsetBaseDist = 12000;
|
|
|
|
|
trackerOffset = [
|
|
|
|
|
[trackerOffsetBaseDist * 1, trackerOffsetBaseDist * 1],
|
|
|
|
|
[trackerOffsetBaseDist * 0, trackerOffsetBaseDist * 1],
|
|
|
|
@ -57,16 +57,24 @@ dirTuples = [ [ -1, -1 ], [ -1, 0 ], [ -1, 1 ], [ 0, -1 ], [ 0, 1 ], [ 1, -1 ],
|
|
|
|
|
safeMode = false;
|
|
|
|
|
fork {
|
|
|
|
|
netAddress.sendMsg("/STATE/SET", "{message: \"all clear\"}");
|
|
|
|
|
netAddress.sendMsg("/STATE/SET", "{message_sub: \"all clear\"}");
|
|
|
|
|
netAddress.sendMsg("/STATE/SET", "{message_public: \"all clear\"}");
|
|
|
|
|
2.wait;
|
|
|
|
|
netAddress.sendMsg("/STATE/SET", "{message: \"\"}");
|
|
|
|
|
netAddress.sendMsg("/STATE/SET", "{message_sub: \"\"}");
|
|
|
|
|
netAddress.sendMsg("/STATE/SET", "{message_public: \"\"}");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}, {
|
|
|
|
|
if(str[1..3].asString == "!!!", {
|
|
|
|
|
netAddress.sendMsg("/STATE/SET", "{message: \"!!! limit switch still on after 1000 steps, this should NEVER happen\"}");
|
|
|
|
|
netAddress.sendMsg("/STATE/SET", "{message_sub: \"!!! limit switch still on after 1000 steps, this should NEVER happen\"}");
|
|
|
|
|
netAddress.sendMsg("/STATE/SET", "{message_public: \"!!! limit switch still on after 1000 steps, this should NEVER happen\"}");
|
|
|
|
|
}, {
|
|
|
|
|
safeMode = true;
|
|
|
|
|
netAddress.sendMsg("/STATE/SET", "{message: \"!! limit hit, move the other direction\"}");
|
|
|
|
|
netAddress.sendMsg("/STATE/SET", "{message_sub: \"!! limit hit, move the other direction\"}");
|
|
|
|
|
netAddress.sendMsg("/STATE/SET", "{message_public: \"!! limit hit, move the other direction\"}");
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
str = "";
|
|
|
|
@ -124,23 +132,34 @@ imgSelect = {
|
|
|
|
|
netAddress.sendMsg("/STATE/SET", "{img_" ++ (i + 1).asString ++ "_select: " ++ (i + 1).neg ++ "}")})});
|
|
|
|
|
lastSelect = imgIndex;
|
|
|
|
|
audioIndex = imgIndexToAudioIndex[imgIndex];
|
|
|
|
|
if(audioIndex != nil, {localAddress.sendMsg('/playTiling', audioIndex)});
|
|
|
|
|
dirTuplesSeq = dirTuples.deepCopy.scramble.collect({arg tup; [tup, tup * -1]}).flatten;
|
|
|
|
|
//if(audioIndex != nil, {localAddress.sendMsg('/playTiling', audioIndex)});
|
|
|
|
|
localAddress.sendMsg('/playTiling', audioIndex);
|
|
|
|
|
dirTuplesSeq = 2.collect({dirTuples.deepCopy.scramble.collect({arg tup; [tup, tup * -1]}).flatten}).flatten;
|
|
|
|
|
dirAdjustRoutine = Routine({
|
|
|
|
|
180.wait;
|
|
|
|
|
120.wait;
|
|
|
|
|
imgPositions[imgIndex] = curPos.deepCopy;
|
|
|
|
|
trackLock = true;
|
|
|
|
|
10.wait;
|
|
|
|
|
8.do({arg dirAdjust;
|
|
|
|
|
//10.wait;
|
|
|
|
|
100.do({arg dirAdjust;
|
|
|
|
|
"here".postln;
|
|
|
|
|
tarPos = imgPositions[imgIndex].deepCopy + (dirTuplesSeq[dirAdjust] * 200);
|
|
|
|
|
moveTo.value(tarPos);
|
|
|
|
|
2.wait;
|
|
|
|
|
trackLock = false;
|
|
|
|
|
10.wait;
|
|
|
|
|
trackLock = true;
|
|
|
|
|
5.wait;
|
|
|
|
|
if(dirAdjust < 8, {
|
|
|
|
|
tarPos = imgPositions[imgIndex].deepCopy + (dirTuplesSeq[dirAdjust] * 200);
|
|
|
|
|
moveTo.value(tarPos);
|
|
|
|
|
3.wait;
|
|
|
|
|
trackLock = false;
|
|
|
|
|
15.wait;
|
|
|
|
|
trackLock = true;
|
|
|
|
|
//3.wait;
|
|
|
|
|
}, {
|
|
|
|
|
trackLock = false;
|
|
|
|
|
15.wait;
|
|
|
|
|
trackLock = true;
|
|
|
|
|
15.wait;
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
trackLock = false;
|
|
|
|
|
//20.wait;
|
|
|
|
|
//trackLock = true;
|
|
|
|
|
}).play;
|
|
|
|
|
}, {
|
|
|
|
|
//lastSelect.postln;
|
|
|
|
@ -160,7 +179,7 @@ imgCalibrate = {
|
|
|
|
|
20.do({0.1.wait});
|
|
|
|
|
[-1, 0, 1].do({arg row;
|
|
|
|
|
[-1, 0, 1].do({arg col;
|
|
|
|
|
imgPositions[imageCalibrationIndex] = setPos.deepCopy + Point.new(6550 * col, 6550 * row);
|
|
|
|
|
imgPositions[imageCalibrationIndex] = setPos.deepCopy + Point.new(6700 * col, 6700 * row);
|
|
|
|
|
imgPositions[imageCalibrationIndex].postln;
|
|
|
|
|
imageCalibrationIndex = imageCalibrationIndex + 1;
|
|
|
|
|
});
|
|
|
|
@ -168,6 +187,8 @@ imgCalibrate = {
|
|
|
|
|
|
|
|
|
|
imgPositions.postln;
|
|
|
|
|
netAddress.sendMsg("/STATE/SET", "{message: \"image calibrated\"}");
|
|
|
|
|
netAddress.sendMsg("/STATE/SET", "{message_sub: \"image calibrated\"}");
|
|
|
|
|
netAddress.sendMsg("/STATE/SET", "{message_public: \"image calibrated\"}");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
OSCFunc({ arg msg;
|
|
|
|
@ -176,7 +197,11 @@ imgCalibrate = {
|
|
|
|
|
setPos = curPos.deepCopy;
|
|
|
|
|
calibrateHold.play(AppClock);
|
|
|
|
|
}, {
|
|
|
|
|
calibrateHold.stop; calibrateHold.reset; netAddress.sendMsg("/STATE/SET", "{message: \"\"}");
|
|
|
|
|
calibrateHold.stop;
|
|
|
|
|
calibrateHold.reset;
|
|
|
|
|
netAddress.sendMsg("/STATE/SET", "{message: \"\"}");
|
|
|
|
|
netAddress.sendMsg("/STATE/SET", "{message_sub: \"\"}");
|
|
|
|
|
netAddress.sendMsg("/STATE/SET", "{message_public: \"\"}");
|
|
|
|
|
});
|
|
|
|
|
}, '/img_calibrate', netAddress);
|
|
|
|
|
}.value;
|
|
|
|
@ -187,11 +212,11 @@ trackerPos = OSCFunc({arg msg;
|
|
|
|
|
distX = curPos.x - imgPositions[lastSelect].x;
|
|
|
|
|
distY = curPos.y - imgPositions[lastSelect].y;
|
|
|
|
|
isFocusing = false;
|
|
|
|
|
if((imgPositions[lastSelect] != nil) && (distX.abs < 300) && ((msg[1] - trackerOffset[lastSelect][0]).abs > 3000), {
|
|
|
|
|
if((imgPositions[lastSelect] != nil) && (distX.abs < 350) && ((msg[1] - trackerOffset[lastSelect][0]).abs > 3000), {
|
|
|
|
|
tarPos.x = curPos.x + (10 * (msg[1] - trackerOffset[lastSelect][0]).sign);// * -1);
|
|
|
|
|
isFocusing = true;
|
|
|
|
|
});
|
|
|
|
|
if((imgPositions[lastSelect] != nil) && (distY.abs < 300) && ((msg[2] - trackerOffset[lastSelect][1]).abs > 3000), {
|
|
|
|
|
if((imgPositions[lastSelect] != nil) && (distY.abs < 350) && ((msg[2] - trackerOffset[lastSelect][1]).abs > 3000), {
|
|
|
|
|
tarPos.y = curPos.y + (10 * (msg[2] - trackerOffset[lastSelect][1]).sign);// * -1);
|
|
|
|
|
isFocusing = true;
|
|
|
|
|
});
|
|
|
|
|