|
|
@ -59,13 +59,13 @@ harmonicDistance = {arg fr; log2(fr[0].asFloat.product * fr[1].asFloat.product)}
|
|
|
|
|
|
|
|
|
|
|
|
//~~~~~~~~~~~~GENERATE MODE~~~~~~~~~~~~
|
|
|
|
//~~~~~~~~~~~~GENERATE MODE~~~~~~~~~~~~
|
|
|
|
//TODO: Play with this a bit more (should I go back to the old way)
|
|
|
|
//TODO: Play with this a bit more (should I go back to the old way)
|
|
|
|
genMode = {
|
|
|
|
genMode = {arg forceHS = false;
|
|
|
|
var mode, alternateProb;
|
|
|
|
var mode, alternateProb;
|
|
|
|
alternateProb = [1, 0].wchoose([1, 4].normalizeSum);
|
|
|
|
alternateProb = [1, 0].wchoose([if(forceHS, {0}, {1}), 4].normalizeSum);
|
|
|
|
mode = [
|
|
|
|
mode = [
|
|
|
|
[1, 1],
|
|
|
|
[1, 1],
|
|
|
|
[9, 8],
|
|
|
|
[9, 8],
|
|
|
|
[[5, 4], [6, 5]].wchoose([3, 1].normalizeSum),
|
|
|
|
[[5, 4], [6, 5]].wchoose([3, if(forceHS, {0}, {1})].normalizeSum),
|
|
|
|
[[4, 3], [11, 8]].wchoose([alternateProb, 1].normalizeSum),
|
|
|
|
[[4, 3], [11, 8]].wchoose([alternateProb, 1].normalizeSum),
|
|
|
|
[3, 2],
|
|
|
|
[3, 2],
|
|
|
|
[[8, 5], [13, 8]].wchoose([alternateProb, 1].normalizeSum),
|
|
|
|
[[8, 5], [13, 8]].wchoose([alternateProb, 1].normalizeSum),
|
|
|
@ -119,7 +119,7 @@ initModeState = {
|
|
|
|
curModeState;
|
|
|
|
curModeState;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
advanceMode = {arg lastModeState, lastCadenceState;
|
|
|
|
advanceMode = {arg lastModeState, lastCadenceState, forceHS = false;
|
|
|
|
var curModeState, curRoots, lastRoots, lastCadenceRoot, changeCount;
|
|
|
|
var curModeState, curRoots, lastRoots, lastCadenceRoot, changeCount;
|
|
|
|
|
|
|
|
|
|
|
|
curModeState = lastModeState.deepCopy;
|
|
|
|
curModeState = lastModeState.deepCopy;
|
|
|
@ -169,10 +169,10 @@ advanceMode = {arg lastModeState, lastCadenceState;
|
|
|
|
old = frNearestInList.value([new, rootSel], curModeState);
|
|
|
|
old = frNearestInList.value([new, rootSel], curModeState);
|
|
|
|
if(curModeState[old][\count] >= 20, {
|
|
|
|
if(curModeState[old][\count] >= 20, {
|
|
|
|
var mode, root;
|
|
|
|
var mode, root;
|
|
|
|
mode = genMode.value;
|
|
|
|
//mode = genMode.value;
|
|
|
|
root = [rootSel, curModeState[rootSel][\mode]];
|
|
|
|
root = [rootSel, curModeState[rootSel][\mode]];
|
|
|
|
curModeState.add(new ->
|
|
|
|
curModeState.add(new ->
|
|
|
|
Dictionary.with(*[\count->1,\mode->genMode.value, \root->root, \mult->multSel, \fr->new]));
|
|
|
|
Dictionary.with(*[\count->1,\mode->genMode.value(forceHS), \root->root, \mult->multSel, \fr->new]));
|
|
|
|
curModeState.removeAt(old);
|
|
|
|
curModeState.removeAt(old);
|
|
|
|
changeCount = changeCount + 1;
|
|
|
|
changeCount = changeCount + 1;
|
|
|
|
})
|
|
|
|
})
|
|
|
@ -278,7 +278,7 @@ genEnsemblePart = {arg partState, modeState, temporalData, roots, part, offset;
|
|
|
|
|
|
|
|
|
|
|
|
partState[\lastDur] = partState[\lastDur] + 1;
|
|
|
|
partState[\lastDur] = partState[\lastDur] + 1;
|
|
|
|
timeStamp = ts + offset;
|
|
|
|
timeStamp = ts + offset;
|
|
|
|
change = [val == 1, (val == 1) && firstChange.not].wchoose([1, 2].normalizeSum);//5 * abs((curPulse / totalLen).clip(0, 1) - 1)].normalizeSum);
|
|
|
|
change = [val == 1, (val == 1) && firstChange.not].wchoose([1, 2].normalizeSum);//5 * abs((curPulse / minTotalLen).clip(0, 1) - 1)].normalizeSum);
|
|
|
|
if(
|
|
|
|
if(
|
|
|
|
(partState[\index] == 0) &&
|
|
|
|
(partState[\index] == 0) &&
|
|
|
|
(frToFloat.value(partState[\lastFreqRatio]) >= 4.0) &&
|
|
|
|
(frToFloat.value(partState[\lastFreqRatio]) >= 4.0) &&
|
|
|
@ -359,7 +359,7 @@ genAccompPart = {arg modeState, temporalData, offset, trans, part, register;
|
|
|
|
accompData = [];
|
|
|
|
accompData = [];
|
|
|
|
temporalData.do({arg val, tS;
|
|
|
|
temporalData.do({arg val, tS;
|
|
|
|
var change;
|
|
|
|
var change;
|
|
|
|
change = [val == 1, (val == 1) && firstChange.not].wchoose([1, if(part == 0, {5}, {3})].normalizeSum); //5 * abs((curPulse / totalLen).clip(0, 0.8) - 1)].normalizeSum);
|
|
|
|
change = [val == 1, (val == 1) && firstChange.not].wchoose([1, if(part == 0, {5}, {3})].normalizeSum); //5 * abs((curPulse / minTotalLen).clip(0, 0.8) - 1)].normalizeSum);
|
|
|
|
if(change, {
|
|
|
|
if(change, {
|
|
|
|
var sel, freq, amp;
|
|
|
|
var sel, freq, amp;
|
|
|
|
sel = wchooseDict.value(modeState, 0.1);
|
|
|
|
sel = wchooseDict.value(modeState, 0.1);
|
|
|
@ -422,8 +422,9 @@ genAmpCurve = {arg temporalData1, temporalData2, offset1, offset2, type;
|
|
|
|
|
|
|
|
|
|
|
|
//~~~~~~~~~~~~GENERATE ALL MUSIC DATA~~~~~~~~~~~~
|
|
|
|
//~~~~~~~~~~~~GENERATE ALL MUSIC DATA~~~~~~~~~~~~
|
|
|
|
~genMusicData = {arg seed;
|
|
|
|
~genMusicData = {arg seed;
|
|
|
|
var totalDur, section1Dur, dUnit, curLen, cadence, ultimate,
|
|
|
|
var minTotalDur, minSection1Dur, dUnit, curLen, cadence,
|
|
|
|
totalLen, section1Len,
|
|
|
|
ultimateSubsection, ultimateSection, ultimateCadenceCount,
|
|
|
|
|
|
|
|
minTotalLen, minSection1Len,
|
|
|
|
modeState, temporalState, partStates,
|
|
|
|
modeState, temporalState, partStates,
|
|
|
|
lastCadenceTemporalData, lastCadenceState, lastSectionPoint,
|
|
|
|
lastCadenceTemporalData, lastCadenceState, lastSectionPoint,
|
|
|
|
ensData, accompData, bassData, ampData,
|
|
|
|
ensData, accompData, bassData, ampData,
|
|
|
@ -431,19 +432,20 @@ genAmpCurve = {arg temporalData1, temporalData2, offset1, offset2, type;
|
|
|
|
sectionCount, subsectionCount,
|
|
|
|
sectionCount, subsectionCount,
|
|
|
|
lastRoots, roots, ampDataTmp;
|
|
|
|
lastRoots, roots, ampDataTmp;
|
|
|
|
|
|
|
|
|
|
|
|
thisThread.randSeed = seed.postln;
|
|
|
|
thisThread.randSeed = seed;
|
|
|
|
|
|
|
|
|
|
|
|
# totalDur, section1Dur, dUnit, curLen, cadence, ultimate = [16 * 60, 8 * 60, 8.reciprocal, 0, false, false];
|
|
|
|
# minTotalDur, minSection1Dur, dUnit, curLen, cadence = [15 * 60, 8 * 60, 8.reciprocal, 0, false];
|
|
|
|
# totalLen, section1Len = [(totalDur / dUnit).round(16), (section1Dur / dUnit).round(16)];
|
|
|
|
# ultimateSubsection, ultimateSection, ultimateCadenceCount = [false, false, 0];
|
|
|
|
|
|
|
|
# minTotalLen, minSection1Len = [(minTotalDur / dUnit).round(16), (minSection1Dur / dUnit).round(16)];
|
|
|
|
# modeState, temporalState, partStates = [initModeState.value, initTemporalState.value, initPartStates.value];
|
|
|
|
# modeState, temporalState, partStates = [initModeState.value, initTemporalState.value, initPartStates.value];
|
|
|
|
# lastCadenceTemporalData, lastCadenceState, lastSectionPoint = [nil, modeState.deepCopy, 0];
|
|
|
|
# lastCadenceTemporalData, lastCadenceState, lastSectionPoint = [nil, modeState.deepCopy, 0];
|
|
|
|
# ensData, accompData, bassData, ampData = [4.collect({[]}), 4.collect({6.collect({[]})}), 2.collect({[]}), 3.collect({[]})];
|
|
|
|
# ensData, accompData, bassData, ampData = [4.collect({[]}), 4.collect({6.collect({[]})}), 2.collect({[]}), 3.collect({[]})];
|
|
|
|
# sectionData, sectionNavDict = [Dictionary.new, Dictionary.new];
|
|
|
|
# sectionData, sectionNavDict = [Dictionary.new, Dictionary.new];
|
|
|
|
# sectionCount, subsectionCount = [1, 1];
|
|
|
|
# sectionCount, subsectionCount = [1, 1];
|
|
|
|
|
|
|
|
|
|
|
|
while({(curLen < totalLen) || ((curLen >= totalLen) && cadence.not)}, {
|
|
|
|
while({(curLen < minTotalLen) || ((curLen >= minTotalLen) && cadence.not) || ultimateSection.not}, {
|
|
|
|
var temporalData;
|
|
|
|
var temporalData;
|
|
|
|
# temporalData, temporalState = genTemporalData.value(temporalState, modeState, curLen <= section1Len);
|
|
|
|
# temporalData, temporalState = genTemporalData.value(temporalState, modeState, curLen <= minSection1Len);
|
|
|
|
|
|
|
|
|
|
|
|
collectRoots.value(modeState).collect({arg fr; [fr[0].asFloat.product, fr[1].asFloat.product]}).postln;
|
|
|
|
collectRoots.value(modeState).collect({arg fr; [fr[0].asFloat.product, fr[1].asFloat.product]}).postln;
|
|
|
|
//modeState.keys.postln;
|
|
|
|
//modeState.keys.postln;
|
|
|
@ -453,7 +455,7 @@ genAmpCurve = {arg temporalData1, temporalData2, offset1, offset2, type;
|
|
|
|
roots = distributeRoots.value(modeState, lastRoots);
|
|
|
|
roots = distributeRoots.value(modeState, lastRoots);
|
|
|
|
|
|
|
|
|
|
|
|
sectionData.add((curLen / 4).asInteger->[roots, lastRoots.collect({arg fr, part;
|
|
|
|
sectionData.add((curLen / 4).asInteger->[roots, lastRoots.collect({arg fr, part;
|
|
|
|
[fr, 36.midicps * pow(2, [1, 0, 1, 2][part]) * frToFloat.value(fr)]}), sectionCount, subsectionCount, cadence, ultimate]);
|
|
|
|
[fr, 36.midicps * pow(2, [1, 0, 1, 2][part]) * frToFloat.value(fr)]}), sectionCount, subsectionCount, cadence, ultimateSubsection]);
|
|
|
|
sectionNavDict.add([sectionCount, subsectionCount]->[(curLen / 16 + 1).asInteger]);
|
|
|
|
sectionNavDict.add([sectionCount, subsectionCount]->[(curLen / 16 + 1).asInteger]);
|
|
|
|
|
|
|
|
|
|
|
|
4.do({arg part;
|
|
|
|
4.do({arg part;
|
|
|
@ -484,7 +486,7 @@ genAmpCurve = {arg temporalData1, temporalData2, offset1, offset2, type;
|
|
|
|
|
|
|
|
|
|
|
|
curLen = curLen + temporalData[0].size;
|
|
|
|
curLen = curLen + temporalData[0].size;
|
|
|
|
|
|
|
|
|
|
|
|
if(curLen > section1Len, {
|
|
|
|
if(curLen > minSection1Len, {
|
|
|
|
if(collectRoots.value(modeState).size == 1, {
|
|
|
|
if(collectRoots.value(modeState).size == 1, {
|
|
|
|
|
|
|
|
|
|
|
|
ampData[0] = ampData[0] ++ genAmpCurve.value(lastCadenceTemporalData, temporalData, lastSectionPoint, curLen, 0);
|
|
|
|
ampData[0] = ampData[0] ++ genAmpCurve.value(lastCadenceTemporalData, temporalData, lastSectionPoint, curLen, 0);
|
|
|
@ -509,10 +511,14 @@ genAmpCurve = {arg temporalData1, temporalData2, offset1, offset2, type;
|
|
|
|
# sectionCount, subsectionCount = [sectionCount + 1, 1];
|
|
|
|
# sectionCount, subsectionCount = [sectionCount + 1, 1];
|
|
|
|
# lastCadenceTemporalData, lastCadenceState, lastSectionPoint = [temporalData, modeState, curLen];
|
|
|
|
# lastCadenceTemporalData, lastCadenceState, lastSectionPoint = [temporalData, modeState, curLen];
|
|
|
|
cadence = true;
|
|
|
|
cadence = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//this should ensure that the final cadence is a HS
|
|
|
|
|
|
|
|
if(curLen >= minTotalLen, {ultimateCadenceCount = ultimateCadenceCount + 1});
|
|
|
|
|
|
|
|
ultimateSection = ultimateCadenceCount > 1;
|
|
|
|
}, {
|
|
|
|
}, {
|
|
|
|
cadence = false
|
|
|
|
cadence = false
|
|
|
|
});
|
|
|
|
});
|
|
|
|
modeState = advanceMode.value(modeState, lastCadenceState);
|
|
|
|
modeState = advanceMode.value(modeState, lastCadenceState, curLen >= minTotalLen);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|