( // Function to test iDraw OSC connection ~testiDrawConnection = { var interfaces, ip; // Log local IP and port information "SuperCollider OSC server info for iDraw OSC connection:".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; }; // Alternate way to find IP addresses that might work better on some systems "Alternative method to find IP addresses:".postln; try { thisProcess.platform.getNetworkNameList.do { |netname| var addr = netname.findRegexp("\\d+\\.\\d+\\.\\d+\\.\\d+"); if(addr.size > 0, { " %".format(addr[0][1]).postln; }); }; } { |err| "Could not use network name list method: %".format(err).postln; }; "OSC Port: 57120".postln; "".postln; "To connect from iDraw OSC:".postln; "1. Ensure iPad/iPhone is on the same WiFi network".postln; "2. Open iDraw OSC app".postln; "3. Set the host/IP to one of the above addresses".postln; "4. Set the port to 57120".postln; "5. Ensure iDraw OSC is sending messages with these addresses:".postln; " - /touch (x, y, pressure)".postln; " - /pen (pen type)".postln; " - /color (r, g, b)".postln; }; // Function to simulate iDraw OSC messages for testing ~simulateiDrawTouch = { |duration=10| var endTime, penTypes, penType, r, g, b; endTime = SystemClock.seconds + duration; "Simulating iDraw OSC touch events for % seconds".format(duration).postln; // Start the effects chain if needed if(~effectsChain.isNil, { ~startEffectsChain.value; }); // First set a pen type penTypes = [\pen, \monoline, \marker, \pencil, \crayon, \fountainPen, \waterColor]; penType = penTypes.choose; OSCdef(\penTypeOSC).value(['/pen', penType], nil, nil, nil); // Set a random color r = 1.0.rand; g = 1.0.rand; b = 1.0.rand; OSCdef(\colorOSC).value(['/color', r, g, b], nil, nil, nil); // Generate simulated touch events fork { while { SystemClock.seconds < endTime } { var x = (-0.5 + 1.0.rand); var y = (-0.5 + 1.0.rand); var pressure = 1 + 7.rand; // Send touch message OSCdef(\touchOSC).value(['/touch', x, y, pressure], nil, nil, nil); // Wait random time between touch events rrand(0.1, 0.3).wait; // Occasionally change pen type or color if(0.1.coin, { penType = penTypes.choose; OSCdef(\penTypeOSC).value(['/pen', penType], nil, nil, nil); "Changed to pen type: %".format(penType).postln; }); if(0.1.coin, { r = 1.0.rand; g = 1.0.rand; b = 1.0.rand; OSCdef(\colorOSC).value(['/color', r, g, b], nil, nil, nil); "Changed to color: % % %".format(r, g, b).postln; }); }; "iDraw OSC simulation complete".postln; }; }; // Run these functions directly "iDraw OSC connection test functions loaded.".postln; "To test connection info, run: ~testiDrawConnection.value".postln; "To simulate iDraw OSC events, run: ~simulateiDrawTouch.value(20)".postln; )