Permalink
Browse files

added some tools

  • Loading branch information...
1 parent bc1ef52 commit 2536d5bd3485b63b06169f04a55b200a883cbd95 @smoge committed Mar 11, 2011
Showing with 1,016 additions and 0 deletions.
  1. +187 −0 DynSeq.sc
  2. +79 −0 Dynamics.sc
  3. +58 −0 FMChord.sc
  4. +83 −0 LilyDynamics.sc
  5. +67 −0 Metro.sc
  6. +54 −0 Segment.sc
  7. +99 −0 SerialMatrix.sc
  8. +221 −0 TendencyMask.sc
  9. +117 −0 TimeSpan.sc
  10. +51 −0 ext-SequenceableCollection.sc
View
@@ -0,0 +1,187 @@
+/*
+
+# LilyDynSeq.sc #
+
+_Sequenceble Collection of Dyn (Dynamics) Instances_
+See Dyn.sc
+
+
+## Default ##
+
+ scale = [\ppp, \pp, \p, \mp, \mf, \f, \ff, \fff]
+ values: 0.0 <-> 1.0
+
+
+## Usage ##
+
+ a = LilyDynSeq.new([0.3, 0.2, 0.4])
+ a = LilyDynSeq.new(
+ ((1..10)/10).scramble,
+ [\pppp, \ppp, \pp, \p, \mp, \mf, \f, \ff, \fff, \ffff]
+ );
+
+ a.dynSeq
+ a.add(0.9)
+ a.add(0.1)
+ a.dynSeq[0]
+ a.dynSeq[1]
+ a.scDyn
+ a.asString
+ a.str_([\pp, \mp, \f])
+ a.dynSeq[0]
+ a.newRange(0.3, 0.6)
+ a.scramble
+ a.invert
+ a.reverse
+ a.rotate(2)
+ a.mean
+ a.first
+ a.firstStr
+ a.last
+ a.lastStr
+ a.permute(1)
+ a.plot
+ a.setTable(9)
+
+*/
+
+LilyDynSeq {
+
+ var <dynSeq, <dynStringList;
+
+ *new { | dynSeq, dynStringList |
+ ^super.new.initDynSeq(dynSeq, dynStringList);
+ }
+
+ initDynSeq { arg newDynSeq = [0.5], newStringList = [\ppp, \pp, \p, \mp, \mf, \f, \ff, \fff];
+
+ this.dynSeq_(newDynSeq);
+ dynStringList = newStringList;
+
+ }
+
+ dynSeq_ { | newDynSeq |
+
+ dynSeq = newDynSeq.collect({|i|
+ LilyDyn(i, dynStringList);
+ });
+ }
+
+ scDyn {
+
+ ^dynSeq.collect({ | i |
+ i.scDyn
+ })
+ }
+
+ vol_ { | newDynSeq |
+
+ dynSeq = Array.newClear(newDynSeq.size);
+ dynSeq = newDynSeq.collect({|i|
+ LilyDyn(i, dynStringList);
+ });
+ }
+
+ size {
+ ^dynSeq.size
+ }
+
+ asString {
+ ^dynSeq.collect({|i|
+ i.asString;
+ })
+ }
+
+ str_ { | newStrList |
+ max(newStrList.size, dynSeq.size).do({|i|
+ dynSeq[i].str_(newStrList[i])
+ })
+ }
+
+ newRange { arg newMin, newMax, newDynString = dynStringList;
+ var newVol;
+ newVol = this.scDyn.normalize * (newMax - newMin) + newMin;
+
+ dynSeq = newVol.collect({|i|
+ LilyDyn(i, newDynString);
+ });
+ }
+
+ invert { arg newDynString = dynStringList;
+ dynSeq = this.scDyn.invert.collect({|i|
+ LilyDyn(i, newDynString);
+ });
+ }
+
+ reverse { arg newDynString = dynStringList;
+ dynSeq = this.scDyn.reverse.collect({|i|
+ LilyDyn(i, newDynString);
+ });
+ }
+
+ scramble { arg newDynString = dynStringList;
+ dynSeq = this.scDyn.scramble.collect({|i|
+ LilyDyn(i, newDynString);
+ });
+ }
+
+
+ rotate { arg thisArg, newDynString = dynStringList;
+ dynSeq = this.scDyn.rotate(thisArg).collect({|i|
+ LilyDyn(i, newDynString);
+ });
+ }
+
+ add { arg thisArg, newDynString = dynStringList;
+ dynSeq = this.scDyn.add(thisArg).collect({|i|
+ LilyDyn(i, newDynString);
+ });
+ }
+
+ permute { arg thisArg, newDynString = dynStringList;
+ dynSeq = this.scDyn.permute(thisArg).collect({|i|
+ LilyDyn(i, newDynString);
+ });
+ }
+
+ mean {
+ ^LilyDyn(this.scDyn.mean, dynStringList);
+ }
+
+ first {
+ ^this.scDyn.first;
+ }
+
+ firstStr {
+ ^this.asString.first;
+ }
+
+ last {
+ ^this.scDyn.last;
+ }
+
+ lastStr {
+ ^this.asString.last;
+ }
+
+ sum {
+ ^this.scDyn.sum
+ }
+
+ plot {
+ this.scDyn.plot(discrete: true, minval: 0.0, maxval:1.0)
+ }
+
+ setTable { |n|
+
+ var thisWindow, thisMultiSlider, thisArray;
+ thisArray = Array.newClear(n);
+ thisWindow = Window.new(this.class.asString, Rect(316, 409, n*13+20, 220)).front;
+ thisMultiSlider = GUI.multiSliderView.new(thisWindow,Rect(7, 9, n*13+2, 200));
+ thisMultiSlider.value=Array.fill(n, {|v| 0.5.gauss(0.1)});
+ thisMultiSlider.action_{|v|
+ this.vol_(v.value);
+ this.asString.postln;
+ };
+ }
+}
View
@@ -0,0 +1,79 @@
+/*
+ Dyn.sc
+
+ Use:
+
+ a = Dyn(0.9)
+ a.scDyn
+ a.vol_(0.2)
+ a.str_(\mf)
+ a.scale
+ a.scale = [\p, \mp, \mf, \f, \ff]
+ a.size
+ a.scList
+ a.showDict
+ a.scDynList
+ a.asString
+ a.string_(\mp)
+ a.scDyn
+
+*/
+
+Dyn {
+
+ var <scDyn, <lilyDyn, <>scale, <dynScList, <dynDict, <scDynList;
+
+ *new { arg scDyn, scale;
+ ^super.new.initDyn(scDyn, scale);
+ }
+
+ initDyn { arg newScDyn=0.5, newStringList = [\ppp, \pp, \p, \mp, \mf, \f, \ff, \fff];
+ this.scDyn_(newScDyn);
+ scale = newStringList;
+ }
+
+ scDyn_ { arg newScDyn;
+ scDyn = newScDyn;
+ }
+
+ vol_ { arg newScDyn;
+ scDyn = newScDyn;
+ }
+
+ size {
+ ^scale.size;
+ }
+
+ scList {
+ ^scDynList = Array.series(this.size, 1.0, -1/(this.size-1)).invert
+ }
+
+ dict {
+ dynDict = Dictionary.new;
+ scale.size.do({|i|
+ dynDict.put( scale[i], this.scList[i] )
+ });
+ }
+
+ showDict {
+ this.dict;
+ ^dynDict;
+ }
+
+ asString {
+ var list;
+ list = this.scList;
+ ^scale.at(list.indexIn(scDyn))
+ }
+
+ string_ { arg newValue;
+ this.dict;
+ scDyn = dynDict[newValue];
+ }
+
+ str_ { arg newValue;
+ this.dict;
+ scDyn = dynDict[newValue];
+ }
+
+}
View
@@ -0,0 +1,58 @@
+/*
+ 'Frequency Modulation' Chord
+ Arguments: carrier, modulator, index
+
+ Use:
+
+ a = FMChord.new(7, -5, 9)
+ a
+ a.index
+ a.car
+ a.car = 4
+ a.mod
+ a.addChord.plot
+ a.diffChord.plot
+ a.fmChord.plot
+
+*/
+
+
+FMChord {
+
+ var <>car, <>mod, <>index;
+
+ *new {|car, mod, index|
+ ^super.new.init(car, mod, index);
+ }
+
+ init {arg thiCar = 7, thiMod = -4, thisIndex = 9;
+
+ car = thiCar;
+ mod = thiMod;
+ index = thisIndex;
+ }
+
+ addChord {
+ var addChordCps;
+ addChordCps = index.collect {|i|
+ (car+60).midicps + ((i+1) * (mod+60).midicps);
+ };
+ ^LilyChord.new(addChordCps.cpsmidi - 60);
+ }
+
+
+ diffChord {
+ var diffChordCps;
+ diffChordCps = index.collect {|i|
+ (car+60).midicps - ((i+1) * (mod+60).midicps);
+ };
+ ^LilyChord.new(diffChordCps.cpsmidi - 60);
+ }
+
+ fmChord {
+ ^LilyChord.new(
+ (this.diffChord.notenumber) ++ (this.addChord.notenumber)
+ );
+ }
+
+}
Oops, something went wrong. Retry.

0 comments on commit 2536d5b

Please sign in to comment.