You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
112 lines
4.1 KiB
Plaintext
112 lines
4.1 KiB
Plaintext
7 months ago
|
(
|
||
|
SynthDef(\string_model, {arg freq, gate = 1, del, sustain, amp, dur, attack, release = 1, busIndex = 0;
|
||
|
var trig, exc, sig1, sig2, noHarms;
|
||
|
noHarms = rrand(20, 40);
|
||
|
exc = Saw.ar(freq, TRand.ar(0.5, 1, Impulse.ar(freq))) * 0.001 + Dust.ar(10000, 0.01);
|
||
|
sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq),
|
||
|
Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}),
|
||
|
Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.8).softclip;
|
||
|
Out.ar([0, 1], 0.75 * sig1 * amp * EnvGen.kr(Env.dadsr(del, attack, 0.3, 0.9, release, 0.9, -3), gate, doneAction: 2));
|
||
|
}).add;
|
||
|
)
|
||
|
|
||
|
(
|
||
|
var primes, hsArrayToFreq, hsArrayDimDiff, file, seq, phraseLengths, musicData, patterns;
|
||
|
|
||
|
thisThread.randSeed = 1923;
|
||
|
|
||
|
primes = [2, 3, 5, 7, 11];
|
||
|
|
||
|
hsArrayToFreq = {
|
||
|
arg array;
|
||
|
array.collect({arg dim, d; pow(primes[d], dim)}).product
|
||
|
};
|
||
|
|
||
|
hsArrayDimDiff = {
|
||
|
arg array1, array2;
|
||
|
var fArray;
|
||
|
fArray = array2.drop(1) - array1.drop(1);
|
||
|
if(fArray.sum == 0, {1}, {(primes[fArray.abs.indexOf(1) + 1] * fArray.sum)})
|
||
|
};
|
||
|
|
||
|
file = File("/home/mwinter/Sketches/compact_sets/seq.txt".standardizePath,"r");
|
||
|
seq = file.readAllString.interpret;
|
||
|
|
||
|
//seq = seq.collect({arg item; item.sort});
|
||
|
seq = seq.collect({arg chord, index;
|
||
|
var ref_ins;
|
||
|
ref_ins = if(index == 0, {0}, {[seq[index - 1], chord].flop.collect({arg pair; pair[0] == pair[1]}).indexOf(true)});
|
||
|
chord.collect({arg pitch;
|
||
|
var dimDiff;
|
||
|
[pitch, [ref_ins, hsArrayDimDiff.value(chord[ref_ins], pitch)]]
|
||
|
})
|
||
|
});
|
||
|
|
||
|
seq.do({arg chord; chord.postln; chord.collect({arg pitch; hsArrayToFreq.value(pitch[0])}).postln});
|
||
|
//seq.postln;
|
||
|
|
||
|
|
||
|
phraseLengths = [];
|
||
|
while({phraseLengths.sum < seq.size}, {phraseLengths = phraseLengths ++ [rrand(1, 3)]});
|
||
|
//phraseLengths.postln;
|
||
|
|
||
|
musicData = seq.clumps(phraseLengths).collect({arg subSeq, seqIndex;
|
||
|
var baseRound, baseDurs;
|
||
|
baseRound = 0.5;
|
||
|
baseDurs = subSeq.size.collect({arg subSeqIndex; if(subSeqIndex != (subSeq.size - 1), {rrand(5.0, 7.0)}, {rrand(10.0, 15.0)})}).round(baseRound);
|
||
|
subSeq.flop.collect({arg voice, v;
|
||
|
var phrases, freqs, durs, delays, attacks, rels, sustains, amps, refs;
|
||
|
phrases = voice.separate({arg a, b; a[0] != b[0]});
|
||
|
freqs = phrases.collect({arg phrase; if(phrase[0][0] != ["Rest"], {48.midicps * pow(2, (v * 2).clip(0, 1)) * hsArrayToFreq.value(phrase[0][0])}, {Rest(0)})});
|
||
|
refs = phrases.collect({arg phrase; if(phrase[0][0] != ["Rest"], {phrase[0][1]}, {Rest(0)})});
|
||
|
durs = baseDurs.clumps(phrases.collect({arg phrase; phrase.size})).collect({arg c; c.sum});
|
||
|
delays = durs.collect({arg dur; rrand(0.0, 0.0)}).round(baseRound);
|
||
|
//durs = durs + delays;
|
||
|
attacks = durs.collect({arg dur, d; if(d == 0, {rrand(3.0, 5.0)}, {rrand(1.0, 3.0)})}).round(baseRound);
|
||
|
rels = durs.collect({arg dur, d; if(d != (durs.size - 1), {rrand(0.5, 1.0)}, {rrand(3.0, 5.0)})}).round(baseRound);
|
||
|
//sustains = durs.collect({arg dur, d; if(d != (durs.size - 1), {dur - rels[d] - delays[d]}, {dur - rels[d] - delays[d]})});
|
||
|
sustains = durs.collect({arg dur, d; if(d != (durs.size - 1), {dur}, {dur - rrand(3.0, 5.0)})}).round(baseRound);
|
||
|
amps = freqs.collect({rrand(0.6, 0.7) / [1, 2, 2][v]});
|
||
|
[freqs, durs, attacks, delays, sustains, rels, amps, refs].flop;
|
||
|
});
|
||
|
}).flop.collect({arg voice; voice.flatten});
|
||
|
|
||
|
musicData = musicData.collect({arg voice, v;
|
||
|
var clumps;
|
||
|
//(v + "~~~~~~~~~~").postln;
|
||
|
clumps = voice.separate({arg a, b; [true, a[0] != b[0]].wchoose([1, 1].normalizeSum)});
|
||
|
clumps = clumps.collect({arg clump;
|
||
|
if(clump.size == 1, {clump[0]}, {
|
||
|
var mergedClump;
|
||
|
mergedClump = clump[0].deepCopy;
|
||
|
mergedClump[1] = clump.slice(nil, 1).sum;
|
||
|
mergedClump[4] = mergedClump[1] - (clump.last[1] - clump.last[4]);
|
||
|
mergedClump
|
||
|
});
|
||
|
});
|
||
|
});
|
||
|
|
||
|
~musicData = musicData;
|
||
|
|
||
|
~patterns = Ppar(
|
||
|
musicData.postln.collect({arg voice, v;
|
||
|
var freqs, durs, attacks, delays, sustains, rels, amps;
|
||
|
# freqs, durs, attacks, delays, sustains, rels, amps = voice.flop;
|
||
|
Pbind(
|
||
|
\instrument, \string_model,
|
||
|
\freq, Pseq(freqs, 1),
|
||
|
\dur, Pseq(durs, 1),
|
||
|
\attack, Pseq(attacks, 1),
|
||
|
\sustain, Pseq(sustains, 1),
|
||
|
\release, Pseq(rels, 1),
|
||
|
\amp, Pseq(amps, 1),
|
||
|
\del, Pseq(delays, 1),
|
||
|
\busIndex, v
|
||
|
)
|
||
|
});
|
||
|
);
|
||
|
|
||
|
~patterns.play
|
||
|
)
|
||
|
|
||
|
~patterns.play
|