Parcel/Plib/Pout

//Julian Rohrhuber 08/01
//creating a new parcel will put its pattern into the Library, just like in Instrument

Parcel : Pattern {
 var <name, <pattern;
 *initClass {
  Library.put(\patterns, \empty, Pbind(
       \freq, Pseq([\rest]),
       \delta, Pseq([0.0])
      ));
  Library.put(\patterns, \rest, Pbind(
     \freq, Pseq([\rest]),
     \dur, Pseq([1])
     ));
  Library.put(\patterns, \loopdur, Pseq([4], 1));
  

  
 }
 
 *new { arg name, pattern;
  ^super.newCopyArgs(name, pattern).init;
 }
 init {
  Library.put(\patterns, name, this);
 }
 asStream { ^pattern.asStream }

}

//playing from the Library
Plib : Pattern {
 var <>whichName, <>key;
 *new { arg whichName, key=\patterns;
  ^super.newCopyArgs(whichName, key)
 }
 asStream {
  ^Routine.new({ arg inval;
   var item, name, nameStream;
   if(whichName.isKindOf(Symbol), {
    Library.at(key, whichName).embedInStream(inval)
   }, {
    nameStream = whichName.asStream;
    while ({
     (name = nameStream.next).notNil;
    },{
     item = Library.at(key, name);
     if(item.isNil, { name.post; " not found".postln; item = Library.at(key, name, \empty) });
     item.embedInStream(inval);
    })
   })
  })
 }
}

//will play the pattern that is in the Library at key \out, looping it with the
//duration that is supplied by the pattern at key \loopdur.

Pout : Plib {
 *new {
  
 
  
  ^Pseq([
   Pfindur2(Plib(\loopdur), Plib(\out))
   ], inf);
 }
 
 *ar { arg channels, protoEvent; ^this.new.ar(channels, protoEvent) }
}












This page was created by SimpleText2Html 1.0.3 on 13-Aug-101.