You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
distances-bending/sclang/generate-score_2023.scd

280 lines
6.1 KiB

(
// generate score II - V (unsorted)
// sound parameters - dif[ference tones], noi[se flute], fut[ure tones]
//
~ii = Dictionary.newFrom(
[\label, "II ", \dif, [[20,40], [1,1]], \noi, [[\a,\b,\c,], [0,1,2]],
\fut, [[800,880,900,1000,1100],[1,2,3]]]);
~iii = Dictionary.newFrom(
[\label, "III", \dif, [[40,80],[1,1]], \noi, [[\d,\e,\f],[0,1,2]],
\fut, [[1760,1800,2020],[1,2,3]]]);
~iv = Dictionary.newFrom(
[\label, "IV ", \dif, [[80,160],[0,1,2]], \noi, [[nil],[0]],
\fut, [[3000,3300,4200],[1,2,3]]]);
~v = Dictionary.newFrom(
[\label, "V ", \dif, [[0],[0]], \noi, [[\g,\h],[0,1,2]],
\fut, [[6000],[1]]]);
// temporal bounds
"".postln; "Temporal constraints".postln;
[~ii, ~iii, ~iv, ~v].do({ arg item, i; var a, b, c;
// minutes [start, duration]
a = [[0, 19], [20, 13], [40, 8], [49, 5]];
// .put: Associate two objects and add them to the Dictionary.
item.put(\start, a[i].at(0));
item.put(\duration, a[i].at(1));
item.put(\end, a[i].at(1)); // unused?
item.put(\bounds, a.at(i)); // unused?
// seconds - unused for now
b = a.deepCollect(2, { arg j; j * 60});
c = b.collect({ arg k; k[1] = k[0] + k[1]});
// post
(item[\label].asString + item[\bounds].asString + "minutes").postln });
// generate scores II - V (unsorted)
"".postln; " s c o r e".postln;
[~ii, ~iii, ~iv, ~v].do({ arg section, i;
"".postln;
(" * *" + section[\label]).postln;
// difference tones and noise samples
// may repeat
[\dif, \noi].do({ arg it; // the types of event we want
n = section[it][1].choose; // the no. of events of each type
if ( n > 0, {("##" + it.asString ++ ": ").postln}, {}); // label: type
n.do({ arg i;
(section[it][0].choose.asString ++ ": ").post; // freq / sample code
((section[\duration].rand + section[\start]).asString
+ "min." + 60.rand.asString).post; // timestamp
"".postln; "".postln;
});
});
// future tones
// one use per frequency
x = section[\fut][0];
n = section[\fut][1].choose; // the no. of events of each type
if ( n > 0, {("##" + \fut.asString ++ ": ").postln}, {}); // label: type
n.do ({ arg i;
// choose a frequency, return it and delete it from the array
(x.removeAt(x.size.rand).asString ++ ": ").post;
((section[\duration].rand + section[\start]).asString
+ "min." + 60.rand.asString).postln; // timestamp
});
// "".postln;
});
// since removeAt has deleted items from \fut,
// (because we didn't want future tones to be repeatable)
// restore the dictionary so that we can generate
// a new score when we want to
// TODO: make an unrepeating stream up to n and
// use that to select \fut items rather than removing them
f = [
[[800,880,900,1000,1100],[1,2,3]],
[[1760,1800,2020],[1,2,3]],
[[3000,3300,4200],[1,2,3]],
[[6000],[1]]];
// .add: if the key value pair already exists in the Dictionary, the key's value will be replaced
[~ii, ~iii, ~iv, ~v].do({ arg section, i; section.add(\fut -> f[i].value ) });
"";
)
// current code ends here
// below here, only scraps of earlier code
)
x = ~ii[\fut][0];
y = x.size.rand;
x.removeAt(x.size.choose);
x;
(
// generate scores II - V (unsorted, repeats allowed)
"".postln;
[~ii, ~iii, ~iv, ~v].do({ arg item, i;
("*" + item[\label]).postln;
[\dif, \noi, \fut].do({ arg it; // the types of event we want
n = item[it][1].choose; // the no. of events of each type
if ( n > 0, {("##" + it.asString ++ ": ").postln}, {}); // label: type
//"".postln;
n.do({ arg i;
(item[it][0].choose.asString ++ ": ").post; // freq / sample code
((item[\duration].rand + item[\start]).asString
+ "min." + 60.rand.asString).post; // timestamp
"".postln; "".postln;
});
});
"".postln;
});
"".postln;
)
(
// generate score II
"".postln; "* II *".postln;
"".postln;
[\dif, \noi, \fut].do({ arg it; // the types of event we want
n = ~ii[it][1].choose; // the no. of events of each type
if ( n > 0, {("##" + it.asString ++ ": ").postln}, {}); // label: type
//"".postln;
n.do({ arg i;
(~ii[it][0].choose.asString ++ ": ").post; // freq / sample code
(~ii[\duration].rand.asString
+ "min." + 60.rand.asString).post; // timestamp
"".postln; "".postln;
});
});
"".postln;
)
(
"".postln;
"~lengthII = ".post; ~lengthII = (11 * 60).postln; // total section time
"n = ".post; n = [1,2,3].choose.postln; // no. of rests
"~lengthRstsII = ".post; ~lengthRstsII = ( ~lengthII - (n * 31.5) ).postln;
// rest lengths will go in here
a = Array.fill([2,n], 0);
// iterate over n rest events
n.do({ arg i; var j, k;
j = i - 1;
// for this rest, put duration in row 0
k = if( i > 0, // after first iteration
{ a[1].at(j) }, { 0 }); //
a[0].put( i, (~lengthRstsII - k).rand.asInteger.max(30) );
// put sum of durations through n in row 1
l = if( i > 0,
{ a[0].at(i) + a[1].at(j) }, { a[0].at(i) } );
a[1].put( i, l);
});
a;
)
a;
a[0] = ~lengthRstsII.rand.asInteger;
a[1] = (~lengthRstsII - a[0]).rand.asInteger ;
a[2] = (~lengthRstsII - a[0])
~lengthRstsII - a[1];
(
n = 3;
n.do({
arg i;
j = i - 1;
a[i] = (~lengthRstsII - ( a.at(j) )).rand.asInteger;
});
)
(
j = 5;
while( {j > 0}, {
j.postln;
j = j - 1;
} )
)
(
n = 3;
n.do({ arg i; var j;
j = n - i - 1;
{j > -1}.while( {
j.postln;
j = (j - 1)
} )
});
)
(
n.do( { arg i; r = r.put( i, Rest().asString ) } )
)
// number of total elements
g = Array.fill(( n * 2 + 1 ), "rest");
// set the note durations to 30s
// n.do({ arg i; g = g.put( (i * 2 + 1), 30) });
g.size.do( { arg i; g = g.put(i, if( i.even, "Rest()", 30) ) } ); g
)
p = (n * 2 + 1);
d = Array.fill(p, { arg i;
if(
i.even, Rest
)
})
"total = ".postln; (~r3 + ~r1 + ~r2 + ~lengthEvtsII);
)
~durations = [Rest(~r1), 30, Rest(~r2), 30, Rest(~r3), 30];
(
"n = ".post; n = [1,2,3].choose.postln;
p = (n * 2 + 1);
f = Array.fill( p, { [20,40].choose }).postln;
d = Array.fill( p, { arg i; if(i.even, Rest(30.rand).asString, 30)});
)
(
p = Pbind (
\instrument, "sine",
\freq, Pseq([800, 0, 1100, 600], 1),
\dur, Pseq([2, Rest(1), 2, 2], 1),
\amp, 4
// \futrrelease, 2,
// \legato, 0.1
).play;
)