Commits

dan mackinlay committed 1541579

restructure synthdef loader to actually reload synths

  • Participants
  • Parent commits 1b6b11b

Comments (0)

Files changed (3)

File phenosynth.scd

 
 /* TODO:
 
-* provide a way to unwarp as well as warp chromosomes, and look up values of either. 
+* provide a way to unwarp as well as warp chromosomes, and look up values of either.
+* support multi-channel listeners (In.ar is hardcoded to 1 channel atm) 
 
 */
 

File phenosynth/listensynthdefs.sc

 PSBasicJudgeSynths {
   *initClass{
     StartUp.add({
-      //first, a simple connector to siphon one bus into another.
-      SynthDef.writeOnce(\jack, { |in, out|
-        Out.ar(out, In.ar(in));
-      });
-      // This judge is one of the simplest I can think of (for demo purposes) 
-      // - evaluates closeness of pitch to a reference value (800 Hz).
-      SynthDef.writeOnce(\ps_listen_eight_hundred, { |in, out, active=0, t_reset=0, targetpitch=800|
-        var testsig, comparison, integral, freq, hasFreq;
-        testsig = LeakDC.ar(Mix.ar(In.ar(in, 1)));
-        # freq, hasFreq = Pitch.kr(testsig);
-        comparison = hasFreq.if(
-          (200 - ((freq - targetpitch).abs)).max(0),
-          0
-        ).poll(1, \foo);
-         // "0" if hasFreq==false because we don't want to encourage quietness
-
-        // Divide by the server's control rate to bring it within a sensible range.
-        comparison = comparison / ControlRate.ir;
-      
-        // Default coefficient of 1.0 = no leak. When t_reset briefly hits nonzero, the integrator drains.
-        integral = Integrator.kr(comparison * active, if(t_reset>0, 0, 1));
-        Out.kr(out, integral);
-      });
+      this.loadSynthDefs
     });
   }
+  *loadSynthDefs {
+    //first, a simple connector to siphon one bus into another.
+    SynthDef.new(\jack, { |in, out|
+      Out.ar(out, In.ar(in));
+    }).add;
+    // This judge is one of the simplest I can think of (for demo purposes) 
+    // - evaluates closeness of pitch to a reference value (800 Hz).
+    SynthDef.new(\ps_listen_eight_hundred, { |in, out, active=0, t_reset=0, targetpitch=800|
+      var testsig, comparison, integral, freq, hasFreq;
+      testsig = LeakDC.ar(Mix.ar(In.ar(in, 1))).poll(1, \sig);
+      # freq, hasFreq = Pitch.kr(testsig).poll(1, \pitch);
+      comparison = hasFreq.if(
+        (200 - ((freq - targetpitch).abs)).max(0),
+        0
+      ).poll(1, \comp);
+       // "0" if hasFreq==false because we don't want to encourage quietness
+
+      // Divide by the server's control rate to bring it within a sensible range.
+      comparison = comparison / ControlRate.ir;
+    
+      // Default coefficient of 1.0 = no leak. When t_reset briefly hits nonzero, the integrator drains.
+      integral = Integrator.kr(comparison * active, if(t_reset>0, 0, 1));
+      Out.kr(out, integral);
+    }).add;
+  }
 }

File phenosynth/phenomes.sc

     ^this.new(newChromosome);
   }
   *setUpSynthDefs {
-    SynthDef.writeOnce(
+    SynthDef.new(
       \ps_reson_saw,
       {|out=0, gate=0, t_reset=0, pitch, ffreq, rq|
         var env;
           )*env
         );
       }
-    );
+    ).add;
     map = (
       \pitch: \midfreq.asSpec,
       \ffreq: \midfreq.asSpec,
   play {|out, group|
     var mappedArgs;
     mappedArgs = this.chromosomeAsSynthArgs;
-    (['MAPPED'] ++ mappedArgs).postln;
     ^Synth.new(
       this.class.synthdef,
       args: [\out, out] ++ mappedArgs,