2020.06.13.01

main
Michael Winter 5 years ago
parent 14f629d754
commit 0347890214

@ -30,18 +30,19 @@
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, generator, transport, ranSeed, order, tempo, sectionDisplay, clock, metronome; var updateTransport, updateSection,
view, generator, transport, ranSeed, order, tempo, sectionDisplay, clock, metronome;
// this func updates the whole transport panel // this func updates the whole transport panel
~updateTransport = {arg measure, beat; updateTransport = {arg measure, beat;
clock.string = clockStringFunc.value(measure, beat); 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);
fork {0.75.wait; {metronome.string = ""}.defer}; {0.75.wait; {metronome.string = ""}.defer}.fork(~tempoClock, quant: 0);
}; }.inEnvir;
// this func handles the movement between sections // this func handles the movement between sections
~updateSection = {arg shift, stop = true, manualCall = true; updateSection = {arg shift, stop = true, manualCall = true;
var runThis; var runThis;
runThis = (manualCall || (manualCall.not && ~autoAdvance)); runThis = (manualCall || (manualCall.not && ~autoAdvance));
runThis = runThis && ((~currentSection + shift) < ~sectionOrder.size); runThis = runThis && ((~currentSection + shift) < ~sectionOrder.size);
@ -71,7 +72,7 @@
sectionDisplay.string = "section: " ++ section.asString ++ "." ++ subSection.asString; sectionDisplay.string = "section: " ++ section.asString ++ "." ++ subSection.asString;
if(~isPlaying, { if(~isPlaying, {
~play.set(\sel, ~currentSection % 2); ~play.set(\sel, ~currentSection % 2);
~patterns[~sectionOrder[~currentSection]].play(quant: 0); ~patterns[~sectionOrder[~currentSection]].play(~tempoClock, quant: 0);
if(~interludes && ((~currentSection % 4) == 3) && (~currentSection != (~sectionOrder.size - 1)), { if(~interludes && ((~currentSection % 4) == 3) && (~currentSection != (~sectionOrder.size - 1)), {
~interludeTremelo.set(\gate, 1); ~interludeTremelo.set(\gate, 1);
~interludeTremelo.set(\amp, 1); ~interludeTremelo.set(\amp, 1);
@ -87,10 +88,10 @@
var measure, beat; var measure, beat;
measure = ~sectionStartMeasure[~sectionOrder[~currentSection]]; measure = ~sectionStartMeasure[~sectionOrder[~currentSection]];
beat = 1; beat = 1;
~updateTransport.value(measure, beat); updateTransport.value(measure, beat);
}); });
}); });
}; }.inEnvir;
// these funcs receive messages from the synth // these funcs receive messages from the synth
OSCFunc({ arg msg, time; OSCFunc({ arg msg, time;
@ -98,22 +99,23 @@
var measure, beat; var measure, beat;
measure = msg[3]; measure = msg[3];
beat = msg[4]; beat = msg[4];
~updateTransport.value(measure, beat) updateTransport.value(measure, beat)
}.defer; }.inEnvir.defer;
},'/measureClock' ++ ~hash, s.addr); },'/measureClock' ++ ~hash, s.addr);
//OSCFunc({ arg msg, time; {metronome.string = ""}.defer},'/measureClockReset', s.addr);
OSCFunc({ arg msg, time; {updateSection.value(1, false, false)}.inEnvir.defer},'/playNextSubsection' ++ ~hash, s.addr);
view = View(win); view = View(win);
generator = HLayout( generator = HLayout(
ranSeed = TextField(view, Rect(10, 10, 10, 20)).string_("20200525"), ranSeed = TextField(view, Rect(10, 10, 10, 20)).string_("20200525"),
Button(view).states_([["reset seed"]]).action_({ ranSeed.string = "20200525"}), Button(view).states_([["reset seed"]]).action_({ ranSeed.string = "20200525"}.inEnvir),
Button(view).states_([["random seed"]]).action_({ ranSeed.string = 50000000.rand.asString}), Button(view).states_([["random seed"]]).action_({ ranSeed.string = 50000000.rand.asString}.inEnvir),
Button(view).states_([["generate"]]).action_({~genAll.value(ranSeed.string.asInteger)}), Button(view).states_([["generate"]]).action_({~genAll.value(ranSeed.string.asInteger)}.inEnvir),
Button(view).states_([["transcribe"]]).action_({~transcribe.value(~scoreData)}), Button(view).states_([["transcribe"]]).action_({~transcribe.value(~scoreData)}.inEnvir),
[StaticText(view).string_(" "), stretch: 1], nil); [StaticText(view).string_(" "), stretch: 1], nil);
transport = HLayout( transport = HLayout(
Button(view).states_([["<<", Color.black]]).action_({arg pState; ~updateSection.value(-4)}), Button(view).states_([["<<", Color.black]]).action_({arg pState; updateSection.value(-4)}.inEnvir),
Button(view).states_([["<", Color.black]]).action_({arg pState; ~updateSection.value(-1)}), Button(view).states_([["<", Color.black]]).action_({arg pState; updateSection.value(-1)}.inEnvir),
Button(view).states_([["play", Color.black], ["stop", Color.black, Color.grey]]).action_( Button(view).states_([["play", Color.black], ["stop", Color.black, Color.grey]]).action_(
{arg pState; {arg pState;
if(pState.value == 0, { if(pState.value == 0, {
@ -123,11 +125,11 @@
~interludeTremelo.set(\gate, 0); ~interludeTremelo.set(\gate, 0);
measure = ~sectionStartMeasure[~currentSection]; measure = ~sectionStartMeasure[~currentSection];
beat = 1; beat = 1;
~updateTransport.value(measure, beat); updateTransport.value(measure, beat);
~interludeTremelo.set(\gate, 0); ~interludeTremelo.set(\gate, 0);
~interludeTremelo.set(\amp, 0); ~interludeTremelo.set(\amp, 0);
},{ },{
fork { {
[1, 2, 1, 2].do({arg beat; [1, 2, 1, 2].do({arg beat;
{ {
metronome.stringColor = metronomeColorFunc.value(beat); metronome.stringColor = metronomeColorFunc.value(beat);
@ -139,17 +141,17 @@
}); });
~isPlaying = true; ~isPlaying = true;
~play.set(\sel, ~currentSection % 2); ~play.set(\sel, ~currentSection % 2);
~patterns[~sectionOrder[~currentSection]].play(quant: 0); ~patterns[~sectionOrder[~currentSection]].play(~tempoClock, quant: 0);
if(~interludes && ((~currentSection % 4) == 3) && (~currentSection != (~sectionOrder.size - 1)), { if(~interludes && ((~currentSection % 4) == 3) && (~currentSection != (~sectionOrder.size - 1)), {
~interludeTremelo.set(\gate, 1); ~interludeTremelo.set(\gate, 1);
~interludeTremelo.set(\amp, 1); ~interludeTremelo.set(\amp, 1);
}); });
} }.fork(~tempoClock, quant: 0);
}) })
} }.inEnvir
), ),
Button(view).states_([[">", Color.black]]).action_({arg pState; ~updateSection.value(1)}), Button(view).states_([[">", Color.black]]).action_({arg pState; updateSection.value(1)}.inEnvir),
Button(view).states_([[">>", Color.black]]).action_({arg pState; ~updateSection.value(4)}), nil, Button(view).states_([[">>", Color.black]]).action_({arg pState; updateSection.value(4)}.inEnvir), nil,
sectionDisplay = StaticText(win).string_("section: 1.1").font_(Font("Monaco", 70)), nil); sectionDisplay = StaticText(win).string_("section: 1.1").font_(Font("Monaco", 70)), nil);
view.layout_(HLayout( view.layout_(HLayout(
[VLayout( [VLayout(
@ -159,14 +161,14 @@
nil, transport, nil, nil, transport, nil,
HLayout( HLayout(
tempo = TextField(view).string_("90"), tempo = TextField(view).string_("90"),
Button(view).states_([["set tempo"]]).action_({TempoClock.tempo = tempo.string.asInteger / 60}), Button(view).states_([["set tempo"]]).action_({~tempoClock.tempo = tempo.string.asInteger / 60}.inEnvir),
StaticText(view).string_(" | "), StaticText(view).string_(" | "),
Button(view).states_([["auto advance", Color.black], ["auto advance", Color.black, Color.grey]]).action_({ Button(view).states_([["auto advance", Color.black], ["auto advance", Color.black, Color.grey]]).action_({
arg v; ~autoAdvance = if(v.value == 0, {false}, {true});~autoAdvance; arg v; ~autoAdvance = if(v.value == 0, {false}, {true});~autoAdvance;
}).value_(1), }.inEnvir).value_(1),
Button(view).states_([["interludes", Color.black], ["interludes", Color.black, Color.grey]]).action_({ Button(view).states_([["interludes", Color.black], ["interludes", Color.black, Color.grey]]).action_({
arg v; ~interludes = if(v.value == 0, {false}, {true}) arg v; ~interludes = if(v.value == 0, {false}, {true})
}), }.inEnvir),
[StaticText(view).string_(" "), stretch: 1]), [StaticText(view).string_(" "), stretch: 1]),
[StaticText(view).string_(" "), stretch: 1], [StaticText(view).string_(" "), stretch: 1],
HLayout( HLayout(
@ -181,8 +183,8 @@
}); });
}).flat; }).flat;
~currentSection = 0; ~currentSection = 0;
~updateSection.value(0); updateSection.value(0);
}), }.inEnvir),
[StaticText(view).string_(" "), stretch: 1]), [StaticText(view).string_(" "), stretch: 1]),
[StaticText(view).string_(" "), stretch: 1], generator [StaticText(view).string_(" "), stretch: 1], generator
), alignment: \top]))}; ), alignment: \top]))};
@ -203,11 +205,11 @@
VLayout( VLayout(
[HLayout( [HLayout(
Slider(view).value_(0.8).action_( Slider(view).value_(0.8).action_(
{arg v; masterVol = v.value * 1.25; ~play.set(\masterVol, masterVol)}), {arg v; masterVol = v.value * 1.25; ~play.set(\masterVol, masterVol)}.inEnvir),
masterIndicators[0], masterIndicators[0],
masterIndicators[1]), stretch: 2], masterIndicators[1]), stretch: 2],
Button(view).states_([["mute", Color.black], ["mute", Color.black, Color.grey]]).action_( Button(view).states_([["mute", Color.black], ["mute", Color.black, Color.grey]]).action_(
{arg v; masterMute = (1 - v.value).abs; ~play.set(\masterMute, masterMute)}), {arg v; masterMute = (1 - v.value).abs; ~play.set(\masterMute, masterMute)}.inEnvir),
StaticText(view).string_(" master ").align_(\center) StaticText(view).string_(" master ").align_(\center)
), nil); ), nil);
tracks = {arg part; tracks = {arg part;
@ -215,13 +217,13 @@
VLayout( VLayout(
HLayout( HLayout(
Slider(view).value_(0.8).action_( Slider(view).value_(0.8).action_(
{arg v; partVols[part] = v.value * 1.25; ~play.set(partAbbr[part] ++ "Vol", partVols[part])}), {arg v; partVols[part] = v.value * 1.25; ~play.set(partAbbr[part] ++ "Vol", partVols[part])}.inEnvir),
trackIndicators[part]), trackIndicators[part]),
Button(view).states_([["mute", Color.black], ["mute", Color.black, Color.grey]]).action_( Button(view).states_([["mute", Color.black], ["mute", Color.black, Color.grey]]).action_(
{arg v; partMutes[part] = (1 - v.value).abs; ~play.set(partAbbr[part] ++ "Mute", partMutes[part])}), {arg v; partMutes[part] = (1 - v.value).abs; ~play.set(partAbbr[part] ++ "Mute", partMutes[part])}.inEnvir),
StaticText(view).string_("pan").align_(\center), StaticText(view).string_("pan").align_(\center),
Knob(view).value_(0.5).action_( Knob(view).value_(0.5).action_(
{arg v; partPans[part] = v.value * 2 - 1; ~play.set(partAbbr[part] ++ "Pan", partPans[part])}), {arg v; partPans[part] = v.value * 2 - 1; ~play.set(partAbbr[part] ++ "Pan", partPans[part])}.inEnvir),
StaticText(view).string_(trackNames[part]).align_(\center) StaticText(view).string_(trackNames[part]).align_(\center)
), ),
nil) nil)
@ -231,9 +233,9 @@
win.layout = VLayout( win.layout = VLayout(
HLayout( HLayout(
transportButton = Button().states_([["transport", Color.white, Color.grey], ["transport", Color.black]]).action_( transportButton = Button().states_([["transport", Color.white, Color.grey], ["transport", Color.black]]).action_(
{tabButtonReset.value; transportButton.value = 0; tabs.index = 0 }).value_(0), {tabButtonReset.value; transportButton.value = 0; tabs.index = 0 }.inEnvir).value_(0),
mixerButton = Button().states_([["mixer", Color.white, Color.grey], ["mixer", Color.black]]).action_( mixerButton = Button().states_([["mixer", Color.white, Color.grey], ["mixer", Color.black]]).action_(
{tabButtonReset.value; mixerButton.value = 0; tabs.index = 1 }).value_(1)), {tabButtonReset.value; mixerButton.value = 0; tabs.index = 1 }.inEnvir).value_(1)),
tabs = StackLayout(masterView.value, faderView.value)); tabs = StackLayout(masterView.value, faderView.value));
}; };
) )

@ -29,17 +29,15 @@ s.waitForBoot({
}; };
// set the global variables // set the global variables
TempoClock.tempo = 90 / 60; ~tempoClock = TempoClock.new(90 / 60);
~dir = thisProcess.nowExecutingPath.dirname; ~dir = thisProcess.nowExecutingPath.dirname;
~genAll.value(20200525); ~genAll.value(20200525);
~play = Synth.new(\masterPlayerControl); ~play = Synth.new(\masterPlayerControl ++ ~hash);
~interludeTremelo = Synth.new(\interludeTremelo); ~interludeTremelo = Synth.new(\interludeTremelo ++ ~hash);
~autoAdvance = true; ~autoAdvance = true;
~interludes = false; ~interludes = false;
~sectionOrder = ~patterns.size.collect({arg sec; sec}); ~sectionOrder = ~patterns.size.collect({arg sec; sec});
~generateGUI.value; ~generateGUI.value;
appEnvironment.pop;
}); });
appEnvironment.pop;
) )

@ -9,7 +9,7 @@
~accompLowUpperBusB = Bus.audio(s, 1); ~accompLowUpperBusB = Bus.audio(s, 1);
~interludeTremoloBus = Bus.audio(s, 1); ~interludeTremoloBus = Bus.audio(s, 1);
SynthDef(\masterPlayerControl, { SynthDef(\masterPlayerControl ++ ~hash, {
arg sel = 0, arg sel = 0,
masterVol = 1, masterMute = 1, masterVol = 1, masterMute = 1,
guitarVol = 1, guitarPan = 0, guitarMute = 1, guitarVol = 1, guitarPan = 0, guitarMute = 1,
@ -69,7 +69,7 @@ SynthDef(\masterPlayerControl, {
}).add; }).add;
SynthDef(\transport, {arg measure = 0, beat = 0, gate = 1, dur = 1; 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, beat]); SendReply.kr(Impulse.kr(0) * (measure > 0) * (beat > 0),'/measureClock' ++ ~hash, values: [measure, beat]);
SendReply.kr(Impulse.kr(0) * (measure < 1) * (beat < 1),'/playNextSubsection' ++ ~hash); SendReply.kr(Impulse.kr(0) * (measure < 1) * (beat < 1),'/playNextSubsection' ++ ~hash);
EnvGen.kr(Env.sine(dur), gate, doneAction: 2); EnvGen.kr(Env.sine(dur), gate, doneAction: 2);
@ -77,7 +77,7 @@ SynthDef(\transport, {arg measure = 0, beat = 0, gate = 1, dur = 1;
//~~~~karplus //~~~~karplus
SynthDef(\karplus, {arg freq, gate = 1, amp = 0.5, bus; SynthDef(\karplus ++ ~hash, {arg freq, gate = 1, amp = 0.5, bus;
Out.ar(bus, Out.ar(bus,
Pluck.ar(WhiteNoise.ar(0.1), Impulse.kr(0), 220.reciprocal, freq.reciprocal, 10, coef:0) * Pluck.ar(WhiteNoise.ar(0.1), Impulse.kr(0), 220.reciprocal, freq.reciprocal, 10, coef:0) *
Linen.kr(gate, doneAction: 2) * amp) Linen.kr(gate, doneAction: 2) * amp)
@ -85,7 +85,7 @@ SynthDef(\karplus, {arg freq, gate = 1, amp = 0.5, bus;
//~~~~accompaniment //~~~~accompaniment
SynthDef(\accompBass, {arg freq1 = 100, freq2 = 100, gate = 1, amp = 0.5, busLower, busUpper, cutoff = 0; SynthDef(\accompBass ++ ~hash, {arg freq1 = 100, freq2 = 100, gate = 1, amp = 0.5, busLower, busUpper, cutoff = 0;
var env, lower, upper; var env, lower, upper;
env = EnvGen.kr(Env.perc(0.1, 10, level: amp), Impulse.kr(0) + Changed.kr(freq2)); env = EnvGen.kr(Env.perc(0.1, 10, level: amp), Impulse.kr(0) + Changed.kr(freq2));
lower = SinOsc.ar(freq1, 0, 0.5) * env; lower = SinOsc.ar(freq1, 0, 0.5) * env;
@ -96,13 +96,13 @@ SynthDef(\accompBass, {arg freq1 = 100, freq2 = 100, gate = 1, amp = 0.5, busLow
//this is not releasing properly //this is not releasing properly
SynthDef(\accompTreble, {arg freq, gate = 1, sustain, amp, bus; SynthDef(\accompTreble ++ ~hash, {arg freq, gate = 1, sustain, amp, bus;
var treble; var treble;
treble = SinOsc.ar(freq, 0, EnvGen.kr(Env.sine(sustain, amp * 0.1), gate, doneAction: 2)); treble = SinOsc.ar(freq, 0, EnvGen.kr(Env.sine(sustain, amp * 0.1), gate, doneAction: 2));
Out.ar(bus, treble) Out.ar(bus, treble)
}).add; }).add;
SynthDef(\interludeTremelo, { arg gate = 0, amp = 1; SynthDef(\interludeTremelo ++ ~hash, { arg gate = 0, amp = 1;
var tremeloTrig, freq, sig, feedback, fade; var tremeloTrig, freq, sig, feedback, fade;
//fast tremelo - note that this can be slower so long as the delaytime of the feedback remains short //fast tremelo - note that this can be slower so long as the delaytime of the feedback remains short
tremeloTrig = Impulse.kr(50); tremeloTrig = Impulse.kr(50);
@ -118,8 +118,6 @@ SynthDef(\interludeTremelo, { arg gate = 0, amp = 1;
Out.ar(~interludeTremoloBus, fade); Out.ar(~interludeTremoloBus, fade);
}).add; }).add;
OSCFunc({ arg msg, time; {~updateSection.value(1, false, false)}.defer},'/playNextSubsection' ++ ~hash, s.addr);
//~~~~gen music //~~~~gen music
~genPatterns = {arg guitarSeqIn, accompLowSeqIn, accompHighSeqIn, sectionSeqIn, beatFrac = 1/8; ~genPatterns = {arg guitarSeqIn, accompLowSeqIn, accompHighSeqIn, sectionSeqIn, beatFrac = 1/8;
var calcSustains, genSectionSec, sectionLimits, measureCount; var calcSustains, genSectionSec, sectionLimits, measureCount;
@ -204,7 +202,7 @@ OSCFunc({ arg msg, time; {~updateSection.value(1, false, false)}.defer},'/playNe
pattern = EventPatternProxy.new; pattern = EventPatternProxy.new;
pattern.source = Ppar([ pattern.source = Ppar([
Pbind( Pbind(
\instrument, \karplus, \instrument, \karplus ++ ~hash,
\amp, 0.3, \amp, 0.3,
\dur, Pseq(durSeq * beatFrac), \dur, Pseq(durSeq * beatFrac),
\sustain, Pseq(susSeq * beatFrac), \sustain, Pseq(susSeq * beatFrac),
@ -214,7 +212,7 @@ OSCFunc({ arg msg, time; {~updateSection.value(1, false, false)}.defer},'/playNe
\bus, ~guitarBus.index), \bus, ~guitarBus.index),
if(accompLowSecSeq.size > 1, { if(accompLowSecSeq.size > 1, {
Pmono( Pmono(
\accompBass, \accompBass ++ ~hash,
\amp, 0.5, \amp, 0.5,
\freq1, Pseq(accompLowSecSeq.slice(nil, 0)), \freq1, Pseq(accompLowSecSeq.slice(nil, 0)),
\freq2, Pseq(accompLowSecSeq.slice(nil, 1)), \freq2, Pseq(accompLowSecSeq.slice(nil, 1)),
@ -223,7 +221,7 @@ OSCFunc({ arg msg, time; {~updateSection.value(1, false, false)}.defer},'/playNe
\busUpper, if(secIndex % 2 == 0, {~accompLowUpperBusA.index}, {~accompLowUpperBusB.index})) \busUpper, if(secIndex % 2 == 0, {~accompLowUpperBusA.index}, {~accompLowUpperBusB.index}))
}, { }, {
Pmono( Pmono(
\accompBass, \accompBass ++ ~hash,
\amp, 0.5, \amp, 0.5,
\freq1, Pseq([accompLowSecSeq[0][0]]), \freq1, Pseq([accompLowSecSeq[0][0]]),
\freq2, Pseq([accompLowSecSeq[0][1]]), \freq2, Pseq([accompLowSecSeq[0][1]]),
@ -232,14 +230,14 @@ OSCFunc({ arg msg, time; {~updateSection.value(1, false, false)}.defer},'/playNe
\busUpper, if(secIndex % 2 == 0, {~accompLowUpperBusA.index}, {~accompLowUpperBusB.index})) \busUpper, if(secIndex % 2 == 0, {~accompLowUpperBusA.index}, {~accompLowUpperBusB.index}))
}), }),
Pbind( Pbind(
\instrument, \accompTreble, \instrument, \accompTreble ++ ~hash,
\freq, Pseq(accompHighSecSeq.slice(nil, 0)), \freq, Pseq(accompHighSecSeq.slice(nil, 0)),
\dur, Pseq(accompHighSecSeq.slice(nil, 1) * beatFrac), \dur, Pseq(accompHighSecSeq.slice(nil, 1) * beatFrac),
\sustain, Pseq(accompHighSecSeq.slice(nil, 2) * beatFrac), \sustain, Pseq(accompHighSecSeq.slice(nil, 2) * beatFrac),
\amp, 0.5, \amp, 0.5,
\bus, ~accompHighBus.index), \bus, ~accompHighBus.index),
Pbind( Pbind(
\instrument, \transport, \instrument, \transport ++ ~hash,
\measure, Pseq(measureSeq), \measure, Pseq(measureSeq),
\beat, Pseq(beatSeq), \beat, Pseq(beatSeq),
\dur, beatFrac * 8 \dur, beatFrac * 8

Loading…
Cancel
Save