From 805ed9d5def9307bd34ce4cde67de227589325ac Mon Sep 17 00:00:00 2001 From: mwinter Date: Thu, 14 Jan 2021 00:42:16 +0100 Subject: [PATCH] mixer save func basically working --- mixer_settings/settings | 7 ++++ supercollider/tkam_gui.scd | 34 +++++++++++++------ supercollider/tkam_musical_data_generator.scd | 2 +- supercollider/tkam_readme.scd | 2 +- 4 files changed, 33 insertions(+), 12 deletions(-) create mode 100644 mixer_settings/settings diff --git a/mixer_settings/settings b/mixer_settings/settings new file mode 100644 index 0000000..74d0382 --- /dev/null +++ b/mixer_settings/settings @@ -0,0 +1,7 @@ +{ +"master_volume": 0.33644859813084, +"master_mute": 0, +"track_volumes": [0.5849582172702,0.37883008356546,0.46518105849582,0.67688022284123,0.29805013927577,0.63231197771588,0.59888579387187], +"track_mutes": [0,0,0,0,0,0,0], +"track_pans": [0.5,0.5,0.5,0.5,0.5,0.5,0.5] +} \ No newline at end of file diff --git a/supercollider/tkam_gui.scd b/supercollider/tkam_gui.scd index 795ca00..d55780f 100644 --- a/supercollider/tkam_gui.scd +++ b/supercollider/tkam_gui.scd @@ -242,7 +242,7 @@ masterView = {arg win, preampBusses, accompBusses, postampBusses; faderView = {arg win; - var view, masterIndicators, trackIndicators, master, tracks, openButton, saveButton; + var view, masterIndicators, trackIndicators, master, tracks, openButton, basePath, saveButton; var partAbbr = ["*", "III", "II", "I", "accomp_I", "accomp_II", "click"]; var trackNames = ["*", "III", "II", "I", "accomp_I", "accomp_II", "click"]; var partVols, partMutes, partPans; @@ -264,23 +264,37 @@ faderView = {arg win; buildTrackFader.value(view, trackNames[part], part); } ! 7; + basePath = ~dir +/+ ".." +/+ "mixer_settings"; + openButton = Button(view).states_([["open", Color.black]]).action_({ Dialog.openPanel({ arg path; - path.postln; - },{ - "cancelled".postln; - }); + var settings; + settings = File.readAllString(path).parseJSON; + master[1].valueAction = settings["master_volume"]; + master[2].valueAction = settings["master_pan"]; + settings["track_volumes"].do({arg val, v; tracks[v][1].valueAction = val}); + settings["track_mutes"].do({arg val, v; tracks[v][2].valueAction = val}); + settings["track_pans"].do({arg val, v; tracks[v][3].valueAction = val}); + },{}, false, basePath); }); saveButton = Button(view).states_([["save", Color.black]]).action_({ Dialog.savePanel({ arg path; - path.postln; - },{ - "cancelled".postln; - }); + var settings, file; + settings = "{\n"; + settings = settings ++ "\"master_volume\": " ++ master[1].value ++ ",\n"; + settings = settings ++ "\"master_mute\": " ++ master[2].value ++ ",\n"; + settings = settings ++ "\"track_volumes\": [" ++ tracks.collect({arg track; track[1].value}).join(",") ++ "],\n"; + settings = settings ++ "\"track_mutes\": [" ++ tracks.collect({arg track; track[2].value}).join(",") ++ "],\n"; + settings = settings ++ "\"track_pans\": [" ++ tracks.collect({arg track; track[3].value}).join(",") ++ "]\n"; + settings = settings ++ "}"; + file = File(path, "w"); + file.write(settings); + file.close; + },{}, basePath); }); - view.layout_(HLayout(HLayout(master[0], nil, *tracks.slice(nil, 0)), VLayout(nil, openButton, saveButton))) + view.layout_(HLayout(HLayout(master[0], nil, *tracks.slice(nil, 0)), VLayout(nil, saveButton, openButton))) }; diff --git a/supercollider/tkam_musical_data_generator.scd b/supercollider/tkam_musical_data_generator.scd index da64e24..0e23276 100644 --- a/supercollider/tkam_musical_data_generator.scd +++ b/supercollider/tkam_musical_data_generator.scd @@ -429,7 +429,7 @@ genAmpCurve = {arg temporalData1, temporalData2, offset1, offset2, type; thisThread.randSeed = seed.postln; - # totalDur, section1Dur, dUnit, curLen, cadence, ultimate = [2 * 60, 1 * 60, 8.reciprocal, 0, false, false]; + # totalDur, section1Dur, dUnit, curLen, cadence, ultimate = [6 * 60, 2 * 60, 8.reciprocal, 0, false, false]; # totalLen, section1Len = [(totalDur / dUnit).round(16), (section1Dur / dUnit).round(16)]; # modeState, temporalState, partStates = [initModeState.value, initTemporalState.value, initPartStates.value]; # lastCadenceTemporalData, lastCadenceState, lastSectionPoint = [nil, modeState.deepCopy, 0]; diff --git a/supercollider/tkam_readme.scd b/supercollider/tkam_readme.scd index fb0c5d4..d32beb8 100644 --- a/supercollider/tkam_readme.scd +++ b/supercollider/tkam_readme.scd @@ -12,7 +12,7 @@ Tempo change will only go into effect once "set tempo" button is pressed. Setting the address:port will create a pipe to recieve a message to advance the subsection externally with an OSC message '/nextSubsection. This could be used to set up a foot pedal / controller for the guitarist to advance the subsections manually. -The default seed given in the application and reseeded when the "reset seed" button is pressed will generate the default music and score (as provided). Changing the seed will generate a new version with that seed once the "generate" button is pressed. After the new version is generated, new Lilypond files can be generated by pressing the "transcribe" button. This will create a cicc_score.ly file in a folder labeled "seed_[number]" which can be rendered by Lilypond. Note that the file must be rendered from that location as it dependes in files in that folder and the "includes" subfolder. +The default seed given in the application and reseeded when the "reset seed" button is pressed will generate the default music and score (as provided). Changing the seed will generate a new version with that seed once the "generate" button is pressed. After the new version is generated, new Lilypond files can be generated by pressing the "transcribe" button. This will create a tkam_score.ly file in a folder labeled "seed_[number]" which can be rendered by Lilypond. Note that the file must be rendered from that location as it dependes on files in that folder and the "includes" subfolder. ~~~~mixer tab