commit 2020.06.04.01.01

main
Michael Winter 5 years ago
parent bbddb724e1
commit 25dcd73203

@ -15,16 +15,16 @@
masterVol = 1; masterVol = 1;
clockStringFunc = { clockStringFunc = {
arg beat; arg measure, beat;
var measure, measureBeat, leadSpace; var measureString, beatString, leadSpace;
measure = ((beat / 2) + 1).asInteger.asString; measureString = measure.asInteger.asString;
measureBeat = ((beat % 2) + 1).asInteger.asString; beatString = beat.asInteger.asString;
leadSpace = (3 - measure.size).collect({" "}).join; leadSpace = (3 - measureString.size).collect({" "}).join;
leadSpace ++ measure ++ "." ++ measureBeat leadSpace ++ measureString ++ "." ++ beatString
}; };
// [-30, -105, -104].asAscii and [-30, -105, -113].asAscii are unicode inverse bullet and normal bullet, respectively // [-30, -105, -104].asAscii and [-30, -105, -113].asAscii are unicode inverse bullet and normal bullet, respectively
metronomeStringFunc = { arg beat; if(beat % 2 == 0, {[-30, -105, -104].asAscii}, {[-30, -105, -113].asAscii}) }; metronomeStringFunc = { arg beat; if(beat == 1, {[-30, -105, -104].asAscii}, {[-30, -105, -113].asAscii}) };
metronomeColorFunc = { arg beat; if(beat % 2 == 0, {Color.red},{Color.black}) }; metronomeColorFunc = { arg beat; if(beat == 1, {Color.red},{Color.black}) };
~appStatusFunc = Task({ ~appStatusFunc = Task({
loop { loop {
@ -39,12 +39,15 @@
win = Window("Counterfeiting in Colonial Connecticut", Rect(500, 500, 1100, 500), false).front; win = Window("Counterfeiting in Colonial Connecticut", Rect(500, 500, 1100, 500), false).front;
masterView = { masterView = {
var view, masterIndicators, master, generator, transport, ranSeed, startPosText, pauseButton, clock, metronome; var view, masterIndicators, master, generator, transport, ranSeed, startPosText,
prevSectionButton, prevSubsectionButton, playStopButton, nextSubsectionButton, nextSectionButton, clock, metronome;
OSCFunc({ arg msg, time; OSCFunc({ arg msg, time;
{ {
var beat = msg[3]; var measure, beat;
clock.string = clockStringFunc.value(beat); measure = msg[3];
beat = msg[4];
clock.string = clockStringFunc.value(measure, beat);
metronome.stringColor = metronomeColorFunc.value(beat); metronome.stringColor = metronomeColorFunc.value(beat);
metronome.string = metronomeStringFunc.value(beat); metronome.string = metronomeStringFunc.value(beat);
}.defer; }.defer;
@ -65,7 +68,31 @@
[~appStatus = StaticText(view).string_("status: ready"), stretch: 1], [~appStatus = StaticText(view).string_("status: ready"), stretch: 1],
nil); nil);
transport = HLayout( transport = HLayout(
Button(view).states_([["play", Color.black], ["stop", Color.black, Color.grey]]).action_( prevSectionButton = Button(view).states_([["<<", Color.black]]).action_({| pState |
if((~currentSection - 4) >= 0, {
if(~isPlaying, {
~patterns[~currentSection].stop;
~currentSection = (~currentSection - 4).trunc(4);
~play.set(\sel, ~currentSection % 2);
~patterns[~currentSection].play(quant: 0)
},{
~currentSection = ~currentSection - 1;
})
});
}),
prevSubsectionButton = Button(view).states_([["<", Color.black]]).action_({| pState |
if((~currentSection - 1) >= 0, {
if(~isPlaying, {
~patterns[~currentSection].stop;
~currentSection = (~currentSection - 1);
~play.set(\sel, ~currentSection % 2);
~patterns[~currentSection].play(quant: 0)
},{
~currentSection = ~currentSection - 1;
})
})
}),
playStopButton = Button(view).states_([["play", Color.black], ["stop", Color.black, Color.grey]]).action_(
/* /*
{| pState | {| pState |
pauseButton.value = 0; pauseButton.value = 0;
@ -74,14 +101,40 @@
{~play.set(\startPos, startPos, \playRate, 1, \startTrig, 1)})} {~play.set(\startPos, startPos, \playRate, 1, \startTrig, 1)})}
*/ */
{| pState | {| pState |
pauseButton.value = 0; if(pState.value == 0, {
if(pState.value == 0, {~patterns[0].stop; ~isPlaying = false;
clock.string = clockStringFunc.value((startPos * ~totalDur * 5).asInteger)}, ~patterns[~currentSection].stop;
{~currentSection = 0; ~play.set(\sel, ~currentSection % 2); ~patterns[~currentSection].play})} },{
~isPlaying = true;
~play.set(\sel, ~currentSection % 2);
~patterns[~currentSection].play(quant: 0)
})
}
), ),
pauseButton = Button(view).states_([["pause", Color.black], ["pause", Color.black, Color.grey]]).action_( nextSubsectionButton = Button(view).states_([[">", Color.black]]).action_({| pState |
{| pState | if((~currentSection + 1) < ~patterns.size, {
if(pState.value == 1, {~play.set(\playRate, 0)},{~play.set(\playRate, 1)})}), if(~isPlaying, {
~patterns[~currentSection].stop;
~currentSection = (~currentSection + 1);
~play.set(\sel, ~currentSection % 2);
~patterns[~currentSection].play(quant: 0)
},{
~currentSection = ~currentSection + 1;
})
})
}),
nextSectionButton = Button(view).states_([[">>", Color.black]]).action_({| pState |
if((~currentSection + 4) < ~patterns.size, {
if(~isPlaying, {
~patterns[~currentSection].stop;
~currentSection = (~currentSection + 4).trunc(4);
~play.set(\sel, ~currentSection % 2);
~patterns[~currentSection].play(quant: 0)
},{
~currentSection = ~currentSection - 1;
})
})
}),
StaticText(view).string_("start time"), StaticText(view).string_("start time"),
[Slider(view, Rect(0, 0, 30, 5)).action_( [Slider(view, Rect(0, 0, 30, 5)).action_(
{|pos| {|pos|

@ -20,6 +20,8 @@ appEnvironment.push;
~scoreData = ~allMusicData[1]; ~scoreData = ~allMusicData[1];
~sectionOffsets = ~allMusicData[2]; ~sectionOffsets = ~allMusicData[2];
~currentSection = 0; ~currentSection = 0;
~currentSubsection = 0;
~isPlaying = false;
~play = Synth.new(\masterPlayerControl); ~play = Synth.new(\masterPlayerControl);

@ -54,10 +54,13 @@ SynthDef(\masterPlayerControl, {
}).add; }).add;
SynthDef(\transport, {arg beat, fin; SynthDef(\transport, {arg measure = 0, beat = 0, gate = 1, dur = 1;
SendReply.kr(Changed.kr(beat * (beat < fin)),'/measureClock', values: [beat]); measure.poll;
SendReply.kr(TDelay.kr(Changed.kr(beat * (beat < fin)), 0.25),'/measureClockReset', values: [beat]); beat.poll;
SendReply.kr(Changed.kr(beat < fin),'/playNextSubsection'); SendReply.kr(Impulse.kr(0) * (measure > 0) * (beat > 0),'/measureClock', values: [measure, beat]);
SendReply.kr(TDelay.kr(Impulse.kr(0) * (measure > 0) * (beat > 0), 0.25),'/measureClockReset');
SendReply.kr(Impulse.kr(0) * (measure < 1) * (beat < 1),'/playNextSubsection');
EnvGen.kr(Env.sine(dur), gate, doneAction: 2);
}).add; }).add;
@ -132,14 +135,16 @@ SynthDef(\droneOut, {arg gate, bus;
OSCFunc({ arg msg, time; OSCFunc({ arg msg, time;
if((~currentSection + 1) < ~patterns.size, {
~currentSection = ~currentSection + 1; ~currentSection = ~currentSection + 1;
~play.set(\sel, ~currentSection % 2); ~play.set(\sel, ~currentSection % 2);
~patterns[~currentSection].play(quant: 0) ~patterns[~currentSection].play(quant: 0)
})
},'/playNextSubsection', s.addr); },'/playNextSubsection', s.addr);
//~~~~gen music //~~~~gen music
~genPatterns = {arg guitarSeqIn, accompLowSeqIn, accompHighSeqIn, sectionSeqIn, tempo = 0.08; ~genPatterns = {arg guitarSeqIn, accompLowSeqIn, accompHighSeqIn, sectionSeqIn, tempo = 0.08;
var calcSustains, genSectionSec, sectionLimits; var calcSustains, genSectionSec, sectionLimits, measureCount;
//~~~~helper sus function //~~~~helper sus function
calcSustains = {arg stringSeq, durSeq; calcSustains = {arg stringSeq, durSeq;
@ -186,16 +191,26 @@ OSCFunc({ arg msg, time;
resSeqs resSeqs
}; };
measureCount = 0;
sectionLimits = []; sectionLimits = [];
sectionSeqIn.slice(nil, 0).add(100000).doAdjacentPairs({arg a, b; sectionLimits = sectionLimits.add([a, b])}); sectionSeqIn.slice(nil, 0).add(100000).doAdjacentPairs({arg a, b; sectionLimits = sectionLimits.add([a, b])});
sectionLimits.collect({arg timePair, secIndex; sectionLimits.collect({arg timePair, secIndex;
var startTime, endTime, endBeat, var startTime, endTime, beatLength, beatSeq, measureSeq,
guitarSecSeq, accompLowSecSeq, accompHighSecSeq, guitarSecSeq, accompLowSecSeq, accompHighSecSeq,
stringSeq, fretSeq, durSeq, susSeq, trigSeq, openStrings, pattern; stringSeq, fretSeq, durSeq, susSeq, trigSeq, openStrings, pattern;
startTime = timePair[0]; startTime = timePair[0];
endTime = timePair[1]; endTime = timePair[1];
endBeat = endTime - startTime;
if((secIndex % 4) == 0, {measureCount = 0});
beatLength = (endTime - startTime) / 8;
beatSeq = ((beatLength / 2) - 1).asInteger.collect({[1, 2]});
beatSeq = if((beatLength % 2) == 0, {beatSeq.add([1, 2])}, {beatSeq.add([1, 2, 3])});
measureSeq = measureCount + beatSeq.collect({arg measure, mIndex; measure.collect({mIndex + 1})}).flat;
measureCount = measureSeq.last;
beatSeq = beatSeq.flat;
measureSeq = measureSeq.add(0);
beatSeq = beatSeq.add(0);
guitarSecSeq = genSectionSec.value(guitarSeqIn, startTime, endTime, 0); guitarSecSeq = genSectionSec.value(guitarSeqIn, startTime, endTime, 0);
accompLowSecSeq = genSectionSec.value(accompLowSeqIn, startTime, endTime, 1); accompLowSecSeq = genSectionSec.value(accompLowSeqIn, startTime, endTime, 1);
@ -260,10 +275,11 @@ OSCFunc({ arg msg, time;
\amp, 0.5, \amp, 0.5,
//\bus, if(secIndex % 2 == 0, {~accompHighBusA.index}, {~accompHighBusB.index})), //\bus, if(secIndex % 2 == 0, {~accompHighBusA.index}, {~accompHighBusB.index})),
\bus, ~accompHighBus.index), \bus, ~accompHighBus.index),
Pmono(\transport, Pbind(
\beat, Pseq((0..((endBeat / 8).asInteger))), \instrument, \transport,
\dur, tempo * 8, \measure, Pseq(measureSeq),
\fin, ((endBeat / 8).asInteger).postln \beat, Pseq(beatSeq),
\dur, tempo * 8
) )
]); ]);
pattern pattern

Loading…
Cancel
Save