-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDynamics.sc
79 lines (62 loc) · 1.26 KB
/
Dynamics.sc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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];
}
}