section shifts should be working now

This commit is contained in:
mwinter 2021-01-01 21:05:54 +01:00
parent a76a653c99
commit c8fff752fb
10 changed files with 2262 additions and 2440 deletions

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.

View file

@ -1,12 +1,13 @@
(
var genWindow, masterView, faderView, buildGenerator, buildMetronome, buildTransport, buildAuxControls, buildMasterFader, buildTrackFader,
clockStringFunc, metronomeStringFunc, metronomeColorFunc, updateTransport;
updateSection, updateSubsection, clockStringFunc, metronomeStringFunc, metronomeColorFunc, updateTransport,
currentSection = 1, currentSubsection = 1;
buildGenerator = {arg view;
var ranSeed;
HLayout(
ranSeed = TextField(view, Rect(10, 10, 10, 20)).string_("20200525"),
Button(view).states_([["reset seed"]]).action_({ ranSeed.string = "20200525"}.inEnvir),
ranSeed = TextField(view, Rect(10, 10, 10, 20)).string_("19800725"),
Button(view).states_([["reset seed"]]).action_({ ranSeed.string = "19800725"}.inEnvir),
Button(view).states_([["random seed"]]).action_({ ranSeed.string = 50000000.rand.asString}.inEnvir),
Button(view).states_([["generate"]]).action_({
{~genAll.value(ranSeed.string.asInteger); ~appStatus.string = "status: ready"}.fork(AppClock);
@ -33,7 +34,8 @@ metronomeStringFunc = { arg beat; if(beat == 1,
{[-30, -105, -113].collect({arg int; int.asAscii}).as(String)})};
metronomeColorFunc = { arg beat; if(beat == 1, {Color.red},{Color.black})};
updateTransport = {arg clock, metronome, measure, beat;
updateTransport = {arg clock, metronome, sectionDisplay, measure, beat, section, subsection;
sectionDisplay.string = "section: " ++ section.asInteger ++ "." ++ subsection.asInteger;
clock.string = clockStringFunc.value(measure, beat);
metronome.stringColor = metronomeColorFunc.value(beat);
metronome.string = metronomeStringFunc.value(beat);
@ -57,15 +59,58 @@ buildMetronome = {arg win;
[clock, metronome, layout]
};
buildTransport = {arg win, view, metronome;
var layout, sectionDisplay, updateSection, countOff;
updateSection = {arg mod, clock, metronome, sectionDisplay, refresh = true;
if(~sectionNavDict[[currentSection + mod, 1]] != nil, {
currentSection = currentSection + mod;
currentSubsection = 1;
if(refresh, {
updateTransport.value(clock, metronome, sectionDisplay,
~sectionNavDict[[currentSection, currentSubsection]], 1,
currentSection, currentSubsection
);
});
});
};
updateSubsection = {arg mod, clock, metronome, sectionDisplay, refresh = true;
if(~sectionNavDict[[currentSection, currentSubsection + mod]] != nil, {
currentSubsection = currentSubsection + mod;
if(refresh, {
updateTransport.value(clock, metronome, sectionDisplay,
~sectionNavDict[[currentSection, currentSubsection]], 1,
currentSection, currentSubsection
);
});
}, {updateSection.value(mod, clock, metronome, sectionDisplay, refresh)})
};
buildTransport = {arg win, view, clock, metronome;
var sec, subsec, sectionDisplay, layout, player;
sectionDisplay = StaticText(win).string_("section: 1.1").font_(Font("Liberation Mono", 70));
OSCFunc({ arg msg, time;
{
var measure, beat, section, subsection;
# measure, beat, section, subsection = msg[3..];
currentSection = sec = section.asInteger;
currentSubsection = subsec = subsection.asInteger;
//currentSubsection.postln;
updateTransport.value(clock, metronome, sectionDisplay, measure, beat, section, subsection);
}.inEnvir.defer;
},'/measureClock_' ++ ~hash, s.addr);
//OSCdef(\externalAdvance ++ ~hash, {arg msg, time; {updateSection.value(1, clock, metronome, sectionDisplay, false)}.inEnvir.defer},'/nextSubsection_' ++ ~hash, s.addr);
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_([["<<", Color.black]]).action_({arg pState; updateSection.value(-1, clock, metronome, sectionDisplay)}.inEnvir),
Button(view).states_([["<", Color.black]]).action_({arg pState; updateSubsection.value(-1, clock, metronome, sectionDisplay)}.inEnvir),
Button(view).states_([["play", Color.black], ["stop", Color.black, Color.grey]]).action_({arg pState;
if(pState.value == 1, {
{
~patternProxy.source = Pseq(~patterns);
player = {
~patternProxy.source = Pseq(~patterns, 1, ~sectionNavDict[[currentSection, currentSubsection]] - 1);
Pbind(\instrument, \click_ ++ ~hash, \beat, Pseq([1, 2, 1, 2]), \dur, 1).play(~tempoClock, quant: 0);
[1, 2, 1, 2].do({arg beat;
{
@ -79,12 +124,17 @@ buildTransport = {arg win, view, metronome;
~patternProxy.play(~tempoClock, quant: 0)
}.fork(~tempoClock, quant: 0)
}, {
~patternProxy.stop
//subsec.postln;
~patternProxy.pause;
//player.stop;
updateTransport.value(clock, metronome, sectionDisplay,
~sectionNavDict[[currentSection, currentSubsection]], 1,
currentSection.postln, currentSubsection.postln);
});
}.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);
Button(view).states_([[">", Color.black]]).action_({arg pState; updateSubsection.value(1, clock, metronome, sectionDisplay)}.inEnvir),
Button(view).states_([[">>", Color.black]]).action_({arg pState; updateSection.value(1, clock, metronome, sectionDisplay)}.inEnvir), nil,
sectionDisplay, nil);
[sectionDisplay, layout]
};
@ -163,18 +213,9 @@ masterView = {arg win;
view = View(win);
generatorLayout = buildGenerator.value(view);
# clock, metronome, metronomeLayout = buildMetronome.value(win);
# sectionDisplay, transportLayout = buildTransport.value(win, view, metronome);
# sectionDisplay, transportLayout = buildTransport.value(win, view, clock, 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(
[
@ -302,34 +343,34 @@ faderView = {arg win;
updateSection = {arg shift, stop = true, manualCall = true;
var runThis;
runThis = (manualCall || (manualCall.not && ~autoAdvance));
runThis = runThis && ((~currentSection + shift) < ~sectionOrder.size);
runThis = runThis && (((~currentSection % 4) == 3) && ~interludes && manualCall.not).not;
runThis = runThis && ((currentSection + shift) < ~sectionOrder.size);
runThis = runThis && (((currentSection % 4) == 3) && ~interludes && manualCall.not).not;
if(runThis, {
var truncOnly, section, subSection;
if(~isPlaying, {
if(stop, {
~patterns[~sectionOrder[~currentSection]].stop
~patterns[~sectionOrder[currentSection]].stop
})
});
truncOnly = case
{(~currentSection + shift) < 0} {true}
{(currentSection + shift) < 0} {true}
{(shift < 0) && ~isPlaying} {true}
{(shift < -1) && ((~currentSection % 4) > 0)} {true}
{(shift < -1) && ((currentSection % 4) > 0)} {true}
{true} {false};
if(truncOnly.not, {
~currentSection = (~currentSection + shift).trunc(shift.abs);
currentSection = (currentSection + shift).trunc(shift.abs);
}, {
~currentSection = ~currentSection.trunc(shift.abs);
currentSection = currentSection.trunc(shift.abs);
});
section = ((~sectionOrder[~currentSection] / 4) + 1).asInteger;
subSection = ((~sectionOrder[~currentSection] % 4) + 1).asInteger;
section = ((~sectionOrder[currentSection] / 4) + 1).asInteger;
subSection = ((~sectionOrder[currentSection] % 4) + 1).asInteger;
sectionDisplay.string = "section: " ++ section.asString ++ "." ++ subSection.asString;
if(~isPlaying, {
countOff = {
if(~interludes && ((~currentSection % 4) == 0), {
if(~interludes && ((currentSection % 4) == 0), {
Pbind(
\instrument, \click ++ ~hash,
\beat, Pseq([1, 2, 1, 2]),
@ -345,9 +386,9 @@ faderView = {arg win;
0.25.wait;
});
});
~play.set(\sel, ~currentSection % 2);
~patterns[~sectionOrder[~currentSection]].play(~tempoClock, quant: 0);
if(~interludes && ((~currentSection % 4) == 3) && (~currentSection != (~sectionOrder.size - 1)), {
~play.set(\sel, currentSection % 2);
~patterns[~sectionOrder[currentSection]].play(~tempoClock, quant: 0);
if(~interludes && ((currentSection % 4) == 3) && (currentSection != (~sectionOrder.size - 1)), {
var center, interval, freq1, freq2, tremRate;
center = 50 - 12.0.rand;
interval = 3.0.rand + 2;
@ -356,16 +397,16 @@ faderView = {arg win;
tremRate = 50 + 4.0.rand2;
~interludeTremelo.set(\gate, 1, \amp, 1, \freq1, freq1, \freq2, freq2, \tremRate, tremRate);
});
if((~currentSection % 4) == 0, {
if((currentSection % 4) == 0, {
~interludeTremelo.set(\gate, 0);
});
if(((~currentSection % 4)) != 0 && ((~currentSection % 4) != 3), {
if(((currentSection % 4)) != 0 && ((currentSection % 4) != 3), {
~interludeTremelo.set(\gate, 0, \amp, 0);
});
}.fork(~tempoClock, quant: 0);
}, {
var measure, beat;
measure = ~sectionStartMeasure[~sectionOrder[~currentSection]];
measure = ~sectionStartMeasure[~sectionOrder[currentSection]];
beat = 1;
updateTransport.value(measure, beat);
});
@ -407,9 +448,9 @@ faderView = {arg win;
var measure, beat;
countOff.stop;
~isPlaying = false;
~patterns[~sectionOrder[~currentSection]].stop;
~patterns[~sectionOrder[currentSection]].stop;
~interludeTremelo.set(\gate, 0);
measure = ~sectionStartMeasure[~currentSection];
measure = ~sectionStartMeasure[currentSection];
beat = 1;
updateTransport.value(measure, beat);
~interludeTremelo.set(\gate, 0, \amp, 0);
@ -430,9 +471,9 @@ faderView = {arg win;
0.25.wait;
});
~isPlaying = true;
~play.set(\sel, ~currentSection % 2);
~patterns[~sectionOrder[~currentSection]].play(~tempoClock, quant: 0);
if(~interludes && ((~currentSection % 4) == 3) && (~currentSection != (~sectionOrder.size - 1)), {
~play.set(\sel, currentSection % 2);
~patterns[~sectionOrder[currentSection]].play(~tempoClock, quant: 0);
if(~interludes && ((currentSection % 4) == 3) && (currentSection != (~sectionOrder.size - 1)), {
var center, interval, freq1, freq2, tremRate;
center = 50 - 12.0.rand;
interval = 3.0.rand + 2;
@ -480,7 +521,7 @@ faderView = {arg win;
HLayout(
order = TextField(view).string_("1-16"),
Button(view).states_([["set order"]]).action_({
~patterns[~sectionOrder[~currentSection]].stop;
~patterns[~sectionOrder[currentSection]].stop;
~sectionOrder = order.string.split($,).collect({arg secEntry;
var bounds;
bounds = secEntry.split($-).collect({arg item; item.asInteger - 1});
@ -488,7 +529,7 @@ faderView = {arg win;
(sec.asInteger * 4) + [0, 1, 2, 3]
});
}).flat;
~currentSection = 0;
currentSection = 0;
updateSection.value(0);
}.inEnvir),
[StaticText(view).string_(" "), stretch: 1]),

View file

@ -22,7 +22,9 @@ s.waitForBoot({
~musicData = ~genMusicData.value(seed);
~scoreData = ~genScoreData.value(~musicData[0]);
~sectionData = ~musicData[2];
~sectionNavDict = ~musicData[3].postln;
~patterns = ~genPatterns.value(~musicData[0], ~musicData[1], ~sectionData);
~isPlaying = false;
};
~patternProxy = EventPatternProxy.new;
@ -30,7 +32,7 @@ s.waitForBoot({
~tempoClock = TempoClock.new(1);
~dir = thisProcess.nowExecutingPath.dirname;
"loading app".postln;
~genAll.value(20200525);
~genAll.value(19800725);
~play = Synth.new(\masterPlayerControl_ ++ ~hash);
4.collect({arg p; Synth.new(\clip_ ++ ~hash, [\bin, p + 6, \bus, ~busses[4].index])});
~generateGUI.value;

View file

@ -374,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, subsectionCount;
roots, lastRoots, sectionCount, subsectionCount, sectionNavDict;
thisThread.randSeed = seed;
@ -390,10 +390,11 @@ genAccompPart = {arg modeState, temporalData, offset, trans, part;
ensData = 4.collect({[]});
accompData = 4.collect({6.collect({[]})});
sectionData = Dictionary.with(*[0->4]);
sectionData = Dictionary.new; //Dictionary.with(*[0->4]);
sectionNavDict = Dictionary.new; //Dictionary.with(*[[[1], [1]]->1]);
sectionCount = 0;
subsectionCount = 0;
sectionCount = 1;
subsectionCount = 1;
while({curLen < totalLen}, {
var temporalData;
# temporalData, temporalState = genTemporalData.value(temporalState, modeState, curLen == 0);
@ -407,6 +408,7 @@ genAccompPart = {arg modeState, temporalData, offset, trans, 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]);
sectionNavDict.add([sectionCount, subsectionCount]->(curLen / 16 + 1).asInteger);
4.do({arg part;
var musicData, partState, noteCountInd;
@ -421,18 +423,19 @@ genAccompPart = {arg modeState, temporalData, offset, trans, part;
});
});
subsectionCount = subsectionCount + 1;
thisThread.randSeed = (seed + (sectionCount * 100) + subsectionCount);
modeState = advanceMode.value(modeState, lastCadenceState);
if(collectRoots.value(modeState).size == 1, {
sectionCount = sectionCount + 1;
subsectionCount = 0;
subsectionCount = 1;
lastCadenceState = modeState;
});
curLen = curLen + temporalData[0].size;
});
[ensData, accompData, sectionData]
[ensData, accompData, sectionData, sectionNavDict]
};
)

View file

@ -29,7 +29,7 @@ SynthDef(\masterPlayerControl_ ++ ~hash, {
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);
//SendReply.kr(Impulse.kr(0),'/nextSubsection_' ++ ~hash);
EnvGen.kr(Env.sine(dur), gate, doneAction: 2);
}).add;