|
@@ -6,9 +6,9 @@
|
|
|
OSCdef.freeAll;
|
|
OSCdef.freeAll;
|
|
|
|
|
|
|
|
// Variables to track current pen type and color
|
|
// Variables to track current pen type and color
|
|
|
-~currentPenType = \pen;
|
|
|
|
|
|
|
+~currentPenType = "\pen";
|
|
|
~currentColor = (r: 0.0, g: 0.0, b: 1.0); // Default blue
|
|
~currentColor = (r: 0.0, g: 0.0, b: 1.0); // Default blue
|
|
|
-~currentPadValues = (x: 0.0, y: 0.0, pressure: 1.0); //Default pad values
|
|
|
|
|
|
|
+~currentPadValues = (x: 0.0, y: 0.0, pressure: 1.0, a: 1); //Default pad values
|
|
|
|
|
|
|
|
|
|
|
|
|
// Define OSC responder for iDraw touch data
|
|
// Define OSC responder for iDraw touch data
|
|
@@ -16,9 +16,10 @@ OSCdef.freeAll;
|
|
|
var x = ~currentPadValues.x;
|
|
var x = ~currentPadValues.x;
|
|
|
var y = ~currentPadValues.y;
|
|
var y = ~currentPadValues.y;
|
|
|
var pressure = ~currentPadValues.pressure;
|
|
var pressure = ~currentPadValues.pressure;
|
|
|
|
|
+ var a = ~currentPadValues.a;
|
|
|
|
|
|
|
|
// Log the received data
|
|
// Log the received data
|
|
|
- ["Touch data:", x, y, pressure, ~currentPenType, ~currentColor].postln;
|
|
|
|
|
|
|
+ //["Touch data:", x, y, pressure, ~currentPenType, ~currentColor].postln;
|
|
|
|
|
|
|
|
// Handle touch based on current pen type
|
|
// Handle touch based on current pen type
|
|
|
switch(~currentPenType,
|
|
switch(~currentPenType,
|
|
@@ -30,38 +31,43 @@ OSCdef.freeAll;
|
|
|
~setSynthsParam.(\ampAttack, ampAttack);
|
|
~setSynthsParam.(\ampAttack, ampAttack);
|
|
|
~setSynthsParam.(\ampRelease, ampRelease);
|
|
~setSynthsParam.(\ampRelease, ampRelease);
|
|
|
|
|
|
|
|
- ["Amplitude envelope:", ampAttack, ampRelease].postln;
|
|
|
|
|
|
|
+ //["Amplitude envelope:", ampAttack, ampRelease].postln;
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
// Monoline - Controls filter envelope
|
|
// Monoline - Controls filter envelope
|
|
|
"/monoline", {
|
|
"/monoline", {
|
|
|
var filterAttack = y.linexp(-0.5, 0.5, 0.001, 5);
|
|
var filterAttack = y.linexp(-0.5, 0.5, 0.001, 5);
|
|
|
- var filterRelease = x.linexp(-0.5, 0.5, 0.001, 10);
|
|
|
|
|
|
|
+ var filterDecay = x.linexp(-0.5, 0.5, 0.001, 10);
|
|
|
|
|
+ var envDepth = a.linlin(0, 1, 50, 0.001);
|
|
|
|
|
|
|
|
- ~setSynthsParam.(\filterAttack, filterAttack);
|
|
|
|
|
- ~setSynthsParam.(\filterRelease, filterRelease);
|
|
|
|
|
|
|
+ ~filterEnv.set(\attack, filterAttack);
|
|
|
|
|
+ ~filterEnv.set(\decay, filterDecay);
|
|
|
|
|
+ ~filter.set(\envDepth, envDepth);
|
|
|
|
|
|
|
|
- ["Filter envelope:", filterAttack, filterRelease].postln;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ //["Filter envelope:", filterAttack, filterDecay, envDepth].postln;
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
// Marker - Controls pitch envelope
|
|
// Marker - Controls pitch envelope
|
|
|
"/marker", {
|
|
"/marker", {
|
|
|
var pitchAttack = y.linexp(-0.5, 0.5, 0.001, 5);
|
|
var pitchAttack = y.linexp(-0.5, 0.5, 0.001, 5);
|
|
|
- var pitchRelease = x.linexp(-0.5, 0.5, 0.001, 10);
|
|
|
|
|
|
|
+ var pitchDecay = x.linexp(-0.5, 0.5, 0.001, 10);
|
|
|
|
|
+ var pitchRatio = a.linexp(0, 1, 10, 1);
|
|
|
|
|
|
|
|
~setSynthsParam.(\pitchAttack, pitchAttack);
|
|
~setSynthsParam.(\pitchAttack, pitchAttack);
|
|
|
- ~setSynthsParam.(\pitchRelease, pitchRelease);
|
|
|
|
|
|
|
+ ~setSynthsParam.(\pitchDecay, pitchDecay);
|
|
|
|
|
+ ~setSynthsParam.(\pitchRatio, pitchRatio);
|
|
|
|
|
|
|
|
- ["Pitch envelope:", pitchAttack, pitchRelease].postln;
|
|
|
|
|
|
|
+ //["Pitch envelope:", pitchAttack, pitchDecay, pitchRatio].postln;
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
// Pencil - Effect preset 1
|
|
// Pencil - Effect preset 1
|
|
|
"/pencil", {
|
|
"/pencil", {
|
|
|
// Apply Preset 1 effects
|
|
// Apply Preset 1 effects
|
|
|
~filter.set(
|
|
~filter.set(
|
|
|
- \cutoff, x.linexp(-0.5, 0.5, 20, 18000),
|
|
|
|
|
|
|
+ \cutoff, x.linexp(-0.5, 0.5, 100, 18000),
|
|
|
\resonance, y.linlin(-0.5, 0.5, 0, 1),
|
|
\resonance, y.linlin(-0.5, 0.5, 0, 1),
|
|
|
- \lfoDepth, pressure.linlin(1, 8, 0, 3)
|
|
|
|
|
|
|
+ \lfoDepth, pressure.linlin(1, 8, 0, 4)
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
~lfo.set(
|
|
~lfo.set(
|
|
@@ -69,44 +75,50 @@ OSCdef.freeAll;
|
|
|
\waveform, 2
|
|
\waveform, 2
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
|
|
+ ~ctl.set(9, y.linlin(-0.5, 0.5, 0, 1));
|
|
|
|
|
|
|
|
- /*
|
|
|
|
|
- ~reverbSynth.set(
|
|
|
|
|
- \roomsize, y.linlin(-0.5, 0.5, 0.1, 0.9)
|
|
|
|
|
- );
|
|
|
|
|
- */
|
|
|
|
|
-
|
|
|
|
|
- ["Pencil preset:", "Cutoff", x.linexp(-0.5, 0.5, 20, 18000), "LFO", x.linlin(-0.5, 0.5, 0, 15)].postln;
|
|
|
|
|
|
|
+ //["Pencil preset:", "Cutoff", x.linexp(-0.5, 0.5, 20, 18000), "LFO", x.linlin(-0.5, 0.5, 0, 15)].postln;
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
// Crayon - Effect preset 2
|
|
// Crayon - Effect preset 2
|
|
|
"/crayon", {
|
|
"/crayon", {
|
|
|
// Apply Preset 2 effects
|
|
// Apply Preset 2 effects
|
|
|
- ~lfoSynth.set(
|
|
|
|
|
|
|
+ ~lfo.set(
|
|
|
\freq, x.linlin(-0.5, 0.5, 15, 1),
|
|
\freq, x.linlin(-0.5, 0.5, 15, 1),
|
|
|
- \intensity, x.linlin(-0.5, 0.5, 0, 1)
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- ~delaySynth.set(
|
|
|
|
|
- \delaytime, x.linlin(-0.5, 0.5, 0.01, 1.0)
|
|
|
|
|
|
|
+ \waveform, 3
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
- ~filterSynth.set(
|
|
|
|
|
|
|
+ ~filter.set(
|
|
|
\cutoff, y.linexp(-0.5, 0.5, 20, 18000),
|
|
\cutoff, y.linexp(-0.5, 0.5, 20, 18000),
|
|
|
- \res, pressure.linlin(1, 5, 0, 1)
|
|
|
|
|
|
|
+ \resonance, pressure.linlin(1, 5, 0, 1),
|
|
|
|
|
+ \lfoDepth, x.linlin(-0.5, 0.5, 0, 3)
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
- ~reverbSynth.set(
|
|
|
|
|
- \mix, y.linlin(-0.5, 0.5, 0, 1)
|
|
|
|
|
- );
|
|
|
|
|
|
|
|
|
|
- ["Crayon preset:", "LFO", x.linlin(-0.5, 0.5, 15, 1), "Filter", y.linexp(-0.5, 0.5, 20, 18000)].postln;
|
|
|
|
|
|
|
+ ~ctl.set(10, y.linlin(-0.5, 0.5, 0, 1)); // Reverb dry/wet
|
|
|
|
|
+
|
|
|
|
|
+ ~ctl.set(8, x.linlin(-0.5, 0.5, 0.001, 1.0)); // Delay amount
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //["Crayon preset:", "LFO", x.linlin(-0.5, 0.5, 15, 1), "Filter", y.linexp(-0.5, 0.5, 20, 18000)].postln;
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
// Fountain pen - Effect preset 3 (placeholder)
|
|
// Fountain pen - Effect preset 3 (placeholder)
|
|
|
"/fountainPen", {
|
|
"/fountainPen", {
|
|
|
- // Apply Preset 3 effects (TBD in documentation)
|
|
|
|
|
- ["Fountain pen preset (TBD)"].postln;
|
|
|
|
|
|
|
+ // Apply Preset 3 effects
|
|
|
|
|
+ ~lfo.set(
|
|
|
|
|
+ \freq, x.linlin(-0.5, 0.5, 1, 15),
|
|
|
|
|
+ \waveform, 0
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ ~filter.set(
|
|
|
|
|
+ \lfoDepth, 0
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ ~setSynthsParam.(\lfoDepth, pressure.linlin(1, 5, 0, 0.5));
|
|
|
|
|
+
|
|
|
|
|
+ //["fountainPen preset:", "LFO Depth", pressure.linlin(1, 5, 0, 0.5), "LFO Freq", x.linlin(-0.5, 0.5, 1, 15)].postln;
|
|
|
|
|
+
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
// Water color - Effect preset 4 (placeholder)
|
|
// Water color - Effect preset 4 (placeholder)
|
|
@@ -237,6 +249,14 @@ OSCdef(\waterColorOSC, { |msg, time, addr, port|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+// ----- OSC Drawing Width -----
|
|
|
|
|
+OSCdef(\opacityOSC, { |msg, time, addr, port|
|
|
|
|
|
+ var a = msg[1].asFloat;
|
|
|
|
|
+ ~currentPadValues.a = a;
|
|
|
|
|
+
|
|
|
|
|
+}, '/a');
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
// ----- OSC RGB Colors -----
|
|
// ----- OSC RGB Colors -----
|
|
|
// OSC responder for red changes
|
|
// OSC responder for red changes
|
|
|
OSCdef(\redOSC, { |msg, time, addr, port|
|
|
OSCdef(\redOSC, { |msg, time, addr, port|
|
|
@@ -246,7 +266,7 @@ OSCdef(\redOSC, { |msg, time, addr, port|
|
|
|
~currentColor.r = component;
|
|
~currentColor.r = component;
|
|
|
~setSynthsParam.(\redAmt, component);
|
|
~setSynthsParam.(\redAmt, component);
|
|
|
|
|
|
|
|
- ["Color changed:", ~currentColor].postln;
|
|
|
|
|
|
|
+ //["Color changed:", ~currentColor].postln;
|
|
|
}, '/r');
|
|
}, '/r');
|
|
|
|
|
|
|
|
// OSC responder for green changes
|
|
// OSC responder for green changes
|
|
@@ -257,7 +277,7 @@ OSCdef(\greenOSC, { |msg, time, addr, port|
|
|
|
~currentColor.g = component;
|
|
~currentColor.g = component;
|
|
|
~setSynthsParam.(\greenAmt, component);
|
|
~setSynthsParam.(\greenAmt, component);
|
|
|
|
|
|
|
|
- ["Color changed:", ~currentColor].postln;
|
|
|
|
|
|
|
+ //["Color changed:", ~currentColor].postln;
|
|
|
}, '/g');
|
|
}, '/g');
|
|
|
|
|
|
|
|
// OSC responder for blue changes
|
|
// OSC responder for blue changes
|
|
@@ -268,7 +288,7 @@ OSCdef(\blueOSC, { |msg, time, addr, port|
|
|
|
~currentColor.b = component;
|
|
~currentColor.b = component;
|
|
|
~setSynthsParam.(\blueAmt, component);
|
|
~setSynthsParam.(\blueAmt, component);
|
|
|
|
|
|
|
|
- ["Color changed:", ~currentColor].postln;
|
|
|
|
|
|
|
+ //["Color changed:", ~currentColor].postln;
|
|
|
}, '/b');
|
|
}, '/b');
|
|
|
|
|
|
|
|
|
|
|
|
@@ -278,6 +298,5 @@ OSCdef(\blueOSC, { |msg, time, addr, port|
|
|
|
// Start the OSC server on port 57120 (default SuperCollider port)
|
|
// Start the OSC server on port 57120 (default SuperCollider port)
|
|
|
thisProcess.openUDPPort(57120);
|
|
thisProcess.openUDPPort(57120);
|
|
|
"OSC server ready on port 57120".postln;
|
|
"OSC server ready on port 57120".postln;
|
|
|
-"Registered OSC commands: /touch, /pen, /color".postln;
|
|
|
|
|
"Ready to receive data from iDraw OSC app".postln;
|
|
"Ready to receive data from iDraw OSC app".postln;
|
|
|
)
|
|
)
|