code cleanup and file location organization

main
mwinter 4 years ago
parent 1e91bc864f
commit 011690056e

@ -79,8 +79,8 @@
print-first-page-number = ##t print-first-page-number = ##t
print-page-number = ##t print-page-number = ##t
oddHeaderMarkup = \markup { \fill-line { \line { \on-the-fly #not-first-page {\pad-markup #2 \italic {"to kill a monarch"} }}}} oddHeaderMarkup = \markup { \fill-line { \line { \on-the-fly #not-first-page {\pad-markup #2 { \concat {\italic {"to kill a monarch "} (seed: 19800725)}}}}}}
evenHeaderMarkup = \markup { \fill-line { \line { \on-the-fly #not-first-page {\pad-markup #2 \italic {"to kill a monarch"} }}}} evenHeaderMarkup = \markup { \fill-line { \line { \on-the-fly #not-first-page {\pad-markup #2 { \concat {\italic {"to kill a monarch "} (seed: 19800725)}}}}}}
oddFooterMarkup = \markup { \fill-line { oddFooterMarkup = \markup { \fill-line {
\concat { \concat {
"-" "-"
@ -100,6 +100,7 @@
\header { \header {
title = \markup { \italic {to kill a monarch}} title = \markup { \italic {to kill a monarch}}
composer = \markup \right-column {"michael winter" "(berlin, germany; 2020)"} composer = \markup \right-column {"michael winter" "(berlin, germany; 2020)"}
poet = "seed: 19800725"
tagline = "" tagline = ""
} }
@ -136,15 +137,6 @@
(minimum-distance . 20 ) (minimum-distance . 20 )
(padding . 0 ) (padding . 0 )
(stretchability . 0)) (stretchability . 0))
%\override TimeSignature.font-size = #2
%\override TimeSignature.break-align-symbol = #'clef
%\override TimeSignature.X-offset =
% #ly:self-alignment-interface::x-aligned-on-self
%\override TimeSignature.self-alignment-X = #LEFT
%\override TimeSignature.Y-offset = #9
%\override TimeSignature.extra-offset = #'(2 . 0)
%\override TimeSignature.break-visibility = #end-of-line-invisible
\override TextScript.staff-padding = #2 \override TextScript.staff-padding = #2
\override TextScript.self-alignment-X = #0 \override TextScript.self-alignment-X = #0
} }
@ -167,7 +159,6 @@
\midi { } \midi { }
%showLastLength = R1*10
\score{ \score{
\new Score \new Score
<< <<
@ -184,5 +175,3 @@
\layout{} \layout{}
\midi{} \midi{}
} }
%\markup { \center-column { \override #'(offset . 5) \underline "3" \override #'(offset . 5) \underline " 2 " \override #'(offset . 5) \underline "1" " 1 " } }

@ -0,0 +1,177 @@
\version "2.19.83"
#(define (override-color-for-all-grobs color)
(lambda (context)
(let loop ((x all-grob-descriptions))
(if (not (null? x))
(let ((grob-name (caar x)))
(ly:context-pushpop-property context grob-name 'color color)
(loop (cdr x)))))))
#(define-markup-command (relMark layout props mus) (ly:music?)
#:properties ((size -2))
(interpret-markup layout props
#{
\markup {
\score {
\new Staff { $mus }
\layout {
\context {
\Staff
\remove Time_signature_engraver
fontSize = #-2
\hide Stem
\override TextScript.outside-staff-priority = ##f
\override StaffSymbol.staff-space = #(magstep -2)
\override StaffSymbol.thickness = #(magstep -2)
\override TextScript.self-alignment-X = #-0.4
\override TextScript.staff-padding = #1
}
\context {
\Score
proportionalNotationDuration = #(ly:make-moment 1/16)
\remove "Separating_line_group_engraver"
\override SpacingSpanner.strict-note-spacing = ##t
\override RehearsalMark.self-alignment-X = #-1
\override RehearsalMark.Y-offset = #10
\override RehearsalMark.X-offset = #10
}
\context {
\Voice
\consists "Horizontal_bracket_engraver"
\override HorizontalBracket.direction = #UP
}
indent = 0
line-width = 4\cm
}
}
}
#}))
\paper {
#(set-paper-size "a4" 'portrait)
top-margin = 1 \cm
bottom-margin = 1 \cm
left-margin = 2 \cm
ragged-bottom = ##t
top-system-spacing =
#'((basic-distance . 15 )
(minimum-distance . 15 )
(padding . 0 )
(stretchability . 0))
system-system-spacing =
#'((basic-distance . 35 )
(minimum-distance . 35 )
(padding . 0 )
(stretchability . 0))
last-bottom-spacing =
#'((basic-distance . 10 )
(minimum-distance . 10 )
(padding . 0 )
(stretchability . 0))
%systems-per-page = 3
first-page-number = 1
print-first-page-number = ##t
print-page-number = ##t
oddHeaderMarkup = \markup { \fill-line { \line { \on-the-fly #not-first-page {\pad-markup #2 { \concat {\italic {"to kill a monarch "} (seed: xxx)}}}}}}
evenHeaderMarkup = \markup { \fill-line { \line { \on-the-fly #not-first-page {\pad-markup #2 { \concat {\italic {"to kill a monarch "} (seed: xxx)}}}}}}
oddFooterMarkup = \markup { \fill-line {
\concat {
"-"
\fontsize #1.5
\on-the-fly #print-page-number-check-first
\fromproperty #'page:page-number-string
"-"}}}
evenFooterMarkup = \markup { \fill-line {
\concat {
"-"
\fontsize #1.5
\on-the-fly #print-page-number-check-first
\fromproperty #'page:page-number-string
"-"}}}
}
\header {
title = \markup { \italic {to kill a monarch}}
composer = \markup \right-column {"michael winter" "(berlin, germany; 2020)"}
poet = "seed: xxx"
tagline = ""
}
#(set-global-staff-size 11)
\layout {
indent = 0.0\cm
line-width = 17.5\cm
ragged-last = ##t
ragged-right = ##f
\context {
\Score
\override BarNumber.stencil = #(make-stencil-circler 0.1 0.25 ly:text-interface::print)
\override Stem.stemlet-length = #0.75
proportionalNotationDuration = #(ly:make-moment 1/16)
\remove "Separating_line_group_engraver"
\override RehearsalMark.self-alignment-X = #-1
\override RehearsalMark.Y-offset = #10
\override RehearsalMark.X-offset = #-8
%\override RehearsalMark.outside-staff-priority = #0
}
\context {
\Staff
\override VerticalAxisGroup.staff-staff-spacing =
#'((basic-distance . 20 )
(minimum-distance . 20 )
(padding . 0 )
(stretchability . 0))
\override VerticalAxisGroup.default-staff-staff-spacing =
#'((basic-distance . 20 )
(minimum-distance . 20 )
(padding . 0 )
(stretchability . 0))
\override TextScript.staff-padding = #2
\override TextScript.self-alignment-X = #0
}
\context {
\StaffGroup
\name "SemiStaffGroup"
\consists "Span_bar_engraver"
\override SpanBar.stencil =
#(lambda (grob)
(if (string=? (ly:grob-property grob 'glyph-name) "|")
(set! (ly:grob-property grob 'glyph-name) ""))
(ly:span-bar::print grob))
}
\context {
\Score
\accepts SemiStaffGroup
}
}
\midi { }
\score{
\new Score
<<
\new SemiStaffGroup {
<<
\include "includes/part_I.ly"
\include "includes/part_II.ly"
\include "includes/part_III.ly"
>>
}
\include "includes/part_star.ly"
>>
\layout{}
\midi{}
}

@ -1,26 +1,7 @@
( (
var genWindow, masterView, faderView, buildGenerator, buildMetronome, buildTransport, buildTempoControl, buildMasterFader, buildTrackFader, var clockStringFunc, metronomeStringFunc, metronomeColorFunc, updateTransport, updateSubsection,
updateSection, updateSubsection, clockStringFunc, metronomeStringFunc, metronomeColorFunc, updateTransport, buildGenerator, buildMetronome, updateSection, buildTransport, buildTempoControl, buildMasterFader, buildTrackFader,
currentSection = 1, currentSubsection = 1; masterView, faderView, currentSection = 1, currentSubsection = 1;
buildGenerator = {arg view;
var ranSeed;
HLayout(
ranSeed = TextField(view).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);
~appStatus.string = "status: generating"}.inEnvir),
[~appStatus = StaticText(view).string_("status: ready"), stretch: 1],
Button(view).states_([["transcribe"]]).action_({
{~transcribe.value(~scoreData, ~sectionData); ~appStatus.string = "status: ready"}.fork(AppClock);
~appStatus.string = "status: transcribing"}.inEnvir),
Button(view).states_([["bounce audio"]]).action_({
{~bounceAudio.value; ~appStatus.string = "status: ready"}.fork(AppClock);
~appStatus.string = "status: bouncing audio"}.inEnvir),
nil)
};
// these funcs update the elements of the transport panel // these funcs update the elements of the transport panel
clockStringFunc = { clockStringFunc = {
@ -46,6 +27,38 @@ updateTransport = {arg clock, metronome, sectionDisplay, measure, beat, section,
{0.75.wait; {metronome.string = ""}.defer}.fork(~tempoClock, quant: 0); {0.75.wait; {metronome.string = ""}.defer}.fork(~tempoClock, quant: 0);
}.inEnvir; }.inEnvir;
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]][0], 1,
currentSection, currentSubsection
);
});
}, {
updateSection.value(mod, clock, metronome, sectionDisplay, refresh, true)
})
};
buildGenerator = {arg view;
var ranSeed;
HLayout(
ranSeed = TextField(view).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);
~appStatus.string = "status: generating"}.inEnvir),
[~appStatus = StaticText(view).string_("status: ready"), stretch: 1],
Button(view).states_([["transcribe"]]).action_({
{~transcribe.value(~scoreData, ~sectionData, ranSeed.value); ~appStatus.string = "status: ready"}.fork(AppClock);
~appStatus.string = "status: transcribing"}.inEnvir),
Button(view).states_([["bounce audio"]]).action_({
{~bounceAudio.value(ranSeed.value); ~appStatus.string = "status: ready"}.fork(AppClock);
~appStatus.string = "status: bouncing audio"}.inEnvir),
nil)
};
buildMetronome = {arg win; buildMetronome = {arg win;
var clock, metronome, layout; var clock, metronome, layout;
@ -90,21 +103,6 @@ updateSection = {arg mod, clock, metronome, sectionDisplay, refresh = true, indi
}); });
}; };
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]][0], 1,
currentSection, currentSubsection
);
});
}, {
updateSection.value(mod, clock, metronome, sectionDisplay, refresh, true)
})
};
buildTransport = {arg win, view, clock, metronome, preampBusses, accompBusses, postampBusses; buildTransport = {arg win, view, clock, metronome, preampBusses, accompBusses, postampBusses;
var sec, subsec, sectionDisplay, layout, player; var sec, subsec, sectionDisplay, layout, player;
@ -116,14 +114,10 @@ buildTransport = {arg win, view, clock, metronome, preampBusses, accompBusses, p
# measure, beat, section, subsection = msg[3..]; # measure, beat, section, subsection = msg[3..];
currentSection = sec = section.asInteger; currentSection = sec = section.asInteger;
currentSubsection = subsec = subsection.asInteger; currentSubsection = subsec = subsection.asInteger;
//currentSubsection.postln;
updateTransport.value(clock, metronome, sectionDisplay, measure, beat, section, subsection); updateTransport.value(clock, metronome, sectionDisplay, measure, beat, section, subsection);
}.inEnvir.defer; }.inEnvir.defer;
},'/measureClock_' ++ ~hash, s.addr); },'/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( layout = HLayout(
Button(view).states_([["<<", Color.black]]).action_({arg pState; updateSection.value(-1, clock, metronome, sectionDisplay)}.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_([["<", Color.black]]).action_({arg pState; updateSubsection.value(-1, clock, metronome, sectionDisplay)}.inEnvir),
@ -145,12 +139,11 @@ buildTransport = {arg win, view, clock, metronome, preampBusses, accompBusses, p
~patternProxy.play(~tempoClock, quant: 0) ~patternProxy.play(~tempoClock, quant: 0)
}.fork(~tempoClock, quant: 0) }.fork(~tempoClock, quant: 0)
}, { }, {
//subsec.postln;
~patternProxy.pause; ~patternProxy.pause;
//player.stop; //player.stop;
updateTransport.value(clock, metronome, sectionDisplay, updateTransport.value(clock, metronome, sectionDisplay,
~sectionNavDict[[currentSection, currentSubsection]][0], 1, ~sectionNavDict[[currentSection, currentSubsection]][0], 1,
currentSection.postln, currentSubsection.postln); currentSection, currentSubsection);
}); });
}.inEnvir), }.inEnvir),
Button(view).states_([[">", Color.black]]).action_({arg pState; updateSubsection.value(1, clock, metronome, sectionDisplay)}.inEnvir), Button(view).states_([[">", Color.black]]).action_({arg pState; updateSubsection.value(1, clock, metronome, sectionDisplay)}.inEnvir),
@ -170,17 +163,17 @@ buildTempoControl = {arg view;
buildMasterFader = {arg view, masterVol, masterMute, masterIndicators; buildMasterFader = {arg view, masterVol, masterMute, masterIndicators;
HLayout( HLayout([
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)}.inEnvir), {arg v; masterVol = v.value * 1.25; ~play.set(\masterVol, masterVol)}.inEnvir),
masterIndicators[0], masterIndicators[0],
masterIndicators[1]), stretch: 2], masterIndicators[1]),
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)}.inEnvir), {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) ), stretch: 2], nil)
}; };
@ -203,7 +196,7 @@ buildTrackFader = {arg view, name, index, initVal;
VLayout( VLayout(
StaticText(view).string_("pan").align_(\center), StaticText(view).string_("pan").align_(\center),
Knob(view).action_({arg v; var pan = v.value * 2 - 1; ~play.set(\pan_ ++ index, pan)}.inEnvir).value_(0.5) Knob(view).action_({arg v; var pan = v.value * 2 - 1; ~play.set(\pan_ ++ index, pan)}.inEnvir).value_(0.5)
), //[StaticText(view).string_(" "), stretch: 0.1] ),
StaticText(view).string_(name).align_(\center) StaticText(view).string_(name).align_(\center)
), ),
nil) nil)
@ -224,7 +217,7 @@ masterView = {arg win, preampBusses, accompBusses, postampBusses;
[ [
VLayout( VLayout(
metronomeLayout, metronomeLayout,
[StaticText(view).string_(" "), stretch: 1], //nil [StaticText(view).string_(" "), stretch: 1],
transportLayout, transportLayout,
[StaticText(view).string_(" "), stretch: 1], [StaticText(view).string_(" "), stretch: 1],
auxControlsLayout, auxControlsLayout,
@ -283,5 +276,4 @@ faderView = {arg win;
), ),
tabs = StackLayout(masterView.value(win, preampBusses, accompBusses, postampBusses), faderView.value(win)/*, helpView.value*/)); tabs = StackLayout(masterView.value(win, preampBusses, accompBusses, postampBusses), faderView.value(win)/*, helpView.value*/));
}; };
//~generateGUI.value
) )

@ -4,8 +4,8 @@
var appEnvironment; var appEnvironment;
//push new environment //push new environment
//appEnvironment = Environment.make; appEnvironment = Environment.make;
//appEnvironment.push; appEnvironment.push;
s.waitForBoot({ s.waitForBoot({
var preampBusses, accompBusses, postampBusses; var preampBusses, accompBusses, postampBusses;
@ -44,5 +44,5 @@ s.waitForBoot({
~generateGUI.value(preampBusses, accompBusses, postampBusses); ~generateGUI.value(preampBusses, accompBusses, postampBusses);
"ready".postln; "ready".postln;
}); });
//appEnvironment.pop; appEnvironment.pop;
) )

@ -82,7 +82,7 @@ hdChoose = {arg mode, exp = 1, weights = [1, 1, 1, 1, 1, 1, 1];
mode.wchoose(probs.normalizeSum) mode.wchoose(probs.normalizeSum)
}; };
//!!!!this is not returning the same thing when if randseed is set. the issue is the array as key and sorting. //faster sorting algorithm?
wchooseDict = {arg dict, exp = 1, limit = 0; wchooseDict = {arg dict, exp = 1, limit = 0;
var keyList, probs; var keyList, probs;
keyList = dict.keys.asList.sort({arg a, b; a.asString < b.asString}); keyList = dict.keys.asList.sort({arg a, b; a.asString < b.asString});
@ -116,7 +116,7 @@ initModeState = {
}; };
advanceMode = {arg lastModeState, lastCadenceState; advanceMode = {arg lastModeState, lastCadenceState;
var frSet, curModeState, curRoots, lastRoots, lastCadenceRoot, changeCount; var curModeState, curRoots, lastRoots, lastCadenceRoot, changeCount;
curModeState = lastModeState.deepCopy; curModeState = lastModeState.deepCopy;
curRoots = collectRoots.value(curModeState); curRoots = collectRoots.value(curModeState);
@ -156,9 +156,7 @@ advanceMode = {arg lastModeState, lastCadenceState;
if(curModeState.includesKey(new), { if(curModeState.includesKey(new), {
//bump if it gets chosen again //bump if it gets chosen again
curModeState[new][\count] = curModeState[new][\count] + 1; curModeState[new][\count] = curModeState[new][\count] + 1;
//"ran0".postln;
if((curModeState[new][\count] >= 20), { if((curModeState[new][\count] >= 20), {
//"ran1".postln;
curModeState[new][\root] = [rootSel, curModeState[rootSel][\mode]] curModeState[new][\root] = [rootSel, curModeState[rootSel][\mode]]
}); });
}, { }, {
@ -167,7 +165,6 @@ advanceMode = {arg lastModeState, lastCadenceState;
old = frNearestInList.value([new, rootSel], curModeState); old = frNearestInList.value([new, rootSel], curModeState);
if(curModeState[old][\count] >= 20, { if(curModeState[old][\count] >= 20, {
var mode, root; var mode, root;
//"ran2".postln;
mode = genMode.value; mode = genMode.value;
root = [rootSel, curModeState[rootSel][\mode]]; root = [rootSel, curModeState[rootSel][\mode]];
curModeState.add(new -> curModeState.add(new ->
@ -196,7 +193,6 @@ genTemporalData = {arg lastTupleState, modeState, cadenceOverride, noParts = 4;
curTupleState = lastTupleState.deepCopy; curTupleState = lastTupleState.deepCopy;
timeToNextEvent = (64 + 50.rand + if(cadence, {50}, {0})).round(16); timeToNextEvent = (64 + 50.rand + if(cadence, {50}, {0})).round(16);
tuple = wchooseDict.value(curTupleState); tuple = wchooseDict.value(curTupleState);
//curTupleState = curTupleState.collect({arg dict; dict[\count] + 1});
if(cadence, {tuple = [1, 1, 1]}); if(cadence, {tuple = [1, 1, 1]});
curTupleState = curTupleState.keysValuesDo({arg key, val; curTupleState = curTupleState.keysValuesDo({arg key, val;
curTupleState[key][\count] = val[\count] + 1}); curTupleState[key][\count] = val[\count] + 1});
@ -211,10 +207,8 @@ 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 =((timeToNextEvent - flourish.size - buffer.size) / if(cadence, {1.25}, {1})).asInteger.rand; 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)}); before = beforeLen.collect({arg i; [0, 1].wchoose([genDensity, 0.25].normalizeSum)});
//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;
if(flourish.sum == 0, {flourish[flourish.size.rand] = 1}); if(flourish.sum == 0, {flourish[flourish.size.rand] = 1});
@ -240,8 +234,7 @@ initPartStates = {
) )
}; };
//this is how a root is chosen this is where we need much more consideration / work //this is how roots are distributed to the parts
//change this to a dictionary
distributeRoots = {arg modeState, lastRoots; distributeRoots = {arg modeState, lastRoots;
var roots; var roots;
roots = modeState.keys.asList.collect({arg fr; modeState[fr][\root]}); roots = modeState.keys.asList.collect({arg fr; modeState[fr][\root]});
@ -250,8 +243,6 @@ distributeRoots = {arg modeState, lastRoots;
roots = [roots[0]] ++ roots[..2].scramble; roots = [roots[0]] ++ roots[..2].scramble;
roots = 4.collect({arg part; roots = 4.collect({arg part;
var root, rootMod, rootFreq, mode; var root, rootMod, rootFreq, mode;
//root = modeState.keys.collect({arg fr; modeState[fr][\root]}).choose;
//if(part == 0, {root = roots[0]});
root = roots[part]; root = roots[part];
rootMod = frDiff.value(root[0], lastRoots[part]); rootMod = frDiff.value(root[0], lastRoots[part]);
rootFreq = 36.midicps * pow(2, [1, 0, 1, 2][part]) * frToFloat.value(root[0]); rootFreq = 36.midicps * pow(2, [1, 0, 1, 2][part]) * frToFloat.value(root[0]);
@ -267,7 +258,7 @@ distributeRoots = {arg modeState, lastRoots;
}; };
genEnsemblePart = {arg partState, modeState, temporalData, roots, part, offset; genEnsemblePart = {arg partState, modeState, temporalData, roots, part, offset;
var trans, root, mults, rootMod, amp, firstChange, cadence, lastInsRef, flutEx, ensData; var trans, root, mults, rootMod, amp, firstChange, cadence, lastInsRef, ensData;
trans = pow(2, [1, 0, 1, 2][partState[\index]]); trans = pow(2, [1, 0, 1, 2][partState[\index]]);
# root, mults, rootMod = roots[part]; # root, mults, rootMod = roots[part];
@ -276,7 +267,6 @@ genEnsemblePart = {arg partState, modeState, temporalData, roots, part, offset;
cadence = if(collectRoots.value(modeState).size == 1, {true}, {false}); cadence = if(collectRoots.value(modeState).size == 1, {true}, {false});
lastInsRef = nil; lastInsRef = nil;
if(offset == 0, {cadence = false}); if(offset == 0, {cadence = false});
flutEx = hdChoose.value(mults, 0.5);
ensData = []; ensData = [];
temporalData.do({arg val, ts; temporalData.do({arg val, ts;
@ -295,7 +285,7 @@ genEnsemblePart = {arg partState, modeState, temporalData, roots, part, offset;
if(change, { if(change, {
var mult, multWeights, freq, rootFreq, insRef; var mult, multWeights, freq, rootFreq, insRef;
//this is is not working correctly //check that this is working correctly
multWeights = mults.collect({arg fr; multWeights = mults.collect({arg fr;
var comp = frCollapse.value(frAdd.value(root, fr)); var comp = frCollapse.value(frAdd.value(root, fr));
if(modeState.keys.includes(comp), {3}, {1}) * pow(partState[\multCounts][fr], 1); if(modeState.keys.includes(comp), {3}, {1}) * pow(partState[\multCounts][fr], 1);
@ -328,7 +318,7 @@ genEnsemblePart = {arg partState, modeState, temporalData, roots, part, offset;
mode = mode ++ mode.collect({arg fr; [frAdd.value(fr[0], [[2], [1]]), fr[1], fr[2]]}); mode = mode ++ mode.collect({arg fr; [frAdd.value(fr[0], [[2], [1]]), fr[1], fr[2]]});
mode = mode ++ mode.collect({arg fr; [frAdd.value(fr[0], [[4], [1]]), fr[1], fr[2]]}); mode = mode ++ mode.collect({arg fr; [frAdd.value(fr[0], [[4], [1]]), fr[1], fr[2]]});
continue = true; continue = true;
//something is still not right here //check that this is working correctly
while({continue}, { while({continue}, {
# freqRatio, root, mult = mode[partState[\noteCount] % 15]; # freqRatio, root, mult = mode[partState[\noteCount] % 15];
freq = 36.midicps * trans * frToFloat.value(frAdd.value([[1], [1]], freqRatio)); freq = 36.midicps * trans * frToFloat.value(frAdd.value([[1], [1]], freqRatio));
@ -342,7 +332,6 @@ genEnsemblePart = {arg partState, modeState, temporalData, roots, part, offset;
}); });
if((partState[\index] == 0) && cadence, { if((partState[\index] == 0) && cadence, {
insRef = if(firstChange.not, {1}, {nil}); insRef = if(firstChange.not, {1}, {nil});
//freq = 36.midicps * trans * 2 * frToFloat.value(frAdd.value(root, flutEx));
}); });
rootFreq = 36.midicps * trans * frToFloat.value(root); rootFreq = 36.midicps * trans * frToFloat.value(root);
@ -380,6 +369,7 @@ genAccompPart = {arg modeState, temporalData, offset, trans, part, register;
accompData accompData
}; };
//~~~~~~~~~~~~GENERATE ELECTRONIC BASS~~~~~~~~~~~~ //~~~~~~~~~~~~GENERATE ELECTRONIC BASS~~~~~~~~~~~~
genBassPart = {arg root, ampCurve, hi; genBassPart = {arg root, ampCurve, hi;
var freq; var freq;
@ -389,6 +379,7 @@ genBassPart = {arg root, ampCurve, hi;
ampCurve.collect({arg sec, iter; [freq, sec[1]]}) ampCurve.collect({arg sec, iter; [freq, sec[1]]})
}; };
//~~~~~~~~~~~~GENERATE AMP CURVES~~~~~~~~~~~~ //~~~~~~~~~~~~GENERATE AMP CURVES~~~~~~~~~~~~
genAmpCurve = {arg temporalData1, temporalData2, offset1, offset2, type; genAmpCurve = {arg temporalData1, temporalData2, offset1, offset2, type;
var firsts1, firsts2, delay, attack, decay, release, min, max, env; var firsts1, firsts2, delay, attack, decay, release, min, max, env;
@ -420,7 +411,6 @@ genAmpCurve = {arg temporalData1, temporalData2, offset1, offset2, type;
{2} {1} ; {2} {1} ;
env = Env.dadsr(delay, attack, decay, 0.25, release, curve: \cub).range(min, max); env = Env.dadsr(delay, attack, decay, 0.25, release, curve: \cub).range(min, max);
((delay + attack + decay + release) / 1).asInteger.collect({arg iter; [env.at(iter * 1), offset1 + (iter * 1)]}) ((delay + attack + decay + release) / 1).asInteger.collect({arg iter; [env.at(iter * 1), offset1 + (iter * 1)]})
}; };
@ -506,9 +496,8 @@ genAmpCurve = {arg temporalData1, temporalData2, offset1, offset2, type;
sectionData.add(((curLen - temporalData[0].size) / 4).asInteger-> sectionData.add(((curLen - temporalData[0].size) / 4).asInteger->
sectionData[((curLen - temporalData[0].size) / 4).asInteger].put(5, true)); sectionData[((curLen - temporalData[0].size) / 4).asInteger].put(5, true));
(subsectionCount - 1).do({arg subsectionIndex; (subsectionCount - 1).do({arg subsectionIndex;
sectionNavDict.add([sectionCount, subsectionIndex + 1]->[sectionNavDict[[sectionCount, subsectionIndex + 1]].postln[0], subsectionCount - 1]); sectionNavDict.add([sectionCount, subsectionIndex + 1]->[sectionNavDict[[sectionCount, subsectionIndex + 1]][0], subsectionCount - 1]);
}); });
//sectionNavDict.add([sectionCount, subsectionCount]->[(curLen / 16 + 1).asInteger, subsectionCount]);
# sectionCount, subsectionCount = [sectionCount + 1, 1]; # sectionCount, subsectionCount = [sectionCount + 1, 1];
# lastCadenceTemporalData, lastCadenceState, lastSectionPoint = [temporalData, modeState, curLen]; # lastCadenceTemporalData, lastCadenceState, lastSectionPoint = [temporalData, modeState, curLen];
cadence = true; cadence = true;
@ -525,7 +514,5 @@ genAmpCurve = {arg temporalData1, temporalData2, offset1, offset2, type;
[ensData, accompData, bassData, ampData, sectionData, sectionNavDict] [ensData, accompData, bassData, ampData, sectionData, sectionNavDict]
}; };
//~genMusicData.value(100)
) )

@ -14,10 +14,6 @@ var formatPatternData;
~defineSynths = {arg server, preampBusses, accompBusses, postampBusses; ~defineSynths = {arg server, preampBusses, accompBusses, postampBusses;
var sdPlayer, sdTransport, sdClick, sdAmpCurve, sdEns, sdAccomp, sdClip, sdBass, sdDiskOut, allSds; var sdPlayer, sdTransport, sdClick, sdAmpCurve, sdEns, sdAccomp, sdClip, sdBass, sdDiskOut, allSds;
//~postampBusses = 7.collect({Bus.audio(server, 1)});
//~preampBusses = 3.collect({Bus.audio(server, 1)});
//~accompBusses = 4.collect({Bus.audio(server, 1)});
sdPlayer = SynthDef(\masterPlayerControl_ ++ ~hash, { sdPlayer = SynthDef(\masterPlayerControl_ ++ ~hash, {
var sigs, sigsPanned, masterSig, imp; var sigs, sigsPanned, masterSig, imp;
@ -97,6 +93,8 @@ formatPatternData = {arg musData, measureLen;
//~~~~~~~~~~~~GENERATE PATTERNS~~~~~~~~~~~~ //~~~~~~~~~~~~GENERATE PATTERNS~~~~~~~~~~~~
//this generates patterns grouped by measures except for bass data and amp curve data which are much higher resolution
//these are used to make playable patterns
~genPatterns = {arg ensData, accompData, bassData, ampData, sectionData, preampBusses, accompBusses, postampBusses; ~genPatterns = {arg ensData, accompData, bassData, ampData, sectionData, preampBusses, accompBusses, postampBusses;
var measureLen, ensDataFormatted, accompDataFormatted, bassDataFormatted, ampDataFormatted, var measureLen, ensDataFormatted, accompDataFormatted, bassDataFormatted, ampDataFormatted,
dUnit, section, subsection, patterns; dUnit, section, subsection, patterns;
@ -108,8 +106,6 @@ 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);
//ampDataFormatted = formatPatternData.value([ampData, ampData, ampData, ampData], measureLen);
dUnit = 8.reciprocal; dUnit = 8.reciprocal;
patterns = measureLen.collect({arg measure; patterns = measureLen.collect({arg measure;
@ -118,6 +114,7 @@ formatPatternData = {arg musData, measureLen;
subsection = sectionData[measure * 4][3]; subsection = sectionData[measure * 4][3];
}); });
Ppar( Ppar(
//check how amplitude is being handled
ensDataFormatted[measure].collect({arg musData, m; ensDataFormatted[measure].collect({arg musData, m;
Pbind( Pbind(
\instrument, \ens_ ++ ~hash, \instrument, \ens_ ++ ~hash,
@ -126,11 +123,11 @@ formatPatternData = {arg musData, measureLen;
\sustain, Pseq(musData[2] * dUnit), \sustain, Pseq(musData[2] * dUnit),
\amp, [0.5, 0.3, 0.3, 0.3][m], \amp, [0.5, 0.3, 0.3, 0.3][m],
//\amp, Pseq(musData[2].collect({arg item; [0, 0.25, 0.5, 0.75][item]}) * [1, 0.5, 0.25, 0.1][m] * 16); //\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})}))
\ampBus, preampBusses[0].index, \ampBus, preampBusses[0].index,
\bus, postampBusses[m].index \bus, postampBusses[m].index
) )
}) ++ }) ++
//check how amplitude and attack are being handled
accompDataFormatted[measure].collect({arg musData, m; accompDataFormatted[measure].collect({arg musData, m;
Pbind( Pbind(
\instrument, \accomp_ ++ ~hash, \instrument, \accomp_ ++ ~hash,
@ -164,6 +161,8 @@ formatPatternData = {arg musData, measureLen;
[patterns, bassData, ampData] [patterns, bassData, ampData]
}; };
//this is a playable pattern based on start measure
~genPlayablePatterns = {arg startMeasure, patterns, preampBusses, accompBusses, postampBusses; ~genPlayablePatterns = {arg startMeasure, patterns, preampBusses, accompBusses, postampBusses;
Ppar( Ppar(
[Pseq(patterns[0][startMeasure..], 1)] ++ [Pseq(patterns[0][startMeasure..], 1)] ++
@ -187,13 +186,16 @@ formatPatternData = {arg musData, measureLen;
}; };
~bounceAudio = { //~~~~~~~~~~~~BOUNCE AUDIO~~~~~~~~~~~~
var basePath, server, buffers, recDur, //this bounces the audio for use in another DAW or for practice
~bounceAudio = {arg seed;
var trackNames, basePath, server, buffers, recDur,
preampBusses, nextNode, accompBusses, postampBusses, preampBusses, nextNode, accompBusses, postampBusses,
synths, prePatterns, playablePatterns, score; synths, prePatterns, playablePatterns, score;
//dir = thisProcess.nowExecutingPath.dirname; trackNames = ["part_start", "part_III", "part_II", "part_I", "accomp_I", "accomp_II", "click"];
basePath = ~dir +/+ ".." +/+ "audio";
basePath = ~dir +/+ ".." +/+ "audio" +/+ "seed_" ++ seed;
basePath.mkdir; basePath.mkdir;
server = Server(\nrt_ ++ ~hash, server = Server(\nrt_ ++ ~hash,
@ -203,7 +205,7 @@ formatPatternData = {arg musData, measureLen;
); );
# preampBusses, accompBusses, postampBusses = ~allocBusses.value(s); # preampBusses, accompBusses, postampBusses = ~allocBusses.value(s);
postampBusses = 7.collect({arg index; Bus.new(rate: 'audio', index: index.postln, numChannels: 1, server: server)}); postampBusses = 7.collect({arg index; Bus.new(rate: 'audio', index: index, numChannels: 1, server: server)});
synths = ~defineSynths.value(s, preampBusses, accompBusses, postampBusses); synths = ~defineSynths.value(s, preampBusses, accompBusses, postampBusses);
prePatterns = ~genPatterns.value(~musicData[0], ~musicData[1], ~musicData[2], ~musicData[3], ~sectionData, prePatterns = ~genPatterns.value(~musicData[0], ~musicData[1], ~musicData[2], ~musicData[3], ~sectionData,
@ -212,28 +214,20 @@ formatPatternData = {arg musData, measureLen;
playablePatterns = ~genPlayablePatterns.value(0, prePatterns, preampBusses, accompBusses, postampBusses); playablePatterns = ~genPlayablePatterns.value(0, prePatterns, preampBusses, accompBusses, postampBusses);
recDur = (prePatterns[2][0].size / 8) + 10; recDur = (prePatterns[2][0].size / 8) + 10;
score = playablePatterns.asScore(duration: recDur, timeOffset: 0.001); score = playablePatterns.asScore(duration: recDur, timeOffset: 0.001);
nextNode = score.score.slice(nil, 1).select({arg msg; msg[0] == 9}).slice(nil, 2).maxItem + 1; nextNode = score.score.slice(nil, 1).select({arg msg; msg[0] == 9}).slice(nil, 2).maxItem + 1;
score.score.last.postln;
nextNode.postln;
synths.do({arg synth; score.add([0.0, [\d_recv, synth.asBytes]])}); synths.do({arg synth; score.add([0.0, [\d_recv, synth.asBytes]])});
4.collect({arg p; 4.collect({arg p;
//Synth.new(\clip_ ++ ~hash, [\bin, accompBusses[p].index, \bus, postampBusses[5].index])
score.add([0.0, [\s_new, \clip_ ++ ~hash, nextNode, 1, 1, \bin, accompBusses[p].index, \bus, postampBusses[5].index]]); score.add([0.0, [\s_new, \clip_ ++ ~hash, nextNode, 1, 1, \bin, accompBusses[p].index, \bus, postampBusses[5].index]]);
nextNode = nextNode + 1; nextNode = nextNode + 1;
}); });
buffers = 7.do({arg track; buffers = 7.do({arg track;
score.add([0.0, [\b_alloc, track, 65536, 1]]); score.add([0.0, [\b_alloc, track, 65536, 1]]);
score.add([0.0, [\b_write, track, basePath +/+ "test_" ++ track ++ ".wav".standardizePath, "WAV", "int16", 0, 0, 1]]); score.add([0.0, [\b_write, track, basePath +/+ "tkam_" ++ trackNames[track] ++ ".wav".standardizePath, "WAV", "int16", 0, 0, 1]]);
score.add([0.0, [\s_new, \disk_out_ ++ ~hash, nextNode, 1, 1, \bufnum, track, \inbus, track]]); score.add([0.0, [\s_new, \disk_out_ ++ ~hash, nextNode, 1, 1, \bufnum, track, \inbus, track]]);
score.add([recDur, [\n_free, nextNode]]); score.add([recDur, [\n_free, nextNode]]);
score.add([recDur, [\b_close, track]]); score.add([recDur, [\b_close, track]]);
score.add([recDur, [\b_free, track]]); score.add([recDur, [\b_free, track]]);
@ -243,7 +237,7 @@ formatPatternData = {arg musData, measureLen;
score.sort; score.sort;
score.recordNRT( score.recordNRT(
outputFilePath: basePath +/+ "test_all" ++ ".wav".standardizePath, outputFilePath: basePath +/+ "tkam_all" ++ ".wav".standardizePath,
sampleRate: 44100, sampleRate: 44100,
headerFormat: "WAV", headerFormat: "WAV",
sampleFormat: "int16", sampleFormat: "int16",
@ -253,7 +247,4 @@ formatPatternData = {arg musData, measureLen;
server.remove; server.remove;
} }
) )
//~bounceAudio.value

@ -28,7 +28,7 @@ formatMusicData = {arg rawMusicData;
musicData musicData
}; };
// constants (spelling dictionaru note names and octaves) // constants (spelling dictionary note names and octaves)
spellingDict = Dictionary.with(* spellingDict = Dictionary.with(*
[ [
\major -> Dictionary.with(* \major -> Dictionary.with(*
@ -67,7 +67,6 @@ lyFinalizeMusic = {arg lyStr, part, name, nameShort, nameMidi, clef;
"<<\n\n{ " + "<<\n\n{ " +
"\n\\set Score.markFormatter = #format-mark-box-numbers " + "\n\\set Score.markFormatter = #format-mark-box-numbers " +
"\\tempo 2 = 60\n" + "\\tempo 2 = 60\n" +
//if(part != 0, {"\\override Staff.TimeSignature #'stencil = ##f"}, {""}) +
"\\numericTimeSignature \\time 2/2\n" + "\\numericTimeSignature \\time 2/2\n" +
"\\clef " ++ clef ++ "\n" ++ lyStr ++ "\\clef " ++ clef ++ "\n" ++ lyStr ++
" }>> \\bar \"|.\" \n} \n\n>>" ++ " }>> \\bar \"|.\" \n} \n\n>>" ++
@ -114,7 +113,6 @@ lyRelMark = {arg root, lastRoot, section, subsection;
lyRelMarkNote.value(root, lastRoot, 1, "bass") ++ "^\\markup{\\large \\raise #2 \"III\"}" ++ lyRelMarkNote.value(root, lastRoot, 1, "bass") ++ "^\\markup{\\large \\raise #2 \"III\"}" ++
//lyHBracket.value(root[part][4], 8.5, 0, 1, 1, 1)
lyHBracket.value(lyFreqRatio.value(root[2][4][2], nil, true, 0, false), 8.5, 1, 2, 1, 1) ++ lyHBracket.value(lyFreqRatio.value(root[2][4][2], nil, true, 0, false), 8.5, 1, 2, 1, 1) ++
lyHBracket.value(lyFreqRatio.value(root[2][4][1], nil, true, 0, false), 5.5, 3, 3, 0, 0) ++ lyHBracket.value(lyFreqRatio.value(root[2][4][1], nil, true, 0, false), 5.5, 3, 3, 0, 0) ++
@ -222,12 +220,16 @@ consolidateNotes = {arg lyStr, part;
res.replace("<MARKUP", "").replace("MARKUP>", ""); res.replace("<MARKUP", "").replace("MARKUP>", "");
}; };
~transcribe = {arg rawMusicData, sectionData; ~transcribe = {arg rawMusicData, sectionData, seed;
var dir, basePath, musicData, insData, insNames, insNamesShort, insMidi, insClef; var basePath, scoreFile, musicData, insData, insNames, insNamesShort, insMidi, insClef;
//dir = thisProcess.nowExecutingPath.dirname; basePath = ~dir +/+ ".." +/+ "lilypond" +/+ "seed_" ++ seed;
basePath = ~dir +/+ ".." +/+ "lilypond";
basePath.mkdir; basePath.mkdir;
(basePath +/+ "includes").mkdir;
scoreFile = File(basePath +/+ "tkam_score.ly".standardizePath,"w");
scoreFile.write(File.readAllString(basePath +/+ ".." +/+ "template" +/+ "tkam_score_template.ly").replace("seed: xxx", "seed: " ++ seed));
scoreFile.close;
musicData = formatMusicData.value(rawMusicData); musicData = formatMusicData.value(rawMusicData);
@ -306,7 +308,6 @@ consolidateNotes = {arg lyStr, part;
lyStr = lyFinalizeMusic.value(lyStr, p, insNames[p], insNamesShort[p], insMidi[p], insClef[p]); lyStr = lyFinalizeMusic.value(lyStr, p, insNames[p], insNamesShort[p], insMidi[p], insClef[p]);
//consolidate notes and rests //consolidate notes and rests
("------------" ++ p).postln;
lyStr = consolidateNotes.value(lyStr, p); lyStr = consolidateNotes.value(lyStr, p);
//write file //write file
@ -315,8 +316,6 @@ consolidateNotes = {arg lyStr, part;
}); });
}; };
//~hdTranscribe.value(~scoreData, ~sectionData);
//~~~~~~~~~~~~GENERATE SCORE DATA~~~~~~~~~~~~ //~~~~~~~~~~~~GENERATE SCORE DATA~~~~~~~~~~~~
~genScoreData = {arg ensData; ~genScoreData = {arg ensData;

Loading…
Cancel
Save