Commits

dan mackinlay  committed 949558f

logarithmic freq scaling

  • Participants
  • Parent commits 1541579

Comments (0)

Files changed (1)

File phenosynth/listensynthdefs.sc

     }).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);
+    SynthDef.new(\ps_listen_eight_hundred, { |in, out, active=0, t_reset=0, i_targetpitch=800|
+      var testsig, comparison, integral, freq, hasFreq, logtargetpitch;
+      logtargetpitch = i_targetpitch.log;
+      testsig = LeakDC.ar(Mix.ar(In.ar(in, 1)));
+      # freq, hasFreq = Pitch.kr(testsig);
       comparison = hasFreq.if(
-        (200 - ((freq - targetpitch).abs)).max(0),
+        (7 - ((freq.log) - logtargetpitch).abs).max(0),
         0
-      ).poll(1, \comp);
-       // "0" if hasFreq==false because we don't want to encourage quietness
+      );
+      // 0 if hasFreq.not 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;