Permalink
Browse files

added subst method for Array

  • Loading branch information...
1 parent 6778d55 commit a0c0b370f6fceb3f960df28b8a3fef72938c12b4 @smoge committed Mar 14, 2011
Showing with 111 additions and 15 deletions.
  1. +68 −6 Array-ext.sc
  2. +34 −1 LilyRhythm.scd
  3. +7 −6 RhythmicGroup.sc
  4. +2 −2 RhythmicSystem.sc
View
@@ -1,26 +1,87 @@
+ Array {
+
+/*
+ method for substitution of a
+ Number with a Structure
+ inside a Structure:
+
+ a = [3, 2, 1, 2, 1]
+ a.subst(3, [2, 1, 2]) // ==> [ 3, 2, 1, [ 2, [ 2, 1, 2 ] ], 1 ]
+
+ This actually is a subdivision of a element in our score representation
+
+*/
+
+ subst { arg index, thisStruct;
+
+ case
+ {thisStruct.isKindOf(Array)}
+ {^this.put(index, [this.at(index), thisStruct])}
+
+ {thisStruct.isKindOf(Number)}
+ {^this.put(index, thisStruct)};
+ }
+
gdc {
if(this.containsSeqColl.not, {
^this.reduce({arg a, b; a.asInteger gcd: b.asInteger})
});
}
-
-
- asRC {
+
+ max {
+
+ if(this.containsSeqColl.not, {
+ ^this.reduce({arg a, b; a max: b})
+ });
+ }
+
+
+ min {
+
+ if(this.containsSeqColl.not, {
+ ^this.reduce({arg a, b; a min: b})
+ });
+ }
+
+
+ minSize {
+
+ ^(this.collect {|i| i.size}).min
+ }
+
+
+ maxSize {
+
+ ^(this.collect {|i| i.size}).max
+ }
+
+
+ asRhythmicCell {
+ ^RhythmicCell(this)
+ }
+
+
+ asRC {
^RhythmicCell(this)
}
+ asRhythmicSeq {
+
+ ^RhythmicSeq(this)
+ }
+
+
asRS {
-
+
^RhythmicSeq(this)
}
-
+
addRC { arg thisRSeq;
thisRSeq.put(this)
@@ -33,5 +94,6 @@
thisRSeq.put(i)
};
}
-
+
+
}
View
@@ -39,6 +39,8 @@ Post << f.([1,2,3,4], 5, 8)
+x.edit
+
a = [
[3, [1, [2, [1, 1, [1, [1, 1, 1]], 1, 1, 1]], 1, 4, 2]],
[4, [2, [2, [1, 1, 1, 1, 1, 1]], 1, 4, 2]],
@@ -50,8 +52,39 @@ a = [
[4, [4, [2, [1, 1, 1, 1, 1, 1, 1]], 2, 4, 1]]
];
-a.asRS.plot
+a.scramble.asRS
+
+[[1, 2, 3, 4], [[9, 1, 2], [8, 2, 3], [7, 4, 3]]].flop
+Help.gui
+
+
+x = RhythmicGroup2();
+x.putMeasure([2, 4, 3, 2, 3, 4, 2]);
+x.putStruct([[2, 1, 3, 2, 1], [1, 2, 1, 3, 2], [2, 1, 3, 2, 1, 2, 3, 2], [2, 1, 2, 3, 1]]);
+x.voiceArray
+x.structMatrix
+[
+ [2, 4, 3, 2, 3, 4, 2],
+ [[2, 1, 3, 2, 1], [1, 2, 1, 3, 2], [2, 1, 3, 2, 1, 2, 3, 2], [2, 1, 2, 3, 1]]
+].flop
+
+
+x.voice
+x.plot
+
+
+x.edit
+x.voiceArray
+
+x.structArray
+x.measureArray
+x.string
+
+(a.scramble.asRS)
+x.put(a.scramble.asRS)
+
+x.plot
a = [[10,20],[30, 40, 50], 60, 70, [80, 90, 100]];
View
@@ -33,7 +33,13 @@ RhythmicGroup : LilyShowableObj {
putArray { arg thisArray;
thisArray.do { |i|
- this.put(i)
+
+ case
+ {i.isKindOf(RhythmicSeq)}
+ {this.put(i)}
+
+ {i.isKIndOf(Array)}
+ {this.put(i.asRS)};
}
}
@@ -45,7 +51,6 @@ RhythmicGroup : LilyShowableObj {
this.voiceArray.do { |i|
outString = outString ++ i.staffString
};
-
^outString
}
@@ -55,13 +60,9 @@ RhythmicGroup : LilyShowableObj {
var outString = String.new;
outString = outString ++ "\\score {\n\t<<\n\t\t";
-
outString = outString ++ this.string;
-
// outString = outString ++ "\n \\midi { } \n\t \\layout { }\n";
-
outString = outString ++ "\n >> \n}\n\n";
-
^outString
}
View
@@ -1,7 +1,7 @@
/*
# Init #
-
+"Ctk".include
a = RhythmicSystem([2, 3, 4]) // <--- Init with measures
a.putMeasure([2, 3, 2]) // <---you can add more later
@@ -70,7 +70,7 @@ RhythmicSystem : LilyShowableObj {
///////////////////////////////////////////
- // Manipulations an measures and struct //
+ // Manipulations on measures and struct //
///////////////////////////////////////////
scrambleMeasures {

0 comments on commit a0c0b37

Please sign in to comment.