| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- (
- // Function to test mobile connection
- ~testMobileConnection = {
- var interfaces, ip; // Declare variables here
- "SuperCollider OSC server info:".postln;
- "Hostname: %".format(Platform.myHostName).postln;
- "Local IP addresses:".postln;
- try {
- interfaces = "ifconfig".unixCmdGetStdOutLines;
- interfaces.do { |line|
- if(line.containsi("inet ") && line.containsStringAt(0, "inet").not, {
- line = line.replace("\t", "").replace(" ", "");
- ip = line.findRegexp("inet([0-9.]+)")[1][1];
- " %".format(ip).postln;
- });
- };
- } { |err|
- "Could not detect network interfaces: %".format(err).postln;
- };
- "OSC Port: 57120".postln;
- "".postln;
- "To connect from a mobile device:".postln;
- "1. Ensure mobile device is on the same WiFi network".postln;
- "2. Use one of the IP addresses above in your mobile OSC app".postln;
- "3. Set the port to 57120".postln;
- };
- // Function to simulate mobile touch for testing without a mobile device
- ~simulateMobileTouch = { |duration=10|
- var endTime = SystemClock.seconds + duration;
- var touchId = 1000;
- "Simulating mobile touch events for % seconds".format(duration).postln;
- // Start the effects chain if needed
- if(~effectsChain.isNil, { ~startEffectsChain.value; });
- // Generate simulated touch events
- fork {
- while { SystemClock.seconds < endTime } {
- var x = 1.0.rand;
- var y = 1.0.rand;
- var pressure = 0.3 + 0.7.rand;
- var state = [\began, \moved, \ended].choose;
- // Create realistic touch sequences
- if(state == \began, {
- touchId = touchId + 1;
- OSCdef(\touchOSC).value(['/touch', touchId, x, y, \began, pressure], nil, nil, nil);
- // Simulate some movement for this touch
- fork {
- var moveCount = rrand(3, 8);
- moveCount.do {
- 0.1.wait;
- // Slight movement from original position
- x = (x + 0.1.rand2).clip(0, 1);
- y = (y + 0.1.rand2).clip(0, 1);
- OSCdef(\touchOSC).value(['/touch', touchId, x, y, \moved, pressure], nil, nil, nil);
- };
- // End the touch
- 0.2.wait;
- OSCdef(\touchOSC).value(['/touch', touchId, x, y, \ended, pressure], nil, nil, nil);
- };
- });
- // Wait random time between new touch events
- rrand(0.2, 1.0).wait;
- };
- "Mobile touch simulation complete".postln;
- };
- };
- // Run these functions directly
- "Mobile connection test functions loaded.".postln;
- "To test connection info, run: ~testMobileConnection.value".postln;
- "To simulate mobile touch events, run: ~simulateMobileTouch.value(20)".postln;
- )
|