adding bass part

main
mwinter 4 years ago
parent c8fff752fb
commit c25347be55

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -236,8 +236,8 @@ masterView = {arg win;
faderView = {arg win; faderView = {arg win;
var view, masterIndicators, trackIndicators, master, tracks; var view, masterIndicators, trackIndicators, master, tracks;
var partAbbr = ["*", "III", "II", "I", "accomp", "click"]; var partAbbr = ["*", "III", "II", "I", "accomp_I", "accomp_II", "click"];
var trackNames = ["*", "III", "II", "I", "accomp", "click"]; var trackNames = ["*", "III", "II", "I", "accomp_I", "accomp_II", "click"];
var partVols, partMutes, partPans; var partVols, partMutes, partPans;
var masterMute, masterVol; var masterMute, masterVol;
@ -264,7 +264,7 @@ faderView = {arg win;
master = buildMasterFader.value(view, masterVol, masterMute, masterIndicators); master = buildMasterFader.value(view, masterVol, masterMute, masterIndicators);
tracks = {arg part; tracks = {arg part;
buildTrackFader.value(view, trackNames[part], part, 0); buildTrackFader.value(view, trackNames[part], part, 0);
} ! 6; } ! 7;
view.layout_(HLayout(master, nil, *tracks)) view.layout_(HLayout(master, nil, *tracks))
}; };

@ -22,8 +22,8 @@ s.waitForBoot({
~musicData = ~genMusicData.value(seed); ~musicData = ~genMusicData.value(seed);
~scoreData = ~genScoreData.value(~musicData[0]); ~scoreData = ~genScoreData.value(~musicData[0]);
~sectionData = ~musicData[2]; ~sectionData = ~musicData[2];
~sectionNavDict = ~musicData[3].postln; ~patterns = ~genPatterns.value(~musicData[0], ~musicData[1], ~musicData[3], ~sectionData);
~patterns = ~genPatterns.value(~musicData[0], ~musicData[1], ~sectionData); ~sectionNavDict = ~musicData[4].postln;
~isPlaying = false; ~isPlaying = false;
}; };
@ -34,7 +34,7 @@ s.waitForBoot({
"loading app".postln; "loading app".postln;
~genAll.value(19800725); ~genAll.value(19800725);
~play = Synth.new(\masterPlayerControl_ ++ ~hash); ~play = Synth.new(\masterPlayerControl_ ++ ~hash);
4.collect({arg p; Synth.new(\clip_ ++ ~hash, [\bin, p + 6, \bus, ~busses[4].index])}); 4.collect({arg p; Synth.new(\clip_ ++ ~hash, [\bin, p + 6, \bus, ~busses[5].index])});
~generateGUI.value; ~generateGUI.value;
"ready".postln; "ready".postln;

@ -4,7 +4,7 @@ genMode, hdChoose, wchooseDict, collectRoots,
initModeState, advanceMode, initModeState, advanceMode,
initTemporalState, genTemporalData, initTemporalState, genTemporalData,
initPartStates, distributeRoots, initPartStates, distributeRoots,
genEnsemblePart, genAccompPart, genMusicData, genScoreData, genPatterns; genEnsemblePart, genAccompPart, genBassPart, genMusicData, genScoreData, genPatterns;
//~~~~~~~~~~~~FREQUENCY RATIO MATH FUNCTIONS~~~~~~~~~~~~ //~~~~~~~~~~~~FREQUENCY RATIO MATH FUNCTIONS~~~~~~~~~~~~
@ -208,8 +208,9 @@ genTemporalData = {arg lastTupleState, modeState, cadenceOverride, noParts = 4;
flourish = (if(cadence, {16}, {8}) + 32.rand).collect({[0, 1].wchoose([flourishDensity, 1].normalizeSum)}); flourish = (if(cadence, {16}, {8}) + 32.rand).collect({[0, 1].wchoose([flourishDensity, 1].normalizeSum)});
buffer = 16.collect({0}); buffer = 16.collect({0});
beforeLen = if(cadence, {32.rand}, {((timeToNextEvent - flourish.size - buffer.size) / 2).asInteger.rand}); //beforeLen = if(cadence, {32.rand}, {((timeToNextEvent - flourish.size - buffer.size) / 2).asInteger.rand});
before = beforeLen.collect({arg i; [0, 1].wchoose([genDensity, 1].normalizeSum)}); beforeLen =((timeToNextEvent - flourish.size - buffer.size) / if(cadence, {1.25}, {1})).asInteger.rand;
before = beforeLen.collect({arg i; [0, 1].wchoose([genDensity, 0.25].normalizeSum)});
//if(collectRoots.value(modeState).size == 1, {before = [0]}); //if(collectRoots.value(modeState).size == 1, {before = [0]});
after = (timeToNextEvent - before.size - flourish.size - buffer.size).collect({[0, 1].wchoose([genDensity, 1].normalizeSum)}); after = (timeToNextEvent - before.size - flourish.size - buffer.size).collect({[0, 1].wchoose([genDensity, 1].normalizeSum)});
flourish = before ++ flourish ++ after; flourish = before ++ flourish ++ after;
@ -349,18 +350,26 @@ genEnsemblePart = {arg partState, modeState, temporalData, roots, part, offset;
//~~~~~~~~~~~~GENERATE ELECTRONIC ACCOMPANIMENT~~~~~~~~~~~~ //~~~~~~~~~~~~GENERATE ELECTRONIC ACCOMPANIMENT~~~~~~~~~~~~
genAccompPart = {arg modeState, temporalData, offset, trans, part; genAccompPart = {arg modeState, temporalData, offset, trans, part, register;
var firstChange, accompData; var firstChange, accompData;
firstChange = false; firstChange = false;
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}, {2})].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 / totalLen).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);
freq = 48.midicps * trans * frToFloat.value(sel); freq = 48.midicps * trans * frToFloat.value(sel);
amp = [0, 1, 2, 3].wchoose([5, 2, 1, 1].normalizeSum); amp = [0, 1, 2, 3].wchoose([2, 2, 1, 1].normalizeSum);
/*
if(register == 0, {
amp = 3;
freq = 24.midicps * trans * frToFloat.value(sel);
});
*/
accompData = accompData.add([freq, tS + offset, amp, part]); accompData = accompData.add([freq, tS + offset, amp, part]);
firstChange = true; firstChange = true;
}); });
@ -368,17 +377,27 @@ genAccompPart = {arg modeState, temporalData, offset, trans, part;
accompData accompData
}; };
//~~~~~~~~~~~~GENERATE ELECTRONIC BASS~~~~~~~~~~~~
genBassPart = {arg root, offset1, offset2;
var bassData;
[
[24.midicps * frToFloat.value(frCollapse.value(frAdd.value(root, [[3], [2]]))), offset1, (offset2 + 32) - (offset1), 10, 5, 1],
//[24.midicps * frToFloat.value(root) * 3/2, offset2 + 16, 1],
[24.midicps * frToFloat.value(root), offset2 + 32, 5, 10, 30, 1]]
};
//~~~~~~~~~~~~GENERATE ALL MUSIC DATA~~~~~~~~~~~~ //~~~~~~~~~~~~GENERATE ALL MUSIC DATA~~~~~~~~~~~~
~genMusicData = {arg seed; ~genMusicData = {arg seed;
var totalDur, dUnit, totalLen, curLen, var totalDur, dUnit, totalLen, curLen,
modeState, temporalState, partStates, lastCadenceState, modeState, temporalState, partStates, lastCadenceState, lastCadencePoint,
ensData, accompData, sectionData, ensData, accompData, bassData, sectionData,
roots, lastRoots, sectionCount, subsectionCount, sectionNavDict; roots, lastRoots, sectionCount, subsectionCount, sectionNavDict;
thisThread.randSeed = seed; thisThread.randSeed = seed;
totalDur = 3 * 60; totalDur = 6 * 60;
dUnit = 8.reciprocal; dUnit = 8.reciprocal;
totalLen = (totalDur / dUnit).round(16); totalLen = (totalDur / dUnit).round(16);
curLen = 0; curLen = 0;
@ -387,8 +406,10 @@ genAccompPart = {arg modeState, temporalData, offset, trans, part;
temporalState = initTemporalState.value; temporalState = initTemporalState.value;
partStates = initPartStates.value; partStates = initPartStates.value;
lastCadenceState = modeState.deepCopy; lastCadenceState = modeState.deepCopy;
lastCadencePoint = 0;
ensData = 4.collect({[]}); ensData = 4.collect({[]});
bassData = 3.collect({[]});
accompData = 4.collect({6.collect({[]})}); accompData = 4.collect({6.collect({[]})});
sectionData = Dictionary.new; //Dictionary.with(*[0->4]); sectionData = Dictionary.new; //Dictionary.with(*[0->4]);
sectionNavDict = Dictionary.new; //Dictionary.with(*[[[1], [1]]->1]); sectionNavDict = Dictionary.new; //Dictionary.with(*[[[1], [1]]->1]);
@ -405,6 +426,7 @@ genAccompPart = {arg modeState, temporalData, offset, trans, part;
lastRoots = if(curLen == 0, {4.collect({[[1], [1]]})}, {roots.slice(nil, 0)}); lastRoots = if(curLen == 0, {4.collect({[[1], [1]]})}, {roots.slice(nil, 0)});
roots = distributeRoots.value(modeState, lastRoots); roots = distributeRoots.value(modeState, lastRoots);
roots.size.postln;
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]); [fr, 36.midicps * pow(2, [1, 0, 1, 2][part]) * frToFloat.value(fr)]}), sectionCount, subsectionCount]);
@ -416,9 +438,13 @@ genAccompPart = {arg modeState, temporalData, offset, trans, part;
ensData[part] = ensData[part] ++ musicData; ensData[part] = ensData[part] ++ musicData;
partStates[part] = partState; partStates[part] = partState;
//if(collectRoots.value(modeState).size == 1, {
// if(part != 0, {bassData[part - 1] = bassData[part - 1] ++ genBassPart.value(roots[2][0], curLen)});
//});
thisThread.randSeed = Date.seed; thisThread.randSeed = Date.seed;
6.do({arg register; 6.do({arg register;
musicData = genAccompPart.value(modeState, temporalData[part], curLen, pow(2, part + register), part); musicData = genAccompPart.value(modeState, temporalData[part], curLen, pow(2, part + register), part, register);
accompData[part][register] = accompData[part][register] ++ musicData; accompData[part][register] = accompData[part][register] ++ musicData;
}); });
@ -426,17 +452,27 @@ genAccompPart = {arg modeState, temporalData, offset, trans, part;
subsectionCount = subsectionCount + 1; subsectionCount = subsectionCount + 1;
thisThread.randSeed = (seed + (sectionCount * 100) + subsectionCount); thisThread.randSeed = (seed + (sectionCount * 100) + subsectionCount);
modeState = advanceMode.value(modeState, lastCadenceState);
if(collectRoots.value(modeState).size == 1, { if(collectRoots.value(modeState).size == 1, {
sectionCount = sectionCount + 1; sectionCount = sectionCount + 1;
subsectionCount = 1; subsectionCount = 1;
lastCadenceState = modeState; lastCadenceState = modeState;
if(curLen > 0, {
bassData[0] = bassData[0] ++ genBassPart.value(roots[0][0].postln, lastCadencePoint.postln, curLen);
});
//bassData[0] = bassData[0] ++ genBassPart.value(roots[0][0].postln, curLen);
lastCadencePoint = curLen + temporalData[0].size;
lastCadencePoint.postln;
}); });
modeState = advanceMode.value(modeState, lastCadenceState);
curLen = curLen + temporalData[0].size; curLen = curLen + temporalData[0].size;
}); });
[ensData, accompData, sectionData, sectionNavDict] [ensData, accompData, sectionData, bassData.postln, sectionNavDict]
}; };
//~genMusicData.value(100)
) )

@ -9,7 +9,7 @@ var formatPatternData;
~accompBus = Bus.audio(s, 1); ~accompBus = Bus.audio(s, 1);
~clickBus = Bus.audio(s, 1); ~clickBus = Bus.audio(s, 1);
~busses = 6.collect({Bus.audio(s, 1)}); ~busses = 7.collect({Bus.audio(s, 1)});
SynthDef(\masterPlayerControl_ ++ ~hash, { SynthDef(\masterPlayerControl_ ++ ~hash, {
var sigs, sigsPanned, masterSig, imp; var sigs, sigsPanned, masterSig, imp;
@ -35,7 +35,7 @@ SynthDef(\transport_ ++ ~hash, {arg measure = 0, beat = 0, section = 0, subsecti
SynthDef(\click_ ++ ~hash, {arg beat = 0, gate = 1, dur = 1; SynthDef(\click_ ++ ~hash, {arg beat = 0, gate = 1, dur = 1;
Out.ar(~busses[5], 10 * BPF.ar(WhiteNoise.ar * EnvGen.kr(Env.perc(0.01, 0.1), gate), 440 * ((beat <= 1) + 1), 0.02)); Out.ar(~busses[6], 10 * BPF.ar(WhiteNoise.ar * EnvGen.kr(Env.perc(0.01, 0.1), gate), 440 * ((beat <= 1) + 1), 0.02));
EnvGen.kr(Env.sine(dur), gate, doneAction: 2); EnvGen.kr(Env.sine(dur), gate, doneAction: 2);
}).add; }).add;
@ -51,7 +51,11 @@ SynthDef(\accomp_ ++ ~hash, {arg freq = 440, amp = 1, attack = 1, dur = 1, gate
SynthDef(\clip_ ++ ~hash, {arg dur = 1, gate = 1, bin = 0, bus = 0; SynthDef(\clip_ ++ ~hash, {arg dur = 1, gate = 1, bin = 0, bus = 0;
//Out.ar([0, 1], (In.ar(bin)).clip(0, 1) * pow(Line.kr(0, 1, 240), 2)) //Out.ar([0, 1], (In.ar(bin)).clip(0, 1) * pow(Line.kr(0, 1, 240), 2))
Out.ar(bus, (In.ar(bin)).clip(0, 1) * 10 * pow(Line.kr(0, 1, 10), 2)) Out.ar(bus, (In.ar(bin)).clip(0, 1) * 50 * pow(Line.kr(0, 1, 10), 2))
}).add;
SynthDef(\bass_ ++ ~hash, {arg freq = 440, amp = 1, dur = 1, attack = 1, decay = 1, release = 1, gate = 1, direction = 1, bus = 0;
Out.ar(bus, (SinOsc.ar(freq) * 0.3 * amp * EnvGen.kr(Env.adsr(attack, decay, 0.5, release, curve: \sqr), gate, doneAction: 2)))
}).add; }).add;
@ -74,8 +78,8 @@ formatPatternData = {arg musData, measureLen;
//~~~~~~~~~~~~GENERATE PATTERNS~~~~~~~~~~~~ //~~~~~~~~~~~~GENERATE PATTERNS~~~~~~~~~~~~
~genPatterns = {arg ensData, accompData, sectionData; ~genPatterns = {arg ensData, accompData, bassData, sectionData;
var measureLen, ensDataFormatted, accompDataFormatted, dUnit, section, subsection; var measureLen, ensDataFormatted, accompDataFormatted, bassDataFormatted, dUnit, section, subsection;
measureLen = (( measureLen = ((
ensData.collect({arg partData; partData.last[1]}) ++ ensData.collect({arg partData; partData.last[1]}) ++
@ -84,6 +88,7 @@ formatPatternData = {arg musData, measureLen;
ensDataFormatted = formatPatternData.value(ensData, measureLen); ensDataFormatted = formatPatternData.value(ensData, measureLen);
accompDataFormatted = formatPatternData.value(accompData.flatten, measureLen); accompDataFormatted = formatPatternData.value(accompData.flatten, measureLen);
bassDataFormatted = formatPatternData.value(bassData[..0], measureLen);
dUnit = 8.reciprocal; dUnit = 8.reciprocal;
measureLen.collect({arg measure; measureLen.collect({arg measure;
@ -113,10 +118,25 @@ formatPatternData = {arg musData, measureLen;
\sustain, Pseq(musData[2] * dUnit), \sustain, Pseq(musData[2] * dUnit),
\amp, Pseq(musData[3].collect({arg item; [0, 2, 4, 8][item]}) * 0.0125 * 1), \amp, Pseq(musData[3].collect({arg item; [0, 2, 4, 8][item]}) * 0.0125 * 1),
//\attack, Pseq(musData[1] * abs(musData[3].clip(0, 0.25) * 2 - 1) * dUnit), //\attack, Pseq(musData[1] * abs(musData[3].clip(0, 0.25) * 2 - 1) * dUnit),
\attack, Pseq(musData[2] * 0.9 * dUnit), \attack, Pseq(musData[2] * 1 * dUnit),
\bout, Pseq(musData[4] + 6) \bout, Pseq(musData[4] + 6)
) )
}) ++ }) ++
bassDataFormatted[measure][..0].postln.collect({arg musData, m;
Pbind(
\instrument, \bass_ ++ ~hash,
\freq, Pseq(musData[0].replace(0, Rest(0)) * [2, 4, 8][m]),
\dur, Pseq(musData[1] * dUnit),
\sustain, Pseq(musData[2] * dUnit),
\attack, Pseq(musData[3] * dUnit),
\decay, Pseq(musData[4]),
\release, Pseq(musData[5]),
\amp, 1,
//\amp, Pseq(musData[2].collect({arg item; [0, 0.25, 0.5, 0.75][item]}) * [1, 0.5, 0.25, 0.1][m] * 16);
// * musData[3].collect({arg val; if(val < 0.25, {0}, {0.5})}))
\bus, ~busses[4].index
)
}) ++
[ [
Pbind( Pbind(
\instrument, \transport_ ++ ~hash, \instrument, \transport_ ++ ~hash,

Loading…
Cancel
Save