getting the gui working and major bug fix to accomp
This commit is contained in:
parent
9d14e6c5b4
commit
a76a653c99
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
Binary file not shown.
Binary file not shown.
|
|
@ -54,31 +54,19 @@ buildMetronome = {arg win;
|
|||
metronome
|
||||
);
|
||||
|
||||
OSCFunc({ arg msg, time;
|
||||
{
|
||||
var measure, beat;
|
||||
measure = msg[3].postln;
|
||||
beat = msg[4];
|
||||
updateTransport.value(clock, metronome, measure, beat)
|
||||
}.inEnvir.defer;
|
||||
},'/measureClock_' ++ ~hash, s.addr);
|
||||
|
||||
[clock, metronome, layout]
|
||||
};
|
||||
|
||||
buildTransport = {arg win, view, metronome;
|
||||
var sectionDisplay, updateSection, countOff;
|
||||
HLayout(
|
||||
var layout, sectionDisplay, updateSection, countOff;
|
||||
layout = HLayout(
|
||||
Button(view).states_([["<<", Color.black]]).action_({arg pState; updateSection.value(-4)}.inEnvir),
|
||||
Button(view).states_([["<", Color.black]]).action_({arg pState; updateSection.value(-1)}.inEnvir),
|
||||
Button(view).states_([["play", Color.black], ["stop", Color.black, Color.grey]]).action_({arg pState;
|
||||
if(pState.value == 1, {
|
||||
{~patternProxy.source = Pseq(~patterns);
|
||||
Pbind(
|
||||
\instrument, \click_ ++ ~hash,
|
||||
\beat, Pseq([1, 2, 1, 2]),
|
||||
\dur, 1
|
||||
).play(~tempoClock, quant: 0);
|
||||
{
|
||||
~patternProxy.source = Pseq(~patterns);
|
||||
Pbind(\instrument, \click_ ++ ~hash, \beat, Pseq([1, 2, 1, 2]), \dur, 1).play(~tempoClock, quant: 0);
|
||||
[1, 2, 1, 2].do({arg beat;
|
||||
{
|
||||
metronome.stringColor = metronomeColorFunc.value(beat);
|
||||
|
|
@ -96,7 +84,8 @@ buildTransport = {arg win, view, metronome;
|
|||
}.inEnvir),
|
||||
Button(view).states_([[">", Color.black]]).action_({arg pState; updateSection.value(1)}.inEnvir),
|
||||
Button(view).states_([[">>", Color.black]]).action_({arg pState; updateSection.value(4)}.inEnvir), nil,
|
||||
sectionDisplay = StaticText(win).string_("section: 1.1").font_(Font("Liberation Mono", 70)), nil)
|
||||
sectionDisplay = StaticText(win).string_("section: 1.1").font_(Font("Liberation Mono", 70)), nil);
|
||||
[sectionDisplay, layout]
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -169,15 +158,23 @@ buildTrackFader = {arg view, name, index, initVal;
|
|||
|
||||
|
||||
masterView = {arg win;
|
||||
var updateTransport, updateSection,
|
||||
view, generatorLayout, clock, metronome, metronomeLayout, transportLayout, auxControlsLayout, countOff, ranSeed, order, tempo, sectionDisplay, address;
|
||||
var view, generatorLayout, clock, metronome, metronomeLayout, transportLayout, auxControlsLayout, countOff, ranSeed, order, tempo, sectionDisplay, address;
|
||||
|
||||
view = View(win);
|
||||
generatorLayout = buildGenerator.value(view);
|
||||
# clock, metronome, metronomeLayout = buildMetronome.value(win);
|
||||
transportLayout = buildTransport.value(win, view, metronome);
|
||||
# sectionDisplay, transportLayout = buildTransport.value(win, view, metronome);
|
||||
auxControlsLayout = buildAuxControls.value(view);
|
||||
|
||||
OSCFunc({ arg msg, time;
|
||||
{
|
||||
var measure, beat, section, subsection;
|
||||
# measure, beat, section, subsection = msg[3..];
|
||||
updateTransport.value(clock, metronome, measure, beat);
|
||||
sectionDisplay.string = "section: " ++ section.asInteger ++ "." ++ subsection.asInteger;
|
||||
}.inEnvir.defer;
|
||||
},'/measureClock_' ++ ~hash, s.addr);
|
||||
|
||||
view.layout_(
|
||||
HLayout(
|
||||
[
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ s.waitForBoot({
|
|||
~musicData = ~genMusicData.value(seed);
|
||||
~scoreData = ~genScoreData.value(~musicData[0]);
|
||||
~sectionData = ~musicData[2];
|
||||
~patterns = ~genPatterns.value(~musicData[0], ~musicData[1]);
|
||||
~patterns = ~genPatterns.value(~musicData[0], ~musicData[1], ~sectionData);
|
||||
};
|
||||
|
||||
~patternProxy = EventPatternProxy.new;
|
||||
|
|
@ -41,6 +41,7 @@ s.waitForBoot({
|
|||
~genAll = {arg seed;
|
||||
~allMusicData = ~genMusicData.value(seed);
|
||||
~patterns = ~allMusicData[0];
|
||||
|
||||
~scoreData = ~allMusicData[1];
|
||||
~sectionOffsets = ~allMusicData[2];
|
||||
~currentSection = 0;
|
||||
|
|
|
|||
|
|
@ -350,17 +350,19 @@ genEnsemblePart = {arg partState, modeState, temporalData, roots, part, offset;
|
|||
|
||||
//~~~~~~~~~~~~GENERATE ELECTRONIC ACCOMPANIMENT~~~~~~~~~~~~
|
||||
genAccompPart = {arg modeState, temporalData, offset, trans, part;
|
||||
var accompData;
|
||||
var firstChange, accompData;
|
||||
firstChange = false;
|
||||
accompData = [];
|
||||
temporalData.do({arg val, tS;
|
||||
var change;
|
||||
change = [val == 1, tS == 0].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}, {2})].normalizeSum); //5 * abs((curPulse / totalLen).clip(0, 0.8) - 1)].normalizeSum);
|
||||
if(change, {
|
||||
var sel, freq, amp;
|
||||
sel = wchooseDict.value(modeState, 0.1);
|
||||
freq = 48.midicps * trans * frToFloat.value(sel);
|
||||
amp = [0, 1, 2, 3].wchoose([5, 2, 1, 1].normalizeSum);
|
||||
accompData = accompData.add([freq, tS + offset, amp, part]);
|
||||
firstChange = true;
|
||||
});
|
||||
});
|
||||
accompData
|
||||
|
|
@ -372,7 +374,7 @@ genAccompPart = {arg modeState, temporalData, offset, trans, part;
|
|||
var totalDur, dUnit, totalLen, curLen,
|
||||
modeState, temporalState, partStates, lastCadenceState,
|
||||
ensData, accompData, sectionData,
|
||||
roots, lastRoots, sectionCount;
|
||||
roots, lastRoots, sectionCount, subsectionCount;
|
||||
|
||||
thisThread.randSeed = seed;
|
||||
|
||||
|
|
@ -391,6 +393,7 @@ genAccompPart = {arg modeState, temporalData, offset, trans, part;
|
|||
sectionData = Dictionary.with(*[0->4]);
|
||||
|
||||
sectionCount = 0;
|
||||
subsectionCount = 0;
|
||||
while({curLen < totalLen}, {
|
||||
var temporalData;
|
||||
# temporalData, temporalState = genTemporalData.value(temporalState, modeState, curLen == 0);
|
||||
|
|
@ -403,11 +406,10 @@ genAccompPart = {arg modeState, temporalData, offset, trans, part;
|
|||
roots = distributeRoots.value(modeState, lastRoots);
|
||||
|
||||
sectionData.add((curLen / 4).asInteger->[roots, lastRoots.collect({arg fr, part;
|
||||
[fr, 36.midicps * pow(2, [1, 0, 1, 2][part]) * frToFloat.value(fr)]})]);
|
||||
[fr, 36.midicps * pow(2, [1, 0, 1, 2][part]) * frToFloat.value(fr)]}), sectionCount, subsectionCount]);
|
||||
|
||||
4.do({arg part;
|
||||
var musicData, partState, noteCountInd;
|
||||
//thisThread.randSeed = (seed + sectionCount + 1 + part).postln;
|
||||
# musicData, partState = genEnsemblePart.value(partStates[part], modeState, temporalData[part], roots, part, curLen);
|
||||
ensData[part] = ensData[part] ++ musicData;
|
||||
partStates[part] = partState;
|
||||
|
|
@ -419,117 +421,19 @@ genAccompPart = {arg modeState, temporalData, offset, trans, part;
|
|||
});
|
||||
|
||||
});
|
||||
sectionCount = sectionCount + 1;
|
||||
thisThread.randSeed = (seed + sectionCount);
|
||||
subsectionCount = subsectionCount + 1;
|
||||
thisThread.randSeed = (seed + (sectionCount * 100) + subsectionCount);
|
||||
modeState = advanceMode.value(modeState, lastCadenceState);
|
||||
if(collectRoots.value(modeState).size == 1, {lastCadenceState = modeState});
|
||||
if(collectRoots.value(modeState).size == 1, {
|
||||
sectionCount = sectionCount + 1;
|
||||
subsectionCount = 0;
|
||||
lastCadenceState = modeState;
|
||||
});
|
||||
curLen = curLen + temporalData[0].size;
|
||||
});
|
||||
|
||||
//format
|
||||
|
||||
/*
|
||||
ensData = ensData.collect({arg partData;
|
||||
partData.flop.collect({arg data, d; if(d == 1, {data.differentiate ++ [10]}, {[0] ++ data})})
|
||||
});
|
||||
*/
|
||||
|
||||
|
||||
//format
|
||||
|
||||
/*
|
||||
ensData = ensData.collect({arg partData;
|
||||
var res;
|
||||
res = partData.flop;
|
||||
res = res.add(res[1]);
|
||||
res[1] = (res[1].differentiate.drop(1) ++ [10]).postln;
|
||||
res = res.flop ++ (res.last.last.ceil(16) / 16).asInteger.collect({arg measure; [0, 0, 0, 0, 0, measure * 16]});
|
||||
res = res.postln.sort({arg a, b; a.last < b.last}).postln;
|
||||
res = res.flop.postln;
|
||||
//res.last.postln;
|
||||
res = res.insert(1, (res.last.postln.differentiate.drop(1) ++ [10])).flop.postln;
|
||||
});
|
||||
|
||||
|
||||
accompData = accompData.collect({arg voice;
|
||||
voice.collect({arg partData;
|
||||
partData.flop.collect({arg data, d; if(d == 1, {data.differentiate ++ [10]}, {[0] ++ data})})
|
||||
});
|
||||
});
|
||||
*/
|
||||
|
||||
[ensData, accompData, sectionData]
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//~~~~~~~~~~~~DEFINE SYNTHS~~~~~~~~~~~~
|
||||
/*
|
||||
SynthDef(\ens, {arg freq = 440, amp = 1, dur = 1, gate = 1;
|
||||
Out.ar([0, 1], SinOsc.ar(freq, 2pi.rand, amp * 0.01) * EnvGen.kr(Env.asr(0.1, 1, 0.1), gate, doneAction: 2))
|
||||
}).add;
|
||||
|
||||
SynthDef(\accomp, {arg freq = 440, amp = 1, attack = 1, dur = 1, gate = 1, bout = 0;
|
||||
Out.ar(bout, SinOsc.ar(freq, 2pi.rand, 1) * 0.01 * amp * EnvGen.kr(Env.asr(attack, 1, 0.01), gate, doneAction: 2))
|
||||
}).add;
|
||||
|
||||
SynthDef(\clip, {arg dur = 1, gate = 1, bin = 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, 10), 2))
|
||||
}).add;
|
||||
|
||||
|
||||
//~~~~~~~~~~~~GENERATE PATTERNS~~~~~~~~~~~~
|
||||
genPatterns = {arg ensData, accompData, dUnit;
|
||||
Ppar(
|
||||
ensData.collect({arg musData, m;
|
||||
Pbind(
|
||||
\instrument, \ens,
|
||||
\freq, Pseq(musData[0]),
|
||||
//\freq, Pseq(musData[0].collect({arg freq; freq.cpsmidi.round(0.5).midicps})),
|
||||
\dur, Pseq(musData[1] * dUnit),
|
||||
\sustain, Pseq(musData[1] * dUnit),
|
||||
\amp, [0.5, 0.3, 0.3, 0.3][m] //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})}))
|
||||
)
|
||||
}) ++
|
||||
accompData.collect({arg voice, v;
|
||||
voice.collect({arg musData;
|
||||
Pbind(
|
||||
\instrument, \accomp,
|
||||
\freq, Pseq(musData[0]),
|
||||
//\freq, Pseq(musData[0].collect({arg freq; freq.cpsmidi.round(0.5).midicps})),
|
||||
\dur, Pseq(musData[1] * dUnit),
|
||||
\sustain, Pseq(musData[1] * dUnit),
|
||||
\amp, Pseq(musData[2].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] * 0.9 * dUnit),
|
||||
\bout, v + 5
|
||||
)
|
||||
}).add(
|
||||
Pmono(
|
||||
\clip,
|
||||
\bin, v + 5
|
||||
)
|
||||
)
|
||||
}).flatten
|
||||
);
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
//~~~~~~~~~~~~MAIN / RUN~~~~~~~~~~~~
|
||||
/*
|
||||
~dUnit = 8.reciprocal;
|
||||
~musicData = genMusicData.value(~dUnit);
|
||||
~scoreData = genScoreData.value(~musicData[0]);
|
||||
~sectionData = ~musicData[2];
|
||||
~sectionData.postln;
|
||||
~patterns = genPatterns.value(~musicData[0], ~musicData[1], ~dUnit);
|
||||
//~patterns.play;
|
||||
*/
|
||||
//~musicData = ~genMusicData.value(100);
|
||||
|
||||
)
|
||||
//~musicData = ~genMusicData.value(100);
|
||||
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ SynthDef(\masterPlayerControl_ ++ ~hash, {
|
|||
}).add;
|
||||
|
||||
|
||||
SynthDef(\transport_ ++ ~hash, {arg measure = 0, beat = 0, gate = 1, dur = 1;
|
||||
SendReply.kr(Impulse.kr(0) * (measure > 0) * (beat > 0),'/measureClock_' ++ ~hash, values: [measure.poll, beat]);
|
||||
SynthDef(\transport_ ++ ~hash, {arg measure = 0, beat = 0, section = 0, subsection = 0, gate = 1, dur = 1;
|
||||
SendReply.kr(Impulse.kr(0) * (measure > 0) * (beat > 0),'/measureClock_' ++ ~hash, values: [measure, beat, section, subsection]);
|
||||
SendReply.kr(Impulse.kr(0) * (measure < 1) * (beat < 1),'/nextSubsection_' ++ ~hash);
|
||||
EnvGen.kr(Env.sine(dur), gate, doneAction: 2);
|
||||
}).add;
|
||||
|
|
@ -74,8 +74,8 @@ formatPatternData = {arg musData, measureLen;
|
|||
|
||||
|
||||
//~~~~~~~~~~~~GENERATE PATTERNS~~~~~~~~~~~~
|
||||
~genPatterns = {arg ensData, accompData;
|
||||
var measureLen, ensDataFormatted, accompDataFormatted, dUnit, pattern;
|
||||
~genPatterns = {arg ensData, accompData, sectionData;
|
||||
var measureLen, ensDataFormatted, accompDataFormatted, dUnit, section, subsection;
|
||||
|
||||
measureLen = ((
|
||||
ensData.collect({arg partData; partData.last[1]}) ++
|
||||
|
|
@ -87,6 +87,10 @@ formatPatternData = {arg musData, measureLen;
|
|||
dUnit = 8.reciprocal;
|
||||
|
||||
measureLen.collect({arg measure;
|
||||
if(sectionData[measure * 4] != nil, {
|
||||
section = sectionData[measure * 4][2];
|
||||
subsection = sectionData[measure * 4][3];
|
||||
});
|
||||
Ppar(
|
||||
ensDataFormatted[measure].collect({arg musData, m;
|
||||
Pbind(
|
||||
|
|
@ -101,6 +105,7 @@ formatPatternData = {arg musData, measureLen;
|
|||
)
|
||||
}) ++
|
||||
accompDataFormatted[measure].collect({arg musData, m;
|
||||
//"--------".postln;
|
||||
Pbind(
|
||||
\instrument, \accomp_ ++ ~hash,
|
||||
\freq, Pseq(musData[0].replace(0, Rest(0))),
|
||||
|
|
@ -109,7 +114,7 @@ formatPatternData = {arg musData, measureLen;
|
|||
\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[2] * 0.9 * dUnit),
|
||||
\bout, musData[4] + 6
|
||||
\bout, Pseq(musData[4] + 6)
|
||||
)
|
||||
}) ++
|
||||
[
|
||||
|
|
@ -117,6 +122,8 @@ formatPatternData = {arg musData, measureLen;
|
|||
\instrument, \transport_ ++ ~hash,
|
||||
\measure, measure + 1,
|
||||
\beat, Pseq([1, 2]),
|
||||
\section, section,
|
||||
\subsection, subsection,
|
||||
\dur, 8 * dUnit
|
||||
),
|
||||
Pbind(
|
||||
|
|
|
|||
|
|
@ -308,7 +308,7 @@ consolidateNotes = {arg lyStr, part;
|
|||
var res;
|
||||
res = ensData.collect({arg partData;
|
||||
partData.flop.collect({arg data, d; if(d == 1, {data.differentiate ++ [10]}, {[0] ++ data})})
|
||||
}).postln;
|
||||
});
|
||||
res.collect({arg part; part.flop})
|
||||
};
|
||||
)
|
||||
Loading…
Reference in a new issue