Commits

dan mackinlay  committed f29767b

track phenosynths to allow routing of responders to 'em

  • Participants
  • Parent commits 3dcc55f

Comments (0)

Files changed (1)

File phenosynth/phenosynth.sc

 Genosynth {
   /* A factory for Phenosynths wrapping a given Instr. You would have one of
   these for each population, as a rule.*/
-  var <voxInstr, <voxDefaults, <listenInstrName, <listenExtraArgs, <sourceGroup, <outBus, <numChannels, <>phenoClass, <chromosomeMap, <triggers, <listenInstr, <evalPeriod, <voxGroup;
+  var <voxInstr, <voxDefaults, <listenInstrName, <listenExtraArgs, <sourceGroup, <outBus, <numChannels, <>phenoClass, <chromosomeMap, <triggers, <listenInstr, <evalPeriod, <voxGroup, <all;
   classvar <defaultVoxInstr="phenosynth.vox.default";
   classvar <defaultListenInstr="phenosynth.listeners.default";
 
       (phenoClass ? ListenPhenosynth)).init;
   }
   init {
+    all = IdentityDictionary.new;
     chromosomeMap = this.class.getChromosomeMap(voxInstr);
     // pad voxDefaults out to equal number of args
     voxDefaults = voxDefaults.extend(voxInstr.specs.size, nil);
   }
   spawn { |chromosome|
     //return a listened phenosynth
-    ^phenoClass.new(this, voxInstr, voxDefaults, chromosomeMap, triggers, listenInstrName, evalPeriod, listenExtraArgs, chromosome);
+    var newPhenosynth;
+    newPhenosynth = phenoClass.new(this, voxInstr, voxDefaults, chromosomeMap, triggers, listenInstrName, evalPeriod, listenExtraArgs, chromosome);
+    //Should this registering-with-all business be the job of the Phenosynth
+    //for consistency?
+    all.put(newPhenosynth.identityHash, newPhenosynth);
+    ^newPhenosynth;
+  }
+  reap { |phenosynth|
+    all.removeAt(phenosynth.identityHash);
   }
   newChromosome {
     ^{1.0.rand}.dup(chromosomeMap.size);
     this.trigger();
   }
   free {
+    genosynth.reap(this);
     this.freeSynthDef(voxPatch);
     voxPatch.free;
   }