|
@@ -1,4 +1,4 @@
|
|
|
-// Module 5: OSC Communication Setup with Integrated Synth Pool
|
|
|
|
|
|
|
+// Module 5: OSC Communication Setup with ROBUST Synth Pool
|
|
|
// Save as "5_osc_communication.scd" (REPLACE PREVIOUS VERSION)
|
|
// Save as "5_osc_communication.scd" (REPLACE PREVIOUS VERSION)
|
|
|
|
|
|
|
|
(
|
|
(
|
|
@@ -34,104 +34,172 @@ OSCdef.freeAll;
|
|
|
blueAmt: 0.5
|
|
blueAmt: 0.5
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
-// ========== SYNTH POOL SYSTEM ==========
|
|
|
|
|
|
|
+// ========== ROBUST SYNTH POOL SYSTEM ==========
|
|
|
// Synth Pool Configuration
|
|
// Synth Pool Configuration
|
|
|
~poolSize = 16; // Number of pre-allocated synths
|
|
~poolSize = 16; // Number of pre-allocated synths
|
|
|
-~synthPool = ();
|
|
|
|
|
|
|
+~synthPool = Array.newClear(~poolSize); // Array instead of dictionary
|
|
|
~activeSynths = IdentityDictionary.new; // Track which synths are in use
|
|
~activeSynths = IdentityDictionary.new; // Track which synths are in use
|
|
|
-~freePool = Array.new(~poolSize); // Available synths
|
|
|
|
|
|
|
+~freeIndices = Array.series(~poolSize); // Available synth indices
|
|
|
~synthPoolGroup = nil;
|
|
~synthPoolGroup = nil;
|
|
|
|
|
+~poolInitialized = false;
|
|
|
|
|
|
|
|
-// Initialize the synth pool
|
|
|
|
|
-~initializeSynthPool = {
|
|
|
|
|
- // Clean up existing pool first
|
|
|
|
|
|
|
+// Clean up existing pool completely
|
|
|
|
|
+~cleanupSynthPool = {
|
|
|
|
|
+ "Cleaning up synth pool...".postln;
|
|
|
|
|
+
|
|
|
|
|
+ // Set flag
|
|
|
|
|
+ ~poolInitialized = false;
|
|
|
|
|
+
|
|
|
|
|
+ // Return all active synths
|
|
|
|
|
+ ~activeSynths.keys.do({ |key|
|
|
|
|
|
+ try {
|
|
|
|
|
+ ~returnSynthToPool.value(key);
|
|
|
|
|
+ } { |error|
|
|
|
|
|
+ // Silent cleanup - don't print errors during cleanup
|
|
|
|
|
+ };
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // Free the group (this frees all synths)
|
|
|
if(~synthPoolGroup.notNil, {
|
|
if(~synthPoolGroup.notNil, {
|
|
|
- ~synthPoolGroup.free;
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ ~synthPoolGroup.free;
|
|
|
|
|
+ } { |error|
|
|
|
|
|
+ // Silent cleanup
|
|
|
|
|
+ };
|
|
|
|
|
+ ~synthPoolGroup = nil;
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
// Clear data structures
|
|
// Clear data structures
|
|
|
- ~synthPool.clear;
|
|
|
|
|
|
|
+ ~synthPool = Array.newClear(~poolSize);
|
|
|
~activeSynths.clear;
|
|
~activeSynths.clear;
|
|
|
- ~freePool.clear;
|
|
|
|
|
|
|
+ ~freeIndices = Array.series(~poolSize);
|
|
|
|
|
+
|
|
|
|
|
+ // Reset touch state
|
|
|
|
|
+ ~touchState.isActive = false;
|
|
|
|
|
+ ~touchState.currentTouchKey = nil;
|
|
|
|
|
+
|
|
|
|
|
+ "Synth pool cleaned up".postln;
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+// Initialize the synth pool
|
|
|
|
|
+~initializeSynthPool = {
|
|
|
|
|
+ // Clean up first
|
|
|
|
|
+ ~cleanupSynthPool.value;
|
|
|
|
|
+
|
|
|
|
|
+ // Wait for server
|
|
|
|
|
+ s.sync;
|
|
|
|
|
|
|
|
// Create a group to hold all pool synths
|
|
// Create a group to hold all pool synths
|
|
|
~synthPoolGroup = Group.new;
|
|
~synthPoolGroup = Group.new;
|
|
|
|
|
+ s.sync;
|
|
|
|
|
|
|
|
"Creating synth pool with % synths...".format(~poolSize).postln;
|
|
"Creating synth pool with % synths...".format(~poolSize).postln;
|
|
|
|
|
|
|
|
// Create all synths at once
|
|
// Create all synths at once
|
|
|
~poolSize.do({ |i|
|
|
~poolSize.do({ |i|
|
|
|
- var synth = Synth(\rgbSynth, [
|
|
|
|
|
- \out, ~sourceBus ? 0,
|
|
|
|
|
- \gate, 0, // Start with gate closed (silent)
|
|
|
|
|
- \amp, 0,
|
|
|
|
|
- \freq, 440,
|
|
|
|
|
- \ampAttack, 0.01,
|
|
|
|
|
- \ampRelease, 1,
|
|
|
|
|
- \filterAttack, 0,
|
|
|
|
|
- \filterRelease, 0,
|
|
|
|
|
- \pitchAttack, 0,
|
|
|
|
|
- \pitchRelease, 0,
|
|
|
|
|
- \redAmt, 0.5,
|
|
|
|
|
- \greenAmt, 0.5,
|
|
|
|
|
- \blueAmt, 0.5
|
|
|
|
|
- ], ~synthPoolGroup);
|
|
|
|
|
-
|
|
|
|
|
- // Add to pool and mark as free
|
|
|
|
|
- ~synthPool[i] = synth;
|
|
|
|
|
- ~freePool.add(i);
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ var synth = Synth(\rgbSynth, [
|
|
|
|
|
+ \out, ~sourceBus ? 0,
|
|
|
|
|
+ \gate, 0, // Start with gate closed (silent)
|
|
|
|
|
+ \amp, 0,
|
|
|
|
|
+ \freq, 440
|
|
|
|
|
+ ], ~synthPoolGroup);
|
|
|
|
|
+
|
|
|
|
|
+ // Store in array
|
|
|
|
|
+ ~synthPool[i] = synth;
|
|
|
|
|
+
|
|
|
|
|
+ } { |error|
|
|
|
|
|
+ "Error creating synth %: %".format(i, error).postln;
|
|
|
|
|
+ };
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ // Wait for all synths to be created
|
|
|
|
|
+ s.sync;
|
|
|
|
|
+
|
|
|
|
|
+ // Mark as initialized
|
|
|
|
|
+ ~poolInitialized = true;
|
|
|
|
|
+
|
|
|
"Synth pool initialized with % synths".format(~poolSize).postln;
|
|
"Synth pool initialized with % synths".format(~poolSize).postln;
|
|
|
- "Free synths: %".format(~freePool.size).postln;
|
|
|
|
|
|
|
+ "Free synths: %".format(~freeIndices.size).postln;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// Get a free synth from the pool
|
|
// Get a free synth from the pool
|
|
|
~getSynthFromPool = { |key|
|
|
~getSynthFromPool = { |key|
|
|
|
- var synthIndex, synth;
|
|
|
|
|
|
|
+ var synthIndex, synth = nil;
|
|
|
|
|
|
|
|
- if(~freePool.size > 0, {
|
|
|
|
|
- // Get the first available synth
|
|
|
|
|
- synthIndex = ~freePool.removeAt(0);
|
|
|
|
|
- synth = ~synthPool[synthIndex];
|
|
|
|
|
-
|
|
|
|
|
- // Mark it as active
|
|
|
|
|
- ~activeSynths[key] = (synth: synth, index: synthIndex);
|
|
|
|
|
-
|
|
|
|
|
- // Update parameters with current settings
|
|
|
|
|
- synth.set(
|
|
|
|
|
- \ampAttack, ~synthParams.ampAttack,
|
|
|
|
|
- \ampRelease, ~synthParams.ampRelease,
|
|
|
|
|
- \filterAttack, ~synthParams.filterAttack,
|
|
|
|
|
- \filterRelease, ~synthParams.filterRelease,
|
|
|
|
|
- \pitchAttack, ~synthParams.pitchAttack,
|
|
|
|
|
- \pitchRelease, ~synthParams.pitchRelease,
|
|
|
|
|
- \redAmt, ~synthParams.redAmt,
|
|
|
|
|
- \greenAmt, ~synthParams.greenAmt,
|
|
|
|
|
- \blueAmt, ~synthParams.blueAmt
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- synth;
|
|
|
|
|
- }, {
|
|
|
|
|
- "Warning: No free synths in pool!".postln;
|
|
|
|
|
|
|
+ if(~poolInitialized.not, {
|
|
|
|
|
+ "Error: Synth pool not initialized!".postln;
|
|
|
nil;
|
|
nil;
|
|
|
|
|
+ }, {
|
|
|
|
|
+ if(~freeIndices.size > 0, {
|
|
|
|
|
+ // Get the first available synth index
|
|
|
|
|
+ synthIndex = ~freeIndices.removeAt(0);
|
|
|
|
|
+ synth = ~synthPool[synthIndex];
|
|
|
|
|
+
|
|
|
|
|
+ // Check if synth is valid
|
|
|
|
|
+ if(synth.notNil and: { synth.isPlaying }, {
|
|
|
|
|
+ // Mark it as active
|
|
|
|
|
+ ~activeSynths[key] = (synth: synth, index: synthIndex);
|
|
|
|
|
+
|
|
|
|
|
+ // Update parameters with current settings
|
|
|
|
|
+ try {
|
|
|
|
|
+ synth.set(
|
|
|
|
|
+ \ampAttack, ~synthParams.ampAttack,
|
|
|
|
|
+ \ampRelease, ~synthParams.ampRelease,
|
|
|
|
|
+ \filterAttack, ~synthParams.filterAttack,
|
|
|
|
|
+ \filterRelease, ~synthParams.filterRelease,
|
|
|
|
|
+ \pitchAttack, ~synthParams.pitchAttack,
|
|
|
|
|
+ \pitchRelease, ~synthParams.pitchRelease,
|
|
|
|
|
+ \redAmt, ~synthParams.redAmt,
|
|
|
|
|
+ \greenAmt, ~synthParams.greenAmt,
|
|
|
|
|
+ \blueAmt, ~synthParams.blueAmt
|
|
|
|
|
+ );
|
|
|
|
|
+ } { |error|
|
|
|
|
|
+ "Error setting synth parameters: %".format(error).postln;
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ synth;
|
|
|
|
|
+ }, {
|
|
|
|
|
+ // Synth is invalid, put index back and return nil
|
|
|
|
|
+ ~freeIndices.add(synthIndex);
|
|
|
|
|
+ "Warning: Synth % is invalid".format(synthIndex).postln;
|
|
|
|
|
+ nil;
|
|
|
|
|
+ });
|
|
|
|
|
+ }, {
|
|
|
|
|
+ "Warning: No free synths in pool!".postln;
|
|
|
|
|
+ nil;
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// Return a synth to the pool
|
|
// Return a synth to the pool
|
|
|
~returnSynthToPool = { |key|
|
|
~returnSynthToPool = { |key|
|
|
|
- var synthData = ~activeSynths[key];
|
|
|
|
|
|
|
+ var synthData;
|
|
|
|
|
|
|
|
- if(synthData.notNil, {
|
|
|
|
|
- var synth = synthData.synth;
|
|
|
|
|
- var index = synthData.index;
|
|
|
|
|
-
|
|
|
|
|
- // Release the synth (set gate to 0)
|
|
|
|
|
- synth.set(\gate, 0, \amp, 0);
|
|
|
|
|
|
|
+ if(~activeSynths.notNil, {
|
|
|
|
|
+ synthData = ~activeSynths[key];
|
|
|
|
|
|
|
|
- // Return to free pool
|
|
|
|
|
- ~freePool.add(index);
|
|
|
|
|
- ~activeSynths.removeAt(key);
|
|
|
|
|
|
|
+ if(synthData.notNil, {
|
|
|
|
|
+ var synth = synthData.synth;
|
|
|
|
|
+ var index = synthData.index;
|
|
|
|
|
+
|
|
|
|
|
+ // Release the synth safely
|
|
|
|
|
+ if(synth.notNil, {
|
|
|
|
|
+ try {
|
|
|
|
|
+ synth.set(\gate, 0, \amp, 0);
|
|
|
|
|
+ } { |error|
|
|
|
|
|
+ // Silent error handling
|
|
|
|
|
+ };
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // Return to free pool
|
|
|
|
|
+ if(~freeIndices.notNil, {
|
|
|
|
|
+ ~freeIndices.add(index);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // Remove from active tracking
|
|
|
|
|
+ ~activeSynths.removeAt(key);
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -141,21 +209,27 @@ OSCdef.freeAll;
|
|
|
|
|
|
|
|
if(synth.notNil, {
|
|
if(synth.notNil, {
|
|
|
// Start the synth
|
|
// Start the synth
|
|
|
- synth.set(
|
|
|
|
|
- \gate, 1,
|
|
|
|
|
- \freq, freq,
|
|
|
|
|
- \amp, amp
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- // If duration is specified, schedule automatic release
|
|
|
|
|
- if(duration.notNil, {
|
|
|
|
|
- SystemClock.sched(duration, {
|
|
|
|
|
- ~returnSynthToPool.value(key);
|
|
|
|
|
- nil;
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ synth.set(
|
|
|
|
|
+ \gate, 1,
|
|
|
|
|
+ \freq, freq,
|
|
|
|
|
+ \amp, amp
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ // If duration is specified, schedule automatic release
|
|
|
|
|
+ if(duration.notNil, {
|
|
|
|
|
+ SystemClock.sched(duration, {
|
|
|
|
|
+ ~returnSynthToPool.value(key);
|
|
|
|
|
+ nil;
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- synth;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ synth;
|
|
|
|
|
+ } { |error|
|
|
|
|
|
+ "Error starting synth: %".format(error).postln;
|
|
|
|
|
+ ~returnSynthToPool.value(key);
|
|
|
|
|
+ nil;
|
|
|
|
|
+ };
|
|
|
}, {
|
|
}, {
|
|
|
nil;
|
|
nil;
|
|
|
});
|
|
});
|
|
@@ -163,63 +237,69 @@ OSCdef.freeAll;
|
|
|
|
|
|
|
|
// Update an active synth
|
|
// Update an active synth
|
|
|
~updatePoolSynth = { |key, freq=nil, amp=nil|
|
|
~updatePoolSynth = { |key, freq=nil, amp=nil|
|
|
|
- var synthData = ~activeSynths[key];
|
|
|
|
|
|
|
+ var synthData;
|
|
|
|
|
|
|
|
- if(synthData.notNil, {
|
|
|
|
|
- var synth = synthData.synth;
|
|
|
|
|
|
|
+ if(~activeSynths.notNil, {
|
|
|
|
|
+ synthData = ~activeSynths[key];
|
|
|
|
|
|
|
|
- if(freq.notNil, { synth.set(\freq, freq); });
|
|
|
|
|
- if(amp.notNil, { synth.set(\amp, amp); });
|
|
|
|
|
|
|
+ if(synthData.notNil, {
|
|
|
|
|
+ var synth = synthData.synth;
|
|
|
|
|
+
|
|
|
|
|
+ if(synth.notNil, {
|
|
|
|
|
+ try {
|
|
|
|
|
+ if(freq.notNil, { synth.set(\freq, freq); });
|
|
|
|
|
+ if(amp.notNil, { synth.set(\amp, amp); });
|
|
|
|
|
+ } { |error|
|
|
|
|
|
+ // Silent error handling
|
|
|
|
|
+ };
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// Update all active synths with new envelope/color parameters
|
|
// Update all active synths with new envelope/color parameters
|
|
|
~updateAllPoolSynths = {
|
|
~updateAllPoolSynths = {
|
|
|
- ~activeSynths.keysValuesDo({ |key, synthData|
|
|
|
|
|
- var synth = synthData.synth;
|
|
|
|
|
-
|
|
|
|
|
- synth.set(
|
|
|
|
|
- \ampAttack, ~synthParams.ampAttack,
|
|
|
|
|
- \ampRelease, ~synthParams.ampRelease,
|
|
|
|
|
- \filterAttack, ~synthParams.filterAttack,
|
|
|
|
|
- \filterRelease, ~synthParams.filterRelease,
|
|
|
|
|
- \pitchAttack, ~synthParams.pitchAttack,
|
|
|
|
|
- \pitchRelease, ~synthParams.pitchRelease,
|
|
|
|
|
- \redAmt, ~synthParams.redAmt,
|
|
|
|
|
- \greenAmt, ~synthParams.greenAmt,
|
|
|
|
|
- \blueAmt, ~synthParams.blueAmt
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ if(~activeSynths.notNil, {
|
|
|
|
|
+ ~activeSynths.keysValuesDo({ |key, synthData|
|
|
|
|
|
+ var synth = synthData.synth;
|
|
|
|
|
+
|
|
|
|
|
+ if(synth.notNil, {
|
|
|
|
|
+ try {
|
|
|
|
|
+ synth.set(
|
|
|
|
|
+ \ampAttack, ~synthParams.ampAttack,
|
|
|
|
|
+ \ampRelease, ~synthParams.ampRelease,
|
|
|
|
|
+ \filterAttack, ~synthParams.filterAttack,
|
|
|
|
|
+ \filterRelease, ~synthParams.filterRelease,
|
|
|
|
|
+ \pitchAttack, ~synthParams.pitchAttack,
|
|
|
|
|
+ \pitchRelease, ~synthParams.pitchRelease,
|
|
|
|
|
+ \redAmt, ~synthParams.redAmt,
|
|
|
|
|
+ \greenAmt, ~synthParams.greenAmt,
|
|
|
|
|
+ \blueAmt, ~synthParams.blueAmt
|
|
|
|
|
+ );
|
|
|
|
|
+ } { |error|
|
|
|
|
|
+ // Silent error handling during updates
|
|
|
|
|
+ };
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// Get pool status
|
|
// Get pool status
|
|
|
~getPoolStatus = {
|
|
~getPoolStatus = {
|
|
|
"=== Synth Pool Status ===".postln;
|
|
"=== Synth Pool Status ===".postln;
|
|
|
|
|
+ "Pool initialized: %".format(~poolInitialized).postln;
|
|
|
"Total synths: %".format(~poolSize).postln;
|
|
"Total synths: %".format(~poolSize).postln;
|
|
|
- "Active synths: %".format(~activeSynths.size).postln;
|
|
|
|
|
- "Free synths: %".format(~freePool.size).postln;
|
|
|
|
|
- "========================".postln;
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-// Clean up the entire pool
|
|
|
|
|
-~cleanupSynthPool = {
|
|
|
|
|
- // Return all active synths to pool
|
|
|
|
|
- ~activeSynths.keys.do({ |key|
|
|
|
|
|
- ~returnSynthToPool.value(key);
|
|
|
|
|
|
|
+ if(~activeSynths.notNil, {
|
|
|
|
|
+ "Active synths: %".format(~activeSynths.size).postln;
|
|
|
|
|
+ }, {
|
|
|
|
|
+ "Active synths: 0 (activeSynths is nil)".postln;
|
|
|
});
|
|
});
|
|
|
-
|
|
|
|
|
- // Free all synths
|
|
|
|
|
- if(~synthPoolGroup.notNil, {
|
|
|
|
|
- ~synthPoolGroup.free;
|
|
|
|
|
- ~synthPoolGroup = nil;
|
|
|
|
|
|
|
+ if(~freeIndices.notNil, {
|
|
|
|
|
+ "Free synths: %".format(~freeIndices.size).postln;
|
|
|
|
|
+ }, {
|
|
|
|
|
+ "Free synths: 0 (freeIndices is nil)".postln;
|
|
|
});
|
|
});
|
|
|
-
|
|
|
|
|
- // Clear data structures
|
|
|
|
|
- ~synthPool.clear;
|
|
|
|
|
- ~activeSynths.clear;
|
|
|
|
|
- ~freePool.clear;
|
|
|
|
|
-
|
|
|
|
|
- "Synth pool cleaned up".postln;
|
|
|
|
|
|
|
+ "========================".postln;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// ========== TOUCH HANDLING ==========
|
|
// ========== TOUCH HANDLING ==========
|
|
@@ -342,22 +422,34 @@ OSCdef.freeAll;
|
|
|
\pencil, {
|
|
\pencil, {
|
|
|
// Apply Preset 1 effects - with safety checks
|
|
// Apply Preset 1 effects - with safety checks
|
|
|
if(~filterSynth.notNil and: { ~filterSynth.isPlaying }, {
|
|
if(~filterSynth.notNil and: { ~filterSynth.isPlaying }, {
|
|
|
- ~filterSynth.set(
|
|
|
|
|
- \cutoff, x.linexp(-0.5, 0.5, 20, 18000),
|
|
|
|
|
- \res, y.linlin(-0.5, 0.5, 0, 1)
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ ~filterSynth.set(
|
|
|
|
|
+ \cutoff, x.linexp(-0.5, 0.5, 20, 18000),
|
|
|
|
|
+ \res, y.linlin(-0.5, 0.5, 0, 1)
|
|
|
|
|
+ );
|
|
|
|
|
+ } { |error|
|
|
|
|
|
+ // Silent error handling
|
|
|
|
|
+ };
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
if(~lfoSynth.notNil and: { ~lfoSynth.isPlaying }, {
|
|
if(~lfoSynth.notNil and: { ~lfoSynth.isPlaying }, {
|
|
|
- ~lfoSynth.set(
|
|
|
|
|
- \freq, x.linlin(-0.5, 0.5, 0, 15)
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ ~lfoSynth.set(
|
|
|
|
|
+ \freq, x.linlin(-0.5, 0.5, 0, 15)
|
|
|
|
|
+ );
|
|
|
|
|
+ } { |error|
|
|
|
|
|
+ // Silent error handling
|
|
|
|
|
+ };
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
if(~reverbSynth.notNil and: { ~reverbSynth.isPlaying }, {
|
|
if(~reverbSynth.notNil and: { ~reverbSynth.isPlaying }, {
|
|
|
- ~reverbSynth.set(
|
|
|
|
|
- \room, y.linlin(-0.5, 0.5, 0.1, 0.9)
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ ~reverbSynth.set(
|
|
|
|
|
+ \room, y.linlin(-0.5, 0.5, 0.1, 0.9)
|
|
|
|
|
+ );
|
|
|
|
|
+ } { |error|
|
|
|
|
|
+ // Silent error handling
|
|
|
|
|
+ };
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
|
|
|
|
@@ -365,28 +457,44 @@ OSCdef.freeAll;
|
|
|
\crayon, {
|
|
\crayon, {
|
|
|
// Apply Preset 2 effects - with safety checks
|
|
// Apply Preset 2 effects - with safety checks
|
|
|
if(~lfoSynth.notNil and: { ~lfoSynth.isPlaying }, {
|
|
if(~lfoSynth.notNil and: { ~lfoSynth.isPlaying }, {
|
|
|
- ~lfoSynth.set(
|
|
|
|
|
- \freq, x.linlin(-0.5, 0.5, 15, 1)
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ ~lfoSynth.set(
|
|
|
|
|
+ \freq, x.linlin(-0.5, 0.5, 15, 1)
|
|
|
|
|
+ );
|
|
|
|
|
+ } { |error|
|
|
|
|
|
+ // Silent error handling
|
|
|
|
|
+ };
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
if(~delaySynth.notNil and: { ~delaySynth.isPlaying }, {
|
|
if(~delaySynth.notNil and: { ~delaySynth.isPlaying }, {
|
|
|
- ~delaySynth.set(
|
|
|
|
|
- \delaytime, x.linlin(-0.5, 0.5, 0.01, 1.0)
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ ~delaySynth.set(
|
|
|
|
|
+ \delaytime, x.linlin(-0.5, 0.5, 0.01, 1.0)
|
|
|
|
|
+ );
|
|
|
|
|
+ } { |error|
|
|
|
|
|
+ // Silent error handling
|
|
|
|
|
+ };
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
if(~filterSynth.notNil and: { ~filterSynth.isPlaying }, {
|
|
if(~filterSynth.notNil and: { ~filterSynth.isPlaying }, {
|
|
|
- ~filterSynth.set(
|
|
|
|
|
- \cutoff, y.linexp(-0.5, 0.5, 20, 18000),
|
|
|
|
|
- \res, pressure.linlin(1, 5, 0, 1)
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ ~filterSynth.set(
|
|
|
|
|
+ \cutoff, y.linexp(-0.5, 0.5, 20, 18000),
|
|
|
|
|
+ \res, pressure.linlin(1, 5, 0, 1)
|
|
|
|
|
+ );
|
|
|
|
|
+ } { |error|
|
|
|
|
|
+ // Silent error handling
|
|
|
|
|
+ };
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
if(~reverbSynth.notNil and: { ~reverbSynth.isPlaying }, {
|
|
if(~reverbSynth.notNil and: { ~reverbSynth.isPlaying }, {
|
|
|
- ~reverbSynth.set(
|
|
|
|
|
- \mix, y.linlin(-0.5, 0.5, 0, 1)
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ ~reverbSynth.set(
|
|
|
|
|
+ \mix, y.linlin(-0.5, 0.5, 0, 1)
|
|
|
|
|
+ );
|
|
|
|
|
+ } { |error|
|
|
|
|
|
+ // Silent error handling
|
|
|
|
|
+ };
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
);
|
|
);
|
|
@@ -450,7 +558,9 @@ OSCdef(\pencilOSC, { |msg, time, addr, port|
|
|
|
var penType = msg[1].asFloat;
|
|
var penType = msg[1].asFloat;
|
|
|
if (penType == 1.0) {
|
|
if (penType == 1.0) {
|
|
|
~currentPenType = \pencil;
|
|
~currentPenType = \pencil;
|
|
|
- if(~initializePreset1.notNil, { ~initializePreset1.value; });
|
|
|
|
|
|
|
+ if(~initializePreset1.notNil, {
|
|
|
|
|
+ try { ~initializePreset1.value; } { |error| };
|
|
|
|
|
+ });
|
|
|
["Current pen type:", ~currentPenType].postln;
|
|
["Current pen type:", ~currentPenType].postln;
|
|
|
}
|
|
}
|
|
|
}, '/pencil');
|
|
}, '/pencil');
|
|
@@ -459,7 +569,9 @@ OSCdef(\crayonOSC, { |msg, time, addr, port|
|
|
|
var penType = msg[1].asFloat;
|
|
var penType = msg[1].asFloat;
|
|
|
if (penType == 1.0) {
|
|
if (penType == 1.0) {
|
|
|
~currentPenType = \crayon;
|
|
~currentPenType = \crayon;
|
|
|
- if(~initializePreset2.notNil, { ~initializePreset2.value; });
|
|
|
|
|
|
|
+ if(~initializePreset2.notNil, {
|
|
|
|
|
+ try { ~initializePreset2.value; } { |error| };
|
|
|
|
|
+ });
|
|
|
["Current pen type:", ~currentPenType].postln;
|
|
["Current pen type:", ~currentPenType].postln;
|
|
|
}
|
|
}
|
|
|
}, '/crayon');
|
|
}, '/crayon');
|
|
@@ -468,7 +580,9 @@ OSCdef(\fountainPenOSC, { |msg, time, addr, port|
|
|
|
var penType = msg[1].asFloat;
|
|
var penType = msg[1].asFloat;
|
|
|
if (penType == 1.0) {
|
|
if (penType == 1.0) {
|
|
|
~currentPenType = \fountainPen;
|
|
~currentPenType = \fountainPen;
|
|
|
- if(~initializePreset3.notNil, { ~initializePreset3.value; });
|
|
|
|
|
|
|
+ if(~initializePreset3.notNil, {
|
|
|
|
|
+ try { ~initializePreset3.value; } { |error| };
|
|
|
|
|
+ });
|
|
|
["Current pen type:", ~currentPenType].postln;
|
|
["Current pen type:", ~currentPenType].postln;
|
|
|
}
|
|
}
|
|
|
}, '/fountainPen');
|
|
}, '/fountainPen');
|
|
@@ -477,7 +591,9 @@ OSCdef(\waterColorOSC, { |msg, time, addr, port|
|
|
|
var penType = msg[1].asFloat;
|
|
var penType = msg[1].asFloat;
|
|
|
if (penType == 1.0) {
|
|
if (penType == 1.0) {
|
|
|
~currentPenType = \waterColor;
|
|
~currentPenType = \waterColor;
|
|
|
- if(~initializePreset4.notNil, { ~initializePreset4.value; });
|
|
|
|
|
|
|
+ if(~initializePreset4.notNil, {
|
|
|
|
|
+ try { ~initializePreset4.value; } { |error| };
|
|
|
|
|
+ });
|
|
|
["Current pen type:", ~currentPenType].postln;
|
|
["Current pen type:", ~currentPenType].postln;
|
|
|
}
|
|
}
|
|
|
}, '/waterColor');
|
|
}, '/waterColor');
|
|
@@ -533,7 +649,7 @@ CmdPeriod.add({
|
|
|
thisProcess.openUDPPort(57120);
|
|
thisProcess.openUDPPort(57120);
|
|
|
|
|
|
|
|
"========================================".postln;
|
|
"========================================".postln;
|
|
|
-"OSC Communication with Synth Pool loaded".postln;
|
|
|
|
|
|
|
+"OSC Communication with ROBUST Synth Pool loaded".postln;
|
|
|
"========================================".postln;
|
|
"========================================".postln;
|
|
|
"Available functions:".postln;
|
|
"Available functions:".postln;
|
|
|
" ~initializeSynthPool.value - Initialize 16 synths".postln;
|
|
" ~initializeSynthPool.value - Initialize 16 synths".postln;
|