Bläddra i källkod

get rid off boolean error

Farnoosh Rad 6 månader sedan
förälder
incheckning
3d312d0581
2 ändrade filer med 337 tillägg och 182 borttagningar
  1. 264 148
      SC/5_osc_communication.scd
  2. 73 34
      SC/9_midi_controller.scd

+ 264 - 148
SC/5_osc_communication.scd

@@ -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)
 
 (
@@ -34,104 +34,172 @@ OSCdef.freeAll;
 	blueAmt: 0.5
 );
 
-// ========== SYNTH POOL SYSTEM ==========
+// ========== ROBUST SYNTH POOL SYSTEM ==========
 // Synth Pool Configuration
 ~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
-~freePool = Array.new(~poolSize);  // Available synths
+~freeIndices = Array.series(~poolSize);  // Available synth indices
 ~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, {
-        ~synthPoolGroup.free;
+        try {
+            ~synthPoolGroup.free;
+        } { |error|
+            // Silent cleanup
+        };
+        ~synthPoolGroup = nil;
     });
     
     // Clear data structures
-    ~synthPool.clear;
+    ~synthPool = Array.newClear(~poolSize);
     ~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
     ~synthPoolGroup = Group.new;
+    s.sync;
     
     "Creating synth pool with % synths...".format(~poolSize).postln;
     
     // Create all synths at once
     ~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;
-    "Free synths: %".format(~freePool.size).postln;
+    "Free synths: %".format(~freeIndices.size).postln;
 };
 
 // Get a free synth from the pool
 ~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;
+    }, {
+        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
 ~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, {
         // 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;
     });
@@ -163,63 +237,69 @@ OSCdef.freeAll;
 
 // Update an active synth
 ~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
 ~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
 ~getPoolStatus = {
     "=== Synth Pool Status ===".postln;
+    "Pool initialized: %".format(~poolInitialized).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 ==========
@@ -342,22 +422,34 @@ OSCdef.freeAll;
 		\pencil, {
             // Apply Preset 1 effects - with safety checks
             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 }, {
-                ~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 }, {
-                ~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, {
             // Apply Preset 2 effects - with safety checks
             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 }, {
-                ~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 }, {
-                ~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 }, {
-                ~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;
 	if (penType == 1.0) {
 		~currentPenType = \pencil;
-		if(~initializePreset1.notNil, { ~initializePreset1.value; });
+		if(~initializePreset1.notNil, { 
+			try { ~initializePreset1.value; } { |error| }; 
+		});
 		["Current pen type:", ~currentPenType].postln;
 	}
 }, '/pencil');
@@ -459,7 +569,9 @@ OSCdef(\crayonOSC, { |msg, time, addr, port|
     var penType = msg[1].asFloat;
 	if (penType == 1.0) {
 		~currentPenType = \crayon;
-		if(~initializePreset2.notNil, { ~initializePreset2.value; });
+		if(~initializePreset2.notNil, { 
+			try { ~initializePreset2.value; } { |error| }; 
+		});
 		["Current pen type:", ~currentPenType].postln;
 	}
 }, '/crayon');
@@ -468,7 +580,9 @@ OSCdef(\fountainPenOSC, { |msg, time, addr, port|
     var penType = msg[1].asFloat;
 	if (penType == 1.0) {
 		~currentPenType = \fountainPen;
-		if(~initializePreset3.notNil, { ~initializePreset3.value; });
+		if(~initializePreset3.notNil, { 
+			try { ~initializePreset3.value; } { |error| }; 
+		});
 		["Current pen type:", ~currentPenType].postln;
 	}
 }, '/fountainPen');
@@ -477,7 +591,9 @@ OSCdef(\waterColorOSC, { |msg, time, addr, port|
     var penType = msg[1].asFloat;
 	if (penType == 1.0) {
 		~currentPenType = \waterColor;
-		if(~initializePreset4.notNil, { ~initializePreset4.value; });
+		if(~initializePreset4.notNil, { 
+			try { ~initializePreset4.value; } { |error| }; 
+		});
 		["Current pen type:", ~currentPenType].postln;
 	}
 }, '/waterColor');
@@ -533,7 +649,7 @@ CmdPeriod.add({
 thisProcess.openUDPPort(57120);
 
 "========================================".postln;
-"OSC Communication with Synth Pool loaded".postln;
+"OSC Communication with ROBUST Synth Pool loaded".postln;
 "========================================".postln;
 "Available functions:".postln;
 "  ~initializeSynthPool.value  - Initialize 16 synths".postln;

+ 73 - 34
SC/9_midi_controller.scd

@@ -1,8 +1,8 @@
-// Module 9: MIDI Controller - FIXED VERSION
+// Module 9: MIDI Controller - ROBUST VERSION
 // Save as "9_midi_controller.scd" (REPLACE YOUR EXISTING VERSION)
 
 (
-// MIDI note handling using synth pool
+// MIDI note handling using synth pool - ROBUST VERSION
 var midiIn, synths;
 
 ~midiNoteKeys = IdentityDictionary.new;  // Track which pool keys are used for MIDI notes
@@ -20,33 +20,50 @@ MIDIdef.noteOn(\noteOn, { |vel, num, chan, src|
     if (vel > 0) {
 		// Check if note is already playing and release it first
 		if(~midiNoteKeys[num].notNil, {
-			if(~returnSynthToPool.notNil, {
-				~returnSynthToPool.value(~midiNoteKeys[num]);
-			});
+			// Safely return synth to pool
+			try {
+				if(~returnSynthToPool.notNil, {
+					~returnSynthToPool.value(~midiNoteKeys[num]);
+				});
+			} { |error|
+				// Silent error handling
+			};
 			~midiNoteKeys.removeAt(num);
 		});
 		
-		// Get a synth from the pool instead of creating new one
-		if(~startPoolSynth.notNil, {
-			var synth = ~startPoolSynth.value(noteKey, freq, amp);
-			
-			if(synth.notNil, {
-				// Track this note
-				~midiNoteKeys[num] = noteKey;
-				// Uncomment for debugging: ["MIDI Note ON: % - Got synth from pool".format(num)].postln;
+		// Check if synth pool functions exist and pool is initialized
+		if(~startPoolSynth.notNil and: { ~poolInitialized == true }, {
+			try {
+				var synth = ~startPoolSynth.value(noteKey, freq, amp);
+				
+				if(synth.notNil, {
+					// Track this note
+					~midiNoteKeys[num] = noteKey;
+					// Uncomment for debugging: ["MIDI Note ON: % - Got synth from pool".format(num)].postln;
+				}, {
+					["MIDI Note ON: % - No free synths available!".format(num)].postln;
+				});
+			} { |error|
+				"MIDI Error getting synth from pool: %".format(error).postln;
+			};
+		}, {
+			if(~poolInitialized != true, {
+				"MIDI Error: Synth pool not initialized! Run ~initializeSynthPool.value first".postln;
 			}, {
-				["MIDI Note ON: % - No free synths available!".format(num)].postln;
+				"MIDI Error: Synth pool functions not available!".postln;
 			});
-		}, {
-			"ERROR: Synth pool not initialized! Run ~initializeSynthPool.value first".postln;
 		});
 
     } { 
 		// Treat as noteOff if it is a noteOn with velocity 0
 		if(~midiNoteKeys[num].notNil, {
-			if(~returnSynthToPool.notNil, {
-				~returnSynthToPool.value(~midiNoteKeys[num]);
-			});
+			try {
+				if(~returnSynthToPool.notNil, {
+					~returnSynthToPool.value(~midiNoteKeys[num]);
+				});
+			} { |error|
+				// Silent error handling
+			};
 			~midiNoteKeys.removeAt(num);
 			// Uncomment for debugging: ["MIDI Note OFF: % (vel 0)".format(num)].postln;
 		});
@@ -56,9 +73,13 @@ MIDIdef.noteOn(\noteOn, { |vel, num, chan, src|
 // Note Off: return synth to pool instead of setting gate
 MIDIdef.noteOff(\noteOff, { |vel, num, chan, src|
 	if(~midiNoteKeys[num].notNil, {
-		if(~returnSynthToPool.notNil, {
-			~returnSynthToPool.value(~midiNoteKeys[num]);
-		});
+		try {
+			if(~returnSynthToPool.notNil, {
+				~returnSynthToPool.value(~midiNoteKeys[num]);
+			});
+		} { |error|
+			// Silent error handling
+		};
 		~midiNoteKeys.removeAt(num);
 		// Uncomment for debugging: ["MIDI Note OFF: %".format(num)].postln;
 	});
@@ -67,11 +88,15 @@ MIDIdef.noteOff(\noteOff, { |vel, num, chan, src|
 // All Notes Off (MIDI Panic) - return all MIDI synths to pool
 MIDIdef.cc(\allNotesOff, { |val, num, chan, src|
 	if(num == 123, {  // All Notes Off CC
-		if(~returnSynthToPool.notNil, {
-			~midiNoteKeys.keysValuesDo({ |noteNum, noteKey|
-				~returnSynthToPool.value(noteKey);
+		try {
+			if(~returnSynthToPool.notNil, {
+				~midiNoteKeys.keysValuesDo({ |noteNum, noteKey|
+					~returnSynthToPool.value(noteKey);
+				});
 			});
-		});
+		} { |error|
+			"Error during All Notes Off: %".format(error).postln;
+		};
 		~midiNoteKeys.clear;
 		"MIDI: All notes off - All synths returned to pool".postln;
 	});
@@ -79,11 +104,15 @@ MIDIdef.cc(\allNotesOff, { |val, num, chan, src|
 
 // Cleanup all MIDI synths function
 ~cleanupAllMIDI = {
-	if(~returnSynthToPool.notNil, {
-		~midiNoteKeys.keysValuesDo({ |noteNum, noteKey|
-			~returnSynthToPool.value(noteKey);
+	try {
+		if(~returnSynthToPool.notNil, {
+			~midiNoteKeys.keysValuesDo({ |noteNum, noteKey|
+				~returnSynthToPool.value(noteKey);
+			});
 		});
-	});
+	} { |error|
+		"Error during MIDI cleanup: %".format(error).postln;
+	};
 	~midiNoteKeys.clear;
 	"All MIDI synths returned to pool".postln;
 };
@@ -91,9 +120,19 @@ MIDIdef.cc(\allNotesOff, { |val, num, chan, src|
 // Get MIDI status
 ~getMIDIStatus = {
 	"=== MIDI Status ===".postln;
-	"Active MIDI notes: %".format(~midiNoteKeys.size).postln;
-	if(~midiNoteKeys.size > 0, {
-		"Playing notes: %".format(~midiNoteKeys.keys.asArray.sort).postln;
+	if(~midiNoteKeys.notNil, {
+		"Active MIDI notes: %".format(~midiNoteKeys.size).postln;
+		if(~midiNoteKeys.size > 0, {
+			"Playing notes: %".format(~midiNoteKeys.keys.asArray.sort).postln;
+		});
+	}, {
+		"MIDI note tracking not initialized".postln;
+	});
+	
+	if(~poolInitialized.notNil, {
+		"Synth pool initialized: %".format(~poolInitialized).postln;
+	}, {
+		"Synth pool status: Unknown".postln;
 	});
 	"==================".postln;
 };
@@ -103,7 +142,7 @@ CmdPeriod.add({
 	~cleanupAllMIDI.value;
 });
 
-"MIDI functions loaded with synth pool integration.".postln;
+"MIDI functions loaded with ROBUST synth pool integration.".postln;
 "Notes will use pre-allocated synths from the pool.".postln;
 "No more memory leaks or stuck notes!".postln;
 "Available functions:".postln;