From 7c5f26b15e1ee38b06de2ecb5c6d3ace6f14d33b Mon Sep 17 00:00:00 2001 From: mwinter Date: Sun, 2 Jul 2023 14:23:12 +0200 Subject: [PATCH] each ledger now has its own resources folder, which should make pruning easier - needs testing to ensure nothing is broken --- lilypond/includes/part_I.ly | 12 +- lilypond/includes/part_II.ly | 12 +- lilypond/includes/part_III.ly | 12 +- lilypond/includes/part_IV.ly | 12 +- lilypond/score_template.pdf | Bin 758187 -> 782343 bytes open_stage_control/modules/custom_module.js | 10 +- open_stage_control/seeds_and_ledgers_gui.json | 22 +- resources/314491/314491_gui_session.json | 1400 ----------------- resources/314491/314491_gui_state.state | 177 --- resources/314s49e1/lilypond/part_I.ly | 56 - resources/314s49e1/lilypond/part_II.ly | 56 - resources/314s49e1/lilypond/part_III.ly | 56 - resources/314s49e1/lilypond/part_IV.ly | 56 - resources/430a1ec1/430a1ec1_code.scd | 1058 ------------- resources/430a1ec1/430a1ec1_mus_model.json | 55 - resources/445b7057/445b7057_mus_model.json | 97 -- resources/46b6952a/46b6952a_mus_model.json | 57 - resources/475efb26/475efb26_mus_model.json | 93 -- resources/4c01589b/lilypond/part_I.ly | 40 - resources/4c01589b/lilypond/part_II.ly | 40 - resources/4c01589b/lilypond/part_III.ly | 40 - resources/4c01589b/lilypond/part_IV.ly | 40 - resources/4f65a9b5/4f65a9b5_code.scd | 1046 ------------ resources/4f65a9b5/4f65a9b5_mus_model.json | 46 - resources/52af48e5/52af48e5_code.scd | 1046 ------------ resources/52af48e5/52af48e5_mus_model.json | 46 - resources/535cc132/535cc132_mus_model.json | 91 -- resources/53ad554b/53ad554b_mus_model.json | 86 - resources/57a598e2/57a598e2_code.scd | 1058 ------------- resources/57a598e2/57a598e2_mus_model.json | 0 resources/5e947063/lilypond/part_I.ly | 32 - resources/5e947063/lilypond/part_II.ly | 32 - resources/5e947063/lilypond/part_III.ly | 32 - resources/5e947063/lilypond/part_IV.ly | 32 - resources/6132dd73/6132dd73_code.scd | 1055 ------------- resources/6132dd73/6132dd73_mus_model.json | 68 - resources/6232ff77/6232ff77_code.scd | 1058 ------------- resources/6232ff77/6232ff77_mus_model.json | 85 - resources/628d5c8b/lilypond/part_I.ly | 24 - resources/628d5c8b/lilypond/part_II.ly | 24 - resources/628d5c8b/lilypond/part_III.ly | 24 - resources/628d5c8b/lilypond/part_IV.ly | 24 - resources/640eeed3/lilypond/part_I.ly | 14 - resources/640eeed3/lilypond/part_II.ly | 14 - resources/640eeed3/lilypond/part_III.ly | 14 - resources/640eeed3/lilypond/part_IV.ly | 14 - resources/64b535ef/64b535ef_code.scd | 1058 ------------- resources/652c77ba/652c77ba_code.scd | 1058 ------------- resources/652c77ba/652c77ba_mus_model.json | 97 -- resources/6881b4ac/6881b4ac_mus_model.json | 98 -- resources/6abf27d4/lilypond/part_I.ly | 110 -- resources/6abf27d4/lilypond/part_II.ly | 110 -- resources/6abf27d4/lilypond/part_III.ly | 110 -- resources/6abf27d4/lilypond/part_IV.ly | 110 -- resources/6d743c5c/lilypond/part_I.ly | 18 - resources/6d743c5c/lilypond/part_II.ly | 18 - resources/6d743c5c/lilypond/part_III.ly | 18 - resources/6d743c5c/lilypond/part_IV.ly | 18 - resources/720a7ee4/720a7ee4_code.scd | 1046 ------------ resources/720a7ee4/720a7ee4_mus_model.json | 60 - resources/72dbaa4c/72dbaa4c_mus_model.json | 46 - resources/72e6131c/72e6131c_code.scd | 1047 ------------ resources/72e6131c/72e6131c_mus_model.json | 89 -- resources/730ad6b9/730ad6b9_code.scd | 1046 ------------ resources/74d9b3e1/74d9b3e1_code.scd | 1033 ------------ resources/74d9b3e1/74d9b3e1_mus_model.json | 0 resources/75837171/75837171_code.scd | 1046 ------------ resources/75837171/75837171_mus_model.json | 73 - resources/78f2229c/78f2229c_code.scd | 1046 ------------ resources/78f2229c/78f2229c_mus_model.json | 73 - resources/7ac10d34/lilypond/part_I.ly | 28 - resources/7ac10d34/lilypond/part_II.ly | 28 - resources/7ac10d34/lilypond/part_III.ly | 28 - resources/7ac10d34/lilypond/part_IV.ly | 28 - resources/7bda0503/7bda0503_code.scd | 1056 ------------- resources/7bda0503/7bda0503_mus_model.json | 65 - resources/7c1ab0e0/7c1ab0e0_code.scd | 1046 ------------ resources/7c1ab0e0/7c1ab0e0_mus_model.json | 51 - resources/7c7ba1aa/7c7ba1aa_code.scd | 1053 ------------- resources/7c7ba1aa/7c7ba1aa_mus_model.json | 61 - resources/7cc3121d/7cc3121d_code.scd | 1058 ------------- resources/7cc3121d/7cc3121d_mus_model.json | 91 -- resources/7e170ef8/lilypond/part_I.ly | 36 - resources/7e170ef8/lilypond/part_II.ly | 36 - resources/7e170ef8/lilypond/part_III.ly | 36 - resources/7e170ef8/lilypond/part_IV.ly | 36 - resources/7e42825a/7e42825a_code.scd | 1033 ------------ resources/7e42825a/7e42825a_mus_model.json | 0 resources/7ebbb471/7ebbb471_code.scd | 1058 ------------- resources/7ebbb471/7ebbb471_mus_model.json | 60 - resources/7ebbb471/lilypond/part_I.ly | 24 - resources/7ebbb471/lilypond/part_II.ly | 24 - resources/7ebbb471/lilypond/part_III.ly | 24 - resources/7ebbb471/lilypond/part_IV.ly | 24 - resources/piece_ledger.json_bak_bak | 17 - .../314s49e1/314s49e1_code.scd | 0 .../314s49e1/314s49e1_mus_model.json | 0 .../46a0e6a8/46a0e6a8_code.scd | 0 .../46a0e6a8/46a0e6a8_mus_model.json | 0 .../4c01589b/4c01589b_code.scd | 0 .../4c01589b/4c01589b_gui_state.json | 0 .../4c01589b/4c01589b_mus_model.json | 0 .../4cf4476d/4cf4476d_code.scd | 0 .../4cf4476d/4cf4476d_mus_model.json | 0 .../55930f4d/55930f4d_code.scd | 0 .../55930f4d/55930f4d_mus_model.json | 0 .../5cf1e9ab/5cf1e9ab_code.scd | 0 .../5cf1e9ab/5cf1e9ab_mus_model.json | 0 .../5e947063/5e947063_code.scd | 0 .../5e947063/5e947063_mus_model.json | 0 .../628d5c8b/628d5c8b_code.scd | 0 .../628d5c8b/628d5c8b_mus_model.json | 0 .../62b894e8/62b894e8_code.scd | 0 .../62b894e8/62b894e8_mus_model.json | 0 .../640eeed3/640eeed3_code.scd | 0 .../640eeed3/640eeed3_mus_model.json | 0 .../6506161e/6506161e_code.scd | 0 .../6506161e/6506161e_mus_model.json | 0 .../69a72421/69a72421_code.scd | 0 .../69a72421/69a72421_mus_model.json | 0 .../6abf27d4/6abf27d4_code.scd | 0 .../6abf27d4/6abf27d4_mus_model.json | 0 .../6be1486c/6be1486c_code.scd | 0 .../6be1486c/6be1486c_mus_model.json | 0 .../7000ae3e/7000ae3e_code.scd | 0 .../7000ae3e/7000ae3e_mus_model.json | 0 .../7aa8c429/7aa8c429_code.scd | 0 .../7aa8c429/7aa8c429_mus_model.json | 0 .../7ac10d34/7ac10d34_code.scd | 0 .../7ac10d34/7ac10d34_gui_state.json | 0 .../7ac10d34/7ac10d34_mus_model.json | 0 .../7e170ef8/7e170ef8_code.scd | 0 .../7e170ef8/7e170ef8_gui_state.json | 0 .../7e170ef8/7e170ef8_mus_model.json | 0 .../7ead41c3/7ead41c3_code.scd | 0 .../7ead41c3/7ead41c3_mus_model.json | 0 .../314s49e1/314s49e1_code.scd} | 0 .../314s49e1/314s49e1_mus_model.json} | 9 +- .../449aeaa6/449aeaa6_code.scd | 0 .../449aeaa6/449aeaa6_mus_model.json | 0 .../46210507/46210507_code.scd | 0 .../46210507/46210507_mus_model.json | 0 .../4b96f62d/4b96f62d_code.scd | 0 .../4b96f62d/4b96f62d_mus_model.json | 0 .../50fec831/50fec831_code.scd | 0 .../50fec831/50fec831_mus_model.json | 0 .../5267b235/5267b235_code.scd | 0 .../5267b235/5267b235_mus_model.json | 0 .../5625a95a/5625a95a_code.scd | 0 .../5625a95a/5625a95a_mus_model.json | 0 .../628d5c8b/628d5c8b_code.scd} | 542 ++----- .../628d5c8b/628d5c8b_mus_model.json | 56 + .../6409252e/6409252e_code.scd | 0 .../6409252e/6409252e_mus_model.json | 0 .../6a3f7c7c/6a3f7c7c_code.scd | 0 .../6a3f7c7c/6a3f7c7c_mus_model.json | 0 .../6abf27d4/6abf27d4_code.scd} | 439 ++---- .../6abf27d4/6abf27d4_mus_model.json | 93 ++ .../6d0c2f19/6d0c2f19_code.scd | 0 .../6d0c2f19/6d0c2f19_mus_model.json | 0 .../6d743c5c/6d743c5c_code.scd | 0 .../6d743c5c/6d743c5c_mus_model.json | 0 .../6f1305ed/6f1305ed_code.scd | 0 .../6f1305ed/6f1305ed_mus_model.json | 0 .../703e109b/703e109b_code.scd | 0 .../703e109b/703e109b_mus_model.json | 0 .../74faf83f/74faf83f_code.scd | 0 .../74faf83f/74faf83f_mus_model.json | 0 .../7ac10d34/7ac10d34_code.scd} | 0 .../7ac10d34/7ac10d34_gui_state.json} | 2 +- .../7ac10d34/7ac10d34_mus_model.json | 59 + .../7bf874ce/7bf874ce_code.scd | 0 .../7bf874ce/7bf874ce_mus_model.json | 0 .../7c7a96a2/7c7a96a2_code.scd | 0 .../7c7a96a2/7c7a96a2_mus_model.json | 0 .../7c8bc6df/7c8bc6df_code.scd | 0 .../7c8bc6df/7c8bc6df_mus_model.json | 0 .../7e170ef8/7e170ef8_code.scd | 718 +++++++++ .../7e170ef8/7e170ef8_gui_state.json | 1359 ++++++++++++++++ .../7e170ef8/7e170ef8_mus_model.json | 79 + .../7fd4d544/7fd4d544_code.scd | 0 .../7fd4d544/7fd4d544_mus_model.json | 0 .../314s49e1/314s49e1_code.scd | 581 +++++++ .../314s49e1/314s49e1_mus_model.json | 74 + .../4a8a6e53/4a8a6e53_code.scd | 0 .../4a8a6e53/4a8a6e53_mus_model.json | 0 .../4c01589b/4c01589b_code.scd | 718 +++++++++ .../4c01589b/4c01589b_gui_state.json | 1359 ++++++++++++++++ .../4c01589b/4c01589b_mus_model.json} | 41 +- .../628d5c8b/628d5c8b_code.scd} | 542 ++----- .../628d5c8b/628d5c8b_mus_model.json | 56 + .../66f6a618/66f6a618_code.scd | 0 .../66f6a618/66f6a618_mus_model.json | 0 .../6abf27d4/6abf27d4_code.scd} | 439 ++---- .../6abf27d4/6abf27d4_mus_model.json | 93 ++ .../7ac10d34/7ac10d34_code.scd | 719 +++++++++ .../7ac10d34/7ac10d34_gui_state.json | 1359 ++++++++++++++++ .../7ac10d34/7ac10d34_mus_model.json | 59 + .../7e170ef8/7e170ef8_code.scd | 718 +++++++++ .../7e170ef8/7e170ef8_gui_state.json | 1359 ++++++++++++++++ .../7e170ef8/7e170ef8_mus_model.json | 79 + .../46985d14/46985d14_code.scd | 0 .../46985d14/46985d14_mus_model.json | 0 .../46985d14/lilypond/part_I.ly | 0 .../46985d14/lilypond/part_II.ly | 0 .../46985d14/lilypond/part_III.ly | 0 .../46985d14/lilypond/part_IV.ly | 0 .../490b1e6e/490b1e6e_code.scd | 0 .../490b1e6e/490b1e6e_mus_model.json | 0 .../490b1e6e/lilypond/part_I.ly | 0 .../490b1e6e/lilypond/part_II.ly | 0 .../490b1e6e/lilypond/part_III.ly | 0 .../490b1e6e/lilypond/part_IV.ly | 0 .../4a8a6e53/4a8a6e53_code.scd} | 0 .../4a8a6e53/4a8a6e53_mus_model.json} | 98 +- .../4a8a6e53/lilypond/part_I.ly | 0 .../4a8a6e53/lilypond/part_II.ly | 0 .../4a8a6e53/lilypond/part_III.ly | 0 .../4a8a6e53/lilypond/part_IV.ly | 0 .../5e54c468/5e54c468_code.scd | 0 .../5e54c468/5e54c468_mus_model.json | 0 .../5e54c468/lilypond/part_I.ly | 44 + .../5e54c468/lilypond/part_II.ly | 44 + .../5e54c468/lilypond/part_III.ly | 44 + .../5e54c468/lilypond/part_IV.ly | 44 + .../66f6a618/66f6a618_code.scd} | 0 .../66f6a618/66f6a618_mus_model.json | 91 ++ .../66f6a618/lilypond/part_I.ly | 0 .../66f6a618/lilypond/part_II.ly | 0 .../66f6a618/lilypond/part_III.ly | 0 .../66f6a618/lilypond/part_IV.ly | 0 .../6fb60ab6/6fb60ab6_code.scd | 0 .../6fb60ab6/6fb60ab6_mus_model.json | 0 .../6fb60ab6/lilypond/part_I.ly | 0 .../6fb60ab6/lilypond/part_II.ly | 0 .../6fb60ab6/lilypond/part_III.ly | 0 .../6fb60ab6/lilypond/part_IV.ly | 0 .../761e4585/761e4585_code.scd | 0 .../761e4585/761e4585_mus_model.json | 0 .../761e4585/lilypond/part_I.ly | 0 .../761e4585/lilypond/part_II.ly | 0 .../761e4585/lilypond/part_III.ly | 0 .../761e4585/lilypond/part_IV.ly | 0 .../tmp/tmp_mus_model.json | 103 ++ .../piece_ledger_transcribe_test.json_bak_bak | 11 - .../314s49e1/314s49e1_code.scd | 581 +++++++ .../314s49e1/314s49e1_mus_model.json | 74 + .../43c05737/43c05737_code.scd | 0 .../43c05737/43c05737_mus_model.json | 0 .../46631d0e/46631d0e_code.scd | 0 .../46631d0e/46631d0e_mus_model.json | 0 .../47770d57/47770d57_code.scd | 0 .../47770d57/47770d57_mus_model.json | 0 .../4828752f/4828752f_code.scd | 0 .../4828752f/4828752f_mus_model.json | 0 .../49258e97/49258e97_code.scd | 0 .../49258e97/49258e97_mus_model.json | 0 .../497509c8/497509c8_code.scd | 0 .../497509c8/497509c8_mus_model.json | 0 .../4c01589b/4c01589b_code.scd | 718 +++++++++ .../4c01589b/4c01589b_gui_state.json | 1359 ++++++++++++++++ .../4c01589b/4c01589b_mus_model.json | 85 + .../5397abab/5397abab_code.scd | 0 .../5397abab/5397abab_mus_model.json | 0 .../54479f3d/54479f3d_code.scd | 0 .../54479f3d/54479f3d_mus_model.json | 0 .../57fa6a01/57fa6a01_code.scd | 0 .../57fa6a01/57fa6a01_mus_model.json | 0 .../5cd72e22/5cd72e22_code.scd | 0 .../5cd72e22/5cd72e22_mus_model.json | 0 .../600e3005/600e3005_code.scd | 0 .../600e3005/600e3005_mus_model.json | 0 .../640eeed3/640eeed3_code.scd | 716 +++++++++ .../640eeed3/640eeed3_mus_model.json | 38 + .../674b56e3/674b56e3_code.scd | 0 .../674b56e3/674b56e3_mus_model.json | 0 .../688ee3e1/688ee3e1_code.scd | 0 .../688ee3e1/688ee3e1_mus_model.json | 0 .../75638b4d/75638b4d_code.scd | 0 .../75638b4d/75638b4d_mus_model.json | 0 .../7ac10d34/7ac10d34_code.scd | 719 +++++++++ .../7ac10d34/7ac10d34_gui_state.json | 1359 ++++++++++++++++ .../7ac10d34/7ac10d34_mus_model.json | 59 + .../7bfea52f/7bfea52f_code.scd | 0 .../7bfea52f/7bfea52f_mus_model.json | 0 .../7e170ef8/7e170ef8_code.scd | 718 +++++++++ .../7e170ef8/7e170ef8_gui_state.json | 1359 ++++++++++++++++ .../7e170ef8/7e170ef8_mus_model.json | 79 + .../7e2c2e91/7e2c2e91_code.scd | 0 .../7e2c2e91/7e2c2e91_mus_model.json | 0 resources/tmp/tmp_gui_state.json.json | 603 ------- resources/tmp/tmp_mus_model.json | 70 - supercollider/seeds_and_ledgers_backend.scd | 36 +- .../seeds_and_ledgers_transcriber.scd | 2 +- supercollider/seeds_and_ledgers_utilities.scd | 129 ++ 295 files changed, 18511 insertions(+), 28019 deletions(-) delete mode 100644 resources/314491/314491_gui_session.json delete mode 100644 resources/314491/314491_gui_state.state delete mode 100644 resources/314s49e1/lilypond/part_I.ly delete mode 100644 resources/314s49e1/lilypond/part_II.ly delete mode 100644 resources/314s49e1/lilypond/part_III.ly delete mode 100644 resources/314s49e1/lilypond/part_IV.ly delete mode 100644 resources/430a1ec1/430a1ec1_code.scd delete mode 100644 resources/430a1ec1/430a1ec1_mus_model.json delete mode 100644 resources/445b7057/445b7057_mus_model.json delete mode 100644 resources/46b6952a/46b6952a_mus_model.json delete mode 100644 resources/475efb26/475efb26_mus_model.json delete mode 100644 resources/4c01589b/lilypond/part_I.ly delete mode 100644 resources/4c01589b/lilypond/part_II.ly delete mode 100644 resources/4c01589b/lilypond/part_III.ly delete mode 100644 resources/4c01589b/lilypond/part_IV.ly delete mode 100644 resources/4f65a9b5/4f65a9b5_code.scd delete mode 100644 resources/4f65a9b5/4f65a9b5_mus_model.json delete mode 100644 resources/52af48e5/52af48e5_code.scd delete mode 100644 resources/52af48e5/52af48e5_mus_model.json delete mode 100644 resources/535cc132/535cc132_mus_model.json delete mode 100644 resources/53ad554b/53ad554b_mus_model.json delete mode 100644 resources/57a598e2/57a598e2_code.scd delete mode 100644 resources/57a598e2/57a598e2_mus_model.json delete mode 100644 resources/5e947063/lilypond/part_I.ly delete mode 100644 resources/5e947063/lilypond/part_II.ly delete mode 100644 resources/5e947063/lilypond/part_III.ly delete mode 100644 resources/5e947063/lilypond/part_IV.ly delete mode 100644 resources/6132dd73/6132dd73_code.scd delete mode 100644 resources/6132dd73/6132dd73_mus_model.json delete mode 100644 resources/6232ff77/6232ff77_code.scd delete mode 100644 resources/6232ff77/6232ff77_mus_model.json delete mode 100644 resources/628d5c8b/lilypond/part_I.ly delete mode 100644 resources/628d5c8b/lilypond/part_II.ly delete mode 100644 resources/628d5c8b/lilypond/part_III.ly delete mode 100644 resources/628d5c8b/lilypond/part_IV.ly delete mode 100644 resources/640eeed3/lilypond/part_I.ly delete mode 100644 resources/640eeed3/lilypond/part_II.ly delete mode 100644 resources/640eeed3/lilypond/part_III.ly delete mode 100644 resources/640eeed3/lilypond/part_IV.ly delete mode 100644 resources/64b535ef/64b535ef_code.scd delete mode 100644 resources/652c77ba/652c77ba_code.scd delete mode 100644 resources/652c77ba/652c77ba_mus_model.json delete mode 100644 resources/6881b4ac/6881b4ac_mus_model.json delete mode 100644 resources/6abf27d4/lilypond/part_I.ly delete mode 100644 resources/6abf27d4/lilypond/part_II.ly delete mode 100644 resources/6abf27d4/lilypond/part_III.ly delete mode 100644 resources/6abf27d4/lilypond/part_IV.ly delete mode 100644 resources/6d743c5c/lilypond/part_I.ly delete mode 100644 resources/6d743c5c/lilypond/part_II.ly delete mode 100644 resources/6d743c5c/lilypond/part_III.ly delete mode 100644 resources/6d743c5c/lilypond/part_IV.ly delete mode 100644 resources/720a7ee4/720a7ee4_code.scd delete mode 100644 resources/720a7ee4/720a7ee4_mus_model.json delete mode 100644 resources/72dbaa4c/72dbaa4c_mus_model.json delete mode 100644 resources/72e6131c/72e6131c_code.scd delete mode 100644 resources/72e6131c/72e6131c_mus_model.json delete mode 100644 resources/730ad6b9/730ad6b9_code.scd delete mode 100644 resources/74d9b3e1/74d9b3e1_code.scd delete mode 100644 resources/74d9b3e1/74d9b3e1_mus_model.json delete mode 100644 resources/75837171/75837171_code.scd delete mode 100644 resources/75837171/75837171_mus_model.json delete mode 100644 resources/78f2229c/78f2229c_code.scd delete mode 100644 resources/78f2229c/78f2229c_mus_model.json delete mode 100644 resources/7ac10d34/lilypond/part_I.ly delete mode 100644 resources/7ac10d34/lilypond/part_II.ly delete mode 100644 resources/7ac10d34/lilypond/part_III.ly delete mode 100644 resources/7ac10d34/lilypond/part_IV.ly delete mode 100644 resources/7bda0503/7bda0503_code.scd delete mode 100644 resources/7bda0503/7bda0503_mus_model.json delete mode 100644 resources/7c1ab0e0/7c1ab0e0_code.scd delete mode 100644 resources/7c1ab0e0/7c1ab0e0_mus_model.json delete mode 100644 resources/7c7ba1aa/7c7ba1aa_code.scd delete mode 100644 resources/7c7ba1aa/7c7ba1aa_mus_model.json delete mode 100644 resources/7cc3121d/7cc3121d_code.scd delete mode 100644 resources/7cc3121d/7cc3121d_mus_model.json delete mode 100644 resources/7e170ef8/lilypond/part_I.ly delete mode 100644 resources/7e170ef8/lilypond/part_II.ly delete mode 100644 resources/7e170ef8/lilypond/part_III.ly delete mode 100644 resources/7e170ef8/lilypond/part_IV.ly delete mode 100644 resources/7e42825a/7e42825a_code.scd delete mode 100644 resources/7e42825a/7e42825a_mus_model.json delete mode 100644 resources/7ebbb471/7ebbb471_code.scd delete mode 100644 resources/7ebbb471/7ebbb471_mus_model.json delete mode 100644 resources/7ebbb471/lilypond/part_I.ly delete mode 100644 resources/7ebbb471/lilypond/part_II.ly delete mode 100644 resources/7ebbb471/lilypond/part_III.ly delete mode 100644 resources/7ebbb471/lilypond/part_IV.ly delete mode 100644 resources/piece_ledger.json_bak_bak rename resources/{ => piece_ledger}/314s49e1/314s49e1_code.scd (100%) rename resources/{ => piece_ledger}/314s49e1/314s49e1_mus_model.json (100%) rename resources/{ => piece_ledger}/46a0e6a8/46a0e6a8_code.scd (100%) rename resources/{ => piece_ledger}/46a0e6a8/46a0e6a8_mus_model.json (100%) rename resources/{ => piece_ledger}/4c01589b/4c01589b_code.scd (100%) rename resources/{ => piece_ledger}/4c01589b/4c01589b_gui_state.json (100%) rename resources/{ => piece_ledger}/4c01589b/4c01589b_mus_model.json (100%) rename resources/{ => piece_ledger}/4cf4476d/4cf4476d_code.scd (100%) rename resources/{ => piece_ledger}/4cf4476d/4cf4476d_mus_model.json (100%) rename resources/{ => piece_ledger}/55930f4d/55930f4d_code.scd (100%) rename resources/{ => piece_ledger}/55930f4d/55930f4d_mus_model.json (100%) rename resources/{ => piece_ledger}/5cf1e9ab/5cf1e9ab_code.scd (100%) rename resources/{ => piece_ledger}/5cf1e9ab/5cf1e9ab_mus_model.json (100%) rename resources/{ => piece_ledger}/5e947063/5e947063_code.scd (100%) rename resources/{ => piece_ledger}/5e947063/5e947063_mus_model.json (100%) rename resources/{ => piece_ledger}/628d5c8b/628d5c8b_code.scd (100%) rename resources/{ => piece_ledger}/628d5c8b/628d5c8b_mus_model.json (100%) rename resources/{ => piece_ledger}/62b894e8/62b894e8_code.scd (100%) rename resources/{ => piece_ledger}/62b894e8/62b894e8_mus_model.json (100%) rename resources/{ => piece_ledger}/640eeed3/640eeed3_code.scd (100%) rename resources/{ => piece_ledger}/640eeed3/640eeed3_mus_model.json (100%) rename resources/{ => piece_ledger}/6506161e/6506161e_code.scd (100%) rename resources/{ => piece_ledger}/6506161e/6506161e_mus_model.json (100%) rename resources/{ => piece_ledger}/69a72421/69a72421_code.scd (100%) rename resources/{ => piece_ledger}/69a72421/69a72421_mus_model.json (100%) rename resources/{ => piece_ledger}/6abf27d4/6abf27d4_code.scd (100%) rename resources/{ => piece_ledger}/6abf27d4/6abf27d4_mus_model.json (100%) rename resources/{ => piece_ledger}/6be1486c/6be1486c_code.scd (100%) rename resources/{ => piece_ledger}/6be1486c/6be1486c_mus_model.json (100%) rename resources/{ => piece_ledger}/7000ae3e/7000ae3e_code.scd (100%) rename resources/{ => piece_ledger}/7000ae3e/7000ae3e_mus_model.json (100%) rename resources/{ => piece_ledger}/7aa8c429/7aa8c429_code.scd (100%) rename resources/{ => piece_ledger}/7aa8c429/7aa8c429_mus_model.json (100%) rename resources/{ => piece_ledger}/7ac10d34/7ac10d34_code.scd (100%) rename resources/{ => piece_ledger}/7ac10d34/7ac10d34_gui_state.json (100%) rename resources/{ => piece_ledger}/7ac10d34/7ac10d34_mus_model.json (100%) rename resources/{ => piece_ledger}/7e170ef8/7e170ef8_code.scd (100%) rename resources/{ => piece_ledger}/7e170ef8/7e170ef8_gui_state.json (100%) rename resources/{ => piece_ledger}/7e170ef8/7e170ef8_mus_model.json (100%) rename resources/{ => piece_ledger}/7ead41c3/7ead41c3_code.scd (100%) rename resources/{ => piece_ledger}/7ead41c3/7ead41c3_mus_model.json (100%) rename resources/{314491/314491_code.scd => piece_ledger_pas/314s49e1/314s49e1_code.scd} (100%) rename resources/{314491/314491_music.json => piece_ledger_pas/314s49e1/314s49e1_mus_model.json} (98%) rename resources/{ => piece_ledger_pas}/449aeaa6/449aeaa6_code.scd (100%) rename resources/{ => piece_ledger_pas}/449aeaa6/449aeaa6_mus_model.json (100%) rename resources/{ => piece_ledger_pas}/46210507/46210507_code.scd (100%) rename resources/{ => piece_ledger_pas}/46210507/46210507_mus_model.json (100%) rename resources/{ => piece_ledger_pas}/4b96f62d/4b96f62d_code.scd (100%) rename resources/{ => piece_ledger_pas}/4b96f62d/4b96f62d_mus_model.json (100%) rename resources/{ => piece_ledger_pas}/50fec831/50fec831_code.scd (100%) rename resources/{ => piece_ledger_pas}/50fec831/50fec831_mus_model.json (100%) rename resources/{ => piece_ledger_pas}/5267b235/5267b235_code.scd (100%) rename resources/{ => piece_ledger_pas}/5267b235/5267b235_mus_model.json (100%) rename resources/{ => piece_ledger_pas}/5625a95a/5625a95a_code.scd (100%) rename resources/{ => piece_ledger_pas}/5625a95a/5625a95a_mus_model.json (100%) rename resources/{475efb26/475efb26_code.scd => piece_ledger_pas/628d5c8b/628d5c8b_code.scd} (53%) create mode 100644 resources/piece_ledger_pas/628d5c8b/628d5c8b_mus_model.json rename resources/{ => piece_ledger_pas}/6409252e/6409252e_code.scd (100%) rename resources/{ => piece_ledger_pas}/6409252e/6409252e_mus_model.json (100%) rename resources/{ => piece_ledger_pas}/6a3f7c7c/6a3f7c7c_code.scd (100%) rename resources/{ => piece_ledger_pas}/6a3f7c7c/6a3f7c7c_mus_model.json (100%) rename resources/{6881b4ac/6881b4ac_code.scd => piece_ledger_pas/6abf27d4/6abf27d4_code.scd} (63%) create mode 100644 resources/piece_ledger_pas/6abf27d4/6abf27d4_mus_model.json rename resources/{ => piece_ledger_pas}/6d0c2f19/6d0c2f19_code.scd (100%) rename resources/{ => piece_ledger_pas}/6d0c2f19/6d0c2f19_mus_model.json (100%) rename resources/{ => piece_ledger_pas}/6d743c5c/6d743c5c_code.scd (100%) rename resources/{ => piece_ledger_pas}/6d743c5c/6d743c5c_mus_model.json (100%) rename resources/{ => piece_ledger_pas}/6f1305ed/6f1305ed_code.scd (100%) rename resources/{ => piece_ledger_pas}/6f1305ed/6f1305ed_mus_model.json (100%) rename resources/{ => piece_ledger_pas}/703e109b/703e109b_code.scd (100%) rename resources/{ => piece_ledger_pas}/703e109b/703e109b_mus_model.json (100%) rename resources/{ => piece_ledger_pas}/74faf83f/74faf83f_code.scd (100%) rename resources/{ => piece_ledger_pas}/74faf83f/74faf83f_mus_model.json (100%) rename resources/{46b6952a/46b6952a_code.scd => piece_ledger_pas/7ac10d34/7ac10d34_code.scd} (100%) rename resources/{46b6952a/46b6952a_gui_state.json => piece_ledger_pas/7ac10d34/7ac10d34_gui_state.json} (99%) create mode 100644 resources/piece_ledger_pas/7ac10d34/7ac10d34_mus_model.json rename resources/{ => piece_ledger_pas}/7bf874ce/7bf874ce_code.scd (100%) rename resources/{ => piece_ledger_pas}/7bf874ce/7bf874ce_mus_model.json (100%) rename resources/{ => piece_ledger_pas}/7c7a96a2/7c7a96a2_code.scd (100%) rename resources/{ => piece_ledger_pas}/7c7a96a2/7c7a96a2_mus_model.json (100%) rename resources/{ => piece_ledger_pas}/7c8bc6df/7c8bc6df_code.scd (100%) rename resources/{ => piece_ledger_pas}/7c8bc6df/7c8bc6df_mus_model.json (100%) create mode 100644 resources/piece_ledger_pas/7e170ef8/7e170ef8_code.scd create mode 100644 resources/piece_ledger_pas/7e170ef8/7e170ef8_gui_state.json create mode 100644 resources/piece_ledger_pas/7e170ef8/7e170ef8_mus_model.json rename resources/{ => piece_ledger_pas}/7fd4d544/7fd4d544_code.scd (100%) rename resources/{ => piece_ledger_pas}/7fd4d544/7fd4d544_mus_model.json (100%) create mode 100644 resources/piece_ledger_sq1_candidates/314s49e1/314s49e1_code.scd create mode 100644 resources/piece_ledger_sq1_candidates/314s49e1/314s49e1_mus_model.json rename resources/{ => piece_ledger_sq1_candidates}/4a8a6e53/4a8a6e53_code.scd (100%) rename resources/{ => piece_ledger_sq1_candidates}/4a8a6e53/4a8a6e53_mus_model.json (100%) create mode 100644 resources/piece_ledger_sq1_candidates/4c01589b/4c01589b_code.scd create mode 100644 resources/piece_ledger_sq1_candidates/4c01589b/4c01589b_gui_state.json rename resources/{730ad6b9/730ad6b9_mus_model.json => piece_ledger_sq1_candidates/4c01589b/4c01589b_mus_model.json} (74%) rename resources/{72dbaa4c/72dbaa4c_code.scd => piece_ledger_sq1_candidates/628d5c8b/628d5c8b_code.scd} (53%) create mode 100644 resources/piece_ledger_sq1_candidates/628d5c8b/628d5c8b_mus_model.json rename resources/{ => piece_ledger_sq1_candidates}/66f6a618/66f6a618_code.scd (100%) rename resources/{ => piece_ledger_sq1_candidates}/66f6a618/66f6a618_mus_model.json (100%) rename resources/{53ad554b/53ad554b_code.scd => piece_ledger_sq1_candidates/6abf27d4/6abf27d4_code.scd} (63%) create mode 100644 resources/piece_ledger_sq1_candidates/6abf27d4/6abf27d4_mus_model.json create mode 100644 resources/piece_ledger_sq1_candidates/7ac10d34/7ac10d34_code.scd create mode 100644 resources/piece_ledger_sq1_candidates/7ac10d34/7ac10d34_gui_state.json create mode 100644 resources/piece_ledger_sq1_candidates/7ac10d34/7ac10d34_mus_model.json create mode 100644 resources/piece_ledger_sq1_candidates/7e170ef8/7e170ef8_code.scd create mode 100644 resources/piece_ledger_sq1_candidates/7e170ef8/7e170ef8_gui_state.json create mode 100644 resources/piece_ledger_sq1_candidates/7e170ef8/7e170ef8_mus_model.json rename resources/{ => piece_ledger_sq1_candidates_stitch}/46985d14/46985d14_code.scd (100%) rename resources/{ => piece_ledger_sq1_candidates_stitch}/46985d14/46985d14_mus_model.json (100%) rename resources/{ => piece_ledger_sq1_candidates_stitch}/46985d14/lilypond/part_I.ly (100%) rename resources/{ => piece_ledger_sq1_candidates_stitch}/46985d14/lilypond/part_II.ly (100%) rename resources/{ => piece_ledger_sq1_candidates_stitch}/46985d14/lilypond/part_III.ly (100%) rename resources/{ => piece_ledger_sq1_candidates_stitch}/46985d14/lilypond/part_IV.ly (100%) rename resources/{ => piece_ledger_sq1_candidates_stitch}/490b1e6e/490b1e6e_code.scd (100%) rename resources/{ => piece_ledger_sq1_candidates_stitch}/490b1e6e/490b1e6e_mus_model.json (100%) rename resources/{ => piece_ledger_sq1_candidates_stitch}/490b1e6e/lilypond/part_I.ly (100%) rename resources/{ => piece_ledger_sq1_candidates_stitch}/490b1e6e/lilypond/part_II.ly (100%) rename resources/{ => piece_ledger_sq1_candidates_stitch}/490b1e6e/lilypond/part_III.ly (100%) rename resources/{ => piece_ledger_sq1_candidates_stitch}/490b1e6e/lilypond/part_IV.ly (100%) rename resources/{445b7057/445b7057_code.scd => piece_ledger_sq1_candidates_stitch/4a8a6e53/4a8a6e53_code.scd} (100%) rename resources/{64b535ef/64b535ef_mus_model.json => piece_ledger_sq1_candidates_stitch/4a8a6e53/4a8a6e53_mus_model.json} (53%) rename resources/{ => piece_ledger_sq1_candidates_stitch}/4a8a6e53/lilypond/part_I.ly (100%) rename resources/{ => piece_ledger_sq1_candidates_stitch}/4a8a6e53/lilypond/part_II.ly (100%) rename resources/{ => piece_ledger_sq1_candidates_stitch}/4a8a6e53/lilypond/part_III.ly (100%) rename resources/{ => piece_ledger_sq1_candidates_stitch}/4a8a6e53/lilypond/part_IV.ly (100%) rename resources/{ => piece_ledger_sq1_candidates_stitch}/5e54c468/5e54c468_code.scd (100%) rename resources/{ => piece_ledger_sq1_candidates_stitch}/5e54c468/5e54c468_mus_model.json (100%) create mode 100644 resources/piece_ledger_sq1_candidates_stitch/5e54c468/lilypond/part_I.ly create mode 100644 resources/piece_ledger_sq1_candidates_stitch/5e54c468/lilypond/part_II.ly create mode 100644 resources/piece_ledger_sq1_candidates_stitch/5e54c468/lilypond/part_III.ly create mode 100644 resources/piece_ledger_sq1_candidates_stitch/5e54c468/lilypond/part_IV.ly rename resources/{535cc132/535cc132_code.scd => piece_ledger_sq1_candidates_stitch/66f6a618/66f6a618_code.scd} (100%) create mode 100644 resources/piece_ledger_sq1_candidates_stitch/66f6a618/66f6a618_mus_model.json rename resources/{ => piece_ledger_sq1_candidates_stitch}/66f6a618/lilypond/part_I.ly (100%) rename resources/{ => piece_ledger_sq1_candidates_stitch}/66f6a618/lilypond/part_II.ly (100%) rename resources/{ => piece_ledger_sq1_candidates_stitch}/66f6a618/lilypond/part_III.ly (100%) rename resources/{ => piece_ledger_sq1_candidates_stitch}/66f6a618/lilypond/part_IV.ly (100%) rename resources/{ => piece_ledger_sq1_candidates_stitch}/6fb60ab6/6fb60ab6_code.scd (100%) rename resources/{ => piece_ledger_sq1_candidates_stitch}/6fb60ab6/6fb60ab6_mus_model.json (100%) rename resources/{ => piece_ledger_sq1_candidates_stitch}/6fb60ab6/lilypond/part_I.ly (100%) rename resources/{ => piece_ledger_sq1_candidates_stitch}/6fb60ab6/lilypond/part_II.ly (100%) rename resources/{ => piece_ledger_sq1_candidates_stitch}/6fb60ab6/lilypond/part_III.ly (100%) rename resources/{ => piece_ledger_sq1_candidates_stitch}/6fb60ab6/lilypond/part_IV.ly (100%) rename resources/{ => piece_ledger_sq1_candidates_stitch}/761e4585/761e4585_code.scd (100%) rename resources/{ => piece_ledger_sq1_candidates_stitch}/761e4585/761e4585_mus_model.json (100%) rename resources/{ => piece_ledger_sq1_candidates_stitch}/761e4585/lilypond/part_I.ly (100%) rename resources/{ => piece_ledger_sq1_candidates_stitch}/761e4585/lilypond/part_II.ly (100%) rename resources/{ => piece_ledger_sq1_candidates_stitch}/761e4585/lilypond/part_III.ly (100%) rename resources/{ => piece_ledger_sq1_candidates_stitch}/761e4585/lilypond/part_IV.ly (100%) create mode 100644 resources/piece_ledger_sq1_candidates_stitch/tmp/tmp_mus_model.json delete mode 100644 resources/piece_ledger_transcribe_test.json_bak_bak create mode 100644 resources/piece_ledger_transcribe_test/314s49e1/314s49e1_code.scd create mode 100644 resources/piece_ledger_transcribe_test/314s49e1/314s49e1_mus_model.json rename resources/{ => piece_ledger_transcribe_test}/43c05737/43c05737_code.scd (100%) rename resources/{ => piece_ledger_transcribe_test}/43c05737/43c05737_mus_model.json (100%) rename resources/{ => piece_ledger_transcribe_test}/46631d0e/46631d0e_code.scd (100%) rename resources/{ => piece_ledger_transcribe_test}/46631d0e/46631d0e_mus_model.json (100%) rename resources/{ => piece_ledger_transcribe_test}/47770d57/47770d57_code.scd (100%) rename resources/{ => piece_ledger_transcribe_test}/47770d57/47770d57_mus_model.json (100%) rename resources/{ => piece_ledger_transcribe_test}/4828752f/4828752f_code.scd (100%) rename resources/{ => piece_ledger_transcribe_test}/4828752f/4828752f_mus_model.json (100%) rename resources/{ => piece_ledger_transcribe_test}/49258e97/49258e97_code.scd (100%) rename resources/{ => piece_ledger_transcribe_test}/49258e97/49258e97_mus_model.json (100%) rename resources/{ => piece_ledger_transcribe_test}/497509c8/497509c8_code.scd (100%) rename resources/{ => piece_ledger_transcribe_test}/497509c8/497509c8_mus_model.json (100%) create mode 100644 resources/piece_ledger_transcribe_test/4c01589b/4c01589b_code.scd create mode 100644 resources/piece_ledger_transcribe_test/4c01589b/4c01589b_gui_state.json create mode 100644 resources/piece_ledger_transcribe_test/4c01589b/4c01589b_mus_model.json rename resources/{ => piece_ledger_transcribe_test}/5397abab/5397abab_code.scd (100%) rename resources/{ => piece_ledger_transcribe_test}/5397abab/5397abab_mus_model.json (100%) rename resources/{ => piece_ledger_transcribe_test}/54479f3d/54479f3d_code.scd (100%) rename resources/{ => piece_ledger_transcribe_test}/54479f3d/54479f3d_mus_model.json (100%) rename resources/{ => piece_ledger_transcribe_test}/57fa6a01/57fa6a01_code.scd (100%) rename resources/{ => piece_ledger_transcribe_test}/57fa6a01/57fa6a01_mus_model.json (100%) rename resources/{ => piece_ledger_transcribe_test}/5cd72e22/5cd72e22_code.scd (100%) rename resources/{ => piece_ledger_transcribe_test}/5cd72e22/5cd72e22_mus_model.json (100%) rename resources/{ => piece_ledger_transcribe_test}/600e3005/600e3005_code.scd (100%) rename resources/{ => piece_ledger_transcribe_test}/600e3005/600e3005_mus_model.json (100%) create mode 100644 resources/piece_ledger_transcribe_test/640eeed3/640eeed3_code.scd create mode 100644 resources/piece_ledger_transcribe_test/640eeed3/640eeed3_mus_model.json rename resources/{ => piece_ledger_transcribe_test}/674b56e3/674b56e3_code.scd (100%) rename resources/{ => piece_ledger_transcribe_test}/674b56e3/674b56e3_mus_model.json (100%) rename resources/{ => piece_ledger_transcribe_test}/688ee3e1/688ee3e1_code.scd (100%) rename resources/{ => piece_ledger_transcribe_test}/688ee3e1/688ee3e1_mus_model.json (100%) rename resources/{ => piece_ledger_transcribe_test}/75638b4d/75638b4d_code.scd (100%) rename resources/{ => piece_ledger_transcribe_test}/75638b4d/75638b4d_mus_model.json (100%) create mode 100644 resources/piece_ledger_transcribe_test/7ac10d34/7ac10d34_code.scd create mode 100644 resources/piece_ledger_transcribe_test/7ac10d34/7ac10d34_gui_state.json create mode 100644 resources/piece_ledger_transcribe_test/7ac10d34/7ac10d34_mus_model.json rename resources/{ => piece_ledger_transcribe_test}/7bfea52f/7bfea52f_code.scd (100%) rename resources/{ => piece_ledger_transcribe_test}/7bfea52f/7bfea52f_mus_model.json (100%) create mode 100644 resources/piece_ledger_transcribe_test/7e170ef8/7e170ef8_code.scd create mode 100644 resources/piece_ledger_transcribe_test/7e170ef8/7e170ef8_gui_state.json create mode 100644 resources/piece_ledger_transcribe_test/7e170ef8/7e170ef8_mus_model.json rename resources/{ => piece_ledger_transcribe_test}/7e2c2e91/7e2c2e91_code.scd (100%) rename resources/{ => piece_ledger_transcribe_test}/7e2c2e91/7e2c2e91_mus_model.json (100%) delete mode 100644 resources/tmp/tmp_gui_state.json.json delete mode 100644 resources/tmp/tmp_mus_model.json create mode 100644 supercollider/seeds_and_ledgers_utilities.scd diff --git a/lilypond/includes/part_I.ly b/lilypond/includes/part_I.ly index 9509295..a3f5519 100644 --- a/lilypond/includes/part_I.ly +++ b/lilypond/includes/part_I.ly @@ -1,6 +1,6 @@ -\include "../../resources/4a8a6e53/lilypond/part_I.ly" -\include "../../resources/66f6a618/lilypond/part_I.ly" -\include "../../resources/490b1e6e/lilypond/part_I.ly" -\include "../../resources/46985d14/lilypond/part_I.ly" -\include "../../resources/761e4585/lilypond/part_I.ly" -\include "../../resources/6fb60ab6/lilypond/part_I.ly" +\include "/home/mwinter/Sketches/seeds_and_ledgers/source/resources/piece_ledger_sq1_candidates_stitch/4a8a6e53/lilypond/part_I.ly" +\include "/home/mwinter/Sketches/seeds_and_ledgers/source/resources/piece_ledger_sq1_candidates_stitch/66f6a618/lilypond/part_I.ly" +\include "/home/mwinter/Sketches/seeds_and_ledgers/source/resources/piece_ledger_sq1_candidates_stitch/490b1e6e/lilypond/part_I.ly" +\include "/home/mwinter/Sketches/seeds_and_ledgers/source/resources/piece_ledger_sq1_candidates_stitch/46985d14/lilypond/part_I.ly" +\include "/home/mwinter/Sketches/seeds_and_ledgers/source/resources/piece_ledger_sq1_candidates_stitch/761e4585/lilypond/part_I.ly" +\include "/home/mwinter/Sketches/seeds_and_ledgers/source/resources/piece_ledger_sq1_candidates_stitch/6fb60ab6/lilypond/part_I.ly" diff --git a/lilypond/includes/part_II.ly b/lilypond/includes/part_II.ly index 94de4e2..ae04fd2 100644 --- a/lilypond/includes/part_II.ly +++ b/lilypond/includes/part_II.ly @@ -1,6 +1,6 @@ -\include "../../resources/4a8a6e53/lilypond/part_II.ly" -\include "../../resources/66f6a618/lilypond/part_II.ly" -\include "../../resources/490b1e6e/lilypond/part_II.ly" -\include "../../resources/46985d14/lilypond/part_II.ly" -\include "../../resources/761e4585/lilypond/part_II.ly" -\include "../../resources/6fb60ab6/lilypond/part_II.ly" +\include "/home/mwinter/Sketches/seeds_and_ledgers/source/resources/piece_ledger_sq1_candidates_stitch/4a8a6e53/lilypond/part_II.ly" +\include "/home/mwinter/Sketches/seeds_and_ledgers/source/resources/piece_ledger_sq1_candidates_stitch/66f6a618/lilypond/part_II.ly" +\include "/home/mwinter/Sketches/seeds_and_ledgers/source/resources/piece_ledger_sq1_candidates_stitch/490b1e6e/lilypond/part_II.ly" +\include "/home/mwinter/Sketches/seeds_and_ledgers/source/resources/piece_ledger_sq1_candidates_stitch/46985d14/lilypond/part_II.ly" +\include "/home/mwinter/Sketches/seeds_and_ledgers/source/resources/piece_ledger_sq1_candidates_stitch/761e4585/lilypond/part_II.ly" +\include "/home/mwinter/Sketches/seeds_and_ledgers/source/resources/piece_ledger_sq1_candidates_stitch/6fb60ab6/lilypond/part_II.ly" diff --git a/lilypond/includes/part_III.ly b/lilypond/includes/part_III.ly index 53f7ce7..a82e0dc 100644 --- a/lilypond/includes/part_III.ly +++ b/lilypond/includes/part_III.ly @@ -1,6 +1,6 @@ -\include "../../resources/4a8a6e53/lilypond/part_III.ly" -\include "../../resources/66f6a618/lilypond/part_III.ly" -\include "../../resources/490b1e6e/lilypond/part_III.ly" -\include "../../resources/46985d14/lilypond/part_III.ly" -\include "../../resources/761e4585/lilypond/part_III.ly" -\include "../../resources/6fb60ab6/lilypond/part_III.ly" +\include "/home/mwinter/Sketches/seeds_and_ledgers/source/resources/piece_ledger_sq1_candidates_stitch/4a8a6e53/lilypond/part_III.ly" +\include "/home/mwinter/Sketches/seeds_and_ledgers/source/resources/piece_ledger_sq1_candidates_stitch/66f6a618/lilypond/part_III.ly" +\include "/home/mwinter/Sketches/seeds_and_ledgers/source/resources/piece_ledger_sq1_candidates_stitch/490b1e6e/lilypond/part_III.ly" +\include "/home/mwinter/Sketches/seeds_and_ledgers/source/resources/piece_ledger_sq1_candidates_stitch/46985d14/lilypond/part_III.ly" +\include "/home/mwinter/Sketches/seeds_and_ledgers/source/resources/piece_ledger_sq1_candidates_stitch/761e4585/lilypond/part_III.ly" +\include "/home/mwinter/Sketches/seeds_and_ledgers/source/resources/piece_ledger_sq1_candidates_stitch/6fb60ab6/lilypond/part_III.ly" diff --git a/lilypond/includes/part_IV.ly b/lilypond/includes/part_IV.ly index 650b9b4..6c5f83e 100644 --- a/lilypond/includes/part_IV.ly +++ b/lilypond/includes/part_IV.ly @@ -1,6 +1,6 @@ -\include "../../resources/4a8a6e53/lilypond/part_IV.ly" -\include "../../resources/66f6a618/lilypond/part_IV.ly" -\include "../../resources/490b1e6e/lilypond/part_IV.ly" -\include "../../resources/46985d14/lilypond/part_IV.ly" -\include "../../resources/761e4585/lilypond/part_IV.ly" -\include "../../resources/6fb60ab6/lilypond/part_IV.ly" +\include "/home/mwinter/Sketches/seeds_and_ledgers/source/resources/piece_ledger_sq1_candidates_stitch/4a8a6e53/lilypond/part_IV.ly" +\include "/home/mwinter/Sketches/seeds_and_ledgers/source/resources/piece_ledger_sq1_candidates_stitch/66f6a618/lilypond/part_IV.ly" +\include "/home/mwinter/Sketches/seeds_and_ledgers/source/resources/piece_ledger_sq1_candidates_stitch/490b1e6e/lilypond/part_IV.ly" +\include "/home/mwinter/Sketches/seeds_and_ledgers/source/resources/piece_ledger_sq1_candidates_stitch/46985d14/lilypond/part_IV.ly" +\include "/home/mwinter/Sketches/seeds_and_ledgers/source/resources/piece_ledger_sq1_candidates_stitch/761e4585/lilypond/part_IV.ly" +\include "/home/mwinter/Sketches/seeds_and_ledgers/source/resources/piece_ledger_sq1_candidates_stitch/6fb60ab6/lilypond/part_IV.ly" diff --git a/lilypond/score_template.pdf b/lilypond/score_template.pdf index 6aa5386eb53c96b59421714144a261c7772e9d65..b20ef3940e7af0b4816115f3b9e87bb01b9b0924 100644 GIT binary patch delta 168338 zcmbSUcf8Nl|9{+lFEUy*+=Y8D!e|Bt^wd-%5p~;)Ig6QbvnN(N02I zwv>iZw6}iG^Sb-Ie*Zkr_n#i$&aiVx%tJEGp3w$&EPRtkGU*9;glIym66K_f4}^728~4jwaL%(Yiud)ZKP%8Zm;bK8`Z zRUFu)MF6Y6DW}*hn3{4g2^&bwGxN7+mzYPVv9Kv`rR15?wVB0c?%gRfIJ`J&z8Nt+ zWu*t$z^!Rb&9r+`?xSJ1&=C3Nl6zB@d4S!&KCQ@%zt3Zn;N>#Fj=tZ6rn%X1RXR-W%2o#vR<5^A3#fBB1Nmld*lw=p1UJtNj5|QuI9I)MHv#_FNC(dED zOu!n=^#Z&3g_LyD=)sg%JeX4dAup75=6QhuTe_+9u+L6sJp$0|`JSMp&0F&pgy-K! zQeNgL`q3JIW$ejpW*R-ls#mY=Fj@N^OIg986tLfmU?uB3!K%oht+22=pI}i=`UhYK zzs+oF{&|ws4rp|)S^pHvMN!Ci7SLe-fTpXTW-TlZSYTdx#sgb{xvNc1k=eSCWd%^? zn+~6Yjh{Tr!j2vWsrzeXT8UZz919D=Zsr6I5cy`#VwyM>?EWPz7|dd0Grx0Mx|zO| zg%zQh{5&h(Vu@i=Nt00lmTnN5`B>s{FR>^kLi+9j2;AJ4Sw)oXj#!rRD#v|*<(py4 zSw}8lSG>Z4E$x?DU^e$nZE7a3VC^Yj3(X}fQh9NWz|t=?d5vB+tYH$7D2 zbB^(HtcGuUS&RDbu=^8*sQWHU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N+j}Iahbr!`*ztxT+%#GELMN!| zm4Q~hGSDD5ViowNY1h)VZ3ju{AA&qbkx4110qkLr_x#8$h7k9+q?xYswVmAB2nG?E z44@uJMduz*Bkw%n6lDf^R1NW@a?-L3^}b1rMWEipJDA1Esh&o>^|0(hEkCO$`CNVL zK|3wN4j5n&PKP=ZVd07)pj~9$5E}C(|Be%uTrw@#Ytm2_F=;VsSl)VJx8k6$suc$s zGcqTm6-RtTe0$N+$5l``dJ#DS18LBFp;jCxJd5MhvSbJct$MYgRVxlO!G*&&_FlSZ zd*uVrs&W)9mA=WyFXU2BACKf571d>Az9C@#VEf76+=JReoezpJ6crR>&_d}!!h#l- zRQ8~-q-ci}#Yz(Mqe~B|2tJjZvkQ=8wKKq}c^0|({XR$WWZXz%7FtPSb14T&h`bcw z)ST61U{muf3KeH~*6h@jrmm1^OdprpYCA=#M;WSO-kE6hY}+Y=?%y-tQ4;G*6^5mi z5hkcJ2J4+?43xUg7*KNADIC3U6G-BL#pV(+hRgo9?HSUV<_{U*L90;Jlu?%86qVoH zPe}|rR?9jttdv!HIwbzX;b?n>Hp(Q5aYv25NMgQn#(v(7B`o03NSs_i%boL_!^@#Nm4s}CPvJ%0H9lSiAUSI=~BdUWL)BO2Kz n-M{?ce@A?Fc6oXB?aMD;y!`&f*U!)R4E)8jJ9nOb{Os&MVo`nr diff --git a/open_stage_control/modules/custom_module.js b/open_stage_control/modules/custom_module.js index 9e39055..138b55f 100644 --- a/open_stage_control/modules/custom_module.js +++ b/open_stage_control/modules/custom_module.js @@ -1,5 +1,7 @@ const {resolve} = nativeRequire("path"); var fs = nativeRequire("fs"); +//const path = nativeRequire("path"); +var resourceDir; stringifyToDepth = function(data, maxDepth){ var prettyString = "" @@ -212,7 +214,7 @@ module.exports = { var state = JSON.parse(args[0].value) //console.log(__dirname) - var modelPath = resolve(__dirname + "/../../resources/tmp/tmp_mus_model.json") + var modelPath = resolve(resourceDir + "/tmp/tmp_mus_model.json") var model = {} model.schema_version = "1.0" model.cur_uid = "tmp" @@ -282,12 +284,14 @@ module.exports = { } if (address === '/load_ledger') { - //console.log(loadJSON(args[0].value)) + //console.log(args[0].value) + resourceDir = args[0].value.replace(/\.[^/.]+$/, ""); receive('/ledger', JSON.stringify(loadJSON(args[0].value).ledger, null, ' ').replace(/['"]+/g, '')) return data } if (address === '/save_ledger') { + resourceDir = args[0].value.replace(/\.[^/.]+$/, ""); ledger = {} ledger.ledger = JSON.parse(args[0].value.replace(/([a-zA-Z0-9-]+)/g, "\"$1\"")) args[0].value = JSON.stringify(ledger) @@ -303,7 +307,7 @@ module.exports = { if (address === '/load_model_state') { id = args[0].value - var modelPath = resolve(__dirname + "/../../resources/" + id + "/" + id + "_mus_model.json") + var modelPath = resolve(resourceDir + "/" + id + "/" + id + "_mus_model.json") var model = loadJSON(modelPath) loadModel(model) return diff --git a/open_stage_control/seeds_and_ledgers_gui.json b/open_stage_control/seeds_and_ledgers_gui.json index e62062c..0daddc3 100644 --- a/open_stage_control/seeds_and_ledgers_gui.json +++ b/open_stage_control/seeds_and_ledgers_gui.json @@ -466,7 +466,7 @@ "ignoreDefaults": false, "bypass": false, "onCreate": "", - "onValue": "set(\"this\", \"open\", {send:false})", + "onValue": "set(\"ledger_name\", value)\nconsole.log(value)\nconsole.log(\"ASDFASDFASDF\")\nset(\"this\", \"open\", {send:false})\n\n", "align": "center", "hidePath": true, "mode": "open", @@ -1022,7 +1022,7 @@ "ignoreDefaults": false, "bypass": true, "onCreate": "", - "onValue": "send(false, \"/save_ledger\", get(\"ledger\"), get(\"this\"));\nset(\"this\", \"save\", {send:false})", + "onValue": "send(false, \"/save_ledger\", get(\"ledger\"), get(\"this\"));\nset(\"this\", \"save\", {send:false})\nset(\"ledger_name\", value)", "align": "center", "hidePath": true, "mode": "save", @@ -1121,6 +1121,24 @@ "mode": "toggle", "doubleTap": false, "decoupled": false + }, + { + "type": "variable", + "lock": false, + "id": "ledger_name", + "comments": "", + "value": "", + "default": "", + "linkId": "", + "address": "auto", + "preArgs": "", + "typeTags": "", + "decimals": 2, + "target": "", + "ignoreDefaults": false, + "bypass": false, + "onCreate": "", + "onValue": "" } ], "tabs": [], diff --git a/resources/314491/314491_gui_session.json b/resources/314491/314491_gui_session.json deleted file mode 100644 index f0b1a0e..0000000 --- a/resources/314491/314491_gui_session.json +++ /dev/null @@ -1,1400 +0,0 @@ -{ - "createdWith": "Open Stage Control", - "version": "1.22.0", - "type": "session", - "content": { - "type": "root", - "lock": false, - "id": "root", - "visible": true, - "interaction": true, - "comments": "", - "width": "auto", - "height": "auto", - "colorText": "auto", - "colorWidget": "auto", - "alphaFillOn": "auto", - "borderRadius": "auto", - "padding": "auto", - "html": "", - "css": "", - "colorBg": "auto", - "layout": "default", - "justify": "start", - "gridTemplate": "", - "contain": true, - "scroll": true, - "innerPadding": true, - "verticalTabs": false, - "hideMenu": false, - "variables": "@{parent.variables}", - "traversing": false, - "value": "", - "default": "", - "linkId": "", - "address": "auto", - "preArgs": "", - "typeTags": "", - "decimals": 2, - "target": "", - "ignoreDefaults": false, - "bypass": false, - "onCreate": "", - "onValue": "", - "widgets": [ - { - "type": "button", - "top": 460, - "left": 470, - "lock": false, - "id": "transport", - "visible": true, - "interaction": true, - "comments": "", - "width": 110, - "height": 30, - "expand": "false", - "colorText": "auto", - "colorWidget": "auto", - "colorStroke": "auto", - "colorFill": "auto", - "alphaStroke": "auto", - "alphaFillOff": "auto", - "alphaFillOn": "auto", - "lineWidth": "auto", - "borderRadius": "auto", - "padding": "auto", - "html": "", - "css": "", - "colorTextOn": "auto", - "label": "#{@{this} == 0 ? \"play\" : \"stop\"}", - "vertical": false, - "wrap": false, - "on": 1, - "off": 0, - "mode": "toggle", - "doubleTap": false, - "decoupled": false, - "value": "", - "default": "", - "linkId": "", - "address": "auto", - "preArgs": "", - "typeTags": "", - "decimals": 0, - "target": "", - "ignoreDefaults": false, - "bypass": true, - "onCreate": "", - "onValue": "if(value === 1){\n send(false, \"/transport\", 1, get(\"m_size\"));\n} else {\n send(false, \"/transport\", 0, get(\"m_size\"));\n}" - }, - { - "type": "button", - "top": 20, - "left": 470, - "lock": false, - "id": "gen", - "visible": true, - "interaction": true, - "comments": "", - "width": 290, - "height": 30, - "expand": "false", - "colorText": "auto", - "colorWidget": "auto", - "colorStroke": "auto", - "colorFill": "auto", - "alphaStroke": "auto", - "alphaFillOff": "auto", - "alphaFillOn": "auto", - "lineWidth": "auto", - "borderRadius": "auto", - "padding": "auto", - "html": "", - "css": "", - "colorTextOn": "auto", - "label": "generate", - "vertical": false, - "wrap": false, - "on": 1, - "off": 0, - "mode": "push", - "doubleTap": false, - "decoupled": false, - "value": "", - "default": 0, - "linkId": "", - "address": "auto", - "preArgs": "", - "typeTags": "", - "decimals": 2, - "target": "", - "ignoreDefaults": false, - "bypass": true, - "onCreate": "", - "onValue": "if(value === 1){\n var sVal = 1\n var order = null\n var passage = null\n var rVal = get(\"reference_seed\")\n \n if(get(\"current_seed_lock\") == 1){\n sVal = get(\"seed\")\n } else {\n sVal = 1\n }\n \n if(get(\"order_lock\") == 1){\n order = get(\"order\").replace(/\\s/g, \"\")\n send(false, \"/gen\", rVal, sVal, order)\n } else {\n order = get(\"order_size\")\n passage = get(\"passage_size\")\n send(false, \"/gen\", rVal, sVal, \n {\"type\": \"i\", \"value\": order[0]}, \n {\"type\": \"i\", \"value\": order[1]}, \n {\"type\": \"i\", \"value\": passage[0]}, \n {\"type\": \"i\", \"value\": passage[1]});\n }\n\n}" - }, - { - "type": "matrix", - "top": 60, - "left": 120, - "lock": false, - "id": "range_matrix", - "visible": true, - "interaction": true, - "comments": "", - "width": 330, - "height": 260, - "expand": "false", - "colorText": "auto", - "colorWidget": "auto", - "colorStroke": "auto", - "colorFill": "auto", - "alphaStroke": "auto", - "alphaFillOff": "auto", - "alphaFillOn": "auto", - "lineWidth": "auto", - "borderRadius": "auto", - "padding": "auto", - "html": "", - "css": "", - "colorBg": "auto", - "layout": "horizontal", - "justify": "start", - "gridTemplate": "", - "contain": true, - "scroll": true, - "innerPadding": true, - "variables": "@{parent.variables}", - "traversing": false, - "widgetType": "fragment", - "quantity": 4, - "props": "{\n \"file\": \"range_slider.json\",\n \"props\": {\"variables\": {\"n\": #{$} }}\n}", - "value": "", - "default": "", - "linkId": "", - "address": "auto", - "preArgs": "", - "typeTags": "", - "decimals": 2, - "target": "", - "ignoreDefaults": false, - "bypass": true, - "onCreate": "", - "onValue": "", - "widgets": [], - "tabs": [] - }, - { - "type": "input", - "top": 110, - "left": 590, - "lock": false, - "id": "current_seed", - "visible": true, - "interaction": true, - "comments": "", - "width": 130, - "height": "auto", - "expand": "false", - "colorText": "auto", - "colorWidget": "auto", - "colorStroke": "auto", - "colorFill": "auto", - "alphaStroke": "auto", - "alphaFillOff": "auto", - "alphaFillOn": "auto", - "lineWidth": "auto", - "borderRadius": "auto", - "padding": "auto", - "html": "", - "css": "", - "value": "", - "default": "", - "linkId": "", - "address": "auto", - "preArgs": "", - "typeTags": "", - "decimals": 0, - "target": "", - "ignoreDefaults": false, - "bypass": true, - "onCreate": "", - "onValue": "", - "align": "center", - "unit": "", - "asYouType": true, - "numeric": true, - "validation": "", - "maxLength": "" - }, - { - "type": "button", - "top": 110, - "left": 730, - "lock": false, - "id": "current_seed_lock", - "visible": true, - "interaction": true, - "comments": "", - "width": 30, - "height": 30, - "expand": "false", - "colorText": "auto", - "colorWidget": "auto", - "colorStroke": "auto", - "colorFill": "auto", - "alphaStroke": "auto", - "alphaFillOff": "auto", - "alphaFillOn": "auto", - "lineWidth": "auto", - "borderRadius": "auto", - "padding": "auto", - "html": "", - "css": "", - "colorTextOn": "auto", - "label": "L", - "vertical": false, - "wrap": false, - "on": 1, - "off": 0, - "mode": "toggle", - "doubleTap": false, - "decoupled": false, - "value": "", - "default": "", - "linkId": "", - "address": "auto", - "preArgs": "", - "typeTags": "", - "decimals": 2, - "target": "", - "ignoreDefaults": false, - "bypass": true, - "onCreate": "", - "onValue": "" - }, - { - "type": "button", - "top": 500, - "left": 470, - "lock": false, - "id": "commit", - "visible": true, - "interaction": true, - "comments": "", - "width": 110, - "height": 30, - "expand": "false", - "colorText": "auto", - "colorWidget": "auto", - "colorStroke": "auto", - "colorFill": "auto", - "alphaStroke": "auto", - "alphaFillOff": "auto", - "alphaFillOn": "auto", - "lineWidth": "auto", - "borderRadius": "auto", - "padding": "auto", - "html": "", - "css": "", - "value": "", - "default": 0, - "linkId": "", - "address": "auto", - "preArgs": "", - "typeTags": "", - "decimals": 2, - "target": "", - "ignoreDefaults": false, - "bypass": true, - "onCreate": "", - "onValue": "if(value === 1){\n send(false, \"/commit\");\n set(\"reference_seed\", get(\"current_seed\"))\n set(\"current_seed\", \"\")\n}\n ", - "colorTextOn": "auto", - "label": "auto", - "vertical": false, - "wrap": false, - "on": 1, - "off": 0, - "mode": "push", - "doubleTap": false, - "decoupled": false - }, - { - "type": "textarea", - "top": 290, - "left": 470, - "lock": false, - "id": "order", - "visible": true, - "interaction": true, - "comments": "", - "width": 250, - "height": 140, - "expand": false, - "colorText": "auto", - "colorWidget": "auto", - "colorStroke": "auto", - "colorFill": "auto", - "alphaStroke": "auto", - "alphaFillOff": "auto", - "alphaFillOn": "auto", - "lineWidth": "auto", - "borderRadius": "auto", - "padding": "auto", - "html": "", - "css": "textarea {\n white-space: pre;\n line-height: 1.5;\n font-size: 12px;\n}", - "value": "", - "default": "", - "linkId": "", - "address": "auto", - "preArgs": "", - "typeTags": "s", - "decimals": 2, - "target": "", - "ignoreDefaults": false, - "bypass": false, - "onCreate": "", - "onValue": "" - }, - { - "type": "button", - "top": 400, - "left": 730, - "lock": false, - "id": "order_lock", - "visible": true, - "comments": "", - "width": 30, - "height": 30, - "expand": "false", - "colorText": "auto", - "colorWidget": "auto", - "colorStroke": "auto", - "colorFill": "auto", - "alphaStroke": "auto", - "alphaFillOff": "auto", - "alphaFillOn": "auto", - "lineWidth": "auto", - "borderRadius": "auto", - "padding": "auto", - "html": "", - "css": "", - "vertical": false, - "wrap": false, - "value": "", - "default": "", - "linkId": "", - "address": "auto", - "preArgs": "", - "decimals": 2, - "target": "", - "onCreate": "", - "onValue": "", - "interaction": true, - "colorTextOn": "auto", - "label": "L", - "on": 1, - "off": 0, - "mode": "toggle", - "doubleTap": false, - "decoupled": false, - "typeTags": "", - "ignoreDefaults": false, - "bypass": false - }, - { - "type": "text", - "top": 110, - "left": 470, - "lock": false, - "id": "current_seed_label", - "visible": true, - "comments": "", - "width": 110, - "height": 30, - "expand": "false", - "colorText": "auto", - "colorWidget": "auto", - "colorStroke": "auto", - "colorFill": "auto", - "alphaStroke": "auto", - "alphaFillOff": "auto", - "alphaFillOn": "auto", - "lineWidth": "auto", - "borderRadius": "auto", - "padding": "auto", - "html": "", - "css": "", - "align": "center", - "value": "current seed", - "default": "", - "linkId": "", - "address": "auto", - "preArgs": "", - "decimals": 2, - "target": "", - "onCreate": "", - "onValue": "", - "vertical": false, - "wrap": false - }, - { - "type": "input", - "top": 60, - "left": 590, - "lock": false, - "id": "reference_seed", - "visible": true, - "comments": "", - "width": 130, - "height": "auto", - "expand": "false", - "colorText": "auto", - "colorWidget": "auto", - "colorStroke": "auto", - "colorFill": "auto", - "alphaStroke": "auto", - "alphaFillOff": "auto", - "alphaFillOn": "auto", - "lineWidth": "auto", - "borderRadius": "auto", - "padding": "auto", - "html": "", - "css": "", - "align": "center", - "value": "", - "default": "nil", - "linkId": "", - "address": "auto", - "preArgs": "", - "decimals": 0, - "target": "", - "onCreate": "", - "onValue": "", - "interaction": true, - "unit": "", - "asYouType": true, - "numeric": true, - "validation": "", - "maxLength": "", - "typeTags": "", - "ignoreDefaults": false, - "bypass": true - }, - { - "type": "text", - "top": 60, - "left": 470, - "lock": false, - "id": "reference_seed_label", - "visible": true, - "comments": "", - "width": 110, - "height": 30, - "expand": "false", - "colorText": "auto", - "colorWidget": "auto", - "colorStroke": "auto", - "colorFill": "auto", - "alphaStroke": "auto", - "alphaFillOff": "auto", - "alphaFillOn": "auto", - "lineWidth": "auto", - "borderRadius": "auto", - "padding": "auto", - "html": "", - "css": "", - "vertical": false, - "wrap": false, - "value": "reference seed", - "default": "", - "linkId": "", - "address": "auto", - "preArgs": "", - "decimals": 2, - "target": "", - "onCreate": "", - "onValue": "", - "align": "center" - }, - { - "type": "button", - "top": 60, - "left": 730, - "lock": false, - "id": "reference_seed_lock", - "visible": true, - "comments": "", - "width": 30, - "height": 30, - "expand": "false", - "colorText": "auto", - "colorWidget": "auto", - "colorStroke": "auto", - "colorFill": "auto", - "alphaStroke": "auto", - "alphaFillOff": "auto", - "alphaFillOn": "auto", - "lineWidth": "auto", - "borderRadius": "auto", - "padding": "auto", - "html": "", - "css": "", - "vertical": false, - "wrap": false, - "value": "", - "default": "", - "linkId": "", - "address": "auto", - "preArgs": "", - "decimals": 2, - "target": "", - "onCreate": "", - "onValue": "", - "interaction": true, - "colorTextOn": "auto", - "label": "L", - "on": 1, - "off": 0, - "mode": "toggle", - "doubleTap": false, - "decoupled": false, - "typeTags": "", - "ignoreDefaults": false, - "bypass": true - }, - { - "type": "text", - "top": 20, - "left": 120, - "lock": false, - "id": "range_label", - "visible": true, - "comments": "", - "width": 110, - "height": 30, - "expand": "false", - "colorText": "auto", - "colorWidget": "auto", - "colorStroke": "auto", - "colorFill": "auto", - "alphaStroke": "auto", - "alphaFillOff": "auto", - "alphaFillOn": "auto", - "lineWidth": "auto", - "borderRadius": "auto", - "padding": "auto", - "html": "", - "css": "", - "vertical": false, - "wrap": false, - "align": "center", - "value": "ranges", - "default": "", - "linkId": "", - "address": "auto", - "preArgs": "", - "decimals": 2, - "target": "", - "onCreate": "", - "onValue": "" - }, - { - "type": "text", - "top": 160, - "left": 470, - "lock": false, - "id": "orders_label", - "visible": true, - "comments": "", - "width": 110, - "height": 30, - "expand": "false", - "colorText": "auto", - "colorWidget": "auto", - "colorStroke": "auto", - "colorFill": "auto", - "alphaStroke": "auto", - "alphaFillOff": "auto", - "alphaFillOn": "auto", - "lineWidth": "auto", - "borderRadius": "auto", - "padding": "auto", - "html": "", - "css": "", - "vertical": false, - "wrap": false, - "align": "center", - "value": "orders", - "default": "", - "linkId": "", - "address": "auto", - "preArgs": "", - "decimals": 2, - "target": "", - "onCreate": "", - "onValue": "" - }, - { - "type": "text", - "top": 340, - "left": 120, - "lock": false, - "id": "dur_probs_label", - "visible": true, - "comments": "", - "width": 110, - "height": 30, - "expand": "false", - "colorText": "auto", - "colorWidget": "auto", - "colorStroke": "auto", - "colorFill": "auto", - "alphaStroke": "auto", - "alphaFillOff": "auto", - "alphaFillOn": "auto", - "lineWidth": "auto", - "borderRadius": "auto", - "padding": "auto", - "html": "", - "css": "", - "align": "center", - "value": "duration probs", - "default": "", - "linkId": "", - "address": "auto", - "preArgs": "", - "decimals": 2, - "target": "", - "onCreate": "", - "onValue": "", - "vertical": false, - "wrap": false - }, - { - "type": "input", - "top": 460, - "left": 590, - "lock": false, - "id": "m_size", - "visible": true, - "comments": "", - "width": 50, - "height": 30, - "expand": "false", - "colorText": "auto", - "colorWidget": "auto", - "colorStroke": "auto", - "colorFill": "auto", - "alphaStroke": "auto", - "alphaFillOff": "auto", - "alphaFillOn": "auto", - "lineWidth": "auto", - "borderRadius": "auto", - "padding": "auto", - "html": "", - "css": "", - "align": "center", - "value": "", - "default": 3, - "linkId": "", - "address": "auto", - "preArgs": "", - "decimals": 0, - "target": "", - "onCreate": "", - "onValue": "", - "interaction": true, - "typeTags": "", - "ignoreDefaults": false, - "bypass": true, - "unit": "", - "asYouType": true, - "numeric": false, - "validation": "", - "maxLength": "" - }, - { - "type": "text", - "top": 460, - "left": 650, - "lock": false, - "id": "play_label", - "visible": true, - "comments": "", - "width": 110, - "height": 30, - "expand": "false", - "colorText": "auto", - "colorWidget": "auto", - "colorStroke": "auto", - "colorFill": "auto", - "alphaStroke": "auto", - "alphaFillOff": "auto", - "alphaFillOn": "auto", - "lineWidth": "auto", - "borderRadius": "auto", - "padding": "auto", - "html": "", - "css": "", - "value": "motifs to play", - "default": "", - "linkId": "", - "address": "auto", - "preArgs": "", - "decimals": 2, - "target": "", - "onCreate": "", - "onValue": "", - "align": "center", - "vertical": false, - "wrap": false - }, - { - "type": "panel", - "top": 380, - "left": 120, - "lock": false, - "id": "dur_panel", - "visible": true, - "interaction": true, - "comments": "", - "width": 330, - "height": 260, - "expand": "false", - "colorText": "auto", - "colorWidget": "auto", - "colorStroke": "auto", - "colorFill": "auto", - "alphaStroke": "auto", - "alphaFillOff": "auto", - "alphaFillOn": "auto", - "lineWidth": "auto", - "borderRadius": "auto", - "padding": "auto", - "html": "", - "css": "", - "colorBg": "auto", - "layout": "default", - "justify": "start", - "gridTemplate": "", - "contain": true, - "scroll": true, - "innerPadding": true, - "variables": "@{parent.variables}", - "traversing": false, - "value": "", - "default": "", - "linkId": "", - "address": "auto", - "preArgs": "", - "typeTags": "", - "decimals": 2, - "target": "", - "ignoreDefaults": false, - "bypass": false, - "onCreate": "", - "onValue": "", - "widgets": [], - "tabs": [ - { - "type": "tab", - "lock": false, - "id": "entrances", - "visible": true, - "interaction": true, - "comments": "", - "colorText": "auto", - "colorWidget": "auto", - "colorFill": "auto", - "borderRadius": "auto", - "padding": "auto", - "html": "", - "css": "", - "colorBg": "auto", - "layout": "default", - "justify": "start", - "gridTemplate": "", - "contain": true, - "scroll": true, - "innerPadding": true, - "verticalTabs": false, - "label": "auto", - "variables": "@{parent.variables}", - "traversing": false, - "value": "", - "default": "", - "linkId": "", - "address": "auto", - "preArgs": "", - "typeTags": "", - "decimals": 2, - "target": "", - "ignoreDefaults": false, - "bypass": false, - "onCreate": "", - "onValue": "", - "widgets": [], - "tabs": [] - }, - { - "type": "tab", - "lock": false, - "id": "passage", - "visible": true, - "interaction": true, - "comments": "", - "colorText": "auto", - "colorWidget": "auto", - "colorFill": "auto", - "borderRadius": "auto", - "padding": "auto", - "html": "", - "css": "", - "colorBg": "auto", - "layout": "default", - "justify": "start", - "gridTemplate": "", - "contain": true, - "scroll": true, - "innerPadding": true, - "verticalTabs": false, - "label": "auto", - "variables": "@{parent.variables}", - "traversing": false, - "value": "", - "default": "", - "linkId": "", - "address": "auto", - "preArgs": "", - "typeTags": "", - "decimals": 2, - "target": "", - "ignoreDefaults": false, - "bypass": false, - "onCreate": "", - "onValue": "", - "widgets": [ - { - "type": "fragment", - "top": 0, - "left": 0, - "lock": false, - "id": "dur", - "visible": true, - "interaction": true, - "comments": "", - "width": 320, - "height": 210, - "expand": "false", - "css": "", - "file": "env.json", - "fallback": "", - "props": {}, - "address": "auto", - "variables": "@{parent.variables}" - } - ], - "tabs": [] - }, - { - "type": "tab", - "lock": false, - "id": "exits", - "visible": true, - "interaction": true, - "comments": "", - "colorText": "auto", - "colorWidget": "auto", - "colorFill": "auto", - "borderRadius": "auto", - "padding": "auto", - "html": "", - "css": "", - "colorBg": "auto", - "layout": "default", - "justify": "start", - "gridTemplate": "", - "contain": true, - "scroll": true, - "innerPadding": true, - "verticalTabs": false, - "label": "auto", - "variables": "@{parent.variables}", - "traversing": false, - "value": "", - "default": "", - "linkId": "", - "address": "auto", - "preArgs": "", - "typeTags": "", - "decimals": 2, - "target": "", - "ignoreDefaults": false, - "bypass": false, - "onCreate": "", - "onValue": "", - "widgets": [], - "tabs": [] - } - ], - "verticalTabs": false - }, - { - "type": "panel", - "top": 200, - "left": 470, - "lock": false, - "id": "order_size_panel", - "visible": true, - "interaction": true, - "comments": "", - "width": 250, - "height": 40, - "expand": "false", - "colorText": "auto", - "colorWidget": "auto", - "colorStroke": "auto", - "colorFill": "auto", - "alphaStroke": "auto", - "alphaFillOff": "auto", - "alphaFillOn": "auto", - "lineWidth": "auto", - "borderRadius": "auto", - "padding": "auto", - "html": "", - "css": "", - "colorBg": "auto", - "layout": "default", - "justify": "start", - "gridTemplate": "", - "contain": true, - "scroll": true, - "innerPadding": true, - "verticalTabs": false, - "variables": "@{parent.variables}", - "traversing": false, - "value": "", - "default": "", - "linkId": "", - "address": "auto", - "preArgs": "", - "typeTags": "", - "decimals": 2, - "target": "", - "ignoreDefaults": false, - "bypass": false, - "onCreate": "", - "onValue": "", - "widgets": [ - { - "type": "range", - "top": 0, - "left": 40, - "lock": false, - "id": "order_size", - "visible": true, - "interaction": true, - "comments": "", - "width": 160, - "height": 30, - "expand": "false", - "colorText": "auto", - "colorWidget": "auto", - "colorStroke": "auto", - "colorFill": "auto", - "alphaStroke": "auto", - "alphaFillOff": "auto", - "alphaFillOn": "auto", - "lineWidth": "auto", - "borderRadius": "auto", - "padding": "auto", - "html": "", - "css": "", - "design": "default", - "knobSize": "auto", - "horizontal": true, - "pips": false, - "dashed": false, - "gradient": [], - "snap": true, - "spring": false, - "doubleTap": false, - "range": { - "min": 1, - "max": 10 - }, - "logScale": false, - "sensitivity": 1, - "steps": 10, - "value": "", - "default": "", - "linkId": "", - "address": "auto", - "preArgs": "", - "typeTags": "i", - "decimals": 0, - "target": "", - "ignoreDefaults": false, - "bypass": false, - "onCreate": "", - "onValue": "", - "onTouch": "" - }, - { - "type": "input", - "top": 0, - "left": 200, - "lock": false, - "id": "order_size_v2", - "visible": true, - "comments": "", - "width": 40, - "height": 30, - "expand": "false", - "colorText": "auto", - "colorWidget": "auto", - "colorStroke": "auto", - "colorFill": "auto", - "alphaStroke": "auto", - "alphaFillOff": "auto", - "alphaFillOn": "auto", - "lineWidth": "auto", - "borderRadius": "auto", - "padding": "auto", - "html": "", - "css": "", - "align": "center", - "value": "@{order_size.value.1}", - "default": "", - "linkId": "", - "address": "auto", - "preArgs": "", - "decimals": 0, - "target": "", - "onCreate": "", - "onValue": "set(\"order_size\", [get(\"order_size_v1\"), value])", - "interaction": true, - "unit": "", - "asYouType": false, - "numeric": false, - "validation": "", - "maxLength": "", - "typeTags": "i", - "ignoreDefaults": false, - "bypass": false - }, - { - "type": "input", - "top": 0, - "left": 0, - "lock": false, - "id": "order_size_v1", - "visible": true, - "comments": "", - "width": 40, - "height": 30, - "expand": "false", - "colorText": "auto", - "colorWidget": "auto", - "colorStroke": "auto", - "colorFill": "auto", - "alphaStroke": "auto", - "alphaFillOff": "auto", - "alphaFillOn": "auto", - "lineWidth": "auto", - "borderRadius": "auto", - "padding": "auto", - "html": "", - "css": "", - "align": "center", - "value": "@{order_size.value.0}", - "default": "", - "linkId": "", - "address": "auto", - "preArgs": "", - "decimals": 0, - "target": "", - "onCreate": "", - "onValue": "set(\"order_size\", [value, get(\"order_size_v2\")])", - "interaction": true, - "unit": "", - "asYouType": false, - "numeric": false, - "validation": "", - "maxLength": "", - "typeTags": "i", - "ignoreDefaults": false, - "bypass": false - } - ], - "tabs": [] - }, - { - "type": "textarea", - "top": 60, - "left": 780, - "lock": false, - "id": "mus_seq", - "visible": true, - "interaction": true, - "comments": "", - "width": 520, - "height": 570, - "expand": false, - "colorText": "auto", - "colorWidget": "auto", - "colorStroke": "auto", - "colorFill": "auto", - "alphaStroke": "auto", - "alphaFillOff": "auto", - "alphaFillOn": "auto", - "lineWidth": "auto", - "borderRadius": "auto", - "padding": "auto", - "html": "", - "css": "textarea {\n white-space: pre;\n line-height: 1.5;\n font-size: 12px;\n}", - "value": "", - "default": "", - "linkId": "", - "address": "auto", - "preArgs": "", - "typeTags": "s", - "decimals": 2, - "target": "", - "ignoreDefaults": false, - "bypass": false, - "onCreate": "", - "onValue": "" - }, - { - "type": "text", - "top": 20, - "left": 780, - "lock": false, - "id": "motif_label", - "visible": true, - "comments": "", - "width": 110, - "height": 33.888888888888886, - "expand": "false", - "colorText": "auto", - "colorWidget": "auto", - "colorStroke": "auto", - "colorFill": "auto", - "alphaStroke": "auto", - "alphaFillOff": "auto", - "alphaFillOn": "auto", - "lineWidth": "auto", - "borderRadius": "auto", - "padding": "auto", - "html": "", - "css": "", - "vertical": false, - "wrap": false, - "align": "center", - "value": "motif", - "default": "", - "linkId": "", - "address": "auto", - "preArgs": "", - "decimals": 2, - "target": "", - "onCreate": "", - "onValue": "" - }, - { - "type": "panel", - "top": 240, - "left": 470, - "lock": false, - "id": "passage_size_panel", - "visible": true, - "interaction": true, - "comments": "", - "width": 250, - "height": 40, - "expand": "false", - "colorText": "auto", - "colorWidget": "auto", - "colorStroke": "auto", - "colorFill": "auto", - "alphaStroke": "auto", - "alphaFillOff": "auto", - "alphaFillOn": "auto", - "lineWidth": "auto", - "borderRadius": "auto", - "padding": "auto", - "html": "", - "css": "", - "colorBg": "auto", - "layout": "default", - "justify": "start", - "gridTemplate": "", - "contain": true, - "scroll": true, - "innerPadding": true, - "verticalTabs": false, - "variables": "@{parent.variables}", - "traversing": false, - "value": "", - "default": "", - "linkId": "", - "address": "auto", - "preArgs": "", - "typeTags": "", - "decimals": 2, - "target": "", - "ignoreDefaults": false, - "bypass": false, - "onCreate": "", - "onValue": "", - "widgets": [ - { - "type": "range", - "top": 0, - "left": 40, - "lock": false, - "id": "passage_size", - "visible": true, - "interaction": true, - "comments": "", - "width": 160, - "height": 30, - "expand": "false", - "colorText": "auto", - "colorWidget": "auto", - "colorStroke": "auto", - "colorFill": "auto", - "alphaStroke": "auto", - "alphaFillOff": "auto", - "alphaFillOn": "auto", - "lineWidth": "auto", - "borderRadius": "auto", - "padding": "auto", - "html": "", - "css": "", - "design": "default", - "knobSize": "auto", - "horizontal": true, - "pips": false, - "dashed": false, - "gradient": [], - "snap": true, - "spring": false, - "doubleTap": false, - "range": { - "min": 0, - "max": 10 - }, - "logScale": false, - "sensitivity": 1, - "steps": 11, - "value": "", - "default": "", - "linkId": "", - "address": "auto", - "preArgs": "", - "typeTags": "", - "decimals": 0, - "target": "", - "ignoreDefaults": false, - "bypass": false, - "onCreate": "", - "onValue": "", - "onTouch": "" - }, - { - "type": "input", - "top": 0, - "left": 200, - "lock": false, - "id": "passage_size_v2", - "visible": true, - "comments": "", - "width": 40, - "height": 30, - "expand": "false", - "colorText": "auto", - "colorWidget": "auto", - "colorStroke": "auto", - "colorFill": "auto", - "alphaStroke": "auto", - "alphaFillOff": "auto", - "alphaFillOn": "auto", - "lineWidth": "auto", - "borderRadius": "auto", - "padding": "auto", - "html": "", - "css": "", - "align": "center", - "value": "@{passage_size.value.1}", - "default": "", - "linkId": "", - "address": "auto", - "preArgs": "", - "decimals": 0, - "target": "", - "onCreate": "", - "onValue": "set(\"passage_size\", [get(\"passage_size_v1\"), value])", - "interaction": true, - "unit": "", - "asYouType": false, - "numeric": false, - "validation": "", - "maxLength": "", - "typeTags": "", - "ignoreDefaults": false, - "bypass": false - }, - { - "type": "input", - "top": 0, - "left": 0, - "lock": false, - "id": "passage_size_v1", - "visible": true, - "comments": "", - "width": 40, - "height": 30, - "expand": "false", - "colorText": "auto", - "colorWidget": "auto", - "colorStroke": "auto", - "colorFill": "auto", - "alphaStroke": "auto", - "alphaFillOff": "auto", - "alphaFillOn": "auto", - "lineWidth": "auto", - "borderRadius": "auto", - "padding": "auto", - "html": "", - "css": "", - "align": "center", - "value": "@{passage_size.value.0}", - "default": "", - "linkId": "", - "address": "auto", - "preArgs": "", - "decimals": 0, - "target": "", - "onCreate": "", - "onValue": "set(\"passage_size\", [value, get(\"passage_size_v2\")])", - "interaction": true, - "unit": "", - "asYouType": false, - "numeric": false, - "validation": "", - "maxLength": "", - "typeTags": "", - "ignoreDefaults": false, - "bypass": false - } - ], - "tabs": [] - } - ], - "tabs": [] - } -} \ No newline at end of file diff --git a/resources/314491/314491_gui_state.state b/resources/314491/314491_gui_state.state deleted file mode 100644 index e251d50..0000000 --- a/resources/314491/314491_gui_state.state +++ /dev/null @@ -1,177 +0,0 @@ -{ - "transport": 0, - "rangeslider_0_v1": -837.209302325582, - "rangeslider_0": [ - -837.209302325582, - 1227.9069767441865 - ], - "rangeslider_0_v2": 1227.9069767441865, - "range_panel": -1, - "rangeslider_1_v1": -613.953488372093, - "rangeslider_1": [ - -613.953488372093, - 1395.348837209302 - ], - "rangeslider_1_v2": 1395.348837209302, - "rangeslider_2_v1": -1116.279069767442, - "rangeslider_2": [ - -1116.279069767442, - 753.4883720930229 - ], - "rangeslider_2_v2": 753.4883720930229, - "rangeslider_3_v1": -725.5813953488375, - "rangeslider_3": [ - -725.5813953488375, - 976.7441860465119 - ], - "rangeslider_3_v2": 976.7441860465119, - "range_matrix": [ - null, - null, - null, - null - ], - "current_seed": 314491, - "current_seed_lock": 1, - "commit": 0, - "order_lock": 0, - "current_seed_label": "current seed", - "reference_seed": "nil", - "reference_seed_label": "reference seed", - "reference_seed_lock": 1, - "range_label": "ranges", - "orders_label": "orders", - "dur_probs_label": "duration probs", - "m_size": 1, - "play_label": "motifs to play", - "entrances": [ - 0, - 0 - ], - "dur_probs_size": 3, - "dur_probs_canvas": [ - [ - 0, - 0.5 - ], - [ - 0.5, - 0.5 - ], - [ - 1, - 0.5 - ], - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - ], - "dur_probs_slider": [ - 0.6147540983606558, - 1.51639344262295 - ], - "dur_probs_rslider_v2": 1.51639344262295, - "dur_probs_rslider_v1": 0.6147540983606558, - "dur_probs_mpos": "", - "dur_probs_env": [ - 0.6147540983606558, - 1.51639344262295, - 0, - 0, - 0.5, - 0.5, - 0.5, - 1, - 0.5 - ], - "dur_probs_flatten": 0, - "dur_probs_chord_prob": 0, - "text_1": "chord prob", - "dur_probs": -1, - "passage": -1, - "exits": [ - 0, - 0 - ], - "order_size": [ - 2, - 6 - ], - "order_size_v2": 6, - "order_size_v1": 2, - "order_size_panel": -1, - "motif_label": "motif", - "passage_size": [ - 8, - 10 - ], - "passage_size_v2": 10, - "passage_size_v1": 8, - "passage_size_panel": -1, - "root": [ - 0, - 0 - ], - "mus_seq": "[\n [\n [\n [ [ [ 0, 0, 0, 0, 0, 0 ], [ \"Rest\" ], [ \"Rest\" ], [ \"Rest\" ] ], 0.875 ],\n [ [ [ 0, 0, 0, 0, 0, 0 ], [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, 0 ], [ 1, 0, 0, -1, -1, 0 ] ], 0.75 ],\n [ [ [ 2, 0, 0, 0, -1, -1 ], [ 1, -1, 0, 0, -1, 0 ], [ 0, 0, 0, 0, -1, 0 ], [ 1, 0, 0, -1, -1, 0 ] ], 1.0 ]\n ],\n [\n [ [ [ 2, 0, 0, 0, -1, -1 ], [ 1, -1, 0, 0, -1, 0 ], [ \"Rest\" ], [ 1, 0, 0, -1, -1, 0 ] ], 0.75 ],\n [ [ [ 2, 0, 0, 0, -1, -1 ], [ 1, -1, 0, 0, -1, 0 ], [ \"Rest\" ], [ 0, -1, 0, 1, -1, 0 ] ], 1.0 ],\n [ [ [ 2, -1, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ \"Rest\" ], [ 0, -1, 0, 1, -1, 0 ] ], 0.875 ],\n [ [ [ 2, -1, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ \"Rest\" ], [ 0, -1, 0, 0, -1, 1 ] ], 1.25 ],\n [ [ [ 1, -1, 0, 1, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ \"Rest\" ], [ 0, -1, 0, 0, -1, 1 ] ], 1.125 ],\n [ [ [ 1, -1, 0, 1, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ \"Rest\" ], [ 1, -1, -1, 0, -1, 0 ] ], 1.0 ],\n [ [ [ 1, 0, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ \"Rest\" ], [ 1, -1, -1, 0, -1, 0 ] ], 0.75 ],\n [ [ [ 1, -1, 0, 0, 0, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ \"Rest\" ], [ 1, -1, -1, 0, -1, 0 ] ], 0.625 ],\n [ [ [ 1, -1, 0, 0, 0, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ \"Rest\" ], [ 0, -1, 0, 0, 0, 0 ] ], 0.75 ],\n [ [ [ 1, -1, 0, 0, 0, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ \"Rest\" ], [ 1, -1, 0, 0, -2, 0 ] ], 1.375 ],\n [ [ [ 2, -2, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ \"Rest\" ], [ 1, -1, 0, 0, -2, 0 ] ], 0.875 ],\n [ [ [ 2, -2, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ \"Rest\" ], [ 0, -1, 0, 0, -1, 1 ] ], 1.375 ],\n [ [ [ 2, -2, 0, 0, -1, 0 ], [ \"Rest\" ], [ \"Rest\" ], [ 0, -1, 0, 0, -1, 1 ] ], 1.5 ],\n [ [ [ \"Rest\" ], [ \"Rest\" ], [ \"Rest\" ], [ 0, -1, 0, 0, -1, 1 ] ], 1.375 ],\n [ [ [ \"Rest\" ], [ \"Rest\" ], [ \"Rest\" ], [ \"Rest\" ] ], 1.0 ]\n ]\n ]\n]", - "order": "[\n [ [ 0, 3 ], [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ], [ 2 ] ],\n [ [ 3 ], [ 0, 2, 0, 0, 2, 2, 0, 0, 0, 0 ], [ 1 ] ],\n [ [ 2 ], [ 1, 3, 0, 1, 1, 0, 3, 3, 1, 0, 0, 1 ], [ ] ],\n [ [ 1 ], [ 3, 0, 3, 0, 3, 0, 0, 3, 3, 0, 3 ], [ 2 ] ]\n]", - "dur_panel": 1, - "gen": 0 -} \ No newline at end of file diff --git a/resources/314s49e1/lilypond/part_I.ly b/resources/314s49e1/lilypond/part_I.ly deleted file mode 100644 index b857590..0000000 --- a/resources/314s49e1/lilypond/part_I.ly +++ /dev/null @@ -1,56 +0,0 @@ -{ - { r4 r8.[ c'16^\markup { \pad-markup #0.2 "+0"}] ~ c'2 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" \break - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" \break - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 } - \bar "|" \break - { b4^\markup { \pad-markup #0.2 "+47"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 11↓" }} ~ b2. ~ } - \bar "|" - { b1 ~ } - \bar "|" - { b4 ~ b8[ ais8^\markup { \pad-markup #0.2 "+35"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 5↑" }}] ~ ais8.[ a16^\markup { \pad-markup #0.2 "-20"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 7↓" }}] ~ a4 ~ } - \bar "|" - { a1 ~ } - \bar "|" \break - { a1 ~ } - \bar "|" - { a1 ~ } - \bar "|" - { a16[ a8.^\markup { \pad-markup #0.2 "+16"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "III"\normal-size-super " 7↑" }}] ~ a2. } - \bar "|" - { gis4^\markup { \pad-markup #0.2 "-13"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 13↑" }} ~ gis2. ~ } - \bar "|" \break - { gis8.[ gis16^\markup { \pad-markup #0.2 "-40"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "III"\normal-size-super " 5↓" }}] ~ gis2. ~ } - \bar "|" - { gis4 ~ gis8[ f8^\markup { \pad-markup #0.2 "-2"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 1↑" }}] ~ f4 fis4^\markup { \pad-markup #0.2 "-5"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "III"\normal-size-super " 11↓" }} ~ } - \bar "|" - { fis2. ~ fis8[ gis8^\markup { \pad-markup #0.2 "-13"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "III"\normal-size-super " 13↑" }}] ~ } - \bar "|" - { gis1 ~ } - \bar "|" \break - { gis1 ~ } - \bar "|" - { gis1 } - \bar "|" - { r1 } -\bar "||" -} \ No newline at end of file diff --git a/resources/314s49e1/lilypond/part_II.ly b/resources/314s49e1/lilypond/part_II.ly deleted file mode 100644 index 003a738..0000000 --- a/resources/314s49e1/lilypond/part_II.ly +++ /dev/null @@ -1,56 +0,0 @@ -{ - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" \break - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" - { r16[ ais8.^\markup { \pad-markup #0.2 "-31"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "I"\normal-size-super " 7↑" }}] ~ ais2. ~ } - \bar "|" \break - { ais2. gis4^\markup { \pad-markup #0.2 "+14"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "I"\normal-size-super " 5↓" }} ~ } - \bar "|" - { gis16[ fis8.^\markup { \pad-markup #0.2 "+49"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "I"\normal-size-super " 11↓" }}] ~ fis2. ~ } - \bar "|" - { fis1 ~ } - \bar "|" - { fis1 ~ } - \bar "|" \break - { fis1 ~ } - \bar "|" - { fis1 ~ } - \bar "|" - { fis1 ~ } - \bar "|" - { fis1 ~ } - \bar "|" \break - { fis1 ~ } - \bar "|" - { fis2 ~ fis8.[ r16] r4 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" \break - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" \break - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } -\bar "||" -} \ No newline at end of file diff --git a/resources/314s49e1/lilypond/part_III.ly b/resources/314s49e1/lilypond/part_III.ly deleted file mode 100644 index 5890e54..0000000 --- a/resources/314s49e1/lilypond/part_III.ly +++ /dev/null @@ -1,56 +0,0 @@ -{ - { r2. e'4^\markup { \pad-markup #0.2 "-41"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 13↓" }} ~ } - \bar "|" - { e'2 e'4^\markup { \pad-markup #0.2 "-14"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 5↑" }} ~ e'8.[ f'16^\markup { \pad-markup #0.2 "-2"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 3↓" }}] ~ } - \bar "|" - { f'4 ~ f'8[ g'8^\markup { \pad-markup #0.2 "+2"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 3↑" }}] ~ g'4 ~ g'8[ ais'8^\markup { \pad-markup #0.2 "-31"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 7↑" }}] ~ } - \bar "|" - { ais'4 ~ ais'8[ c''8^\markup { \pad-markup #0.2 "+0"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 1↑" }}] ~ c''2 } - \bar "|" \break - { gis'4^\markup { \pad-markup #0.2 "+41"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 13↑" }} ~ gis'8.[ gis'16^\markup { \pad-markup #0.2 "+14"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 5↓" }}] ~ gis'4 ~ gis'8[ f'8^\markup { \pad-markup #0.2 "-2"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 3↓" }}] ~ } - \bar "|" - { f'2 e'4^\markup { \pad-markup #0.2 "-14"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 5↑" }} ~ e'8[ r8] } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" \break - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" - { r2 r16[ dis'8.^\markup { \pad-markup #0.2 "-38"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 5↓" }}] ~ dis'4 ~ } - \bar "|" \break - { dis'1 ~ } - \bar "|" - { dis'8[ dis'8^\markup { \pad-markup #0.2 "-11"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 13↑" }}] ~ dis'2 d'4^\markup { \pad-markup #0.2 "-49"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 3↑" }} ~ } - \bar "|" - { d'1 ~ } - \bar "|" - { d'4 ~ d'8[ ais8^\markup { \pad-markup #0.2 "+35"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 5↑" }}] ~ ais2 ~ } - \bar "|" \break - { ais1 ~ } - \bar "|" - { ais8.[ b16^\markup { \pad-markup #0.2 "+47"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 3↓" }}] ~ b2. ~ } - \bar "|" - { b1 ~ } - \bar "|" - { b1 ~ } - \bar "|" \break - { b1 ~ } - \bar "|" - { b1 ~ } - \bar "|" - { b1 ~ } - \bar "|" - { b1 ~ } - \bar "|" \break - { b2 ~ b16[ r8.] r4 } - \bar "|" - { r1 } - \bar "|" - { r1 } -\bar "||" -} \ No newline at end of file diff --git a/resources/314s49e1/lilypond/part_IV.ly b/resources/314s49e1/lilypond/part_IV.ly deleted file mode 100644 index 059a0bb..0000000 --- a/resources/314s49e1/lilypond/part_IV.ly +++ /dev/null @@ -1,56 +0,0 @@ -{ - { c'4^\markup { \pad-markup #0.2 "+0"} ~ c'2. ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" \break - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'4 ~ c'16[ e'8.^\markup { \pad-markup #0.2 "-41"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "I"\normal-size-super " 13↓" }}] ~ e'2 ~ } - \bar "|" - { e'2 ~ e'8.[ g'16^\markup { \pad-markup #0.2 "+2"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "I"\normal-size-super " 3↑" }}] ~ g'4 ~ } - \bar "|" \break - { g'4 ~ g'8[ ais'8^\markup { \pad-markup #0.2 "-31"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 1↑" }}] ~ ais'2 ~ } - \bar "|" - { ais'4 ~ ais'8.[ gis'16^\markup { \pad-markup #0.2 "+41"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "I"\normal-size-super " 13↑" }}] ~ gis'2 } - \bar "|" - { gis'2^\markup { \pad-markup #0.2 "+14"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "I"\normal-size-super " 5↓" }} ~ gis'8[ g'8^\markup { \pad-markup #0.2 "+2"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "I"\normal-size-super " 3↑" }}] ~ g'4 ~ } - \bar "|" - { g'8[ f'8^\markup { \pad-markup #0.2 "-2"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "I"\normal-size-super " 3↓" }}] ~ f'2. ~ } - \bar "|" \break - { f'4 ~ f'8[ e'8^\markup { \pad-markup #0.2 "+18"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 7↑" }}] ~ e'2 ~ } - \bar "|" - { e'1 ~ } - \bar "|" - { e'16[ fis'8.^\markup { \pad-markup #0.2 "+49"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 1↑" }}] ~ fis'2. ~ } - \bar "|" - { fis'1 ~ } - \bar "|" \break - { fis'16[ a'8.^\markup { \pad-markup #0.2 "-20"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "I"\normal-size-super " 1↑" }}] ~ a'2 ~ a'16[ ais'8.^\markup { \pad-markup #0.2 "+8"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 13↓" }}] ~ } - \bar "|" - { ais'1 ~ } - \bar "|" - { ais'2 ~ ais'16[ b'8.^\markup { \pad-markup #0.2 "+47"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "III"\normal-size-super " 1↑" }}] ~ b'4 ~ } - \bar "|" - { b'2 ~ b'8[ a'8^\markup { \pad-markup #0.2 "+16"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "III"\normal-size-super " 7↑" }}] ~ a'4 ~ } - \bar "|" \break - { a'2 ~ a'8.[ fis'16^\markup { \pad-markup #0.2 "+49"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "III"\normal-size-super " 3↑" }}] ~ fis'4 ~ } - \bar "|" - { fis'16[ f'8.^\markup { \pad-markup #0.2 "-2"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "III"\normal-size-super " 11↑" }}] ~ f'2. ~ } - \bar "|" - { f'4 ~ f'8.[ e'16^\markup { \pad-markup #0.2 "+45"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "III"\normal-size-super " 3↓" }}] ~ e'2 ~ } - \bar "|" - { e'1 ~ } - \bar "|" \break - { e'1 ~ } - \bar "|" - { e'4 ~ e'16[ r8.] r2 } - \bar "|" - { r1 } -\bar "||" -} \ No newline at end of file diff --git a/resources/430a1ec1/430a1ec1_code.scd b/resources/430a1ec1/430a1ec1_code.scd deleted file mode 100644 index 70eb49e..0000000 --- a/resources/430a1ec1/430a1ec1_code.scd +++ /dev/null @@ -1,1058 +0,0 @@ -( -// helper funcs -var hsArrayToCents, pDist, hdSum, hsChordalDistance, hsArrayToFreq; - -// score funcs -var isInRange, spacingScore, rangeScore, intervalScore, inclusionScore; - -// subroutines -var genTuples, initVoices, genOrders, genSubMotif, updateVoices, genDurFunc, genStepFunc; - -// primary routines -var genMotif, genSecondarySeq; - -// audition funcs -var genPatterns, genMidiPatterns; - -// resource management funcs -var seedFunc, genUID, writeResources, stringifyToDepth, setSeeds, sanityCheck, -msgInterpret, loadLedgerFile, loadLedgerJSON, loadModelFile, loadModelJSON, -setGlobalVars, globalVarsToDict, saveLedger; - -// model vars -//(model and global vars mostly set by OSC funcs -var seq, lastXChanges, -curUID, refUID, orderSeed, durSeed, motifSeed, -entrancesProbVals, passagesProbVals, exitsProbVals, -ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, -orders, susWeights, orderSize, passagesSize, -motifEdited, orderEdited; - -// model aux vars -var entrancesDurFunc, passagesDurFunc, exitsDurFunc, stepFunc; - -// other global vars -var popSize, exPath, dir, primes, dims, tuples, -group, player, ledgerPath, ledger, currentlyPlayingUID, -nameSpaces; - -// install JSON quark -if(Quarks.isInstalled("JSONlib").not, { - Quarks.install("https://github.com/musikinformatik/JSONlib.git"); - thisProcess.recompile; - //HelpBrowser.openHelpFor("Classes/JSONlib"); -}); - - -//------helper funcs - -hsArrayToCents = { - arg hsArray; - hsArray.collect({arg dist, p; dist * 1200 * log2(primes[p][0]/primes[p][1])}).sum -}; - -pDist = { - arg array1, array2, signed = false; - var pDistance; - pDistance = hsArrayToCents.value(array1) - hsArrayToCents.value(array2); - if(signed, {pDistance}, {abs(pDistance)}) -}; - -hdSum = { - arg hsArrays; - var size, distances, mean; - size = hsArrays.size; - distances = (size - 1).collect({arg i; - ((i + 1)..(size - 1)).collect({arg j; - abs(hsArrays[i] - hsArrays[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsChordalDistance = { - arg hsArrays1, hsArrays2; - var size, distances, mean; - size = hsArrays1.size; - distances = hsArrays1.size.collect({arg i; - hsArrays2.size.collect({arg j; - abs(hsArrays1[i] - hsArrays2[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsArrayToFreq = { - arg array; - array.collect({arg dim, d; pow(primes[d][0]/primes[d][1], dim)}).product -}; - -//------score funcs - -/* -isInRange = { - arg hsArray, min, max; - var cents; - cents = hsArrayToCents.value(hsArray); - (cents >= min) && (cents <= max) -}; -*/ - -spacingScore = { - arg hsArrays, min; - var centsArray; - centsArray = hsArrays.collect({arg hsArray; hsArrayToCents.value(hsArray)}).sort({arg a, b; a < b}); - centsArray.differentiate.drop(1).collect({arg pDistance; if(pDistance >= min, {1}, {0.01})}).sum; -}; - -rangeScore = { - arg hsArray1, hsArray2, min, max, low, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - if((pDistance >= min) && (pDistance <= max), {1}, {low}); -}; - -intervalScore = { - arg hsArray1, hsArray2, mean, sd, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - //pDistance.gaussCurve(1, mean, sd) - stepFunc.value(pDistance); -}; - -inclusionScore = { - arg array, test, min = 0.01; - if(array.collect({arg v; v.hash}).includes(test.hash), {min}, {1}); -}; - - -//------subroutines - -genTuples = { - var tuples; - tuples = dims.collect({[-1, 0, 1]}).allTuples.select({arg tuple; (abs(tuple.drop(1)).sum <= 1) && (tuple[0] == 0)}); - tuples = tuples ++ tuples.collect({arg tuple; [-3, -2, -1, 1, 2, 3].collect({arg octTrans; tuple.deepCopy.put(0, octTrans)})}).flatten; -}; - -initVoices = { - var init, voicesInit; - voicesInit = popSize.collect({dims.collect({0})}); - /* - voicesInit = [dims.collect({0})]; - (popSize - 1).do({ - arg rep, new; - rep = dims.rand; - new = voicesInit.last.deepCopy; - new[rep] = new[rep] + [-1, 1].choose(); - voicesInit = voicesInit.add(new); - }); - */ - voicesInit.deepCopy; -}; - -genDurFunc = {arg chordProb, minPad, maxPad, minDur, maxDur, envData, seed; - var env, pTable, durFunc; - env = Env.pairs([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).asSignal(256).asList.asArray; - pTable = env.asRandomTable; - [chordProb, minPad, maxPad, minDur, maxDur, envData].postln; - durFunc = {arg allowChord, pad = false; - var res; - res = if(allowChord.not, { - pTable.tableRand * (maxDur - minDur) + minDur - }, { - if(1.0.rand < chordProb, {0}, {pTable.tableRand * (maxDur - minDur) + minDur}); - }).round(0.125); - if(pad, {res = res + rrand(minPad.asFloat, maxPad.asFloat).round(0.125)}); - if(res.asInteger == res, {res = res.asInteger}); - res - }; - seedFunc.value(durFunc, seed); -}; - -genStepFunc = {arg minStep, maxStep, envData, seed; - var envDataNorm, env, pTable, stepFunc; - [minStep, maxStep, envData].postln; - envDataNorm = ([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).flop; - envDataNorm = [envDataNorm[0].normalize(minStep, maxStep), envDataNorm[1]].flop; - env = Env.pairs(envDataNorm); - stepFunc = {arg pDist; - env.at(pDist).clip(0.001, 1); - }; - seedFunc.value(stepFunc, seed); -}; - -genOrders = {arg minMotifLength = 1, maxMotifLength = 5, minProgLength = 0, maxProgLength = 5; - ((maxMotifLength - minMotifLength).rand + minMotifLength).collect({ - var noProgIns, noSusIns, noSilentIns, prog, sus, silent, order; - noSusIns = [1, 2, 3].wchoose(susWeights.normalizeSum); - noProgIns = (popSize - noSusIns).rand + 1; - noSilentIns = popSize - noSusIns - noProgIns; - - # prog, sus, silent = (0..(popSize-1)).scramble.clumps([noProgIns, noSusIns, noSilentIns]); - - prog = (prog.scramble ++ ((maxProgLength - minProgLength).rand + minProgLength).collect({prog.choose}).scramble); - if(silent == nil, {silent = []}); - [sus.scramble, prog, silent.scramble] - }); -}; - -updateVoices = {arg ins, sus; - var voices, candidates, nWeights, nProbs, sel; - - voices = lastXChanges.deepCopy.last; - - candidates = sus.collect({arg v; tuples.collect({arg t; voices[v] + t})}).flatten; - candidates = difference(candidates.asSet, voices.asSet).asList; - nProbs = candidates.collect({arg candidate; - var stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore; - - //stepScore = intervalScore.value(voices[ins], candidate, 30, 400, 0.1); - stepScore = intervalScore.value(voices[ins], candidate, 100, 100); - recentlySoundedScore = inclusionScore.value(lastXChanges.flop[ins], candidate, 0); - isInRangeScore = rangeScore.value(candidate, candidate.collect({0}), ranges[ins][0], ranges[ins][1], 0, true); - regScore = spacingScore.value(voices.deepCopy.put(ins, candidate), 300); - hdScore = pow(hdSum.value(voices.deepCopy.put(ins, candidate)), hdExp); - if(hdInvert == 0, {hdScore = 1/hdScore}); - //maybe what you want here is a vector to another root and then favoring movement towards it. - //distScore = pow(hsChordalDistance.value(voices, voices.put(ins, candidate)), 2); - - [stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore] - }); - - nWeights = passagesWeights; - - //this handles nWeights of 0; mainly for testing - nProbs = nProbs.flop.select({arg scores, s; nWeights[s] != 0}).flop; - nWeights = nWeights.select({arg weight; weight != 0}); - nProbs = nProbs.flop.collect({arg scores, s; - if(scores.sum == 0, {scores}, {scores.normalizeSum * nWeights[s]}) - }); - nProbs = nProbs.flop.collect({arg scores, s; scores.product}).normalizeSum; - - sel = candidates.wchoose(nProbs); - - voices[ins] = sel; - lastXChanges = lastXChanges.add(voices).keep(-5); -}; - -genSubMotif = {arg order, orderIndex, lastState, repeatLast = false, startFromLast = false, isLastOrder = false; - var sus, prog, silent, flatOrder, res, isInChord, allowChord, pad, lastXChangesHold, voices, adder; - # sus, prog, silent = order; - flatOrder = silent ++ sus ++ prog; - lastXChangesHold = lastXChanges.deepCopy; - voices = lastState.deepCopy; - isInChord = popSize.collect({false}); - allowChord = false; - pad = false; - res = []; - "------generating motif".postln; - //need to figure out here if voices move between motifs - flatOrder.do({arg ins, i; - - if(prog.includes(ins) && repeatLast.not, {updateVoices.value(ins, sus)}); - adder = if(silent.includes(ins), {["Rest"]}, {lastXChanges.last.deepCopy[ins]}); - - if(voices[ins] != adder, { - var dur; - - if((sus ++ silent).includes(ins), { - allowChord = (ins != sus.last); - pad = (ins == sus.last); - }, { - if(i < (flatOrder.size - 1), { - allowChord = (isInChord[flatOrder[i + 1]] || (ins == flatOrder[i + 1])).not; - pad = false; - }, { - allowChord = false; - pad = true - }); - }); - if((orderIndex == 0) && sus.includes(ins), { - dur = entrancesDurFunc.value(allowChord, pad); - }, { - dur = passagesDurFunc.value(allowChord, pad); - }); - if(dur == 0, {isInChord[ins] = true}, {isInChord = popSize.collect({false})}); - - voices[ins] = adder; - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - - // pad ending - if(orderIndex == (orders.size - 1), { - (0..(popSize-1)).scramble.do({arg ins; - if(res.last.first[ins] != ["Rest"], { - var dur; - voices[ins] = ["Rest"]; - allowChord = (voices != popSize.collect({["Rest"]})); - pad = allowChord.not; - dur = exitsDurFunc.value(allowChord, pad); - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - }); - - //format and return - if(startFromLast, {lastXChanges = lastXChangesHold.deepCopy}); - res; -}; - - -//------primary routines - -genMotif = { - var repeats, fSeq, fDur, durAdd; - - repeats = 1; - fSeq = []; - - repeats.do({arg index; - var motif; - - motif = []; - - orders.do({arg order, o; - var lastState, subMotif; - lastState = if(o == 0, {popSize.collect({["Rest"]})}, {motif.last.last.first}); - subMotif = genSubMotif.value(order, o, lastState, isLastOrder: o == (orders.size - 1)); - motif = motif.add(subMotif); - - }); - - sanityCheck.value(motif, index); - - fSeq = fSeq.add(motif); - }); - - //round last duration to measure - fDur = fSeq.flatten.flatten.slice(nil, 1).sum; - durAdd = fDur.round(4) - fDur; - if(durAdd < 0, {durAdd = 4 - durAdd}); - fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] = fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] + durAdd; - - fSeq -}; - -genSecondarySeq = {arg seq; - var curdles, fSeq; - curdles = []; - while({curdles.sum < seq.size}, {curdles = curdles ++ [3.rand + 1]}); - - fSeq = seq.clumps(curdles).collect({arg clump, m; - var repeats, paddedSeq; - - //add rest - paddedSeq = clump.add([[[popSize.collect({["Rest"]}), 0.5.rand]]]); - - //implement repeats - repeats = [0.rand + 1, 1].wchoose([1, 0].normalizeSum); - repeats.collect({paddedSeq}); - }); - fSeq -}; - - -//------audition funcs - -/* -Event.addEventType(\osc, { - if (~addr.postln.notNil) { - ~addr.sendMsg(~indexPath, ~indexMsg); - ~addr.sendMsg(~seqPath, stringifyToDepth.value(~seqMsg, 3)); - //~addr.sendMsg("/STATE/OPEN", (dir.replace("supercollider", "resources") +/+ ~idMsg +/+ ~idMsg ++ "_gui_state" ++ ".state").standardizePath.postln); - }; -}); -*/ - -Event.addEventType(\osc, { - if (~addr.notNil) { - ~msg; - ~addr.sendMsg(~path, *~msg); - }; -}); - -genPatterns = {arg inSeq, addr, oneShot = false; - var voices, durs, pbinds, res, indices, sectionDurs, msg, ids, seq; - seq = inSeq.collect({arg mSeq; mSeq[0]}); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - pbinds = voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs, attacks, rels, amps; - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - //attacks = 2.collect({rrand(1, 3)}) ++ freqs.drop(2).collect({rrand(0.3, 0.5)}); - attacks = fDurs.collect({arg dur; dur * rrand(0.2, 0.4)}); - //rels = freqs.drop(2).collect({rrand(0.3, 0.5)}) ++ 2.collect({rrand(1, 3)}); - rels = (clumps.size - 1).collect({arg c; - if(clumps[c + 1][0] == ["Rest"], {rrand(1.0, 3.0)}, {rrand(0.3, 0.5)}); - }); - rels = rels.add(rrand(1.0, 3.0)); - amps = freqs.collect({rrand(0.6, 0.99)}); - - [ - Pbind( - \instrument, \string_model, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \attack, Pseq(attacks, 1), - \sustain, Pseq(fDurs, 1), - \release, Pseq(rels, 1), - //\amp, Pseq(amps, 1), - \amp, Pbrown(0.5, 1, 0.5), - \busIndex, v - ), - Pbind( - \instrument, \sine, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \sustain, Pseq(fDurs, 1), - \busIndex, v - ) - ] - }).flatten; - if(oneShot.not, { - msg = inSeq.collect({arg mSeq, m; mSeq[1..]}); - //ids = inSeq.collect({arg mSeq, m; mSeq[2]}); - sectionDurs = seq.collect({arg mSeq; mSeq.flatten2(mSeq.maxDepth - 5).flop[1].sum}); - pbinds = pbinds ++ - [ - Pbind( - \type, \osc, - \addr, addr, - \path, "/playing", - \msg, Pseq(msg, 1), - \dur, Pseq(sectionDurs, 1) - ); - ] - }); - res = Ppar(pbinds); - res -}; - -/* -genMidiPatterns = {arg seq; - var voices, durs, patterns, res, mOut, pbRange; - pbRange = 1; //semitones - change this as needed for your situation - mOut = MIDIOut.newByName("TiMidity", "TiMidity port 0").latency_(Server.default.latency); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - res = Ppar( - voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs; - - mOut.program(v, 70); - - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - - Pbind( - \type, \midi, - \chan, v, - \noteval, Pseq(freqs.cpsmidi - 24, 1), - \note, Pfunc({ | event | event[\noteval].floor }), - \dur, Pseq(fDurs, 1), - \midiout, mOut, - \amp, 1, - \bend, Pfunc({ - | event | - if (event[\note].isRest.not) { - var pitchbendvalue = event[\noteval].frac.linlin(0, pbRange, 8192, 8192*2).asInteger; - m.bend(v, pitchbendvalue); - }; - 0; // return something other than nil to avoid stopping the pattern - }), - ); - }); - ); - res -}; -*/ - - -//------resource management funcs - -genUID = {Date.seed.asHexString.toLower}; - -seedFunc = {arg func, seed; - var funcArgs, next; - next = Routine({loop{func.valueArray(funcArgs).yield }}); - next.randSeed_(seed); - {arg ...args; funcArgs = args; next.value} -}; - -stringifyToDepth = {arg data, maxDepth = 1; - var prettyString = "", rCount = 0, writeArray, indent; - - if(maxDepth == 0, { - data.asCompileString - }, { - indent = {arg size; size.collect({" "}).join("")}; - writeArray = {arg array; - prettyString = prettyString ++ indent.value(rCount) ++ "[\n"; - rCount = rCount + 1; - if(rCount < maxDepth, { - array.do({arg subArray; writeArray.value(subArray)}); - }, { - prettyString = prettyString ++ array.collect({arg subArray; - indent.value(rCount + 1) ++ subArray.asCompileString - }).join(",\n"); - }); - rCount = rCount - 1; - prettyString = prettyString ++ "\n" ++ indent.value(rCount) ++ "],\n"; - }; - - writeArray.value(data); - prettyString.replace(",\n\n", "\n").drop(-2); - }) -}; - -sanityCheck = {arg motif, index; - //print functions = very helpful - ("----------" + index + "------------").postln; - - motif.flatten.do({arg val, v; - if(v > 0, { - if(motif.flatten[v-1][0].hammingDistance(val[0]) > 1, {"problem 1".postln}); - if(motif.flatten[v-1][0].hammingDistance(val[0]) == 0, {"problem 2".postln}); - }); - val.postln - }); - "***********".postln; -}; - -msgInterpret = {arg in, escapeDoubleQuotes = true, escapeSingleQuotes = true; - var res; - - res = in; - if(res.isNil.not, { - if((res.isArray && res.isString.not), { - res = res.asCompileString; - res = res.replace(" ", "").replace("\n", "").replace("\t", ""); - if(escapeSingleQuotes, {res = res.replace("\'", "")}); - if(escapeDoubleQuotes, {res = res.replace("\"", "")}); - res = res.replace("Rest", "\"Rest\""); - res = res.interpret; - }, { - var tmpRes; - if(res.every({arg char; char.isDecDigit}), {tmpRes = res.asInteger}); - if(res.contains("."), {tmpRes = res.asFloat}); - if(tmpRes != nil, {res = tmpRes}); - }); - }); - res -}; - -writeResources = {arg path, dict; - var file, modelItems, resString; - file = File(path,"w"); - - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - - resString = nameSpaces.collect({arg nameSpace; - var depth = 0, insert = " "; - if(nameSpace == "music_data", {depth = 3; insert = "\n"}); - if(nameSpace == "last_changes", {depth = 1; insert = "\n"}); - if(nameSpace == "order", {depth = 1; insert = "\n"}); - if((nameSpace == "ref_uid") && (dict[nameSpace] == nil), {dict[nameSpace] = "nil"}); - "\"" ++ nameSpace ++ "\":" ++ insert ++ stringifyToDepth.value(dict[nameSpace], depth) - }).join(",\n"); - - resString = "{\n" ++ resString ++ "\n}"; - - file.write(resString); - file.close; - resString -}; - -loadModelFile = {arg path; loadModelJSON.value(File(path, "r").readAllString.parseJSON)}; - -loadModelJSON = {arg jsonObject; - var dict; - dict = Dictionary.with(*nameSpaces.collect({arg nS; nS->msgInterpret.value(jsonObject[nS])})); - dict -}; - -setGlobalVars = {arg dict, skipLastXChanges = false; - var tmpLastXChanges; - tmpLastXChanges = lastXChanges.deepCopy; - // order really matters!!!! - # seq, lastXChanges, curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited = nameSpaces.collect({arg nS; dict[nS]}); - if(skipLastXChanges, {lastXChanges = tmpLastXChanges}); - dict -}; - -globalVarsToDict = { - var modelItems, dict; - // order really matters!!!! - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - dict = Dictionary.with(*nameSpaces.collect({arg nS, n; nS->modelItems[n]})); -}; - -loadLedgerFile = {arg path; - ledgerPath = path; - loadLedgerJSON.value(File(ledgerPath, "r").readAllString.parseJSON) -}; - -loadLedgerJSON = {arg jsonObject; ledger = jsonObject["ledger"]}; - -saveLedger = {arg ledger, path; - var file; - file = File(path, "w"); - file.write("{\n\"ledger\":\n" ++ stringifyToDepth.value(ledger, 1) ++ "\n}"); - file.close; -}; - -//------global vars - -primes = [[2, 1], [3, 2], [5, 4], [7, 4], [11, 8], [13, 8]]; -//ranges = [[-2400, 0], [-1200, 1200], [0, 2400], [0, 2400]]; -exPath = thisProcess.nowExecutingPath; -dir = exPath.dirname; -//popSize = 4; -dims = primes.size; -tuples = genTuples.value(); -//refUID = nil; -group = Group.new; -~group = group; -loadLedgerFile.value(dir +/+ ".." +/+ "resources" +/+ "piece_ledger.json"); -//passagesWeights = [1, 1, 1, 1, 1]; -//susWeights = [1, 1, 1]; -// order really matters!!!! -nameSpaces = [ - "music_data", "last_changes", "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", - "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", - "ranges", "step_probs_vals", "passages_weights", "hd_exp", "hd_invert", - "order", "sus_weights", "order_size", "passages_size", - "motif_edited", "order_edited" -]; - - -//------OSC funcs - -OSCdef(\load_ledger, {arg msg, time, addr, port; - loadLedgerFile.value(msg[1].asString); -}, \load_ledger); - -OSCdef(\load_model, {arg msg, time, addr, port; - var dict; - dict = loadModelFile.value(msg[1].asString); - setGlobalVars.value(dict); -}, \load_model); - -OSCdef(\save_ledger, {arg msg, time, addr, port; - msg.postln; - ledger = msgInterpret.value(msg[1].asString.parseJSON["ledger"], false).postln; - //loadLedgerJSON.value(msg[0]) - saveLedger.value(ledger, msg[2].asString); - //loadLedgerFile.value(msg[1].asString); -}, \save_ledger); - -OSCdef(\generate, {arg msg, time, addr, port; - var path, dict, durSeeds, musPath, modelString; - msg.postln; - - path = msg[1].asString; - - dict = loadModelFile.value(path); - setGlobalVars.value(dict, true); - - popSize = ranges.size; - - //refUID.postln; - - loadLedgerFile.value(ledgerPath); - if(ledger == nil, {ledger = ["tmp"]}); - if(ledger.last != "tmp", {ledger = ledger.add("tmp")}); - - if(refUID == nil, {lastXChanges = [initVoices.value().deepCopy]}); - if((refUID != nil) && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - lastXChanges = msgInterpret.value(file.readAllString.parseJSON["last_changes"]); - }); - - refUID.postln; - lastXChanges.collect({arg item; item.postln}); - - durSeeds = seedFunc.value({3.collect({rrand(100000, 999999)})}, durSeed).value.postln; - entrancesDurFunc = genDurFunc.valueArray(entrancesProbVals[..4] ++ [entrancesProbVals[5..]] ++ [durSeeds[0]]); - passagesDurFunc = genDurFunc.valueArray(passagesProbVals[..4] ++ [passagesProbVals[5..]] ++ [durSeeds[1]]); - exitsDurFunc = genDurFunc.valueArray(exitsProbVals[..4] ++ [exitsProbVals[5..]] ++ [durSeeds[2]]); - - if(orders == nil, { - orders = seedFunc.value(genOrders, orderSeed).valueArray(orderSize ++ passagesSize); - //addr.sendMsg("/order", stringifyToDepth.value(orders, 1)); - }); - - stepFunc = genStepFunc.valueArray(stepProbsVals[..1] ++ [stepProbsVals[2..]] ++ [motifSeed]); - seq = seedFunc.value(genMotif, motifSeed).value; - - lastXChanges.collect({arg item; item.postln}); - - dict = globalVarsToDict.value; - modelString = writeResources.value(path, dict); - - //addr.sendMsg("/generated", musPath, stringifyToDepth.value(seq, 3)); - //~seq = seq; - - addr.sendMsg("/generated", path, modelString, ledgerPath); -}, \generate); - - -OSCdef(\commit, {arg msg, time, addr, port; - var musicData, musicChanged, dict, newLedger, modelPath, musString, musFile, test1, test2, lastCurUID, commitType, commitPos, equalityLedger; - //msg.postln; - - /* - test1 = msg[1].asString.parseJSON; - test2 = (dir +/+ ".." +/+ "resources/tmp/tmp_music" ++ ".json").standardizePath.parseJSONFile; - msgInterpret.value(test1["music"])[0][0][0][1].class.postln; - msgInterpret.value(test2["music_data"])[0][0][0][1].class.postln; - (test1["music"] == test2["music_data"]).postln; - */ - - musicData = loadModelJSON.value(msg[1].asString.parseJSON)["music_data"].postln; - musicChanged = (musicData != seq).postln; - commitType = msg[2].asString; - commitPos = msg[3].postln.asInteger; - - lastCurUID = curUID.deepCopy; - curUID = genUID.value; - - File.mkdir((dir +/+ ".." +/+ "resources" +/+ curUID).standardizePath); - File.copy(exPath, (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_code" ++ ".scd").standardizePath); - - modelPath = (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_mus_model" ++ ".json").standardizePath; - dict = globalVarsToDict.value; - if(musicChanged, { - seq = musicData; - dict["music_data"] = seq; - dict["motif_edited"] = "true" - }); - dict["cur_uid"] = curUID; - - writeResources.value(modelPath, dict); - - File.delete(ledgerPath ++ "_bak"); - File.copy(ledgerPath, ledgerPath ++ "_bak"); - File.delete(ledgerPath); - - /* - if(commitType == "add", { - if(lastCurUID == "tmp", { - ledger = ledger.drop(-1).add(curUID); - }, { - ledger = ledger.add(curUID); - }) - }); - */ - - ledger.postln; - - if(commitType == "add", {ledger = ledger.add(curUID)}); - - if(commitType == "insert", {ledger = ledger.insert(commitPos - 1, curUID)}); - - if(commitType == "replace", {ledger = ledger.put(commitPos, curUID)}); - - equalityLedger = ledger.collect({arg item; item.asSymbol}); - if(equalityLedger.includes(\tmp).postln, {ledger = ledger.removeAt(equalityLedger.indexOf(\tmp).postln)}); - - ledger.postln; - - saveLedger.value(ledger, ledgerPath); - - addr.sendMsg("/committed", curUID, ledgerPath); - //refUID = curUID; - -}, \commit); - -OSCdef(\transport, {arg msg, time, addr, port; - msg.postln; - if(msg[1] == 0, { - group.set(\release, 2); - group.set(\gate, 0); - player.stop; - }, { - // the cued sequence can now be read from file, so this can be cleaned up - var cSize, patterns, pSeq, cuedSeek, indexStart, indexEnd, tmpLedger; - if(msg[1] == 1, { - pSeq = []; - cuedSeek = (seq != nil); - indexStart = msg[2].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.postln.parseJSON["music_data"]), path, indexStart + index, uid]); - file.close; - }); - }); - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - patterns = genPatterns.value(pSeq, addr); - }, { - pSeq = [loadModelJSON.value(msg[2].asString.parseJSON)["music_data"].postln]; - patterns = genPatterns.value(pSeq, addr, true); - }); - player = Pfset(pattern: patterns, cleanupFunc: { - addr.sendMsg("/transport", 0); - addr.sendMsg("/one_shot", 0); - }); - player = player.play - }); -}, \transport); - - -OSCdef(\transcribe_motif, {arg msg, time, addr, port; - var tSeq, refChord, refUID; - - msg.postln; - - tSeq = [loadModelJSON.value(msg[1].asString.parseJSON)["music_data"]]; - refUID = msg[2].asString.postln; - - if((refUID != "nil") && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }, { - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - }); - - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "lilypond" +/+ "includes").standardizePath, addr, "/transcribe_motif"); -}, \transcribe_motif); - - -OSCdef(\transcribe_all, {arg msg, time, addr, port; - var cSize, patterns, cuedSeek, indexStart, indexEnd, tmpLedger; - if(true, { - cuedSeek = (seq != nil); - indexStart = msg[1].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - - //tmp for testing transcription - indexEnd = (indexStart+5); - - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - var lilyPartLedgerFiles; - - lilyPartLedgerFiles = 4.collect({arg p; - File((dir +/+ ".." +/+ "lilypond" +/+ "includes" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly").standardizePath, "w"); - }); - - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file, fileString, tSeq, refUID, refChord; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - fileString = file.readAllString; - tSeq = msgInterpret.value(fileString.parseJSON["music_data"]); - refUID = msgInterpret.value(fileString.parseJSON["ref_uid"]); - file.close; - - //uid.postln; - //(refUID == "nil").postln; - - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - - if(refUID != "nil", { - path = (dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }); - - if(index != indexEnd, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath); - }, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath, addr, "/transcribe_all"); - }); - - lilyPartLedgerFiles.do({arg f, p; - f.write("\\include \".." +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly\"\n"); - }); - - }); - - lilyPartLedgerFiles.do({arg f; - f.close - }); - }); - /* - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - */ - }, { - - }); - -}, \transcribe_all); - -) - -~transcribe.value(~seq, dir); - -( -//synthdefs -~stringModelBusArray = 4.collect({Bus.audio(s, 1)}); -~sineBusArray = 4.collect({Bus.audio(s, 1)}); -~bassBusArray = 1.collect({Bus.audio(s, 1)}); -~hdustBusArray = 1.collect({Bus.audio(s, 1)}); -~samplerBusArray = 2.collect({Bus.audio(s, 1)}); -~sBuf = Buffer.alloc(s, 10, 2); -SynthDef(\string_model, {arg freq, gate = 1, sustain, amp, dur, attack, release = 1, busIndex = 0; - var trig, exc, sig1, sig2, noHarms; - noHarms = rrand(20, 40); - exc = Saw.ar(freq, TRand.ar(0.5, 1, Impulse.ar(freq))) * 0.001 + Dust.ar(10000, 0.01); - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.8).softclip; - //sig1 = HPF.ar(sig1, 300); - Out.ar(Select.kr(busIndex, ~stringModelBusArray), sig1 * amp * EnvGen.kr(Env.adsr(attack, 0.3, 0.9, release, 0.9, -3), gate, doneAction: 2)); - //Out.ar([0, 1], sig1 * EnvGen.kr(Env.asr(dur, 0.3, 1), gate, doneAction: 2)); -}).add; - -SynthDef(\sine, {arg freq, gate = 1, sustain, amp, dur, busIndex = 0; - var sig; - sig = SinOsc.ar(freq); - Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.asr(0.3, 0.4, 0.3), gate, timeScale: dur, doneAction: 2)); - //Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.sine(dur), gate, doneAction: 2)); -}).add; - -SynthDef(\mixer, {arg freq, gate = 1, sustain, amp, dur, out; - var nameSpaces, sigs; - - sigs = [~stringModelBusArray, ~sineBusArray/*, ~bassBusArray, ~hdustBusArray, ~samplerBusArray*/].collect({arg busArray, i; - var nameSpace, sig; - nameSpace = ['string', 'sine', 'bass', 'hdust', 'sampler'][i]; - sig = busArray.collect({arg bus, c; In.ar(bus, 1) * NamedControl.kr(\ ++ nameSpace ++ '_volume_' ++ c, 1, 0.1)}); - sig = sig.collect({arg channel, c; Pan2.ar(channel, NamedControl.kr(\ ++ nameSpace ++ '_pan_' ++ c, i / (busArray.size - 1), 0.1) * 2 - 1)}); - sig = sig.collect({arg channel, c; channel * NamedControl.kr(\ ++ nameSpace ++ '_mute_' ++ c, 1, 0.1)}); - sig = Mix.ar(sig) * pow(NamedControl.kr(\ ++ nameSpace ++ '_volume_master', 1, 0.1), 2); - }); - - sigs = Mix.ar(sigs / 4); - Out.ar(0, sigs) -}).add; - -SynthDef(\bass, { - var switches, drone; - switches = {|i| Dust.kr(0.1)} ! 9; - drone = {|i| var harm = pow(2, 2 - (i / 3).trunc), amp = (1 / pow(harm, 2)); - SinOsc.ar(60 * harm + TRand.kr(-3, 3, switches[i]), 0, amp)} ! 9; - Out.ar(~bassBusArray[0], Mix.new(drone) * 0.2); -}).add; - -SynthDef(\sampler, { - Out.ar(~samplerBusArray, PlayBuf.ar(2, ~sBuf, BufRateScale.kr(~sBuf), doneAction: 2)) -}).add; - -// main routine -SynthDef(\hdust, { - arg gate = 0; - var hierarchical_dust, low_sine, high_sine, brown_noise, white_noise; - // this triggers the combinations of sources - // it is similar to the Supercollider UGen called dust but with a hierarchical structure - hierarchical_dust = ( - TIRand.kr(0, 1, Impulse.kr(100)) * - TIRand.kr(0, 1, Impulse.kr(10)) * - TIRand.kr(0, 1, Impulse.kr(1)) * - TIRand.kr(0, 1, Impulse.kr(0.1)) - ); - // adjust the multiplier at the end of each line for adjusting levels - // note with each trigger, each source has a 1 in 3 chance of sounding - low_sine = SinOsc.ar(76.midicps / 16) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.1; - high_sine = SinOsc.ar(76.midicps * 8) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.01; - brown_noise = BrownNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.025; - white_noise = WhiteNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.02; - Out.ar(~hdustBusArray[0], - ((low_sine + high_sine + brown_noise + white_noise) ) - ); -}).add; - -) - -( -var bass, hdust, sampler, mixer; -/* -bass = Synth.tail(~group, \bass); -hdust = Synth.tail(~group, \hdust); -sampler = Synth.head(~group, \sampler); -*/ -mixer = Synth.tail(~group, \mixer); - -OSCdef(\mixer, {arg msg, time, addr, port; - mixer.set((msg[1] ++ '_' ++ msg[2] ++ '_' ++ msg[3]), msg[4]) -}, \mixer); - -/* -OSCdef(\sampler, {arg msg, time, addr, port; - msg.postln; - sampler.free; - ~sBuf.free; - ~sBuf = Buffer.read(s, msg[1].asString.postln, action: {sampler = Synth.head(~group, \sampler)}); -}, \sampler); -*/ -) - -/* old something -( -SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; - var trig, exc, sig1, sig2, noHarms, freqFinal, start, end; - noHarms = 30; - freq = WhiteNoise.ar * 3 + freq; - freqFinal = Duty.ar((1/freq), 0, freq); - trig = Changed.ar(freqFinal); - start = Demand.ar(trig, 0, Dwhite(-1, -0.75)); - end = Demand.ar(trig, 0, Dwhite(0.75, 1)); - exc = Phasor.ar(trig, (end - start) * freqFinal / SampleRate.ir, start, end, 0) * 0.001 + Dust.ar(10000, 0.01); - - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(2, 3)}) ], exc) * 0.5).softclip; - sig1 = HPF.ar(sig1, 300); - Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); -}).add; -) -*/ - diff --git a/resources/430a1ec1/430a1ec1_mus_model.json b/resources/430a1ec1/430a1ec1_mus_model.json deleted file mode 100644 index 7e6ce6c..0000000 --- a/resources/430a1ec1/430a1ec1_mus_model.json +++ /dev/null @@ -1,55 +0,0 @@ -{ -"music_data": -[ - [ - [ - [ [ [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ] ], 8.375 ], - [ [ [ 0, 0, 1, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ] ], 0 ], - [ [ [ 0, 0, 1, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ "Rest" ] ], 0 ], - [ [ [ 0, 0, 1, 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], [ 1, -1, 0, 0, 0, 0 ], [ 0, -1, 0, 0, 0, 0 ] ], - [ [ 1, -1, -1, 0, 0, 0 ], [ 0, -1, 1, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ 0, -1, 0, 0, 0, 0 ] ], - [ [ 1, -1, -1, 0, 0, 0 ], [ 0, -1, 1, 0, 0, 0 ], [ 2, -1, 0, 0, 0, -1 ], [ 0, -1, 0, 0, 0, 0 ] ], - [ [ 1, -1, -1, 0, 0, 0 ], [ 1, -2, 0, 0, 0, 0 ], [ 2, -1, 0, 0, 0, -1 ], [ 0, -1, 0, 0, 0, 0 ] ] -], -"cur_uid": "430a1ec1", -"ref_uid": "nil", -"order_seed": 554844, -"dur_seed": 362584, -"motifs_seed": 941930, -"entrances_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.26424870466321, 0.75675675675676, 0.5, 0.5, 0.58549222797927, 0.72635135135135, 1, 0.5 ], -"passages_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"exits_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"ranges": [ [ -384, 2400 ], [ -507, 2400 ], [ -282, 2237 ], [ -1200, 2053 ] ], -"step_probs_vals": [ 0, 1200, 0, 0.5, 0.5, 0.5, 1, 0.5 ], -"passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], -"hd_exp": 2, -"hd_invert": 0, -"order": -[ - [ [ 1 ], [ 0, 2, 3, 3 ], [ ] ], - [ [ 3 ], [ 1, 0, 2, 1 ], [ ] ] -], -"sus_weights": [ 0.75, 0.69, 0.75 ], -"order_size": [ 2, 6 ], -"passages_size": [ 0, 10 ], -"motif_edited": "false", -"order_edited": "false" -} \ No newline at end of file diff --git a/resources/445b7057/445b7057_mus_model.json b/resources/445b7057/445b7057_mus_model.json deleted file mode 100644 index 4e00d32..0000000 --- a/resources/445b7057/445b7057_mus_model.json +++ /dev/null @@ -1,97 +0,0 @@ -{ -"music_data": -[ - [ - [ - [ [ [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ] ], 0.875 ], - [ [ [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ] ], 0.625 ], - [ [ [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, -1 ], [ 0, 0, 0, 0, 0, 0 ] ], 1.5 ], - [ [ [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 1, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], 0.875 ], - [ [ [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], 0.875 ], - [ [ [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], 1 ], - [ [ [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 1, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], 1 ], - [ [ [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], 1.25 ], - [ [ [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 1 ], [ 0, 0, 0, 0, 0, 0 ] ], 0.875 ], - [ [ [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, -1, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], 0.875 ], - [ [ [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0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-1, -1, 0 ], [ 0, 0, 1, 0, -1, 0 ], [ 1, 0, 0, -1, -1, 0 ] ], 1.5 ], - [ [ [ 0, 0, 0, 0, -1, 0 ], [ 2, 0, 0, 0, -1, -1 ], [ 0, 0, 1, 0, -1, 0 ], [ 1, 0, 0, -1, -1, 0 ] ], 0.75 ], - [ [ [ 0, 0, 0, 0, -1, 0 ], [ 2, 0, 0, 0, -1, -1 ], [ 1, -1, 0, 0, -1, 0 ], [ 1, 0, 0, -1, -1, 0 ] ], 1 ] - ], - [ - [ [ [ "Rest" ], [ 2, 0, 0, 0, -1, -1 ], [ 1, -1, 0, 0, -1, 0 ], [ 1, 0, 0, -1, -1, 0 ] ], 0.75 ], - [ [ [ "Rest" ], [ 2, 0, 0, 0, -1, -1 ], [ 1, -1, 0, 0, -1, 0 ], [ 0, -1, 0, 1, -1, 0 ] ], 1 ], - [ [ [ "Rest" ], [ 2, -1, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 0, -1, 0, 1, -1, 0 ] ], 0.875 ], - [ [ [ "Rest" ], [ 2, -1, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 0, -1, 0, 0, -1, 1 ] ], 1.25 ], - [ [ [ "Rest" ], [ 1, -1, 0, 1, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 0, -1, 0, 0, -1, 1 ] ], 1.125 ], - [ [ [ "Rest" ], [ 1, -1, 0, 1, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 1, -1, -1, 0, -1, 0 ] ], 1 ], - [ [ [ "Rest" ], [ 1, 0, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 1, -1, -1, 0, -1, 0 ] ], 0.75 ], - [ [ [ "Rest" ], [ 1, -1, 0, 0, 0, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 1, -1, -1, 0, -1, 0 ] ], 0.625 ], - [ [ [ "Rest" ], [ 1, -1, 0, 0, 0, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 0, -1, 0, 0, 0, 0 ] ], 0.75 ], - [ [ [ "Rest" ], [ 1, -1, 0, 0, 0, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -2, 0 ] ], 1.375 ], - [ [ [ "Rest" ], [ 2, -2, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -2, 0 ] ], 0.875 ], - [ [ [ "Rest" ], [ 2, -2, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 0, -1, 0, 0, -1, 1 ] ], 3.375 ], - [ [ [ "Rest" ], [ 2, -2, 0, 0, -1, 0 ], [ "Rest" ], [ 0, -1, 0, 0, -1, 1 ] ], 1.5 ], - [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ 0, -1, 0, 0, -1, 1 ] ], 1.375 ], - [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 1 ] - ] - ] -], -"last_changes": -[ - [ [ 0, 0, 0, 1, 0, -1 ], [ 0, 0, 0, 0, 0, 0 ], [ 2, 0, 0, 0, 0, -1 ], [ 1, 0, 0, 0, 0, -2 ] ], - [ [ 0, 0, 0, 1, 0, -1 ], [ 0, 0, 0, 0, 0, 0 ], [ 2, 0, 0, 0, 0, -1 ], [ -1, 0, 0, 1, 0, -1 ] ], - [ [ 0, 0, 0, 1, 0, -1 ], [ 0, 0, 0, 0, 0, 0 ], [ 2, 0, 0, 0, 0, -1 ], [ 0, 0, 0, 0, -1, 0 ] ], - [ [ 0, 0, 0, 1, 0, -1 ], [ 0, 0, 0, 0, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ], [ 0, 0, 0, 0, -1, 0 ] ], - [ [ 1, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ], [ 0, 0, 0, 0, -1, 0 ] ] -], -"cur_uid": "445b7057", -"ref_uid": "nil", -"order_seed": 320463, -"dur_seed": 903977, -"motifs_seed": 895384, -"entrances_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.26424870466321, 0.75675675675676, 0.5, 0.5, 0.58549222797927, 0.72635135135135, 1, 0.5 ], -"passages_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"exits_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"ranges": [ [ -384, 2400 ], [ -507, 2400 ], [ -282, 2237 ], [ -1200, 2053 ] ], -"step_probs_vals": [ 0, 1200, 0, 0.5, 0.5, 0.5, 1, 0.5 ], -"passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], -"hd_exp": 2, -"hd_invert": 0, -"order": -[ - [ [ 1 ], [ 0, 3, 2, 3, 3, 2 ], [ ] ], - [ [ 2, 1 ], [ 3, 0, 3 ], [ ] ], - [ [ 1 ], [ 3, 2, 0 ], [ ] ] -], -"sus_weights": [ 0.75, 0.69, 0.75 ], -"order_size": [ 2, 6 ], -"passages_size": [ 0, 10 ], -"motif_edited": "true", -"order_edited": "false" -} \ No newline at end of file diff --git a/resources/46b6952a/46b6952a_mus_model.json b/resources/46b6952a/46b6952a_mus_model.json deleted file mode 100644 index 024062b..0000000 --- a/resources/46b6952a/46b6952a_mus_model.json +++ /dev/null @@ -1,57 +0,0 @@ -{ -"music_data": -[ - [ - [ - [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 0 ], - [ [ [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ] ], 0 ], - [ [ [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ "Rest" ], [ 2, 0, 0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1, 0, 0 ], [ 1, -1, 1, 0, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ] ] -], -"cur_uid": "46b6952a", -"ref_uid": "7e170ef8", -"order_seed": 969134, -"dur_seed": 384656, -"motifs_seed": 435714, -"entrances_probs_vals": [ 0.75, 0.5, 2, 0, 0.5, 0.26424870466321, 0.75675675675676, 0.5, 0.5, 0.58549222797927, 0.72635135135135, 1, 0.5 ], -"passages_probs_vals": [ 0.75, 0.5, 2, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"exits_probs_vals": [ 0.75, 0.5, 2, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"ranges": [ [ -384, 2400 ], [ -507, 2400 ], [ -282, 2237 ], [ -1200, 2053 ] ], -"passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], -"order": -[ - [ [ 0, 1, 3 ], [ 2, 2, 2, 2, 2, 2, 2, 2, 2 ], [ ] ], - [ [ 0, 2, 3 ], [ 1, 1, 1, 1 ], [ ] ] -], -"sus_weights": [ 0.75, 0.69, 0.75 ], -"order_size": [ 2, 6 ], -"passages_size": [ 0, 10 ] -} \ No newline at end of file diff --git a/resources/475efb26/475efb26_mus_model.json b/resources/475efb26/475efb26_mus_model.json deleted file mode 100644 index f9710fa..0000000 --- a/resources/475efb26/475efb26_mus_model.json +++ /dev/null @@ -1,93 +0,0 @@ -{ -"music_data": -[ - [ - [ - [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 0.875 ], - [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ] ], 0.625 ], - [ [ [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, -1 ], [ "Rest" ],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rest" ], [ 1, 0, 0, -1, -1, 0 ] ], 0.75 ], - [ [ [ 2, 0, 0, 0, -1, -1 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 0, -1, 0, 1, -1, 0 ] ], 1 ], - [ [ [ 2, -1, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 0, -1, 0, 1, -1, 0 ] ], 0.875 ], - [ [ [ 2, -1, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 0, -1, 0, 0, -1, 1 ] ], 1.25 ], - [ [ [ 1, -1, 0, 1, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 0, -1, 0, 0, -1, 1 ] ], 1.125 ], - [ [ [ 1, -1, 0, 1, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 1, -1, -1, 0, -1, 0 ] ], 1 ], - [ [ [ 1, 0, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 1, -1, -1, 0, -1, 0 ] ], 0.75 ], - [ [ [ 1, -1, 0, 0, 0, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 1, -1, -1, 0, -1, 0 ] ], 0.625 ], - [ [ [ 1, -1, 0, 0, 0, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 0, -1, 0, 0, 0, 0 ] ], 0.75 ], - [ [ [ 1, -1, 0, 0, 0, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 1, -1, 0, 0, -2, 0 ] ], 1.375 ], - [ [ [ 2, -2, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 1, -1, 0, 0, -2, 0 ] ], 0.875 ], - [ [ [ 2, -2, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 0, -1, 0, 0, -1, 1 ] ], 3.375 ], - [ [ [ 2, -2, 0, 0, -1, 0 ], [ "Rest" ], [ "Rest" ], [ 0, -1, 0, 0, -1, 1 ] ], 1.5 ], - [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ 0, -1, 0, 0, -1, 1 ] ], 1.375 ], - [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 1 ] - ] - ] -], -"last_changes": -[ - [ [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], - [ [ 2, 0, 0, 0, 0, -1 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], - [ [ 1, 1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ] -], -"cur_uid": "475efb26", -"ref_uid": "nil", -"order_seed": 403998, -"dur_seed": 276580, -"motifs_seed": 561314, -"entrances_probs_vals": [ 0, 0, 10, 0, 3.08, 0, 0.64527027027027, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"passages_probs_vals": [ 0, 0, 10, 0, 3.08, 0, 0.64527027027027, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"exits_probs_vals": [ 0, 0, 10, 0, 3.08, 0, 0.64527027027027, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"ranges": [ [ 1419.1950464396, 2400 ], [ 1519.5046439628, 2400 ], [ 1541.7956656347, 2237 ], [ 1519.5046439628, 2053 ] ], -"step_probs_vals": [ 0, 1200, 0, 0.5, 0.5, 0.5, 1, 0.5 ], -"passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], -"hd_exp": 2, -"hd_invert": 0, -"order": -[ - [ [ 2, 3, 1 ], [ 0, 0 ], [ ] ] -], -"sus_weights": [ 0.75, 0.69, 0.75 ], -"order_size": [ 1, 2 ], -"passages_size": [ 0, 2 ], -"motif_edited": "true", -"order_edited": "false" -} \ No newline at end of file diff --git a/resources/4c01589b/lilypond/part_I.ly b/resources/4c01589b/lilypond/part_I.ly deleted file mode 100644 index 0adf15a..0000000 --- a/resources/4c01589b/lilypond/part_I.ly +++ /dev/null @@ -1,40 +0,0 @@ -{ - { r2. r8[ e'8^\markup { \pad-markup #0.2 "-14"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 5↑" }}] ~ } - \bar "|" - { e'1 ~ } - \bar "|" - { e'4 ~ e'8[ f'8^\markup { \pad-markup #0.2 "-2"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 3↓" }}] ~ f'4 ~ f'16[ e'8.^\markup { \pad-markup #0.2 "-41"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 13↓" }}] ~ } - \bar "|" - { e'1 ~ } - \bar "|" \break - { e'2 d'4^\markup { \pad-markup #0.2 "+31"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 7↓" }} ~ d'4 ~ } - \bar "|" - { d'1 ~ } - \bar "|" - { d'1 ~ } - \bar "|" - { d'1 ~ } - \bar "|" \break - { d'1 ~ } - \bar "|" - { d'1 ~ } - \bar "|" - { d'1 ~ } - \bar "|" - { d'2 r2 } - \bar "|" \break - { r8.[ d'16^\markup { \pad-markup #0.2 "+31"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 7↓" }}] ~ d'2. ~ } - \bar "|" - { d'1 ~ } - \bar "|" - { d'1 ~ } - \bar "|" - { d'1 ~ } - \bar "|" \break - { d'1 ~ } - \bar "|" - { d'1 ~ } - \bar "|" - { d'16[ r8.] r2. } -\bar "||" -} \ No newline at end of file diff --git a/resources/4c01589b/lilypond/part_II.ly b/resources/4c01589b/lilypond/part_II.ly deleted file mode 100644 index 1073a84..0000000 --- a/resources/4c01589b/lilypond/part_II.ly +++ /dev/null @@ -1,40 +0,0 @@ -{ - { c'4^\markup { \pad-markup #0.2 "+0"} ~ c'2. ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" \break - { c'2. ~ c'8.[ b16^\markup { \pad-markup #0.2 "-12"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 5↑" }}] ~ } - \bar "|" - { b4 b4^\markup { \pad-markup #0.2 "-39"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 13↓" }} ~ b2 ~ } - \bar "|" - { b16[ cis'8.^\markup { \pad-markup #0.2 "-47"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 11↑" }}] ~ cis'4 ~ cis'8[ ais8^\markup { \pad-markup #0.2 "+45"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "I"\normal-size-super " 5↓" }}] ~ ais4 ~ } - \bar "|" - { ais8[ a8^\markup { \pad-markup #0.2 "+33"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 7↓" }}] ~ a8[ b8^\markup { \pad-markup #0.2 "-28"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "I"\normal-size-super " 13↑" }}] ~ b2 ~ } - \bar "|" \break - { b8.[ c'16^\markup { \pad-markup #0.2 "+0"}] ~ c'2 ~ c'8.[ b16^\markup { \pad-markup #0.2 "-39"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 13↓" }}] ~ } - \bar "|" - { b1 ~ } - \bar "|" - { b1 ~ } - \bar "|" - { b2 c'4^\markup { \pad-markup #0.2 "+0"} ~ c'4 ~ } - \bar "|" \break - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" \break - { c'1 ~ } - \bar "|" - { c'8.[ r16] r2. } - \bar "|" - { r1 } -\bar "||" -} \ No newline at end of file diff --git a/resources/4c01589b/lilypond/part_III.ly b/resources/4c01589b/lilypond/part_III.ly deleted file mode 100644 index 272bcc9..0000000 --- a/resources/4c01589b/lilypond/part_III.ly +++ /dev/null @@ -1,40 +0,0 @@ -{ - { r2. r8[ ais8^\markup { \pad-markup #0.2 "-31"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 7↑" }}] ~ } - \bar "|" - { ais2 gis4^\markup { \pad-markup #0.2 "+14"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 5↓" }} ~ gis4 ~ } - \bar "|" - { gis4 ~ gis8[ g8^\markup { \pad-markup #0.2 "+2"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 3↑" }}] ~ g2 ~ } - \bar "|" - { g1 ~ } - \bar "|" \break - { g1 ~ } - \bar "|" - { g1 ~ } - \bar "|" - { g1 ~ } - \bar "|" - { g1 ~ } - \bar "|" \break - { g1 ~ } - \bar "|" - { g8.[ g16^\markup { \pad-markup #0.2 "+29"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "I"\normal-size-super " 3↓" }}] ~ g8.[ a16^\markup { \pad-markup #0.2 "+33"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 7↓" }}] ~ a2 ~ } - \bar "|" - { a8.[ gis16^\markup { \pad-markup #0.2 "+30"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 7↑" }}] ~ gis2 ~ gis8.[ a16^\markup { \pad-markup #0.2 "-20"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "I"\normal-size-super " 11↓" }}] ~ } - \bar "|" - { a2 r2 } - \bar "|" \break - { r1 } - \bar "|" - { r16[ gis8.^\markup { \pad-markup #0.2 "-18"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "I"\normal-size-super " 11↑" }}] ~ gis2. } - \bar "|" - { gis4^\markup { \pad-markup #0.2 "+41"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 13↑" }} ~ gis8[ gis8^\markup { \pad-markup #0.2 "+14"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 5↓" }}] ~ gis2 } - \bar "|" - { g4^\markup { \pad-markup #0.2 "+2"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 1↑" }} ~ g4 g4^\markup { \pad-markup #0.2 "+29"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "I"\normal-size-super " 3↓" }} ~ g4 ~ } - \bar "|" \break - { g8.[ a16^\markup { \pad-markup #0.2 "-20"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "I"\normal-size-super " 11↓" }}] ~ a2. ~ } - \bar "|" - { a1 ~ } - \bar "|" - { a16[ r8.] r2. } -\bar "||" -} \ No newline at end of file diff --git a/resources/4c01589b/lilypond/part_IV.ly b/resources/4c01589b/lilypond/part_IV.ly deleted file mode 100644 index 5e27bf3..0000000 --- a/resources/4c01589b/lilypond/part_IV.ly +++ /dev/null @@ -1,40 +0,0 @@ -{ - { r2. r8[ gis8^\markup { \pad-markup #0.2 "+41"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 13↑" }}] ~ } - \bar "|" - { gis1 ~ } - \bar "|" - { gis4 ~ gis8[ ais8^\markup { \pad-markup #0.2 "-31"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 7↑" }}] ~ ais4 ~ ais16[ d'8.^\markup { \pad-markup #0.2 "+31"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 7↓" }}] ~ } - \bar "|" - { d'2 ~ d'8[ f'8^\markup { \pad-markup #0.2 "-2"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 3↓" }}] ~ f'4 ~ } - \bar "|" \break - { f'2 g'2^\markup { \pad-markup #0.2 "+2"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "III"\normal-size-super " 1↑" }} ~ } - \bar "|" - { g'1 ~ } - \bar "|" - { g'1 ~ } - \bar "|" - { g'1 ~ } - \bar "|" \break - { g'1 ~ } - \bar "|" - { g'1 ~ } - \bar "|" - { g'1 ~ } - \bar "|" - { g'1 ~ } - \bar "|" \break - { g'1 ~ } - \bar "|" - { g'1 ~ } - \bar "|" - { g'1 ~ } - \bar "|" - { g'1 ~ } - \bar "|" \break - { g'1 ~ } - \bar "|" - { g'8.[ r16] r2. } - \bar "|" - { r1 } -\bar "||" -} \ No newline at end of file diff --git a/resources/4f65a9b5/4f65a9b5_code.scd b/resources/4f65a9b5/4f65a9b5_code.scd deleted file mode 100644 index 47fbb43..0000000 --- a/resources/4f65a9b5/4f65a9b5_code.scd +++ /dev/null @@ -1,1046 +0,0 @@ -( -// helper funcs -var hsArrayToCents, pDist, hdSum, hsChordalDistance, hsArrayToFreq; - -// score funcs -var isInRange, spacingScore, rangeScore, intervalScore, inclusionScore; - -// subroutines -var genTuples, initVoices, genOrders, genSubMotif, updateVoices, genDurFunc, genStepFunc; - -// primary routines -var genMotif, genSecondarySeq; - -// audition funcs -var genPatterns, genMidiPatterns; - -// resource management funcs -var seedFunc, genUID, writeResources, stringifyToDepth, setSeeds, sanityCheck, -msgInterpret, loadLedgerFile, loadLedgerJSON, loadModelFile, loadModelJSON, -setGlobalVars, globalVarsToDict, saveLedger; - -// model vars -//(model and global vars mostly set by OSC funcs -var seq, lastXChanges, -curUID, refUID, orderSeed, durSeed, motifSeed, -entrancesProbVals, passagesProbVals, exitsProbVals, -ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, -orders, susWeights, orderSize, passagesSize, -motifEdited, orderEdited; - -// model aux vars -var entrancesDurFunc, passagesDurFunc, exitsDurFunc, stepFunc; - -// other global vars -var popSize, exPath, dir, primes, dims, tuples, -group, player, ledgerPath, ledger, currentlyPlayingUID, -nameSpaces; - -// install JSON quark -if(Quarks.isInstalled("JSONlib").not, { - Quarks.install("https://github.com/musikinformatik/JSONlib.git"); - thisProcess.recompile; - //HelpBrowser.openHelpFor("Classes/JSONlib"); -}); - - -//------helper funcs - -hsArrayToCents = { - arg hsArray; - hsArray.collect({arg dist, p; dist * 1200 * log2(primes[p][0]/primes[p][1])}).sum -}; - -pDist = { - arg array1, array2, signed = false; - var pDistance; - pDistance = hsArrayToCents.value(array1) - hsArrayToCents.value(array2); - if(signed, {pDistance}, {abs(pDistance)}) -}; - -hdSum = { - arg hsArrays; - var size, distances, mean; - size = hsArrays.size; - distances = (size - 1).collect({arg i; - ((i + 1)..(size - 1)).collect({arg j; - abs(hsArrays[i] - hsArrays[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsChordalDistance = { - arg hsArrays1, hsArrays2; - var size, distances, mean; - size = hsArrays1.size; - distances = hsArrays1.size.collect({arg i; - hsArrays2.size.collect({arg j; - abs(hsArrays1[i] - hsArrays2[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsArrayToFreq = { - arg array; - array.collect({arg dim, d; pow(primes[d][0]/primes[d][1], dim)}).product -}; - -//------score funcs - -/* -isInRange = { - arg hsArray, min, max; - var cents; - cents = hsArrayToCents.value(hsArray); - (cents >= min) && (cents <= max) -}; -*/ - -spacingScore = { - arg hsArrays, min; - var centsArray; - centsArray = hsArrays.collect({arg hsArray; hsArrayToCents.value(hsArray)}).sort({arg a, b; a < b}); - centsArray.differentiate.drop(1).collect({arg pDistance; if(pDistance >= min, {1}, {0.01})}).sum; -}; - -rangeScore = { - arg hsArray1, hsArray2, min, max, low, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - if((pDistance >= min) && (pDistance <= max), {1}, {low}); -}; - -intervalScore = { - arg hsArray1, hsArray2, mean, sd, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - //pDistance.gaussCurve(1, mean, sd) - stepFunc.value(pDistance); -}; - -inclusionScore = { - arg array, test, min = 0.01; - if(array.collect({arg v; v.hash}).includes(test.hash), {min}, {1}); -}; - - -//------subroutines - -genTuples = { - var tuples; - tuples = dims.collect({[-1, 0, 1]}).allTuples.select({arg tuple; (abs(tuple.drop(1)).sum <= 1) && (tuple[0] == 0)}); - tuples = tuples ++ tuples.collect({arg tuple; [-3, -2, -1, 1, 2, 3].collect({arg octTrans; tuple.deepCopy.put(0, octTrans)})}).flatten; -}; - -initVoices = { - var init, voicesInit; - voicesInit = popSize.collect({dims.collect({0})}); - /* - voicesInit = [dims.collect({0})]; - (popSize - 1).do({ - arg rep, new; - rep = dims.rand; - new = voicesInit.last.deepCopy; - new[rep] = new[rep] + [-1, 1].choose(); - voicesInit = voicesInit.add(new); - }); - */ - voicesInit.deepCopy; -}; - -genDurFunc = {arg chordProb, minPad, maxPad, minDur, maxDur, envData, seed; - var env, pTable, durFunc; - env = Env.pairs([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).asSignal(256).asList.asArray; - pTable = env.asRandomTable; - [chordProb, minPad, maxPad, minDur, maxDur, envData].postln; - durFunc = {arg allowChord, pad = false; - var res; - res = if(allowChord.not, { - pTable.tableRand * (maxDur - minDur) + minDur - }, { - if(1.0.rand < chordProb, {0}, {pTable.tableRand * (maxDur - minDur) + minDur}); - }).round(0.125); - if(pad, {res = res + rrand(minPad.asFloat, maxPad.asFloat).round(0.125)}); - if(res.asInteger == res, {res = res.asInteger}); - res - }; - seedFunc.value(durFunc, seed); -}; - -genStepFunc = {arg minStep, maxStep, envData, seed; - var envDataNorm, env, pTable, stepFunc; - [minStep, maxStep, envData].postln; - envDataNorm = ([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).flop; - envDataNorm = [envDataNorm[0].normalize(minStep, maxStep), envDataNorm[1]].flop; - env = Env.pairs(envDataNorm); - stepFunc = {arg pDist; - env.at(pDist).clip(0.001, 1); - }; - seedFunc.value(stepFunc, seed); -}; - -genOrders = {arg minMotifLength = 1, maxMotifLength = 5, minProgLength = 0, maxProgLength = 5; - ((maxMotifLength - minMotifLength).rand + minMotifLength).collect({ - var noProgIns, noSusIns, noSilentIns, prog, sus, silent, order; - noSusIns = [1, 2, 3].wchoose(susWeights.normalizeSum); - noProgIns = (popSize - noSusIns).rand + 1; - noSilentIns = popSize - noSusIns - noProgIns; - - # prog, sus, silent = (0..(popSize-1)).scramble.clumps([noProgIns, noSusIns, noSilentIns]); - - prog = (prog.scramble ++ ((maxProgLength - minProgLength).rand + minProgLength).collect({prog.choose}).scramble); - if(silent == nil, {silent = []}); - [sus.scramble, prog, silent.scramble] - }); -}; - -updateVoices = {arg ins, sus; - var voices, candidates, nWeights, nProbs, sel; - - voices = lastXChanges.deepCopy.last; - - candidates = sus.collect({arg v; tuples.collect({arg t; voices[v] + t})}).flatten; - candidates = difference(candidates.asSet, voices.asSet).asList; - nProbs = candidates.collect({arg candidate; - var stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore; - - //stepScore = intervalScore.value(voices[ins], candidate, 30, 400, 0.1); - stepScore = intervalScore.value(voices[ins], candidate, 100, 100); - recentlySoundedScore = inclusionScore.value(lastXChanges.flop[ins], candidate, 0); - isInRangeScore = rangeScore.value(candidate, candidate.collect({0}), ranges[ins][0], ranges[ins][1], 0, true); - regScore = spacingScore.value(voices.deepCopy.put(ins, candidate), 300); - hdScore = pow(hdSum.value(voices.deepCopy.put(ins, candidate)), hdExp); - if(hdInvert == 0, {hdScore = 1/hdScore}); - //maybe what you want here is a vector to another root and then favoring movement towards it. - //distScore = pow(hsChordalDistance.value(voices, voices.put(ins, candidate)), 2); - - [stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore] - }); - - nWeights = passagesWeights; - - //this handles nWeights of 0; mainly for testing - nProbs = nProbs.flop.select({arg scores, s; nWeights[s] != 0}).flop; - nWeights = nWeights.select({arg weight; weight != 0}); - nProbs = nProbs.flop.collect({arg scores, s; - if(scores.sum == 0, {scores}, {scores.normalizeSum * nWeights[s]}) - }); - nProbs = nProbs.flop.collect({arg scores, s; scores.product}).normalizeSum; - - sel = candidates.wchoose(nProbs); - - voices[ins] = sel; - lastXChanges = lastXChanges.add(voices).keep(-5); -}; - -genSubMotif = {arg order, orderIndex, lastState, repeatLast = false, startFromLast = false, isLastOrder = false; - var sus, prog, silent, flatOrder, res, isInChord, allowChord, pad, lastXChangesHold, voices, adder; - # sus, prog, silent = order; - flatOrder = silent ++ sus ++ prog; - lastXChangesHold = lastXChanges.deepCopy; - voices = lastState.deepCopy; - isInChord = popSize.collect({false}); - allowChord = false; - pad = false; - res = []; - "------generating motif".postln; - //need to figure out here if voices move between motifs - flatOrder.do({arg ins, i; - - if(prog.includes(ins) && repeatLast.not, {updateVoices.value(ins, sus)}); - adder = if(silent.includes(ins), {["Rest"]}, {lastXChanges.last.deepCopy[ins]}); - - if(voices[ins] != adder, { - var dur; - - if((sus ++ silent).includes(ins), { - allowChord = (ins != sus.last); - pad = (ins == sus.last); - }, { - if(i < (flatOrder.size - 1), { - allowChord = (isInChord[flatOrder[i + 1]] || (ins == flatOrder[i + 1])).not; - pad = false; - }, { - allowChord = false; - pad = true - }); - }); - if((orderIndex == 0) && sus.includes(ins), { - dur = entrancesDurFunc.value(allowChord, pad); - }, { - dur = passagesDurFunc.value(allowChord, pad); - }); - if(dur == 0, {isInChord[ins] = true}, {isInChord = popSize.collect({false})}); - - voices[ins] = adder; - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - - // pad ending - if(orderIndex == (orders.size - 1), { - (0..(popSize-1)).scramble.do({arg ins; - if(res.last.first[ins] != ["Rest"], { - var dur; - voices[ins] = ["Rest"]; - allowChord = (voices != popSize.collect({["Rest"]})); - pad = allowChord.not; - dur = exitsDurFunc.value(allowChord, pad); - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - }); - - //format and return - if(startFromLast, {lastXChanges = lastXChangesHold.deepCopy}); - res; -}; - - -//------primary routines - -genMotif = { - var repeats, fSeq, fDur, durAdd; - - repeats = 1; - fSeq = []; - - repeats.do({arg index; - var motif; - - motif = []; - - orders.do({arg order, o; - var lastState, subMotif; - lastState = if(o == 0, {popSize.collect({["Rest"]})}, {motif.last.last.first}); - subMotif = genSubMotif.value(order, o, lastState, isLastOrder: o == (orders.size - 1)); - motif = motif.add(subMotif); - - }); - - sanityCheck.value(motif, index); - - fSeq = fSeq.add(motif); - }); - - //round last duration to measure - fDur = fSeq.flatten.flatten.slice(nil, 1).sum; - durAdd = fDur.round(4) - fDur; - if(durAdd < 0, {durAdd = 4 - durAdd}); - fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] = fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] + durAdd; - - fSeq -}; - -genSecondarySeq = {arg seq; - var curdles, fSeq; - curdles = []; - while({curdles.sum < seq.size}, {curdles = curdles ++ [3.rand + 1]}); - - fSeq = seq.clumps(curdles).collect({arg clump, m; - var repeats, paddedSeq; - - //add rest - paddedSeq = clump.add([[[popSize.collect({["Rest"]}), 0.5.rand]]]); - - //implement repeats - repeats = [0.rand + 1, 1].wchoose([1, 0].normalizeSum); - repeats.collect({paddedSeq}); - }); - fSeq -}; - - -//------audition funcs - -/* -Event.addEventType(\osc, { - if (~addr.postln.notNil) { - ~addr.sendMsg(~indexPath, ~indexMsg); - ~addr.sendMsg(~seqPath, stringifyToDepth.value(~seqMsg, 3)); - //~addr.sendMsg("/STATE/OPEN", (dir.replace("supercollider", "resources") +/+ ~idMsg +/+ ~idMsg ++ "_gui_state" ++ ".state").standardizePath.postln); - }; -}); -*/ - -Event.addEventType(\osc, { - if (~addr.notNil) { - ~msg; - ~addr.sendMsg(~path, *~msg); - }; -}); - -genPatterns = {arg inSeq, addr, oneShot = false; - var voices, durs, pbinds, res, indices, sectionDurs, msg, ids, seq; - seq = inSeq.collect({arg mSeq; mSeq[0]}); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - pbinds = voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs, attacks, rels, amps; - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - //attacks = 2.collect({rrand(1, 3)}) ++ freqs.drop(2).collect({rrand(0.3, 0.5)}); - attacks = fDurs.collect({arg dur; dur * rrand(0.2, 0.4)}); - //rels = freqs.drop(2).collect({rrand(0.3, 0.5)}) ++ 2.collect({rrand(1, 3)}); - rels = (clumps.size - 1).collect({arg c; - if(clumps[c + 1][0] == ["Rest"], {rrand(1.0, 3.0)}, {rrand(0.3, 0.5)}); - }); - rels = rels.add(rrand(1.0, 3.0)); - amps = freqs.collect({rrand(0.6, 0.99)}); - - [ - Pbind( - \instrument, \string_model, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \attack, Pseq(attacks, 1), - \sustain, Pseq(fDurs, 1), - \release, Pseq(rels, 1), - //\amp, Pseq(amps, 1), - \amp, Pbrown(0.5, 1, 0.5), - \busIndex, v - ), - Pbind( - \instrument, \sine, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \sustain, Pseq(fDurs, 1), - \busIndex, v - ) - ] - }).flatten; - if(oneShot.not, { - msg = inSeq.collect({arg mSeq, m; mSeq[1..]}); - //ids = inSeq.collect({arg mSeq, m; mSeq[2]}); - sectionDurs = seq.collect({arg mSeq; mSeq.flatten2(mSeq.maxDepth - 5).flop[1].sum}); - pbinds = pbinds ++ - [ - Pbind( - \type, \osc, - \addr, addr, - \path, "/playing", - \msg, Pseq(msg, 1), - \dur, Pseq(sectionDurs, 1) - ); - ] - }); - res = Ppar(pbinds); - res -}; - -/* -genMidiPatterns = {arg seq; - var voices, durs, patterns, res, mOut, pbRange; - pbRange = 1; //semitones - change this as needed for your situation - mOut = MIDIOut.newByName("TiMidity", "TiMidity port 0").latency_(Server.default.latency); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - res = Ppar( - voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs; - - mOut.program(v, 70); - - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - - Pbind( - \type, \midi, - \chan, v, - \noteval, Pseq(freqs.cpsmidi - 24, 1), - \note, Pfunc({ | event | event[\noteval].floor }), - \dur, Pseq(fDurs, 1), - \midiout, mOut, - \amp, 1, - \bend, Pfunc({ - | event | - if (event[\note].isRest.not) { - var pitchbendvalue = event[\noteval].frac.linlin(0, pbRange, 8192, 8192*2).asInteger; - m.bend(v, pitchbendvalue); - }; - 0; // return something other than nil to avoid stopping the pattern - }), - ); - }); - ); - res -}; -*/ - - -//------resource management funcs - -genUID = {Date.seed.asHexString.toLower}; - -seedFunc = {arg func, seed; - var funcArgs, next; - next = Routine({loop{func.valueArray(funcArgs).yield }}); - next.randSeed_(seed); - {arg ...args; funcArgs = args; next.value} -}; - -stringifyToDepth = {arg data, maxDepth = 1; - var prettyString = "", rCount = 0, writeArray, indent; - - if(maxDepth == 0, { - data.asCompileString - }, { - indent = {arg size; size.collect({" "}).join("")}; - writeArray = {arg array; - prettyString = prettyString ++ indent.value(rCount) ++ "[\n"; - rCount = rCount + 1; - if(rCount < maxDepth, { - array.do({arg subArray; writeArray.value(subArray)}); - }, { - prettyString = prettyString ++ array.collect({arg subArray; - indent.value(rCount + 1) ++ subArray.asCompileString - }).join(",\n"); - }); - rCount = rCount - 1; - prettyString = prettyString ++ "\n" ++ indent.value(rCount) ++ "],\n"; - }; - - writeArray.value(data); - prettyString.replace(",\n\n", "\n").drop(-2); - }) -}; - -sanityCheck = {arg motif, index; - //print functions = very helpful - ("----------" + index + "------------").postln; - - motif.flatten.do({arg val, v; - if(v > 0, { - if(motif.flatten[v-1][0].hammingDistance(val[0]) > 1, {"problem 1".postln}); - if(motif.flatten[v-1][0].hammingDistance(val[0]) == 0, {"problem 2".postln}); - }); - val.postln - }); - "***********".postln; -}; - -msgInterpret = {arg in, escapeDoubleQuotes = true, escapeSingleQuotes = true; - var res; - - res = in; - if(res.isNil.not, { - if((res.isArray && res.isString.not), { - res = res.asCompileString; - res = res.replace(" ", "").replace("\n", "").replace("\t", ""); - if(escapeSingleQuotes, {res = res.replace("\'", "")}); - if(escapeDoubleQuotes, {res = res.replace("\"", "")}); - res = res.replace("Rest", "\"Rest\""); - res = res.interpret; - }, { - var tmpRes; - if(res.every({arg char; char.isDecDigit}), {tmpRes = res.asInteger}); - if(res.contains("."), {tmpRes = res.asFloat}); - if(tmpRes != nil, {res = tmpRes}); - }); - }); - res -}; - -writeResources = {arg path, dict; - var file, modelItems, resString; - file = File(path,"w"); - - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - - resString = nameSpaces.collect({arg nameSpace; - var depth = 0, insert = " "; - if(nameSpace == "music_data", {depth = 3; insert = "\n"}); - if(nameSpace == "last_changes", {depth = 1; insert = "\n"}); - if(nameSpace == "order", {depth = 1; insert = "\n"}); - if((nameSpace == "ref_uid") && (dict[nameSpace] == nil), {dict[nameSpace] = "nil"}); - "\"" ++ nameSpace ++ "\":" ++ insert ++ stringifyToDepth.value(dict[nameSpace], depth) - }).join(",\n"); - - resString = "{\n" ++ resString ++ "\n}"; - - file.write(resString); - file.close; - resString -}; - -loadModelFile = {arg path; loadModelJSON.value(File(path, "r").readAllString.parseJSON)}; - -loadModelJSON = {arg jsonObject; - var dict; - dict = Dictionary.with(*nameSpaces.collect({arg nS; nS->msgInterpret.value(jsonObject[nS])})); - dict -}; - -setGlobalVars = {arg dict, skipLastXChanges = false; - var tmpLastXChanges; - tmpLastXChanges = lastXChanges.deepCopy; - // order really matters!!!! - # seq, lastXChanges, curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited = nameSpaces.collect({arg nS; dict[nS]}); - if(skipLastXChanges, {lastXChanges = tmpLastXChanges}); - dict -}; - -globalVarsToDict = { - var modelItems, dict; - // order really matters!!!! - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - dict = Dictionary.with(*nameSpaces.collect({arg nS, n; nS->modelItems[n]})); -}; - -loadLedgerFile = {arg path; - ledgerPath = path; - loadLedgerJSON.value(File(ledgerPath, "r").readAllString.parseJSON) -}; - -loadLedgerJSON = {arg jsonObject; ledger = jsonObject["ledger"]}; - -saveLedger = {arg ledger, path; - var file; - file = File(path, "w"); - file.write("{\n\"ledger\":\n" ++ stringifyToDepth.value(ledger, 1) ++ "\n}"); - file.close; -}; - -//------global vars - -primes = [[2, 1], [3, 2], [5, 4], [7, 4], [11, 8], [13, 8]]; -//ranges = [[-2400, 0], [-1200, 1200], [0, 2400], [0, 2400]]; -exPath = thisProcess.nowExecutingPath; -dir = exPath.dirname; -//popSize = 4; -dims = primes.size; -tuples = genTuples.value(); -//refUID = nil; -group = Group.new; -~group = group; -loadLedgerFile.value(dir +/+ ".." +/+ "resources" +/+ "piece_ledger.json"); -//passagesWeights = [1, 1, 1, 1, 1]; -//susWeights = [1, 1, 1]; -// order really matters!!!! -nameSpaces = [ - "music_data", "last_changes", "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", - "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", - "ranges", "step_probs_vals", "passages_weights", "hd_exp", "hd_invert", - "order", "sus_weights", "order_size", "passages_size", - "motif_edited", "order_edited" -]; - - -//------OSC funcs - -OSCdef(\load_ledger, {arg msg, time, addr, port; - loadLedgerFile.value(msg[1].asString); -}, \load_ledger); - -OSCdef(\load_model, {arg msg, time, addr, port; - var dict; - dict = loadModelFile.value(msg[1].asString); - setGlobalVars.value(dict); -}, \load_model); - -OSCdef(\save_ledger, {arg msg, time, addr, port; - msg.postln; - ledger = msgInterpret.value(msg[1].asString.parseJSON["ledger"], false).postln; - //loadLedgerJSON.value(msg[0]) - saveLedger.value(ledger, msg[2].asString); - //loadLedgerFile.value(msg[1].asString); -}, \save_ledger); - -OSCdef(\generate, {arg msg, time, addr, port; - var path, dict, durSeeds, musPath, modelString; - msg.postln; - - path = msg[1].asString; - - dict = loadModelFile.value(path); - setGlobalVars.value(dict, true); - - popSize = ranges.size; - - //refUID.postln; - - loadLedgerFile.value(ledgerPath); - if(ledger == nil, {ledger = ["tmp"]}); - if(ledger.last != "tmp", {ledger = ledger.add("tmp")}); - - if(refUID == nil, {lastXChanges = [initVoices.value().deepCopy]}); - if((refUID != nil) && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - lastXChanges = msgInterpret.value(file.readAllString.parseJSON["last_changes"]); - }); - - refUID.postln; - lastXChanges.collect({arg item; item.postln}); - - durSeeds = seedFunc.value({3.collect({rrand(100000, 999999)})}, durSeed).value.postln; - entrancesDurFunc = genDurFunc.valueArray(entrancesProbVals[..4] ++ [entrancesProbVals[5..]] ++ [durSeeds[0]]); - passagesDurFunc = genDurFunc.valueArray(passagesProbVals[..4] ++ [passagesProbVals[5..]] ++ [durSeeds[1]]); - exitsDurFunc = genDurFunc.valueArray(exitsProbVals[..4] ++ [exitsProbVals[5..]] ++ [durSeeds[2]]); - - if(orders == nil, { - orders = seedFunc.value(genOrders, orderSeed).valueArray(orderSize ++ passagesSize); - //addr.sendMsg("/order", stringifyToDepth.value(orders, 1)); - }); - - stepFunc = genStepFunc.valueArray(stepProbsVals[..1] ++ [stepProbsVals[2..]] ++ [motifSeed]); - seq = seedFunc.value(genMotif, motifSeed).value; - - lastXChanges.collect({arg item; item.postln}); - - dict = globalVarsToDict.value; - modelString = writeResources.value(path, dict); - - //addr.sendMsg("/generated", musPath, stringifyToDepth.value(seq, 3)); - //~seq = seq; - - addr.sendMsg("/generated", path, modelString, ledgerPath); -}, \generate); - - -OSCdef(\commit, {arg msg, time, addr, port; - var musicData, musicChanged, dict, newLedger, modelPath, musString, musFile, test1, test2, lastCurUID, commitType; - //msg.postln; - - /* - test1 = msg[1].asString.parseJSON; - test2 = (dir +/+ ".." +/+ "resources/tmp/tmp_music" ++ ".json").standardizePath.parseJSONFile; - msgInterpret.value(test1["music"])[0][0][0][1].class.postln; - msgInterpret.value(test2["music_data"])[0][0][0][1].class.postln; - (test1["music"] == test2["music_data"]).postln; - */ - - musicData = loadModelJSON.value(msg[1].asString.parseJSON)["music_data"].postln; - musicChanged = (musicData != seq).postln; - commitType = msg[2].asString; - - lastCurUID = curUID.deepCopy; - curUID = genUID.value; - - File.mkdir((dir +/+ ".." +/+ "resources" +/+ curUID).standardizePath); - File.copy(exPath, (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_code" ++ ".scd").standardizePath); - - modelPath = (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_mus_model" ++ ".json").standardizePath; - dict = globalVarsToDict.value; - if(musicChanged, { - seq = musicData; - dict["music_data"] = seq; - dict["motif_edited"] = "true" - }); - dict["cur_uid"] = curUID; - - writeResources.value(modelPath, dict); - - File.delete(ledgerPath ++ "_bak"); - File.copy(ledgerPath, ledgerPath ++ "_bak"); - File.delete(ledgerPath); - - if(commitType == "add", { - if(lastCurUID == "tmp", { - ledger = ledger.drop(-1).add(ledger.indexOf(curUID)); - }, { - ledger = ledger.add(curUID); - }) - }); - - if(commitType == "insert", {ledger = ledger.insert(lastCurUID, curUID)}); - - if(commitType == "replace", {ledger = ledger.put(lastCurUID, curUID)}); - - saveLedger.value(ledger, ledgerPath); - - addr.sendMsg("/committed", curUID, ledgerPath); - //refUID = curUID; - -}, \commit); - -OSCdef(\transport, {arg msg, time, addr, port; - msg.postln; - if(msg[1] == 0, { - group.set(\release, 2); - group.set(\gate, 0); - player.stop; - }, { - // the cued sequence can now be read from file, so this can be cleaned up - var cSize, patterns, pSeq, cuedSeek, indexStart, indexEnd, tmpLedger; - if(msg[1] == 1, { - pSeq = []; - cuedSeek = (seq != nil); - indexStart = msg[2].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.postln.parseJSON["music_data"]), path, indexStart + index, uid]); - file.close; - }); - }); - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - patterns = genPatterns.value(pSeq, addr); - }, { - pSeq = [loadModelJSON.value(msg[2].asString.parseJSON)["music_data"].postln]; - patterns = genPatterns.value(pSeq, addr, true); - }); - player = Pfset(pattern: patterns, cleanupFunc: { - addr.sendMsg("/transport", 0); - addr.sendMsg("/one_shot", 0); - }); - player = player.play - }); -}, \transport); - - -OSCdef(\transcribe_motif, {arg msg, time, addr, port; - var tSeq, refChord, refUID; - - msg.postln; - - tSeq = [loadModelJSON.value(msg[1].asString.parseJSON)["music_data"]]; - refUID = msg[2].asString.postln; - - if((refUID != "nil") && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }, { - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - }); - - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "lilypond" +/+ "includes").standardizePath, addr, "/transcribe_motif"); -}, \transcribe_motif); - - -OSCdef(\transcribe_all, {arg msg, time, addr, port; - var cSize, patterns, cuedSeek, indexStart, indexEnd, tmpLedger; - if(true, { - cuedSeek = (seq != nil); - indexStart = msg[1].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - - //tmp for testing transcription - indexEnd = (indexStart+5); - - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - var lilyPartLedgerFiles; - - lilyPartLedgerFiles = 4.collect({arg p; - File((dir +/+ ".." +/+ "lilypond" +/+ "includes" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly").standardizePath, "w"); - }); - - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file, fileString, tSeq, refUID, refChord; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - fileString = file.readAllString; - tSeq = msgInterpret.value(fileString.parseJSON["music_data"]); - refUID = msgInterpret.value(fileString.parseJSON["ref_uid"]); - file.close; - - //uid.postln; - //(refUID == "nil").postln; - - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - - if(refUID != "nil", { - path = (dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }); - - if(index != indexEnd, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath); - }, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath, addr, "/transcribe_all"); - }); - - lilyPartLedgerFiles.do({arg f, p; - f.write("\\include \".." +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly\"\n"); - }); - - }); - - lilyPartLedgerFiles.do({arg f; - f.close - }); - }); - /* - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - */ - }, { - - }); - -}, \transcribe_all); - -) - -~transcribe.value(~seq, dir); - -( -//synthdefs -~stringModelBusArray = 4.collect({Bus.audio(s, 1)}); -~sineBusArray = 4.collect({Bus.audio(s, 1)}); -~bassBusArray = 1.collect({Bus.audio(s, 1)}); -~hdustBusArray = 1.collect({Bus.audio(s, 1)}); -~samplerBusArray = 2.collect({Bus.audio(s, 1)}); -~sBuf = Buffer.alloc(s, 10, 2); -SynthDef(\string_model, {arg freq, gate = 1, sustain, amp, dur, attack, release = 1, busIndex = 0; - var trig, exc, sig1, sig2, noHarms; - noHarms = rrand(20, 40); - exc = Saw.ar(freq, TRand.ar(0.5, 1, Impulse.ar(freq))) * 0.001 + Dust.ar(10000, 0.01); - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.8).softclip; - //sig1 = HPF.ar(sig1, 300); - Out.ar(Select.kr(busIndex, ~stringModelBusArray), sig1 * amp * EnvGen.kr(Env.adsr(attack, 0.3, 0.9, release, 0.9, -3), gate, doneAction: 2)); - //Out.ar([0, 1], sig1 * EnvGen.kr(Env.asr(dur, 0.3, 1), gate, doneAction: 2)); -}).add; - -SynthDef(\sine, {arg freq, gate = 1, sustain, amp, dur, busIndex = 0; - var sig; - sig = SinOsc.ar(freq); - Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.asr(0.3, 0.4, 0.3), gate, timeScale: dur, doneAction: 2)); - //Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.sine(dur), gate, doneAction: 2)); -}).add; - -SynthDef(\mixer, {arg freq, gate = 1, sustain, amp, dur, out; - var nameSpaces, sigs; - - sigs = [~stringModelBusArray, ~sineBusArray/*, ~bassBusArray, ~hdustBusArray, ~samplerBusArray*/].collect({arg busArray, i; - var nameSpace, sig; - nameSpace = ['string', 'sine', 'bass', 'hdust', 'sampler'][i]; - sig = busArray.collect({arg bus, c; In.ar(bus, 1) * NamedControl.kr(\ ++ nameSpace ++ '_volume_' ++ c, 1, 0.1)}); - sig = sig.collect({arg channel, c; Pan2.ar(channel, NamedControl.kr(\ ++ nameSpace ++ '_pan_' ++ c, i / (busArray.size - 1), 0.1) * 2 - 1)}); - sig = sig.collect({arg channel, c; channel * NamedControl.kr(\ ++ nameSpace ++ '_mute_' ++ c, 1, 0.1)}); - sig = Mix.ar(sig) * pow(NamedControl.kr(\ ++ nameSpace ++ '_volume_master', 1, 0.1), 2); - }); - - sigs = Mix.ar(sigs / 4); - Out.ar(0, sigs) -}).add; - -SynthDef(\bass, { - var switches, drone; - switches = {|i| Dust.kr(0.1)} ! 9; - drone = {|i| var harm = pow(2, 2 - (i / 3).trunc), amp = (1 / pow(harm, 2)); - SinOsc.ar(60 * harm + TRand.kr(-3, 3, switches[i]), 0, amp)} ! 9; - Out.ar(~bassBusArray[0], Mix.new(drone) * 0.2); -}).add; - -SynthDef(\sampler, { - Out.ar(~samplerBusArray, PlayBuf.ar(2, ~sBuf, BufRateScale.kr(~sBuf), doneAction: 2)) -}).add; - -// main routine -SynthDef(\hdust, { - arg gate = 0; - var hierarchical_dust, low_sine, high_sine, brown_noise, white_noise; - // this triggers the combinations of sources - // it is similar to the Supercollider UGen called dust but with a hierarchical structure - hierarchical_dust = ( - TIRand.kr(0, 1, Impulse.kr(100)) * - TIRand.kr(0, 1, Impulse.kr(10)) * - TIRand.kr(0, 1, Impulse.kr(1)) * - TIRand.kr(0, 1, Impulse.kr(0.1)) - ); - // adjust the multiplier at the end of each line for adjusting levels - // note with each trigger, each source has a 1 in 3 chance of sounding - low_sine = SinOsc.ar(76.midicps / 16) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.1; - high_sine = SinOsc.ar(76.midicps * 8) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.01; - brown_noise = BrownNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.025; - white_noise = WhiteNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.02; - Out.ar(~hdustBusArray[0], - ((low_sine + high_sine + brown_noise + white_noise) ) - ); -}).add; - -) - -( -var bass, hdust, sampler, mixer; -/* -bass = Synth.tail(~group, \bass); -hdust = Synth.tail(~group, \hdust); -sampler = Synth.head(~group, \sampler); -*/ -mixer = Synth.tail(~group, \mixer); - -OSCdef(\mixer, {arg msg, time, addr, port; - mixer.set((msg[1] ++ '_' ++ msg[2] ++ '_' ++ msg[3]), msg[4]) -}, \mixer); - -/* -OSCdef(\sampler, {arg msg, time, addr, port; - msg.postln; - sampler.free; - ~sBuf.free; - ~sBuf = Buffer.read(s, msg[1].asString.postln, action: {sampler = Synth.head(~group, \sampler)}); -}, \sampler); -*/ -) - -/* old something -( -SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; - var trig, exc, sig1, sig2, noHarms, freqFinal, start, end; - noHarms = 30; - freq = WhiteNoise.ar * 3 + freq; - freqFinal = Duty.ar((1/freq), 0, freq); - trig = Changed.ar(freqFinal); - start = Demand.ar(trig, 0, Dwhite(-1, -0.75)); - end = Demand.ar(trig, 0, Dwhite(0.75, 1)); - exc = Phasor.ar(trig, (end - start) * freqFinal / SampleRate.ir, start, end, 0) * 0.001 + Dust.ar(10000, 0.01); - - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(2, 3)}) ], exc) * 0.5).softclip; - sig1 = HPF.ar(sig1, 300); - Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); -}).add; -) -*/ - diff --git a/resources/4f65a9b5/4f65a9b5_mus_model.json b/resources/4f65a9b5/4f65a9b5_mus_model.json deleted file mode 100644 index d0d96ef..0000000 --- a/resources/4f65a9b5/4f65a9b5_mus_model.json +++ /dev/null @@ -1,46 +0,0 @@ -{ -"music_data": -[ - [ - [ - [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ] ], 2.125 ], - [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ] ], 2.625 ], - [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], 10.125 ], - [ [ [ 0, 0, 0, 0, 0, 0 ], [ 2, 0, 0, 0, -1, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], 2.375 ], - [ [ [ 0, 0, 0, 0, 0, 0 ], [ 1, 1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], 10 ], - [ [ [ 0, 0, 0, 0, 0, 0 ], [ 1, 1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ] ], 0.125 ], - [ [ [ 0, 0, 0, 0, 0, 0 ], [ 1, 1, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ] ], 1.625 ], - [ [ [ "Rest" ], [ 1, 1, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ] ], 2.75 ], - [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 12.25 ] - ] - ] -], -"last_changes": -[ - [ [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], - [ [ 0, 0, 0, 0, 0, 0 ], [ 2, 0, 0, 0, -1, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], - [ [ 0, 0, 0, 0, 0, 0 ], [ 1, 1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ] -], -"cur_uid": "4f65a9b5", -"ref_uid": "nil", -"order_seed": 355251, -"dur_seed": 773995, -"motifs_seed": 203444, -"entrances_probs_vals": [ 0, 0, 10, 0, 3.08, 0, 0.64527027027027, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"passages_probs_vals": [ 0, 0, 10, 0, 3.08, 0, 0.64527027027027, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"exits_probs_vals": [ 0, 0, 10, 0, 3.08, 0, 0.64527027027027, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"ranges": [ [ 1419.1950464396, 2400 ], [ 1519.5046439628, 2400 ], [ 1541.7956656347, 2237 ], [ 1519.5046439628, 2053 ] ], -"step_probs_vals": [ 0, 1200, 0, 0.5, 0.5, 0.5, 1, 0.5 ], -"passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], -"hd_exp": 2, -"hd_invert": 0, -"order": -[ - [ [ 3, 0, 2 ], [ 1, 1 ], [ ] ] -], -"sus_weights": [ 0.75, 0.69, 0.75 ], -"order_size": [ 1, 2 ], -"passages_size": [ 0, 2 ], -"motif_edited": "false", -"order_edited": "false" -} \ No newline at end of file diff --git a/resources/52af48e5/52af48e5_code.scd b/resources/52af48e5/52af48e5_code.scd deleted file mode 100644 index 47fbb43..0000000 --- a/resources/52af48e5/52af48e5_code.scd +++ /dev/null @@ -1,1046 +0,0 @@ -( -// helper funcs -var hsArrayToCents, pDist, hdSum, hsChordalDistance, hsArrayToFreq; - -// score funcs -var isInRange, spacingScore, rangeScore, intervalScore, inclusionScore; - -// subroutines -var genTuples, initVoices, genOrders, genSubMotif, updateVoices, genDurFunc, genStepFunc; - -// primary routines -var genMotif, genSecondarySeq; - -// audition funcs -var genPatterns, genMidiPatterns; - -// resource management funcs -var seedFunc, genUID, writeResources, stringifyToDepth, setSeeds, sanityCheck, -msgInterpret, loadLedgerFile, loadLedgerJSON, loadModelFile, loadModelJSON, -setGlobalVars, globalVarsToDict, saveLedger; - -// model vars -//(model and global vars mostly set by OSC funcs -var seq, lastXChanges, -curUID, refUID, orderSeed, durSeed, motifSeed, -entrancesProbVals, passagesProbVals, exitsProbVals, -ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, -orders, susWeights, orderSize, passagesSize, -motifEdited, orderEdited; - -// model aux vars -var entrancesDurFunc, passagesDurFunc, exitsDurFunc, stepFunc; - -// other global vars -var popSize, exPath, dir, primes, dims, tuples, -group, player, ledgerPath, ledger, currentlyPlayingUID, -nameSpaces; - -// install JSON quark -if(Quarks.isInstalled("JSONlib").not, { - Quarks.install("https://github.com/musikinformatik/JSONlib.git"); - thisProcess.recompile; - //HelpBrowser.openHelpFor("Classes/JSONlib"); -}); - - -//------helper funcs - -hsArrayToCents = { - arg hsArray; - hsArray.collect({arg dist, p; dist * 1200 * log2(primes[p][0]/primes[p][1])}).sum -}; - -pDist = { - arg array1, array2, signed = false; - var pDistance; - pDistance = hsArrayToCents.value(array1) - hsArrayToCents.value(array2); - if(signed, {pDistance}, {abs(pDistance)}) -}; - -hdSum = { - arg hsArrays; - var size, distances, mean; - size = hsArrays.size; - distances = (size - 1).collect({arg i; - ((i + 1)..(size - 1)).collect({arg j; - abs(hsArrays[i] - hsArrays[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsChordalDistance = { - arg hsArrays1, hsArrays2; - var size, distances, mean; - size = hsArrays1.size; - distances = hsArrays1.size.collect({arg i; - hsArrays2.size.collect({arg j; - abs(hsArrays1[i] - hsArrays2[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsArrayToFreq = { - arg array; - array.collect({arg dim, d; pow(primes[d][0]/primes[d][1], dim)}).product -}; - -//------score funcs - -/* -isInRange = { - arg hsArray, min, max; - var cents; - cents = hsArrayToCents.value(hsArray); - (cents >= min) && (cents <= max) -}; -*/ - -spacingScore = { - arg hsArrays, min; - var centsArray; - centsArray = hsArrays.collect({arg hsArray; hsArrayToCents.value(hsArray)}).sort({arg a, b; a < b}); - centsArray.differentiate.drop(1).collect({arg pDistance; if(pDistance >= min, {1}, {0.01})}).sum; -}; - -rangeScore = { - arg hsArray1, hsArray2, min, max, low, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - if((pDistance >= min) && (pDistance <= max), {1}, {low}); -}; - -intervalScore = { - arg hsArray1, hsArray2, mean, sd, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - //pDistance.gaussCurve(1, mean, sd) - stepFunc.value(pDistance); -}; - -inclusionScore = { - arg array, test, min = 0.01; - if(array.collect({arg v; v.hash}).includes(test.hash), {min}, {1}); -}; - - -//------subroutines - -genTuples = { - var tuples; - tuples = dims.collect({[-1, 0, 1]}).allTuples.select({arg tuple; (abs(tuple.drop(1)).sum <= 1) && (tuple[0] == 0)}); - tuples = tuples ++ tuples.collect({arg tuple; [-3, -2, -1, 1, 2, 3].collect({arg octTrans; tuple.deepCopy.put(0, octTrans)})}).flatten; -}; - -initVoices = { - var init, voicesInit; - voicesInit = popSize.collect({dims.collect({0})}); - /* - voicesInit = [dims.collect({0})]; - (popSize - 1).do({ - arg rep, new; - rep = dims.rand; - new = voicesInit.last.deepCopy; - new[rep] = new[rep] + [-1, 1].choose(); - voicesInit = voicesInit.add(new); - }); - */ - voicesInit.deepCopy; -}; - -genDurFunc = {arg chordProb, minPad, maxPad, minDur, maxDur, envData, seed; - var env, pTable, durFunc; - env = Env.pairs([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).asSignal(256).asList.asArray; - pTable = env.asRandomTable; - [chordProb, minPad, maxPad, minDur, maxDur, envData].postln; - durFunc = {arg allowChord, pad = false; - var res; - res = if(allowChord.not, { - pTable.tableRand * (maxDur - minDur) + minDur - }, { - if(1.0.rand < chordProb, {0}, {pTable.tableRand * (maxDur - minDur) + minDur}); - }).round(0.125); - if(pad, {res = res + rrand(minPad.asFloat, maxPad.asFloat).round(0.125)}); - if(res.asInteger == res, {res = res.asInteger}); - res - }; - seedFunc.value(durFunc, seed); -}; - -genStepFunc = {arg minStep, maxStep, envData, seed; - var envDataNorm, env, pTable, stepFunc; - [minStep, maxStep, envData].postln; - envDataNorm = ([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).flop; - envDataNorm = [envDataNorm[0].normalize(minStep, maxStep), envDataNorm[1]].flop; - env = Env.pairs(envDataNorm); - stepFunc = {arg pDist; - env.at(pDist).clip(0.001, 1); - }; - seedFunc.value(stepFunc, seed); -}; - -genOrders = {arg minMotifLength = 1, maxMotifLength = 5, minProgLength = 0, maxProgLength = 5; - ((maxMotifLength - minMotifLength).rand + minMotifLength).collect({ - var noProgIns, noSusIns, noSilentIns, prog, sus, silent, order; - noSusIns = [1, 2, 3].wchoose(susWeights.normalizeSum); - noProgIns = (popSize - noSusIns).rand + 1; - noSilentIns = popSize - noSusIns - noProgIns; - - # prog, sus, silent = (0..(popSize-1)).scramble.clumps([noProgIns, noSusIns, noSilentIns]); - - prog = (prog.scramble ++ ((maxProgLength - minProgLength).rand + minProgLength).collect({prog.choose}).scramble); - if(silent == nil, {silent = []}); - [sus.scramble, prog, silent.scramble] - }); -}; - -updateVoices = {arg ins, sus; - var voices, candidates, nWeights, nProbs, sel; - - voices = lastXChanges.deepCopy.last; - - candidates = sus.collect({arg v; tuples.collect({arg t; voices[v] + t})}).flatten; - candidates = difference(candidates.asSet, voices.asSet).asList; - nProbs = candidates.collect({arg candidate; - var stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore; - - //stepScore = intervalScore.value(voices[ins], candidate, 30, 400, 0.1); - stepScore = intervalScore.value(voices[ins], candidate, 100, 100); - recentlySoundedScore = inclusionScore.value(lastXChanges.flop[ins], candidate, 0); - isInRangeScore = rangeScore.value(candidate, candidate.collect({0}), ranges[ins][0], ranges[ins][1], 0, true); - regScore = spacingScore.value(voices.deepCopy.put(ins, candidate), 300); - hdScore = pow(hdSum.value(voices.deepCopy.put(ins, candidate)), hdExp); - if(hdInvert == 0, {hdScore = 1/hdScore}); - //maybe what you want here is a vector to another root and then favoring movement towards it. - //distScore = pow(hsChordalDistance.value(voices, voices.put(ins, candidate)), 2); - - [stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore] - }); - - nWeights = passagesWeights; - - //this handles nWeights of 0; mainly for testing - nProbs = nProbs.flop.select({arg scores, s; nWeights[s] != 0}).flop; - nWeights = nWeights.select({arg weight; weight != 0}); - nProbs = nProbs.flop.collect({arg scores, s; - if(scores.sum == 0, {scores}, {scores.normalizeSum * nWeights[s]}) - }); - nProbs = nProbs.flop.collect({arg scores, s; scores.product}).normalizeSum; - - sel = candidates.wchoose(nProbs); - - voices[ins] = sel; - lastXChanges = lastXChanges.add(voices).keep(-5); -}; - -genSubMotif = {arg order, orderIndex, lastState, repeatLast = false, startFromLast = false, isLastOrder = false; - var sus, prog, silent, flatOrder, res, isInChord, allowChord, pad, lastXChangesHold, voices, adder; - # sus, prog, silent = order; - flatOrder = silent ++ sus ++ prog; - lastXChangesHold = lastXChanges.deepCopy; - voices = lastState.deepCopy; - isInChord = popSize.collect({false}); - allowChord = false; - pad = false; - res = []; - "------generating motif".postln; - //need to figure out here if voices move between motifs - flatOrder.do({arg ins, i; - - if(prog.includes(ins) && repeatLast.not, {updateVoices.value(ins, sus)}); - adder = if(silent.includes(ins), {["Rest"]}, {lastXChanges.last.deepCopy[ins]}); - - if(voices[ins] != adder, { - var dur; - - if((sus ++ silent).includes(ins), { - allowChord = (ins != sus.last); - pad = (ins == sus.last); - }, { - if(i < (flatOrder.size - 1), { - allowChord = (isInChord[flatOrder[i + 1]] || (ins == flatOrder[i + 1])).not; - pad = false; - }, { - allowChord = false; - pad = true - }); - }); - if((orderIndex == 0) && sus.includes(ins), { - dur = entrancesDurFunc.value(allowChord, pad); - }, { - dur = passagesDurFunc.value(allowChord, pad); - }); - if(dur == 0, {isInChord[ins] = true}, {isInChord = popSize.collect({false})}); - - voices[ins] = adder; - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - - // pad ending - if(orderIndex == (orders.size - 1), { - (0..(popSize-1)).scramble.do({arg ins; - if(res.last.first[ins] != ["Rest"], { - var dur; - voices[ins] = ["Rest"]; - allowChord = (voices != popSize.collect({["Rest"]})); - pad = allowChord.not; - dur = exitsDurFunc.value(allowChord, pad); - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - }); - - //format and return - if(startFromLast, {lastXChanges = lastXChangesHold.deepCopy}); - res; -}; - - -//------primary routines - -genMotif = { - var repeats, fSeq, fDur, durAdd; - - repeats = 1; - fSeq = []; - - repeats.do({arg index; - var motif; - - motif = []; - - orders.do({arg order, o; - var lastState, subMotif; - lastState = if(o == 0, {popSize.collect({["Rest"]})}, {motif.last.last.first}); - subMotif = genSubMotif.value(order, o, lastState, isLastOrder: o == (orders.size - 1)); - motif = motif.add(subMotif); - - }); - - sanityCheck.value(motif, index); - - fSeq = fSeq.add(motif); - }); - - //round last duration to measure - fDur = fSeq.flatten.flatten.slice(nil, 1).sum; - durAdd = fDur.round(4) - fDur; - if(durAdd < 0, {durAdd = 4 - durAdd}); - fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] = fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] + durAdd; - - fSeq -}; - -genSecondarySeq = {arg seq; - var curdles, fSeq; - curdles = []; - while({curdles.sum < seq.size}, {curdles = curdles ++ [3.rand + 1]}); - - fSeq = seq.clumps(curdles).collect({arg clump, m; - var repeats, paddedSeq; - - //add rest - paddedSeq = clump.add([[[popSize.collect({["Rest"]}), 0.5.rand]]]); - - //implement repeats - repeats = [0.rand + 1, 1].wchoose([1, 0].normalizeSum); - repeats.collect({paddedSeq}); - }); - fSeq -}; - - -//------audition funcs - -/* -Event.addEventType(\osc, { - if (~addr.postln.notNil) { - ~addr.sendMsg(~indexPath, ~indexMsg); - ~addr.sendMsg(~seqPath, stringifyToDepth.value(~seqMsg, 3)); - //~addr.sendMsg("/STATE/OPEN", (dir.replace("supercollider", "resources") +/+ ~idMsg +/+ ~idMsg ++ "_gui_state" ++ ".state").standardizePath.postln); - }; -}); -*/ - -Event.addEventType(\osc, { - if (~addr.notNil) { - ~msg; - ~addr.sendMsg(~path, *~msg); - }; -}); - -genPatterns = {arg inSeq, addr, oneShot = false; - var voices, durs, pbinds, res, indices, sectionDurs, msg, ids, seq; - seq = inSeq.collect({arg mSeq; mSeq[0]}); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - pbinds = voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs, attacks, rels, amps; - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - //attacks = 2.collect({rrand(1, 3)}) ++ freqs.drop(2).collect({rrand(0.3, 0.5)}); - attacks = fDurs.collect({arg dur; dur * rrand(0.2, 0.4)}); - //rels = freqs.drop(2).collect({rrand(0.3, 0.5)}) ++ 2.collect({rrand(1, 3)}); - rels = (clumps.size - 1).collect({arg c; - if(clumps[c + 1][0] == ["Rest"], {rrand(1.0, 3.0)}, {rrand(0.3, 0.5)}); - }); - rels = rels.add(rrand(1.0, 3.0)); - amps = freqs.collect({rrand(0.6, 0.99)}); - - [ - Pbind( - \instrument, \string_model, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \attack, Pseq(attacks, 1), - \sustain, Pseq(fDurs, 1), - \release, Pseq(rels, 1), - //\amp, Pseq(amps, 1), - \amp, Pbrown(0.5, 1, 0.5), - \busIndex, v - ), - Pbind( - \instrument, \sine, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \sustain, Pseq(fDurs, 1), - \busIndex, v - ) - ] - }).flatten; - if(oneShot.not, { - msg = inSeq.collect({arg mSeq, m; mSeq[1..]}); - //ids = inSeq.collect({arg mSeq, m; mSeq[2]}); - sectionDurs = seq.collect({arg mSeq; mSeq.flatten2(mSeq.maxDepth - 5).flop[1].sum}); - pbinds = pbinds ++ - [ - Pbind( - \type, \osc, - \addr, addr, - \path, "/playing", - \msg, Pseq(msg, 1), - \dur, Pseq(sectionDurs, 1) - ); - ] - }); - res = Ppar(pbinds); - res -}; - -/* -genMidiPatterns = {arg seq; - var voices, durs, patterns, res, mOut, pbRange; - pbRange = 1; //semitones - change this as needed for your situation - mOut = MIDIOut.newByName("TiMidity", "TiMidity port 0").latency_(Server.default.latency); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - res = Ppar( - voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs; - - mOut.program(v, 70); - - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - - Pbind( - \type, \midi, - \chan, v, - \noteval, Pseq(freqs.cpsmidi - 24, 1), - \note, Pfunc({ | event | event[\noteval].floor }), - \dur, Pseq(fDurs, 1), - \midiout, mOut, - \amp, 1, - \bend, Pfunc({ - | event | - if (event[\note].isRest.not) { - var pitchbendvalue = event[\noteval].frac.linlin(0, pbRange, 8192, 8192*2).asInteger; - m.bend(v, pitchbendvalue); - }; - 0; // return something other than nil to avoid stopping the pattern - }), - ); - }); - ); - res -}; -*/ - - -//------resource management funcs - -genUID = {Date.seed.asHexString.toLower}; - -seedFunc = {arg func, seed; - var funcArgs, next; - next = Routine({loop{func.valueArray(funcArgs).yield }}); - next.randSeed_(seed); - {arg ...args; funcArgs = args; next.value} -}; - -stringifyToDepth = {arg data, maxDepth = 1; - var prettyString = "", rCount = 0, writeArray, indent; - - if(maxDepth == 0, { - data.asCompileString - }, { - indent = {arg size; size.collect({" "}).join("")}; - writeArray = {arg array; - prettyString = prettyString ++ indent.value(rCount) ++ "[\n"; - rCount = rCount + 1; - if(rCount < maxDepth, { - array.do({arg subArray; writeArray.value(subArray)}); - }, { - prettyString = prettyString ++ array.collect({arg subArray; - indent.value(rCount + 1) ++ subArray.asCompileString - }).join(",\n"); - }); - rCount = rCount - 1; - prettyString = prettyString ++ "\n" ++ indent.value(rCount) ++ "],\n"; - }; - - writeArray.value(data); - prettyString.replace(",\n\n", "\n").drop(-2); - }) -}; - -sanityCheck = {arg motif, index; - //print functions = very helpful - ("----------" + index + "------------").postln; - - motif.flatten.do({arg val, v; - if(v > 0, { - if(motif.flatten[v-1][0].hammingDistance(val[0]) > 1, {"problem 1".postln}); - if(motif.flatten[v-1][0].hammingDistance(val[0]) == 0, {"problem 2".postln}); - }); - val.postln - }); - "***********".postln; -}; - -msgInterpret = {arg in, escapeDoubleQuotes = true, escapeSingleQuotes = true; - var res; - - res = in; - if(res.isNil.not, { - if((res.isArray && res.isString.not), { - res = res.asCompileString; - res = res.replace(" ", "").replace("\n", "").replace("\t", ""); - if(escapeSingleQuotes, {res = res.replace("\'", "")}); - if(escapeDoubleQuotes, {res = res.replace("\"", "")}); - res = res.replace("Rest", "\"Rest\""); - res = res.interpret; - }, { - var tmpRes; - if(res.every({arg char; char.isDecDigit}), {tmpRes = res.asInteger}); - if(res.contains("."), {tmpRes = res.asFloat}); - if(tmpRes != nil, {res = tmpRes}); - }); - }); - res -}; - -writeResources = {arg path, dict; - var file, modelItems, resString; - file = File(path,"w"); - - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - - resString = nameSpaces.collect({arg nameSpace; - var depth = 0, insert = " "; - if(nameSpace == "music_data", {depth = 3; insert = "\n"}); - if(nameSpace == "last_changes", {depth = 1; insert = "\n"}); - if(nameSpace == "order", {depth = 1; insert = "\n"}); - if((nameSpace == "ref_uid") && (dict[nameSpace] == nil), {dict[nameSpace] = "nil"}); - "\"" ++ nameSpace ++ "\":" ++ insert ++ stringifyToDepth.value(dict[nameSpace], depth) - }).join(",\n"); - - resString = "{\n" ++ resString ++ "\n}"; - - file.write(resString); - file.close; - resString -}; - -loadModelFile = {arg path; loadModelJSON.value(File(path, "r").readAllString.parseJSON)}; - -loadModelJSON = {arg jsonObject; - var dict; - dict = Dictionary.with(*nameSpaces.collect({arg nS; nS->msgInterpret.value(jsonObject[nS])})); - dict -}; - -setGlobalVars = {arg dict, skipLastXChanges = false; - var tmpLastXChanges; - tmpLastXChanges = lastXChanges.deepCopy; - // order really matters!!!! - # seq, lastXChanges, curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited = nameSpaces.collect({arg nS; dict[nS]}); - if(skipLastXChanges, {lastXChanges = tmpLastXChanges}); - dict -}; - -globalVarsToDict = { - var modelItems, dict; - // order really matters!!!! - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - dict = Dictionary.with(*nameSpaces.collect({arg nS, n; nS->modelItems[n]})); -}; - -loadLedgerFile = {arg path; - ledgerPath = path; - loadLedgerJSON.value(File(ledgerPath, "r").readAllString.parseJSON) -}; - -loadLedgerJSON = {arg jsonObject; ledger = jsonObject["ledger"]}; - -saveLedger = {arg ledger, path; - var file; - file = File(path, "w"); - file.write("{\n\"ledger\":\n" ++ stringifyToDepth.value(ledger, 1) ++ "\n}"); - file.close; -}; - -//------global vars - -primes = [[2, 1], [3, 2], [5, 4], [7, 4], [11, 8], [13, 8]]; -//ranges = [[-2400, 0], [-1200, 1200], [0, 2400], [0, 2400]]; -exPath = thisProcess.nowExecutingPath; -dir = exPath.dirname; -//popSize = 4; -dims = primes.size; -tuples = genTuples.value(); -//refUID = nil; -group = Group.new; -~group = group; -loadLedgerFile.value(dir +/+ ".." +/+ "resources" +/+ "piece_ledger.json"); -//passagesWeights = [1, 1, 1, 1, 1]; -//susWeights = [1, 1, 1]; -// order really matters!!!! -nameSpaces = [ - "music_data", "last_changes", "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", - "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", - "ranges", "step_probs_vals", "passages_weights", "hd_exp", "hd_invert", - "order", "sus_weights", "order_size", "passages_size", - "motif_edited", "order_edited" -]; - - -//------OSC funcs - -OSCdef(\load_ledger, {arg msg, time, addr, port; - loadLedgerFile.value(msg[1].asString); -}, \load_ledger); - -OSCdef(\load_model, {arg msg, time, addr, port; - var dict; - dict = loadModelFile.value(msg[1].asString); - setGlobalVars.value(dict); -}, \load_model); - -OSCdef(\save_ledger, {arg msg, time, addr, port; - msg.postln; - ledger = msgInterpret.value(msg[1].asString.parseJSON["ledger"], false).postln; - //loadLedgerJSON.value(msg[0]) - saveLedger.value(ledger, msg[2].asString); - //loadLedgerFile.value(msg[1].asString); -}, \save_ledger); - -OSCdef(\generate, {arg msg, time, addr, port; - var path, dict, durSeeds, musPath, modelString; - msg.postln; - - path = msg[1].asString; - - dict = loadModelFile.value(path); - setGlobalVars.value(dict, true); - - popSize = ranges.size; - - //refUID.postln; - - loadLedgerFile.value(ledgerPath); - if(ledger == nil, {ledger = ["tmp"]}); - if(ledger.last != "tmp", {ledger = ledger.add("tmp")}); - - if(refUID == nil, {lastXChanges = [initVoices.value().deepCopy]}); - if((refUID != nil) && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - lastXChanges = msgInterpret.value(file.readAllString.parseJSON["last_changes"]); - }); - - refUID.postln; - lastXChanges.collect({arg item; item.postln}); - - durSeeds = seedFunc.value({3.collect({rrand(100000, 999999)})}, durSeed).value.postln; - entrancesDurFunc = genDurFunc.valueArray(entrancesProbVals[..4] ++ [entrancesProbVals[5..]] ++ [durSeeds[0]]); - passagesDurFunc = genDurFunc.valueArray(passagesProbVals[..4] ++ [passagesProbVals[5..]] ++ [durSeeds[1]]); - exitsDurFunc = genDurFunc.valueArray(exitsProbVals[..4] ++ [exitsProbVals[5..]] ++ [durSeeds[2]]); - - if(orders == nil, { - orders = seedFunc.value(genOrders, orderSeed).valueArray(orderSize ++ passagesSize); - //addr.sendMsg("/order", stringifyToDepth.value(orders, 1)); - }); - - stepFunc = genStepFunc.valueArray(stepProbsVals[..1] ++ [stepProbsVals[2..]] ++ [motifSeed]); - seq = seedFunc.value(genMotif, motifSeed).value; - - lastXChanges.collect({arg item; item.postln}); - - dict = globalVarsToDict.value; - modelString = writeResources.value(path, dict); - - //addr.sendMsg("/generated", musPath, stringifyToDepth.value(seq, 3)); - //~seq = seq; - - addr.sendMsg("/generated", path, modelString, ledgerPath); -}, \generate); - - -OSCdef(\commit, {arg msg, time, addr, port; - var musicData, musicChanged, dict, newLedger, modelPath, musString, musFile, test1, test2, lastCurUID, commitType; - //msg.postln; - - /* - test1 = msg[1].asString.parseJSON; - test2 = (dir +/+ ".." +/+ "resources/tmp/tmp_music" ++ ".json").standardizePath.parseJSONFile; - msgInterpret.value(test1["music"])[0][0][0][1].class.postln; - msgInterpret.value(test2["music_data"])[0][0][0][1].class.postln; - (test1["music"] == test2["music_data"]).postln; - */ - - musicData = loadModelJSON.value(msg[1].asString.parseJSON)["music_data"].postln; - musicChanged = (musicData != seq).postln; - commitType = msg[2].asString; - - lastCurUID = curUID.deepCopy; - curUID = genUID.value; - - File.mkdir((dir +/+ ".." +/+ "resources" +/+ curUID).standardizePath); - File.copy(exPath, (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_code" ++ ".scd").standardizePath); - - modelPath = (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_mus_model" ++ ".json").standardizePath; - dict = globalVarsToDict.value; - if(musicChanged, { - seq = musicData; - dict["music_data"] = seq; - dict["motif_edited"] = "true" - }); - dict["cur_uid"] = curUID; - - writeResources.value(modelPath, dict); - - File.delete(ledgerPath ++ "_bak"); - File.copy(ledgerPath, ledgerPath ++ "_bak"); - File.delete(ledgerPath); - - if(commitType == "add", { - if(lastCurUID == "tmp", { - ledger = ledger.drop(-1).add(ledger.indexOf(curUID)); - }, { - ledger = ledger.add(curUID); - }) - }); - - if(commitType == "insert", {ledger = ledger.insert(lastCurUID, curUID)}); - - if(commitType == "replace", {ledger = ledger.put(lastCurUID, curUID)}); - - saveLedger.value(ledger, ledgerPath); - - addr.sendMsg("/committed", curUID, ledgerPath); - //refUID = curUID; - -}, \commit); - -OSCdef(\transport, {arg msg, time, addr, port; - msg.postln; - if(msg[1] == 0, { - group.set(\release, 2); - group.set(\gate, 0); - player.stop; - }, { - // the cued sequence can now be read from file, so this can be cleaned up - var cSize, patterns, pSeq, cuedSeek, indexStart, indexEnd, tmpLedger; - if(msg[1] == 1, { - pSeq = []; - cuedSeek = (seq != nil); - indexStart = msg[2].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.postln.parseJSON["music_data"]), path, indexStart + index, uid]); - file.close; - }); - }); - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - patterns = genPatterns.value(pSeq, addr); - }, { - pSeq = [loadModelJSON.value(msg[2].asString.parseJSON)["music_data"].postln]; - patterns = genPatterns.value(pSeq, addr, true); - }); - player = Pfset(pattern: patterns, cleanupFunc: { - addr.sendMsg("/transport", 0); - addr.sendMsg("/one_shot", 0); - }); - player = player.play - }); -}, \transport); - - -OSCdef(\transcribe_motif, {arg msg, time, addr, port; - var tSeq, refChord, refUID; - - msg.postln; - - tSeq = [loadModelJSON.value(msg[1].asString.parseJSON)["music_data"]]; - refUID = msg[2].asString.postln; - - if((refUID != "nil") && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }, { - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - }); - - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "lilypond" +/+ "includes").standardizePath, addr, "/transcribe_motif"); -}, \transcribe_motif); - - -OSCdef(\transcribe_all, {arg msg, time, addr, port; - var cSize, patterns, cuedSeek, indexStart, indexEnd, tmpLedger; - if(true, { - cuedSeek = (seq != nil); - indexStart = msg[1].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - - //tmp for testing transcription - indexEnd = (indexStart+5); - - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - var lilyPartLedgerFiles; - - lilyPartLedgerFiles = 4.collect({arg p; - File((dir +/+ ".." +/+ "lilypond" +/+ "includes" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly").standardizePath, "w"); - }); - - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file, fileString, tSeq, refUID, refChord; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - fileString = file.readAllString; - tSeq = msgInterpret.value(fileString.parseJSON["music_data"]); - refUID = msgInterpret.value(fileString.parseJSON["ref_uid"]); - file.close; - - //uid.postln; - //(refUID == "nil").postln; - - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - - if(refUID != "nil", { - path = (dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }); - - if(index != indexEnd, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath); - }, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath, addr, "/transcribe_all"); - }); - - lilyPartLedgerFiles.do({arg f, p; - f.write("\\include \".." +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly\"\n"); - }); - - }); - - lilyPartLedgerFiles.do({arg f; - f.close - }); - }); - /* - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - */ - }, { - - }); - -}, \transcribe_all); - -) - -~transcribe.value(~seq, dir); - -( -//synthdefs -~stringModelBusArray = 4.collect({Bus.audio(s, 1)}); -~sineBusArray = 4.collect({Bus.audio(s, 1)}); -~bassBusArray = 1.collect({Bus.audio(s, 1)}); -~hdustBusArray = 1.collect({Bus.audio(s, 1)}); -~samplerBusArray = 2.collect({Bus.audio(s, 1)}); -~sBuf = Buffer.alloc(s, 10, 2); -SynthDef(\string_model, {arg freq, gate = 1, sustain, amp, dur, attack, release = 1, busIndex = 0; - var trig, exc, sig1, sig2, noHarms; - noHarms = rrand(20, 40); - exc = Saw.ar(freq, TRand.ar(0.5, 1, Impulse.ar(freq))) * 0.001 + Dust.ar(10000, 0.01); - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.8).softclip; - //sig1 = HPF.ar(sig1, 300); - Out.ar(Select.kr(busIndex, ~stringModelBusArray), sig1 * amp * EnvGen.kr(Env.adsr(attack, 0.3, 0.9, release, 0.9, -3), gate, doneAction: 2)); - //Out.ar([0, 1], sig1 * EnvGen.kr(Env.asr(dur, 0.3, 1), gate, doneAction: 2)); -}).add; - -SynthDef(\sine, {arg freq, gate = 1, sustain, amp, dur, busIndex = 0; - var sig; - sig = SinOsc.ar(freq); - Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.asr(0.3, 0.4, 0.3), gate, timeScale: dur, doneAction: 2)); - //Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.sine(dur), gate, doneAction: 2)); -}).add; - -SynthDef(\mixer, {arg freq, gate = 1, sustain, amp, dur, out; - var nameSpaces, sigs; - - sigs = [~stringModelBusArray, ~sineBusArray/*, ~bassBusArray, ~hdustBusArray, ~samplerBusArray*/].collect({arg busArray, i; - var nameSpace, sig; - nameSpace = ['string', 'sine', 'bass', 'hdust', 'sampler'][i]; - sig = busArray.collect({arg bus, c; In.ar(bus, 1) * NamedControl.kr(\ ++ nameSpace ++ '_volume_' ++ c, 1, 0.1)}); - sig = sig.collect({arg channel, c; Pan2.ar(channel, NamedControl.kr(\ ++ nameSpace ++ '_pan_' ++ c, i / (busArray.size - 1), 0.1) * 2 - 1)}); - sig = sig.collect({arg channel, c; channel * NamedControl.kr(\ ++ nameSpace ++ '_mute_' ++ c, 1, 0.1)}); - sig = Mix.ar(sig) * pow(NamedControl.kr(\ ++ nameSpace ++ '_volume_master', 1, 0.1), 2); - }); - - sigs = Mix.ar(sigs / 4); - Out.ar(0, sigs) -}).add; - -SynthDef(\bass, { - var switches, drone; - switches = {|i| Dust.kr(0.1)} ! 9; - drone = {|i| var harm = pow(2, 2 - (i / 3).trunc), amp = (1 / pow(harm, 2)); - SinOsc.ar(60 * harm + TRand.kr(-3, 3, switches[i]), 0, amp)} ! 9; - Out.ar(~bassBusArray[0], Mix.new(drone) * 0.2); -}).add; - -SynthDef(\sampler, { - Out.ar(~samplerBusArray, PlayBuf.ar(2, ~sBuf, BufRateScale.kr(~sBuf), doneAction: 2)) -}).add; - -// main routine -SynthDef(\hdust, { - arg gate = 0; - var hierarchical_dust, low_sine, high_sine, brown_noise, white_noise; - // this triggers the combinations of sources - // it is similar to the Supercollider UGen called dust but with a hierarchical structure - hierarchical_dust = ( - TIRand.kr(0, 1, Impulse.kr(100)) * - TIRand.kr(0, 1, Impulse.kr(10)) * - TIRand.kr(0, 1, Impulse.kr(1)) * - TIRand.kr(0, 1, Impulse.kr(0.1)) - ); - // adjust the multiplier at the end of each line for adjusting levels - // note with each trigger, each source has a 1 in 3 chance of sounding - low_sine = SinOsc.ar(76.midicps / 16) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.1; - high_sine = SinOsc.ar(76.midicps * 8) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.01; - brown_noise = BrownNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.025; - white_noise = WhiteNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.02; - Out.ar(~hdustBusArray[0], - ((low_sine + high_sine + brown_noise + white_noise) ) - ); -}).add; - -) - -( -var bass, hdust, sampler, mixer; -/* -bass = Synth.tail(~group, \bass); -hdust = Synth.tail(~group, \hdust); -sampler = Synth.head(~group, \sampler); -*/ -mixer = Synth.tail(~group, \mixer); - -OSCdef(\mixer, {arg msg, time, addr, port; - mixer.set((msg[1] ++ '_' ++ msg[2] ++ '_' ++ msg[3]), msg[4]) -}, \mixer); - -/* -OSCdef(\sampler, {arg msg, time, addr, port; - msg.postln; - sampler.free; - ~sBuf.free; - ~sBuf = Buffer.read(s, msg[1].asString.postln, action: {sampler = Synth.head(~group, \sampler)}); -}, \sampler); -*/ -) - -/* old something -( -SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; - var trig, exc, sig1, sig2, noHarms, freqFinal, start, end; - noHarms = 30; - freq = WhiteNoise.ar * 3 + freq; - freqFinal = Duty.ar((1/freq), 0, freq); - trig = Changed.ar(freqFinal); - start = Demand.ar(trig, 0, Dwhite(-1, -0.75)); - end = Demand.ar(trig, 0, Dwhite(0.75, 1)); - exc = Phasor.ar(trig, (end - start) * freqFinal / SampleRate.ir, start, end, 0) * 0.001 + Dust.ar(10000, 0.01); - - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(2, 3)}) ], exc) * 0.5).softclip; - sig1 = HPF.ar(sig1, 300); - Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); -}).add; -) -*/ - diff --git a/resources/52af48e5/52af48e5_mus_model.json b/resources/52af48e5/52af48e5_mus_model.json deleted file mode 100644 index f704ff5..0000000 --- a/resources/52af48e5/52af48e5_mus_model.json +++ /dev/null @@ -1,46 +0,0 @@ -{ -"music_data": -[ - [ - [ - [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ] ], 2.125 ], - [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ] ], 2.625 ], - [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], 10.125 ], - [ [ [ 0, 0, 0, 0, 0, 0 ], [ 2, 0, 0, 0, -1, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], 2.375 ], - [ [ [ 0, 0, 0, 0, 0, 0 ], [ 1, 1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], 10 ], - [ [ [ 0, 0, 0, 0, 0, 0 ], [ 1, 1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ] ], 0.125 ], - [ [ [ 0, 0, 0, 0, 0, 0 ], [ 1, 1, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ] ], 1.625 ], - [ [ [ "Rest" ], [ 1, 1, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ] ], 2.75 ], - [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 12.25 ] - ] - ] -], -"last_changes": -[ - [ [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], - [ [ 0, 0, 0, 0, 0, 0 ], [ 2, 0, 0, 0, -1, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], - [ [ 0, 0, 0, 0, 0, 0 ], [ 1, 1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ] -], -"cur_uid": "52af48e5", -"ref_uid": "nil", -"order_seed": 355251, -"dur_seed": 773995, -"motifs_seed": 203444, -"entrances_probs_vals": [ 0, 0, 10, 0, 3.08, 0, 0.64527027027027, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"passages_probs_vals": [ 0, 0, 10, 0, 3.08, 0, 0.64527027027027, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"exits_probs_vals": [ 0, 0, 10, 0, 3.08, 0, 0.64527027027027, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"ranges": [ [ 1419.1950464396, 2400 ], [ 1519.5046439628, 2400 ], [ 1541.7956656347, 2237 ], [ 1519.5046439628, 2053 ] ], -"step_probs_vals": [ 0, 1200, 0, 0.5, 0.5, 0.5, 1, 0.5 ], -"passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], -"hd_exp": 2, -"hd_invert": 0, -"order": -[ - [ [ 3, 0, 2 ], [ 1, 1 ], [ ] ] -], -"sus_weights": [ 0.75, 0.69, 0.75 ], -"order_size": [ 1, 2 ], -"passages_size": [ 0, 2 ], -"motif_edited": "false", -"order_edited": "false" -} \ No newline at end of file diff --git a/resources/535cc132/535cc132_mus_model.json b/resources/535cc132/535cc132_mus_model.json deleted file mode 100644 index dcd0704..0000000 --- a/resources/535cc132/535cc132_mus_model.json +++ /dev/null @@ -1,91 +0,0 @@ -{ -"music_data": -[ - [ - [ - [ [ [ 1, -1, 0, 0, -1, 1 ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 0 ], - [ [ [ 1, -1, 0, 0, -1, 1 ], [ "Rest" ], [ 1, -1, 0, 0, -1, 1 ], [ "Rest" ] ], 0 ], - [ [ [ 1, -1, 0, 0, -1, 1 ], [ "Rest" ], [ 1, -1, 0, 0, -1, 1 ], [ 1, -1, 0, 0, -1, 1 ] ], 8.375 ], - [ [ [ 1, -1, 0, 0, -1, 1 ], [ 0, -1, 0, 0, -1, 2 ], [ 1, -1, 0, 0, -1, 1 ], [ 1, -1, 0, 0, -1, 1 ] ], 1.5 ], - [ [ [ 1, -1, 0, 0, -1, 1 ], [ 0, 0, 0, 0, -1, 1 ], [ 1, -1, 0, 0, -1, 1 ], [ 1, -1, 0, 0, -1, 1 ] ], 0.875 ], - [ [ [ 1, -1, 0, 0, -1, 1 ], [ 1, -2, 0, 0, -1, 1 ], [ 1, -1, 0, 0, -1, 1 ], [ 1, -1, 0, 0, -1, 1 ] ], 0.75 ], - [ [ [ 1, -1, 0, 0, -1, 1 ], [ 0, -1, 1, 0, -1, 1 ], [ 1, -1, 0, 0, -1, 1 ], [ 1, -1, 0, 0, -1, 1 ] ], 0.75 ], - [ [ [ 1, -1, 0, 0, -1, 1 ], [ 1, -1, 0, -1, -1, 1 ], [ 1, -1, 0, 0, -1, 1 ], [ 1, -1, 0, 0, -1, 1 ] ], 10.75 ] - ], - [ - [ [ [ 1, -1, 0, 0, -1, 1 ], [ 1, -1, 0, -1, -1, 1 ], [ 1, -1, 0, 0, -1, 1 ], [ 2, -1, 0, -1, -1, 1 ] ], 0.625 ], - [ [ [ 1, -1, 0, 0, -1, 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"Rest" ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 8.375 ] - ] - ] -], -"last_changes": -[ - [ [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], - [ [ 1, -1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], - [ [ 0, 0, -1, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], - [ [ -1, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], - [ [ 0, -1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ] -], -"cur_uid": "535cc132", -"ref_uid": "nil", -"order_seed": 209164, -"dur_seed": 417909, -"motifs_seed": 885208, -"entrances_probs_vals": [ 0.34, 0, 10, 0.5, 2, 0, 0.5, 0.24509803921569, 0.89189189189189, 0.5, 1, 0.5, 0.5, 0.8562091503268, 0.69932432432432, 1, 0.5 ], -"passages_probs_vals": [ 0.34, 0, 10, 0.5, 2, 0, 0.5, 0.24509803921569, 0.89189189189189, 0.5, 1, 0.5, 0.5, 0.8562091503268, 0.69932432432432, 1, 0.5 ], -"exits_probs_vals": [ 0.34, 0, 10, 0.5, 2, 0, 0.5, 0.24509803921569, 0.89189189189189, 0.5, 1, 0.5, 0.5, 0.8562091503268, 0.69932432432432, 1, 0.5 ], -"ranges": [ [ -1200, 2400 ], [ -1200, 2400 ], [ -1200, 2400 ], [ -1200, 2400 ] ], -"step_probs_vals": [ 0, 1200, 0, 0.5, 0.5, 0.5, 1, 0.5 ], -"passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], -"hd_exp": 2, -"hd_invert": 0, -"order": -[ - [ [ 2 ], [ 0, 0, 0, 0 ], [ 1, 3 ] ] -], -"sus_weights": [ 0.75, 0.75, 0.75 ], -"order_size": [ 1, 10 ], -"passages_size": [ 0, 10 ], -"motif_edited": "true", -"order_edited": "false" -} \ No newline at end of file diff --git a/resources/53ad554b/53ad554b_mus_model.json b/resources/53ad554b/53ad554b_mus_model.json deleted file mode 100644 index fe62c6d..0000000 --- a/resources/53ad554b/53ad554b_mus_model.json +++ /dev/null @@ -1,86 +0,0 @@ -{ -"music_data": -[ - [ - [ - [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ] ], 8.375 ], - [ [ [ 1, 0, -1, 0, 0, 0 ], [ "Rest" ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ] ], 0 ], - [ [ [ 1, 0, -1, 0, 0, 0 ], [ "Rest" ], [ 1, -1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], 0.375 ], - [ [ [ 1, 1, 0, 0, 0, 0 ], [ "Rest" ], [ 1, -1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], 0 ], - [ [ [ 1, 1, 0, 0, 0, 0 ], [ "Rest" ], [ 1, 0, 0, 0, 0, -1 ], [ 0, 0, 0, 0, 0, 0 ] ], 0.375 ], - [ [ [ 1, 1, 0, 0, 0, 0 ], [ "Rest" ], [ 1, 0, -1, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], 0.375 ], - [ [ [ 1, 1, 0, 0, 0, 0 ], [ "Rest" ], [ 0, 1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], 0 ], - [ [ [ 2, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 0, 1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], 0.375 ], - [ [ [ 2, 0, 0, 0, 0, 0 ], [ "Rest" ],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 0, -1, 0, 0, 0 ] ], - [ [ 1, -1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, -1 ], [ 2, -2, 0, 0, 0, 0 ] ], - [ [ 1, -1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, -1 ], [ 2, 0, 0, 0, 0, -1 ] ] -], -"cur_uid": "53ad554b", -"ref_uid": "nil", -"order_seed": 157046, -"dur_seed": 249113, -"motifs_seed": 618906, -"entrances_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.26424870466321, 0.75675675675676, 0.5, 0.5, 0.58549222797927, 0.72635135135135, 1, 0.5 ], -"passages_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"exits_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"ranges": [ [ -384, 2400 ], [ -507, 2400 ], [ -282, 2237 ], [ -1200, 2053 ] ], -"step_probs_vals": [ 0, 1200, 0, 0.5, 0.5, 0.5, 1, 0.5 ], -"passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], -"hd_exp": 0.75, -"hd_invert": 0, -"order": -[ - [ [ 3 ], [ 0, 2, 0, 2, 2, 2, 0, 2, 0, 0 ], [ 1 ] ], - [ [ 3, 1 ], [ 0, 0 ], [ 2 ] ], - [ [ 3, 1 ], [ 2, 0, 2, 0, 2, 0, 0, 2, 2, 0 ], [ ] ], - [ [ 0, 1, 2 ], [ 3, 3, 3, 3, 3, 3, 3, 3, 3 ], [ ] ] -], -"sus_weights": [ 0.75, 0.69, 0.75 ], -"order_size": [ 2, 6 ], -"passages_size": [ 0, 10 ], -"motif_edited": "false", -"order_edited": "false" -} \ No newline at end of file diff --git a/resources/57a598e2/57a598e2_code.scd b/resources/57a598e2/57a598e2_code.scd deleted file mode 100644 index 3eb3cbd..0000000 --- a/resources/57a598e2/57a598e2_code.scd +++ /dev/null @@ -1,1058 +0,0 @@ -( -// helper funcs -var hsArrayToCents, pDist, hdSum, hsChordalDistance, hsArrayToFreq; - -// score funcs -var isInRange, spacingScore, rangeScore, intervalScore, inclusionScore; - -// subroutines -var genTuples, initVoices, genOrders, genSubMotif, updateVoices, genDurFunc, genStepFunc; - -// primary routines -var genMotif, genSecondarySeq; - -// audition funcs -var genPatterns, genMidiPatterns; - -// resource management funcs -var seedFunc, genUID, writeResources, stringifyToDepth, setSeeds, sanityCheck, -msgInterpret, loadLedgerFile, loadLedgerJSON, loadModelFile, loadModelJSON, -setGlobalVars, globalVarsToDict, saveLedger; - -// model vars -//(model and global vars mostly set by OSC funcs -var seq, lastXChanges, -curUID, refUID, orderSeed, durSeed, motifSeed, -entrancesProbVals, passagesProbVals, exitsProbVals, -ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, -orders, susWeights, orderSize, passagesSize, -motifEdited, orderEdited; - -// model aux vars -var entrancesDurFunc, passagesDurFunc, exitsDurFunc, stepFunc; - -// other global vars -var popSize, exPath, dir, primes, dims, tuples, -group, player, ledgerPath, ledger, currentlyPlayingUID, -nameSpaces; - -// install JSON quark -if(Quarks.isInstalled("JSONlib").not, { - Quarks.install("https://github.com/musikinformatik/JSONlib.git"); - thisProcess.recompile; - //HelpBrowser.openHelpFor("Classes/JSONlib"); -}); - - -//------helper funcs - -hsArrayToCents = { - arg hsArray; - hsArray.collect({arg dist, p; dist * 1200 * log2(primes[p][0]/primes[p][1])}).sum -}; - -pDist = { - arg array1, array2, signed = false; - var pDistance; - pDistance = hsArrayToCents.value(array1) - hsArrayToCents.value(array2); - if(signed, {pDistance}, {abs(pDistance)}) -}; - -hdSum = { - arg hsArrays; - var size, distances, mean; - size = hsArrays.size; - distances = (size - 1).collect({arg i; - ((i + 1)..(size - 1)).collect({arg j; - abs(hsArrays[i] - hsArrays[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsChordalDistance = { - arg hsArrays1, hsArrays2; - var size, distances, mean; - size = hsArrays1.size; - distances = hsArrays1.size.collect({arg i; - hsArrays2.size.collect({arg j; - abs(hsArrays1[i] - hsArrays2[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsArrayToFreq = { - arg array; - array.collect({arg dim, d; pow(primes[d][0]/primes[d][1], dim)}).product -}; - -//------score funcs - -/* -isInRange = { - arg hsArray, min, max; - var cents; - cents = hsArrayToCents.value(hsArray); - (cents >= min) && (cents <= max) -}; -*/ - -spacingScore = { - arg hsArrays, min; - var centsArray; - centsArray = hsArrays.collect({arg hsArray; hsArrayToCents.value(hsArray)}).sort({arg a, b; a < b}); - centsArray.differentiate.drop(1).collect({arg pDistance; if(pDistance >= min, {1}, {0.01})}).sum; -}; - -rangeScore = { - arg hsArray1, hsArray2, min, max, low, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - if((pDistance >= min) && (pDistance <= max), {1}, {low}); -}; - -intervalScore = { - arg hsArray1, hsArray2, mean, sd, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - //pDistance.gaussCurve(1, mean, sd) - stepFunc.value(pDistance); -}; - -inclusionScore = { - arg array, test, min = 0.01; - if(array.collect({arg v; v.hash}).includes(test.hash), {min}, {1}); -}; - - -//------subroutines - -genTuples = { - var tuples; - tuples = dims.collect({[-1, 0, 1]}).allTuples.select({arg tuple; (abs(tuple.drop(1)).sum <= 1) && (tuple[0] == 0)}); - tuples = tuples ++ tuples.collect({arg tuple; [-3, -2, -1, 1, 2, 3].collect({arg octTrans; tuple.deepCopy.put(0, octTrans)})}).flatten; -}; - -initVoices = { - var init, voicesInit; - voicesInit = popSize.collect({dims.collect({0})}); - /* - voicesInit = [dims.collect({0})]; - (popSize - 1).do({ - arg rep, new; - rep = dims.rand; - new = voicesInit.last.deepCopy; - new[rep] = new[rep] + [-1, 1].choose(); - voicesInit = voicesInit.add(new); - }); - */ - voicesInit.deepCopy; -}; - -genDurFunc = {arg chordProb, minPad, maxPad, minDur, maxDur, envData, seed; - var env, pTable, durFunc; - env = Env.pairs([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).asSignal(256).asList.asArray; - pTable = env.asRandomTable; - [chordProb, minPad, maxPad, minDur, maxDur, envData].postln; - durFunc = {arg allowChord, pad = false; - var res; - res = if(allowChord.not, { - pTable.tableRand * (maxDur - minDur) + minDur - }, { - if(1.0.rand < chordProb, {0}, {pTable.tableRand * (maxDur - minDur) + minDur}); - }).round(0.125); - if(pad, {res = res + rrand(minPad.asFloat, maxPad.asFloat).round(0.125)}); - if(res.asInteger == res, {res = res.asInteger}); - res - }; - seedFunc.value(durFunc, seed); -}; - -genStepFunc = {arg minStep, maxStep, envData, seed; - var envDataNorm, env, pTable, stepFunc; - [minStep, maxStep, envData].postln; - envDataNorm = ([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).flop; - envDataNorm = [envDataNorm[0].normalize(minStep, maxStep), envDataNorm[1]].flop; - env = Env.pairs(envDataNorm); - stepFunc = {arg pDist; - env.at(pDist).clip(0.001, 1); - }; - seedFunc.value(stepFunc, seed); -}; - -genOrders = {arg minMotifLength = 1, maxMotifLength = 5, minProgLength = 0, maxProgLength = 5; - ((maxMotifLength - minMotifLength).rand + minMotifLength).collect({ - var noProgIns, noSusIns, noSilentIns, prog, sus, silent, order; - noSusIns = [1, 2, 3].wchoose(susWeights.normalizeSum); - noProgIns = (popSize - noSusIns).rand + 1; - noSilentIns = popSize - noSusIns - noProgIns; - - # prog, sus, silent = (0..(popSize-1)).scramble.clumps([noProgIns, noSusIns, noSilentIns]); - - prog = (prog.scramble ++ ((maxProgLength - minProgLength).rand + minProgLength).collect({prog.choose}).scramble); - if(silent == nil, {silent = []}); - [sus.scramble, prog, silent.scramble] - }); -}; - -updateVoices = {arg ins, sus; - var voices, candidates, nWeights, nProbs, sel; - - voices = lastXChanges.deepCopy.last; - - candidates = sus.collect({arg v; tuples.collect({arg t; voices[v] + t})}).flatten; - candidates = difference(candidates.asSet, voices.asSet).asList; - nProbs = candidates.collect({arg candidate; - var stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore; - - //stepScore = intervalScore.value(voices[ins], candidate, 30, 400, 0.1); - stepScore = intervalScore.value(voices[ins], candidate, 100, 100); - recentlySoundedScore = inclusionScore.value(lastXChanges.flop[ins], candidate, 0); - isInRangeScore = rangeScore.value(candidate, candidate.collect({0}), ranges[ins][0], ranges[ins][1], 0, true); - regScore = spacingScore.value(voices.deepCopy.put(ins, candidate), 300); - hdScore = pow(hdSum.value(voices.deepCopy.put(ins, candidate)), hdExp); - if(hdInvert == 0, {hdScore = 1/hdScore}); - //maybe what you want here is a vector to another root and then favoring movement towards it. - //distScore = pow(hsChordalDistance.value(voices, voices.put(ins, candidate)), 2); - - [stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore] - }); - - nWeights = passagesWeights; - - //this handles nWeights of 0; mainly for testing - nProbs = nProbs.flop.select({arg scores, s; nWeights[s] != 0}).flop; - nWeights = nWeights.select({arg weight; weight != 0}); - nProbs = nProbs.flop.collect({arg scores, s; - if(scores.sum == 0, {scores}, {scores.normalizeSum * nWeights[s]}) - }); - nProbs = nProbs.flop.collect({arg scores, s; scores.product}).normalizeSum; - - sel = candidates.wchoose(nProbs); - - voices[ins] = sel; - lastXChanges = lastXChanges.add(voices).keep(-5); -}; - -genSubMotif = {arg order, orderIndex, lastState, repeatLast = false, startFromLast = false, isLastOrder = false; - var sus, prog, silent, flatOrder, res, isInChord, allowChord, pad, lastXChangesHold, voices, adder; - # sus, prog, silent = order; - flatOrder = silent ++ sus ++ prog; - lastXChangesHold = lastXChanges.deepCopy; - voices = lastState.deepCopy; - isInChord = popSize.collect({false}); - allowChord = false; - pad = false; - res = []; - "------generating motif".postln; - //need to figure out here if voices move between motifs - flatOrder.do({arg ins, i; - - if(prog.includes(ins) && repeatLast.not, {updateVoices.value(ins, sus)}); - adder = if(silent.includes(ins), {["Rest"]}, {lastXChanges.last.deepCopy[ins]}); - - if(voices[ins] != adder, { - var dur; - - if((sus ++ silent).includes(ins), { - allowChord = (ins != sus.last); - pad = (ins == sus.last); - }, { - if(i < (flatOrder.size - 1), { - allowChord = (isInChord[flatOrder[i + 1]] || (ins == flatOrder[i + 1])).not; - pad = false; - }, { - allowChord = false; - pad = true - }); - }); - if((orderIndex == 0) && sus.includes(ins), { - dur = entrancesDurFunc.value(allowChord, pad); - }, { - dur = passagesDurFunc.value(allowChord, pad); - }); - if(dur == 0, {isInChord[ins] = true}, {isInChord = popSize.collect({false})}); - - voices[ins] = adder; - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - - // pad ending - if(orderIndex == (orders.size - 1), { - (0..(popSize-1)).scramble.do({arg ins; - if(res.last.first[ins] != ["Rest"], { - var dur; - voices[ins] = ["Rest"]; - allowChord = (voices != popSize.collect({["Rest"]})); - pad = allowChord.not; - dur = exitsDurFunc.value(allowChord, pad); - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - }); - - //format and return - if(startFromLast, {lastXChanges = lastXChangesHold.deepCopy}); - res; -}; - - -//------primary routines - -genMotif = { - var repeats, fSeq, fDur, durAdd; - - repeats = 1; - fSeq = []; - - repeats.do({arg index; - var motif; - - motif = []; - - orders.do({arg order, o; - var lastState, subMotif; - lastState = if(o == 0, {popSize.collect({["Rest"]})}, {motif.last.last.first}); - subMotif = genSubMotif.value(order, o, lastState, isLastOrder: o == (orders.size - 1)); - motif = motif.add(subMotif); - - }); - - sanityCheck.value(motif, index); - - fSeq = fSeq.add(motif); - }); - - //round last duration to measure - fDur = fSeq.flatten.flatten.slice(nil, 1).sum; - durAdd = fDur.round(4) - fDur; - if(durAdd < 0, {durAdd = 4 - durAdd}); - fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] = fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] + durAdd; - - fSeq -}; - -genSecondarySeq = {arg seq; - var curdles, fSeq; - curdles = []; - while({curdles.sum < seq.size}, {curdles = curdles ++ [3.rand + 1]}); - - fSeq = seq.clumps(curdles).collect({arg clump, m; - var repeats, paddedSeq; - - //add rest - paddedSeq = clump.add([[[popSize.collect({["Rest"]}), 0.5.rand]]]); - - //implement repeats - repeats = [0.rand + 1, 1].wchoose([1, 0].normalizeSum); - repeats.collect({paddedSeq}); - }); - fSeq -}; - - -//------audition funcs - -/* -Event.addEventType(\osc, { - if (~addr.postln.notNil) { - ~addr.sendMsg(~indexPath, ~indexMsg); - ~addr.sendMsg(~seqPath, stringifyToDepth.value(~seqMsg, 3)); - //~addr.sendMsg("/STATE/OPEN", (dir.replace("supercollider", "resources") +/+ ~idMsg +/+ ~idMsg ++ "_gui_state" ++ ".state").standardizePath.postln); - }; -}); -*/ - -Event.addEventType(\osc, { - if (~addr.notNil) { - ~msg; - ~addr.sendMsg(~path, *~msg); - }; -}); - -genPatterns = {arg inSeq, addr, oneShot = false; - var voices, durs, pbinds, res, indices, sectionDurs, msg, ids, seq; - seq = inSeq.collect({arg mSeq; mSeq[0]}); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - pbinds = voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs, attacks, rels, amps; - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - //attacks = 2.collect({rrand(1, 3)}) ++ freqs.drop(2).collect({rrand(0.3, 0.5)}); - attacks = fDurs.collect({arg dur; dur * rrand(0.2, 0.4)}); - //rels = freqs.drop(2).collect({rrand(0.3, 0.5)}) ++ 2.collect({rrand(1, 3)}); - rels = (clumps.size - 1).collect({arg c; - if(clumps[c + 1][0] == ["Rest"], {rrand(1.0, 3.0)}, {rrand(0.3, 0.5)}); - }); - rels = rels.add(rrand(1.0, 3.0)); - amps = freqs.collect({rrand(0.6, 0.99)}); - - [ - Pbind( - \instrument, \string_model, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \attack, Pseq(attacks, 1), - \sustain, Pseq(fDurs, 1), - \release, Pseq(rels, 1), - //\amp, Pseq(amps, 1), - \amp, Pbrown(0.5, 1, 0.5), - \busIndex, v - ), - Pbind( - \instrument, \sine, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \sustain, Pseq(fDurs, 1), - \busIndex, v - ) - ] - }).flatten; - if(oneShot.not, { - msg = inSeq.collect({arg mSeq, m; mSeq[1..]}); - //ids = inSeq.collect({arg mSeq, m; mSeq[2]}); - sectionDurs = seq.collect({arg mSeq; mSeq.flatten2(mSeq.maxDepth - 5).flop[1].sum}); - pbinds = pbinds ++ - [ - Pbind( - \type, \osc, - \addr, addr, - \path, "/playing", - \msg, Pseq(msg, 1), - \dur, Pseq(sectionDurs, 1) - ); - ] - }); - res = Ppar(pbinds); - res -}; - -/* -genMidiPatterns = {arg seq; - var voices, durs, patterns, res, mOut, pbRange; - pbRange = 1; //semitones - change this as needed for your situation - mOut = MIDIOut.newByName("TiMidity", "TiMidity port 0").latency_(Server.default.latency); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - res = Ppar( - voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs; - - mOut.program(v, 70); - - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - - Pbind( - \type, \midi, - \chan, v, - \noteval, Pseq(freqs.cpsmidi - 24, 1), - \note, Pfunc({ | event | event[\noteval].floor }), - \dur, Pseq(fDurs, 1), - \midiout, mOut, - \amp, 1, - \bend, Pfunc({ - | event | - if (event[\note].isRest.not) { - var pitchbendvalue = event[\noteval].frac.linlin(0, pbRange, 8192, 8192*2).asInteger; - m.bend(v, pitchbendvalue); - }; - 0; // return something other than nil to avoid stopping the pattern - }), - ); - }); - ); - res -}; -*/ - - -//------resource management funcs - -genUID = {Date.seed.asHexString.toLower}; - -seedFunc = {arg func, seed; - var funcArgs, next; - next = Routine({loop{func.valueArray(funcArgs).yield }}); - next.randSeed_(seed); - {arg ...args; funcArgs = args; next.value} -}; - -stringifyToDepth = {arg data, maxDepth = 1; - var prettyString = "", rCount = 0, writeArray, indent; - - if(maxDepth == 0, { - data.asCompileString - }, { - indent = {arg size; size.collect({" "}).join("")}; - writeArray = {arg array; - prettyString = prettyString ++ indent.value(rCount) ++ "[\n"; - rCount = rCount + 1; - if(rCount < maxDepth, { - array.do({arg subArray; writeArray.value(subArray)}); - }, { - prettyString = prettyString ++ array.collect({arg subArray; - indent.value(rCount + 1) ++ subArray.asCompileString - }).join(",\n"); - }); - rCount = rCount - 1; - prettyString = prettyString ++ "\n" ++ indent.value(rCount) ++ "],\n"; - }; - - writeArray.value(data); - prettyString.replace(",\n\n", "\n").drop(-2); - }) -}; - -sanityCheck = {arg motif, index; - //print functions = very helpful - ("----------" + index + "------------").postln; - - motif.flatten.do({arg val, v; - if(v > 0, { - if(motif.flatten[v-1][0].hammingDistance(val[0]) > 1, {"problem 1".postln}); - if(motif.flatten[v-1][0].hammingDistance(val[0]) == 0, {"problem 2".postln}); - }); - val.postln - }); - "***********".postln; -}; - -msgInterpret = {arg in, escapeDoubleQuotes = true, escapeSingleQuotes = true; - var res; - - res = in; - if(res.isNil.not, { - if((res.isArray && res.isString.not), { - res = res.asCompileString; - res = res.replace(" ", "").replace("\n", "").replace("\t", ""); - if(escapeSingleQuotes, {res = res.replace("\'", "")}); - if(escapeDoubleQuotes, {res = res.replace("\"", "")}); - res = res.replace("Rest", "\"Rest\""); - res = res.interpret; - }, { - var tmpRes; - if(res.every({arg char; char.isDecDigit}), {tmpRes = res.asInteger}); - if(res.contains("."), {tmpRes = res.asFloat}); - if(tmpRes != nil, {res = tmpRes}); - }); - }); - res -}; - -writeResources = {arg path, dict; - var file, modelItems, resString; - file = File(path,"w"); - - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - - resString = nameSpaces.collect({arg nameSpace; - var depth = 0, insert = " "; - if(nameSpace == "music_data", {depth = 3; insert = "\n"}); - if(nameSpace == "last_changes", {depth = 1; insert = "\n"}); - if(nameSpace == "order", {depth = 1; insert = "\n"}); - if((nameSpace == "ref_uid") && (dict[nameSpace] == nil), {dict[nameSpace] = "nil"}); - "\"" ++ nameSpace ++ "\":" ++ insert ++ stringifyToDepth.value(dict[nameSpace], depth) - }).join(",\n"); - - resString = "{\n" ++ resString ++ "\n}"; - - file.write(resString); - file.close; - resString -}; - -loadModelFile = {arg path; loadModelJSON.value(File(path, "r").readAllString.parseJSON)}; - -loadModelJSON = {arg jsonObject; - var dict; - dict = Dictionary.with(*nameSpaces.collect({arg nS; nS->msgInterpret.value(jsonObject[nS])})); - dict -}; - -setGlobalVars = {arg dict, skipLastXChanges = false; - var tmpLastXChanges; - tmpLastXChanges = lastXChanges.deepCopy; - // order really matters!!!! - # seq, lastXChanges, curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited = nameSpaces.collect({arg nS; dict[nS]}); - if(skipLastXChanges, {lastXChanges = tmpLastXChanges}); - dict -}; - -globalVarsToDict = { - var modelItems, dict; - // order really matters!!!! - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - dict = Dictionary.with(*nameSpaces.collect({arg nS, n; nS->modelItems[n]})); -}; - -loadLedgerFile = {arg path; - ledgerPath = path; - loadLedgerJSON.value(File(ledgerPath, "r").readAllString.parseJSON) -}; - -loadLedgerJSON = {arg jsonObject; ledger = jsonObject["ledger"]}; - -saveLedger = {arg ledger, path; - var file; - file = File(path, "w"); - file.write("{\n\"ledger\":\n" ++ stringifyToDepth.value(ledger, 1) ++ "\n}"); - file.close; -}; - -//------global vars - -primes = [[2, 1], [3, 2], [5, 4], [7, 4], [11, 8], [13, 8]]; -//ranges = [[-2400, 0], [-1200, 1200], [0, 2400], [0, 2400]]; -exPath = thisProcess.nowExecutingPath; -dir = exPath.dirname; -//popSize = 4; -dims = primes.size; -tuples = genTuples.value(); -//refUID = nil; -group = Group.new; -~group = group; -loadLedgerFile.value(dir +/+ ".." +/+ "resources" +/+ "piece_ledger.json"); -//passagesWeights = [1, 1, 1, 1, 1]; -//susWeights = [1, 1, 1]; -// order really matters!!!! -nameSpaces = [ - "music_data", "last_changes", "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", - "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", - "ranges", "step_probs_vals", "passages_weights", "hd_exp", "hd_invert", - "order", "sus_weights", "order_size", "passages_size", - "motif_edited", "order_edited" -]; - - -//------OSC funcs - -OSCdef(\load_ledger, {arg msg, time, addr, port; - loadLedgerFile.value(msg[1].asString); -}, \load_ledger); - -OSCdef(\load_model, {arg msg, time, addr, port; - var dict; - dict = loadModelFile.value(msg[1].asString); - setGlobalVars.value(dict); -}, \load_model); - -OSCdef(\save_ledger, {arg msg, time, addr, port; - msg.postln; - ledger = msgInterpret.value(msg[1].asString.parseJSON["ledger"], false).postln; - //loadLedgerJSON.value(msg[0]) - saveLedger.value(ledger, msg[2].asString); - //loadLedgerFile.value(msg[1].asString); -}, \save_ledger); - -OSCdef(\generate, {arg msg, time, addr, port; - var path, dict, durSeeds, musPath, modelString; - msg.postln; - - path = msg[1].asString; - - dict = loadModelFile.value(path); - setGlobalVars.value(dict, true); - - popSize = ranges.size; - - //refUID.postln; - - loadLedgerFile.value(ledgerPath); - if(ledger == nil, {ledger = ["tmp"]}); - if(ledger.last != "tmp", {ledger = ledger.add("tmp")}); - - if(refUID == nil, {lastXChanges = [initVoices.value().deepCopy]}); - if((refUID != nil) && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - lastXChanges = msgInterpret.value(file.readAllString.parseJSON["last_changes"]); - }); - - refUID.postln; - lastXChanges.collect({arg item; item.postln}); - - durSeeds = seedFunc.value({3.collect({rrand(100000, 999999)})}, durSeed).value.postln; - entrancesDurFunc = genDurFunc.valueArray(entrancesProbVals[..4] ++ [entrancesProbVals[5..]] ++ [durSeeds[0]]); - passagesDurFunc = genDurFunc.valueArray(passagesProbVals[..4] ++ [passagesProbVals[5..]] ++ [durSeeds[1]]); - exitsDurFunc = genDurFunc.valueArray(exitsProbVals[..4] ++ [exitsProbVals[5..]] ++ [durSeeds[2]]); - - if(orders == nil, { - orders = seedFunc.value(genOrders, orderSeed).valueArray(orderSize ++ passagesSize); - //addr.sendMsg("/order", stringifyToDepth.value(orders, 1)); - }); - - stepFunc = genStepFunc.valueArray(stepProbsVals[..1] ++ [stepProbsVals[2..]] ++ [motifSeed]); - seq = seedFunc.value(genMotif, motifSeed).value; - - lastXChanges.collect({arg item; item.postln}); - - dict = globalVarsToDict.value; - modelString = writeResources.value(path, dict); - - //addr.sendMsg("/generated", musPath, stringifyToDepth.value(seq, 3)); - //~seq = seq; - - addr.sendMsg("/generated", path, modelString, ledgerPath); -}, \generate); - - -OSCdef(\commit, {arg msg, time, addr, port; - var musicData, musicChanged, dict, newLedger, modelPath, musString, musFile, test1, test2, lastCurUID, commitType, commitPos, equalityLedger; - //msg.postln; - - /* - test1 = msg[1].asString.parseJSON; - test2 = (dir +/+ ".." +/+ "resources/tmp/tmp_music" ++ ".json").standardizePath.parseJSONFile; - msgInterpret.value(test1["music"])[0][0][0][1].class.postln; - msgInterpret.value(test2["music_data"])[0][0][0][1].class.postln; - (test1["music"] == test2["music_data"]).postln; - */ - - musicData = loadModelJSON.value(msg[1].asString.parseJSON)["music_data"].postln; - musicChanged = (musicData != seq).postln; - commitType = msg[2].asString; - commitPos = msg[3].postln.asInteger; - - lastCurUID = curUID.deepCopy; - curUID = genUID.value; - - File.mkdir((dir +/+ ".." +/+ "resources" +/+ curUID).standardizePath); - File.copy(exPath, (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_code" ++ ".scd").standardizePath); - - modelPath = (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_mus_model" ++ ".json").standardizePath; - dict = globalVarsToDict.value; - if(musicChanged, { - seq = musicData; - dict["music_data"] = seq; - dict["motif_edited"] = "true" - }); - dict["cur_uid"] = curUID; - - writeResources.value(modelPath, dict); - - File.delete(ledgerPath ++ "_bak"); - File.copy(ledgerPath, ledgerPath ++ "_bak"); - File.delete(ledgerPath); - - /* - if(commitType == "add", { - if(lastCurUID == "tmp", { - ledger = ledger.drop(-1).add(curUID); - }, { - ledger = ledger.add(curUID); - }) - }); - */ - - ledger.postln; - - if(commitType == "add", {ledger = ledger.add(curUID)}); - - if(commitType == "insert", {ledger = ledger.insert(commitPos + 1, curUID)}); - - if(commitType == "replace", {ledger = ledger.put(commitPos, curUID)}); - - equalityLedger = ledger.collect({arg item; item.asSymbol}); - if(equalityLedger.includes(\tmp).postln, {ledger.removeAt(equalityLedger.indexOf(\tmp).postln)}); - - ledger.postln; - - saveLedger.value(ledger, ledgerPath); - - addr.sendMsg("/committed", curUID, ledgerPath); - //refUID = curUID; - -}, \commit); - -OSCdef(\transport, {arg msg, time, addr, port; - msg.postln; - if(msg[1] == 0, { - group.set(\release, 2); - group.set(\gate, 0); - player.stop; - }, { - // the cued sequence can now be read from file, so this can be cleaned up - var cSize, patterns, pSeq, cuedSeek, indexStart, indexEnd, tmpLedger; - if(msg[1] == 1, { - pSeq = []; - cuedSeek = (seq != nil); - indexStart = msg[2].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.postln.parseJSON["music_data"]), path, indexStart + index, uid]); - file.close; - }); - }); - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - patterns = genPatterns.value(pSeq, addr); - }, { - pSeq = [loadModelJSON.value(msg[2].asString.parseJSON)["music_data"].postln]; - patterns = genPatterns.value(pSeq, addr, true); - }); - player = Pfset(pattern: patterns, cleanupFunc: { - addr.sendMsg("/transport", 0); - addr.sendMsg("/one_shot", 0); - }); - player = player.play - }); -}, \transport); - - -OSCdef(\transcribe_motif, {arg msg, time, addr, port; - var tSeq, refChord, refUID; - - msg.postln; - - tSeq = [loadModelJSON.value(msg[1].asString.parseJSON)["music_data"]]; - refUID = msg[2].asString.postln; - - if((refUID != "nil") && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }, { - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - }); - - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "lilypond" +/+ "includes").standardizePath, addr, "/transcribe_motif"); -}, \transcribe_motif); - - -OSCdef(\transcribe_all, {arg msg, time, addr, port; - var cSize, patterns, cuedSeek, indexStart, indexEnd, tmpLedger; - if(true, { - cuedSeek = (seq != nil); - indexStart = msg[1].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - - //tmp for testing transcription - indexEnd = (indexStart+5); - - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - var lilyPartLedgerFiles; - - lilyPartLedgerFiles = 4.collect({arg p; - File((dir +/+ ".." +/+ "lilypond" +/+ "includes" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly").standardizePath, "w"); - }); - - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file, fileString, tSeq, refUID, refChord; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - fileString = file.readAllString; - tSeq = msgInterpret.value(fileString.parseJSON["music_data"]); - refUID = msgInterpret.value(fileString.parseJSON["ref_uid"]); - file.close; - - //uid.postln; - //(refUID == "nil").postln; - - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - - if(refUID != "nil", { - path = (dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }); - - if(index != indexEnd, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath); - }, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath, addr, "/transcribe_all"); - }); - - lilyPartLedgerFiles.do({arg f, p; - f.write("\\include \".." +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly\"\n"); - }); - - }); - - lilyPartLedgerFiles.do({arg f; - f.close - }); - }); - /* - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - */ - }, { - - }); - -}, \transcribe_all); - -) - -~transcribe.value(~seq, dir); - -( -//synthdefs -~stringModelBusArray = 4.collect({Bus.audio(s, 1)}); -~sineBusArray = 4.collect({Bus.audio(s, 1)}); -~bassBusArray = 1.collect({Bus.audio(s, 1)}); -~hdustBusArray = 1.collect({Bus.audio(s, 1)}); -~samplerBusArray = 2.collect({Bus.audio(s, 1)}); -~sBuf = Buffer.alloc(s, 10, 2); -SynthDef(\string_model, {arg freq, gate = 1, sustain, amp, dur, attack, release = 1, busIndex = 0; - var trig, exc, sig1, sig2, noHarms; - noHarms = rrand(20, 40); - exc = Saw.ar(freq, TRand.ar(0.5, 1, Impulse.ar(freq))) * 0.001 + Dust.ar(10000, 0.01); - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.8).softclip; - //sig1 = HPF.ar(sig1, 300); - Out.ar(Select.kr(busIndex, ~stringModelBusArray), sig1 * amp * EnvGen.kr(Env.adsr(attack, 0.3, 0.9, release, 0.9, -3), gate, doneAction: 2)); - //Out.ar([0, 1], sig1 * EnvGen.kr(Env.asr(dur, 0.3, 1), gate, doneAction: 2)); -}).add; - -SynthDef(\sine, {arg freq, gate = 1, sustain, amp, dur, busIndex = 0; - var sig; - sig = SinOsc.ar(freq); - Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.asr(0.3, 0.4, 0.3), gate, timeScale: dur, doneAction: 2)); - //Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.sine(dur), gate, doneAction: 2)); -}).add; - -SynthDef(\mixer, {arg freq, gate = 1, sustain, amp, dur, out; - var nameSpaces, sigs; - - sigs = [~stringModelBusArray, ~sineBusArray/*, ~bassBusArray, ~hdustBusArray, ~samplerBusArray*/].collect({arg busArray, i; - var nameSpace, sig; - nameSpace = ['string', 'sine', 'bass', 'hdust', 'sampler'][i]; - sig = busArray.collect({arg bus, c; In.ar(bus, 1) * NamedControl.kr(\ ++ nameSpace ++ '_volume_' ++ c, 1, 0.1)}); - sig = sig.collect({arg channel, c; Pan2.ar(channel, NamedControl.kr(\ ++ nameSpace ++ '_pan_' ++ c, i / (busArray.size - 1), 0.1) * 2 - 1)}); - sig = sig.collect({arg channel, c; channel * NamedControl.kr(\ ++ nameSpace ++ '_mute_' ++ c, 1, 0.1)}); - sig = Mix.ar(sig) * pow(NamedControl.kr(\ ++ nameSpace ++ '_volume_master', 1, 0.1), 2); - }); - - sigs = Mix.ar(sigs / 4); - Out.ar(0, sigs) -}).add; - -SynthDef(\bass, { - var switches, drone; - switches = {|i| Dust.kr(0.1)} ! 9; - drone = {|i| var harm = pow(2, 2 - (i / 3).trunc), amp = (1 / pow(harm, 2)); - SinOsc.ar(60 * harm + TRand.kr(-3, 3, switches[i]), 0, amp)} ! 9; - Out.ar(~bassBusArray[0], Mix.new(drone) * 0.2); -}).add; - -SynthDef(\sampler, { - Out.ar(~samplerBusArray, PlayBuf.ar(2, ~sBuf, BufRateScale.kr(~sBuf), doneAction: 2)) -}).add; - -// main routine -SynthDef(\hdust, { - arg gate = 0; - var hierarchical_dust, low_sine, high_sine, brown_noise, white_noise; - // this triggers the combinations of sources - // it is similar to the Supercollider UGen called dust but with a hierarchical structure - hierarchical_dust = ( - TIRand.kr(0, 1, Impulse.kr(100)) * - TIRand.kr(0, 1, Impulse.kr(10)) * - TIRand.kr(0, 1, Impulse.kr(1)) * - TIRand.kr(0, 1, Impulse.kr(0.1)) - ); - // adjust the multiplier at the end of each line for adjusting levels - // note with each trigger, each source has a 1 in 3 chance of sounding - low_sine = SinOsc.ar(76.midicps / 16) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.1; - high_sine = SinOsc.ar(76.midicps * 8) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.01; - brown_noise = BrownNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.025; - white_noise = WhiteNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.02; - Out.ar(~hdustBusArray[0], - ((low_sine + high_sine + brown_noise + white_noise) ) - ); -}).add; - -) - -( -var bass, hdust, sampler, mixer; -/* -bass = Synth.tail(~group, \bass); -hdust = Synth.tail(~group, \hdust); -sampler = Synth.head(~group, \sampler); -*/ -mixer = Synth.tail(~group, \mixer); - -OSCdef(\mixer, {arg msg, time, addr, port; - mixer.set((msg[1] ++ '_' ++ msg[2] ++ '_' ++ msg[3]), msg[4]) -}, \mixer); - -/* -OSCdef(\sampler, {arg msg, time, addr, port; - msg.postln; - sampler.free; - ~sBuf.free; - ~sBuf = Buffer.read(s, msg[1].asString.postln, action: {sampler = Synth.head(~group, \sampler)}); -}, \sampler); -*/ -) - -/* old something -( -SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; - var trig, exc, sig1, sig2, noHarms, freqFinal, start, end; - noHarms = 30; - freq = WhiteNoise.ar * 3 + freq; - freqFinal = Duty.ar((1/freq), 0, freq); - trig = Changed.ar(freqFinal); - start = Demand.ar(trig, 0, Dwhite(-1, -0.75)); - end = Demand.ar(trig, 0, Dwhite(0.75, 1)); - exc = Phasor.ar(trig, (end - start) * freqFinal / SampleRate.ir, start, end, 0) * 0.001 + Dust.ar(10000, 0.01); - - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(2, 3)}) ], exc) * 0.5).softclip; - sig1 = HPF.ar(sig1, 300); - Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); -}).add; -) -*/ - diff --git a/resources/57a598e2/57a598e2_mus_model.json b/resources/57a598e2/57a598e2_mus_model.json deleted file mode 100644 index e69de29..0000000 diff --git a/resources/5e947063/lilypond/part_I.ly b/resources/5e947063/lilypond/part_I.ly deleted file mode 100644 index d88c2e4..0000000 --- a/resources/5e947063/lilypond/part_I.ly +++ /dev/null @@ -1,32 +0,0 @@ -{ - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" - { r2 b4^\markup { \pad-markup #0.2 "+11"} ~ b4 ~ } - \bar "|" \break - { b1 ~ } - \bar "|" - { b1 ~ } - \bar "|" - { b1 ~ } - \bar "|" - { b1 ~ } - \bar "|" \break - { b1 ~ } - \bar "|" - { b1 ~ } - \bar "|" - { b1 ~ } - \bar "|" - { b2. ~ b16[ r8.] } - \bar "|" \break - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } -\bar "||" -} \ No newline at end of file diff --git a/resources/5e947063/lilypond/part_II.ly b/resources/5e947063/lilypond/part_II.ly deleted file mode 100644 index b045897..0000000 --- a/resources/5e947063/lilypond/part_II.ly +++ /dev/null @@ -1,32 +0,0 @@ -{ - { c'4^\markup { \pad-markup #0.2 "+0"} ~ c'2. ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" \break - { c'4 ~ c'8.[ dis'16^\markup { \pad-markup #0.2 "-3"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "I"\normal-size-super " 5↑" }}] ~ dis'2 ~ } - \bar "|" - { dis'1 ~ } - \bar "|" - { dis'1 ~ } - \bar "|" - { dis'1 ~ } - \bar "|" \break - { dis'1 ~ } - \bar "|" - { dis'1 ~ } - \bar "|" - { dis'4 ~ dis'8.[ r16] r2 } - \bar "|" - { r1 } - \bar "|" \break - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } -\bar "||" -} \ No newline at end of file diff --git a/resources/5e947063/lilypond/part_III.ly b/resources/5e947063/lilypond/part_III.ly deleted file mode 100644 index 362b383..0000000 --- a/resources/5e947063/lilypond/part_III.ly +++ /dev/null @@ -1,32 +0,0 @@ -{ - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" \break - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" - { r4 r8[ g8^\markup { \pad-markup #0.2 "+25"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 1↑" }}] ~ g2 ~ } - \bar "|" \break - { g2 ~ g8[ r8] r4 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" \break - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } -\bar "||" -} \ No newline at end of file diff --git a/resources/5e947063/lilypond/part_IV.ly b/resources/5e947063/lilypond/part_IV.ly deleted file mode 100644 index 493f638..0000000 --- a/resources/5e947063/lilypond/part_IV.ly +++ /dev/null @@ -1,32 +0,0 @@ -{ - { r1 } - \bar "|" - { r4 r8.[ gis'16^\markup { \pad-markup #0.2 "+14"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 5↓" }}] ~ gis'2 ~ } - \bar "|" - { gis'4 ~ gis'8[ fis'8^\markup { \pad-markup #0.2 "+49"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 11↓" }}] ~ fis'2 ~ } - \bar "|" - { fis'1 ~ } - \bar "|" \break - { fis'1 ~ } - \bar "|" - { fis'1 ~ } - \bar "|" - { fis'8.[ g'16^\markup { \pad-markup #0.2 "+25"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "I"\normal-size-super " 5↓" }}] ~ g'2. ~ } - \bar "|" - { g'1 ~ } - \bar "|" \break - { g'1 ~ } - \bar "|" - { g'1 ~ } - \bar "|" - { g'1 ~ } - \bar "|" - { g'1 ~ } - \bar "|" \break - { g'1 ~ } - \bar "|" - { g'2 ~ g'8[ r8] r4 } - \bar "|" - { r1 } -\bar "||" -} \ No newline at end of file diff --git a/resources/6132dd73/6132dd73_code.scd b/resources/6132dd73/6132dd73_code.scd deleted file mode 100644 index 1c97ceb..0000000 --- a/resources/6132dd73/6132dd73_code.scd +++ /dev/null @@ -1,1055 +0,0 @@ -( -// helper funcs -var hsArrayToCents, pDist, hdSum, hsChordalDistance, hsArrayToFreq; - -// score funcs -var isInRange, spacingScore, rangeScore, intervalScore, inclusionScore; - -// subroutines -var genTuples, initVoices, genOrders, genSubMotif, updateVoices, genDurFunc, genStepFunc; - -// primary routines -var genMotif, genSecondarySeq; - -// audition funcs -var genPatterns, genMidiPatterns; - -// resource management funcs -var seedFunc, genUID, writeResources, stringifyToDepth, setSeeds, sanityCheck, -msgInterpret, loadLedgerFile, loadLedgerJSON, loadModelFile, loadModelJSON, -setGlobalVars, globalVarsToDict, saveLedger; - -// model vars -//(model and global vars mostly set by OSC funcs -var seq, lastXChanges, -curUID, refUID, orderSeed, durSeed, motifSeed, -entrancesProbVals, passagesProbVals, exitsProbVals, -ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, -orders, susWeights, orderSize, passagesSize, -motifEdited, orderEdited; - -// model aux vars -var entrancesDurFunc, passagesDurFunc, exitsDurFunc, stepFunc; - -// other global vars -var popSize, exPath, dir, primes, dims, tuples, -group, player, ledgerPath, ledger, currentlyPlayingUID, -nameSpaces; - -// install JSON quark -if(Quarks.isInstalled("JSONlib").not, { - Quarks.install("https://github.com/musikinformatik/JSONlib.git"); - thisProcess.recompile; - //HelpBrowser.openHelpFor("Classes/JSONlib"); -}); - - -//------helper funcs - -hsArrayToCents = { - arg hsArray; - hsArray.collect({arg dist, p; dist * 1200 * log2(primes[p][0]/primes[p][1])}).sum -}; - -pDist = { - arg array1, array2, signed = false; - var pDistance; - pDistance = hsArrayToCents.value(array1) - hsArrayToCents.value(array2); - if(signed, {pDistance}, {abs(pDistance)}) -}; - -hdSum = { - arg hsArrays; - var size, distances, mean; - size = hsArrays.size; - distances = (size - 1).collect({arg i; - ((i + 1)..(size - 1)).collect({arg j; - abs(hsArrays[i] - hsArrays[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsChordalDistance = { - arg hsArrays1, hsArrays2; - var size, distances, mean; - size = hsArrays1.size; - distances = hsArrays1.size.collect({arg i; - hsArrays2.size.collect({arg j; - abs(hsArrays1[i] - hsArrays2[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsArrayToFreq = { - arg array; - array.collect({arg dim, d; pow(primes[d][0]/primes[d][1], dim)}).product -}; - -//------score funcs - -/* -isInRange = { - arg hsArray, min, max; - var cents; - cents = hsArrayToCents.value(hsArray); - (cents >= min) && (cents <= max) -}; -*/ - -spacingScore = { - arg hsArrays, min; - var centsArray; - centsArray = hsArrays.collect({arg hsArray; hsArrayToCents.value(hsArray)}).sort({arg a, b; a < b}); - centsArray.differentiate.drop(1).collect({arg pDistance; if(pDistance >= min, {1}, {0.01})}).sum; -}; - -rangeScore = { - arg hsArray1, hsArray2, min, max, low, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - if((pDistance >= min) && (pDistance <= max), {1}, {low}); -}; - -intervalScore = { - arg hsArray1, hsArray2, mean, sd, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - //pDistance.gaussCurve(1, mean, sd) - stepFunc.value(pDistance); -}; - -inclusionScore = { - arg array, test, min = 0.01; - if(array.collect({arg v; v.hash}).includes(test.hash), {min}, {1}); -}; - - -//------subroutines - -genTuples = { - var tuples; - tuples = dims.collect({[-1, 0, 1]}).allTuples.select({arg tuple; (abs(tuple.drop(1)).sum <= 1) && (tuple[0] == 0)}); - tuples = tuples ++ tuples.collect({arg tuple; [-3, -2, -1, 1, 2, 3].collect({arg octTrans; tuple.deepCopy.put(0, octTrans)})}).flatten; -}; - -initVoices = { - var init, voicesInit; - voicesInit = popSize.collect({dims.collect({0})}); - /* - voicesInit = [dims.collect({0})]; - (popSize - 1).do({ - arg rep, new; - rep = dims.rand; - new = voicesInit.last.deepCopy; - new[rep] = new[rep] + [-1, 1].choose(); - voicesInit = voicesInit.add(new); - }); - */ - voicesInit.deepCopy; -}; - -genDurFunc = {arg chordProb, minPad, maxPad, minDur, maxDur, envData, seed; - var env, pTable, durFunc; - env = Env.pairs([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).asSignal(256).asList.asArray; - pTable = env.asRandomTable; - [chordProb, minPad, maxPad, minDur, maxDur, envData].postln; - durFunc = {arg allowChord, pad = false; - var res; - res = if(allowChord.not, { - pTable.tableRand * (maxDur - minDur) + minDur - }, { - if(1.0.rand < chordProb, {0}, {pTable.tableRand * (maxDur - minDur) + minDur}); - }).round(0.125); - if(pad, {res = res + rrand(minPad.asFloat, maxPad.asFloat).round(0.125)}); - if(res.asInteger == res, {res = res.asInteger}); - res - }; - seedFunc.value(durFunc, seed); -}; - -genStepFunc = {arg minStep, maxStep, envData, seed; - var envDataNorm, env, pTable, stepFunc; - [minStep, maxStep, envData].postln; - envDataNorm = ([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).flop; - envDataNorm = [envDataNorm[0].normalize(minStep, maxStep), envDataNorm[1]].flop; - env = Env.pairs(envDataNorm); - stepFunc = {arg pDist; - env.at(pDist).clip(0.001, 1); - }; - seedFunc.value(stepFunc, seed); -}; - -genOrders = {arg minMotifLength = 1, maxMotifLength = 5, minProgLength = 0, maxProgLength = 5; - ((maxMotifLength - minMotifLength).rand + minMotifLength).collect({ - var noProgIns, noSusIns, noSilentIns, prog, sus, silent, order; - noSusIns = [1, 2, 3].wchoose(susWeights.normalizeSum); - noProgIns = (popSize - noSusIns).rand + 1; - noSilentIns = popSize - noSusIns - noProgIns; - - # prog, sus, silent = (0..(popSize-1)).scramble.clumps([noProgIns, noSusIns, noSilentIns]); - - prog = (prog.scramble ++ ((maxProgLength - minProgLength).rand + minProgLength).collect({prog.choose}).scramble); - if(silent == nil, {silent = []}); - [sus.scramble, prog, silent.scramble] - }); -}; - -updateVoices = {arg ins, sus; - var voices, candidates, nWeights, nProbs, sel; - - voices = lastXChanges.deepCopy.last; - - candidates = sus.collect({arg v; tuples.collect({arg t; voices[v] + t})}).flatten; - candidates = difference(candidates.asSet, voices.asSet).asList; - nProbs = candidates.collect({arg candidate; - var stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore; - - //stepScore = intervalScore.value(voices[ins], candidate, 30, 400, 0.1); - stepScore = intervalScore.value(voices[ins], candidate, 100, 100); - recentlySoundedScore = inclusionScore.value(lastXChanges.flop[ins], candidate, 0); - isInRangeScore = rangeScore.value(candidate, candidate.collect({0}), ranges[ins][0], ranges[ins][1], 0, true); - regScore = spacingScore.value(voices.deepCopy.put(ins, candidate), 300); - hdScore = pow(hdSum.value(voices.deepCopy.put(ins, candidate)), hdExp); - if(hdInvert == 0, {hdScore = 1/hdScore}); - //maybe what you want here is a vector to another root and then favoring movement towards it. - //distScore = pow(hsChordalDistance.value(voices, voices.put(ins, candidate)), 2); - - [stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore] - }); - - nWeights = passagesWeights; - - //this handles nWeights of 0; mainly for testing - nProbs = nProbs.flop.select({arg scores, s; nWeights[s] != 0}).flop; - nWeights = nWeights.select({arg weight; weight != 0}); - nProbs = nProbs.flop.collect({arg scores, s; - if(scores.sum == 0, {scores}, {scores.normalizeSum * nWeights[s]}) - }); - nProbs = nProbs.flop.collect({arg scores, s; scores.product}).normalizeSum; - - sel = candidates.wchoose(nProbs); - - voices[ins] = sel; - lastXChanges = lastXChanges.add(voices).keep(-5); -}; - -genSubMotif = {arg order, orderIndex, lastState, repeatLast = false, startFromLast = false, isLastOrder = false; - var sus, prog, silent, flatOrder, res, isInChord, allowChord, pad, lastXChangesHold, voices, adder; - # sus, prog, silent = order; - flatOrder = silent ++ sus ++ prog; - lastXChangesHold = lastXChanges.deepCopy; - voices = lastState.deepCopy; - isInChord = popSize.collect({false}); - allowChord = false; - pad = false; - res = []; - "------generating motif".postln; - //need to figure out here if voices move between motifs - flatOrder.do({arg ins, i; - - if(prog.includes(ins) && repeatLast.not, {updateVoices.value(ins, sus)}); - adder = if(silent.includes(ins), {["Rest"]}, {lastXChanges.last.deepCopy[ins]}); - - if(voices[ins] != adder, { - var dur; - - if((sus ++ silent).includes(ins), { - allowChord = (ins != sus.last); - pad = (ins == sus.last); - }, { - if(i < (flatOrder.size - 1), { - allowChord = (isInChord[flatOrder[i + 1]] || (ins == flatOrder[i + 1])).not; - pad = false; - }, { - allowChord = false; - pad = true - }); - }); - if((orderIndex == 0) && sus.includes(ins), { - dur = entrancesDurFunc.value(allowChord, pad); - }, { - dur = passagesDurFunc.value(allowChord, pad); - }); - if(dur == 0, {isInChord[ins] = true}, {isInChord = popSize.collect({false})}); - - voices[ins] = adder; - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - - // pad ending - if(orderIndex == (orders.size - 1), { - (0..(popSize-1)).scramble.do({arg ins; - if(res.last.first[ins] != ["Rest"], { - var dur; - voices[ins] = ["Rest"]; - allowChord = (voices != popSize.collect({["Rest"]})); - pad = allowChord.not; - dur = exitsDurFunc.value(allowChord, pad); - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - }); - - //format and return - if(startFromLast, {lastXChanges = lastXChangesHold.deepCopy}); - res; -}; - - -//------primary routines - -genMotif = { - var repeats, fSeq, fDur, durAdd; - - repeats = 1; - fSeq = []; - - repeats.do({arg index; - var motif; - - motif = []; - - orders.do({arg order, o; - var lastState, subMotif; - lastState = if(o == 0, {popSize.collect({["Rest"]})}, {motif.last.last.first}); - subMotif = genSubMotif.value(order, o, lastState, isLastOrder: o == (orders.size - 1)); - motif = motif.add(subMotif); - - }); - - sanityCheck.value(motif, index); - - fSeq = fSeq.add(motif); - }); - - //round last duration to measure - fDur = fSeq.flatten.flatten.slice(nil, 1).sum; - durAdd = fDur.round(4) - fDur; - if(durAdd < 0, {durAdd = 4 - durAdd}); - fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] = fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] + durAdd; - - fSeq -}; - -genSecondarySeq = {arg seq; - var curdles, fSeq; - curdles = []; - while({curdles.sum < seq.size}, {curdles = curdles ++ [3.rand + 1]}); - - fSeq = seq.clumps(curdles).collect({arg clump, m; - var repeats, paddedSeq; - - //add rest - paddedSeq = clump.add([[[popSize.collect({["Rest"]}), 0.5.rand]]]); - - //implement repeats - repeats = [0.rand + 1, 1].wchoose([1, 0].normalizeSum); - repeats.collect({paddedSeq}); - }); - fSeq -}; - - -//------audition funcs - -/* -Event.addEventType(\osc, { - if (~addr.postln.notNil) { - ~addr.sendMsg(~indexPath, ~indexMsg); - ~addr.sendMsg(~seqPath, stringifyToDepth.value(~seqMsg, 3)); - //~addr.sendMsg("/STATE/OPEN", (dir.replace("supercollider", "resources") +/+ ~idMsg +/+ ~idMsg ++ "_gui_state" ++ ".state").standardizePath.postln); - }; -}); -*/ - -Event.addEventType(\osc, { - if (~addr.notNil) { - ~msg; - ~addr.sendMsg(~path, *~msg); - }; -}); - -genPatterns = {arg inSeq, addr, oneShot = false; - var voices, durs, pbinds, res, indices, sectionDurs, msg, ids, seq; - seq = inSeq.collect({arg mSeq; mSeq[0]}); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - pbinds = voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs, attacks, rels, amps; - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - //attacks = 2.collect({rrand(1, 3)}) ++ freqs.drop(2).collect({rrand(0.3, 0.5)}); - attacks = fDurs.collect({arg dur; dur * rrand(0.2, 0.4)}); - //rels = freqs.drop(2).collect({rrand(0.3, 0.5)}) ++ 2.collect({rrand(1, 3)}); - rels = (clumps.size - 1).collect({arg c; - if(clumps[c + 1][0] == ["Rest"], {rrand(1.0, 3.0)}, {rrand(0.3, 0.5)}); - }); - rels = rels.add(rrand(1.0, 3.0)); - amps = freqs.collect({rrand(0.6, 0.99)}); - - [ - Pbind( - \instrument, \string_model, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \attack, Pseq(attacks, 1), - \sustain, Pseq(fDurs, 1), - \release, Pseq(rels, 1), - //\amp, Pseq(amps, 1), - \amp, Pbrown(0.5, 1, 0.5), - \busIndex, v - ), - Pbind( - \instrument, \sine, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \sustain, Pseq(fDurs, 1), - \busIndex, v - ) - ] - }).flatten; - if(oneShot.not, { - msg = inSeq.collect({arg mSeq, m; mSeq[1..]}); - //ids = inSeq.collect({arg mSeq, m; mSeq[2]}); - sectionDurs = seq.collect({arg mSeq; mSeq.flatten2(mSeq.maxDepth - 5).flop[1].sum}); - pbinds = pbinds ++ - [ - Pbind( - \type, \osc, - \addr, addr, - \path, "/playing", - \msg, Pseq(msg, 1), - \dur, Pseq(sectionDurs, 1) - ); - ] - }); - res = Ppar(pbinds); - res -}; - -/* -genMidiPatterns = {arg seq; - var voices, durs, patterns, res, mOut, pbRange; - pbRange = 1; //semitones - change this as needed for your situation - mOut = MIDIOut.newByName("TiMidity", "TiMidity port 0").latency_(Server.default.latency); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - res = Ppar( - voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs; - - mOut.program(v, 70); - - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - - Pbind( - \type, \midi, - \chan, v, - \noteval, Pseq(freqs.cpsmidi - 24, 1), - \note, Pfunc({ | event | event[\noteval].floor }), - \dur, Pseq(fDurs, 1), - \midiout, mOut, - \amp, 1, - \bend, Pfunc({ - | event | - if (event[\note].isRest.not) { - var pitchbendvalue = event[\noteval].frac.linlin(0, pbRange, 8192, 8192*2).asInteger; - m.bend(v, pitchbendvalue); - }; - 0; // return something other than nil to avoid stopping the pattern - }), - ); - }); - ); - res -}; -*/ - - -//------resource management funcs - -genUID = {Date.seed.asHexString.toLower}; - -seedFunc = {arg func, seed; - var funcArgs, next; - next = Routine({loop{func.valueArray(funcArgs).yield }}); - next.randSeed_(seed); - {arg ...args; funcArgs = args; next.value} -}; - -stringifyToDepth = {arg data, maxDepth = 1; - var prettyString = "", rCount = 0, writeArray, indent; - - if(maxDepth == 0, { - data.asCompileString - }, { - indent = {arg size; size.collect({" "}).join("")}; - writeArray = {arg array; - prettyString = prettyString ++ indent.value(rCount) ++ "[\n"; - rCount = rCount + 1; - if(rCount < maxDepth, { - array.do({arg subArray; writeArray.value(subArray)}); - }, { - prettyString = prettyString ++ array.collect({arg subArray; - indent.value(rCount + 1) ++ subArray.asCompileString - }).join(",\n"); - }); - rCount = rCount - 1; - prettyString = prettyString ++ "\n" ++ indent.value(rCount) ++ "],\n"; - }; - - writeArray.value(data); - prettyString.replace(",\n\n", "\n").drop(-2); - }) -}; - -sanityCheck = {arg motif, index; - //print functions = very helpful - ("----------" + index + "------------").postln; - - motif.flatten.do({arg val, v; - if(v > 0, { - if(motif.flatten[v-1][0].hammingDistance(val[0]) > 1, {"problem 1".postln}); - if(motif.flatten[v-1][0].hammingDistance(val[0]) == 0, {"problem 2".postln}); - }); - val.postln - }); - "***********".postln; -}; - -msgInterpret = {arg in, escapeDoubleQuotes = true, escapeSingleQuotes = true; - var res; - - res = in; - if(res.isNil.not, { - if((res.isArray && res.isString.not), { - res = res.asCompileString; - res = res.replace(" ", "").replace("\n", "").replace("\t", ""); - if(escapeSingleQuotes, {res = res.replace("\'", "")}); - if(escapeDoubleQuotes, {res = res.replace("\"", "")}); - res = res.replace("Rest", "\"Rest\""); - res = res.interpret; - }, { - var tmpRes; - if(res.every({arg char; char.isDecDigit}), {tmpRes = res.asInteger}); - if(res.contains("."), {tmpRes = res.asFloat}); - if(tmpRes != nil, {res = tmpRes}); - }); - }); - res -}; - -writeResources = {arg path, dict; - var file, modelItems, resString; - file = File(path,"w"); - - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - - resString = nameSpaces.collect({arg nameSpace; - var depth = 0, insert = " "; - if(nameSpace == "music_data", {depth = 3; insert = "\n"}); - if(nameSpace == "last_changes", {depth = 1; insert = "\n"}); - if(nameSpace == "order", {depth = 1; insert = "\n"}); - if((nameSpace == "ref_uid") && (dict[nameSpace] == nil), {dict[nameSpace] = "nil"}); - "\"" ++ nameSpace ++ "\":" ++ insert ++ stringifyToDepth.value(dict[nameSpace], depth) - }).join(",\n"); - - resString = "{\n" ++ resString ++ "\n}"; - - file.write(resString); - file.close; - resString -}; - -loadModelFile = {arg path; loadModelJSON.value(File(path, "r").readAllString.parseJSON)}; - -loadModelJSON = {arg jsonObject; - var dict; - dict = Dictionary.with(*nameSpaces.collect({arg nS; nS->msgInterpret.value(jsonObject[nS])})); - dict -}; - -setGlobalVars = {arg dict, skipLastXChanges = false; - var tmpLastXChanges; - tmpLastXChanges = lastXChanges.deepCopy; - // order really matters!!!! - # seq, lastXChanges, curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited = nameSpaces.collect({arg nS; dict[nS]}); - if(skipLastXChanges, {lastXChanges = tmpLastXChanges}); - dict -}; - -globalVarsToDict = { - var modelItems, dict; - // order really matters!!!! - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - dict = Dictionary.with(*nameSpaces.collect({arg nS, n; nS->modelItems[n]})); -}; - -loadLedgerFile = {arg path; - ledgerPath = path; - loadLedgerJSON.value(File(ledgerPath, "r").readAllString.parseJSON) -}; - -loadLedgerJSON = {arg jsonObject; ledger = jsonObject["ledger"]}; - -saveLedger = {arg ledger, path; - var file; - file = File(path, "w"); - file.write("{\n\"ledger\":\n" ++ stringifyToDepth.value(ledger, 1) ++ "\n}"); - file.close; -}; - -//------global vars - -primes = [[2, 1], [3, 2], [5, 4], [7, 4], [11, 8], [13, 8]]; -//ranges = [[-2400, 0], [-1200, 1200], [0, 2400], [0, 2400]]; -exPath = thisProcess.nowExecutingPath; -dir = exPath.dirname; -//popSize = 4; -dims = primes.size; -tuples = genTuples.value(); -//refUID = nil; -group = Group.new; -~group = group; -loadLedgerFile.value(dir +/+ ".." +/+ "resources" +/+ "piece_ledger.json"); -//passagesWeights = [1, 1, 1, 1, 1]; -//susWeights = [1, 1, 1]; -// order really matters!!!! -nameSpaces = [ - "music_data", "last_changes", "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", - "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", - "ranges", "step_probs_vals", "passages_weights", "hd_exp", "hd_invert", - "order", "sus_weights", "order_size", "passages_size", - "motif_edited", "order_edited" -]; - - -//------OSC funcs - -OSCdef(\load_ledger, {arg msg, time, addr, port; - loadLedgerFile.value(msg[1].asString); -}, \load_ledger); - -OSCdef(\load_model, {arg msg, time, addr, port; - var dict; - dict = loadModelFile.value(msg[1].asString); - setGlobalVars.value(dict); -}, \load_model); - -OSCdef(\save_ledger, {arg msg, time, addr, port; - msg.postln; - ledger = msgInterpret.value(msg[1].asString.parseJSON["ledger"], false).postln; - //loadLedgerJSON.value(msg[0]) - saveLedger.value(ledger, msg[2].asString); - //loadLedgerFile.value(msg[1].asString); -}, \save_ledger); - -OSCdef(\generate, {arg msg, time, addr, port; - var path, dict, durSeeds, musPath, modelString; - msg.postln; - - path = msg[1].asString; - - dict = loadModelFile.value(path); - setGlobalVars.value(dict, true); - - popSize = ranges.size; - - //refUID.postln; - - loadLedgerFile.value(ledgerPath); - if(ledger == nil, {ledger = ["tmp"]}); - if(ledger.last != "tmp", {ledger = ledger.add("tmp")}); - - if(refUID == nil, {lastXChanges = [initVoices.value().deepCopy]}); - if((refUID != nil) && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - lastXChanges = msgInterpret.value(file.readAllString.parseJSON["last_changes"]); - }); - - refUID.postln; - lastXChanges.collect({arg item; item.postln}); - - durSeeds = seedFunc.value({3.collect({rrand(100000, 999999)})}, durSeed).value.postln; - entrancesDurFunc = genDurFunc.valueArray(entrancesProbVals[..4] ++ [entrancesProbVals[5..]] ++ [durSeeds[0]]); - passagesDurFunc = genDurFunc.valueArray(passagesProbVals[..4] ++ [passagesProbVals[5..]] ++ [durSeeds[1]]); - exitsDurFunc = genDurFunc.valueArray(exitsProbVals[..4] ++ [exitsProbVals[5..]] ++ [durSeeds[2]]); - - if(orders == nil, { - orders = seedFunc.value(genOrders, orderSeed).valueArray(orderSize ++ passagesSize); - //addr.sendMsg("/order", stringifyToDepth.value(orders, 1)); - }); - - stepFunc = genStepFunc.valueArray(stepProbsVals[..1] ++ [stepProbsVals[2..]] ++ [motifSeed]); - seq = seedFunc.value(genMotif, motifSeed).value; - - lastXChanges.collect({arg item; item.postln}); - - dict = globalVarsToDict.value; - modelString = writeResources.value(path, dict); - - //addr.sendMsg("/generated", musPath, stringifyToDepth.value(seq, 3)); - //~seq = seq; - - addr.sendMsg("/generated", path, modelString, ledgerPath); -}, \generate); - - -OSCdef(\commit, {arg msg, time, addr, port; - var musicData, musicChanged, dict, newLedger, modelPath, musString, musFile, test1, test2, lastCurUID, commitType, commitPos; - //msg.postln; - - /* - test1 = msg[1].asString.parseJSON; - test2 = (dir +/+ ".." +/+ "resources/tmp/tmp_music" ++ ".json").standardizePath.parseJSONFile; - msgInterpret.value(test1["music"])[0][0][0][1].class.postln; - msgInterpret.value(test2["music_data"])[0][0][0][1].class.postln; - (test1["music"] == test2["music_data"]).postln; - */ - - musicData = loadModelJSON.value(msg[1].asString.parseJSON)["music_data"].postln; - musicChanged = (musicData != seq).postln; - commitType = msg[2].asString; - commitPos = msg[3].postln.asInteger; - - lastCurUID = curUID.deepCopy; - curUID = genUID.value; - - File.mkdir((dir +/+ ".." +/+ "resources" +/+ curUID).standardizePath); - File.copy(exPath, (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_code" ++ ".scd").standardizePath); - - modelPath = (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_mus_model" ++ ".json").standardizePath; - dict = globalVarsToDict.value; - if(musicChanged, { - seq = musicData; - dict["music_data"] = seq; - dict["motif_edited"] = "true" - }); - dict["cur_uid"] = curUID; - - writeResources.value(modelPath, dict); - - File.delete(ledgerPath ++ "_bak"); - File.copy(ledgerPath, ledgerPath ++ "_bak"); - File.delete(ledgerPath); - - /* - if(commitType == "add", { - if(lastCurUID == "tmp", { - ledger = ledger.drop(-1).add(curUID); - }, { - ledger = ledger.add(curUID); - }) - }); - */ - - ledger.postln; - - if(commitType == "add", {ledger = ledger.add(curUID)}); - - if(commitType == "insert", {ledger = ledger.insert(commitPos - 1, curUID)}); - - if(commitType == "replace", {ledger = ledger.put(commitPos, curUID)}); - - if(ledger.includes("tmp").postln, {ledger = ledger.removeAt(ledger.indexOf("tmp").postln)}); - - saveLedger.value(ledger, ledgerPath); - - addr.sendMsg("/committed", curUID, ledgerPath); - //refUID = curUID; - -}, \commit); - -OSCdef(\transport, {arg msg, time, addr, port; - msg.postln; - if(msg[1] == 0, { - group.set(\release, 2); - group.set(\gate, 0); - player.stop; - }, { - // the cued sequence can now be read from file, so this can be cleaned up - var cSize, patterns, pSeq, cuedSeek, indexStart, indexEnd, tmpLedger; - if(msg[1] == 1, { - pSeq = []; - cuedSeek = (seq != nil); - indexStart = msg[2].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.postln.parseJSON["music_data"]), path, indexStart + index, uid]); - file.close; - }); - }); - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - patterns = genPatterns.value(pSeq, addr); - }, { - pSeq = [loadModelJSON.value(msg[2].asString.parseJSON)["music_data"].postln]; - patterns = genPatterns.value(pSeq, addr, true); - }); - player = Pfset(pattern: patterns, cleanupFunc: { - addr.sendMsg("/transport", 0); - addr.sendMsg("/one_shot", 0); - }); - player = player.play - }); -}, \transport); - - -OSCdef(\transcribe_motif, {arg msg, time, addr, port; - var tSeq, refChord, refUID; - - msg.postln; - - tSeq = [loadModelJSON.value(msg[1].asString.parseJSON)["music_data"]]; - refUID = msg[2].asString.postln; - - if((refUID != "nil") && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }, { - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - }); - - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "lilypond" +/+ "includes").standardizePath, addr, "/transcribe_motif"); -}, \transcribe_motif); - - -OSCdef(\transcribe_all, {arg msg, time, addr, port; - var cSize, patterns, cuedSeek, indexStart, indexEnd, tmpLedger; - if(true, { - cuedSeek = (seq != nil); - indexStart = msg[1].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - - //tmp for testing transcription - indexEnd = (indexStart+5); - - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - var lilyPartLedgerFiles; - - lilyPartLedgerFiles = 4.collect({arg p; - File((dir +/+ ".." +/+ "lilypond" +/+ "includes" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly").standardizePath, "w"); - }); - - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file, fileString, tSeq, refUID, refChord; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - fileString = file.readAllString; - tSeq = msgInterpret.value(fileString.parseJSON["music_data"]); - refUID = msgInterpret.value(fileString.parseJSON["ref_uid"]); - file.close; - - //uid.postln; - //(refUID == "nil").postln; - - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - - if(refUID != "nil", { - path = (dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }); - - if(index != indexEnd, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath); - }, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath, addr, "/transcribe_all"); - }); - - lilyPartLedgerFiles.do({arg f, p; - f.write("\\include \".." +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly\"\n"); - }); - - }); - - lilyPartLedgerFiles.do({arg f; - f.close - }); - }); - /* - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - */ - }, { - - }); - -}, \transcribe_all); - -) - -~transcribe.value(~seq, dir); - -( -//synthdefs -~stringModelBusArray = 4.collect({Bus.audio(s, 1)}); -~sineBusArray = 4.collect({Bus.audio(s, 1)}); -~bassBusArray = 1.collect({Bus.audio(s, 1)}); -~hdustBusArray = 1.collect({Bus.audio(s, 1)}); -~samplerBusArray = 2.collect({Bus.audio(s, 1)}); -~sBuf = Buffer.alloc(s, 10, 2); -SynthDef(\string_model, {arg freq, gate = 1, sustain, amp, dur, attack, release = 1, busIndex = 0; - var trig, exc, sig1, sig2, noHarms; - noHarms = rrand(20, 40); - exc = Saw.ar(freq, TRand.ar(0.5, 1, Impulse.ar(freq))) * 0.001 + Dust.ar(10000, 0.01); - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.8).softclip; - //sig1 = HPF.ar(sig1, 300); - Out.ar(Select.kr(busIndex, ~stringModelBusArray), sig1 * amp * EnvGen.kr(Env.adsr(attack, 0.3, 0.9, release, 0.9, -3), gate, doneAction: 2)); - //Out.ar([0, 1], sig1 * EnvGen.kr(Env.asr(dur, 0.3, 1), gate, doneAction: 2)); -}).add; - -SynthDef(\sine, {arg freq, gate = 1, sustain, amp, dur, busIndex = 0; - var sig; - sig = SinOsc.ar(freq); - Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.asr(0.3, 0.4, 0.3), gate, timeScale: dur, doneAction: 2)); - //Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.sine(dur), gate, doneAction: 2)); -}).add; - -SynthDef(\mixer, {arg freq, gate = 1, sustain, amp, dur, out; - var nameSpaces, sigs; - - sigs = [~stringModelBusArray, ~sineBusArray/*, ~bassBusArray, ~hdustBusArray, ~samplerBusArray*/].collect({arg busArray, i; - var nameSpace, sig; - nameSpace = ['string', 'sine', 'bass', 'hdust', 'sampler'][i]; - sig = busArray.collect({arg bus, c; In.ar(bus, 1) * NamedControl.kr(\ ++ nameSpace ++ '_volume_' ++ c, 1, 0.1)}); - sig = sig.collect({arg channel, c; Pan2.ar(channel, NamedControl.kr(\ ++ nameSpace ++ '_pan_' ++ c, i / (busArray.size - 1), 0.1) * 2 - 1)}); - sig = sig.collect({arg channel, c; channel * NamedControl.kr(\ ++ nameSpace ++ '_mute_' ++ c, 1, 0.1)}); - sig = Mix.ar(sig) * pow(NamedControl.kr(\ ++ nameSpace ++ '_volume_master', 1, 0.1), 2); - }); - - sigs = Mix.ar(sigs / 4); - Out.ar(0, sigs) -}).add; - -SynthDef(\bass, { - var switches, drone; - switches = {|i| Dust.kr(0.1)} ! 9; - drone = {|i| var harm = pow(2, 2 - (i / 3).trunc), amp = (1 / pow(harm, 2)); - SinOsc.ar(60 * harm + TRand.kr(-3, 3, switches[i]), 0, amp)} ! 9; - Out.ar(~bassBusArray[0], Mix.new(drone) * 0.2); -}).add; - -SynthDef(\sampler, { - Out.ar(~samplerBusArray, PlayBuf.ar(2, ~sBuf, BufRateScale.kr(~sBuf), doneAction: 2)) -}).add; - -// main routine -SynthDef(\hdust, { - arg gate = 0; - var hierarchical_dust, low_sine, high_sine, brown_noise, white_noise; - // this triggers the combinations of sources - // it is similar to the Supercollider UGen called dust but with a hierarchical structure - hierarchical_dust = ( - TIRand.kr(0, 1, Impulse.kr(100)) * - TIRand.kr(0, 1, Impulse.kr(10)) * - TIRand.kr(0, 1, Impulse.kr(1)) * - TIRand.kr(0, 1, Impulse.kr(0.1)) - ); - // adjust the multiplier at the end of each line for adjusting levels - // note with each trigger, each source has a 1 in 3 chance of sounding - low_sine = SinOsc.ar(76.midicps / 16) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.1; - high_sine = SinOsc.ar(76.midicps * 8) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.01; - brown_noise = BrownNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.025; - white_noise = WhiteNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.02; - Out.ar(~hdustBusArray[0], - ((low_sine + high_sine + brown_noise + white_noise) ) - ); -}).add; - -) - -( -var bass, hdust, sampler, mixer; -/* -bass = Synth.tail(~group, \bass); -hdust = Synth.tail(~group, \hdust); -sampler = Synth.head(~group, \sampler); -*/ -mixer = Synth.tail(~group, \mixer); - -OSCdef(\mixer, {arg msg, time, addr, port; - mixer.set((msg[1] ++ '_' ++ msg[2] ++ '_' ++ msg[3]), msg[4]) -}, \mixer); - -/* -OSCdef(\sampler, {arg msg, time, addr, port; - msg.postln; - sampler.free; - ~sBuf.free; - ~sBuf = Buffer.read(s, msg[1].asString.postln, action: {sampler = Synth.head(~group, \sampler)}); -}, \sampler); -*/ -) - -/* old something -( -SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; - var trig, exc, sig1, sig2, noHarms, freqFinal, start, end; - noHarms = 30; - freq = WhiteNoise.ar * 3 + freq; - freqFinal = Duty.ar((1/freq), 0, freq); - trig = Changed.ar(freqFinal); - start = Demand.ar(trig, 0, Dwhite(-1, -0.75)); - end = Demand.ar(trig, 0, Dwhite(0.75, 1)); - exc = Phasor.ar(trig, (end - start) * freqFinal / SampleRate.ir, start, end, 0) * 0.001 + Dust.ar(10000, 0.01); - - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(2, 3)}) ], exc) * 0.5).softclip; - sig1 = HPF.ar(sig1, 300); - Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); -}).add; -) -*/ - diff --git a/resources/6132dd73/6132dd73_mus_model.json b/resources/6132dd73/6132dd73_mus_model.json deleted file mode 100644 index 7b0b545..0000000 --- a/resources/6132dd73/6132dd73_mus_model.json +++ /dev/null @@ -1,68 +0,0 @@ -{ -"music_data": -[ - [ - [ - [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 2.875 ], - [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 0, 1, 0, 0, 0, 0 ], [ "Rest" ] ], 0 ], - [ [ [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ 0, 1, 0, 0, 0, 0 ], [ "Rest" ] ], 0.125 ], - [ [ [ 0, 0, 0, 0, 0, 0 ], [ -1, 0, 0, 0, 0, 1 ], [ 0, 1, 0, 0, 0, 0 ], [ "Rest" ] ], 0.25 ], - [ [ [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 0, 1, 0, 0, 0, 0 ], [ "Rest" ] ], 0 ], - [ [ [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 1, 0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0 ], [ -1, 0, 0, 1, 0, -1 ] ], - [ [ 0, 0, 0, 1, 0, -1 ], [ 1, -1, 0, 1, 0, 0 ], [ -1, 0, 0, 1, 0, 0 ], [ -1, 0, 0, 1, 0, -1 ] ], - [ [ 0, 0, 0, 1, 0, -1 ], [ 1, -1, 0, 1, 0, 0 ], [ -1, 0, 0, 1, 0, 0 ], [ -1, 0, 0, 0, 0, 0 ] ], - [ [ 1, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 1, 0, 0 ], [ -1, 0, 0, 1, 0, 0 ], [ -1, 0, 0, 0, 0, 0 ] ] -], -"cur_uid": "6132dd73", -"ref_uid": "nil", -"order_seed": 721732, -"dur_seed": 938604, -"motifs_seed": 311461, -"entrances_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.26424870466321, 0.75675675675676, 0.5, 0.5, 0.58549222797927, 0.72635135135135, 1, 0.5 ], -"passages_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"exits_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"ranges": [ [ -384, 2400 ], [ -507, 2400 ], [ -282, 2237 ], [ -1200, 2053 ] ], -"step_probs_vals": [ 0, 1200, 0, 0.5, 0.5, 0.5, 1, 0.5 ], -"passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], -"hd_exp": 2, -"hd_invert": 0, -"order": -[ - [ [ 0 ], [ 2, 1, 1, 1, 2, 2, 1, 1, 2, 2 ], [ 3 ] ], - [ [ 2 ], [ 3, 1, 0, 0, 1, 1, 1, 0, 1, 3, 0 ], [ ] ] -], -"sus_weights": [ 0.75, 0.69, 0.75 ], -"order_size": [ 2, 6 ], -"passages_size": [ 0, 10 ], -"motif_edited": "false", -"order_edited": "false" -} \ No newline at end of file diff --git a/resources/6232ff77/6232ff77_code.scd b/resources/6232ff77/6232ff77_code.scd deleted file mode 100644 index b638147..0000000 --- a/resources/6232ff77/6232ff77_code.scd +++ /dev/null @@ -1,1058 +0,0 @@ -( -// helper funcs -var hsArrayToCents, pDist, hdSum, hsChordalDistance, hsArrayToFreq; - -// score funcs -var isInRange, spacingScore, rangeScore, intervalScore, inclusionScore; - -// subroutines -var genTuples, initVoices, genOrders, genSubMotif, updateVoices, genDurFunc, genStepFunc; - -// primary routines -var genMotif, genSecondarySeq; - -// audition funcs -var genPatterns, genMidiPatterns; - -// resource management funcs -var seedFunc, genUID, writeResources, stringifyToDepth, setSeeds, sanityCheck, -msgInterpret, loadLedgerFile, loadLedgerJSON, loadModelFile, loadModelJSON, -setGlobalVars, globalVarsToDict, saveLedger; - -// model vars -//(model and global vars mostly set by OSC funcs -var seq, lastXChanges, -curUID, refUID, orderSeed, durSeed, motifSeed, -entrancesProbVals, passagesProbVals, exitsProbVals, -ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, -orders, susWeights, orderSize, passagesSize, -motifEdited, orderEdited; - -// model aux vars -var entrancesDurFunc, passagesDurFunc, exitsDurFunc, stepFunc; - -// other global vars -var popSize, exPath, dir, primes, dims, tuples, -group, player, ledgerPath, ledger, currentlyPlayingUID, -nameSpaces; - -// install JSON quark -if(Quarks.isInstalled("JSONlib").not, { - Quarks.install("https://github.com/musikinformatik/JSONlib.git"); - thisProcess.recompile; - //HelpBrowser.openHelpFor("Classes/JSONlib"); -}); - - -//------helper funcs - -hsArrayToCents = { - arg hsArray; - hsArray.collect({arg dist, p; dist * 1200 * log2(primes[p][0]/primes[p][1])}).sum -}; - -pDist = { - arg array1, array2, signed = false; - var pDistance; - pDistance = hsArrayToCents.value(array1) - hsArrayToCents.value(array2); - if(signed, {pDistance}, {abs(pDistance)}) -}; - -hdSum = { - arg hsArrays; - var size, distances, mean; - size = hsArrays.size; - distances = (size - 1).collect({arg i; - ((i + 1)..(size - 1)).collect({arg j; - abs(hsArrays[i] - hsArrays[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsChordalDistance = { - arg hsArrays1, hsArrays2; - var size, distances, mean; - size = hsArrays1.size; - distances = hsArrays1.size.collect({arg i; - hsArrays2.size.collect({arg j; - abs(hsArrays1[i] - hsArrays2[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsArrayToFreq = { - arg array; - array.collect({arg dim, d; pow(primes[d][0]/primes[d][1], dim)}).product -}; - -//------score funcs - -/* -isInRange = { - arg hsArray, min, max; - var cents; - cents = hsArrayToCents.value(hsArray); - (cents >= min) && (cents <= max) -}; -*/ - -spacingScore = { - arg hsArrays, min; - var centsArray; - centsArray = hsArrays.collect({arg hsArray; hsArrayToCents.value(hsArray)}).sort({arg a, b; a < b}); - centsArray.differentiate.drop(1).collect({arg pDistance; if(pDistance >= min, {1}, {0.01})}).sum; -}; - -rangeScore = { - arg hsArray1, hsArray2, min, max, low, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - if((pDistance >= min) && (pDistance <= max), {1}, {low}); -}; - -intervalScore = { - arg hsArray1, hsArray2, mean, sd, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - //pDistance.gaussCurve(1, mean, sd) - stepFunc.value(pDistance); -}; - -inclusionScore = { - arg array, test, min = 0.01; - if(array.collect({arg v; v.hash}).includes(test.hash), {min}, {1}); -}; - - -//------subroutines - -genTuples = { - var tuples; - tuples = dims.collect({[-1, 0, 1]}).allTuples.select({arg tuple; (abs(tuple.drop(1)).sum <= 1) && (tuple[0] == 0)}); - tuples = tuples ++ tuples.collect({arg tuple; [-3, -2, -1, 1, 2, 3].collect({arg octTrans; tuple.deepCopy.put(0, octTrans)})}).flatten; -}; - -initVoices = { - var init, voicesInit; - voicesInit = popSize.collect({dims.collect({0})}); - /* - voicesInit = [dims.collect({0})]; - (popSize - 1).do({ - arg rep, new; - rep = dims.rand; - new = voicesInit.last.deepCopy; - new[rep] = new[rep] + [-1, 1].choose(); - voicesInit = voicesInit.add(new); - }); - */ - voicesInit.deepCopy; -}; - -genDurFunc = {arg chordProb, minPad, maxPad, minDur, maxDur, envData, seed; - var env, pTable, durFunc; - env = Env.pairs([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).asSignal(256).asList.asArray; - pTable = env.asRandomTable; - [chordProb, minPad, maxPad, minDur, maxDur, envData].postln; - durFunc = {arg allowChord, pad = false; - var res; - res = if(allowChord.not, { - pTable.tableRand * (maxDur - minDur) + minDur - }, { - if(1.0.rand < chordProb, {0}, {pTable.tableRand * (maxDur - minDur) + minDur}); - }).round(0.125); - if(pad, {res = res + rrand(minPad.asFloat, maxPad.asFloat).round(0.125)}); - if(res.asInteger == res, {res = res.asInteger}); - res - }; - seedFunc.value(durFunc, seed); -}; - -genStepFunc = {arg minStep, maxStep, envData, seed; - var envDataNorm, env, pTable, stepFunc; - [minStep, maxStep, envData].postln; - envDataNorm = ([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).flop; - envDataNorm = [envDataNorm[0].normalize(minStep, maxStep), envDataNorm[1]].flop; - env = Env.pairs(envDataNorm); - stepFunc = {arg pDist; - env.at(pDist).clip(0.001, 1); - }; - seedFunc.value(stepFunc, seed); -}; - -genOrders = {arg minMotifLength = 1, maxMotifLength = 5, minProgLength = 0, maxProgLength = 5; - ((maxMotifLength - minMotifLength).rand + minMotifLength).collect({ - var noProgIns, noSusIns, noSilentIns, prog, sus, silent, order; - noSusIns = [1, 2, 3].wchoose(susWeights.normalizeSum); - noProgIns = (popSize - noSusIns).rand + 1; - noSilentIns = popSize - noSusIns - noProgIns; - - # prog, sus, silent = (0..(popSize-1)).scramble.clumps([noProgIns, noSusIns, noSilentIns]); - - prog = (prog.scramble ++ ((maxProgLength - minProgLength).rand + minProgLength).collect({prog.choose}).scramble); - if(silent == nil, {silent = []}); - [sus.scramble, prog, silent.scramble] - }); -}; - -updateVoices = {arg ins, sus; - var voices, candidates, nWeights, nProbs, sel; - - voices = lastXChanges.deepCopy.last; - - candidates = sus.collect({arg v; tuples.collect({arg t; voices[v] + t})}).flatten; - candidates = difference(candidates.asSet, voices.asSet).asList; - nProbs = candidates.collect({arg candidate; - var stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore; - - //stepScore = intervalScore.value(voices[ins], candidate, 30, 400, 0.1); - stepScore = intervalScore.value(voices[ins], candidate, 100, 100); - recentlySoundedScore = inclusionScore.value(lastXChanges.flop[ins], candidate, 0); - isInRangeScore = rangeScore.value(candidate, candidate.collect({0}), ranges[ins][0], ranges[ins][1], 0, true); - regScore = spacingScore.value(voices.deepCopy.put(ins, candidate), 300); - hdScore = pow(hdSum.value(voices.deepCopy.put(ins, candidate)), hdExp); - if(hdInvert == 0, {hdScore = 1/hdScore}); - //maybe what you want here is a vector to another root and then favoring movement towards it. - //distScore = pow(hsChordalDistance.value(voices, voices.put(ins, candidate)), 2); - - [stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore] - }); - - nWeights = passagesWeights; - - //this handles nWeights of 0; mainly for testing - nProbs = nProbs.flop.select({arg scores, s; nWeights[s] != 0}).flop; - nWeights = nWeights.select({arg weight; weight != 0}); - nProbs = nProbs.flop.collect({arg scores, s; - if(scores.sum == 0, {scores}, {scores.normalizeSum * nWeights[s]}) - }); - nProbs = nProbs.flop.collect({arg scores, s; scores.product}).normalizeSum; - - sel = candidates.wchoose(nProbs); - - voices[ins] = sel; - lastXChanges = lastXChanges.add(voices).keep(-5); -}; - -genSubMotif = {arg order, orderIndex, lastState, repeatLast = false, startFromLast = false, isLastOrder = false; - var sus, prog, silent, flatOrder, res, isInChord, allowChord, pad, lastXChangesHold, voices, adder; - # sus, prog, silent = order; - flatOrder = silent ++ sus ++ prog; - lastXChangesHold = lastXChanges.deepCopy; - voices = lastState.deepCopy; - isInChord = popSize.collect({false}); - allowChord = false; - pad = false; - res = []; - "------generating motif".postln; - //need to figure out here if voices move between motifs - flatOrder.do({arg ins, i; - - if(prog.includes(ins) && repeatLast.not, {updateVoices.value(ins, sus)}); - adder = if(silent.includes(ins), {["Rest"]}, {lastXChanges.last.deepCopy[ins]}); - - if(voices[ins] != adder, { - var dur; - - if((sus ++ silent).includes(ins), { - allowChord = (ins != sus.last); - pad = (ins == sus.last); - }, { - if(i < (flatOrder.size - 1), { - allowChord = (isInChord[flatOrder[i + 1]] || (ins == flatOrder[i + 1])).not; - pad = false; - }, { - allowChord = false; - pad = true - }); - }); - if((orderIndex == 0) && sus.includes(ins), { - dur = entrancesDurFunc.value(allowChord, pad); - }, { - dur = passagesDurFunc.value(allowChord, pad); - }); - if(dur == 0, {isInChord[ins] = true}, {isInChord = popSize.collect({false})}); - - voices[ins] = adder; - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - - // pad ending - if(orderIndex == (orders.size - 1), { - (0..(popSize-1)).scramble.do({arg ins; - if(res.last.first[ins] != ["Rest"], { - var dur; - voices[ins] = ["Rest"]; - allowChord = (voices != popSize.collect({["Rest"]})); - pad = allowChord.not; - dur = exitsDurFunc.value(allowChord, pad); - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - }); - - //format and return - if(startFromLast, {lastXChanges = lastXChangesHold.deepCopy}); - res; -}; - - -//------primary routines - -genMotif = { - var repeats, fSeq, fDur, durAdd; - - repeats = 1; - fSeq = []; - - repeats.do({arg index; - var motif; - - motif = []; - - orders.do({arg order, o; - var lastState, subMotif; - lastState = if(o == 0, {popSize.collect({["Rest"]})}, {motif.last.last.first}); - subMotif = genSubMotif.value(order, o, lastState, isLastOrder: o == (orders.size - 1)); - motif = motif.add(subMotif); - - }); - - sanityCheck.value(motif, index); - - fSeq = fSeq.add(motif); - }); - - //round last duration to measure - fDur = fSeq.flatten.flatten.slice(nil, 1).sum; - durAdd = fDur.round(4) - fDur; - if(durAdd < 0, {durAdd = 4 - durAdd}); - fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] = fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] + durAdd; - - fSeq -}; - -genSecondarySeq = {arg seq; - var curdles, fSeq; - curdles = []; - while({curdles.sum < seq.size}, {curdles = curdles ++ [3.rand + 1]}); - - fSeq = seq.clumps(curdles).collect({arg clump, m; - var repeats, paddedSeq; - - //add rest - paddedSeq = clump.add([[[popSize.collect({["Rest"]}), 0.5.rand]]]); - - //implement repeats - repeats = [0.rand + 1, 1].wchoose([1, 0].normalizeSum); - repeats.collect({paddedSeq}); - }); - fSeq -}; - - -//------audition funcs - -/* -Event.addEventType(\osc, { - if (~addr.postln.notNil) { - ~addr.sendMsg(~indexPath, ~indexMsg); - ~addr.sendMsg(~seqPath, stringifyToDepth.value(~seqMsg, 3)); - //~addr.sendMsg("/STATE/OPEN", (dir.replace("supercollider", "resources") +/+ ~idMsg +/+ ~idMsg ++ "_gui_state" ++ ".state").standardizePath.postln); - }; -}); -*/ - -Event.addEventType(\osc, { - if (~addr.notNil) { - ~msg; - ~addr.sendMsg(~path, *~msg); - }; -}); - -genPatterns = {arg inSeq, addr, oneShot = false; - var voices, durs, pbinds, res, indices, sectionDurs, msg, ids, seq; - seq = inSeq.collect({arg mSeq; mSeq[0]}); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - pbinds = voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs, attacks, rels, amps; - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - //attacks = 2.collect({rrand(1, 3)}) ++ freqs.drop(2).collect({rrand(0.3, 0.5)}); - attacks = fDurs.collect({arg dur; dur * rrand(0.2, 0.4)}); - //rels = freqs.drop(2).collect({rrand(0.3, 0.5)}) ++ 2.collect({rrand(1, 3)}); - rels = (clumps.size - 1).collect({arg c; - if(clumps[c + 1][0] == ["Rest"], {rrand(1.0, 3.0)}, {rrand(0.3, 0.5)}); - }); - rels = rels.add(rrand(1.0, 3.0)); - amps = freqs.collect({rrand(0.6, 0.99)}); - - [ - Pbind( - \instrument, \string_model, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \attack, Pseq(attacks, 1), - \sustain, Pseq(fDurs, 1), - \release, Pseq(rels, 1), - //\amp, Pseq(amps, 1), - \amp, Pbrown(0.5, 1, 0.5), - \busIndex, v - ), - Pbind( - \instrument, \sine, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \sustain, Pseq(fDurs, 1), - \busIndex, v - ) - ] - }).flatten; - if(oneShot.not, { - msg = inSeq.collect({arg mSeq, m; mSeq[1..]}); - //ids = inSeq.collect({arg mSeq, m; mSeq[2]}); - sectionDurs = seq.collect({arg mSeq; mSeq.flatten2(mSeq.maxDepth - 5).flop[1].sum}); - pbinds = pbinds ++ - [ - Pbind( - \type, \osc, - \addr, addr, - \path, "/playing", - \msg, Pseq(msg, 1), - \dur, Pseq(sectionDurs, 1) - ); - ] - }); - res = Ppar(pbinds); - res -}; - -/* -genMidiPatterns = {arg seq; - var voices, durs, patterns, res, mOut, pbRange; - pbRange = 1; //semitones - change this as needed for your situation - mOut = MIDIOut.newByName("TiMidity", "TiMidity port 0").latency_(Server.default.latency); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - res = Ppar( - voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs; - - mOut.program(v, 70); - - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - - Pbind( - \type, \midi, - \chan, v, - \noteval, Pseq(freqs.cpsmidi - 24, 1), - \note, Pfunc({ | event | event[\noteval].floor }), - \dur, Pseq(fDurs, 1), - \midiout, mOut, - \amp, 1, - \bend, Pfunc({ - | event | - if (event[\note].isRest.not) { - var pitchbendvalue = event[\noteval].frac.linlin(0, pbRange, 8192, 8192*2).asInteger; - m.bend(v, pitchbendvalue); - }; - 0; // return something other than nil to avoid stopping the pattern - }), - ); - }); - ); - res -}; -*/ - - -//------resource management funcs - -genUID = {Date.seed.asHexString.toLower}; - -seedFunc = {arg func, seed; - var funcArgs, next; - next = Routine({loop{func.valueArray(funcArgs).yield }}); - next.randSeed_(seed); - {arg ...args; funcArgs = args; next.value} -}; - -stringifyToDepth = {arg data, maxDepth = 1; - var prettyString = "", rCount = 0, writeArray, indent; - - if(maxDepth == 0, { - data.asCompileString - }, { - indent = {arg size; size.collect({" "}).join("")}; - writeArray = {arg array; - prettyString = prettyString ++ indent.value(rCount) ++ "[\n"; - rCount = rCount + 1; - if(rCount < maxDepth, { - array.do({arg subArray; writeArray.value(subArray)}); - }, { - prettyString = prettyString ++ array.collect({arg subArray; - indent.value(rCount + 1) ++ subArray.asCompileString - }).join(",\n"); - }); - rCount = rCount - 1; - prettyString = prettyString ++ "\n" ++ indent.value(rCount) ++ "],\n"; - }; - - writeArray.value(data); - prettyString.replace(",\n\n", "\n").drop(-2); - }) -}; - -sanityCheck = {arg motif, index; - //print functions = very helpful - ("----------" + index + "------------").postln; - - motif.flatten.do({arg val, v; - if(v > 0, { - if(motif.flatten[v-1][0].hammingDistance(val[0]) > 1, {"problem 1".postln}); - if(motif.flatten[v-1][0].hammingDistance(val[0]) == 0, {"problem 2".postln}); - }); - val.postln - }); - "***********".postln; -}; - -msgInterpret = {arg in, escapeDoubleQuotes = true, escapeSingleQuotes = true; - var res; - - res = in; - if(res.isNil.not, { - if((res.isArray && res.isString.not), { - res = res.asCompileString; - res = res.replace(" ", "").replace("\n", "").replace("\t", ""); - if(escapeSingleQuotes, {res = res.replace("\'", "")}); - if(escapeDoubleQuotes, {res = res.replace("\"", "")}); - res = res.replace("Rest", "\"Rest\""); - res = res.interpret; - }, { - var tmpRes; - if(res.every({arg char; char.isDecDigit}), {tmpRes = res.asInteger}); - if(res.contains("."), {tmpRes = res.asFloat}); - if(tmpRes != nil, {res = tmpRes}); - }); - }); - res -}; - -writeResources = {arg path, dict; - var file, modelItems, resString; - file = File(path,"w"); - - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - - resString = nameSpaces.collect({arg nameSpace; - var depth = 0, insert = " "; - if(nameSpace == "music_data", {depth = 3; insert = "\n"}); - if(nameSpace == "last_changes", {depth = 1; insert = "\n"}); - if(nameSpace == "order", {depth = 1; insert = "\n"}); - if((nameSpace == "ref_uid") && (dict[nameSpace] == nil), {dict[nameSpace] = "nil"}); - "\"" ++ nameSpace ++ "\":" ++ insert ++ stringifyToDepth.value(dict[nameSpace], depth) - }).join(",\n"); - - resString = "{\n" ++ resString ++ "\n}"; - - file.write(resString); - file.close; - resString -}; - -loadModelFile = {arg path; loadModelJSON.value(File(path, "r").readAllString.parseJSON)}; - -loadModelJSON = {arg jsonObject; - var dict; - dict = Dictionary.with(*nameSpaces.collect({arg nS; nS->msgInterpret.value(jsonObject[nS])})); - dict -}; - -setGlobalVars = {arg dict, skipLastXChanges = false; - var tmpLastXChanges; - tmpLastXChanges = lastXChanges.deepCopy; - // order really matters!!!! - # seq, lastXChanges, curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited = nameSpaces.collect({arg nS; dict[nS]}); - if(skipLastXChanges, {lastXChanges = tmpLastXChanges}); - dict -}; - -globalVarsToDict = { - var modelItems, dict; - // order really matters!!!! - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - dict = Dictionary.with(*nameSpaces.collect({arg nS, n; nS->modelItems[n]})); -}; - -loadLedgerFile = {arg path; - ledgerPath = path; - loadLedgerJSON.value(File(ledgerPath, "r").readAllString.parseJSON) -}; - -loadLedgerJSON = {arg jsonObject; ledger = jsonObject["ledger"]}; - -saveLedger = {arg ledger, path; - var file; - file = File(path, "w"); - file.write("{\n\"ledger\":\n" ++ stringifyToDepth.value(ledger, 1) ++ "\n}"); - file.close; -}; - -//------global vars - -primes = [[2, 1], [3, 2], [5, 4], [7, 4], [11, 8], [13, 8]]; -//ranges = [[-2400, 0], [-1200, 1200], [0, 2400], [0, 2400]]; -exPath = thisProcess.nowExecutingPath; -dir = exPath.dirname; -//popSize = 4; -dims = primes.size; -tuples = genTuples.value(); -//refUID = nil; -group = Group.new; -~group = group; -loadLedgerFile.value(dir +/+ ".." +/+ "resources" +/+ "piece_ledger.json"); -//passagesWeights = [1, 1, 1, 1, 1]; -//susWeights = [1, 1, 1]; -// order really matters!!!! -nameSpaces = [ - "music_data", "last_changes", "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", - "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", - "ranges", "step_probs_vals", "passages_weights", "hd_exp", "hd_invert", - "order", "sus_weights", "order_size", "passages_size", - "motif_edited", "order_edited" -]; - - -//------OSC funcs - -OSCdef(\load_ledger, {arg msg, time, addr, port; - loadLedgerFile.value(msg[1].asString); -}, \load_ledger); - -OSCdef(\load_model, {arg msg, time, addr, port; - var dict; - dict = loadModelFile.value(msg[1].asString); - setGlobalVars.value(dict); -}, \load_model); - -OSCdef(\save_ledger, {arg msg, time, addr, port; - msg.postln; - ledger = msgInterpret.value(msg[1].asString.parseJSON["ledger"], false).postln; - //loadLedgerJSON.value(msg[0]) - saveLedger.value(ledger, msg[2].asString); - //loadLedgerFile.value(msg[1].asString); -}, \save_ledger); - -OSCdef(\generate, {arg msg, time, addr, port; - var path, dict, durSeeds, musPath, modelString; - msg.postln; - - path = msg[1].asString; - - dict = loadModelFile.value(path); - setGlobalVars.value(dict, true); - - popSize = ranges.size; - - //refUID.postln; - - loadLedgerFile.value(ledgerPath); - if(ledger == nil, {ledger = ["tmp"]}); - if(ledger.last != "tmp", {ledger = ledger.add("tmp")}); - - if(refUID == nil, {lastXChanges = [initVoices.value().deepCopy]}); - if((refUID != nil) && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - lastXChanges = msgInterpret.value(file.readAllString.parseJSON["last_changes"]); - }); - - refUID.postln; - lastXChanges.collect({arg item; item.postln}); - - durSeeds = seedFunc.value({3.collect({rrand(100000, 999999)})}, durSeed).value.postln; - entrancesDurFunc = genDurFunc.valueArray(entrancesProbVals[..4] ++ [entrancesProbVals[5..]] ++ [durSeeds[0]]); - passagesDurFunc = genDurFunc.valueArray(passagesProbVals[..4] ++ [passagesProbVals[5..]] ++ [durSeeds[1]]); - exitsDurFunc = genDurFunc.valueArray(exitsProbVals[..4] ++ [exitsProbVals[5..]] ++ [durSeeds[2]]); - - if(orders == nil, { - orders = seedFunc.value(genOrders, orderSeed).valueArray(orderSize ++ passagesSize); - //addr.sendMsg("/order", stringifyToDepth.value(orders, 1)); - }); - - stepFunc = genStepFunc.valueArray(stepProbsVals[..1] ++ [stepProbsVals[2..]] ++ [motifSeed]); - seq = seedFunc.value(genMotif, motifSeed).value; - - lastXChanges.collect({arg item; item.postln}); - - dict = globalVarsToDict.value; - modelString = writeResources.value(path, dict); - - //addr.sendMsg("/generated", musPath, stringifyToDepth.value(seq, 3)); - //~seq = seq; - - addr.sendMsg("/generated", path, modelString, ledgerPath); -}, \generate); - - -OSCdef(\commit, {arg msg, time, addr, port; - var musicData, musicChanged, dict, newLedger, modelPath, musString, musFile, test1, test2, lastCurUID, commitType, commitPos, equalityLedger; - //msg.postln; - - /* - test1 = msg[1].asString.parseJSON; - test2 = (dir +/+ ".." +/+ "resources/tmp/tmp_music" ++ ".json").standardizePath.parseJSONFile; - msgInterpret.value(test1["music"])[0][0][0][1].class.postln; - msgInterpret.value(test2["music_data"])[0][0][0][1].class.postln; - (test1["music"] == test2["music_data"]).postln; - */ - - musicData = loadModelJSON.value(msg[1].asString.parseJSON)["music_data"].postln; - musicChanged = (musicData != seq).postln; - commitType = msg[2].asString; - commitPos = msg[3].postln.asInteger; - - lastCurUID = curUID.deepCopy; - curUID = genUID.value; - - File.mkdir((dir +/+ ".." +/+ "resources" +/+ curUID).standardizePath); - File.copy(exPath, (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_code" ++ ".scd").standardizePath); - - modelPath = (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_mus_model" ++ ".json").standardizePath; - dict = globalVarsToDict.value; - if(musicChanged, { - seq = musicData; - dict["music_data"] = seq; - dict["motif_edited"] = "true" - }); - dict["cur_uid"] = curUID; - - writeResources.value(modelPath, dict); - - File.delete(ledgerPath ++ "_bak"); - File.copy(ledgerPath, ledgerPath ++ "_bak"); - File.delete(ledgerPath); - - /* - if(commitType == "add", { - if(lastCurUID == "tmp", { - ledger = ledger.drop(-1).add(curUID); - }, { - ledger = ledger.add(curUID); - }) - }); - */ - - ledger.postln; - - if(commitType == "add", {ledger = ledger.add(curUID)}); - - if(commitType == "insert", {ledger = ledger.insert(commitPos - 1, curUID)}); - - if(commitType == "replace", {ledger = ledger.put(commitPos, curUID)}); - - equalityLedger = ledger.collect({arg item; item.asSymbol}); - if(equalityLedger.includes(\tmp).postln, {ledger.removeAt(equalityLedger.indexOf(\tmp).postln)}); - - ledger.postln; - - saveLedger.value(ledger, ledgerPath); - - addr.sendMsg("/committed", curUID, ledgerPath); - //refUID = curUID; - -}, \commit); - -OSCdef(\transport, {arg msg, time, addr, port; - msg.postln; - if(msg[1] == 0, { - group.set(\release, 2); - group.set(\gate, 0); - player.stop; - }, { - // the cued sequence can now be read from file, so this can be cleaned up - var cSize, patterns, pSeq, cuedSeek, indexStart, indexEnd, tmpLedger; - if(msg[1] == 1, { - pSeq = []; - cuedSeek = (seq != nil); - indexStart = msg[2].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.postln.parseJSON["music_data"]), path, indexStart + index, uid]); - file.close; - }); - }); - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - patterns = genPatterns.value(pSeq, addr); - }, { - pSeq = [loadModelJSON.value(msg[2].asString.parseJSON)["music_data"].postln]; - patterns = genPatterns.value(pSeq, addr, true); - }); - player = Pfset(pattern: patterns, cleanupFunc: { - addr.sendMsg("/transport", 0); - addr.sendMsg("/one_shot", 0); - }); - player = player.play - }); -}, \transport); - - -OSCdef(\transcribe_motif, {arg msg, time, addr, port; - var tSeq, refChord, refUID; - - msg.postln; - - tSeq = [loadModelJSON.value(msg[1].asString.parseJSON)["music_data"]]; - refUID = msg[2].asString.postln; - - if((refUID != "nil") && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }, { - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - }); - - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "lilypond" +/+ "includes").standardizePath, addr, "/transcribe_motif"); -}, \transcribe_motif); - - -OSCdef(\transcribe_all, {arg msg, time, addr, port; - var cSize, patterns, cuedSeek, indexStart, indexEnd, tmpLedger; - if(true, { - cuedSeek = (seq != nil); - indexStart = msg[1].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - - //tmp for testing transcription - indexEnd = (indexStart+5); - - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - var lilyPartLedgerFiles; - - lilyPartLedgerFiles = 4.collect({arg p; - File((dir +/+ ".." +/+ "lilypond" +/+ "includes" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly").standardizePath, "w"); - }); - - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file, fileString, tSeq, refUID, refChord; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - fileString = file.readAllString; - tSeq = msgInterpret.value(fileString.parseJSON["music_data"]); - refUID = msgInterpret.value(fileString.parseJSON["ref_uid"]); - file.close; - - //uid.postln; - //(refUID == "nil").postln; - - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - - if(refUID != "nil", { - path = (dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }); - - if(index != indexEnd, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath); - }, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath, addr, "/transcribe_all"); - }); - - lilyPartLedgerFiles.do({arg f, p; - f.write("\\include \".." +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly\"\n"); - }); - - }); - - lilyPartLedgerFiles.do({arg f; - f.close - }); - }); - /* - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - */ - }, { - - }); - -}, \transcribe_all); - -) - -~transcribe.value(~seq, dir); - -( -//synthdefs -~stringModelBusArray = 4.collect({Bus.audio(s, 1)}); -~sineBusArray = 4.collect({Bus.audio(s, 1)}); -~bassBusArray = 1.collect({Bus.audio(s, 1)}); -~hdustBusArray = 1.collect({Bus.audio(s, 1)}); -~samplerBusArray = 2.collect({Bus.audio(s, 1)}); -~sBuf = Buffer.alloc(s, 10, 2); -SynthDef(\string_model, {arg freq, gate = 1, sustain, amp, dur, attack, release = 1, busIndex = 0; - var trig, exc, sig1, sig2, noHarms; - noHarms = rrand(20, 40); - exc = Saw.ar(freq, TRand.ar(0.5, 1, Impulse.ar(freq))) * 0.001 + Dust.ar(10000, 0.01); - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.8).softclip; - //sig1 = HPF.ar(sig1, 300); - Out.ar(Select.kr(busIndex, ~stringModelBusArray), sig1 * amp * EnvGen.kr(Env.adsr(attack, 0.3, 0.9, release, 0.9, -3), gate, doneAction: 2)); - //Out.ar([0, 1], sig1 * EnvGen.kr(Env.asr(dur, 0.3, 1), gate, doneAction: 2)); -}).add; - -SynthDef(\sine, {arg freq, gate = 1, sustain, amp, dur, busIndex = 0; - var sig; - sig = SinOsc.ar(freq); - Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.asr(0.3, 0.4, 0.3), gate, timeScale: dur, doneAction: 2)); - //Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.sine(dur), gate, doneAction: 2)); -}).add; - -SynthDef(\mixer, {arg freq, gate = 1, sustain, amp, dur, out; - var nameSpaces, sigs; - - sigs = [~stringModelBusArray, ~sineBusArray/*, ~bassBusArray, ~hdustBusArray, ~samplerBusArray*/].collect({arg busArray, i; - var nameSpace, sig; - nameSpace = ['string', 'sine', 'bass', 'hdust', 'sampler'][i]; - sig = busArray.collect({arg bus, c; In.ar(bus, 1) * NamedControl.kr(\ ++ nameSpace ++ '_volume_' ++ c, 1, 0.1)}); - sig = sig.collect({arg channel, c; Pan2.ar(channel, NamedControl.kr(\ ++ nameSpace ++ '_pan_' ++ c, i / (busArray.size - 1), 0.1) * 2 - 1)}); - sig = sig.collect({arg channel, c; channel * NamedControl.kr(\ ++ nameSpace ++ '_mute_' ++ c, 1, 0.1)}); - sig = Mix.ar(sig) * pow(NamedControl.kr(\ ++ nameSpace ++ '_volume_master', 1, 0.1), 2); - }); - - sigs = Mix.ar(sigs / 4); - Out.ar(0, sigs) -}).add; - -SynthDef(\bass, { - var switches, drone; - switches = {|i| Dust.kr(0.1)} ! 9; - drone = {|i| var harm = pow(2, 2 - (i / 3).trunc), amp = (1 / pow(harm, 2)); - SinOsc.ar(60 * harm + TRand.kr(-3, 3, switches[i]), 0, amp)} ! 9; - Out.ar(~bassBusArray[0], Mix.new(drone) * 0.2); -}).add; - -SynthDef(\sampler, { - Out.ar(~samplerBusArray, PlayBuf.ar(2, ~sBuf, BufRateScale.kr(~sBuf), doneAction: 2)) -}).add; - -// main routine -SynthDef(\hdust, { - arg gate = 0; - var hierarchical_dust, low_sine, high_sine, brown_noise, white_noise; - // this triggers the combinations of sources - // it is similar to the Supercollider UGen called dust but with a hierarchical structure - hierarchical_dust = ( - TIRand.kr(0, 1, Impulse.kr(100)) * - TIRand.kr(0, 1, Impulse.kr(10)) * - TIRand.kr(0, 1, Impulse.kr(1)) * - TIRand.kr(0, 1, Impulse.kr(0.1)) - ); - // adjust the multiplier at the end of each line for adjusting levels - // note with each trigger, each source has a 1 in 3 chance of sounding - low_sine = SinOsc.ar(76.midicps / 16) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.1; - high_sine = SinOsc.ar(76.midicps * 8) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.01; - brown_noise = BrownNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.025; - white_noise = WhiteNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.02; - Out.ar(~hdustBusArray[0], - ((low_sine + high_sine + brown_noise + white_noise) ) - ); -}).add; - -) - -( -var bass, hdust, sampler, mixer; -/* -bass = Synth.tail(~group, \bass); -hdust = Synth.tail(~group, \hdust); -sampler = Synth.head(~group, \sampler); -*/ -mixer = Synth.tail(~group, \mixer); - -OSCdef(\mixer, {arg msg, time, addr, port; - mixer.set((msg[1] ++ '_' ++ msg[2] ++ '_' ++ msg[3]), msg[4]) -}, \mixer); - -/* -OSCdef(\sampler, {arg msg, time, addr, port; - msg.postln; - sampler.free; - ~sBuf.free; - ~sBuf = Buffer.read(s, msg[1].asString.postln, action: {sampler = Synth.head(~group, \sampler)}); -}, \sampler); -*/ -) - -/* old something -( -SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; - var trig, exc, sig1, sig2, noHarms, freqFinal, start, end; - noHarms = 30; - freq = WhiteNoise.ar * 3 + freq; - freqFinal = Duty.ar((1/freq), 0, freq); - trig = Changed.ar(freqFinal); - start = Demand.ar(trig, 0, Dwhite(-1, -0.75)); - end = Demand.ar(trig, 0, Dwhite(0.75, 1)); - exc = Phasor.ar(trig, (end - start) * freqFinal / SampleRate.ir, start, end, 0) * 0.001 + Dust.ar(10000, 0.01); - - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(2, 3)}) ], exc) * 0.5).softclip; - sig1 = HPF.ar(sig1, 300); - Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); -}).add; -) -*/ - diff --git a/resources/6232ff77/6232ff77_mus_model.json b/resources/6232ff77/6232ff77_mus_model.json deleted file mode 100644 index f2507ff..0000000 --- a/resources/6232ff77/6232ff77_mus_model.json +++ /dev/null @@ -1,85 +0,0 @@ -{ -"music_data": -[ - [ - [ - [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 0 ], - [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ] ], 0.625 ], - [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, -1, 0, 0, 0 ] ], 0.125 ], - [ [ [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 1 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, -1, 0, 0, 0 ] ], 0.375 ], - [ [ [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, -1, 0, 0, 0 ] ], 0.25 ], - [ [ [ 0, 0, 0, 0, 0, 0 ], [ 2, 0, 0, 0, 0, -1 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, -1, 0, 0, 0 ] ], 4.75 ] - ], - [ - [ [ [ 0, 0, 0, 0, 0, 0 ], [ 2, 0, 0, 0, 0, -1 ], [ "Rest" ], [ 1, 0, -1, 0, 0, 0 ] ], 0.25 ], - [ [ [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 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, 0 ] ], 0 ], - [ [ [ 2, 0, -1, 0, 0, 0 ], [ 1, 0, -1, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, 0 ] ], 4.5 ], - [ [ [ 2, 0, -1, 0, 0, 0 ], [ 1, 0, -1, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ] ], 0 ], - [ [ [ "Rest" ], [ 1, 0, -1, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ] ], 0.25 ], - [ [ [ "Rest" ], [ 1, 0, -1, 0, 0, 0 ], [ "Rest" ], [ "Rest" ] ], 0 ], - [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 8.375 ] - ] - ] -], -"last_changes": -[ - [ [ 2, 0, -1, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, 0 ] ], - [ [ 2, 0, -1, 0, 0, 0 ], [ 1, -1, -1, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, 0 ] ], - [ [ 2, 0, -1, 0, 0, 0 ], [ 0, 0, 0, 1, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, 0 ] ], - [ [ 2, 0, -1, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 1 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, 0 ] ], - [ [ 2, 0, -1, 0, 0, 0 ], [ 1, 0, -1, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, 0 ] ] -], -"cur_uid": "6232ff77", -"ref_uid": "nil", -"order_seed": 604809, -"dur_seed": 701911, -"motifs_seed": 617408, -"entrances_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.26424870466321, 0.75675675675676, 0.5, 0.5, 0.58549222797927, 0.72635135135135, 1, 0.5 ], -"passages_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"exits_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"ranges": [ [ -384, 2400 ], [ -507, 2400 ], [ -282, 2237 ], [ -1200, 2053 ] ], -"step_probs_vals": [ 0, 1200, 0, 0.5, 0.5, 0.5, 1, 0.5 ], -"passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], -"hd_exp": 2, -"hd_invert": 0, -"order": -[ - [ [ 0, 2 ], [ 3, 1, 1, 1 ], [ ] ], - [ [ 0 ], [ 1, 3, 1 ], [ 2 ] ], - [ [ 1, 2, 3 ], [ 0, 0, 0, 0, 0, 0, 0, 0 ], [ ] ], - [ [ 0, 2 ], [ 1, 1, 1, 1, 1, 1, 1, 1 ], [ 3 ] ], - [ [ 3, 2, 0 ], [ 1 ], [ ] ] -], -"sus_weights": [ 0.75, 0.69, 0.75 ], -"order_size": [ 2, 6 ], -"passages_size": [ 0, 10 ], -"motif_edited": "false", -"order_edited": "false" -} \ No newline at end of file diff --git a/resources/628d5c8b/lilypond/part_I.ly b/resources/628d5c8b/lilypond/part_I.ly deleted file mode 100644 index 8bff5c2..0000000 --- a/resources/628d5c8b/lilypond/part_I.ly +++ /dev/null @@ -1,24 +0,0 @@ -{ - { r4 r16[ g'8.^\markup { \pad-markup #0.2 "+2"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 3↑" }}] ~ g'2 ~ } - \bar "|" - { g'8.[ fis'16^\markup { \pad-markup #0.2 "+49"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 11↓" }}] ~ fis'2. ~ } - \bar "|" - { fis'8[ fis'8^\markup { \pad-markup #0.2 "-49"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 11↑" }}] ~ fis'2 ~ fis'8[ e'8^\markup { \pad-markup #0.2 "-14"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 5↑" }}] ~ } - \bar "|" - { e'4 d'4^\markup { \pad-markup #0.2 "+31"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 7↓" }} ~ d'4 ~ d'8[ ais8^\markup { \pad-markup #0.2 "-31"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 7↑" }}] ~ } - \bar "|" \break - { ais2 ~ ais8.[ g'16^\markup { \pad-markup #0.2 "+2"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 3↑" }}] ~ g'4 ~ } - \bar "|" - { g'1 ~ } - \bar "|" - { g'1 ~ } - \bar "|" - { g'1 ~ } - \bar "|" \break - { g'1 ~ } - \bar "|" - { g'1 } - \bar "|" - { r1 } -\bar "||" -} \ No newline at end of file diff --git a/resources/628d5c8b/lilypond/part_II.ly b/resources/628d5c8b/lilypond/part_II.ly deleted file mode 100644 index 9f6d48c..0000000 --- a/resources/628d5c8b/lilypond/part_II.ly +++ /dev/null @@ -1,24 +0,0 @@ -{ - { r4 r16[ e'8.^\markup { \pad-markup #0.2 "-41"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 13↓" }}] ~ e'2 ~ } - \bar "|" - { e'1 ~ } - \bar "|" - { e'1 ~ } - \bar "|" - { e'1 ~ } - \bar "|" \break - { e'1 ~ } - \bar "|" - { e'1 ~ } - \bar "|" - { e'8[ fis'8^\markup { \pad-markup #0.2 "-49"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 11↑" }}] ~ fis'4 ~ fis'8.[ dis'16^\markup { \pad-markup #0.2 "+16"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "I"\normal-size-super " 5↓" }}] ~ dis'4 ~ } - \bar "|" - { dis'16[ d'8.^\markup { \pad-markup #0.2 "-49"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "I"\normal-size-super " 11↓" }}] ~ d'2 ~ d'16[ cis'8.^\markup { \pad-markup #0.2 "+39"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "III"\normal-size-super " 13↑" }}] ~ } - \bar "|" \break - { cis'2 ~ cis'16[ b8.^\markup { \pad-markup #0.2 "-39"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "I"\normal-size-super " 13↓" }}] ~ b4 ~ } - \bar "|" - { b4 ~ b8.[ r16] r2 } - \bar "|" - { r1 } -\bar "||" -} \ No newline at end of file diff --git a/resources/628d5c8b/lilypond/part_III.ly b/resources/628d5c8b/lilypond/part_III.ly deleted file mode 100644 index 43117d2..0000000 --- a/resources/628d5c8b/lilypond/part_III.ly +++ /dev/null @@ -1,24 +0,0 @@ -{ - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" \break - { r1 } - \bar "|" - { r2 r8[ f'8^\markup { \pad-markup #0.2 "-2"}] ~ f'4 ~ } - \bar "|" - { f'1 ~ } - \bar "|" - { f'1 ~ } - \bar "|" \break - { f'1 ~ } - \bar "|" - { f'1 ~ } - \bar "|" - { f'4 r2. } -\bar "||" -} \ No newline at end of file diff --git a/resources/628d5c8b/lilypond/part_IV.ly b/resources/628d5c8b/lilypond/part_IV.ly deleted file mode 100644 index 6224cde..0000000 --- a/resources/628d5c8b/lilypond/part_IV.ly +++ /dev/null @@ -1,24 +0,0 @@ -{ - { c'4^\markup { \pad-markup #0.2 "+0"} ~ c'2. ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" \break - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" \break - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'4 r2. } -\bar "||" -} \ No newline at end of file diff --git a/resources/640eeed3/lilypond/part_I.ly b/resources/640eeed3/lilypond/part_I.ly deleted file mode 100644 index 461d085..0000000 --- a/resources/640eeed3/lilypond/part_I.ly +++ /dev/null @@ -1,14 +0,0 @@ -{ - { r1 } - \bar "|" - { r2 r16[ b8.^\markup { \pad-markup #0.2 "+11"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "III"\normal-size-super " 7↓" }}] ~ b4 ~ } - \bar "|" - { b2 ~ b8.[ r16] r4 } - \bar "|" - { r1 } - \bar "|" \break - { r1 } - \bar "|" - { r1 } -\bar "||" -} \ No newline at end of file diff --git a/resources/640eeed3/lilypond/part_II.ly b/resources/640eeed3/lilypond/part_II.ly deleted file mode 100644 index e6f1a35..0000000 --- a/resources/640eeed3/lilypond/part_II.ly +++ /dev/null @@ -1,14 +0,0 @@ -{ - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" \break - { r1 } - \bar "|" - { r1 } -\bar "||" -} \ No newline at end of file diff --git a/resources/640eeed3/lilypond/part_III.ly b/resources/640eeed3/lilypond/part_III.ly deleted file mode 100644 index d922a8e..0000000 --- a/resources/640eeed3/lilypond/part_III.ly +++ /dev/null @@ -1,14 +0,0 @@ -{ - { a4^\markup { \pad-markup #0.2 "-20"} ~ a2. ~ } - \bar "|" - { a1 ~ } - \bar "|" - { a1 ~ } - \bar "|" - { a1 } - \bar "|" \break - { r1 } - \bar "|" - { r1 } -\bar "||" -} \ No newline at end of file diff --git a/resources/640eeed3/lilypond/part_IV.ly b/resources/640eeed3/lilypond/part_IV.ly deleted file mode 100644 index e6f1a35..0000000 --- a/resources/640eeed3/lilypond/part_IV.ly +++ /dev/null @@ -1,14 +0,0 @@ -{ - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" \break - { r1 } - \bar "|" - { r1 } -\bar "||" -} \ No newline at end of file diff --git a/resources/64b535ef/64b535ef_code.scd b/resources/64b535ef/64b535ef_code.scd deleted file mode 100644 index 3eb3cbd..0000000 --- a/resources/64b535ef/64b535ef_code.scd +++ /dev/null @@ -1,1058 +0,0 @@ -( -// helper funcs -var hsArrayToCents, pDist, hdSum, hsChordalDistance, hsArrayToFreq; - -// score funcs -var isInRange, spacingScore, rangeScore, intervalScore, inclusionScore; - -// subroutines -var genTuples, initVoices, genOrders, genSubMotif, updateVoices, genDurFunc, genStepFunc; - -// primary routines -var genMotif, genSecondarySeq; - -// audition funcs -var genPatterns, genMidiPatterns; - -// resource management funcs -var seedFunc, genUID, writeResources, stringifyToDepth, setSeeds, sanityCheck, -msgInterpret, loadLedgerFile, loadLedgerJSON, loadModelFile, loadModelJSON, -setGlobalVars, globalVarsToDict, saveLedger; - -// model vars -//(model and global vars mostly set by OSC funcs -var seq, lastXChanges, -curUID, refUID, orderSeed, durSeed, motifSeed, -entrancesProbVals, passagesProbVals, exitsProbVals, -ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, -orders, susWeights, orderSize, passagesSize, -motifEdited, orderEdited; - -// model aux vars -var entrancesDurFunc, passagesDurFunc, exitsDurFunc, stepFunc; - -// other global vars -var popSize, exPath, dir, primes, dims, tuples, -group, player, ledgerPath, ledger, currentlyPlayingUID, -nameSpaces; - -// install JSON quark -if(Quarks.isInstalled("JSONlib").not, { - Quarks.install("https://github.com/musikinformatik/JSONlib.git"); - thisProcess.recompile; - //HelpBrowser.openHelpFor("Classes/JSONlib"); -}); - - -//------helper funcs - -hsArrayToCents = { - arg hsArray; - hsArray.collect({arg dist, p; dist * 1200 * log2(primes[p][0]/primes[p][1])}).sum -}; - -pDist = { - arg array1, array2, signed = false; - var pDistance; - pDistance = hsArrayToCents.value(array1) - hsArrayToCents.value(array2); - if(signed, {pDistance}, {abs(pDistance)}) -}; - -hdSum = { - arg hsArrays; - var size, distances, mean; - size = hsArrays.size; - distances = (size - 1).collect({arg i; - ((i + 1)..(size - 1)).collect({arg j; - abs(hsArrays[i] - hsArrays[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsChordalDistance = { - arg hsArrays1, hsArrays2; - var size, distances, mean; - size = hsArrays1.size; - distances = hsArrays1.size.collect({arg i; - hsArrays2.size.collect({arg j; - abs(hsArrays1[i] - hsArrays2[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsArrayToFreq = { - arg array; - array.collect({arg dim, d; pow(primes[d][0]/primes[d][1], dim)}).product -}; - -//------score funcs - -/* -isInRange = { - arg hsArray, min, max; - var cents; - cents = hsArrayToCents.value(hsArray); - (cents >= min) && (cents <= max) -}; -*/ - -spacingScore = { - arg hsArrays, min; - var centsArray; - centsArray = hsArrays.collect({arg hsArray; hsArrayToCents.value(hsArray)}).sort({arg a, b; a < b}); - centsArray.differentiate.drop(1).collect({arg pDistance; if(pDistance >= min, {1}, {0.01})}).sum; -}; - -rangeScore = { - arg hsArray1, hsArray2, min, max, low, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - if((pDistance >= min) && (pDistance <= max), {1}, {low}); -}; - -intervalScore = { - arg hsArray1, hsArray2, mean, sd, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - //pDistance.gaussCurve(1, mean, sd) - stepFunc.value(pDistance); -}; - -inclusionScore = { - arg array, test, min = 0.01; - if(array.collect({arg v; v.hash}).includes(test.hash), {min}, {1}); -}; - - -//------subroutines - -genTuples = { - var tuples; - tuples = dims.collect({[-1, 0, 1]}).allTuples.select({arg tuple; (abs(tuple.drop(1)).sum <= 1) && (tuple[0] == 0)}); - tuples = tuples ++ tuples.collect({arg tuple; [-3, -2, -1, 1, 2, 3].collect({arg octTrans; tuple.deepCopy.put(0, octTrans)})}).flatten; -}; - -initVoices = { - var init, voicesInit; - voicesInit = popSize.collect({dims.collect({0})}); - /* - voicesInit = [dims.collect({0})]; - (popSize - 1).do({ - arg rep, new; - rep = dims.rand; - new = voicesInit.last.deepCopy; - new[rep] = new[rep] + [-1, 1].choose(); - voicesInit = voicesInit.add(new); - }); - */ - voicesInit.deepCopy; -}; - -genDurFunc = {arg chordProb, minPad, maxPad, minDur, maxDur, envData, seed; - var env, pTable, durFunc; - env = Env.pairs([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).asSignal(256).asList.asArray; - pTable = env.asRandomTable; - [chordProb, minPad, maxPad, minDur, maxDur, envData].postln; - durFunc = {arg allowChord, pad = false; - var res; - res = if(allowChord.not, { - pTable.tableRand * (maxDur - minDur) + minDur - }, { - if(1.0.rand < chordProb, {0}, {pTable.tableRand * (maxDur - minDur) + minDur}); - }).round(0.125); - if(pad, {res = res + rrand(minPad.asFloat, maxPad.asFloat).round(0.125)}); - if(res.asInteger == res, {res = res.asInteger}); - res - }; - seedFunc.value(durFunc, seed); -}; - -genStepFunc = {arg minStep, maxStep, envData, seed; - var envDataNorm, env, pTable, stepFunc; - [minStep, maxStep, envData].postln; - envDataNorm = ([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).flop; - envDataNorm = [envDataNorm[0].normalize(minStep, maxStep), envDataNorm[1]].flop; - env = Env.pairs(envDataNorm); - stepFunc = {arg pDist; - env.at(pDist).clip(0.001, 1); - }; - seedFunc.value(stepFunc, seed); -}; - -genOrders = {arg minMotifLength = 1, maxMotifLength = 5, minProgLength = 0, maxProgLength = 5; - ((maxMotifLength - minMotifLength).rand + minMotifLength).collect({ - var noProgIns, noSusIns, noSilentIns, prog, sus, silent, order; - noSusIns = [1, 2, 3].wchoose(susWeights.normalizeSum); - noProgIns = (popSize - noSusIns).rand + 1; - noSilentIns = popSize - noSusIns - noProgIns; - - # prog, sus, silent = (0..(popSize-1)).scramble.clumps([noProgIns, noSusIns, noSilentIns]); - - prog = (prog.scramble ++ ((maxProgLength - minProgLength).rand + minProgLength).collect({prog.choose}).scramble); - if(silent == nil, {silent = []}); - [sus.scramble, prog, silent.scramble] - }); -}; - -updateVoices = {arg ins, sus; - var voices, candidates, nWeights, nProbs, sel; - - voices = lastXChanges.deepCopy.last; - - candidates = sus.collect({arg v; tuples.collect({arg t; voices[v] + t})}).flatten; - candidates = difference(candidates.asSet, voices.asSet).asList; - nProbs = candidates.collect({arg candidate; - var stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore; - - //stepScore = intervalScore.value(voices[ins], candidate, 30, 400, 0.1); - stepScore = intervalScore.value(voices[ins], candidate, 100, 100); - recentlySoundedScore = inclusionScore.value(lastXChanges.flop[ins], candidate, 0); - isInRangeScore = rangeScore.value(candidate, candidate.collect({0}), ranges[ins][0], ranges[ins][1], 0, true); - regScore = spacingScore.value(voices.deepCopy.put(ins, candidate), 300); - hdScore = pow(hdSum.value(voices.deepCopy.put(ins, candidate)), hdExp); - if(hdInvert == 0, {hdScore = 1/hdScore}); - //maybe what you want here is a vector to another root and then favoring movement towards it. - //distScore = pow(hsChordalDistance.value(voices, voices.put(ins, candidate)), 2); - - [stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore] - }); - - nWeights = passagesWeights; - - //this handles nWeights of 0; mainly for testing - nProbs = nProbs.flop.select({arg scores, s; nWeights[s] != 0}).flop; - nWeights = nWeights.select({arg weight; weight != 0}); - nProbs = nProbs.flop.collect({arg scores, s; - if(scores.sum == 0, {scores}, {scores.normalizeSum * nWeights[s]}) - }); - nProbs = nProbs.flop.collect({arg scores, s; scores.product}).normalizeSum; - - sel = candidates.wchoose(nProbs); - - voices[ins] = sel; - lastXChanges = lastXChanges.add(voices).keep(-5); -}; - -genSubMotif = {arg order, orderIndex, lastState, repeatLast = false, startFromLast = false, isLastOrder = false; - var sus, prog, silent, flatOrder, res, isInChord, allowChord, pad, lastXChangesHold, voices, adder; - # sus, prog, silent = order; - flatOrder = silent ++ sus ++ prog; - lastXChangesHold = lastXChanges.deepCopy; - voices = lastState.deepCopy; - isInChord = popSize.collect({false}); - allowChord = false; - pad = false; - res = []; - "------generating motif".postln; - //need to figure out here if voices move between motifs - flatOrder.do({arg ins, i; - - if(prog.includes(ins) && repeatLast.not, {updateVoices.value(ins, sus)}); - adder = if(silent.includes(ins), {["Rest"]}, {lastXChanges.last.deepCopy[ins]}); - - if(voices[ins] != adder, { - var dur; - - if((sus ++ silent).includes(ins), { - allowChord = (ins != sus.last); - pad = (ins == sus.last); - }, { - if(i < (flatOrder.size - 1), { - allowChord = (isInChord[flatOrder[i + 1]] || (ins == flatOrder[i + 1])).not; - pad = false; - }, { - allowChord = false; - pad = true - }); - }); - if((orderIndex == 0) && sus.includes(ins), { - dur = entrancesDurFunc.value(allowChord, pad); - }, { - dur = passagesDurFunc.value(allowChord, pad); - }); - if(dur == 0, {isInChord[ins] = true}, {isInChord = popSize.collect({false})}); - - voices[ins] = adder; - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - - // pad ending - if(orderIndex == (orders.size - 1), { - (0..(popSize-1)).scramble.do({arg ins; - if(res.last.first[ins] != ["Rest"], { - var dur; - voices[ins] = ["Rest"]; - allowChord = (voices != popSize.collect({["Rest"]})); - pad = allowChord.not; - dur = exitsDurFunc.value(allowChord, pad); - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - }); - - //format and return - if(startFromLast, {lastXChanges = lastXChangesHold.deepCopy}); - res; -}; - - -//------primary routines - -genMotif = { - var repeats, fSeq, fDur, durAdd; - - repeats = 1; - fSeq = []; - - repeats.do({arg index; - var motif; - - motif = []; - - orders.do({arg order, o; - var lastState, subMotif; - lastState = if(o == 0, {popSize.collect({["Rest"]})}, {motif.last.last.first}); - subMotif = genSubMotif.value(order, o, lastState, isLastOrder: o == (orders.size - 1)); - motif = motif.add(subMotif); - - }); - - sanityCheck.value(motif, index); - - fSeq = fSeq.add(motif); - }); - - //round last duration to measure - fDur = fSeq.flatten.flatten.slice(nil, 1).sum; - durAdd = fDur.round(4) - fDur; - if(durAdd < 0, {durAdd = 4 - durAdd}); - fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] = fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] + durAdd; - - fSeq -}; - -genSecondarySeq = {arg seq; - var curdles, fSeq; - curdles = []; - while({curdles.sum < seq.size}, {curdles = curdles ++ [3.rand + 1]}); - - fSeq = seq.clumps(curdles).collect({arg clump, m; - var repeats, paddedSeq; - - //add rest - paddedSeq = clump.add([[[popSize.collect({["Rest"]}), 0.5.rand]]]); - - //implement repeats - repeats = [0.rand + 1, 1].wchoose([1, 0].normalizeSum); - repeats.collect({paddedSeq}); - }); - fSeq -}; - - -//------audition funcs - -/* -Event.addEventType(\osc, { - if (~addr.postln.notNil) { - ~addr.sendMsg(~indexPath, ~indexMsg); - ~addr.sendMsg(~seqPath, stringifyToDepth.value(~seqMsg, 3)); - //~addr.sendMsg("/STATE/OPEN", (dir.replace("supercollider", "resources") +/+ ~idMsg +/+ ~idMsg ++ "_gui_state" ++ ".state").standardizePath.postln); - }; -}); -*/ - -Event.addEventType(\osc, { - if (~addr.notNil) { - ~msg; - ~addr.sendMsg(~path, *~msg); - }; -}); - -genPatterns = {arg inSeq, addr, oneShot = false; - var voices, durs, pbinds, res, indices, sectionDurs, msg, ids, seq; - seq = inSeq.collect({arg mSeq; mSeq[0]}); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - pbinds = voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs, attacks, rels, amps; - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - //attacks = 2.collect({rrand(1, 3)}) ++ freqs.drop(2).collect({rrand(0.3, 0.5)}); - attacks = fDurs.collect({arg dur; dur * rrand(0.2, 0.4)}); - //rels = freqs.drop(2).collect({rrand(0.3, 0.5)}) ++ 2.collect({rrand(1, 3)}); - rels = (clumps.size - 1).collect({arg c; - if(clumps[c + 1][0] == ["Rest"], {rrand(1.0, 3.0)}, {rrand(0.3, 0.5)}); - }); - rels = rels.add(rrand(1.0, 3.0)); - amps = freqs.collect({rrand(0.6, 0.99)}); - - [ - Pbind( - \instrument, \string_model, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \attack, Pseq(attacks, 1), - \sustain, Pseq(fDurs, 1), - \release, Pseq(rels, 1), - //\amp, Pseq(amps, 1), - \amp, Pbrown(0.5, 1, 0.5), - \busIndex, v - ), - Pbind( - \instrument, \sine, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \sustain, Pseq(fDurs, 1), - \busIndex, v - ) - ] - }).flatten; - if(oneShot.not, { - msg = inSeq.collect({arg mSeq, m; mSeq[1..]}); - //ids = inSeq.collect({arg mSeq, m; mSeq[2]}); - sectionDurs = seq.collect({arg mSeq; mSeq.flatten2(mSeq.maxDepth - 5).flop[1].sum}); - pbinds = pbinds ++ - [ - Pbind( - \type, \osc, - \addr, addr, - \path, "/playing", - \msg, Pseq(msg, 1), - \dur, Pseq(sectionDurs, 1) - ); - ] - }); - res = Ppar(pbinds); - res -}; - -/* -genMidiPatterns = {arg seq; - var voices, durs, patterns, res, mOut, pbRange; - pbRange = 1; //semitones - change this as needed for your situation - mOut = MIDIOut.newByName("TiMidity", "TiMidity port 0").latency_(Server.default.latency); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - res = Ppar( - voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs; - - mOut.program(v, 70); - - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - - Pbind( - \type, \midi, - \chan, v, - \noteval, Pseq(freqs.cpsmidi - 24, 1), - \note, Pfunc({ | event | event[\noteval].floor }), - \dur, Pseq(fDurs, 1), - \midiout, mOut, - \amp, 1, - \bend, Pfunc({ - | event | - if (event[\note].isRest.not) { - var pitchbendvalue = event[\noteval].frac.linlin(0, pbRange, 8192, 8192*2).asInteger; - m.bend(v, pitchbendvalue); - }; - 0; // return something other than nil to avoid stopping the pattern - }), - ); - }); - ); - res -}; -*/ - - -//------resource management funcs - -genUID = {Date.seed.asHexString.toLower}; - -seedFunc = {arg func, seed; - var funcArgs, next; - next = Routine({loop{func.valueArray(funcArgs).yield }}); - next.randSeed_(seed); - {arg ...args; funcArgs = args; next.value} -}; - -stringifyToDepth = {arg data, maxDepth = 1; - var prettyString = "", rCount = 0, writeArray, indent; - - if(maxDepth == 0, { - data.asCompileString - }, { - indent = {arg size; size.collect({" "}).join("")}; - writeArray = {arg array; - prettyString = prettyString ++ indent.value(rCount) ++ "[\n"; - rCount = rCount + 1; - if(rCount < maxDepth, { - array.do({arg subArray; writeArray.value(subArray)}); - }, { - prettyString = prettyString ++ array.collect({arg subArray; - indent.value(rCount + 1) ++ subArray.asCompileString - }).join(",\n"); - }); - rCount = rCount - 1; - prettyString = prettyString ++ "\n" ++ indent.value(rCount) ++ "],\n"; - }; - - writeArray.value(data); - prettyString.replace(",\n\n", "\n").drop(-2); - }) -}; - -sanityCheck = {arg motif, index; - //print functions = very helpful - ("----------" + index + "------------").postln; - - motif.flatten.do({arg val, v; - if(v > 0, { - if(motif.flatten[v-1][0].hammingDistance(val[0]) > 1, {"problem 1".postln}); - if(motif.flatten[v-1][0].hammingDistance(val[0]) == 0, {"problem 2".postln}); - }); - val.postln - }); - "***********".postln; -}; - -msgInterpret = {arg in, escapeDoubleQuotes = true, escapeSingleQuotes = true; - var res; - - res = in; - if(res.isNil.not, { - if((res.isArray && res.isString.not), { - res = res.asCompileString; - res = res.replace(" ", "").replace("\n", "").replace("\t", ""); - if(escapeSingleQuotes, {res = res.replace("\'", "")}); - if(escapeDoubleQuotes, {res = res.replace("\"", "")}); - res = res.replace("Rest", "\"Rest\""); - res = res.interpret; - }, { - var tmpRes; - if(res.every({arg char; char.isDecDigit}), {tmpRes = res.asInteger}); - if(res.contains("."), {tmpRes = res.asFloat}); - if(tmpRes != nil, {res = tmpRes}); - }); - }); - res -}; - -writeResources = {arg path, dict; - var file, modelItems, resString; - file = File(path,"w"); - - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - - resString = nameSpaces.collect({arg nameSpace; - var depth = 0, insert = " "; - if(nameSpace == "music_data", {depth = 3; insert = "\n"}); - if(nameSpace == "last_changes", {depth = 1; insert = "\n"}); - if(nameSpace == "order", {depth = 1; insert = "\n"}); - if((nameSpace == "ref_uid") && (dict[nameSpace] == nil), {dict[nameSpace] = "nil"}); - "\"" ++ nameSpace ++ "\":" ++ insert ++ stringifyToDepth.value(dict[nameSpace], depth) - }).join(",\n"); - - resString = "{\n" ++ resString ++ "\n}"; - - file.write(resString); - file.close; - resString -}; - -loadModelFile = {arg path; loadModelJSON.value(File(path, "r").readAllString.parseJSON)}; - -loadModelJSON = {arg jsonObject; - var dict; - dict = Dictionary.with(*nameSpaces.collect({arg nS; nS->msgInterpret.value(jsonObject[nS])})); - dict -}; - -setGlobalVars = {arg dict, skipLastXChanges = false; - var tmpLastXChanges; - tmpLastXChanges = lastXChanges.deepCopy; - // order really matters!!!! - # seq, lastXChanges, curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited = nameSpaces.collect({arg nS; dict[nS]}); - if(skipLastXChanges, {lastXChanges = tmpLastXChanges}); - dict -}; - -globalVarsToDict = { - var modelItems, dict; - // order really matters!!!! - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - dict = Dictionary.with(*nameSpaces.collect({arg nS, n; nS->modelItems[n]})); -}; - -loadLedgerFile = {arg path; - ledgerPath = path; - loadLedgerJSON.value(File(ledgerPath, "r").readAllString.parseJSON) -}; - -loadLedgerJSON = {arg jsonObject; ledger = jsonObject["ledger"]}; - -saveLedger = {arg ledger, path; - var file; - file = File(path, "w"); - file.write("{\n\"ledger\":\n" ++ stringifyToDepth.value(ledger, 1) ++ "\n}"); - file.close; -}; - -//------global vars - -primes = [[2, 1], [3, 2], [5, 4], [7, 4], [11, 8], [13, 8]]; -//ranges = [[-2400, 0], [-1200, 1200], [0, 2400], [0, 2400]]; -exPath = thisProcess.nowExecutingPath; -dir = exPath.dirname; -//popSize = 4; -dims = primes.size; -tuples = genTuples.value(); -//refUID = nil; -group = Group.new; -~group = group; -loadLedgerFile.value(dir +/+ ".." +/+ "resources" +/+ "piece_ledger.json"); -//passagesWeights = [1, 1, 1, 1, 1]; -//susWeights = [1, 1, 1]; -// order really matters!!!! -nameSpaces = [ - "music_data", "last_changes", "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", - "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", - "ranges", "step_probs_vals", "passages_weights", "hd_exp", "hd_invert", - "order", "sus_weights", "order_size", "passages_size", - "motif_edited", "order_edited" -]; - - -//------OSC funcs - -OSCdef(\load_ledger, {arg msg, time, addr, port; - loadLedgerFile.value(msg[1].asString); -}, \load_ledger); - -OSCdef(\load_model, {arg msg, time, addr, port; - var dict; - dict = loadModelFile.value(msg[1].asString); - setGlobalVars.value(dict); -}, \load_model); - -OSCdef(\save_ledger, {arg msg, time, addr, port; - msg.postln; - ledger = msgInterpret.value(msg[1].asString.parseJSON["ledger"], false).postln; - //loadLedgerJSON.value(msg[0]) - saveLedger.value(ledger, msg[2].asString); - //loadLedgerFile.value(msg[1].asString); -}, \save_ledger); - -OSCdef(\generate, {arg msg, time, addr, port; - var path, dict, durSeeds, musPath, modelString; - msg.postln; - - path = msg[1].asString; - - dict = loadModelFile.value(path); - setGlobalVars.value(dict, true); - - popSize = ranges.size; - - //refUID.postln; - - loadLedgerFile.value(ledgerPath); - if(ledger == nil, {ledger = ["tmp"]}); - if(ledger.last != "tmp", {ledger = ledger.add("tmp")}); - - if(refUID == nil, {lastXChanges = [initVoices.value().deepCopy]}); - if((refUID != nil) && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - lastXChanges = msgInterpret.value(file.readAllString.parseJSON["last_changes"]); - }); - - refUID.postln; - lastXChanges.collect({arg item; item.postln}); - - durSeeds = seedFunc.value({3.collect({rrand(100000, 999999)})}, durSeed).value.postln; - entrancesDurFunc = genDurFunc.valueArray(entrancesProbVals[..4] ++ [entrancesProbVals[5..]] ++ [durSeeds[0]]); - passagesDurFunc = genDurFunc.valueArray(passagesProbVals[..4] ++ [passagesProbVals[5..]] ++ [durSeeds[1]]); - exitsDurFunc = genDurFunc.valueArray(exitsProbVals[..4] ++ [exitsProbVals[5..]] ++ [durSeeds[2]]); - - if(orders == nil, { - orders = seedFunc.value(genOrders, orderSeed).valueArray(orderSize ++ passagesSize); - //addr.sendMsg("/order", stringifyToDepth.value(orders, 1)); - }); - - stepFunc = genStepFunc.valueArray(stepProbsVals[..1] ++ [stepProbsVals[2..]] ++ [motifSeed]); - seq = seedFunc.value(genMotif, motifSeed).value; - - lastXChanges.collect({arg item; item.postln}); - - dict = globalVarsToDict.value; - modelString = writeResources.value(path, dict); - - //addr.sendMsg("/generated", musPath, stringifyToDepth.value(seq, 3)); - //~seq = seq; - - addr.sendMsg("/generated", path, modelString, ledgerPath); -}, \generate); - - -OSCdef(\commit, {arg msg, time, addr, port; - var musicData, musicChanged, dict, newLedger, modelPath, musString, musFile, test1, test2, lastCurUID, commitType, commitPos, equalityLedger; - //msg.postln; - - /* - test1 = msg[1].asString.parseJSON; - test2 = (dir +/+ ".." +/+ "resources/tmp/tmp_music" ++ ".json").standardizePath.parseJSONFile; - msgInterpret.value(test1["music"])[0][0][0][1].class.postln; - msgInterpret.value(test2["music_data"])[0][0][0][1].class.postln; - (test1["music"] == test2["music_data"]).postln; - */ - - musicData = loadModelJSON.value(msg[1].asString.parseJSON)["music_data"].postln; - musicChanged = (musicData != seq).postln; - commitType = msg[2].asString; - commitPos = msg[3].postln.asInteger; - - lastCurUID = curUID.deepCopy; - curUID = genUID.value; - - File.mkdir((dir +/+ ".." +/+ "resources" +/+ curUID).standardizePath); - File.copy(exPath, (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_code" ++ ".scd").standardizePath); - - modelPath = (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_mus_model" ++ ".json").standardizePath; - dict = globalVarsToDict.value; - if(musicChanged, { - seq = musicData; - dict["music_data"] = seq; - dict["motif_edited"] = "true" - }); - dict["cur_uid"] = curUID; - - writeResources.value(modelPath, dict); - - File.delete(ledgerPath ++ "_bak"); - File.copy(ledgerPath, ledgerPath ++ "_bak"); - File.delete(ledgerPath); - - /* - if(commitType == "add", { - if(lastCurUID == "tmp", { - ledger = ledger.drop(-1).add(curUID); - }, { - ledger = ledger.add(curUID); - }) - }); - */ - - ledger.postln; - - if(commitType == "add", {ledger = ledger.add(curUID)}); - - if(commitType == "insert", {ledger = ledger.insert(commitPos + 1, curUID)}); - - if(commitType == "replace", {ledger = ledger.put(commitPos, curUID)}); - - equalityLedger = ledger.collect({arg item; item.asSymbol}); - if(equalityLedger.includes(\tmp).postln, {ledger.removeAt(equalityLedger.indexOf(\tmp).postln)}); - - ledger.postln; - - saveLedger.value(ledger, ledgerPath); - - addr.sendMsg("/committed", curUID, ledgerPath); - //refUID = curUID; - -}, \commit); - -OSCdef(\transport, {arg msg, time, addr, port; - msg.postln; - if(msg[1] == 0, { - group.set(\release, 2); - group.set(\gate, 0); - player.stop; - }, { - // the cued sequence can now be read from file, so this can be cleaned up - var cSize, patterns, pSeq, cuedSeek, indexStart, indexEnd, tmpLedger; - if(msg[1] == 1, { - pSeq = []; - cuedSeek = (seq != nil); - indexStart = msg[2].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.postln.parseJSON["music_data"]), path, indexStart + index, uid]); - file.close; - }); - }); - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - patterns = genPatterns.value(pSeq, addr); - }, { - pSeq = [loadModelJSON.value(msg[2].asString.parseJSON)["music_data"].postln]; - patterns = genPatterns.value(pSeq, addr, true); - }); - player = Pfset(pattern: patterns, cleanupFunc: { - addr.sendMsg("/transport", 0); - addr.sendMsg("/one_shot", 0); - }); - player = player.play - }); -}, \transport); - - -OSCdef(\transcribe_motif, {arg msg, time, addr, port; - var tSeq, refChord, refUID; - - msg.postln; - - tSeq = [loadModelJSON.value(msg[1].asString.parseJSON)["music_data"]]; - refUID = msg[2].asString.postln; - - if((refUID != "nil") && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }, { - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - }); - - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "lilypond" +/+ "includes").standardizePath, addr, "/transcribe_motif"); -}, \transcribe_motif); - - -OSCdef(\transcribe_all, {arg msg, time, addr, port; - var cSize, patterns, cuedSeek, indexStart, indexEnd, tmpLedger; - if(true, { - cuedSeek = (seq != nil); - indexStart = msg[1].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - - //tmp for testing transcription - indexEnd = (indexStart+5); - - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - var lilyPartLedgerFiles; - - lilyPartLedgerFiles = 4.collect({arg p; - File((dir +/+ ".." +/+ "lilypond" +/+ "includes" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly").standardizePath, "w"); - }); - - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file, fileString, tSeq, refUID, refChord; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - fileString = file.readAllString; - tSeq = msgInterpret.value(fileString.parseJSON["music_data"]); - refUID = msgInterpret.value(fileString.parseJSON["ref_uid"]); - file.close; - - //uid.postln; - //(refUID == "nil").postln; - - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - - if(refUID != "nil", { - path = (dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }); - - if(index != indexEnd, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath); - }, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath, addr, "/transcribe_all"); - }); - - lilyPartLedgerFiles.do({arg f, p; - f.write("\\include \".." +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly\"\n"); - }); - - }); - - lilyPartLedgerFiles.do({arg f; - f.close - }); - }); - /* - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - */ - }, { - - }); - -}, \transcribe_all); - -) - -~transcribe.value(~seq, dir); - -( -//synthdefs -~stringModelBusArray = 4.collect({Bus.audio(s, 1)}); -~sineBusArray = 4.collect({Bus.audio(s, 1)}); -~bassBusArray = 1.collect({Bus.audio(s, 1)}); -~hdustBusArray = 1.collect({Bus.audio(s, 1)}); -~samplerBusArray = 2.collect({Bus.audio(s, 1)}); -~sBuf = Buffer.alloc(s, 10, 2); -SynthDef(\string_model, {arg freq, gate = 1, sustain, amp, dur, attack, release = 1, busIndex = 0; - var trig, exc, sig1, sig2, noHarms; - noHarms = rrand(20, 40); - exc = Saw.ar(freq, TRand.ar(0.5, 1, Impulse.ar(freq))) * 0.001 + Dust.ar(10000, 0.01); - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.8).softclip; - //sig1 = HPF.ar(sig1, 300); - Out.ar(Select.kr(busIndex, ~stringModelBusArray), sig1 * amp * EnvGen.kr(Env.adsr(attack, 0.3, 0.9, release, 0.9, -3), gate, doneAction: 2)); - //Out.ar([0, 1], sig1 * EnvGen.kr(Env.asr(dur, 0.3, 1), gate, doneAction: 2)); -}).add; - -SynthDef(\sine, {arg freq, gate = 1, sustain, amp, dur, busIndex = 0; - var sig; - sig = SinOsc.ar(freq); - Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.asr(0.3, 0.4, 0.3), gate, timeScale: dur, doneAction: 2)); - //Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.sine(dur), gate, doneAction: 2)); -}).add; - -SynthDef(\mixer, {arg freq, gate = 1, sustain, amp, dur, out; - var nameSpaces, sigs; - - sigs = [~stringModelBusArray, ~sineBusArray/*, ~bassBusArray, ~hdustBusArray, ~samplerBusArray*/].collect({arg busArray, i; - var nameSpace, sig; - nameSpace = ['string', 'sine', 'bass', 'hdust', 'sampler'][i]; - sig = busArray.collect({arg bus, c; In.ar(bus, 1) * NamedControl.kr(\ ++ nameSpace ++ '_volume_' ++ c, 1, 0.1)}); - sig = sig.collect({arg channel, c; Pan2.ar(channel, NamedControl.kr(\ ++ nameSpace ++ '_pan_' ++ c, i / (busArray.size - 1), 0.1) * 2 - 1)}); - sig = sig.collect({arg channel, c; channel * NamedControl.kr(\ ++ nameSpace ++ '_mute_' ++ c, 1, 0.1)}); - sig = Mix.ar(sig) * pow(NamedControl.kr(\ ++ nameSpace ++ '_volume_master', 1, 0.1), 2); - }); - - sigs = Mix.ar(sigs / 4); - Out.ar(0, sigs) -}).add; - -SynthDef(\bass, { - var switches, drone; - switches = {|i| Dust.kr(0.1)} ! 9; - drone = {|i| var harm = pow(2, 2 - (i / 3).trunc), amp = (1 / pow(harm, 2)); - SinOsc.ar(60 * harm + TRand.kr(-3, 3, switches[i]), 0, amp)} ! 9; - Out.ar(~bassBusArray[0], Mix.new(drone) * 0.2); -}).add; - -SynthDef(\sampler, { - Out.ar(~samplerBusArray, PlayBuf.ar(2, ~sBuf, BufRateScale.kr(~sBuf), doneAction: 2)) -}).add; - -// main routine -SynthDef(\hdust, { - arg gate = 0; - var hierarchical_dust, low_sine, high_sine, brown_noise, white_noise; - // this triggers the combinations of sources - // it is similar to the Supercollider UGen called dust but with a hierarchical structure - hierarchical_dust = ( - TIRand.kr(0, 1, Impulse.kr(100)) * - TIRand.kr(0, 1, Impulse.kr(10)) * - TIRand.kr(0, 1, Impulse.kr(1)) * - TIRand.kr(0, 1, Impulse.kr(0.1)) - ); - // adjust the multiplier at the end of each line for adjusting levels - // note with each trigger, each source has a 1 in 3 chance of sounding - low_sine = SinOsc.ar(76.midicps / 16) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.1; - high_sine = SinOsc.ar(76.midicps * 8) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.01; - brown_noise = BrownNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.025; - white_noise = WhiteNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.02; - Out.ar(~hdustBusArray[0], - ((low_sine + high_sine + brown_noise + white_noise) ) - ); -}).add; - -) - -( -var bass, hdust, sampler, mixer; -/* -bass = Synth.tail(~group, \bass); -hdust = Synth.tail(~group, \hdust); -sampler = Synth.head(~group, \sampler); -*/ -mixer = Synth.tail(~group, \mixer); - -OSCdef(\mixer, {arg msg, time, addr, port; - mixer.set((msg[1] ++ '_' ++ msg[2] ++ '_' ++ msg[3]), msg[4]) -}, \mixer); - -/* -OSCdef(\sampler, {arg msg, time, addr, port; - msg.postln; - sampler.free; - ~sBuf.free; - ~sBuf = Buffer.read(s, msg[1].asString.postln, action: {sampler = Synth.head(~group, \sampler)}); -}, \sampler); -*/ -) - -/* old something -( -SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; - var trig, exc, sig1, sig2, noHarms, freqFinal, start, end; - noHarms = 30; - freq = WhiteNoise.ar * 3 + freq; - freqFinal = Duty.ar((1/freq), 0, freq); - trig = Changed.ar(freqFinal); - start = Demand.ar(trig, 0, Dwhite(-1, -0.75)); - end = Demand.ar(trig, 0, Dwhite(0.75, 1)); - exc = Phasor.ar(trig, (end - start) * freqFinal / SampleRate.ir, start, end, 0) * 0.001 + Dust.ar(10000, 0.01); - - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(2, 3)}) ], exc) * 0.5).softclip; - sig1 = HPF.ar(sig1, 300); - Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); -}).add; -) -*/ - diff --git a/resources/652c77ba/652c77ba_code.scd b/resources/652c77ba/652c77ba_code.scd deleted file mode 100644 index 3eb3cbd..0000000 --- a/resources/652c77ba/652c77ba_code.scd +++ /dev/null @@ -1,1058 +0,0 @@ -( -// helper funcs -var hsArrayToCents, pDist, hdSum, hsChordalDistance, hsArrayToFreq; - -// score funcs -var isInRange, spacingScore, rangeScore, intervalScore, inclusionScore; - -// subroutines -var genTuples, initVoices, genOrders, genSubMotif, updateVoices, genDurFunc, genStepFunc; - -// primary routines -var genMotif, genSecondarySeq; - -// audition funcs -var genPatterns, genMidiPatterns; - -// resource management funcs -var seedFunc, genUID, writeResources, stringifyToDepth, setSeeds, sanityCheck, -msgInterpret, loadLedgerFile, loadLedgerJSON, loadModelFile, loadModelJSON, -setGlobalVars, globalVarsToDict, saveLedger; - -// model vars -//(model and global vars mostly set by OSC funcs -var seq, lastXChanges, -curUID, refUID, orderSeed, durSeed, motifSeed, -entrancesProbVals, passagesProbVals, exitsProbVals, -ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, -orders, susWeights, orderSize, passagesSize, -motifEdited, orderEdited; - -// model aux vars -var entrancesDurFunc, passagesDurFunc, exitsDurFunc, stepFunc; - -// other global vars -var popSize, exPath, dir, primes, dims, tuples, -group, player, ledgerPath, ledger, currentlyPlayingUID, -nameSpaces; - -// install JSON quark -if(Quarks.isInstalled("JSONlib").not, { - Quarks.install("https://github.com/musikinformatik/JSONlib.git"); - thisProcess.recompile; - //HelpBrowser.openHelpFor("Classes/JSONlib"); -}); - - -//------helper funcs - -hsArrayToCents = { - arg hsArray; - hsArray.collect({arg dist, p; dist * 1200 * log2(primes[p][0]/primes[p][1])}).sum -}; - -pDist = { - arg array1, array2, signed = false; - var pDistance; - pDistance = hsArrayToCents.value(array1) - hsArrayToCents.value(array2); - if(signed, {pDistance}, {abs(pDistance)}) -}; - -hdSum = { - arg hsArrays; - var size, distances, mean; - size = hsArrays.size; - distances = (size - 1).collect({arg i; - ((i + 1)..(size - 1)).collect({arg j; - abs(hsArrays[i] - hsArrays[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsChordalDistance = { - arg hsArrays1, hsArrays2; - var size, distances, mean; - size = hsArrays1.size; - distances = hsArrays1.size.collect({arg i; - hsArrays2.size.collect({arg j; - abs(hsArrays1[i] - hsArrays2[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsArrayToFreq = { - arg array; - array.collect({arg dim, d; pow(primes[d][0]/primes[d][1], dim)}).product -}; - -//------score funcs - -/* -isInRange = { - arg hsArray, min, max; - var cents; - cents = hsArrayToCents.value(hsArray); - (cents >= min) && (cents <= max) -}; -*/ - -spacingScore = { - arg hsArrays, min; - var centsArray; - centsArray = hsArrays.collect({arg hsArray; hsArrayToCents.value(hsArray)}).sort({arg a, b; a < b}); - centsArray.differentiate.drop(1).collect({arg pDistance; if(pDistance >= min, {1}, {0.01})}).sum; -}; - -rangeScore = { - arg hsArray1, hsArray2, min, max, low, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - if((pDistance >= min) && (pDistance <= max), {1}, {low}); -}; - -intervalScore = { - arg hsArray1, hsArray2, mean, sd, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - //pDistance.gaussCurve(1, mean, sd) - stepFunc.value(pDistance); -}; - -inclusionScore = { - arg array, test, min = 0.01; - if(array.collect({arg v; v.hash}).includes(test.hash), {min}, {1}); -}; - - -//------subroutines - -genTuples = { - var tuples; - tuples = dims.collect({[-1, 0, 1]}).allTuples.select({arg tuple; (abs(tuple.drop(1)).sum <= 1) && (tuple[0] == 0)}); - tuples = tuples ++ tuples.collect({arg tuple; [-3, -2, -1, 1, 2, 3].collect({arg octTrans; tuple.deepCopy.put(0, octTrans)})}).flatten; -}; - -initVoices = { - var init, voicesInit; - voicesInit = popSize.collect({dims.collect({0})}); - /* - voicesInit = [dims.collect({0})]; - (popSize - 1).do({ - arg rep, new; - rep = dims.rand; - new = voicesInit.last.deepCopy; - new[rep] = new[rep] + [-1, 1].choose(); - voicesInit = voicesInit.add(new); - }); - */ - voicesInit.deepCopy; -}; - -genDurFunc = {arg chordProb, minPad, maxPad, minDur, maxDur, envData, seed; - var env, pTable, durFunc; - env = Env.pairs([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).asSignal(256).asList.asArray; - pTable = env.asRandomTable; - [chordProb, minPad, maxPad, minDur, maxDur, envData].postln; - durFunc = {arg allowChord, pad = false; - var res; - res = if(allowChord.not, { - pTable.tableRand * (maxDur - minDur) + minDur - }, { - if(1.0.rand < chordProb, {0}, {pTable.tableRand * (maxDur - minDur) + minDur}); - }).round(0.125); - if(pad, {res = res + rrand(minPad.asFloat, maxPad.asFloat).round(0.125)}); - if(res.asInteger == res, {res = res.asInteger}); - res - }; - seedFunc.value(durFunc, seed); -}; - -genStepFunc = {arg minStep, maxStep, envData, seed; - var envDataNorm, env, pTable, stepFunc; - [minStep, maxStep, envData].postln; - envDataNorm = ([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).flop; - envDataNorm = [envDataNorm[0].normalize(minStep, maxStep), envDataNorm[1]].flop; - env = Env.pairs(envDataNorm); - stepFunc = {arg pDist; - env.at(pDist).clip(0.001, 1); - }; - seedFunc.value(stepFunc, seed); -}; - -genOrders = {arg minMotifLength = 1, maxMotifLength = 5, minProgLength = 0, maxProgLength = 5; - ((maxMotifLength - minMotifLength).rand + minMotifLength).collect({ - var noProgIns, noSusIns, noSilentIns, prog, sus, silent, order; - noSusIns = [1, 2, 3].wchoose(susWeights.normalizeSum); - noProgIns = (popSize - noSusIns).rand + 1; - noSilentIns = popSize - noSusIns - noProgIns; - - # prog, sus, silent = (0..(popSize-1)).scramble.clumps([noProgIns, noSusIns, noSilentIns]); - - prog = (prog.scramble ++ ((maxProgLength - minProgLength).rand + minProgLength).collect({prog.choose}).scramble); - if(silent == nil, {silent = []}); - [sus.scramble, prog, silent.scramble] - }); -}; - -updateVoices = {arg ins, sus; - var voices, candidates, nWeights, nProbs, sel; - - voices = lastXChanges.deepCopy.last; - - candidates = sus.collect({arg v; tuples.collect({arg t; voices[v] + t})}).flatten; - candidates = difference(candidates.asSet, voices.asSet).asList; - nProbs = candidates.collect({arg candidate; - var stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore; - - //stepScore = intervalScore.value(voices[ins], candidate, 30, 400, 0.1); - stepScore = intervalScore.value(voices[ins], candidate, 100, 100); - recentlySoundedScore = inclusionScore.value(lastXChanges.flop[ins], candidate, 0); - isInRangeScore = rangeScore.value(candidate, candidate.collect({0}), ranges[ins][0], ranges[ins][1], 0, true); - regScore = spacingScore.value(voices.deepCopy.put(ins, candidate), 300); - hdScore = pow(hdSum.value(voices.deepCopy.put(ins, candidate)), hdExp); - if(hdInvert == 0, {hdScore = 1/hdScore}); - //maybe what you want here is a vector to another root and then favoring movement towards it. - //distScore = pow(hsChordalDistance.value(voices, voices.put(ins, candidate)), 2); - - [stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore] - }); - - nWeights = passagesWeights; - - //this handles nWeights of 0; mainly for testing - nProbs = nProbs.flop.select({arg scores, s; nWeights[s] != 0}).flop; - nWeights = nWeights.select({arg weight; weight != 0}); - nProbs = nProbs.flop.collect({arg scores, s; - if(scores.sum == 0, {scores}, {scores.normalizeSum * nWeights[s]}) - }); - nProbs = nProbs.flop.collect({arg scores, s; scores.product}).normalizeSum; - - sel = candidates.wchoose(nProbs); - - voices[ins] = sel; - lastXChanges = lastXChanges.add(voices).keep(-5); -}; - -genSubMotif = {arg order, orderIndex, lastState, repeatLast = false, startFromLast = false, isLastOrder = false; - var sus, prog, silent, flatOrder, res, isInChord, allowChord, pad, lastXChangesHold, voices, adder; - # sus, prog, silent = order; - flatOrder = silent ++ sus ++ prog; - lastXChangesHold = lastXChanges.deepCopy; - voices = lastState.deepCopy; - isInChord = popSize.collect({false}); - allowChord = false; - pad = false; - res = []; - "------generating motif".postln; - //need to figure out here if voices move between motifs - flatOrder.do({arg ins, i; - - if(prog.includes(ins) && repeatLast.not, {updateVoices.value(ins, sus)}); - adder = if(silent.includes(ins), {["Rest"]}, {lastXChanges.last.deepCopy[ins]}); - - if(voices[ins] != adder, { - var dur; - - if((sus ++ silent).includes(ins), { - allowChord = (ins != sus.last); - pad = (ins == sus.last); - }, { - if(i < (flatOrder.size - 1), { - allowChord = (isInChord[flatOrder[i + 1]] || (ins == flatOrder[i + 1])).not; - pad = false; - }, { - allowChord = false; - pad = true - }); - }); - if((orderIndex == 0) && sus.includes(ins), { - dur = entrancesDurFunc.value(allowChord, pad); - }, { - dur = passagesDurFunc.value(allowChord, pad); - }); - if(dur == 0, {isInChord[ins] = true}, {isInChord = popSize.collect({false})}); - - voices[ins] = adder; - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - - // pad ending - if(orderIndex == (orders.size - 1), { - (0..(popSize-1)).scramble.do({arg ins; - if(res.last.first[ins] != ["Rest"], { - var dur; - voices[ins] = ["Rest"]; - allowChord = (voices != popSize.collect({["Rest"]})); - pad = allowChord.not; - dur = exitsDurFunc.value(allowChord, pad); - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - }); - - //format and return - if(startFromLast, {lastXChanges = lastXChangesHold.deepCopy}); - res; -}; - - -//------primary routines - -genMotif = { - var repeats, fSeq, fDur, durAdd; - - repeats = 1; - fSeq = []; - - repeats.do({arg index; - var motif; - - motif = []; - - orders.do({arg order, o; - var lastState, subMotif; - lastState = if(o == 0, {popSize.collect({["Rest"]})}, {motif.last.last.first}); - subMotif = genSubMotif.value(order, o, lastState, isLastOrder: o == (orders.size - 1)); - motif = motif.add(subMotif); - - }); - - sanityCheck.value(motif, index); - - fSeq = fSeq.add(motif); - }); - - //round last duration to measure - fDur = fSeq.flatten.flatten.slice(nil, 1).sum; - durAdd = fDur.round(4) - fDur; - if(durAdd < 0, {durAdd = 4 - durAdd}); - fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] = fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] + durAdd; - - fSeq -}; - -genSecondarySeq = {arg seq; - var curdles, fSeq; - curdles = []; - while({curdles.sum < seq.size}, {curdles = curdles ++ [3.rand + 1]}); - - fSeq = seq.clumps(curdles).collect({arg clump, m; - var repeats, paddedSeq; - - //add rest - paddedSeq = clump.add([[[popSize.collect({["Rest"]}), 0.5.rand]]]); - - //implement repeats - repeats = [0.rand + 1, 1].wchoose([1, 0].normalizeSum); - repeats.collect({paddedSeq}); - }); - fSeq -}; - - -//------audition funcs - -/* -Event.addEventType(\osc, { - if (~addr.postln.notNil) { - ~addr.sendMsg(~indexPath, ~indexMsg); - ~addr.sendMsg(~seqPath, stringifyToDepth.value(~seqMsg, 3)); - //~addr.sendMsg("/STATE/OPEN", (dir.replace("supercollider", "resources") +/+ ~idMsg +/+ ~idMsg ++ "_gui_state" ++ ".state").standardizePath.postln); - }; -}); -*/ - -Event.addEventType(\osc, { - if (~addr.notNil) { - ~msg; - ~addr.sendMsg(~path, *~msg); - }; -}); - -genPatterns = {arg inSeq, addr, oneShot = false; - var voices, durs, pbinds, res, indices, sectionDurs, msg, ids, seq; - seq = inSeq.collect({arg mSeq; mSeq[0]}); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - pbinds = voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs, attacks, rels, amps; - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - //attacks = 2.collect({rrand(1, 3)}) ++ freqs.drop(2).collect({rrand(0.3, 0.5)}); - attacks = fDurs.collect({arg dur; dur * rrand(0.2, 0.4)}); - //rels = freqs.drop(2).collect({rrand(0.3, 0.5)}) ++ 2.collect({rrand(1, 3)}); - rels = (clumps.size - 1).collect({arg c; - if(clumps[c + 1][0] == ["Rest"], {rrand(1.0, 3.0)}, {rrand(0.3, 0.5)}); - }); - rels = rels.add(rrand(1.0, 3.0)); - amps = freqs.collect({rrand(0.6, 0.99)}); - - [ - Pbind( - \instrument, \string_model, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \attack, Pseq(attacks, 1), - \sustain, Pseq(fDurs, 1), - \release, Pseq(rels, 1), - //\amp, Pseq(amps, 1), - \amp, Pbrown(0.5, 1, 0.5), - \busIndex, v - ), - Pbind( - \instrument, \sine, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \sustain, Pseq(fDurs, 1), - \busIndex, v - ) - ] - }).flatten; - if(oneShot.not, { - msg = inSeq.collect({arg mSeq, m; mSeq[1..]}); - //ids = inSeq.collect({arg mSeq, m; mSeq[2]}); - sectionDurs = seq.collect({arg mSeq; mSeq.flatten2(mSeq.maxDepth - 5).flop[1].sum}); - pbinds = pbinds ++ - [ - Pbind( - \type, \osc, - \addr, addr, - \path, "/playing", - \msg, Pseq(msg, 1), - \dur, Pseq(sectionDurs, 1) - ); - ] - }); - res = Ppar(pbinds); - res -}; - -/* -genMidiPatterns = {arg seq; - var voices, durs, patterns, res, mOut, pbRange; - pbRange = 1; //semitones - change this as needed for your situation - mOut = MIDIOut.newByName("TiMidity", "TiMidity port 0").latency_(Server.default.latency); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - res = Ppar( - voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs; - - mOut.program(v, 70); - - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - - Pbind( - \type, \midi, - \chan, v, - \noteval, Pseq(freqs.cpsmidi - 24, 1), - \note, Pfunc({ | event | event[\noteval].floor }), - \dur, Pseq(fDurs, 1), - \midiout, mOut, - \amp, 1, - \bend, Pfunc({ - | event | - if (event[\note].isRest.not) { - var pitchbendvalue = event[\noteval].frac.linlin(0, pbRange, 8192, 8192*2).asInteger; - m.bend(v, pitchbendvalue); - }; - 0; // return something other than nil to avoid stopping the pattern - }), - ); - }); - ); - res -}; -*/ - - -//------resource management funcs - -genUID = {Date.seed.asHexString.toLower}; - -seedFunc = {arg func, seed; - var funcArgs, next; - next = Routine({loop{func.valueArray(funcArgs).yield }}); - next.randSeed_(seed); - {arg ...args; funcArgs = args; next.value} -}; - -stringifyToDepth = {arg data, maxDepth = 1; - var prettyString = "", rCount = 0, writeArray, indent; - - if(maxDepth == 0, { - data.asCompileString - }, { - indent = {arg size; size.collect({" "}).join("")}; - writeArray = {arg array; - prettyString = prettyString ++ indent.value(rCount) ++ "[\n"; - rCount = rCount + 1; - if(rCount < maxDepth, { - array.do({arg subArray; writeArray.value(subArray)}); - }, { - prettyString = prettyString ++ array.collect({arg subArray; - indent.value(rCount + 1) ++ subArray.asCompileString - }).join(",\n"); - }); - rCount = rCount - 1; - prettyString = prettyString ++ "\n" ++ indent.value(rCount) ++ "],\n"; - }; - - writeArray.value(data); - prettyString.replace(",\n\n", "\n").drop(-2); - }) -}; - -sanityCheck = {arg motif, index; - //print functions = very helpful - ("----------" + index + "------------").postln; - - motif.flatten.do({arg val, v; - if(v > 0, { - if(motif.flatten[v-1][0].hammingDistance(val[0]) > 1, {"problem 1".postln}); - if(motif.flatten[v-1][0].hammingDistance(val[0]) == 0, {"problem 2".postln}); - }); - val.postln - }); - "***********".postln; -}; - -msgInterpret = {arg in, escapeDoubleQuotes = true, escapeSingleQuotes = true; - var res; - - res = in; - if(res.isNil.not, { - if((res.isArray && res.isString.not), { - res = res.asCompileString; - res = res.replace(" ", "").replace("\n", "").replace("\t", ""); - if(escapeSingleQuotes, {res = res.replace("\'", "")}); - if(escapeDoubleQuotes, {res = res.replace("\"", "")}); - res = res.replace("Rest", "\"Rest\""); - res = res.interpret; - }, { - var tmpRes; - if(res.every({arg char; char.isDecDigit}), {tmpRes = res.asInteger}); - if(res.contains("."), {tmpRes = res.asFloat}); - if(tmpRes != nil, {res = tmpRes}); - }); - }); - res -}; - -writeResources = {arg path, dict; - var file, modelItems, resString; - file = File(path,"w"); - - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - - resString = nameSpaces.collect({arg nameSpace; - var depth = 0, insert = " "; - if(nameSpace == "music_data", {depth = 3; insert = "\n"}); - if(nameSpace == "last_changes", {depth = 1; insert = "\n"}); - if(nameSpace == "order", {depth = 1; insert = "\n"}); - if((nameSpace == "ref_uid") && (dict[nameSpace] == nil), {dict[nameSpace] = "nil"}); - "\"" ++ nameSpace ++ "\":" ++ insert ++ stringifyToDepth.value(dict[nameSpace], depth) - }).join(",\n"); - - resString = "{\n" ++ resString ++ "\n}"; - - file.write(resString); - file.close; - resString -}; - -loadModelFile = {arg path; loadModelJSON.value(File(path, "r").readAllString.parseJSON)}; - -loadModelJSON = {arg jsonObject; - var dict; - dict = Dictionary.with(*nameSpaces.collect({arg nS; nS->msgInterpret.value(jsonObject[nS])})); - dict -}; - -setGlobalVars = {arg dict, skipLastXChanges = false; - var tmpLastXChanges; - tmpLastXChanges = lastXChanges.deepCopy; - // order really matters!!!! - # seq, lastXChanges, curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited = nameSpaces.collect({arg nS; dict[nS]}); - if(skipLastXChanges, {lastXChanges = tmpLastXChanges}); - dict -}; - -globalVarsToDict = { - var modelItems, dict; - // order really matters!!!! - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - dict = Dictionary.with(*nameSpaces.collect({arg nS, n; nS->modelItems[n]})); -}; - -loadLedgerFile = {arg path; - ledgerPath = path; - loadLedgerJSON.value(File(ledgerPath, "r").readAllString.parseJSON) -}; - -loadLedgerJSON = {arg jsonObject; ledger = jsonObject["ledger"]}; - -saveLedger = {arg ledger, path; - var file; - file = File(path, "w"); - file.write("{\n\"ledger\":\n" ++ stringifyToDepth.value(ledger, 1) ++ "\n}"); - file.close; -}; - -//------global vars - -primes = [[2, 1], [3, 2], [5, 4], [7, 4], [11, 8], [13, 8]]; -//ranges = [[-2400, 0], [-1200, 1200], [0, 2400], [0, 2400]]; -exPath = thisProcess.nowExecutingPath; -dir = exPath.dirname; -//popSize = 4; -dims = primes.size; -tuples = genTuples.value(); -//refUID = nil; -group = Group.new; -~group = group; -loadLedgerFile.value(dir +/+ ".." +/+ "resources" +/+ "piece_ledger.json"); -//passagesWeights = [1, 1, 1, 1, 1]; -//susWeights = [1, 1, 1]; -// order really matters!!!! -nameSpaces = [ - "music_data", "last_changes", "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", - "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", - "ranges", "step_probs_vals", "passages_weights", "hd_exp", "hd_invert", - "order", "sus_weights", "order_size", "passages_size", - "motif_edited", "order_edited" -]; - - -//------OSC funcs - -OSCdef(\load_ledger, {arg msg, time, addr, port; - loadLedgerFile.value(msg[1].asString); -}, \load_ledger); - -OSCdef(\load_model, {arg msg, time, addr, port; - var dict; - dict = loadModelFile.value(msg[1].asString); - setGlobalVars.value(dict); -}, \load_model); - -OSCdef(\save_ledger, {arg msg, time, addr, port; - msg.postln; - ledger = msgInterpret.value(msg[1].asString.parseJSON["ledger"], false).postln; - //loadLedgerJSON.value(msg[0]) - saveLedger.value(ledger, msg[2].asString); - //loadLedgerFile.value(msg[1].asString); -}, \save_ledger); - -OSCdef(\generate, {arg msg, time, addr, port; - var path, dict, durSeeds, musPath, modelString; - msg.postln; - - path = msg[1].asString; - - dict = loadModelFile.value(path); - setGlobalVars.value(dict, true); - - popSize = ranges.size; - - //refUID.postln; - - loadLedgerFile.value(ledgerPath); - if(ledger == nil, {ledger = ["tmp"]}); - if(ledger.last != "tmp", {ledger = ledger.add("tmp")}); - - if(refUID == nil, {lastXChanges = [initVoices.value().deepCopy]}); - if((refUID != nil) && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - lastXChanges = msgInterpret.value(file.readAllString.parseJSON["last_changes"]); - }); - - refUID.postln; - lastXChanges.collect({arg item; item.postln}); - - durSeeds = seedFunc.value({3.collect({rrand(100000, 999999)})}, durSeed).value.postln; - entrancesDurFunc = genDurFunc.valueArray(entrancesProbVals[..4] ++ [entrancesProbVals[5..]] ++ [durSeeds[0]]); - passagesDurFunc = genDurFunc.valueArray(passagesProbVals[..4] ++ [passagesProbVals[5..]] ++ [durSeeds[1]]); - exitsDurFunc = genDurFunc.valueArray(exitsProbVals[..4] ++ [exitsProbVals[5..]] ++ [durSeeds[2]]); - - if(orders == nil, { - orders = seedFunc.value(genOrders, orderSeed).valueArray(orderSize ++ passagesSize); - //addr.sendMsg("/order", stringifyToDepth.value(orders, 1)); - }); - - stepFunc = genStepFunc.valueArray(stepProbsVals[..1] ++ [stepProbsVals[2..]] ++ [motifSeed]); - seq = seedFunc.value(genMotif, motifSeed).value; - - lastXChanges.collect({arg item; item.postln}); - - dict = globalVarsToDict.value; - modelString = writeResources.value(path, dict); - - //addr.sendMsg("/generated", musPath, stringifyToDepth.value(seq, 3)); - //~seq = seq; - - addr.sendMsg("/generated", path, modelString, ledgerPath); -}, \generate); - - -OSCdef(\commit, {arg msg, time, addr, port; - var musicData, musicChanged, dict, newLedger, modelPath, musString, musFile, test1, test2, lastCurUID, commitType, commitPos, equalityLedger; - //msg.postln; - - /* - test1 = msg[1].asString.parseJSON; - test2 = (dir +/+ ".." +/+ "resources/tmp/tmp_music" ++ ".json").standardizePath.parseJSONFile; - msgInterpret.value(test1["music"])[0][0][0][1].class.postln; - msgInterpret.value(test2["music_data"])[0][0][0][1].class.postln; - (test1["music"] == test2["music_data"]).postln; - */ - - musicData = loadModelJSON.value(msg[1].asString.parseJSON)["music_data"].postln; - musicChanged = (musicData != seq).postln; - commitType = msg[2].asString; - commitPos = msg[3].postln.asInteger; - - lastCurUID = curUID.deepCopy; - curUID = genUID.value; - - File.mkdir((dir +/+ ".." +/+ "resources" +/+ curUID).standardizePath); - File.copy(exPath, (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_code" ++ ".scd").standardizePath); - - modelPath = (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_mus_model" ++ ".json").standardizePath; - dict = globalVarsToDict.value; - if(musicChanged, { - seq = musicData; - dict["music_data"] = seq; - dict["motif_edited"] = "true" - }); - dict["cur_uid"] = curUID; - - writeResources.value(modelPath, dict); - - File.delete(ledgerPath ++ "_bak"); - File.copy(ledgerPath, ledgerPath ++ "_bak"); - File.delete(ledgerPath); - - /* - if(commitType == "add", { - if(lastCurUID == "tmp", { - ledger = ledger.drop(-1).add(curUID); - }, { - ledger = ledger.add(curUID); - }) - }); - */ - - ledger.postln; - - if(commitType == "add", {ledger = ledger.add(curUID)}); - - if(commitType == "insert", {ledger = ledger.insert(commitPos + 1, curUID)}); - - if(commitType == "replace", {ledger = ledger.put(commitPos, curUID)}); - - equalityLedger = ledger.collect({arg item; item.asSymbol}); - if(equalityLedger.includes(\tmp).postln, {ledger.removeAt(equalityLedger.indexOf(\tmp).postln)}); - - ledger.postln; - - saveLedger.value(ledger, ledgerPath); - - addr.sendMsg("/committed", curUID, ledgerPath); - //refUID = curUID; - -}, \commit); - -OSCdef(\transport, {arg msg, time, addr, port; - msg.postln; - if(msg[1] == 0, { - group.set(\release, 2); - group.set(\gate, 0); - player.stop; - }, { - // the cued sequence can now be read from file, so this can be cleaned up - var cSize, patterns, pSeq, cuedSeek, indexStart, indexEnd, tmpLedger; - if(msg[1] == 1, { - pSeq = []; - cuedSeek = (seq != nil); - indexStart = msg[2].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.postln.parseJSON["music_data"]), path, indexStart + index, uid]); - file.close; - }); - }); - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - patterns = genPatterns.value(pSeq, addr); - }, { - pSeq = [loadModelJSON.value(msg[2].asString.parseJSON)["music_data"].postln]; - patterns = genPatterns.value(pSeq, addr, true); - }); - player = Pfset(pattern: patterns, cleanupFunc: { - addr.sendMsg("/transport", 0); - addr.sendMsg("/one_shot", 0); - }); - player = player.play - }); -}, \transport); - - -OSCdef(\transcribe_motif, {arg msg, time, addr, port; - var tSeq, refChord, refUID; - - msg.postln; - - tSeq = [loadModelJSON.value(msg[1].asString.parseJSON)["music_data"]]; - refUID = msg[2].asString.postln; - - if((refUID != "nil") && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }, { - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - }); - - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "lilypond" +/+ "includes").standardizePath, addr, "/transcribe_motif"); -}, \transcribe_motif); - - -OSCdef(\transcribe_all, {arg msg, time, addr, port; - var cSize, patterns, cuedSeek, indexStart, indexEnd, tmpLedger; - if(true, { - cuedSeek = (seq != nil); - indexStart = msg[1].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - - //tmp for testing transcription - indexEnd = (indexStart+5); - - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - var lilyPartLedgerFiles; - - lilyPartLedgerFiles = 4.collect({arg p; - File((dir +/+ ".." +/+ "lilypond" +/+ "includes" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly").standardizePath, "w"); - }); - - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file, fileString, tSeq, refUID, refChord; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - fileString = file.readAllString; - tSeq = msgInterpret.value(fileString.parseJSON["music_data"]); - refUID = msgInterpret.value(fileString.parseJSON["ref_uid"]); - file.close; - - //uid.postln; - //(refUID == "nil").postln; - - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - - if(refUID != "nil", { - path = (dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }); - - if(index != indexEnd, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath); - }, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath, addr, "/transcribe_all"); - }); - - lilyPartLedgerFiles.do({arg f, p; - f.write("\\include \".." +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly\"\n"); - }); - - }); - - lilyPartLedgerFiles.do({arg f; - f.close - }); - }); - /* - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - */ - }, { - - }); - -}, \transcribe_all); - -) - -~transcribe.value(~seq, dir); - -( -//synthdefs -~stringModelBusArray = 4.collect({Bus.audio(s, 1)}); -~sineBusArray = 4.collect({Bus.audio(s, 1)}); -~bassBusArray = 1.collect({Bus.audio(s, 1)}); -~hdustBusArray = 1.collect({Bus.audio(s, 1)}); -~samplerBusArray = 2.collect({Bus.audio(s, 1)}); -~sBuf = Buffer.alloc(s, 10, 2); -SynthDef(\string_model, {arg freq, gate = 1, sustain, amp, dur, attack, release = 1, busIndex = 0; - var trig, exc, sig1, sig2, noHarms; - noHarms = rrand(20, 40); - exc = Saw.ar(freq, TRand.ar(0.5, 1, Impulse.ar(freq))) * 0.001 + Dust.ar(10000, 0.01); - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.8).softclip; - //sig1 = HPF.ar(sig1, 300); - Out.ar(Select.kr(busIndex, ~stringModelBusArray), sig1 * amp * EnvGen.kr(Env.adsr(attack, 0.3, 0.9, release, 0.9, -3), gate, doneAction: 2)); - //Out.ar([0, 1], sig1 * EnvGen.kr(Env.asr(dur, 0.3, 1), gate, doneAction: 2)); -}).add; - -SynthDef(\sine, {arg freq, gate = 1, sustain, amp, dur, busIndex = 0; - var sig; - sig = SinOsc.ar(freq); - Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.asr(0.3, 0.4, 0.3), gate, timeScale: dur, doneAction: 2)); - //Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.sine(dur), gate, doneAction: 2)); -}).add; - -SynthDef(\mixer, {arg freq, gate = 1, sustain, amp, dur, out; - var nameSpaces, sigs; - - sigs = [~stringModelBusArray, ~sineBusArray/*, ~bassBusArray, ~hdustBusArray, ~samplerBusArray*/].collect({arg busArray, i; - var nameSpace, sig; - nameSpace = ['string', 'sine', 'bass', 'hdust', 'sampler'][i]; - sig = busArray.collect({arg bus, c; In.ar(bus, 1) * NamedControl.kr(\ ++ nameSpace ++ '_volume_' ++ c, 1, 0.1)}); - sig = sig.collect({arg channel, c; Pan2.ar(channel, NamedControl.kr(\ ++ nameSpace ++ '_pan_' ++ c, i / (busArray.size - 1), 0.1) * 2 - 1)}); - sig = sig.collect({arg channel, c; channel * NamedControl.kr(\ ++ nameSpace ++ '_mute_' ++ c, 1, 0.1)}); - sig = Mix.ar(sig) * pow(NamedControl.kr(\ ++ nameSpace ++ '_volume_master', 1, 0.1), 2); - }); - - sigs = Mix.ar(sigs / 4); - Out.ar(0, sigs) -}).add; - -SynthDef(\bass, { - var switches, drone; - switches = {|i| Dust.kr(0.1)} ! 9; - drone = {|i| var harm = pow(2, 2 - (i / 3).trunc), amp = (1 / pow(harm, 2)); - SinOsc.ar(60 * harm + TRand.kr(-3, 3, switches[i]), 0, amp)} ! 9; - Out.ar(~bassBusArray[0], Mix.new(drone) * 0.2); -}).add; - -SynthDef(\sampler, { - Out.ar(~samplerBusArray, PlayBuf.ar(2, ~sBuf, BufRateScale.kr(~sBuf), doneAction: 2)) -}).add; - -// main routine -SynthDef(\hdust, { - arg gate = 0; - var hierarchical_dust, low_sine, high_sine, brown_noise, white_noise; - // this triggers the combinations of sources - // it is similar to the Supercollider UGen called dust but with a hierarchical structure - hierarchical_dust = ( - TIRand.kr(0, 1, Impulse.kr(100)) * - TIRand.kr(0, 1, Impulse.kr(10)) * - TIRand.kr(0, 1, Impulse.kr(1)) * - TIRand.kr(0, 1, Impulse.kr(0.1)) - ); - // adjust the multiplier at the end of each line for adjusting levels - // note with each trigger, each source has a 1 in 3 chance of sounding - low_sine = SinOsc.ar(76.midicps / 16) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.1; - high_sine = SinOsc.ar(76.midicps * 8) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.01; - brown_noise = BrownNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.025; - white_noise = WhiteNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.02; - Out.ar(~hdustBusArray[0], - ((low_sine + high_sine + brown_noise + white_noise) ) - ); -}).add; - -) - -( -var bass, hdust, sampler, mixer; -/* -bass = Synth.tail(~group, \bass); -hdust = Synth.tail(~group, \hdust); -sampler = Synth.head(~group, \sampler); -*/ -mixer = Synth.tail(~group, \mixer); - -OSCdef(\mixer, {arg msg, time, addr, port; - mixer.set((msg[1] ++ '_' ++ msg[2] ++ '_' ++ msg[3]), msg[4]) -}, \mixer); - -/* -OSCdef(\sampler, {arg msg, time, addr, port; - msg.postln; - sampler.free; - ~sBuf.free; - ~sBuf = Buffer.read(s, msg[1].asString.postln, action: {sampler = Synth.head(~group, \sampler)}); -}, \sampler); -*/ -) - -/* old something -( -SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; - var trig, exc, sig1, sig2, noHarms, freqFinal, start, end; - noHarms = 30; - freq = WhiteNoise.ar * 3 + freq; - freqFinal = Duty.ar((1/freq), 0, freq); - trig = Changed.ar(freqFinal); - start = Demand.ar(trig, 0, Dwhite(-1, -0.75)); - end = Demand.ar(trig, 0, Dwhite(0.75, 1)); - exc = Phasor.ar(trig, (end - start) * freqFinal / SampleRate.ir, start, end, 0) * 0.001 + Dust.ar(10000, 0.01); - - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(2, 3)}) ], exc) * 0.5).softclip; - sig1 = HPF.ar(sig1, 300); - Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); -}).add; -) -*/ - diff --git a/resources/652c77ba/652c77ba_mus_model.json b/resources/652c77ba/652c77ba_mus_model.json deleted file mode 100644 index a671438..0000000 --- a/resources/652c77ba/652c77ba_mus_model.json +++ /dev/null @@ -1,97 +0,0 @@ -{ -"music_data": -[ - [ - [ - [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 0.875 ], - [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ] ], 0.625 ], - [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 1, 0, 0, 0, 0, -1 ], [ 0, 0, 0, 0, 0, 0 ] ], 1.5 ], - [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 0, 0, 1, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], 0.875 ], - [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 1, -1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], 0.875 ], -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], - [ [ [ 2, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 1, -1, 0, 0, -1, 0 ], [ 0, -1, 0, 0, -1, 1 ] ], 1.25 ], - [ [ [ 1, -1, 0, 1, -1, 0 ], [ "Rest" ], [ 1, -1, 0, 0, -1, 0 ], [ 0, -1, 0, 0, -1, 1 ] ], 1.125 ], - [ [ [ 1, -1, 0, 1, -1, 0 ], [ "Rest" ], [ 1, -1, 0, 0, -1, 0 ], [ 1, -1, -1, 0, -1, 0 ] ], 1 ], - [ [ [ 1, 0, 0, 0, -1, 0 ], [ "Rest" ], [ 1, -1, 0, 0, -1, 0 ], [ 1, -1, -1, 0, -1, 0 ] ], 0.75 ], - [ [ [ 1, -1, 0, 0, 0, 0 ], [ "Rest" ], [ 1, -1, 0, 0, -1, 0 ], [ 1, -1, -1, 0, -1, 0 ] ], 0.625 ], - [ [ [ 1, -1, 0, 0, 0, 0 ], [ "Rest" ], [ 1, -1, 0, 0, -1, 0 ], [ 0, -1, 0, 0, 0, 0 ] ], 0.75 ], - [ [ [ 1, -1, 0, 0, 0, 0 ], [ "Rest" ], [ 1, -1, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -2, 0 ] ], 1.375 ], - [ [ [ 2, -2, 0, 0, -1, 0 ], [ "Rest" ], [ 1, -1, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -2, 0 ] ], 0.875 ], - [ [ [ 2, -2, 0, 0, -1, 0 ], [ "Rest" ], [ 1, -1, 0, 0, -1, 0 ], [ 0, -1, 0, 0, -1, 1 ] ], 3.375 ], - [ [ [ 2, -2, 0, 0, -1, 0 ], [ "Rest" ], [ "Rest" ], [ 0, -1, 0, 0, -1, 1 ] ], 1.5 ], - [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ 0, -1, 0, 0, -1, 1 ] ], 1.375 ], - [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 1 ] - ] - ] -], -"last_changes": -[ - [ [ 0, 0, 0, 1, 0, -1 ], [ 0, 0, 0, 0, 0, 0 ], [ 2, 0, 0, 0, 0, -1 ], [ 1, 0, 0, 0, 0, -2 ] ], - [ [ 0, 0, 0, 1, 0, -1 ], [ 0, 0, 0, 0, 0, 0 ], [ 2, 0, 0, 0, 0, -1 ], [ -1, 0, 0, 1, 0, -1 ] ], - [ [ 0, 0, 0, 1, 0, -1 ], [ 0, 0, 0, 0, 0, 0 ], [ 2, 0, 0, 0, 0, -1 ], [ 0, 0, 0, 0, -1, 0 ] ], - [ [ 0, 0, 0, 1, 0, -1 ], [ 0, 0, 0, 0, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ], [ 0, 0, 0, 0, -1, 0 ] ], - [ [ 1, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ], [ 0, 0, 0, 0, -1, 0 ] ] -], -"cur_uid": "652c77ba", -"ref_uid": "nil", -"order_seed": 320463, -"dur_seed": 903977, -"motifs_seed": 895384, -"entrances_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.26424870466321, 0.75675675675676, 0.5, 0.5, 0.58549222797927, 0.72635135135135, 1, 0.5 ], -"passages_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"exits_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"ranges": [ [ -384, 2400 ], [ -507, 2400 ], [ -282, 2237 ], [ -1200, 2053 ] ], -"step_probs_vals": [ 0, 1200, 0, 0.5, 0.5, 0.5, 1, 0.5 ], -"passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], -"hd_exp": 2, -"hd_invert": 0, -"order": -[ - [ [ 1 ], [ 0, 3, 2, 3, 3, 2 ], [ ] ], - [ [ 2, 1 ], [ 3, 0, 3 ], [ ] ], - [ [ 1 ], [ 3, 2, 0 ], [ ] ] -], -"sus_weights": [ 0.75, 0.69, 0.75 ], -"order_size": [ 2, 6 ], -"passages_size": [ 0, 10 ], -"motif_edited": "true", -"order_edited": "false" -} \ No newline at end of file diff --git a/resources/6881b4ac/6881b4ac_mus_model.json b/resources/6881b4ac/6881b4ac_mus_model.json deleted file mode 100644 index ec7886b..0000000 --- a/resources/6881b4ac/6881b4ac_mus_model.json +++ /dev/null @@ -1,98 +0,0 @@ -{ -"music_data": -[ - [ - [ - [ [ [ -1, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 0.875 ], - [ [ [ -1, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ] ], 0.625 ], - [ [ [ -1, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, -1 ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ] ], 1.5 ], - [ [ [ -1, 0, 0, 0, 0, 0 ], [ 0, 0, 1, 0, 0, 0 ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ] ], 0.875 ], - [ [ [ -1, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ] ], 0.875 ], - [ [ [ -1, 0, 0, 0, 0, 0 ], [ 0, 1, 0, 0, 0, 0 ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ] ], 1 ], - [ [ [ -1, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 1, 0, 0 ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ] ], 1 ], - [ [ [ -1, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ] ], 1.25 ], - [ [ [ -1, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 1 ], [ "Rest" ], [ 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 0, 0, -1, -1, 0 ] ], 1.375 ], - [ [ [ 0, 0, 0, 0, -1, 0 ], [ 0, 0, 1, 0, -1, 0 ], [ 0, 0, 0, 0, -1, 0 ], [ 1, 0, 0, -1, -1, 0 ] ], 1.375 ], - [ [ [ 1, 0, 0, -1, -1, 0 ], [ 0, 0, 1, 0, -1, 0 ], [ 0, 0, 0, 0, -1, 0 ], [ 1, 0, 0, -1, -1, 0 ] ], 1.5 ], - [ [ [ 1, 0, 0, 0, -1, -1 ], [ 0, 0, 1, 0, -1, 0 ], [ 0, 0, 0, 0, -1, 0 ], [ 1, 0, 0, -1, -1, 0 ] ], 0.75 ], - [ [ [ 1, 0, 0, 0, -1, -1 ], [ 1, -1, 0, 0, -1, 0 ], [ 0, 0, 0, 0, -1, 0 ], [ 1, 0, 0, -1, -1, 0 ] ], 1 ] - ], - [ - [ [ [ 1, 0, 0, 0, -1, -1 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 1, 0, 0, -1, -1, 0 ] ], 0.75 ], - [ [ [ 1, 0, 0, 0, -1, -1 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 0, -1, 0, 1, -1, 0 ] ], 1 ], - [ [ [ 1, -1, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 0, -1, 0, 1, -1, 0 ] ], 0.875 ], - [ [ [ 1, -1, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 0, -1, 0, 0, -1, 1 ] ], 1.25 ], - [ [ [ 0, -1, 0, 1, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 0, -1, 0, 0, -1, 1 ] ], 1.125 ], - [ [ [ 0, -1, 0, 1, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 1, -1, -1, 0, -1, 0 ] ], 1 ], - [ [ [ 0, 0, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 1, -1, -1, 0, -1, 0 ] ], 0.75 ], - [ [ [ 0, -1, 0, 0, 0, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 1, -1, -1, 0, -1, 0 ] ], 0.625 ], - [ [ [ 0, -1, 0, 0, 0, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 0, -1, 0, 0, 0, 0 ] ], 0.75 ], - [ [ [ 0, -1, 0, 0, 0, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 1, -1, 0, 0, -2, 0 ] ], 1.375 ], - [ [ [ 1, -2, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 1, -1, 0, 0, -2, 0 ] ], 0.875 ], - [ [ [ 1, -2, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 0, -1, 0, 0, -1, 1 ] ], 3.375 ], - [ [ [ 1, -2, 0, 0, -1, 0 ], [ "Rest" ], [ "Rest" ], [ 0, -1, 0, 0, -1, 1 ] ], 1.5 ], - [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ 0, -1, 0, 0, -1, 1 ] ], 1.375 ], - [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 1 ] - ] - ] -], -"last_changes": -[ - [ [ 1, -1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, -1 ], [ -1, 0, 0, 1, 0, 0 ] ], - [ [ 1, -1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, -1 ], [ 1, 0, 1, 0, 0, -1 ] ], - [ [ 1, -1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, -1 ], [ 1, 0, -1, 0, 0, 0 ] ], - [ [ 1, -1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, -1 ], [ 2, -2, 0, 0, 0, 0 ] ], - [ [ 1, -1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, -1 ], [ 2, 0, 0, 0, 0, -1 ] ] -], -"cur_uid": "6881b4ac", -"ref_uid": "nil", -"order_seed": 157046, -"dur_seed": 249113, -"motifs_seed": 618906, -"entrances_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.26424870466321, 0.75675675675676, 0.5, 0.5, 0.58549222797927, 0.72635135135135, 1, 0.5 ], -"passages_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"exits_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"ranges": [ [ -384, 2400 ], [ -507, 2400 ], [ -282, 2237 ], [ -1200, 2053 ] ], -"step_probs_vals": [ 0, 1200, 0, 0.5, 0.5, 0.5, 1, 0.5 ], -"passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], -"hd_exp": 0.75, -"hd_invert": 0, -"order": -[ - [ [ 3 ], [ 0, 2, 0, 2, 2, 2, 0, 2, 0, 0 ], [ 1 ] ], - [ [ 3, 1 ], [ 0, 0 ], [ 2 ] ], - [ [ 3, 1 ], [ 2, 0, 2, 0, 2, 0, 0, 2, 2, 0 ], [ ] ], - [ [ 0, 1, 2 ], [ 3, 3, 3, 3, 3, 3, 3, 3, 3 ], [ ] ] -], -"sus_weights": [ 0.75, 0.69, 0.75 ], -"order_size": [ 2, 6 ], -"passages_size": [ 0, 10 ], -"motif_edited": "true", -"order_edited": "false" -} \ No newline at end of file diff --git a/resources/6abf27d4/lilypond/part_I.ly b/resources/6abf27d4/lilypond/part_I.ly deleted file mode 100644 index cd9693f..0000000 --- a/resources/6abf27d4/lilypond/part_I.ly +++ /dev/null @@ -1,110 +0,0 @@ -{ - { c'4^\markup { \pad-markup #0.2 "+0"} ~ c'2. ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" \break - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" \break - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'2 d'4^\markup { \pad-markup #0.2 "+31"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "III"\normal-size-super " 1↑" }} ~ d'4 ~ } - \bar "|" \break - { d'2. ~ d'8.[ e'16^\markup { \pad-markup #0.2 "-41"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "III"\normal-size-super " 1↑" }}] ~ } - \bar "|" - { e'1 ~ } - \bar "|" - { e'4 ~ e'8.[ fis'16^\markup { \pad-markup #0.2 "-49"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 11↑" }}] ~ fis'2 ~ } - \bar "|" - { fis'1 ~ } - \bar "|" \break - { fis'1 ~ } - \bar "|" - { fis'1 ~ } - \bar "|" - { fis'1 ~ } - \bar "|" - { fis'1 ~ } - \bar "|" \break - { fis'1 ~ } - \bar "|" - { fis'1 ~ } - \bar "|" - { fis'1 ~ } - \bar "|" - { fis'1 ~ } - \bar "|" \break - { fis'1 ~ } - \bar "|" - { fis'1 ~ } - \bar "|" - { fis'2 ~ fis'16[ gis'8.^\markup { \pad-markup #0.2 "+14"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 5↓" }}] ~ gis'4 ~ } - \bar "|" - { gis'4 ~ gis'8.[ a'16^\markup { \pad-markup #0.2 "+33"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 7↓" }}] ~ a'2 ~ } - \bar "|" \break - { a'4 ~ a'8[ a'8^\markup { \pad-markup #0.2 "-33"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "III"\normal-size-super " 5↓" }}] ~ a'8.[ g'16^\markup { \pad-markup #0.2 "+2"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 1↑" }}] ~ g'4 } - \bar "|" - { fis'4^\markup { \pad-markup #0.2 "+5"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "III"\normal-size-super " 11↑" }} ~ fis'2. ~ } - \bar "|" - { fis'1 ~ } - \bar "|" - { fis'1 ~ } - \bar "|" \break - { fis'1 ~ } - \bar "|" - { fis'1 ~ } - \bar "|" - { fis'1 ~ } - \bar "|" - { fis'1 ~ } - \bar "|" \break - { fis'1 ~ } - \bar "|" - { fis'1 ~ } - \bar "|" - { fis'1 ~ } - \bar "|" - { fis'1 ~ } - \bar "|" \break - { fis'1 ~ } - \bar "|" - { fis'1 ~ } - \bar "|" - { fis'1 ~ } - \bar "|" - { fis'1 ~ } - \bar "|" \break - { fis'1 ~ } - \bar "|" - { fis'1 ~ } - \bar "|" - { fis'1 ~ } - \bar "|" - { fis'1 ~ } - \bar "|" \break - { fis'2 ~ fis'16[ r8.] r4 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" \break - { r1 } - \bar "|" - { r1 } -\bar "||" -} \ No newline at end of file diff --git a/resources/6abf27d4/lilypond/part_II.ly b/resources/6abf27d4/lilypond/part_II.ly deleted file mode 100644 index 9dfb032..0000000 --- a/resources/6abf27d4/lilypond/part_II.ly +++ /dev/null @@ -1,110 +0,0 @@ -{ - { c'4^\markup { \pad-markup #0.2 "+0"} ~ c'2. ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" \break - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" \break - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'2. ~ c'16[ ais8.^\markup { \pad-markup #0.2 "-31"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 7↑" }}] ~ } - \bar "|" \break - { ais1 ~ } - \bar "|" - { ais2 ~ ais16[ gis8.^\markup { \pad-markup #0.2 "+14"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 5↓" }}] ~ gis4 ~ } - \bar "|" - { gis4 ~ gis8.[ gis16^\markup { \pad-markup #0.2 "+41"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 13↑" }}] ~ gis2 ~ } - \bar "|" - { gis4 ~ gis8[ g8^\markup { \pad-markup #0.2 "+2"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 3↑" }}] ~ g2 ~ } - \bar "|" \break - { g1 ~ } - \bar "|" - { g1 ~ } - \bar "|" - { g1 ~ } - \bar "|" - { g1 ~ } - \bar "|" \break - { g1 ~ } - \bar "|" - { g1 ~ } - \bar "|" - { g1 ~ } - \bar "|" - { g1 ~ } - \bar "|" \break - { g1 ~ } - \bar "|" - { g1 ~ } - \bar "|" - { g1 ~ } - \bar "|" - { g1 ~ } - \bar "|" \break - { g1 ~ } - \bar "|" - { g1 ~ } - \bar "|" - { g1 ~ } - \bar "|" - { g1 ~ } - \bar "|" \break - { g1 ~ } - \bar "|" - { g2 ~ g8[ fis8^\markup { \pad-markup #0.2 "-49"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 11↑" }}] ~ fis4 ~ } - \bar "|" - { fis2 ~ fis16[ gis8.^\markup { \pad-markup #0.2 "+14"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 5↓" }}] ~ gis4 ~ } - \bar "|" - { gis4 ~ gis8[ fis8^\markup { \pad-markup #0.2 "+49"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 11↓" }}] ~ fis2 ~ } - \bar "|" \break - { fis8.[ f16^\markup { \pad-markup #0.2 "-2"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 3↓" }}] ~ f4 ~ f8.[ e16^\markup { \pad-markup #0.2 "+13"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "III"\normal-size-super " 13↓" }}] ~ e4 ~ } - \bar "|" - { e1 ~ } - \bar "|" - { e1 ~ } - \bar "|" - { e1 ~ } - \bar "|" \break - { e1 ~ } - \bar "|" - { e1 ~ } - \bar "|" - { e8.[ d16^\markup { \pad-markup #0.2 "+45"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "I"\normal-size-super " 13↑" }}] ~ d2. ~ } - \bar "|" - { d8[ cis8^\markup { \pad-markup #0.2 "+7"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "I"\normal-size-super " 3↑" }}] ~ cis2 d4^\markup { \pad-markup #0.2 "+18"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "I"\normal-size-super " 5↓" }} ~ } - \bar "|" \break - { d2. e4^\markup { \pad-markup #0.2 "-27"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "I"\normal-size-super " 7↑" }} ~ } - \bar "|" - { e1 ~ } - \bar "|" - { e1 ~ } - \bar "|" - { e1 ~ } - \bar "|" \break - { e1 ~ } - \bar "|" - { e16[ r8.] r2. } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" \break - { r1 } - \bar "|" - { r1 } -\bar "||" -} \ No newline at end of file diff --git a/resources/6abf27d4/lilypond/part_III.ly b/resources/6abf27d4/lilypond/part_III.ly deleted file mode 100644 index 9f99438..0000000 --- a/resources/6abf27d4/lilypond/part_III.ly +++ /dev/null @@ -1,110 +0,0 @@ -{ - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" \break - { r8.[ gis16^\markup { \pad-markup #0.2 "+41"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 13↑" }}] ~ gis2 ~ gis8.[ g16^\markup { \pad-markup #0.2 "+2"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 3↑" }}] ~ } - \bar "|" - { g4 ~ g8[ f8^\markup { \pad-markup #0.2 "-2"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 3↓" }}] ~ f4 e4^\markup { \pad-markup #0.2 "-14"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 5↑" }} ~ } - \bar "|" - { e8[ d8^\markup { \pad-markup #0.2 "+31"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 7↓" }}] ~ d2. ~ } - \bar "|" - { d1 ~ } - \bar "|" \break - { d1 ~ } - \bar "|" - { d1 ~ } - \bar "|" - { d1 ~ } - \bar "|" - { d1 ~ } - \bar "|" \break - { d8[ c8^\markup { \pad-markup #0.2 "+0"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 1↑" }}] ~ c4 e4^\markup { \pad-markup #0.2 "-41"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 13↓" }} ~ e4 ~ } - \bar "|" - { e1 ~ } - \bar "|" - { e4 ~ e8.[ e16^\markup { \pad-markup #0.2 "-14"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 5↑" }}] ~ e2 ~ } - \bar "|" - { e1 ~ } - \bar "|" \break - { e1 ~ } - \bar "|" - { e1 ~ } - \bar "|" - { e1 ~ } - \bar "|" - { e4 ~ e8[ d8^\markup { \pad-markup #0.2 "-35"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "I"\normal-size-super " 5↓" }}] ~ d4 ~ d8[ dis8^\markup { \pad-markup #0.2 "+16"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 5↓" }}] ~ } - \bar "|" \break - { dis4 ~ dis8[ d8^\markup { \pad-markup #0.2 "+31"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 7↓" }}] ~ d2 ~ } - \bar "|" - { d8.[ d16^\markup { \pad-markup #0.2 "-8"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "I"\normal-size-super " 13↑" }}] ~ d4 ~ d8[ c8^\markup { \pad-markup #0.2 "+0"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 1↑" }}] ~ c4 ~ } - \bar "|" - { c4 cis4^\markup { \pad-markup #0.2 "-47"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 11↑" }} ~ cis2 ~ } - \bar "|" - { cis1 ~ } - \bar "|" \break - { cis1 ~ } - \bar "|" - { cis1 ~ } - \bar "|" - { cis1 ~ } - \bar "|" - { cis1 ~ } - \bar "|" \break - { cis1 ~ } - \bar "|" - { cis1 ~ } - \bar "|" - { cis1 ~ } - \bar "|" - { cis1 ~ } - \bar "|" \break - { cis1 ~ } - \bar "|" - { cis1 ~ } - \bar "|" - { cis1 ~ } - \bar "|" - { cis1 ~ } - \bar "|" \break - { cis1 ~ } - \bar "|" - { cis1 ~ } - \bar "|" - { cis1 ~ } - \bar "|" - { cis1 ~ } - \bar "|" \break - { cis1 ~ } - \bar "|" - { cis2 ~ cis16[ r8.] r4 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" \break - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" \break - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" \break - { r1 } - \bar "|" - { r1 } -\bar "||" -} \ No newline at end of file diff --git a/resources/6abf27d4/lilypond/part_IV.ly b/resources/6abf27d4/lilypond/part_IV.ly deleted file mode 100644 index 32bfe3f..0000000 --- a/resources/6abf27d4/lilypond/part_IV.ly +++ /dev/null @@ -1,110 +0,0 @@ -{ - { c'4^\markup { \pad-markup #0.2 "+0"} ~ c'2. ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" \break - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" \break - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" \break - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" \break - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" \break - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" \break - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" \break - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" \break - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" \break - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" \break - { c'1 ~ } - \bar "|" - { c'2 ~ c'16[ r8.] r4 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" \break - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" \break - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" \break - { r1 } - \bar "|" - { r1 } -\bar "||" -} \ No newline at end of file diff --git a/resources/6d743c5c/lilypond/part_I.ly b/resources/6d743c5c/lilypond/part_I.ly deleted file mode 100644 index f32eeeb..0000000 --- a/resources/6d743c5c/lilypond/part_I.ly +++ /dev/null @@ -1,18 +0,0 @@ -{ - { r1 } - \bar "|" - { r1 } - \bar "|" - { e''4^\markup { \pad-markup #0.2 "-41"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 13↓" }} ~ e''2. ~ } - \bar "|" - { e''1 ~ } - \bar "|" \break - { e''2. ~ e''16[ r8.] } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } -\bar "||" -} \ No newline at end of file diff --git a/resources/6d743c5c/lilypond/part_II.ly b/resources/6d743c5c/lilypond/part_II.ly deleted file mode 100644 index 5ac2380..0000000 --- a/resources/6d743c5c/lilypond/part_II.ly +++ /dev/null @@ -1,18 +0,0 @@ -{ - { r1 } - \bar "|" - { r16[ c'8.^\markup { \pad-markup #0.2 "+0"}] ~ c'2. ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" \break - { c'1 ~ } - \bar "|" - { c'2. ~ c'8.[ r16] } - \bar "|" - { r1 } - \bar "|" - { r1 } -\bar "||" -} \ No newline at end of file diff --git a/resources/6d743c5c/lilypond/part_III.ly b/resources/6d743c5c/lilypond/part_III.ly deleted file mode 100644 index 7e445e7..0000000 --- a/resources/6d743c5c/lilypond/part_III.ly +++ /dev/null @@ -1,18 +0,0 @@ -{ - { r2 r8.[ c'16^\markup { \pad-markup #0.2 "+0"}] ~ c'4 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'2. ~ c'16[ r8.] } - \bar "|" \break - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } -\bar "||" -} \ No newline at end of file diff --git a/resources/6d743c5c/lilypond/part_IV.ly b/resources/6d743c5c/lilypond/part_IV.ly deleted file mode 100644 index 04bc1b8..0000000 --- a/resources/6d743c5c/lilypond/part_IV.ly +++ /dev/null @@ -1,18 +0,0 @@ -{ - { c'4^\markup { \pad-markup #0.2 "+0"} ~ c'2. ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'2 ~ c'8.[ r16] r4 } - \bar "|" \break - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } -\bar "||" -} \ No newline at end of file diff --git a/resources/720a7ee4/720a7ee4_code.scd b/resources/720a7ee4/720a7ee4_code.scd deleted file mode 100644 index 47fbb43..0000000 --- a/resources/720a7ee4/720a7ee4_code.scd +++ /dev/null @@ -1,1046 +0,0 @@ -( -// helper funcs -var hsArrayToCents, pDist, hdSum, hsChordalDistance, hsArrayToFreq; - -// score funcs -var isInRange, spacingScore, rangeScore, intervalScore, inclusionScore; - -// subroutines -var genTuples, initVoices, genOrders, genSubMotif, updateVoices, genDurFunc, genStepFunc; - -// primary routines -var genMotif, genSecondarySeq; - -// audition funcs -var genPatterns, genMidiPatterns; - -// resource management funcs -var seedFunc, genUID, writeResources, stringifyToDepth, setSeeds, sanityCheck, -msgInterpret, loadLedgerFile, loadLedgerJSON, loadModelFile, loadModelJSON, -setGlobalVars, globalVarsToDict, saveLedger; - -// model vars -//(model and global vars mostly set by OSC funcs -var seq, lastXChanges, -curUID, refUID, orderSeed, durSeed, motifSeed, -entrancesProbVals, passagesProbVals, exitsProbVals, -ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, -orders, susWeights, orderSize, passagesSize, -motifEdited, orderEdited; - -// model aux vars -var entrancesDurFunc, passagesDurFunc, exitsDurFunc, stepFunc; - -// other global vars -var popSize, exPath, dir, primes, dims, tuples, -group, player, ledgerPath, ledger, currentlyPlayingUID, -nameSpaces; - -// install JSON quark -if(Quarks.isInstalled("JSONlib").not, { - Quarks.install("https://github.com/musikinformatik/JSONlib.git"); - thisProcess.recompile; - //HelpBrowser.openHelpFor("Classes/JSONlib"); -}); - - -//------helper funcs - -hsArrayToCents = { - arg hsArray; - hsArray.collect({arg dist, p; dist * 1200 * log2(primes[p][0]/primes[p][1])}).sum -}; - -pDist = { - arg array1, array2, signed = false; - var pDistance; - pDistance = hsArrayToCents.value(array1) - hsArrayToCents.value(array2); - if(signed, {pDistance}, {abs(pDistance)}) -}; - -hdSum = { - arg hsArrays; - var size, distances, mean; - size = hsArrays.size; - distances = (size - 1).collect({arg i; - ((i + 1)..(size - 1)).collect({arg j; - abs(hsArrays[i] - hsArrays[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsChordalDistance = { - arg hsArrays1, hsArrays2; - var size, distances, mean; - size = hsArrays1.size; - distances = hsArrays1.size.collect({arg i; - hsArrays2.size.collect({arg j; - abs(hsArrays1[i] - hsArrays2[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsArrayToFreq = { - arg array; - array.collect({arg dim, d; pow(primes[d][0]/primes[d][1], dim)}).product -}; - -//------score funcs - -/* -isInRange = { - arg hsArray, min, max; - var cents; - cents = hsArrayToCents.value(hsArray); - (cents >= min) && (cents <= max) -}; -*/ - -spacingScore = { - arg hsArrays, min; - var centsArray; - centsArray = hsArrays.collect({arg hsArray; hsArrayToCents.value(hsArray)}).sort({arg a, b; a < b}); - centsArray.differentiate.drop(1).collect({arg pDistance; if(pDistance >= min, {1}, {0.01})}).sum; -}; - -rangeScore = { - arg hsArray1, hsArray2, min, max, low, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - if((pDistance >= min) && (pDistance <= max), {1}, {low}); -}; - -intervalScore = { - arg hsArray1, hsArray2, mean, sd, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - //pDistance.gaussCurve(1, mean, sd) - stepFunc.value(pDistance); -}; - -inclusionScore = { - arg array, test, min = 0.01; - if(array.collect({arg v; v.hash}).includes(test.hash), {min}, {1}); -}; - - -//------subroutines - -genTuples = { - var tuples; - tuples = dims.collect({[-1, 0, 1]}).allTuples.select({arg tuple; (abs(tuple.drop(1)).sum <= 1) && (tuple[0] == 0)}); - tuples = tuples ++ tuples.collect({arg tuple; [-3, -2, -1, 1, 2, 3].collect({arg octTrans; tuple.deepCopy.put(0, octTrans)})}).flatten; -}; - -initVoices = { - var init, voicesInit; - voicesInit = popSize.collect({dims.collect({0})}); - /* - voicesInit = [dims.collect({0})]; - (popSize - 1).do({ - arg rep, new; - rep = dims.rand; - new = voicesInit.last.deepCopy; - new[rep] = new[rep] + [-1, 1].choose(); - voicesInit = voicesInit.add(new); - }); - */ - voicesInit.deepCopy; -}; - -genDurFunc = {arg chordProb, minPad, maxPad, minDur, maxDur, envData, seed; - var env, pTable, durFunc; - env = Env.pairs([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).asSignal(256).asList.asArray; - pTable = env.asRandomTable; - [chordProb, minPad, maxPad, minDur, maxDur, envData].postln; - durFunc = {arg allowChord, pad = false; - var res; - res = if(allowChord.not, { - pTable.tableRand * (maxDur - minDur) + minDur - }, { - if(1.0.rand < chordProb, {0}, {pTable.tableRand * (maxDur - minDur) + minDur}); - }).round(0.125); - if(pad, {res = res + rrand(minPad.asFloat, maxPad.asFloat).round(0.125)}); - if(res.asInteger == res, {res = res.asInteger}); - res - }; - seedFunc.value(durFunc, seed); -}; - -genStepFunc = {arg minStep, maxStep, envData, seed; - var envDataNorm, env, pTable, stepFunc; - [minStep, maxStep, envData].postln; - envDataNorm = ([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).flop; - envDataNorm = [envDataNorm[0].normalize(minStep, maxStep), envDataNorm[1]].flop; - env = Env.pairs(envDataNorm); - stepFunc = {arg pDist; - env.at(pDist).clip(0.001, 1); - }; - seedFunc.value(stepFunc, seed); -}; - -genOrders = {arg minMotifLength = 1, maxMotifLength = 5, minProgLength = 0, maxProgLength = 5; - ((maxMotifLength - minMotifLength).rand + minMotifLength).collect({ - var noProgIns, noSusIns, noSilentIns, prog, sus, silent, order; - noSusIns = [1, 2, 3].wchoose(susWeights.normalizeSum); - noProgIns = (popSize - noSusIns).rand + 1; - noSilentIns = popSize - noSusIns - noProgIns; - - # prog, sus, silent = (0..(popSize-1)).scramble.clumps([noProgIns, noSusIns, noSilentIns]); - - prog = (prog.scramble ++ ((maxProgLength - minProgLength).rand + minProgLength).collect({prog.choose}).scramble); - if(silent == nil, {silent = []}); - [sus.scramble, prog, silent.scramble] - }); -}; - -updateVoices = {arg ins, sus; - var voices, candidates, nWeights, nProbs, sel; - - voices = lastXChanges.deepCopy.last; - - candidates = sus.collect({arg v; tuples.collect({arg t; voices[v] + t})}).flatten; - candidates = difference(candidates.asSet, voices.asSet).asList; - nProbs = candidates.collect({arg candidate; - var stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore; - - //stepScore = intervalScore.value(voices[ins], candidate, 30, 400, 0.1); - stepScore = intervalScore.value(voices[ins], candidate, 100, 100); - recentlySoundedScore = inclusionScore.value(lastXChanges.flop[ins], candidate, 0); - isInRangeScore = rangeScore.value(candidate, candidate.collect({0}), ranges[ins][0], ranges[ins][1], 0, true); - regScore = spacingScore.value(voices.deepCopy.put(ins, candidate), 300); - hdScore = pow(hdSum.value(voices.deepCopy.put(ins, candidate)), hdExp); - if(hdInvert == 0, {hdScore = 1/hdScore}); - //maybe what you want here is a vector to another root and then favoring movement towards it. - //distScore = pow(hsChordalDistance.value(voices, voices.put(ins, candidate)), 2); - - [stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore] - }); - - nWeights = passagesWeights; - - //this handles nWeights of 0; mainly for testing - nProbs = nProbs.flop.select({arg scores, s; nWeights[s] != 0}).flop; - nWeights = nWeights.select({arg weight; weight != 0}); - nProbs = nProbs.flop.collect({arg scores, s; - if(scores.sum == 0, {scores}, {scores.normalizeSum * nWeights[s]}) - }); - nProbs = nProbs.flop.collect({arg scores, s; scores.product}).normalizeSum; - - sel = candidates.wchoose(nProbs); - - voices[ins] = sel; - lastXChanges = lastXChanges.add(voices).keep(-5); -}; - -genSubMotif = {arg order, orderIndex, lastState, repeatLast = false, startFromLast = false, isLastOrder = false; - var sus, prog, silent, flatOrder, res, isInChord, allowChord, pad, lastXChangesHold, voices, adder; - # sus, prog, silent = order; - flatOrder = silent ++ sus ++ prog; - lastXChangesHold = lastXChanges.deepCopy; - voices = lastState.deepCopy; - isInChord = popSize.collect({false}); - allowChord = false; - pad = false; - res = []; - "------generating motif".postln; - //need to figure out here if voices move between motifs - flatOrder.do({arg ins, i; - - if(prog.includes(ins) && repeatLast.not, {updateVoices.value(ins, sus)}); - adder = if(silent.includes(ins), {["Rest"]}, {lastXChanges.last.deepCopy[ins]}); - - if(voices[ins] != adder, { - var dur; - - if((sus ++ silent).includes(ins), { - allowChord = (ins != sus.last); - pad = (ins == sus.last); - }, { - if(i < (flatOrder.size - 1), { - allowChord = (isInChord[flatOrder[i + 1]] || (ins == flatOrder[i + 1])).not; - pad = false; - }, { - allowChord = false; - pad = true - }); - }); - if((orderIndex == 0) && sus.includes(ins), { - dur = entrancesDurFunc.value(allowChord, pad); - }, { - dur = passagesDurFunc.value(allowChord, pad); - }); - if(dur == 0, {isInChord[ins] = true}, {isInChord = popSize.collect({false})}); - - voices[ins] = adder; - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - - // pad ending - if(orderIndex == (orders.size - 1), { - (0..(popSize-1)).scramble.do({arg ins; - if(res.last.first[ins] != ["Rest"], { - var dur; - voices[ins] = ["Rest"]; - allowChord = (voices != popSize.collect({["Rest"]})); - pad = allowChord.not; - dur = exitsDurFunc.value(allowChord, pad); - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - }); - - //format and return - if(startFromLast, {lastXChanges = lastXChangesHold.deepCopy}); - res; -}; - - -//------primary routines - -genMotif = { - var repeats, fSeq, fDur, durAdd; - - repeats = 1; - fSeq = []; - - repeats.do({arg index; - var motif; - - motif = []; - - orders.do({arg order, o; - var lastState, subMotif; - lastState = if(o == 0, {popSize.collect({["Rest"]})}, {motif.last.last.first}); - subMotif = genSubMotif.value(order, o, lastState, isLastOrder: o == (orders.size - 1)); - motif = motif.add(subMotif); - - }); - - sanityCheck.value(motif, index); - - fSeq = fSeq.add(motif); - }); - - //round last duration to measure - fDur = fSeq.flatten.flatten.slice(nil, 1).sum; - durAdd = fDur.round(4) - fDur; - if(durAdd < 0, {durAdd = 4 - durAdd}); - fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] = fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] + durAdd; - - fSeq -}; - -genSecondarySeq = {arg seq; - var curdles, fSeq; - curdles = []; - while({curdles.sum < seq.size}, {curdles = curdles ++ [3.rand + 1]}); - - fSeq = seq.clumps(curdles).collect({arg clump, m; - var repeats, paddedSeq; - - //add rest - paddedSeq = clump.add([[[popSize.collect({["Rest"]}), 0.5.rand]]]); - - //implement repeats - repeats = [0.rand + 1, 1].wchoose([1, 0].normalizeSum); - repeats.collect({paddedSeq}); - }); - fSeq -}; - - -//------audition funcs - -/* -Event.addEventType(\osc, { - if (~addr.postln.notNil) { - ~addr.sendMsg(~indexPath, ~indexMsg); - ~addr.sendMsg(~seqPath, stringifyToDepth.value(~seqMsg, 3)); - //~addr.sendMsg("/STATE/OPEN", (dir.replace("supercollider", "resources") +/+ ~idMsg +/+ ~idMsg ++ "_gui_state" ++ ".state").standardizePath.postln); - }; -}); -*/ - -Event.addEventType(\osc, { - if (~addr.notNil) { - ~msg; - ~addr.sendMsg(~path, *~msg); - }; -}); - -genPatterns = {arg inSeq, addr, oneShot = false; - var voices, durs, pbinds, res, indices, sectionDurs, msg, ids, seq; - seq = inSeq.collect({arg mSeq; mSeq[0]}); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - pbinds = voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs, attacks, rels, amps; - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - //attacks = 2.collect({rrand(1, 3)}) ++ freqs.drop(2).collect({rrand(0.3, 0.5)}); - attacks = fDurs.collect({arg dur; dur * rrand(0.2, 0.4)}); - //rels = freqs.drop(2).collect({rrand(0.3, 0.5)}) ++ 2.collect({rrand(1, 3)}); - rels = (clumps.size - 1).collect({arg c; - if(clumps[c + 1][0] == ["Rest"], {rrand(1.0, 3.0)}, {rrand(0.3, 0.5)}); - }); - rels = rels.add(rrand(1.0, 3.0)); - amps = freqs.collect({rrand(0.6, 0.99)}); - - [ - Pbind( - \instrument, \string_model, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \attack, Pseq(attacks, 1), - \sustain, Pseq(fDurs, 1), - \release, Pseq(rels, 1), - //\amp, Pseq(amps, 1), - \amp, Pbrown(0.5, 1, 0.5), - \busIndex, v - ), - Pbind( - \instrument, \sine, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \sustain, Pseq(fDurs, 1), - \busIndex, v - ) - ] - }).flatten; - if(oneShot.not, { - msg = inSeq.collect({arg mSeq, m; mSeq[1..]}); - //ids = inSeq.collect({arg mSeq, m; mSeq[2]}); - sectionDurs = seq.collect({arg mSeq; mSeq.flatten2(mSeq.maxDepth - 5).flop[1].sum}); - pbinds = pbinds ++ - [ - Pbind( - \type, \osc, - \addr, addr, - \path, "/playing", - \msg, Pseq(msg, 1), - \dur, Pseq(sectionDurs, 1) - ); - ] - }); - res = Ppar(pbinds); - res -}; - -/* -genMidiPatterns = {arg seq; - var voices, durs, patterns, res, mOut, pbRange; - pbRange = 1; //semitones - change this as needed for your situation - mOut = MIDIOut.newByName("TiMidity", "TiMidity port 0").latency_(Server.default.latency); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - res = Ppar( - voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs; - - mOut.program(v, 70); - - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - - Pbind( - \type, \midi, - \chan, v, - \noteval, Pseq(freqs.cpsmidi - 24, 1), - \note, Pfunc({ | event | event[\noteval].floor }), - \dur, Pseq(fDurs, 1), - \midiout, mOut, - \amp, 1, - \bend, Pfunc({ - | event | - if (event[\note].isRest.not) { - var pitchbendvalue = event[\noteval].frac.linlin(0, pbRange, 8192, 8192*2).asInteger; - m.bend(v, pitchbendvalue); - }; - 0; // return something other than nil to avoid stopping the pattern - }), - ); - }); - ); - res -}; -*/ - - -//------resource management funcs - -genUID = {Date.seed.asHexString.toLower}; - -seedFunc = {arg func, seed; - var funcArgs, next; - next = Routine({loop{func.valueArray(funcArgs).yield }}); - next.randSeed_(seed); - {arg ...args; funcArgs = args; next.value} -}; - -stringifyToDepth = {arg data, maxDepth = 1; - var prettyString = "", rCount = 0, writeArray, indent; - - if(maxDepth == 0, { - data.asCompileString - }, { - indent = {arg size; size.collect({" "}).join("")}; - writeArray = {arg array; - prettyString = prettyString ++ indent.value(rCount) ++ "[\n"; - rCount = rCount + 1; - if(rCount < maxDepth, { - array.do({arg subArray; writeArray.value(subArray)}); - }, { - prettyString = prettyString ++ array.collect({arg subArray; - indent.value(rCount + 1) ++ subArray.asCompileString - }).join(",\n"); - }); - rCount = rCount - 1; - prettyString = prettyString ++ "\n" ++ indent.value(rCount) ++ "],\n"; - }; - - writeArray.value(data); - prettyString.replace(",\n\n", "\n").drop(-2); - }) -}; - -sanityCheck = {arg motif, index; - //print functions = very helpful - ("----------" + index + "------------").postln; - - motif.flatten.do({arg val, v; - if(v > 0, { - if(motif.flatten[v-1][0].hammingDistance(val[0]) > 1, {"problem 1".postln}); - if(motif.flatten[v-1][0].hammingDistance(val[0]) == 0, {"problem 2".postln}); - }); - val.postln - }); - "***********".postln; -}; - -msgInterpret = {arg in, escapeDoubleQuotes = true, escapeSingleQuotes = true; - var res; - - res = in; - if(res.isNil.not, { - if((res.isArray && res.isString.not), { - res = res.asCompileString; - res = res.replace(" ", "").replace("\n", "").replace("\t", ""); - if(escapeSingleQuotes, {res = res.replace("\'", "")}); - if(escapeDoubleQuotes, {res = res.replace("\"", "")}); - res = res.replace("Rest", "\"Rest\""); - res = res.interpret; - }, { - var tmpRes; - if(res.every({arg char; char.isDecDigit}), {tmpRes = res.asInteger}); - if(res.contains("."), {tmpRes = res.asFloat}); - if(tmpRes != nil, {res = tmpRes}); - }); - }); - res -}; - -writeResources = {arg path, dict; - var file, modelItems, resString; - file = File(path,"w"); - - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - - resString = nameSpaces.collect({arg nameSpace; - var depth = 0, insert = " "; - if(nameSpace == "music_data", {depth = 3; insert = "\n"}); - if(nameSpace == "last_changes", {depth = 1; insert = "\n"}); - if(nameSpace == "order", {depth = 1; insert = "\n"}); - if((nameSpace == "ref_uid") && (dict[nameSpace] == nil), {dict[nameSpace] = "nil"}); - "\"" ++ nameSpace ++ "\":" ++ insert ++ stringifyToDepth.value(dict[nameSpace], depth) - }).join(",\n"); - - resString = "{\n" ++ resString ++ "\n}"; - - file.write(resString); - file.close; - resString -}; - -loadModelFile = {arg path; loadModelJSON.value(File(path, "r").readAllString.parseJSON)}; - -loadModelJSON = {arg jsonObject; - var dict; - dict = Dictionary.with(*nameSpaces.collect({arg nS; nS->msgInterpret.value(jsonObject[nS])})); - dict -}; - -setGlobalVars = {arg dict, skipLastXChanges = false; - var tmpLastXChanges; - tmpLastXChanges = lastXChanges.deepCopy; - // order really matters!!!! - # seq, lastXChanges, curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited = nameSpaces.collect({arg nS; dict[nS]}); - if(skipLastXChanges, {lastXChanges = tmpLastXChanges}); - dict -}; - -globalVarsToDict = { - var modelItems, dict; - // order really matters!!!! - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - dict = Dictionary.with(*nameSpaces.collect({arg nS, n; nS->modelItems[n]})); -}; - -loadLedgerFile = {arg path; - ledgerPath = path; - loadLedgerJSON.value(File(ledgerPath, "r").readAllString.parseJSON) -}; - -loadLedgerJSON = {arg jsonObject; ledger = jsonObject["ledger"]}; - -saveLedger = {arg ledger, path; - var file; - file = File(path, "w"); - file.write("{\n\"ledger\":\n" ++ stringifyToDepth.value(ledger, 1) ++ "\n}"); - file.close; -}; - -//------global vars - -primes = [[2, 1], [3, 2], [5, 4], [7, 4], [11, 8], [13, 8]]; -//ranges = [[-2400, 0], [-1200, 1200], [0, 2400], [0, 2400]]; -exPath = thisProcess.nowExecutingPath; -dir = exPath.dirname; -//popSize = 4; -dims = primes.size; -tuples = genTuples.value(); -//refUID = nil; -group = Group.new; -~group = group; -loadLedgerFile.value(dir +/+ ".." +/+ "resources" +/+ "piece_ledger.json"); -//passagesWeights = [1, 1, 1, 1, 1]; -//susWeights = [1, 1, 1]; -// order really matters!!!! -nameSpaces = [ - "music_data", "last_changes", "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", - "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", - "ranges", "step_probs_vals", "passages_weights", "hd_exp", "hd_invert", - "order", "sus_weights", "order_size", "passages_size", - "motif_edited", "order_edited" -]; - - -//------OSC funcs - -OSCdef(\load_ledger, {arg msg, time, addr, port; - loadLedgerFile.value(msg[1].asString); -}, \load_ledger); - -OSCdef(\load_model, {arg msg, time, addr, port; - var dict; - dict = loadModelFile.value(msg[1].asString); - setGlobalVars.value(dict); -}, \load_model); - -OSCdef(\save_ledger, {arg msg, time, addr, port; - msg.postln; - ledger = msgInterpret.value(msg[1].asString.parseJSON["ledger"], false).postln; - //loadLedgerJSON.value(msg[0]) - saveLedger.value(ledger, msg[2].asString); - //loadLedgerFile.value(msg[1].asString); -}, \save_ledger); - -OSCdef(\generate, {arg msg, time, addr, port; - var path, dict, durSeeds, musPath, modelString; - msg.postln; - - path = msg[1].asString; - - dict = loadModelFile.value(path); - setGlobalVars.value(dict, true); - - popSize = ranges.size; - - //refUID.postln; - - loadLedgerFile.value(ledgerPath); - if(ledger == nil, {ledger = ["tmp"]}); - if(ledger.last != "tmp", {ledger = ledger.add("tmp")}); - - if(refUID == nil, {lastXChanges = [initVoices.value().deepCopy]}); - if((refUID != nil) && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - lastXChanges = msgInterpret.value(file.readAllString.parseJSON["last_changes"]); - }); - - refUID.postln; - lastXChanges.collect({arg item; item.postln}); - - durSeeds = seedFunc.value({3.collect({rrand(100000, 999999)})}, durSeed).value.postln; - entrancesDurFunc = genDurFunc.valueArray(entrancesProbVals[..4] ++ [entrancesProbVals[5..]] ++ [durSeeds[0]]); - passagesDurFunc = genDurFunc.valueArray(passagesProbVals[..4] ++ [passagesProbVals[5..]] ++ [durSeeds[1]]); - exitsDurFunc = genDurFunc.valueArray(exitsProbVals[..4] ++ [exitsProbVals[5..]] ++ [durSeeds[2]]); - - if(orders == nil, { - orders = seedFunc.value(genOrders, orderSeed).valueArray(orderSize ++ passagesSize); - //addr.sendMsg("/order", stringifyToDepth.value(orders, 1)); - }); - - stepFunc = genStepFunc.valueArray(stepProbsVals[..1] ++ [stepProbsVals[2..]] ++ [motifSeed]); - seq = seedFunc.value(genMotif, motifSeed).value; - - lastXChanges.collect({arg item; item.postln}); - - dict = globalVarsToDict.value; - modelString = writeResources.value(path, dict); - - //addr.sendMsg("/generated", musPath, stringifyToDepth.value(seq, 3)); - //~seq = seq; - - addr.sendMsg("/generated", path, modelString, ledgerPath); -}, \generate); - - -OSCdef(\commit, {arg msg, time, addr, port; - var musicData, musicChanged, dict, newLedger, modelPath, musString, musFile, test1, test2, lastCurUID, commitType; - //msg.postln; - - /* - test1 = msg[1].asString.parseJSON; - test2 = (dir +/+ ".." +/+ "resources/tmp/tmp_music" ++ ".json").standardizePath.parseJSONFile; - msgInterpret.value(test1["music"])[0][0][0][1].class.postln; - msgInterpret.value(test2["music_data"])[0][0][0][1].class.postln; - (test1["music"] == test2["music_data"]).postln; - */ - - musicData = loadModelJSON.value(msg[1].asString.parseJSON)["music_data"].postln; - musicChanged = (musicData != seq).postln; - commitType = msg[2].asString; - - lastCurUID = curUID.deepCopy; - curUID = genUID.value; - - File.mkdir((dir +/+ ".." +/+ "resources" +/+ curUID).standardizePath); - File.copy(exPath, (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_code" ++ ".scd").standardizePath); - - modelPath = (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_mus_model" ++ ".json").standardizePath; - dict = globalVarsToDict.value; - if(musicChanged, { - seq = musicData; - dict["music_data"] = seq; - dict["motif_edited"] = "true" - }); - dict["cur_uid"] = curUID; - - writeResources.value(modelPath, dict); - - File.delete(ledgerPath ++ "_bak"); - File.copy(ledgerPath, ledgerPath ++ "_bak"); - File.delete(ledgerPath); - - if(commitType == "add", { - if(lastCurUID == "tmp", { - ledger = ledger.drop(-1).add(ledger.indexOf(curUID)); - }, { - ledger = ledger.add(curUID); - }) - }); - - if(commitType == "insert", {ledger = ledger.insert(lastCurUID, curUID)}); - - if(commitType == "replace", {ledger = ledger.put(lastCurUID, curUID)}); - - saveLedger.value(ledger, ledgerPath); - - addr.sendMsg("/committed", curUID, ledgerPath); - //refUID = curUID; - -}, \commit); - -OSCdef(\transport, {arg msg, time, addr, port; - msg.postln; - if(msg[1] == 0, { - group.set(\release, 2); - group.set(\gate, 0); - player.stop; - }, { - // the cued sequence can now be read from file, so this can be cleaned up - var cSize, patterns, pSeq, cuedSeek, indexStart, indexEnd, tmpLedger; - if(msg[1] == 1, { - pSeq = []; - cuedSeek = (seq != nil); - indexStart = msg[2].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.postln.parseJSON["music_data"]), path, indexStart + index, uid]); - file.close; - }); - }); - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - patterns = genPatterns.value(pSeq, addr); - }, { - pSeq = [loadModelJSON.value(msg[2].asString.parseJSON)["music_data"].postln]; - patterns = genPatterns.value(pSeq, addr, true); - }); - player = Pfset(pattern: patterns, cleanupFunc: { - addr.sendMsg("/transport", 0); - addr.sendMsg("/one_shot", 0); - }); - player = player.play - }); -}, \transport); - - -OSCdef(\transcribe_motif, {arg msg, time, addr, port; - var tSeq, refChord, refUID; - - msg.postln; - - tSeq = [loadModelJSON.value(msg[1].asString.parseJSON)["music_data"]]; - refUID = msg[2].asString.postln; - - if((refUID != "nil") && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }, { - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - }); - - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "lilypond" +/+ "includes").standardizePath, addr, "/transcribe_motif"); -}, \transcribe_motif); - - -OSCdef(\transcribe_all, {arg msg, time, addr, port; - var cSize, patterns, cuedSeek, indexStart, indexEnd, tmpLedger; - if(true, { - cuedSeek = (seq != nil); - indexStart = msg[1].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - - //tmp for testing transcription - indexEnd = (indexStart+5); - - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - var lilyPartLedgerFiles; - - lilyPartLedgerFiles = 4.collect({arg p; - File((dir +/+ ".." +/+ "lilypond" +/+ "includes" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly").standardizePath, "w"); - }); - - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file, fileString, tSeq, refUID, refChord; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - fileString = file.readAllString; - tSeq = msgInterpret.value(fileString.parseJSON["music_data"]); - refUID = msgInterpret.value(fileString.parseJSON["ref_uid"]); - file.close; - - //uid.postln; - //(refUID == "nil").postln; - - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - - if(refUID != "nil", { - path = (dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }); - - if(index != indexEnd, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath); - }, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath, addr, "/transcribe_all"); - }); - - lilyPartLedgerFiles.do({arg f, p; - f.write("\\include \".." +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly\"\n"); - }); - - }); - - lilyPartLedgerFiles.do({arg f; - f.close - }); - }); - /* - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - */ - }, { - - }); - -}, \transcribe_all); - -) - -~transcribe.value(~seq, dir); - -( -//synthdefs -~stringModelBusArray = 4.collect({Bus.audio(s, 1)}); -~sineBusArray = 4.collect({Bus.audio(s, 1)}); -~bassBusArray = 1.collect({Bus.audio(s, 1)}); -~hdustBusArray = 1.collect({Bus.audio(s, 1)}); -~samplerBusArray = 2.collect({Bus.audio(s, 1)}); -~sBuf = Buffer.alloc(s, 10, 2); -SynthDef(\string_model, {arg freq, gate = 1, sustain, amp, dur, attack, release = 1, busIndex = 0; - var trig, exc, sig1, sig2, noHarms; - noHarms = rrand(20, 40); - exc = Saw.ar(freq, TRand.ar(0.5, 1, Impulse.ar(freq))) * 0.001 + Dust.ar(10000, 0.01); - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.8).softclip; - //sig1 = HPF.ar(sig1, 300); - Out.ar(Select.kr(busIndex, ~stringModelBusArray), sig1 * amp * EnvGen.kr(Env.adsr(attack, 0.3, 0.9, release, 0.9, -3), gate, doneAction: 2)); - //Out.ar([0, 1], sig1 * EnvGen.kr(Env.asr(dur, 0.3, 1), gate, doneAction: 2)); -}).add; - -SynthDef(\sine, {arg freq, gate = 1, sustain, amp, dur, busIndex = 0; - var sig; - sig = SinOsc.ar(freq); - Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.asr(0.3, 0.4, 0.3), gate, timeScale: dur, doneAction: 2)); - //Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.sine(dur), gate, doneAction: 2)); -}).add; - -SynthDef(\mixer, {arg freq, gate = 1, sustain, amp, dur, out; - var nameSpaces, sigs; - - sigs = [~stringModelBusArray, ~sineBusArray/*, ~bassBusArray, ~hdustBusArray, ~samplerBusArray*/].collect({arg busArray, i; - var nameSpace, sig; - nameSpace = ['string', 'sine', 'bass', 'hdust', 'sampler'][i]; - sig = busArray.collect({arg bus, c; In.ar(bus, 1) * NamedControl.kr(\ ++ nameSpace ++ '_volume_' ++ c, 1, 0.1)}); - sig = sig.collect({arg channel, c; Pan2.ar(channel, NamedControl.kr(\ ++ nameSpace ++ '_pan_' ++ c, i / (busArray.size - 1), 0.1) * 2 - 1)}); - sig = sig.collect({arg channel, c; channel * NamedControl.kr(\ ++ nameSpace ++ '_mute_' ++ c, 1, 0.1)}); - sig = Mix.ar(sig) * pow(NamedControl.kr(\ ++ nameSpace ++ '_volume_master', 1, 0.1), 2); - }); - - sigs = Mix.ar(sigs / 4); - Out.ar(0, sigs) -}).add; - -SynthDef(\bass, { - var switches, drone; - switches = {|i| Dust.kr(0.1)} ! 9; - drone = {|i| var harm = pow(2, 2 - (i / 3).trunc), amp = (1 / pow(harm, 2)); - SinOsc.ar(60 * harm + TRand.kr(-3, 3, switches[i]), 0, amp)} ! 9; - Out.ar(~bassBusArray[0], Mix.new(drone) * 0.2); -}).add; - -SynthDef(\sampler, { - Out.ar(~samplerBusArray, PlayBuf.ar(2, ~sBuf, BufRateScale.kr(~sBuf), doneAction: 2)) -}).add; - -// main routine -SynthDef(\hdust, { - arg gate = 0; - var hierarchical_dust, low_sine, high_sine, brown_noise, white_noise; - // this triggers the combinations of sources - // it is similar to the Supercollider UGen called dust but with a hierarchical structure - hierarchical_dust = ( - TIRand.kr(0, 1, Impulse.kr(100)) * - TIRand.kr(0, 1, Impulse.kr(10)) * - TIRand.kr(0, 1, Impulse.kr(1)) * - TIRand.kr(0, 1, Impulse.kr(0.1)) - ); - // adjust the multiplier at the end of each line for adjusting levels - // note with each trigger, each source has a 1 in 3 chance of sounding - low_sine = SinOsc.ar(76.midicps / 16) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.1; - high_sine = SinOsc.ar(76.midicps * 8) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.01; - brown_noise = BrownNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.025; - white_noise = WhiteNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.02; - Out.ar(~hdustBusArray[0], - ((low_sine + high_sine + brown_noise + white_noise) ) - ); -}).add; - -) - -( -var bass, hdust, sampler, mixer; -/* -bass = Synth.tail(~group, \bass); -hdust = Synth.tail(~group, \hdust); -sampler = Synth.head(~group, \sampler); -*/ -mixer = Synth.tail(~group, \mixer); - -OSCdef(\mixer, {arg msg, time, addr, port; - mixer.set((msg[1] ++ '_' ++ msg[2] ++ '_' ++ msg[3]), msg[4]) -}, \mixer); - -/* -OSCdef(\sampler, {arg msg, time, addr, port; - msg.postln; - sampler.free; - ~sBuf.free; - ~sBuf = Buffer.read(s, msg[1].asString.postln, action: {sampler = Synth.head(~group, \sampler)}); -}, \sampler); -*/ -) - -/* old something -( -SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; - var trig, exc, sig1, sig2, noHarms, freqFinal, start, end; - noHarms = 30; - freq = WhiteNoise.ar * 3 + freq; - freqFinal = Duty.ar((1/freq), 0, freq); - trig = Changed.ar(freqFinal); - start = Demand.ar(trig, 0, Dwhite(-1, -0.75)); - end = Demand.ar(trig, 0, Dwhite(0.75, 1)); - exc = Phasor.ar(trig, (end - start) * freqFinal / SampleRate.ir, start, end, 0) * 0.001 + Dust.ar(10000, 0.01); - - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(2, 3)}) ], exc) * 0.5).softclip; - sig1 = HPF.ar(sig1, 300); - Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); -}).add; -) -*/ - diff --git a/resources/720a7ee4/720a7ee4_mus_model.json b/resources/720a7ee4/720a7ee4_mus_model.json deleted file mode 100644 index f3a9ac9..0000000 --- a/resources/720a7ee4/720a7ee4_mus_model.json +++ /dev/null @@ -1,60 +0,0 @@ -{ -"music_data": -[ - [ - [ - [ [ [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ] ], 8.125 ], - [ [ [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 0, -1, 0, 0, 0, 0 ] ], 0 ], - [ [ [ 0, 1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 0, -1, 0, 0, 0, 0 ] ], 0.375 ], - [ [ [ 0, 1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ -1, 0, 0, 0, 0, 0 ] ], 0 ], - [ [ [ 1, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ -1, 0, 0, 0, 0, 0 ] ], 0.375 ], - [ [ [ 1, 0, 0, 0, 1, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ -1, 0, 0, 0, 0, 0 ] ], 0.375 ], - [ [ [ 1, 0, -1, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ -1, 0, 0, 0, 0, 0 ] ], 0 ], - [ [ [ 1, 0, -1, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ -1, 1, 0, 0, 0, 0 ] ], 0.25 ], - [ [ [ 0, 0, 1, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ -1, 1, 0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, 0, 0, 0, 0 ], [ 1, 0, 0, 0, -1, 0 ] ], - [ [ 1, 1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, -1, 0 ] ], - [ [ 1, 1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 1, -1, 0, 0, 0 ] ] -], -"cur_uid": "720a7ee4", -"ref_uid": "nil", -"order_seed": 855344, -"dur_seed": 699760, -"motifs_seed": 648533, -"entrances_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.26424870466321, 0.75675675675676, 0.5, 0.5, 0.58549222797927, 0.72635135135135, 1, 0.5 ], -"passages_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"exits_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"ranges": [ [ -384, 2400 ], [ -507, 2400 ], [ -282, 2237 ], [ -1200, 2053 ] ], -"step_probs_vals": [ 0, 1200, 0, 0.5, 0.5, 0.5, 1, 0.5 ], -"passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], -"hd_exp": 2, -"hd_invert": 0, -"order": -[ - [ [ 1 ], [ 3, 0, 3, 0, 0, 0, 3, 0, 0, 3, 0 ], [ 2 ] ], - [ [ 2, 0, 1 ], [ 3 ], [ ] ] -], -"sus_weights": [ 0.75, 0.69, 0.75 ], -"order_size": [ 2, 6 ], -"passages_size": [ 0, 10 ], -"motif_edited": "false", -"order_edited": "false" -} \ No newline at end of file diff --git a/resources/72dbaa4c/72dbaa4c_mus_model.json b/resources/72dbaa4c/72dbaa4c_mus_model.json deleted file mode 100644 index 9561bac..0000000 --- a/resources/72dbaa4c/72dbaa4c_mus_model.json +++ /dev/null @@ -1,46 +0,0 @@ -{ -"music_data": -[ - [ - [ - [ [ [ "Rest" ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ] ], 1.625 ], - [ [ [ "Rest" ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], 3 ], - [ [ [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], 11.5 ], - [ [ [ 2, 0, 0, 0, 0, -1 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], 1.875 ], - [ [ [ 1, 1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], 9.25 ], - [ [ [ 1, 1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ] ], 1.5 ], - [ [ [ 1, 1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ] ], 2 ], - [ [ [ 1, 1, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 2.5 ], - [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 13.5 ] - ] - ] -], -"last_changes": -[ - [ [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], - [ [ 2, 0, 0, 0, 0, -1 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], - [ [ 1, 1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ] -], -"cur_uid": "72dbaa4c", -"ref_uid": "nil", -"order_seed": 403998, -"dur_seed": 276580, -"motifs_seed": 561314, -"entrances_probs_vals": [ 0, 0, 10, 0, 3.08, 0, 0.64527027027027, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"passages_probs_vals": [ 0, 0, 10, 0, 3.08, 0, 0.64527027027027, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"exits_probs_vals": [ 0, 0, 10, 0, 3.08, 0, 0.64527027027027, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"ranges": [ [ 1419.1950464396, 2400 ], [ 1519.5046439628, 2400 ], [ 1541.7956656347, 2237 ], [ 1519.5046439628, 2053 ] ], -"step_probs_vals": [ 0, 1200, 0, 0.5, 0.5, 0.5, 1, 0.5 ], -"passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], -"hd_exp": 2, -"hd_invert": 0, -"order": -[ - [ [ 2, 3, 1 ], [ 0, 0 ], [ ] ] -], -"sus_weights": [ 0.75, 0.69, 0.75 ], -"order_size": [ 1, 2 ], -"passages_size": [ 0, 2 ], -"motif_edited": "false", -"order_edited": "false" -} \ No newline at end of file diff --git a/resources/72e6131c/72e6131c_code.scd b/resources/72e6131c/72e6131c_code.scd deleted file mode 100644 index 40ae463..0000000 --- a/resources/72e6131c/72e6131c_code.scd +++ /dev/null @@ -1,1047 +0,0 @@ -( -// helper funcs -var hsArrayToCents, pDist, hdSum, hsChordalDistance, hsArrayToFreq; - -// score funcs -var isInRange, spacingScore, rangeScore, intervalScore, inclusionScore; - -// subroutines -var genTuples, initVoices, genOrders, genSubMotif, updateVoices, genDurFunc, genStepFunc; - -// primary routines -var genMotif, genSecondarySeq; - -// audition funcs -var genPatterns, genMidiPatterns; - -// resource management funcs -var seedFunc, genUID, writeResources, stringifyToDepth, setSeeds, sanityCheck, -msgInterpret, loadLedgerFile, loadLedgerJSON, loadModelFile, loadModelJSON, -setGlobalVars, globalVarsToDict, saveLedger; - -// model vars -//(model and global vars mostly set by OSC funcs -var seq, lastXChanges, -curUID, refUID, orderSeed, durSeed, motifSeed, -entrancesProbVals, passagesProbVals, exitsProbVals, -ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, -orders, susWeights, orderSize, passagesSize, -motifEdited, orderEdited; - -// model aux vars -var entrancesDurFunc, passagesDurFunc, exitsDurFunc, stepFunc; - -// other global vars -var popSize, exPath, dir, primes, dims, tuples, -group, player, ledgerPath, ledger, currentlyPlayingUID, -nameSpaces; - -// install JSON quark -if(Quarks.isInstalled("JSONlib").not, { - Quarks.install("https://github.com/musikinformatik/JSONlib.git"); - thisProcess.recompile; - //HelpBrowser.openHelpFor("Classes/JSONlib"); -}); - - -//------helper funcs - -hsArrayToCents = { - arg hsArray; - hsArray.collect({arg dist, p; dist * 1200 * log2(primes[p][0]/primes[p][1])}).sum -}; - -pDist = { - arg array1, array2, signed = false; - var pDistance; - pDistance = hsArrayToCents.value(array1) - hsArrayToCents.value(array2); - if(signed, {pDistance}, {abs(pDistance)}) -}; - -hdSum = { - arg hsArrays; - var size, distances, mean; - size = hsArrays.size; - distances = (size - 1).collect({arg i; - ((i + 1)..(size - 1)).collect({arg j; - abs(hsArrays[i] - hsArrays[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsChordalDistance = { - arg hsArrays1, hsArrays2; - var size, distances, mean; - size = hsArrays1.size; - distances = hsArrays1.size.collect({arg i; - hsArrays2.size.collect({arg j; - abs(hsArrays1[i] - hsArrays2[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsArrayToFreq = { - arg array; - array.collect({arg dim, d; pow(primes[d][0]/primes[d][1], dim)}).product -}; - -//------score funcs - -/* -isInRange = { - arg hsArray, min, max; - var cents; - cents = hsArrayToCents.value(hsArray); - (cents >= min) && (cents <= max) -}; -*/ - -spacingScore = { - arg hsArrays, min; - var centsArray; - centsArray = hsArrays.collect({arg hsArray; hsArrayToCents.value(hsArray)}).sort({arg a, b; a < b}); - centsArray.differentiate.drop(1).collect({arg pDistance; if(pDistance >= min, {1}, {0.01})}).sum; -}; - -rangeScore = { - arg hsArray1, hsArray2, min, max, low, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - if((pDistance >= min) && (pDistance <= max), {1}, {low}); -}; - -intervalScore = { - arg hsArray1, hsArray2, mean, sd, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - //pDistance.gaussCurve(1, mean, sd) - stepFunc.value(pDistance); -}; - -inclusionScore = { - arg array, test, min = 0.01; - if(array.collect({arg v; v.hash}).includes(test.hash), {min}, {1}); -}; - - -//------subroutines - -genTuples = { - var tuples; - tuples = dims.collect({[-1, 0, 1]}).allTuples.select({arg tuple; (abs(tuple.drop(1)).sum <= 1) && (tuple[0] == 0)}); - tuples = tuples ++ tuples.collect({arg tuple; [-3, -2, -1, 1, 2, 3].collect({arg octTrans; tuple.deepCopy.put(0, octTrans)})}).flatten; -}; - -initVoices = { - var init, voicesInit; - voicesInit = popSize.collect({dims.collect({0})}); - /* - voicesInit = [dims.collect({0})]; - (popSize - 1).do({ - arg rep, new; - rep = dims.rand; - new = voicesInit.last.deepCopy; - new[rep] = new[rep] + [-1, 1].choose(); - voicesInit = voicesInit.add(new); - }); - */ - voicesInit.deepCopy; -}; - -genDurFunc = {arg chordProb, minPad, maxPad, minDur, maxDur, envData, seed; - var env, pTable, durFunc; - env = Env.pairs([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).asSignal(256).asList.asArray; - pTable = env.asRandomTable; - [chordProb, minPad, maxPad, minDur, maxDur, envData].postln; - durFunc = {arg allowChord, pad = false; - var res; - res = if(allowChord.not, { - pTable.tableRand * (maxDur - minDur) + minDur - }, { - if(1.0.rand < chordProb, {0}, {pTable.tableRand * (maxDur - minDur) + minDur}); - }).round(0.125); - if(pad, {res = res + rrand(minPad.asFloat, maxPad.asFloat).round(0.125)}); - if(res.asInteger == res, {res = res.asInteger}); - res - }; - seedFunc.value(durFunc, seed); -}; - -genStepFunc = {arg minStep, maxStep, envData, seed; - var envDataNorm, env, pTable, stepFunc; - [minStep, maxStep, envData].postln; - envDataNorm = ([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).flop; - envDataNorm = [envDataNorm[0].normalize(minStep, maxStep), envDataNorm[1]].flop; - env = Env.pairs(envDataNorm); - stepFunc = {arg pDist; - env.at(pDist).clip(0.001, 1); - }; - seedFunc.value(stepFunc, seed); -}; - -genOrders = {arg minMotifLength = 1, maxMotifLength = 5, minProgLength = 0, maxProgLength = 5; - ((maxMotifLength - minMotifLength).rand + minMotifLength).collect({ - var noProgIns, noSusIns, noSilentIns, prog, sus, silent, order; - noSusIns = [1, 2, 3].wchoose(susWeights.normalizeSum); - noProgIns = (popSize - noSusIns).rand + 1; - noSilentIns = popSize - noSusIns - noProgIns; - - # prog, sus, silent = (0..(popSize-1)).scramble.clumps([noProgIns, noSusIns, noSilentIns]); - - prog = (prog.scramble ++ ((maxProgLength - minProgLength).rand + minProgLength).collect({prog.choose}).scramble); - if(silent == nil, {silent = []}); - [sus.scramble, prog, silent.scramble] - }); -}; - -updateVoices = {arg ins, sus; - var voices, candidates, nWeights, nProbs, sel; - - voices = lastXChanges.deepCopy.last; - - candidates = sus.collect({arg v; tuples.collect({arg t; voices[v] + t})}).flatten; - candidates = difference(candidates.asSet, voices.asSet).asList; - nProbs = candidates.collect({arg candidate; - var stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore; - - //stepScore = intervalScore.value(voices[ins], candidate, 30, 400, 0.1); - stepScore = intervalScore.value(voices[ins], candidate, 100, 100); - recentlySoundedScore = inclusionScore.value(lastXChanges.flop[ins], candidate, 0); - isInRangeScore = rangeScore.value(candidate, candidate.collect({0}), ranges[ins][0], ranges[ins][1], 0, true); - regScore = spacingScore.value(voices.deepCopy.put(ins, candidate), 300); - hdScore = pow(hdSum.value(voices.deepCopy.put(ins, candidate)), hdExp); - if(hdInvert == 0, {hdScore = 1/hdScore}); - //maybe what you want here is a vector to another root and then favoring movement towards it. - //distScore = pow(hsChordalDistance.value(voices, voices.put(ins, candidate)), 2); - - [stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore] - }); - - nWeights = passagesWeights; - - //this handles nWeights of 0; mainly for testing - nProbs = nProbs.flop.select({arg scores, s; nWeights[s] != 0}).flop; - nWeights = nWeights.select({arg weight; weight != 0}); - nProbs = nProbs.flop.collect({arg scores, s; - if(scores.sum == 0, {scores}, {scores.normalizeSum * nWeights[s]}) - }); - nProbs = nProbs.flop.collect({arg scores, s; scores.product}).normalizeSum; - - sel = candidates.wchoose(nProbs); - - voices[ins] = sel; - lastXChanges = lastXChanges.add(voices).keep(-5); -}; - -genSubMotif = {arg order, orderIndex, lastState, repeatLast = false, startFromLast = false, isLastOrder = false; - var sus, prog, silent, flatOrder, res, isInChord, allowChord, pad, lastXChangesHold, voices, adder; - # sus, prog, silent = order; - flatOrder = silent ++ sus ++ prog; - lastXChangesHold = lastXChanges.deepCopy; - voices = lastState.deepCopy; - isInChord = popSize.collect({false}); - allowChord = false; - pad = false; - res = []; - "------generating motif".postln; - //need to figure out here if voices move between motifs - flatOrder.do({arg ins, i; - - if(prog.includes(ins) && repeatLast.not, {updateVoices.value(ins, sus)}); - adder = if(silent.includes(ins), {["Rest"]}, {lastXChanges.last.deepCopy[ins]}); - - if(voices[ins] != adder, { - var dur; - - if((sus ++ silent).includes(ins), { - allowChord = (ins != sus.last); - pad = (ins == sus.last); - }, { - if(i < (flatOrder.size - 1), { - allowChord = (isInChord[flatOrder[i + 1]] || (ins == flatOrder[i + 1])).not; - pad = false; - }, { - allowChord = false; - pad = true - }); - }); - if((orderIndex == 0) && sus.includes(ins), { - dur = entrancesDurFunc.value(allowChord, pad); - }, { - dur = passagesDurFunc.value(allowChord, pad); - }); - if(dur == 0, {isInChord[ins] = true}, {isInChord = popSize.collect({false})}); - - voices[ins] = adder; - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - - // pad ending - if(orderIndex == (orders.size - 1), { - (0..(popSize-1)).scramble.do({arg ins; - if(res.last.first[ins] != ["Rest"], { - var dur; - voices[ins] = ["Rest"]; - allowChord = (voices != popSize.collect({["Rest"]})); - pad = allowChord.not; - dur = exitsDurFunc.value(allowChord, pad); - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - }); - - //format and return - if(startFromLast, {lastXChanges = lastXChangesHold.deepCopy}); - res; -}; - - -//------primary routines - -genMotif = { - var repeats, fSeq, fDur, durAdd; - - repeats = 1; - fSeq = []; - - repeats.do({arg index; - var motif; - - motif = []; - - orders.do({arg order, o; - var lastState, subMotif; - lastState = if(o == 0, {popSize.collect({["Rest"]})}, {motif.last.last.first}); - subMotif = genSubMotif.value(order, o, lastState, isLastOrder: o == (orders.size - 1)); - motif = motif.add(subMotif); - - }); - - sanityCheck.value(motif, index); - - fSeq = fSeq.add(motif); - }); - - //round last duration to measure - fDur = fSeq.flatten.flatten.slice(nil, 1).sum; - durAdd = fDur.round(4) - fDur; - if(durAdd < 0, {durAdd = 4 - durAdd}); - fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] = fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] + durAdd; - - fSeq -}; - -genSecondarySeq = {arg seq; - var curdles, fSeq; - curdles = []; - while({curdles.sum < seq.size}, {curdles = curdles ++ [3.rand + 1]}); - - fSeq = seq.clumps(curdles).collect({arg clump, m; - var repeats, paddedSeq; - - //add rest - paddedSeq = clump.add([[[popSize.collect({["Rest"]}), 0.5.rand]]]); - - //implement repeats - repeats = [0.rand + 1, 1].wchoose([1, 0].normalizeSum); - repeats.collect({paddedSeq}); - }); - fSeq -}; - - -//------audition funcs - -/* -Event.addEventType(\osc, { - if (~addr.postln.notNil) { - ~addr.sendMsg(~indexPath, ~indexMsg); - ~addr.sendMsg(~seqPath, stringifyToDepth.value(~seqMsg, 3)); - //~addr.sendMsg("/STATE/OPEN", (dir.replace("supercollider", "resources") +/+ ~idMsg +/+ ~idMsg ++ "_gui_state" ++ ".state").standardizePath.postln); - }; -}); -*/ - -Event.addEventType(\osc, { - if (~addr.notNil) { - ~msg; - ~addr.sendMsg(~path, *~msg); - }; -}); - -genPatterns = {arg inSeq, addr, oneShot = false; - var voices, durs, pbinds, res, indices, sectionDurs, msg, ids, seq; - seq = inSeq.collect({arg mSeq; mSeq[0]}); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - pbinds = voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs, attacks, rels, amps; - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - //attacks = 2.collect({rrand(1, 3)}) ++ freqs.drop(2).collect({rrand(0.3, 0.5)}); - attacks = fDurs.collect({arg dur; dur * rrand(0.2, 0.4)}); - //rels = freqs.drop(2).collect({rrand(0.3, 0.5)}) ++ 2.collect({rrand(1, 3)}); - rels = (clumps.size - 1).collect({arg c; - if(clumps[c + 1][0] == ["Rest"], {rrand(1.0, 3.0)}, {rrand(0.3, 0.5)}); - }); - rels = rels.add(rrand(1.0, 3.0)); - amps = freqs.collect({rrand(0.6, 0.99)}); - - [ - Pbind( - \instrument, \string_model, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \attack, Pseq(attacks, 1), - \sustain, Pseq(fDurs, 1), - \release, Pseq(rels, 1), - //\amp, Pseq(amps, 1), - \amp, Pbrown(0.5, 1, 0.5), - \busIndex, v - ), - Pbind( - \instrument, \sine, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \sustain, Pseq(fDurs, 1), - \busIndex, v - ) - ] - }).flatten; - if(oneShot.not, { - msg = inSeq.collect({arg mSeq, m; mSeq[1..]}); - //ids = inSeq.collect({arg mSeq, m; mSeq[2]}); - sectionDurs = seq.collect({arg mSeq; mSeq.flatten2(mSeq.maxDepth - 5).flop[1].sum}); - pbinds = pbinds ++ - [ - Pbind( - \type, \osc, - \addr, addr, - \path, "/playing", - \msg, Pseq(msg, 1), - \dur, Pseq(sectionDurs, 1) - ); - ] - }); - res = Ppar(pbinds); - res -}; - -/* -genMidiPatterns = {arg seq; - var voices, durs, patterns, res, mOut, pbRange; - pbRange = 1; //semitones - change this as needed for your situation - mOut = MIDIOut.newByName("TiMidity", "TiMidity port 0").latency_(Server.default.latency); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - res = Ppar( - voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs; - - mOut.program(v, 70); - - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - - Pbind( - \type, \midi, - \chan, v, - \noteval, Pseq(freqs.cpsmidi - 24, 1), - \note, Pfunc({ | event | event[\noteval].floor }), - \dur, Pseq(fDurs, 1), - \midiout, mOut, - \amp, 1, - \bend, Pfunc({ - | event | - if (event[\note].isRest.not) { - var pitchbendvalue = event[\noteval].frac.linlin(0, pbRange, 8192, 8192*2).asInteger; - m.bend(v, pitchbendvalue); - }; - 0; // return something other than nil to avoid stopping the pattern - }), - ); - }); - ); - res -}; -*/ - - -//------resource management funcs - -genUID = {Date.seed.asHexString.toLower}; - -seedFunc = {arg func, seed; - var funcArgs, next; - next = Routine({loop{func.valueArray(funcArgs).yield }}); - next.randSeed_(seed); - {arg ...args; funcArgs = args; next.value} -}; - -stringifyToDepth = {arg data, maxDepth = 1; - var prettyString = "", rCount = 0, writeArray, indent; - - if(maxDepth == 0, { - data.asCompileString - }, { - indent = {arg size; size.collect({" "}).join("")}; - writeArray = {arg array; - prettyString = prettyString ++ indent.value(rCount) ++ "[\n"; - rCount = rCount + 1; - if(rCount < maxDepth, { - array.do({arg subArray; writeArray.value(subArray)}); - }, { - prettyString = prettyString ++ array.collect({arg subArray; - indent.value(rCount + 1) ++ subArray.asCompileString - }).join(",\n"); - }); - rCount = rCount - 1; - prettyString = prettyString ++ "\n" ++ indent.value(rCount) ++ "],\n"; - }; - - writeArray.value(data); - prettyString.replace(",\n\n", "\n").drop(-2); - }) -}; - -sanityCheck = {arg motif, index; - //print functions = very helpful - ("----------" + index + "------------").postln; - - motif.flatten.do({arg val, v; - if(v > 0, { - if(motif.flatten[v-1][0].hammingDistance(val[0]) > 1, {"problem 1".postln}); - if(motif.flatten[v-1][0].hammingDistance(val[0]) == 0, {"problem 2".postln}); - }); - val.postln - }); - "***********".postln; -}; - -msgInterpret = {arg in, escapeDoubleQuotes = true, escapeSingleQuotes = true; - var res; - - res = in; - if(res.isNil.not, { - if((res.isArray && res.isString.not), { - res = res.asCompileString; - res = res.replace(" ", "").replace("\n", "").replace("\t", ""); - if(escapeSingleQuotes, {res = res.replace("\'", "")}); - if(escapeDoubleQuotes, {res = res.replace("\"", "")}); - res = res.replace("Rest", "\"Rest\""); - res = res.interpret; - }, { - var tmpRes; - if(res.every({arg char; char.isDecDigit}), {tmpRes = res.asInteger}); - if(res.contains("."), {tmpRes = res.asFloat}); - if(tmpRes != nil, {res = tmpRes}); - }); - }); - res -}; - -writeResources = {arg path, dict; - var file, modelItems, resString; - file = File(path,"w"); - - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - - resString = nameSpaces.collect({arg nameSpace; - var depth = 0, insert = " "; - if(nameSpace == "music_data", {depth = 3; insert = "\n"}); - if(nameSpace == "last_changes", {depth = 1; insert = "\n"}); - if(nameSpace == "order", {depth = 1; insert = "\n"}); - if((nameSpace == "ref_uid") && (dict[nameSpace] == nil), {dict[nameSpace] = "nil"}); - "\"" ++ nameSpace ++ "\":" ++ insert ++ stringifyToDepth.value(dict[nameSpace], depth) - }).join(",\n"); - - resString = "{\n" ++ resString ++ "\n}"; - - file.write(resString); - file.close; - resString -}; - -loadModelFile = {arg path; loadModelJSON.value(File(path, "r").readAllString.parseJSON)}; - -loadModelJSON = {arg jsonObject; - var dict; - dict = Dictionary.with(*nameSpaces.collect({arg nS; nS->msgInterpret.value(jsonObject[nS])})); - dict -}; - -setGlobalVars = {arg dict, skipLastXChanges = false; - var tmpLastXChanges; - tmpLastXChanges = lastXChanges.deepCopy; - // order really matters!!!! - # seq, lastXChanges, curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited = nameSpaces.collect({arg nS; dict[nS]}); - if(skipLastXChanges, {lastXChanges = tmpLastXChanges}); - dict -}; - -globalVarsToDict = { - var modelItems, dict; - // order really matters!!!! - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - dict = Dictionary.with(*nameSpaces.collect({arg nS, n; nS->modelItems[n]})); -}; - -loadLedgerFile = {arg path; - ledgerPath = path; - loadLedgerJSON.value(File(ledgerPath, "r").readAllString.parseJSON) -}; - -loadLedgerJSON = {arg jsonObject; ledger = jsonObject["ledger"]}; - -saveLedger = {arg ledger, path; - var file; - file = File(path, "w"); - file.write("{\n\"ledger\":\n" ++ stringifyToDepth.value(ledger, 1) ++ "\n}"); - file.close; -}; - -//------global vars - -primes = [[2, 1], [3, 2], [5, 4], [7, 4], [11, 8], [13, 8]]; -//ranges = [[-2400, 0], [-1200, 1200], [0, 2400], [0, 2400]]; -exPath = thisProcess.nowExecutingPath; -dir = exPath.dirname; -//popSize = 4; -dims = primes.size; -tuples = genTuples.value(); -//refUID = nil; -group = Group.new; -~group = group; -loadLedgerFile.value(dir +/+ ".." +/+ "resources" +/+ "piece_ledger.json"); -//passagesWeights = [1, 1, 1, 1, 1]; -//susWeights = [1, 1, 1]; -// order really matters!!!! -nameSpaces = [ - "music_data", "last_changes", "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", - "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", - "ranges", "step_probs_vals", "passages_weights", "hd_exp", "hd_invert", - "order", "sus_weights", "order_size", "passages_size", - "motif_edited", "order_edited" -]; - - -//------OSC funcs - -OSCdef(\load_ledger, {arg msg, time, addr, port; - loadLedgerFile.value(msg[1].asString); -}, \load_ledger); - -OSCdef(\load_model, {arg msg, time, addr, port; - var dict; - dict = loadModelFile.value(msg[1].asString); - setGlobalVars.value(dict); -}, \load_model); - -OSCdef(\save_ledger, {arg msg, time, addr, port; - msg.postln; - ledger = msgInterpret.value(msg[1].asString.parseJSON["ledger"], false).postln; - //loadLedgerJSON.value(msg[0]) - saveLedger.value(ledger, msg[2].asString); - //loadLedgerFile.value(msg[1].asString); -}, \save_ledger); - -OSCdef(\generate, {arg msg, time, addr, port; - var path, dict, durSeeds, musPath, modelString; - msg.postln; - - path = msg[1].asString; - - dict = loadModelFile.value(path); - setGlobalVars.value(dict, true); - - popSize = ranges.size; - - //refUID.postln; - - loadLedgerFile.value(ledgerPath); - if(ledger == nil, {ledger = ["tmp"]}); - if(ledger.last != "tmp", {ledger = ledger.add("tmp")}); - - if(refUID == nil, {lastXChanges = [initVoices.value().deepCopy]}); - if((refUID != nil) && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - lastXChanges = msgInterpret.value(file.readAllString.parseJSON["last_changes"]); - }); - - refUID.postln; - lastXChanges.collect({arg item; item.postln}); - - durSeeds = seedFunc.value({3.collect({rrand(100000, 999999)})}, durSeed).value.postln; - entrancesDurFunc = genDurFunc.valueArray(entrancesProbVals[..4] ++ [entrancesProbVals[5..]] ++ [durSeeds[0]]); - passagesDurFunc = genDurFunc.valueArray(passagesProbVals[..4] ++ [passagesProbVals[5..]] ++ [durSeeds[1]]); - exitsDurFunc = genDurFunc.valueArray(exitsProbVals[..4] ++ [exitsProbVals[5..]] ++ [durSeeds[2]]); - - if(orders == nil, { - orders = seedFunc.value(genOrders, orderSeed).valueArray(orderSize ++ passagesSize); - //addr.sendMsg("/order", stringifyToDepth.value(orders, 1)); - }); - - stepFunc = genStepFunc.valueArray(stepProbsVals[..1] ++ [stepProbsVals[2..]] ++ [motifSeed]); - seq = seedFunc.value(genMotif, motifSeed).value; - - lastXChanges.collect({arg item; item.postln}); - - dict = globalVarsToDict.value; - modelString = writeResources.value(path, dict); - - //addr.sendMsg("/generated", musPath, stringifyToDepth.value(seq, 3)); - //~seq = seq; - - addr.sendMsg("/generated", path, modelString, ledgerPath); -}, \generate); - - -OSCdef(\commit, {arg msg, time, addr, port; - var musicData, musicChanged, dict, newLedger, modelPath, musString, musFile, test1, test2, lastCurUID, commitType, commitPos; - //msg.postln; - - /* - test1 = msg[1].asString.parseJSON; - test2 = (dir +/+ ".." +/+ "resources/tmp/tmp_music" ++ ".json").standardizePath.parseJSONFile; - msgInterpret.value(test1["music"])[0][0][0][1].class.postln; - msgInterpret.value(test2["music_data"])[0][0][0][1].class.postln; - (test1["music"] == test2["music_data"]).postln; - */ - - musicData = loadModelJSON.value(msg[1].asString.parseJSON)["music_data"].postln; - musicChanged = (musicData != seq).postln; - commitType = msg[2].asString; - commitPos = msg[3].postln.asInteger; - - lastCurUID = curUID.deepCopy; - curUID = genUID.value; - - File.mkdir((dir +/+ ".." +/+ "resources" +/+ curUID).standardizePath); - File.copy(exPath, (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_code" ++ ".scd").standardizePath); - - modelPath = (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_mus_model" ++ ".json").standardizePath; - dict = globalVarsToDict.value; - if(musicChanged, { - seq = musicData; - dict["music_data"] = seq; - dict["motif_edited"] = "true" - }); - dict["cur_uid"] = curUID; - - writeResources.value(modelPath, dict); - - File.delete(ledgerPath ++ "_bak"); - File.copy(ledgerPath, ledgerPath ++ "_bak"); - File.delete(ledgerPath); - - if(commitType == "add", { - if(lastCurUID == "tmp", { - ledger = ledger.drop(-1).add(curUID); - }, { - ledger = ledger.add(curUID); - }) - }); - - if(commitType == "insert", {ledger = ledger.insert(commitPos.postln, curUID)}); - - if(commitType == "replace", {ledger = ledger.put(commitPos.postln, curUID)}); - - saveLedger.value(ledger, ledgerPath); - - addr.sendMsg("/committed", curUID, ledgerPath); - //refUID = curUID; - -}, \commit); - -OSCdef(\transport, {arg msg, time, addr, port; - msg.postln; - if(msg[1] == 0, { - group.set(\release, 2); - group.set(\gate, 0); - player.stop; - }, { - // the cued sequence can now be read from file, so this can be cleaned up - var cSize, patterns, pSeq, cuedSeek, indexStart, indexEnd, tmpLedger; - if(msg[1] == 1, { - pSeq = []; - cuedSeek = (seq != nil); - indexStart = msg[2].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.postln.parseJSON["music_data"]), path, indexStart + index, uid]); - file.close; - }); - }); - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - patterns = genPatterns.value(pSeq, addr); - }, { - pSeq = [loadModelJSON.value(msg[2].asString.parseJSON)["music_data"].postln]; - patterns = genPatterns.value(pSeq, addr, true); - }); - player = Pfset(pattern: patterns, cleanupFunc: { - addr.sendMsg("/transport", 0); - addr.sendMsg("/one_shot", 0); - }); - player = player.play - }); -}, \transport); - - -OSCdef(\transcribe_motif, {arg msg, time, addr, port; - var tSeq, refChord, refUID; - - msg.postln; - - tSeq = [loadModelJSON.value(msg[1].asString.parseJSON)["music_data"]]; - refUID = msg[2].asString.postln; - - if((refUID != "nil") && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }, { - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - }); - - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "lilypond" +/+ "includes").standardizePath, addr, "/transcribe_motif"); -}, \transcribe_motif); - - -OSCdef(\transcribe_all, {arg msg, time, addr, port; - var cSize, patterns, cuedSeek, indexStart, indexEnd, tmpLedger; - if(true, { - cuedSeek = (seq != nil); - indexStart = msg[1].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - - //tmp for testing transcription - indexEnd = (indexStart+5); - - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - var lilyPartLedgerFiles; - - lilyPartLedgerFiles = 4.collect({arg p; - File((dir +/+ ".." +/+ "lilypond" +/+ "includes" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly").standardizePath, "w"); - }); - - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file, fileString, tSeq, refUID, refChord; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - fileString = file.readAllString; - tSeq = msgInterpret.value(fileString.parseJSON["music_data"]); - refUID = msgInterpret.value(fileString.parseJSON["ref_uid"]); - file.close; - - //uid.postln; - //(refUID == "nil").postln; - - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - - if(refUID != "nil", { - path = (dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }); - - if(index != indexEnd, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath); - }, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath, addr, "/transcribe_all"); - }); - - lilyPartLedgerFiles.do({arg f, p; - f.write("\\include \".." +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly\"\n"); - }); - - }); - - lilyPartLedgerFiles.do({arg f; - f.close - }); - }); - /* - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - */ - }, { - - }); - -}, \transcribe_all); - -) - -~transcribe.value(~seq, dir); - -( -//synthdefs -~stringModelBusArray = 4.collect({Bus.audio(s, 1)}); -~sineBusArray = 4.collect({Bus.audio(s, 1)}); -~bassBusArray = 1.collect({Bus.audio(s, 1)}); -~hdustBusArray = 1.collect({Bus.audio(s, 1)}); -~samplerBusArray = 2.collect({Bus.audio(s, 1)}); -~sBuf = Buffer.alloc(s, 10, 2); -SynthDef(\string_model, {arg freq, gate = 1, sustain, amp, dur, attack, release = 1, busIndex = 0; - var trig, exc, sig1, sig2, noHarms; - noHarms = rrand(20, 40); - exc = Saw.ar(freq, TRand.ar(0.5, 1, Impulse.ar(freq))) * 0.001 + Dust.ar(10000, 0.01); - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.8).softclip; - //sig1 = HPF.ar(sig1, 300); - Out.ar(Select.kr(busIndex, ~stringModelBusArray), sig1 * amp * EnvGen.kr(Env.adsr(attack, 0.3, 0.9, release, 0.9, -3), gate, doneAction: 2)); - //Out.ar([0, 1], sig1 * EnvGen.kr(Env.asr(dur, 0.3, 1), gate, doneAction: 2)); -}).add; - -SynthDef(\sine, {arg freq, gate = 1, sustain, amp, dur, busIndex = 0; - var sig; - sig = SinOsc.ar(freq); - Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.asr(0.3, 0.4, 0.3), gate, timeScale: dur, doneAction: 2)); - //Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.sine(dur), gate, doneAction: 2)); -}).add; - -SynthDef(\mixer, {arg freq, gate = 1, sustain, amp, dur, out; - var nameSpaces, sigs; - - sigs = [~stringModelBusArray, ~sineBusArray/*, ~bassBusArray, ~hdustBusArray, ~samplerBusArray*/].collect({arg busArray, i; - var nameSpace, sig; - nameSpace = ['string', 'sine', 'bass', 'hdust', 'sampler'][i]; - sig = busArray.collect({arg bus, c; In.ar(bus, 1) * NamedControl.kr(\ ++ nameSpace ++ '_volume_' ++ c, 1, 0.1)}); - sig = sig.collect({arg channel, c; Pan2.ar(channel, NamedControl.kr(\ ++ nameSpace ++ '_pan_' ++ c, i / (busArray.size - 1), 0.1) * 2 - 1)}); - sig = sig.collect({arg channel, c; channel * NamedControl.kr(\ ++ nameSpace ++ '_mute_' ++ c, 1, 0.1)}); - sig = Mix.ar(sig) * pow(NamedControl.kr(\ ++ nameSpace ++ '_volume_master', 1, 0.1), 2); - }); - - sigs = Mix.ar(sigs / 4); - Out.ar(0, sigs) -}).add; - -SynthDef(\bass, { - var switches, drone; - switches = {|i| Dust.kr(0.1)} ! 9; - drone = {|i| var harm = pow(2, 2 - (i / 3).trunc), amp = (1 / pow(harm, 2)); - SinOsc.ar(60 * harm + TRand.kr(-3, 3, switches[i]), 0, amp)} ! 9; - Out.ar(~bassBusArray[0], Mix.new(drone) * 0.2); -}).add; - -SynthDef(\sampler, { - Out.ar(~samplerBusArray, PlayBuf.ar(2, ~sBuf, BufRateScale.kr(~sBuf), doneAction: 2)) -}).add; - -// main routine -SynthDef(\hdust, { - arg gate = 0; - var hierarchical_dust, low_sine, high_sine, brown_noise, white_noise; - // this triggers the combinations of sources - // it is similar to the Supercollider UGen called dust but with a hierarchical structure - hierarchical_dust = ( - TIRand.kr(0, 1, Impulse.kr(100)) * - TIRand.kr(0, 1, Impulse.kr(10)) * - TIRand.kr(0, 1, Impulse.kr(1)) * - TIRand.kr(0, 1, Impulse.kr(0.1)) - ); - // adjust the multiplier at the end of each line for adjusting levels - // note with each trigger, each source has a 1 in 3 chance of sounding - low_sine = SinOsc.ar(76.midicps / 16) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.1; - high_sine = SinOsc.ar(76.midicps * 8) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.01; - brown_noise = BrownNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.025; - white_noise = WhiteNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.02; - Out.ar(~hdustBusArray[0], - ((low_sine + high_sine + brown_noise + white_noise) ) - ); -}).add; - -) - -( -var bass, hdust, sampler, mixer; -/* -bass = Synth.tail(~group, \bass); -hdust = Synth.tail(~group, \hdust); -sampler = Synth.head(~group, \sampler); -*/ -mixer = Synth.tail(~group, \mixer); - -OSCdef(\mixer, {arg msg, time, addr, port; - mixer.set((msg[1] ++ '_' ++ msg[2] ++ '_' ++ msg[3]), msg[4]) -}, \mixer); - -/* -OSCdef(\sampler, {arg msg, time, addr, port; - msg.postln; - sampler.free; - ~sBuf.free; - ~sBuf = Buffer.read(s, msg[1].asString.postln, action: {sampler = Synth.head(~group, \sampler)}); -}, \sampler); -*/ -) - -/* old something -( -SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; - var trig, exc, sig1, sig2, noHarms, freqFinal, start, end; - noHarms = 30; - freq = WhiteNoise.ar * 3 + freq; - freqFinal = Duty.ar((1/freq), 0, freq); - trig = Changed.ar(freqFinal); - start = Demand.ar(trig, 0, Dwhite(-1, -0.75)); - end = Demand.ar(trig, 0, Dwhite(0.75, 1)); - exc = Phasor.ar(trig, (end - start) * freqFinal / SampleRate.ir, start, end, 0) * 0.001 + Dust.ar(10000, 0.01); - - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(2, 3)}) ], exc) * 0.5).softclip; - sig1 = HPF.ar(sig1, 300); - Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); -}).add; -) -*/ - diff --git a/resources/72e6131c/72e6131c_mus_model.json b/resources/72e6131c/72e6131c_mus_model.json deleted file mode 100644 index d66fa07..0000000 --- a/resources/72e6131c/72e6131c_mus_model.json +++ /dev/null @@ -1,89 +0,0 @@ -{ -"music_data": -[ - [ - [ - [ [ [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ] ], 0 ], - [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], - [ [ [ 1, 0, 0, 0, -1, 0 ], [ 1, 0, 0, 0, 0, 1 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, -1, 0 ] ], 9.75 ], - [ [ [ 1, 0, 0, 0, -1, 0 ], [ 1, 0, 0, 0, 0, 1 ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ] ], 0 ], - [ [ [ 1, 0, 0, 0, -1, 0 ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ] ], 0.375 ], - [ [ [ 1, 0, 0, 0, -1, 0 ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 0 ], - [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 5.5 ] - ] - ] -], -"last_changes": -[ - [ [ 1, 0, 1, 0, 0, 0 ], [ 1, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, -1, 0 ] ], - [ [ 1, 0, 1, 0, 0, 0 ], [ 1, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ] ], - [ [ 1, 0, 0, 0, -1, 0 ], [ 1, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ] ], - [ [ 1, 0, 0, 0, -1, 0 ], [ 1, 0, 0, 0, 0, 1 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ] ], - [ [ 1, 0, 0, 0, -1, 0 ], [ 1, 0, 0, 0, 0, 1 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, -1, 0 ] ] -], -"cur_uid": "72e6131c", -"ref_uid": "nil", -"order_seed": 876056, -"dur_seed": 947616, -"motifs_seed": 497194, -"entrances_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.26424870466321, 0.75675675675676, 0.5, 0.5, 0.58549222797927, 0.72635135135135, 1, 0.5 ], -"passages_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"exits_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"ranges": [ [ -384, 2400 ], [ -507, 2400 ], [ -282, 2237 ], [ -1200, 2053 ] ], -"step_probs_vals": [ 0, 1200, 0, 0.5, 0.5, 0.5, 1, 0.5 ], -"passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], -"hd_exp": 2, -"hd_invert": 0, -"order": -[ - [ [ 1, 2, 0 ], [ 3, 3, 3, 3, 3 ], [ ] ], - [ [ 2 ], [ 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1 ], [ 3 ] ], - [ [ 0, 2, 3 ], [ 1, 1, 1, 1, 1 ], [ ] ], - [ [ 0, 2, 1 ], [ 3 ], [ ] ], - [ [ 2 ], [ 0, 1, 3, 3, 0, 1, 3 ], [ ] ] -], -"sus_weights": [ 0.75, 0.69, 0.75 ], -"order_size": [ 2, 6 ], -"passages_size": [ 0, 10 ], -"motif_edited": "false", -"order_edited": "false" -} \ No newline at end of file diff --git a/resources/730ad6b9/730ad6b9_code.scd b/resources/730ad6b9/730ad6b9_code.scd deleted file mode 100644 index ab2dc17..0000000 --- a/resources/730ad6b9/730ad6b9_code.scd +++ /dev/null @@ -1,1046 +0,0 @@ -( -// helper funcs -var hsArrayToCents, pDist, hdSum, hsChordalDistance, hsArrayToFreq; - -// score funcs -var isInRange, spacingScore, rangeScore, intervalScore, inclusionScore; - -// subroutines -var genTuples, initVoices, genOrders, genSubMotif, updateVoices, genDurFunc, genStepFunc; - -// primary routines -var genMotif, genSecondarySeq; - -// audition funcs -var genPatterns, genMidiPatterns; - -// resource management funcs -var seedFunc, genUID, writeResources, stringifyToDepth, setSeeds, sanityCheck, -msgInterpret, loadLedgerFile, loadLedgerJSON, loadModelFile, loadModelJSON, -setGlobalVars, globalVarsToDict, saveLedger; - -// model vars -//(model and global vars mostly set by OSC funcs -var seq, lastXChanges, -curUID, refUID, orderSeed, durSeed, motifSeed, -entrancesProbVals, passagesProbVals, exitsProbVals, -ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, -orders, susWeights, orderSize, passagesSize, -motifEdited, orderEdited; - -// model aux vars -var entrancesDurFunc, passagesDurFunc, exitsDurFunc, stepFunc; - -// other global vars -var popSize, exPath, dir, primes, dims, tuples, -group, player, ledgerPath, ledger, currentlyPlayingUID, -nameSpaces; - -// install JSON quark -if(Quarks.isInstalled("JSONlib").not, { - Quarks.install("https://github.com/musikinformatik/JSONlib.git"); - thisProcess.recompile; - //HelpBrowser.openHelpFor("Classes/JSONlib"); -}); - - -//------helper funcs - -hsArrayToCents = { - arg hsArray; - hsArray.collect({arg dist, p; dist * 1200 * log2(primes[p][0]/primes[p][1])}).sum -}; - -pDist = { - arg array1, array2, signed = false; - var pDistance; - pDistance = hsArrayToCents.value(array1) - hsArrayToCents.value(array2); - if(signed, {pDistance}, {abs(pDistance)}) -}; - -hdSum = { - arg hsArrays; - var size, distances, mean; - size = hsArrays.size; - distances = (size - 1).collect({arg i; - ((i + 1)..(size - 1)).collect({arg j; - abs(hsArrays[i] - hsArrays[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsChordalDistance = { - arg hsArrays1, hsArrays2; - var size, distances, mean; - size = hsArrays1.size; - distances = hsArrays1.size.collect({arg i; - hsArrays2.size.collect({arg j; - abs(hsArrays1[i] - hsArrays2[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsArrayToFreq = { - arg array; - array.collect({arg dim, d; pow(primes[d][0]/primes[d][1], dim)}).product -}; - -//------score funcs - -/* -isInRange = { - arg hsArray, min, max; - var cents; - cents = hsArrayToCents.value(hsArray); - (cents >= min) && (cents <= max) -}; -*/ - -spacingScore = { - arg hsArrays, min; - var centsArray; - centsArray = hsArrays.collect({arg hsArray; hsArrayToCents.value(hsArray)}).sort({arg a, b; a < b}); - centsArray.differentiate.drop(1).collect({arg pDistance; if(pDistance >= min, {1}, {0.01})}).sum; -}; - -rangeScore = { - arg hsArray1, hsArray2, min, max, low, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - if((pDistance >= min) && (pDistance <= max), {1}, {low}); -}; - -intervalScore = { - arg hsArray1, hsArray2, mean, sd, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - //pDistance.gaussCurve(1, mean, sd) - stepFunc.value(pDistance); -}; - -inclusionScore = { - arg array, test, min = 0.01; - if(array.collect({arg v; v.hash}).includes(test.hash), {min}, {1}); -}; - - -//------subroutines - -genTuples = { - var tuples; - tuples = dims.collect({[-1, 0, 1]}).allTuples.select({arg tuple; (abs(tuple.drop(1)).sum <= 1) && (tuple[0] == 0)}); - tuples = tuples ++ tuples.collect({arg tuple; [-3, -2, -1, 1, 2, 3].collect({arg octTrans; tuple.deepCopy.put(0, octTrans)})}).flatten; -}; - -initVoices = { - var init, voicesInit; - voicesInit = popSize.collect({dims.collect({0})}); - /* - voicesInit = [dims.collect({0})]; - (popSize - 1).do({ - arg rep, new; - rep = dims.rand; - new = voicesInit.last.deepCopy; - new[rep] = new[rep] + [-1, 1].choose(); - voicesInit = voicesInit.add(new); - }); - */ - voicesInit.deepCopy; -}; - -genDurFunc = {arg chordProb, minPad, maxPad, minDur, maxDur, envData, seed; - var env, pTable, durFunc; - env = Env.pairs([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).asSignal(256).asList.asArray; - pTable = env.asRandomTable; - [chordProb, minPad, maxPad, minDur, maxDur, envData].postln; - durFunc = {arg allowChord, pad = false; - var res; - res = if(allowChord.not, { - pTable.tableRand * (maxDur - minDur) + minDur - }, { - if(1.0.rand < chordProb, {0}, {pTable.tableRand * (maxDur - minDur) + minDur}); - }).round(0.125); - if(pad, {res = res + rrand(minPad.asFloat, maxPad.asFloat).round(0.125)}); - if(res.asInteger == res, {res = res.asInteger}); - res - }; - seedFunc.value(durFunc, seed); -}; - -genStepFunc = {arg minStep, maxStep, envData, seed; - var envDataNorm, env, pTable, stepFunc; - [minStep, maxStep, envData].postln; - envDataNorm = ([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).flop; - envDataNorm = [envDataNorm[0].normalize(minStep, maxStep), envDataNorm[1]].flop; - env = Env.pairs(envDataNorm); - stepFunc = {arg pDist; - env.at(pDist).clip(0.001, 1); - }; - seedFunc.value(stepFunc, seed); -}; - -genOrders = {arg minMotifLength = 1, maxMotifLength = 5, minProgLength = 0, maxProgLength = 5; - ((maxMotifLength - minMotifLength).rand + minMotifLength).collect({ - var noProgIns, noSusIns, noSilentIns, prog, sus, silent, order; - noSusIns = [1, 2, 3].wchoose(susWeights.normalizeSum); - noProgIns = (popSize - noSusIns).rand + 1; - noSilentIns = popSize - noSusIns - noProgIns; - - # prog, sus, silent = (0..(popSize-1)).scramble.clumps([noProgIns, noSusIns, noSilentIns]); - - prog = (prog.scramble ++ ((maxProgLength - minProgLength).rand + minProgLength).collect({prog.choose}).scramble); - if(silent == nil, {silent = []}); - [sus.scramble, prog, silent.scramble] - }); -}; - -updateVoices = {arg ins, sus; - var voices, candidates, nWeights, nProbs, sel; - - voices = lastXChanges.deepCopy.last; - - candidates = sus.collect({arg v; tuples.collect({arg t; voices[v] + t})}).flatten; - candidates = difference(candidates.asSet, voices.asSet).asList; - nProbs = candidates.collect({arg candidate; - var stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore; - - //stepScore = intervalScore.value(voices[ins], candidate, 30, 400, 0.1); - stepScore = intervalScore.value(voices[ins], candidate, 100, 100); - recentlySoundedScore = inclusionScore.value(lastXChanges.flop[ins], candidate, 0); - isInRangeScore = rangeScore.value(candidate, candidate.collect({0}), ranges[ins][0], ranges[ins][1], 0, true); - regScore = spacingScore.value(voices.deepCopy.put(ins, candidate), 300); - hdScore = pow(hdSum.value(voices.deepCopy.put(ins, candidate)), hdExp); - if(hdInvert == 0, {hdScore = 1/hdScore}); - //maybe what you want here is a vector to another root and then favoring movement towards it. - //distScore = pow(hsChordalDistance.value(voices, voices.put(ins, candidate)), 2); - - [stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore] - }); - - nWeights = passagesWeights; - - //this handles nWeights of 0; mainly for testing - nProbs = nProbs.flop.select({arg scores, s; nWeights[s] != 0}).flop; - nWeights = nWeights.select({arg weight; weight != 0}); - nProbs = nProbs.flop.collect({arg scores, s; - if(scores.sum == 0, {scores}, {scores.normalizeSum * nWeights[s]}) - }); - nProbs = nProbs.flop.collect({arg scores, s; scores.product}).normalizeSum; - - sel = candidates.wchoose(nProbs); - - voices[ins] = sel; - lastXChanges = lastXChanges.add(voices).keep(-5); -}; - -genSubMotif = {arg order, orderIndex, lastState, repeatLast = false, startFromLast = false, isLastOrder = false; - var sus, prog, silent, flatOrder, res, isInChord, allowChord, pad, lastXChangesHold, voices, adder; - # sus, prog, silent = order; - flatOrder = silent ++ sus ++ prog; - lastXChangesHold = lastXChanges.deepCopy; - voices = lastState.deepCopy; - isInChord = popSize.collect({false}); - allowChord = false; - pad = false; - res = []; - "------generating motif".postln; - //need to figure out here if voices move between motifs - flatOrder.do({arg ins, i; - - if(prog.includes(ins) && repeatLast.not, {updateVoices.value(ins, sus)}); - adder = if(silent.includes(ins), {["Rest"]}, {lastXChanges.last.deepCopy[ins]}); - - if(voices[ins] != adder, { - var dur; - - if((sus ++ silent).includes(ins), { - allowChord = (ins != sus.last); - pad = (ins == sus.last); - }, { - if(i < (flatOrder.size - 1), { - allowChord = (isInChord[flatOrder[i + 1]] || (ins == flatOrder[i + 1])).not; - pad = false; - }, { - allowChord = false; - pad = true - }); - }); - if((orderIndex == 0) && sus.includes(ins), { - dur = entrancesDurFunc.value(allowChord, pad); - }, { - dur = passagesDurFunc.value(allowChord, pad); - }); - if(dur == 0, {isInChord[ins] = true}, {isInChord = popSize.collect({false})}); - - voices[ins] = adder; - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - - // pad ending - if(orderIndex == (orders.size - 1), { - (0..(popSize-1)).scramble.do({arg ins; - if(res.last.first[ins] != ["Rest"], { - var dur; - voices[ins] = ["Rest"]; - allowChord = (voices != popSize.collect({["Rest"]})); - pad = allowChord.not; - dur = exitsDurFunc.value(allowChord, pad); - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - }); - - //format and return - if(startFromLast, {lastXChanges = lastXChangesHold.deepCopy}); - res; -}; - - -//------primary routines - -genMotif = { - var repeats, fSeq, fDur, durAdd; - - repeats = 1; - fSeq = []; - - repeats.do({arg index; - var motif; - - motif = []; - - orders.do({arg order, o; - var lastState, subMotif; - lastState = if(o == 0, {popSize.collect({["Rest"]})}, {motif.last.last.first}); - subMotif = genSubMotif.value(order, o, lastState, isLastOrder: o == (orders.size - 1)); - motif = motif.add(subMotif); - - }); - - sanityCheck.value(motif, index); - - fSeq = fSeq.add(motif); - }); - - //round last duration to measure - fDur = fSeq.flatten.flatten.slice(nil, 1).sum; - durAdd = fDur.round(4) - fDur; - if(durAdd < 0, {durAdd = 4 - durAdd}); - fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] = fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] + durAdd; - - fSeq -}; - -genSecondarySeq = {arg seq; - var curdles, fSeq; - curdles = []; - while({curdles.sum < seq.size}, {curdles = curdles ++ [3.rand + 1]}); - - fSeq = seq.clumps(curdles).collect({arg clump, m; - var repeats, paddedSeq; - - //add rest - paddedSeq = clump.add([[[popSize.collect({["Rest"]}), 0.5.rand]]]); - - //implement repeats - repeats = [0.rand + 1, 1].wchoose([1, 0].normalizeSum); - repeats.collect({paddedSeq}); - }); - fSeq -}; - - -//------audition funcs - -/* -Event.addEventType(\osc, { - if (~addr.postln.notNil) { - ~addr.sendMsg(~indexPath, ~indexMsg); - ~addr.sendMsg(~seqPath, stringifyToDepth.value(~seqMsg, 3)); - //~addr.sendMsg("/STATE/OPEN", (dir.replace("supercollider", "resources") +/+ ~idMsg +/+ ~idMsg ++ "_gui_state" ++ ".state").standardizePath.postln); - }; -}); -*/ - -Event.addEventType(\osc, { - if (~addr.notNil) { - ~msg; - ~addr.sendMsg(~path, *~msg); - }; -}); - -genPatterns = {arg inSeq, addr, oneShot = false; - var voices, durs, pbinds, res, indices, sectionDurs, msg, ids, seq; - seq = inSeq.collect({arg mSeq; mSeq[0]}); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - pbinds = voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs, attacks, rels, amps; - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - //attacks = 2.collect({rrand(1, 3)}) ++ freqs.drop(2).collect({rrand(0.3, 0.5)}); - attacks = fDurs.collect({arg dur; dur * rrand(0.2, 0.4)}); - //rels = freqs.drop(2).collect({rrand(0.3, 0.5)}) ++ 2.collect({rrand(1, 3)}); - rels = (clumps.size - 1).collect({arg c; - if(clumps[c + 1][0] == ["Rest"], {rrand(1.0, 3.0)}, {rrand(0.3, 0.5)}); - }); - rels = rels.add(rrand(1.0, 3.0)); - amps = freqs.collect({rrand(0.6, 0.99)}); - - [ - Pbind( - \instrument, \string_model, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \attack, Pseq(attacks, 1), - \sustain, Pseq(fDurs, 1), - \release, Pseq(rels, 1), - //\amp, Pseq(amps, 1), - \amp, Pbrown(0.5, 1, 0.5), - \busIndex, v - ), - Pbind( - \instrument, \sine, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \sustain, Pseq(fDurs, 1), - \busIndex, v - ) - ] - }).flatten; - if(oneShot.not, { - msg = inSeq.collect({arg mSeq, m; mSeq[1..]}); - //ids = inSeq.collect({arg mSeq, m; mSeq[2]}); - sectionDurs = seq.collect({arg mSeq; mSeq.flatten2(mSeq.maxDepth - 5).flop[1].sum}); - pbinds = pbinds ++ - [ - Pbind( - \type, \osc, - \addr, addr, - \path, "/playing", - \msg, Pseq(msg, 1), - \dur, Pseq(sectionDurs, 1) - ); - ] - }); - res = Ppar(pbinds); - res -}; - -/* -genMidiPatterns = {arg seq; - var voices, durs, patterns, res, mOut, pbRange; - pbRange = 1; //semitones - change this as needed for your situation - mOut = MIDIOut.newByName("TiMidity", "TiMidity port 0").latency_(Server.default.latency); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - res = Ppar( - voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs; - - mOut.program(v, 70); - - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - - Pbind( - \type, \midi, - \chan, v, - \noteval, Pseq(freqs.cpsmidi - 24, 1), - \note, Pfunc({ | event | event[\noteval].floor }), - \dur, Pseq(fDurs, 1), - \midiout, mOut, - \amp, 1, - \bend, Pfunc({ - | event | - if (event[\note].isRest.not) { - var pitchbendvalue = event[\noteval].frac.linlin(0, pbRange, 8192, 8192*2).asInteger; - m.bend(v, pitchbendvalue); - }; - 0; // return something other than nil to avoid stopping the pattern - }), - ); - }); - ); - res -}; -*/ - - -//------resource management funcs - -genUID = {Date.seed.asHexString.toLower}; - -seedFunc = {arg func, seed; - var funcArgs, next; - next = Routine({loop{func.valueArray(funcArgs).yield }}); - next.randSeed_(seed); - {arg ...args; funcArgs = args; next.value} -}; - -stringifyToDepth = {arg data, maxDepth = 1; - var prettyString = "", rCount = 0, writeArray, indent; - - if(maxDepth == 0, { - data.asCompileString - }, { - indent = {arg size; size.collect({" "}).join("")}; - writeArray = {arg array; - prettyString = prettyString ++ indent.value(rCount) ++ "[\n"; - rCount = rCount + 1; - if(rCount < maxDepth, { - array.do({arg subArray; writeArray.value(subArray)}); - }, { - prettyString = prettyString ++ array.collect({arg subArray; - indent.value(rCount + 1) ++ subArray.asCompileString - }).join(",\n"); - }); - rCount = rCount - 1; - prettyString = prettyString ++ "\n" ++ indent.value(rCount) ++ "],\n"; - }; - - writeArray.value(data); - prettyString.replace(",\n\n", "\n").drop(-2); - }) -}; - -sanityCheck = {arg motif, index; - //print functions = very helpful - ("----------" + index + "------------").postln; - - motif.flatten.do({arg val, v; - if(v > 0, { - if(motif.flatten[v-1][0].hammingDistance(val[0]) > 1, {"problem 1".postln}); - if(motif.flatten[v-1][0].hammingDistance(val[0]) == 0, {"problem 2".postln}); - }); - val.postln - }); - "***********".postln; -}; - -msgInterpret = {arg in, escapeDoubleQuotes = true, escapeSingleQuotes = true; - var res; - - res = in; - if(res.isNil.not, { - if((res.isArray && res.isString.not), { - res = res.asCompileString; - res = res.replace(" ", "").replace("\n", "").replace("\t", ""); - if(escapeSingleQuotes, {res = res.replace("\'", "")}); - if(escapeDoubleQuotes, {res = res.replace("\"", "")}); - res = res.replace("Rest", "\"Rest\""); - res = res.interpret; - }, { - var tmpRes; - if(res.every({arg char; char.isDecDigit}), {tmpRes = res.asInteger}); - if(res.contains("."), {tmpRes = res.asFloat}); - if(tmpRes != nil, {res = tmpRes}); - }); - }); - res -}; - -writeResources = {arg path, dict; - var file, modelItems, resString; - file = File(path,"w"); - - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - - resString = nameSpaces.collect({arg nameSpace; - var depth = 0, insert = " "; - if(nameSpace == "music_data", {depth = 3; insert = "\n"}); - if(nameSpace == "last_changes", {depth = 1; insert = "\n"}); - if(nameSpace == "order", {depth = 1; insert = "\n"}); - if((nameSpace == "ref_uid") && (dict[nameSpace] == nil), {dict[nameSpace] = "nil"}); - "\"" ++ nameSpace ++ "\":" ++ insert ++ stringifyToDepth.value(dict[nameSpace], depth) - }).join(",\n"); - - resString = "{\n" ++ resString ++ "\n}"; - - file.write(resString); - file.close; - resString -}; - -loadModelFile = {arg path; loadModelJSON.value(File(path, "r").readAllString.parseJSON)}; - -loadModelJSON = {arg jsonObject; - var dict; - dict = Dictionary.with(*nameSpaces.collect({arg nS; nS->msgInterpret.value(jsonObject[nS])})); - dict -}; - -setGlobalVars = {arg dict, skipLastXChanges = false; - var tmpLastXChanges; - tmpLastXChanges = lastXChanges.deepCopy; - // order really matters!!!! - # seq, lastXChanges, curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited = nameSpaces.collect({arg nS; dict[nS]}); - if(skipLastXChanges, {lastXChanges = tmpLastXChanges}); - dict -}; - -globalVarsToDict = { - var modelItems, dict; - // order really matters!!!! - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - dict = Dictionary.with(*nameSpaces.collect({arg nS, n; nS->modelItems[n]})); -}; - -loadLedgerFile = {arg path; - ledgerPath = path; - loadLedgerJSON.value(File(ledgerPath, "r").readAllString.parseJSON) -}; - -loadLedgerJSON = {arg jsonObject; ledger = jsonObject["ledger"]}; - -saveLedger = {arg ledger, path; - var file; - file = File(path, "w"); - file.write("{\n\"ledger\":\n" ++ stringifyToDepth.value(ledger, 1) ++ "\n}"); - file.close; -}; - -//------global vars - -primes = [[2, 1], [3, 2], [5, 4], [7, 4], [11, 8], [13, 8]]; -//ranges = [[-2400, 0], [-1200, 1200], [0, 2400], [0, 2400]]; -exPath = thisProcess.nowExecutingPath; -dir = exPath.dirname; -//popSize = 4; -dims = primes.size; -tuples = genTuples.value(); -//refUID = nil; -group = Group.new; -~group = group; -loadLedgerFile.value(dir +/+ ".." +/+ "resources" +/+ "piece_ledger.json"); -//passagesWeights = [1, 1, 1, 1, 1]; -//susWeights = [1, 1, 1]; -// order really matters!!!! -nameSpaces = [ - "music_data", "last_changes", "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", - "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", - "ranges", "step_probs_vals", "passages_weights", "hd_exp", "hd_invert", - "order", "sus_weights", "order_size", "passages_size", - "motif_edited", "order_edited" -]; - - -//------OSC funcs - -OSCdef(\load_ledger, {arg msg, time, addr, port; - loadLedgerFile.value(msg[1].asString); -}, \load_ledger); - -OSCdef(\load_model, {arg msg, time, addr, port; - var dict; - dict = loadModelFile.value(msg[1].asString); - setGlobalVars.value(dict); -}, \load_model); - -OSCdef(\save_ledger, {arg msg, time, addr, port; - msg.postln; - ledger = msgInterpret.value(msg[1].asString.parseJSON["ledger"], false).postln; - //loadLedgerJSON.value(msg[0]) - saveLedger.value(ledger, msg[2].asString); - //loadLedgerFile.value(msg[1].asString); -}, \save_ledger); - -OSCdef(\generate, {arg msg, time, addr, port; - var path, dict, durSeeds, musPath, modelString; - msg.postln; - - path = msg[1].asString; - - dict = loadModelFile.value(path); - setGlobalVars.value(dict, true); - - popSize = ranges.size; - - //refUID.postln; - - loadLedgerFile.value(ledgerPath); - if(ledger == nil, {ledger = ["tmp"]}); - if(ledger.last != "tmp", {ledger = ledger.add("tmp")}); - - if(refUID == nil, {lastXChanges = [initVoices.value().deepCopy]}); - if((refUID != nil) && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - lastXChanges = msgInterpret.value(file.readAllString.parseJSON["last_changes"]); - }); - - refUID.postln; - lastXChanges.collect({arg item; item.postln}); - - durSeeds = seedFunc.value({3.collect({rrand(100000, 999999)})}, durSeed).value.postln; - entrancesDurFunc = genDurFunc.valueArray(entrancesProbVals[..4] ++ [entrancesProbVals[5..]] ++ [durSeeds[0]]); - passagesDurFunc = genDurFunc.valueArray(passagesProbVals[..4] ++ [passagesProbVals[5..]] ++ [durSeeds[1]]); - exitsDurFunc = genDurFunc.valueArray(exitsProbVals[..4] ++ [exitsProbVals[5..]] ++ [durSeeds[2]]); - - if(orders == nil, { - orders = seedFunc.value(genOrders, orderSeed).valueArray(orderSize ++ passagesSize); - //addr.sendMsg("/order", stringifyToDepth.value(orders, 1)); - }); - - stepFunc = genStepFunc.valueArray(stepProbsVals[..1] ++ [stepProbsVals[2..]] ++ [motifSeed]); - seq = seedFunc.value(genMotif, motifSeed).value; - - lastXChanges.collect({arg item; item.postln}); - - dict = globalVarsToDict.value; - modelString = writeResources.value(path, dict); - - //addr.sendMsg("/generated", musPath, stringifyToDepth.value(seq, 3)); - //~seq = seq; - - addr.sendMsg("/generated", path, modelString, ledgerPath); -}, \generate); - - -OSCdef(\commit, {arg msg, time, addr, port; - var musicData, musicChanged, dict, newLedger, modelPath, musString, musFile, test1, test2, lastCurUID, commitType; - //msg.postln; - - /* - test1 = msg[1].asString.parseJSON; - test2 = (dir +/+ ".." +/+ "resources/tmp/tmp_music" ++ ".json").standardizePath.parseJSONFile; - msgInterpret.value(test1["music"])[0][0][0][1].class.postln; - msgInterpret.value(test2["music_data"])[0][0][0][1].class.postln; - (test1["music"] == test2["music_data"]).postln; - */ - - musicData = loadModelJSON.value(msg[1].asString.parseJSON)["music_data"].postln; - musicChanged = (musicData != seq).postln; - commitType = msg[2].asString; - - lastCurUID = curUID.deepCopy; - curUID = genUID.value; - - File.mkdir((dir +/+ ".." +/+ "resources" +/+ curUID).standardizePath); - File.copy(exPath, (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_code" ++ ".scd").standardizePath); - - modelPath = (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_mus_model" ++ ".json").standardizePath; - dict = globalVarsToDict.value; - if(musicChanged, { - seq = musicData; - dict["music_data"] = seq; - dict["motif_edited"] = "true" - }); - dict["cur_uid"] = curUID; - - writeResources.value(modelPath, dict); - - File.delete(ledgerPath ++ "_bak"); - File.copy(ledgerPath, ledgerPath ++ "_bak"); - File.delete(ledgerPath); - - if(commitType == "add", { - if(lastCurUID == "tmp", { - ledger = ledger.drop(-1).add(curUID); - }, { - ledger = ledger.add(curUID); - }) - }); - - if(commitType == "insert", {ledger = ledger.insert(ledger.indexOf(lastCurUID), curUID)}); - - if(commitType == "replace", {ledger = ledger.put(ledger.indexOf(lastCurUID), curUID)}); - - saveLedger.value(ledger, ledgerPath); - - addr.sendMsg("/committed", curUID, ledgerPath); - //refUID = curUID; - -}, \commit); - -OSCdef(\transport, {arg msg, time, addr, port; - msg.postln; - if(msg[1] == 0, { - group.set(\release, 2); - group.set(\gate, 0); - player.stop; - }, { - // the cued sequence can now be read from file, so this can be cleaned up - var cSize, patterns, pSeq, cuedSeek, indexStart, indexEnd, tmpLedger; - if(msg[1] == 1, { - pSeq = []; - cuedSeek = (seq != nil); - indexStart = msg[2].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.postln.parseJSON["music_data"]), path, indexStart + index, uid]); - file.close; - }); - }); - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - patterns = genPatterns.value(pSeq, addr); - }, { - pSeq = [loadModelJSON.value(msg[2].asString.parseJSON)["music_data"].postln]; - patterns = genPatterns.value(pSeq, addr, true); - }); - player = Pfset(pattern: patterns, cleanupFunc: { - addr.sendMsg("/transport", 0); - addr.sendMsg("/one_shot", 0); - }); - player = player.play - }); -}, \transport); - - -OSCdef(\transcribe_motif, {arg msg, time, addr, port; - var tSeq, refChord, refUID; - - msg.postln; - - tSeq = [loadModelJSON.value(msg[1].asString.parseJSON)["music_data"]]; - refUID = msg[2].asString.postln; - - if((refUID != "nil") && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }, { - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - }); - - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "lilypond" +/+ "includes").standardizePath, addr, "/transcribe_motif"); -}, \transcribe_motif); - - -OSCdef(\transcribe_all, {arg msg, time, addr, port; - var cSize, patterns, cuedSeek, indexStart, indexEnd, tmpLedger; - if(true, { - cuedSeek = (seq != nil); - indexStart = msg[1].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - - //tmp for testing transcription - indexEnd = (indexStart+5); - - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - var lilyPartLedgerFiles; - - lilyPartLedgerFiles = 4.collect({arg p; - File((dir +/+ ".." +/+ "lilypond" +/+ "includes" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly").standardizePath, "w"); - }); - - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file, fileString, tSeq, refUID, refChord; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - fileString = file.readAllString; - tSeq = msgInterpret.value(fileString.parseJSON["music_data"]); - refUID = msgInterpret.value(fileString.parseJSON["ref_uid"]); - file.close; - - //uid.postln; - //(refUID == "nil").postln; - - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - - if(refUID != "nil", { - path = (dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }); - - if(index != indexEnd, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath); - }, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath, addr, "/transcribe_all"); - }); - - lilyPartLedgerFiles.do({arg f, p; - f.write("\\include \".." +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly\"\n"); - }); - - }); - - lilyPartLedgerFiles.do({arg f; - f.close - }); - }); - /* - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - */ - }, { - - }); - -}, \transcribe_all); - -) - -~transcribe.value(~seq, dir); - -( -//synthdefs -~stringModelBusArray = 4.collect({Bus.audio(s, 1)}); -~sineBusArray = 4.collect({Bus.audio(s, 1)}); -~bassBusArray = 1.collect({Bus.audio(s, 1)}); -~hdustBusArray = 1.collect({Bus.audio(s, 1)}); -~samplerBusArray = 2.collect({Bus.audio(s, 1)}); -~sBuf = Buffer.alloc(s, 10, 2); -SynthDef(\string_model, {arg freq, gate = 1, sustain, amp, dur, attack, release = 1, busIndex = 0; - var trig, exc, sig1, sig2, noHarms; - noHarms = rrand(20, 40); - exc = Saw.ar(freq, TRand.ar(0.5, 1, Impulse.ar(freq))) * 0.001 + Dust.ar(10000, 0.01); - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.8).softclip; - //sig1 = HPF.ar(sig1, 300); - Out.ar(Select.kr(busIndex, ~stringModelBusArray), sig1 * amp * EnvGen.kr(Env.adsr(attack, 0.3, 0.9, release, 0.9, -3), gate, doneAction: 2)); - //Out.ar([0, 1], sig1 * EnvGen.kr(Env.asr(dur, 0.3, 1), gate, doneAction: 2)); -}).add; - -SynthDef(\sine, {arg freq, gate = 1, sustain, amp, dur, busIndex = 0; - var sig; - sig = SinOsc.ar(freq); - Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.asr(0.3, 0.4, 0.3), gate, timeScale: dur, doneAction: 2)); - //Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.sine(dur), gate, doneAction: 2)); -}).add; - -SynthDef(\mixer, {arg freq, gate = 1, sustain, amp, dur, out; - var nameSpaces, sigs; - - sigs = [~stringModelBusArray, ~sineBusArray/*, ~bassBusArray, ~hdustBusArray, ~samplerBusArray*/].collect({arg busArray, i; - var nameSpace, sig; - nameSpace = ['string', 'sine', 'bass', 'hdust', 'sampler'][i]; - sig = busArray.collect({arg bus, c; In.ar(bus, 1) * NamedControl.kr(\ ++ nameSpace ++ '_volume_' ++ c, 1, 0.1)}); - sig = sig.collect({arg channel, c; Pan2.ar(channel, NamedControl.kr(\ ++ nameSpace ++ '_pan_' ++ c, i / (busArray.size - 1), 0.1) * 2 - 1)}); - sig = sig.collect({arg channel, c; channel * NamedControl.kr(\ ++ nameSpace ++ '_mute_' ++ c, 1, 0.1)}); - sig = Mix.ar(sig) * pow(NamedControl.kr(\ ++ nameSpace ++ '_volume_master', 1, 0.1), 2); - }); - - sigs = Mix.ar(sigs / 4); - Out.ar(0, sigs) -}).add; - -SynthDef(\bass, { - var switches, drone; - switches = {|i| Dust.kr(0.1)} ! 9; - drone = {|i| var harm = pow(2, 2 - (i / 3).trunc), amp = (1 / pow(harm, 2)); - SinOsc.ar(60 * harm + TRand.kr(-3, 3, switches[i]), 0, amp)} ! 9; - Out.ar(~bassBusArray[0], Mix.new(drone) * 0.2); -}).add; - -SynthDef(\sampler, { - Out.ar(~samplerBusArray, PlayBuf.ar(2, ~sBuf, BufRateScale.kr(~sBuf), doneAction: 2)) -}).add; - -// main routine -SynthDef(\hdust, { - arg gate = 0; - var hierarchical_dust, low_sine, high_sine, brown_noise, white_noise; - // this triggers the combinations of sources - // it is similar to the Supercollider UGen called dust but with a hierarchical structure - hierarchical_dust = ( - TIRand.kr(0, 1, Impulse.kr(100)) * - TIRand.kr(0, 1, Impulse.kr(10)) * - TIRand.kr(0, 1, Impulse.kr(1)) * - TIRand.kr(0, 1, Impulse.kr(0.1)) - ); - // adjust the multiplier at the end of each line for adjusting levels - // note with each trigger, each source has a 1 in 3 chance of sounding - low_sine = SinOsc.ar(76.midicps / 16) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.1; - high_sine = SinOsc.ar(76.midicps * 8) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.01; - brown_noise = BrownNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.025; - white_noise = WhiteNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.02; - Out.ar(~hdustBusArray[0], - ((low_sine + high_sine + brown_noise + white_noise) ) - ); -}).add; - -) - -( -var bass, hdust, sampler, mixer; -/* -bass = Synth.tail(~group, \bass); -hdust = Synth.tail(~group, \hdust); -sampler = Synth.head(~group, \sampler); -*/ -mixer = Synth.tail(~group, \mixer); - -OSCdef(\mixer, {arg msg, time, addr, port; - mixer.set((msg[1] ++ '_' ++ msg[2] ++ '_' ++ msg[3]), msg[4]) -}, \mixer); - -/* -OSCdef(\sampler, {arg msg, time, addr, port; - msg.postln; - sampler.free; - ~sBuf.free; - ~sBuf = Buffer.read(s, msg[1].asString.postln, action: {sampler = Synth.head(~group, \sampler)}); -}, \sampler); -*/ -) - -/* old something -( -SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; - var trig, exc, sig1, sig2, noHarms, freqFinal, start, end; - noHarms = 30; - freq = WhiteNoise.ar * 3 + freq; - freqFinal = Duty.ar((1/freq), 0, freq); - trig = Changed.ar(freqFinal); - start = Demand.ar(trig, 0, Dwhite(-1, -0.75)); - end = Demand.ar(trig, 0, Dwhite(0.75, 1)); - exc = Phasor.ar(trig, (end - start) * freqFinal / SampleRate.ir, start, end, 0) * 0.001 + Dust.ar(10000, 0.01); - - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(2, 3)}) ], exc) * 0.5).softclip; - sig1 = HPF.ar(sig1, 300); - Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); -}).add; -) -*/ - diff --git a/resources/74d9b3e1/74d9b3e1_code.scd b/resources/74d9b3e1/74d9b3e1_code.scd deleted file mode 100644 index 55bfebd..0000000 --- a/resources/74d9b3e1/74d9b3e1_code.scd +++ /dev/null @@ -1,1033 +0,0 @@ -( -// helper funcs -var hsArrayToCents, pDist, hdSum, hsChordalDistance, hsArrayToFreq; - -// score funcs -var isInRange, spacingScore, rangeScore, intervalScore, inclusionScore; - -// subroutines -var genTuples, initVoices, genOrders, genSubMotif, updateVoices, genDurFunc, genStepFunc; - -// primary routines -var genMotif, genSecondarySeq; - -// audition funcs -var genPatterns, genMidiPatterns; - -// resource management funcs -var seedFunc, genUID, writeResources, stringifyToDepth, setSeeds, sanityCheck, -msgInterpret, loadLedgerFile, loadLedgerJSON, loadModelFile, loadModelJSON, -setGlobalVars, globalVarsToDict, saveLedger; - -// model vars -//(model and global vars mostly set by OSC funcs -var seq, lastXChanges, -curUID, refUID, orderSeed, durSeed, motifSeed, -entrancesProbVals, passagesProbVals, exitsProbVals, -ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, -orders, susWeights, orderSize, passagesSize, -motifEdited, orderEdited; - -// model aux vars -var entrancesDurFunc, passagesDurFunc, exitsDurFunc, stepFunc; - -// other global vars -var popSize, exPath, dir, primes, dims, tuples, -group, player, ledgerPath, ledger, currentlyPlayingUID, -nameSpaces; - -// install JSON quark -if(Quarks.isInstalled("JSONlib").not, { - Quarks.install("https://github.com/musikinformatik/JSONlib.git"); - thisProcess.recompile; - //HelpBrowser.openHelpFor("Classes/JSONlib"); -}); - - -//------helper funcs - -hsArrayToCents = { - arg hsArray; - hsArray.collect({arg dist, p; dist * 1200 * log2(primes[p][0]/primes[p][1])}).sum -}; - -pDist = { - arg array1, array2, signed = false; - var pDistance; - pDistance = hsArrayToCents.value(array1) - hsArrayToCents.value(array2); - if(signed, {pDistance}, {abs(pDistance)}) -}; - -hdSum = { - arg hsArrays; - var size, distances, mean; - size = hsArrays.size; - distances = (size - 1).collect({arg i; - ((i + 1)..(size - 1)).collect({arg j; - abs(hsArrays[i] - hsArrays[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsChordalDistance = { - arg hsArrays1, hsArrays2; - var size, distances, mean; - size = hsArrays1.size; - distances = hsArrays1.size.collect({arg i; - hsArrays2.size.collect({arg j; - abs(hsArrays1[i] - hsArrays2[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsArrayToFreq = { - arg array; - array.collect({arg dim, d; pow(primes[d][0]/primes[d][1], dim)}).product -}; - -//------score funcs - -/* -isInRange = { - arg hsArray, min, max; - var cents; - cents = hsArrayToCents.value(hsArray); - (cents >= min) && (cents <= max) -}; -*/ - -spacingScore = { - arg hsArrays, min; - var centsArray; - centsArray = hsArrays.collect({arg hsArray; hsArrayToCents.value(hsArray)}).sort({arg a, b; a < b}); - centsArray.differentiate.drop(1).collect({arg pDistance; if(pDistance >= min, {1}, {0.01})}).sum; -}; - -rangeScore = { - arg hsArray1, hsArray2, min, max, low, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - if((pDistance >= min) && (pDistance <= max), {1}, {low}); -}; - -intervalScore = { - arg hsArray1, hsArray2, mean, sd, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - //pDistance.gaussCurve(1, mean, sd) - stepFunc.value(pDistance); -}; - -inclusionScore = { - arg array, test, min = 0.01; - if(array.collect({arg v; v.hash}).includes(test.hash), {min}, {1}); -}; - - -//------subroutines - -genTuples = { - var tuples; - tuples = dims.collect({[-1, 0, 1]}).allTuples.select({arg tuple; (abs(tuple.drop(1)).sum <= 1) && (tuple[0] == 0)}); - tuples = tuples ++ tuples.collect({arg tuple; [-3, -2, -1, 1, 2, 3].collect({arg octTrans; tuple.deepCopy.put(0, octTrans)})}).flatten; -}; - -initVoices = { - var init, voicesInit; - voicesInit = popSize.collect({dims.collect({0})}); - /* - voicesInit = [dims.collect({0})]; - (popSize - 1).do({ - arg rep, new; - rep = dims.rand; - new = voicesInit.last.deepCopy; - new[rep] = new[rep] + [-1, 1].choose(); - voicesInit = voicesInit.add(new); - }); - */ - voicesInit.deepCopy; -}; - -genDurFunc = {arg chordProb, minPad, maxPad, minDur, maxDur, envData, seed; - var env, pTable, durFunc; - env = Env.pairs([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).asSignal(256).asList.asArray; - pTable = env.asRandomTable; - [chordProb, minPad, maxPad, minDur, maxDur, envData].postln; - durFunc = {arg allowChord, pad = false; - var res; - res = if(allowChord.not, { - pTable.tableRand * (maxDur - minDur) + minDur - }, { - if(1.0.rand < chordProb, {0}, {pTable.tableRand * (maxDur - minDur) + minDur}); - }).round(0.125); - if(pad, {res = res + rrand(minPad.asFloat, maxPad.asFloat).round(0.125)}); - if(res.asInteger == res, {res = res.asInteger}); - res - }; - seedFunc.value(durFunc, seed); -}; - -genStepFunc = {arg minStep, maxStep, envData, seed; - var envDataNorm, env, pTable, stepFunc; - [minStep, maxStep, envData].postln; - envDataNorm = ([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).flop; - envDataNorm = [envDataNorm[0].normalize(minStep, maxStep), envDataNorm[1]].flop; - env = Env.pairs(envDataNorm); - stepFunc = {arg pDist; - env.at(pDist).clip(0.001, 1); - }; - seedFunc.value(stepFunc, seed); -}; - -genOrders = {arg minMotifLength = 1, maxMotifLength = 5, minProgLength = 0, maxProgLength = 5; - ((maxMotifLength - minMotifLength).rand + minMotifLength).collect({ - var noProgIns, noSusIns, noSilentIns, prog, sus, silent, order; - noSusIns = [1, 2, 3].wchoose(susWeights.normalizeSum); - noProgIns = (popSize - noSusIns).rand + 1; - noSilentIns = popSize - noSusIns - noProgIns; - - # prog, sus, silent = (0..(popSize-1)).scramble.clumps([noProgIns, noSusIns, noSilentIns]); - - prog = (prog.scramble ++ ((maxProgLength - minProgLength).rand + minProgLength).collect({prog.choose}).scramble); - if(silent == nil, {silent = []}); - [sus.scramble, prog, silent.scramble] - }); -}; - -updateVoices = {arg ins, sus; - var voices, candidates, nWeights, nProbs, sel; - - voices = lastXChanges.deepCopy.last; - - candidates = sus.collect({arg v; tuples.collect({arg t; voices[v] + t})}).flatten; - candidates = difference(candidates.asSet, voices.asSet).asList; - nProbs = candidates.collect({arg candidate; - var stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore; - - //stepScore = intervalScore.value(voices[ins], candidate, 30, 400, 0.1); - stepScore = intervalScore.value(voices[ins], candidate, 100, 100); - recentlySoundedScore = inclusionScore.value(lastXChanges.flop[ins], candidate, 0); - isInRangeScore = rangeScore.value(candidate, candidate.collect({0}), ranges[ins][0], ranges[ins][1], 0, true); - regScore = spacingScore.value(voices.deepCopy.put(ins, candidate), 300); - hdScore = pow(hdSum.value(voices.deepCopy.put(ins, candidate)), hdExp); - if(hdInvert == 0, {hdScore = 1/hdScore}); - //maybe what you want here is a vector to another root and then favoring movement towards it. - //distScore = pow(hsChordalDistance.value(voices, voices.put(ins, candidate)), 2); - - [stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore] - }); - - nWeights = passagesWeights; - - //this handles nWeights of 0; mainly for testing - nProbs = nProbs.flop.select({arg scores, s; nWeights[s] != 0}).flop; - nWeights = nWeights.select({arg weight; weight != 0}); - nProbs = nProbs.flop.collect({arg scores, s; - if(scores.sum == 0, {scores}, {scores.normalizeSum * nWeights[s]}) - }); - nProbs = nProbs.flop.collect({arg scores, s; scores.product}).normalizeSum; - - sel = candidates.wchoose(nProbs); - - voices[ins] = sel; - lastXChanges = lastXChanges.add(voices).keep(-5); -}; - -genSubMotif = {arg order, orderIndex, lastState, repeatLast = false, startFromLast = false, isLastOrder = false; - var sus, prog, silent, flatOrder, res, isInChord, allowChord, pad, lastXChangesHold, voices, adder; - # sus, prog, silent = order; - flatOrder = silent ++ sus ++ prog; - lastXChangesHold = lastXChanges.deepCopy; - voices = lastState.deepCopy; - isInChord = popSize.collect({false}); - allowChord = false; - pad = false; - res = []; - "------generating motif".postln; - //need to figure out here if voices move between motifs - flatOrder.do({arg ins, i; - - if(prog.includes(ins) && repeatLast.not, {updateVoices.value(ins, sus)}); - adder = if(silent.includes(ins), {["Rest"]}, {lastXChanges.last.deepCopy[ins]}); - - if(voices[ins] != adder, { - var dur; - - if((sus ++ silent).includes(ins), { - allowChord = (ins != sus.last); - pad = (ins == sus.last); - }, { - if(i < (flatOrder.size - 1), { - allowChord = (isInChord[flatOrder[i + 1]] || (ins == flatOrder[i + 1])).not; - pad = false; - }, { - allowChord = false; - pad = true - }); - }); - if((orderIndex == 0) && sus.includes(ins), { - dur = entrancesDurFunc.value(allowChord, pad); - }, { - dur = passagesDurFunc.value(allowChord, pad); - }); - if(dur == 0, {isInChord[ins] = true}, {isInChord = popSize.collect({false})}); - - voices[ins] = adder; - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - - // pad ending - if(orderIndex == (orders.size - 1), { - (0..(popSize-1)).scramble.do({arg ins; - if(res.last.first[ins] != ["Rest"], { - var dur; - voices[ins] = ["Rest"]; - allowChord = (voices != popSize.collect({["Rest"]})); - pad = allowChord.not; - dur = exitsDurFunc.value(allowChord, pad); - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - }); - - //format and return - if(startFromLast, {lastXChanges = lastXChangesHold.deepCopy}); - res; -}; - - -//------primary routines - -genMotif = { - var repeats, fSeq, fDur, durAdd; - - repeats = 1; - fSeq = []; - - repeats.do({arg index; - var motif; - - motif = []; - - orders.do({arg order, o; - var lastState, subMotif; - lastState = if(o == 0, {popSize.collect({["Rest"]})}, {motif.last.last.first}); - subMotif = genSubMotif.value(order, o, lastState, isLastOrder: o == (orders.size - 1)); - motif = motif.add(subMotif); - - }); - - sanityCheck.value(motif, index); - - fSeq = fSeq.add(motif); - }); - - //round last duration to measure - fDur = fSeq.flatten.flatten.slice(nil, 1).sum; - durAdd = fDur.round(4) - fDur; - if(durAdd < 0, {durAdd = 4 - durAdd}); - fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] = fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] + durAdd; - - fSeq -}; - -genSecondarySeq = {arg seq; - var curdles, fSeq; - curdles = []; - while({curdles.sum < seq.size}, {curdles = curdles ++ [3.rand + 1]}); - - fSeq = seq.clumps(curdles).collect({arg clump, m; - var repeats, paddedSeq; - - //add rest - paddedSeq = clump.add([[[popSize.collect({["Rest"]}), 0.5.rand]]]); - - //implement repeats - repeats = [0.rand + 1, 1].wchoose([1, 0].normalizeSum); - repeats.collect({paddedSeq}); - }); - fSeq -}; - - -//------audition funcs - -/* -Event.addEventType(\osc, { - if (~addr.postln.notNil) { - ~addr.sendMsg(~indexPath, ~indexMsg); - ~addr.sendMsg(~seqPath, stringifyToDepth.value(~seqMsg, 3)); - //~addr.sendMsg("/STATE/OPEN", (dir.replace("supercollider", "resources") +/+ ~idMsg +/+ ~idMsg ++ "_gui_state" ++ ".state").standardizePath.postln); - }; -}); -*/ - -Event.addEventType(\osc, { - if (~addr.notNil) { - ~msg; - ~addr.sendMsg(~path, *~msg); - }; -}); - -genPatterns = {arg inSeq, addr, oneShot = false; - var voices, durs, pbinds, res, indices, sectionDurs, msg, ids, seq; - seq = inSeq.collect({arg mSeq; mSeq[0]}); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - pbinds = voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs, attacks, rels, amps; - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - //attacks = 2.collect({rrand(1, 3)}) ++ freqs.drop(2).collect({rrand(0.3, 0.5)}); - attacks = fDurs.collect({arg dur; dur * rrand(0.2, 0.4)}); - //rels = freqs.drop(2).collect({rrand(0.3, 0.5)}) ++ 2.collect({rrand(1, 3)}); - rels = (clumps.size - 1).collect({arg c; - if(clumps[c + 1][0] == ["Rest"], {rrand(1.0, 3.0)}, {rrand(0.3, 0.5)}); - }); - rels = rels.add(rrand(1.0, 3.0)); - amps = freqs.collect({rrand(0.6, 0.99)}); - - [ - Pbind( - \instrument, \string_model, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \attack, Pseq(attacks, 1), - \sustain, Pseq(fDurs, 1), - \release, Pseq(rels, 1), - //\amp, Pseq(amps, 1), - \amp, Pbrown(0.5, 1, 0.5), - \busIndex, v - ), - Pbind( - \instrument, \sine, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \sustain, Pseq(fDurs, 1), - \busIndex, v - ) - ] - }).flatten; - if(oneShot.not, { - msg = inSeq.collect({arg mSeq, m; mSeq[1..]}); - //ids = inSeq.collect({arg mSeq, m; mSeq[2]}); - sectionDurs = seq.collect({arg mSeq; mSeq.flatten2(mSeq.maxDepth - 5).flop[1].sum}); - pbinds = pbinds ++ - [ - Pbind( - \type, \osc, - \addr, addr, - \path, "/playing", - \msg, Pseq(msg, 1), - \dur, Pseq(sectionDurs, 1) - ); - ] - }); - res = Ppar(pbinds); - res -}; - -/* -genMidiPatterns = {arg seq; - var voices, durs, patterns, res, mOut, pbRange; - pbRange = 1; //semitones - change this as needed for your situation - mOut = MIDIOut.newByName("TiMidity", "TiMidity port 0").latency_(Server.default.latency); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - res = Ppar( - voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs; - - mOut.program(v, 70); - - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - - Pbind( - \type, \midi, - \chan, v, - \noteval, Pseq(freqs.cpsmidi - 24, 1), - \note, Pfunc({ | event | event[\noteval].floor }), - \dur, Pseq(fDurs, 1), - \midiout, mOut, - \amp, 1, - \bend, Pfunc({ - | event | - if (event[\note].isRest.not) { - var pitchbendvalue = event[\noteval].frac.linlin(0, pbRange, 8192, 8192*2).asInteger; - m.bend(v, pitchbendvalue); - }; - 0; // return something other than nil to avoid stopping the pattern - }), - ); - }); - ); - res -}; -*/ - - -//------resource management funcs - -genUID = {Date.seed.asHexString.toLower}; - -seedFunc = {arg func, seed; - var funcArgs, next; - next = Routine({loop{func.valueArray(funcArgs).yield }}); - next.randSeed_(seed); - {arg ...args; funcArgs = args; next.value} -}; - -stringifyToDepth = {arg data, maxDepth = 1; - var prettyString = "", rCount = 0, writeArray, indent; - - if(maxDepth == 0, { - data.asCompileString - }, { - indent = {arg size; size.collect({" "}).join("")}; - writeArray = {arg array; - prettyString = prettyString ++ indent.value(rCount) ++ "[\n"; - rCount = rCount + 1; - if(rCount < maxDepth, { - array.do({arg subArray; writeArray.value(subArray)}); - }, { - prettyString = prettyString ++ array.collect({arg subArray; - indent.value(rCount + 1) ++ subArray.asCompileString - }).join(",\n"); - }); - rCount = rCount - 1; - prettyString = prettyString ++ "\n" ++ indent.value(rCount) ++ "],\n"; - }; - - writeArray.value(data); - prettyString.replace(",\n\n", "\n").drop(-2); - }) -}; - -sanityCheck = {arg motif, index; - //print functions = very helpful - ("----------" + index + "------------").postln; - - motif.flatten.do({arg val, v; - if(v > 0, { - if(motif.flatten[v-1][0].hammingDistance(val[0]) > 1, {"problem 1".postln}); - if(motif.flatten[v-1][0].hammingDistance(val[0]) == 0, {"problem 2".postln}); - }); - val.postln - }); - "***********".postln; -}; - -msgInterpret = {arg in, escapeDoubleQuotes = true, escapeSingleQuotes = true; - var res; - - res = in; - if(res.isNil.not, { - if((res.isArray && res.isString.not), { - res = res.asCompileString; - res = res.replace(" ", "").replace("\n", "").replace("\t", ""); - if(escapeSingleQuotes, {res = res.replace("\'", "")}); - if(escapeDoubleQuotes, {res = res.replace("\"", "")}); - res = res.replace("Rest", "\"Rest\""); - res = res.interpret; - }, { - var tmpRes; - if(res.every({arg char; char.isDecDigit}), {tmpRes = res.asInteger}); - if(res.contains("."), {tmpRes = res.asFloat}); - if(tmpRes != nil, {res = tmpRes}); - }); - }); - res -}; - -writeResources = {arg path, dict; - var file, modelItems, resString; - file = File(path,"w"); - - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - - resString = nameSpaces.collect({arg nameSpace; - var depth = 0, insert = " "; - if(nameSpace == "music_data", {depth = 3; insert = "\n"}); - if(nameSpace == "last_changes", {depth = 1; insert = "\n"}); - if(nameSpace == "order", {depth = 1; insert = "\n"}); - if((nameSpace == "ref_uid") && (dict[nameSpace] == nil), {dict[nameSpace] = "nil"}); - "\"" ++ nameSpace ++ "\":" ++ insert ++ stringifyToDepth.value(dict[nameSpace], depth) - }).join(",\n"); - - resString = "{\n" ++ resString ++ "\n}"; - - file.write(resString); - file.close; - resString -}; - -loadModelFile = {arg path; loadModelJSON.value(File(path, "r").readAllString.parseJSON)}; - -loadModelJSON = {arg jsonObject; - var dict; - dict = Dictionary.with(*nameSpaces.collect({arg nS; nS->msgInterpret.value(jsonObject[nS])})); - dict -}; - -setGlobalVars = {arg dict, skipLastXChanges = false; - var tmpLastXChanges; - tmpLastXChanges = lastXChanges.deepCopy; - // order really matters!!!! - # seq, lastXChanges, curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited = nameSpaces.collect({arg nS; dict[nS]}); - if(skipLastXChanges, {lastXChanges = tmpLastXChanges}); - dict -}; - -globalVarsToDict = { - var modelItems, dict; - // order really matters!!!! - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - dict = Dictionary.with(*nameSpaces.collect({arg nS, n; nS->modelItems[n]})); -}; - -loadLedgerFile = {arg path; - ledgerPath = path; - loadLedgerJSON.value(File(ledgerPath, "r").readAllString.parseJSON) -}; - -loadLedgerJSON = {arg jsonObject; ledger = jsonObject["ledger"]}; - -saveLedger = {arg ledger, path; - var file; - file = File(path, "w"); - file.write("{\n\"ledger\":\n" ++ stringifyToDepth.value(ledger, 1) ++ "\n}"); - file.close; -}; - -//------global vars - -primes = [[2, 1], [3, 2], [5, 4], [7, 4], [11, 8], [13, 8]]; -//ranges = [[-2400, 0], [-1200, 1200], [0, 2400], [0, 2400]]; -exPath = thisProcess.nowExecutingPath; -dir = exPath.dirname; -//popSize = 4; -dims = primes.size; -tuples = genTuples.value(); -//refUID = nil; -group = Group.new; -~group = group; -loadLedgerFile.value(dir +/+ ".." +/+ "resources" +/+ "piece_ledger.json"); -//passagesWeights = [1, 1, 1, 1, 1]; -//susWeights = [1, 1, 1]; -// order really matters!!!! -nameSpaces = [ - "music_data", "last_changes", "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", - "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", - "ranges", "step_probs_vals", "passages_weights", "hd_exp", "hd_invert", - "order", "sus_weights", "order_size", "passages_size", - "motif_edited", "order_edited" -]; - - -//------OSC funcs - -OSCdef(\load_ledger, {arg msg, time, addr, port; - loadLedgerFile.value(msg[1].asString); -}, \load_ledger); - -OSCdef(\load_model, {arg msg, time, addr, port; - var dict; - dict = loadModelFile.value(msg[1].asString); - setGlobalVars.value(dict); -}, \load_model); - -OSCdef(\save_ledger, {arg msg, time, addr, port; - msg.postln; - ledger = msgInterpret.value(msg[1].asString.parseJSON["ledger"], false).postln; - //loadLedgerJSON.value(msg[0]) - saveLedger.value(ledger, msg[2].asString); - //loadLedgerFile.value(msg[1].asString); -}, \save_ledger); - -OSCdef(\generate, {arg msg, time, addr, port; - var path, dict, durSeeds, musPath, modelString; - msg.postln; - - path = msg[1].asString; - - dict = loadModelFile.value(path); - setGlobalVars.value(dict, true); - - popSize = ranges.size; - - //refUID.postln; - - loadLedgerFile.value(ledgerPath); - if(ledger == nil, {ledger = ["tmp"]}); - if(ledger.last != "tmp", {ledger = ledger.add("tmp")}); - - if(refUID == nil, {lastXChanges = [initVoices.value().deepCopy]}); - if((refUID != nil) && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - lastXChanges = msgInterpret.value(file.readAllString.parseJSON["last_changes"]); - }); - - refUID.postln; - lastXChanges.collect({arg item; item.postln}); - - durSeeds = seedFunc.value({3.collect({rrand(100000, 999999)})}, durSeed).value.postln; - entrancesDurFunc = genDurFunc.valueArray(entrancesProbVals[..4] ++ [entrancesProbVals[5..]] ++ [durSeeds[0]]); - passagesDurFunc = genDurFunc.valueArray(passagesProbVals[..4] ++ [passagesProbVals[5..]] ++ [durSeeds[1]]); - exitsDurFunc = genDurFunc.valueArray(exitsProbVals[..4] ++ [exitsProbVals[5..]] ++ [durSeeds[2]]); - - if(orders == nil, { - orders = seedFunc.value(genOrders, orderSeed).valueArray(orderSize ++ passagesSize); - //addr.sendMsg("/order", stringifyToDepth.value(orders, 1)); - }); - - stepFunc = genStepFunc.valueArray(stepProbsVals[..1] ++ [stepProbsVals[2..]] ++ [motifSeed]); - seq = seedFunc.value(genMotif, motifSeed).value; - - lastXChanges.collect({arg item; item.postln}); - - dict = globalVarsToDict.value; - modelString = writeResources.value(path, dict); - - //addr.sendMsg("/generated", musPath, stringifyToDepth.value(seq, 3)); - //~seq = seq; - - addr.sendMsg("/generated", path, modelString, ledgerPath); -}, \generate); - - -OSCdef(\commit, {arg msg, time, addr, port; - var musicData, musicChanged, dict, newLedger, modelPath, musString, musFile, test1, test2; - //msg.postln; - - /* - test1 = msg[1].asString.parseJSON; - test2 = (dir +/+ ".." +/+ "resources/tmp/tmp_music" ++ ".json").standardizePath.parseJSONFile; - msgInterpret.value(test1["music"])[0][0][0][1].class.postln; - msgInterpret.value(test2["music_data"])[0][0][0][1].class.postln; - (test1["music"] == test2["music_data"]).postln; - */ - - musicData = loadModelJSON.value(msg[1].asString.parseJSON)["music_data"].postln; - musicChanged = (musicData != seq).postln; - - curUID = genUID.value; - - File.mkdir((dir +/+ ".." +/+ "resources" +/+ curUID).standardizePath); - File.copy(exPath, (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_code" ++ ".scd").standardizePath); - - modelPath = (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_mus_model" ++ ".json").standardizePath; - dict = globalVarsToDict.value; - if(musicChanged, { - seq = musicData; - dict["music_data"] = seq; - dict["motif_edited"] = "true" - }); - dict["cur_uid"] = curUID; - - writeResources.value(modelPath, dict); - - File.delete(ledgerPath ++ "_bak"); - File.copy(ledgerPath, ledgerPath ++ "_bak"); - File.delete(ledgerPath); - ledger = ledger.drop(-1).add(curUID); - - saveLedger.value(ledger, ledgerPath); - - addr.sendMsg("/committed", curUID, ledgerPath); - //refUID = curUID; - -}, \commit); - -OSCdef(\transport, {arg msg, time, addr, port; - msg.postln; - if(msg[1] == 0, { - group.set(\release, 2); - group.set(\gate, 0); - player.stop; - }, { - // the cued sequence can now be read from file, so this can be cleaned up - var cSize, patterns, pSeq, cuedSeek, indexStart, indexEnd, tmpLedger; - if(msg[1] == 1, { - pSeq = []; - cuedSeek = (seq != nil); - indexStart = msg[2].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.postln.parseJSON["music_data"]), path, indexStart + index, uid]); - file.close; - }); - }); - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - patterns = genPatterns.value(pSeq, addr); - }, { - pSeq = [loadModelJSON.value(msg[2].asString.parseJSON)["music_data"].postln]; - patterns = genPatterns.value(pSeq, addr, true); - }); - player = Pfset(pattern: patterns, cleanupFunc: { - addr.sendMsg("/transport", 0); - addr.sendMsg("/one_shot", 0); - }); - player = player.play - }); -}, \transport); - - -OSCdef(\transcribe_motif, {arg msg, time, addr, port; - var tSeq, refChord, refUID; - - msg.postln; - - tSeq = [loadModelJSON.value(msg[1].asString.parseJSON)["music_data"]]; - refUID = msg[2].asString.postln; - - if((refUID != "nil") && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }, { - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - }); - - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "lilypond" +/+ "includes").standardizePath, addr, "/transcribe_motif"); -}, \transcribe_motif); - - -OSCdef(\transcribe_all, {arg msg, time, addr, port; - var cSize, patterns, cuedSeek, indexStart, indexEnd, tmpLedger; - if(true, { - cuedSeek = (seq != nil); - indexStart = msg[1].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - - //tmp for testing transcription - indexEnd = (indexStart+5); - - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - var lilyPartLedgerFiles; - - lilyPartLedgerFiles = 4.collect({arg p; - File((dir +/+ ".." +/+ "lilypond" +/+ "includes" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly").standardizePath, "w"); - }); - - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file, fileString, tSeq, refUID, refChord; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - fileString = file.readAllString; - tSeq = msgInterpret.value(fileString.parseJSON["music_data"]); - refUID = msgInterpret.value(fileString.parseJSON["ref_uid"]); - file.close; - - //uid.postln; - //(refUID == "nil").postln; - - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - - if(refUID != "nil", { - path = (dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }); - - if(index != indexEnd, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath); - }, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath, addr, "/transcribe_all"); - }); - - lilyPartLedgerFiles.do({arg f, p; - f.write("\\include \".." +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly\"\n"); - }); - - }); - - lilyPartLedgerFiles.do({arg f; - f.close - }); - }); - /* - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - */ - }, { - - }); - -}, \transcribe_all); - -) - -~transcribe.value(~seq, dir); - -( -//synthdefs -~stringModelBusArray = 4.collect({Bus.audio(s, 1)}); -~sineBusArray = 4.collect({Bus.audio(s, 1)}); -~bassBusArray = 1.collect({Bus.audio(s, 1)}); -~hdustBusArray = 1.collect({Bus.audio(s, 1)}); -~samplerBusArray = 2.collect({Bus.audio(s, 1)}); -~sBuf = Buffer.alloc(s, 10, 2); -SynthDef(\string_model, {arg freq, gate = 1, sustain, amp, dur, attack, release = 1, busIndex = 0; - var trig, exc, sig1, sig2, noHarms; - noHarms = rrand(20, 40); - exc = Saw.ar(freq, TRand.ar(0.5, 1, Impulse.ar(freq))) * 0.001 + Dust.ar(10000, 0.01); - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.8).softclip; - //sig1 = HPF.ar(sig1, 300); - Out.ar(Select.kr(busIndex, ~stringModelBusArray), sig1 * amp * EnvGen.kr(Env.adsr(attack, 0.3, 0.9, release, 0.9, -3), gate, doneAction: 2)); - //Out.ar([0, 1], sig1 * EnvGen.kr(Env.asr(dur, 0.3, 1), gate, doneAction: 2)); -}).add; - -SynthDef(\sine, {arg freq, gate = 1, sustain, amp, dur, busIndex = 0; - var sig; - sig = SinOsc.ar(freq); - Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.asr(0.3, 0.4, 0.3), gate, timeScale: dur, doneAction: 2)); - //Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.sine(dur), gate, doneAction: 2)); -}).add; - -SynthDef(\mixer, {arg freq, gate = 1, sustain, amp, dur, out; - var nameSpaces, sigs; - - sigs = [~stringModelBusArray, ~sineBusArray/*, ~bassBusArray, ~hdustBusArray, ~samplerBusArray*/].collect({arg busArray, i; - var nameSpace, sig; - nameSpace = ['string', 'sine', 'bass', 'hdust', 'sampler'][i]; - sig = busArray.collect({arg bus, c; In.ar(bus, 1) * NamedControl.kr(\ ++ nameSpace ++ '_volume_' ++ c, 1, 0.1)}); - sig = sig.collect({arg channel, c; Pan2.ar(channel, NamedControl.kr(\ ++ nameSpace ++ '_pan_' ++ c, i / (busArray.size - 1), 0.1) * 2 - 1)}); - sig = sig.collect({arg channel, c; channel * NamedControl.kr(\ ++ nameSpace ++ '_mute_' ++ c, 1, 0.1)}); - sig = Mix.ar(sig) * pow(NamedControl.kr(\ ++ nameSpace ++ '_volume_master', 1, 0.1), 2); - }); - - sigs = Mix.ar(sigs / 4); - Out.ar(0, sigs) -}).add; - -SynthDef(\bass, { - var switches, drone; - switches = {|i| Dust.kr(0.1)} ! 9; - drone = {|i| var harm = pow(2, 2 - (i / 3).trunc), amp = (1 / pow(harm, 2)); - SinOsc.ar(60 * harm + TRand.kr(-3, 3, switches[i]), 0, amp)} ! 9; - Out.ar(~bassBusArray[0], Mix.new(drone) * 0.2); -}).add; - -SynthDef(\sampler, { - Out.ar(~samplerBusArray, PlayBuf.ar(2, ~sBuf, BufRateScale.kr(~sBuf), doneAction: 2)) -}).add; - -// main routine -SynthDef(\hdust, { - arg gate = 0; - var hierarchical_dust, low_sine, high_sine, brown_noise, white_noise; - // this triggers the combinations of sources - // it is similar to the Supercollider UGen called dust but with a hierarchical structure - hierarchical_dust = ( - TIRand.kr(0, 1, Impulse.kr(100)) * - TIRand.kr(0, 1, Impulse.kr(10)) * - TIRand.kr(0, 1, Impulse.kr(1)) * - TIRand.kr(0, 1, Impulse.kr(0.1)) - ); - // adjust the multiplier at the end of each line for adjusting levels - // note with each trigger, each source has a 1 in 3 chance of sounding - low_sine = SinOsc.ar(76.midicps / 16) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.1; - high_sine = SinOsc.ar(76.midicps * 8) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.01; - brown_noise = BrownNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.025; - white_noise = WhiteNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.02; - Out.ar(~hdustBusArray[0], - ((low_sine + high_sine + brown_noise + white_noise) ) - ); -}).add; - -) - -( -var bass, hdust, sampler, mixer; -/* -bass = Synth.tail(~group, \bass); -hdust = Synth.tail(~group, \hdust); -sampler = Synth.head(~group, \sampler); -*/ -mixer = Synth.tail(~group, \mixer); - -OSCdef(\mixer, {arg msg, time, addr, port; - mixer.set((msg[1] ++ '_' ++ msg[2] ++ '_' ++ msg[3]), msg[4]) -}, \mixer); - -/* -OSCdef(\sampler, {arg msg, time, addr, port; - msg.postln; - sampler.free; - ~sBuf.free; - ~sBuf = Buffer.read(s, msg[1].asString.postln, action: {sampler = Synth.head(~group, \sampler)}); -}, \sampler); -*/ -) - -/* old something -( -SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; - var trig, exc, sig1, sig2, noHarms, freqFinal, start, end; - noHarms = 30; - freq = WhiteNoise.ar * 3 + freq; - freqFinal = Duty.ar((1/freq), 0, freq); - trig = Changed.ar(freqFinal); - start = Demand.ar(trig, 0, Dwhite(-1, -0.75)); - end = Demand.ar(trig, 0, Dwhite(0.75, 1)); - exc = Phasor.ar(trig, (end - start) * freqFinal / SampleRate.ir, start, end, 0) * 0.001 + Dust.ar(10000, 0.01); - - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(2, 3)}) ], exc) * 0.5).softclip; - sig1 = HPF.ar(sig1, 300); - Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); -}).add; -) -*/ - diff --git a/resources/74d9b3e1/74d9b3e1_mus_model.json b/resources/74d9b3e1/74d9b3e1_mus_model.json deleted file mode 100644 index e69de29..0000000 diff --git a/resources/75837171/75837171_code.scd b/resources/75837171/75837171_code.scd deleted file mode 100644 index 47fbb43..0000000 --- a/resources/75837171/75837171_code.scd +++ /dev/null @@ -1,1046 +0,0 @@ -( -// helper funcs -var hsArrayToCents, pDist, hdSum, hsChordalDistance, hsArrayToFreq; - -// score funcs -var isInRange, spacingScore, rangeScore, intervalScore, inclusionScore; - -// subroutines -var genTuples, initVoices, genOrders, genSubMotif, updateVoices, genDurFunc, genStepFunc; - -// primary routines -var genMotif, genSecondarySeq; - -// audition funcs -var genPatterns, genMidiPatterns; - -// resource management funcs -var seedFunc, genUID, writeResources, stringifyToDepth, setSeeds, sanityCheck, -msgInterpret, loadLedgerFile, loadLedgerJSON, loadModelFile, loadModelJSON, -setGlobalVars, globalVarsToDict, saveLedger; - -// model vars -//(model and global vars mostly set by OSC funcs -var seq, lastXChanges, -curUID, refUID, orderSeed, durSeed, motifSeed, -entrancesProbVals, passagesProbVals, exitsProbVals, -ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, -orders, susWeights, orderSize, passagesSize, -motifEdited, orderEdited; - -// model aux vars -var entrancesDurFunc, passagesDurFunc, exitsDurFunc, stepFunc; - -// other global vars -var popSize, exPath, dir, primes, dims, tuples, -group, player, ledgerPath, ledger, currentlyPlayingUID, -nameSpaces; - -// install JSON quark -if(Quarks.isInstalled("JSONlib").not, { - Quarks.install("https://github.com/musikinformatik/JSONlib.git"); - thisProcess.recompile; - //HelpBrowser.openHelpFor("Classes/JSONlib"); -}); - - -//------helper funcs - -hsArrayToCents = { - arg hsArray; - hsArray.collect({arg dist, p; dist * 1200 * log2(primes[p][0]/primes[p][1])}).sum -}; - -pDist = { - arg array1, array2, signed = false; - var pDistance; - pDistance = hsArrayToCents.value(array1) - hsArrayToCents.value(array2); - if(signed, {pDistance}, {abs(pDistance)}) -}; - -hdSum = { - arg hsArrays; - var size, distances, mean; - size = hsArrays.size; - distances = (size - 1).collect({arg i; - ((i + 1)..(size - 1)).collect({arg j; - abs(hsArrays[i] - hsArrays[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsChordalDistance = { - arg hsArrays1, hsArrays2; - var size, distances, mean; - size = hsArrays1.size; - distances = hsArrays1.size.collect({arg i; - hsArrays2.size.collect({arg j; - abs(hsArrays1[i] - hsArrays2[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsArrayToFreq = { - arg array; - array.collect({arg dim, d; pow(primes[d][0]/primes[d][1], dim)}).product -}; - -//------score funcs - -/* -isInRange = { - arg hsArray, min, max; - var cents; - cents = hsArrayToCents.value(hsArray); - (cents >= min) && (cents <= max) -}; -*/ - -spacingScore = { - arg hsArrays, min; - var centsArray; - centsArray = hsArrays.collect({arg hsArray; hsArrayToCents.value(hsArray)}).sort({arg a, b; a < b}); - centsArray.differentiate.drop(1).collect({arg pDistance; if(pDistance >= min, {1}, {0.01})}).sum; -}; - -rangeScore = { - arg hsArray1, hsArray2, min, max, low, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - if((pDistance >= min) && (pDistance <= max), {1}, {low}); -}; - -intervalScore = { - arg hsArray1, hsArray2, mean, sd, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - //pDistance.gaussCurve(1, mean, sd) - stepFunc.value(pDistance); -}; - -inclusionScore = { - arg array, test, min = 0.01; - if(array.collect({arg v; v.hash}).includes(test.hash), {min}, {1}); -}; - - -//------subroutines - -genTuples = { - var tuples; - tuples = dims.collect({[-1, 0, 1]}).allTuples.select({arg tuple; (abs(tuple.drop(1)).sum <= 1) && (tuple[0] == 0)}); - tuples = tuples ++ tuples.collect({arg tuple; [-3, -2, -1, 1, 2, 3].collect({arg octTrans; tuple.deepCopy.put(0, octTrans)})}).flatten; -}; - -initVoices = { - var init, voicesInit; - voicesInit = popSize.collect({dims.collect({0})}); - /* - voicesInit = [dims.collect({0})]; - (popSize - 1).do({ - arg rep, new; - rep = dims.rand; - new = voicesInit.last.deepCopy; - new[rep] = new[rep] + [-1, 1].choose(); - voicesInit = voicesInit.add(new); - }); - */ - voicesInit.deepCopy; -}; - -genDurFunc = {arg chordProb, minPad, maxPad, minDur, maxDur, envData, seed; - var env, pTable, durFunc; - env = Env.pairs([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).asSignal(256).asList.asArray; - pTable = env.asRandomTable; - [chordProb, minPad, maxPad, minDur, maxDur, envData].postln; - durFunc = {arg allowChord, pad = false; - var res; - res = if(allowChord.not, { - pTable.tableRand * (maxDur - minDur) + minDur - }, { - if(1.0.rand < chordProb, {0}, {pTable.tableRand * (maxDur - minDur) + minDur}); - }).round(0.125); - if(pad, {res = res + rrand(minPad.asFloat, maxPad.asFloat).round(0.125)}); - if(res.asInteger == res, {res = res.asInteger}); - res - }; - seedFunc.value(durFunc, seed); -}; - -genStepFunc = {arg minStep, maxStep, envData, seed; - var envDataNorm, env, pTable, stepFunc; - [minStep, maxStep, envData].postln; - envDataNorm = ([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).flop; - envDataNorm = [envDataNorm[0].normalize(minStep, maxStep), envDataNorm[1]].flop; - env = Env.pairs(envDataNorm); - stepFunc = {arg pDist; - env.at(pDist).clip(0.001, 1); - }; - seedFunc.value(stepFunc, seed); -}; - -genOrders = {arg minMotifLength = 1, maxMotifLength = 5, minProgLength = 0, maxProgLength = 5; - ((maxMotifLength - minMotifLength).rand + minMotifLength).collect({ - var noProgIns, noSusIns, noSilentIns, prog, sus, silent, order; - noSusIns = [1, 2, 3].wchoose(susWeights.normalizeSum); - noProgIns = (popSize - noSusIns).rand + 1; - noSilentIns = popSize - noSusIns - noProgIns; - - # prog, sus, silent = (0..(popSize-1)).scramble.clumps([noProgIns, noSusIns, noSilentIns]); - - prog = (prog.scramble ++ ((maxProgLength - minProgLength).rand + minProgLength).collect({prog.choose}).scramble); - if(silent == nil, {silent = []}); - [sus.scramble, prog, silent.scramble] - }); -}; - -updateVoices = {arg ins, sus; - var voices, candidates, nWeights, nProbs, sel; - - voices = lastXChanges.deepCopy.last; - - candidates = sus.collect({arg v; tuples.collect({arg t; voices[v] + t})}).flatten; - candidates = difference(candidates.asSet, voices.asSet).asList; - nProbs = candidates.collect({arg candidate; - var stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore; - - //stepScore = intervalScore.value(voices[ins], candidate, 30, 400, 0.1); - stepScore = intervalScore.value(voices[ins], candidate, 100, 100); - recentlySoundedScore = inclusionScore.value(lastXChanges.flop[ins], candidate, 0); - isInRangeScore = rangeScore.value(candidate, candidate.collect({0}), ranges[ins][0], ranges[ins][1], 0, true); - regScore = spacingScore.value(voices.deepCopy.put(ins, candidate), 300); - hdScore = pow(hdSum.value(voices.deepCopy.put(ins, candidate)), hdExp); - if(hdInvert == 0, {hdScore = 1/hdScore}); - //maybe what you want here is a vector to another root and then favoring movement towards it. - //distScore = pow(hsChordalDistance.value(voices, voices.put(ins, candidate)), 2); - - [stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore] - }); - - nWeights = passagesWeights; - - //this handles nWeights of 0; mainly for testing - nProbs = nProbs.flop.select({arg scores, s; nWeights[s] != 0}).flop; - nWeights = nWeights.select({arg weight; weight != 0}); - nProbs = nProbs.flop.collect({arg scores, s; - if(scores.sum == 0, {scores}, {scores.normalizeSum * nWeights[s]}) - }); - nProbs = nProbs.flop.collect({arg scores, s; scores.product}).normalizeSum; - - sel = candidates.wchoose(nProbs); - - voices[ins] = sel; - lastXChanges = lastXChanges.add(voices).keep(-5); -}; - -genSubMotif = {arg order, orderIndex, lastState, repeatLast = false, startFromLast = false, isLastOrder = false; - var sus, prog, silent, flatOrder, res, isInChord, allowChord, pad, lastXChangesHold, voices, adder; - # sus, prog, silent = order; - flatOrder = silent ++ sus ++ prog; - lastXChangesHold = lastXChanges.deepCopy; - voices = lastState.deepCopy; - isInChord = popSize.collect({false}); - allowChord = false; - pad = false; - res = []; - "------generating motif".postln; - //need to figure out here if voices move between motifs - flatOrder.do({arg ins, i; - - if(prog.includes(ins) && repeatLast.not, {updateVoices.value(ins, sus)}); - adder = if(silent.includes(ins), {["Rest"]}, {lastXChanges.last.deepCopy[ins]}); - - if(voices[ins] != adder, { - var dur; - - if((sus ++ silent).includes(ins), { - allowChord = (ins != sus.last); - pad = (ins == sus.last); - }, { - if(i < (flatOrder.size - 1), { - allowChord = (isInChord[flatOrder[i + 1]] || (ins == flatOrder[i + 1])).not; - pad = false; - }, { - allowChord = false; - pad = true - }); - }); - if((orderIndex == 0) && sus.includes(ins), { - dur = entrancesDurFunc.value(allowChord, pad); - }, { - dur = passagesDurFunc.value(allowChord, pad); - }); - if(dur == 0, {isInChord[ins] = true}, {isInChord = popSize.collect({false})}); - - voices[ins] = adder; - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - - // pad ending - if(orderIndex == (orders.size - 1), { - (0..(popSize-1)).scramble.do({arg ins; - if(res.last.first[ins] != ["Rest"], { - var dur; - voices[ins] = ["Rest"]; - allowChord = (voices != popSize.collect({["Rest"]})); - pad = allowChord.not; - dur = exitsDurFunc.value(allowChord, pad); - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - }); - - //format and return - if(startFromLast, {lastXChanges = lastXChangesHold.deepCopy}); - res; -}; - - -//------primary routines - -genMotif = { - var repeats, fSeq, fDur, durAdd; - - repeats = 1; - fSeq = []; - - repeats.do({arg index; - var motif; - - motif = []; - - orders.do({arg order, o; - var lastState, subMotif; - lastState = if(o == 0, {popSize.collect({["Rest"]})}, {motif.last.last.first}); - subMotif = genSubMotif.value(order, o, lastState, isLastOrder: o == (orders.size - 1)); - motif = motif.add(subMotif); - - }); - - sanityCheck.value(motif, index); - - fSeq = fSeq.add(motif); - }); - - //round last duration to measure - fDur = fSeq.flatten.flatten.slice(nil, 1).sum; - durAdd = fDur.round(4) - fDur; - if(durAdd < 0, {durAdd = 4 - durAdd}); - fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] = fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] + durAdd; - - fSeq -}; - -genSecondarySeq = {arg seq; - var curdles, fSeq; - curdles = []; - while({curdles.sum < seq.size}, {curdles = curdles ++ [3.rand + 1]}); - - fSeq = seq.clumps(curdles).collect({arg clump, m; - var repeats, paddedSeq; - - //add rest - paddedSeq = clump.add([[[popSize.collect({["Rest"]}), 0.5.rand]]]); - - //implement repeats - repeats = [0.rand + 1, 1].wchoose([1, 0].normalizeSum); - repeats.collect({paddedSeq}); - }); - fSeq -}; - - -//------audition funcs - -/* -Event.addEventType(\osc, { - if (~addr.postln.notNil) { - ~addr.sendMsg(~indexPath, ~indexMsg); - ~addr.sendMsg(~seqPath, stringifyToDepth.value(~seqMsg, 3)); - //~addr.sendMsg("/STATE/OPEN", (dir.replace("supercollider", "resources") +/+ ~idMsg +/+ ~idMsg ++ "_gui_state" ++ ".state").standardizePath.postln); - }; -}); -*/ - -Event.addEventType(\osc, { - if (~addr.notNil) { - ~msg; - ~addr.sendMsg(~path, *~msg); - }; -}); - -genPatterns = {arg inSeq, addr, oneShot = false; - var voices, durs, pbinds, res, indices, sectionDurs, msg, ids, seq; - seq = inSeq.collect({arg mSeq; mSeq[0]}); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - pbinds = voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs, attacks, rels, amps; - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - //attacks = 2.collect({rrand(1, 3)}) ++ freqs.drop(2).collect({rrand(0.3, 0.5)}); - attacks = fDurs.collect({arg dur; dur * rrand(0.2, 0.4)}); - //rels = freqs.drop(2).collect({rrand(0.3, 0.5)}) ++ 2.collect({rrand(1, 3)}); - rels = (clumps.size - 1).collect({arg c; - if(clumps[c + 1][0] == ["Rest"], {rrand(1.0, 3.0)}, {rrand(0.3, 0.5)}); - }); - rels = rels.add(rrand(1.0, 3.0)); - amps = freqs.collect({rrand(0.6, 0.99)}); - - [ - Pbind( - \instrument, \string_model, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \attack, Pseq(attacks, 1), - \sustain, Pseq(fDurs, 1), - \release, Pseq(rels, 1), - //\amp, Pseq(amps, 1), - \amp, Pbrown(0.5, 1, 0.5), - \busIndex, v - ), - Pbind( - \instrument, \sine, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \sustain, Pseq(fDurs, 1), - \busIndex, v - ) - ] - }).flatten; - if(oneShot.not, { - msg = inSeq.collect({arg mSeq, m; mSeq[1..]}); - //ids = inSeq.collect({arg mSeq, m; mSeq[2]}); - sectionDurs = seq.collect({arg mSeq; mSeq.flatten2(mSeq.maxDepth - 5).flop[1].sum}); - pbinds = pbinds ++ - [ - Pbind( - \type, \osc, - \addr, addr, - \path, "/playing", - \msg, Pseq(msg, 1), - \dur, Pseq(sectionDurs, 1) - ); - ] - }); - res = Ppar(pbinds); - res -}; - -/* -genMidiPatterns = {arg seq; - var voices, durs, patterns, res, mOut, pbRange; - pbRange = 1; //semitones - change this as needed for your situation - mOut = MIDIOut.newByName("TiMidity", "TiMidity port 0").latency_(Server.default.latency); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - res = Ppar( - voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs; - - mOut.program(v, 70); - - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - - Pbind( - \type, \midi, - \chan, v, - \noteval, Pseq(freqs.cpsmidi - 24, 1), - \note, Pfunc({ | event | event[\noteval].floor }), - \dur, Pseq(fDurs, 1), - \midiout, mOut, - \amp, 1, - \bend, Pfunc({ - | event | - if (event[\note].isRest.not) { - var pitchbendvalue = event[\noteval].frac.linlin(0, pbRange, 8192, 8192*2).asInteger; - m.bend(v, pitchbendvalue); - }; - 0; // return something other than nil to avoid stopping the pattern - }), - ); - }); - ); - res -}; -*/ - - -//------resource management funcs - -genUID = {Date.seed.asHexString.toLower}; - -seedFunc = {arg func, seed; - var funcArgs, next; - next = Routine({loop{func.valueArray(funcArgs).yield }}); - next.randSeed_(seed); - {arg ...args; funcArgs = args; next.value} -}; - -stringifyToDepth = {arg data, maxDepth = 1; - var prettyString = "", rCount = 0, writeArray, indent; - - if(maxDepth == 0, { - data.asCompileString - }, { - indent = {arg size; size.collect({" "}).join("")}; - writeArray = {arg array; - prettyString = prettyString ++ indent.value(rCount) ++ "[\n"; - rCount = rCount + 1; - if(rCount < maxDepth, { - array.do({arg subArray; writeArray.value(subArray)}); - }, { - prettyString = prettyString ++ array.collect({arg subArray; - indent.value(rCount + 1) ++ subArray.asCompileString - }).join(",\n"); - }); - rCount = rCount - 1; - prettyString = prettyString ++ "\n" ++ indent.value(rCount) ++ "],\n"; - }; - - writeArray.value(data); - prettyString.replace(",\n\n", "\n").drop(-2); - }) -}; - -sanityCheck = {arg motif, index; - //print functions = very helpful - ("----------" + index + "------------").postln; - - motif.flatten.do({arg val, v; - if(v > 0, { - if(motif.flatten[v-1][0].hammingDistance(val[0]) > 1, {"problem 1".postln}); - if(motif.flatten[v-1][0].hammingDistance(val[0]) == 0, {"problem 2".postln}); - }); - val.postln - }); - "***********".postln; -}; - -msgInterpret = {arg in, escapeDoubleQuotes = true, escapeSingleQuotes = true; - var res; - - res = in; - if(res.isNil.not, { - if((res.isArray && res.isString.not), { - res = res.asCompileString; - res = res.replace(" ", "").replace("\n", "").replace("\t", ""); - if(escapeSingleQuotes, {res = res.replace("\'", "")}); - if(escapeDoubleQuotes, {res = res.replace("\"", "")}); - res = res.replace("Rest", "\"Rest\""); - res = res.interpret; - }, { - var tmpRes; - if(res.every({arg char; char.isDecDigit}), {tmpRes = res.asInteger}); - if(res.contains("."), {tmpRes = res.asFloat}); - if(tmpRes != nil, {res = tmpRes}); - }); - }); - res -}; - -writeResources = {arg path, dict; - var file, modelItems, resString; - file = File(path,"w"); - - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - - resString = nameSpaces.collect({arg nameSpace; - var depth = 0, insert = " "; - if(nameSpace == "music_data", {depth = 3; insert = "\n"}); - if(nameSpace == "last_changes", {depth = 1; insert = "\n"}); - if(nameSpace == "order", {depth = 1; insert = "\n"}); - if((nameSpace == "ref_uid") && (dict[nameSpace] == nil), {dict[nameSpace] = "nil"}); - "\"" ++ nameSpace ++ "\":" ++ insert ++ stringifyToDepth.value(dict[nameSpace], depth) - }).join(",\n"); - - resString = "{\n" ++ resString ++ "\n}"; - - file.write(resString); - file.close; - resString -}; - -loadModelFile = {arg path; loadModelJSON.value(File(path, "r").readAllString.parseJSON)}; - -loadModelJSON = {arg jsonObject; - var dict; - dict = Dictionary.with(*nameSpaces.collect({arg nS; nS->msgInterpret.value(jsonObject[nS])})); - dict -}; - -setGlobalVars = {arg dict, skipLastXChanges = false; - var tmpLastXChanges; - tmpLastXChanges = lastXChanges.deepCopy; - // order really matters!!!! - # seq, lastXChanges, curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited = nameSpaces.collect({arg nS; dict[nS]}); - if(skipLastXChanges, {lastXChanges = tmpLastXChanges}); - dict -}; - -globalVarsToDict = { - var modelItems, dict; - // order really matters!!!! - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - dict = Dictionary.with(*nameSpaces.collect({arg nS, n; nS->modelItems[n]})); -}; - -loadLedgerFile = {arg path; - ledgerPath = path; - loadLedgerJSON.value(File(ledgerPath, "r").readAllString.parseJSON) -}; - -loadLedgerJSON = {arg jsonObject; ledger = jsonObject["ledger"]}; - -saveLedger = {arg ledger, path; - var file; - file = File(path, "w"); - file.write("{\n\"ledger\":\n" ++ stringifyToDepth.value(ledger, 1) ++ "\n}"); - file.close; -}; - -//------global vars - -primes = [[2, 1], [3, 2], [5, 4], [7, 4], [11, 8], [13, 8]]; -//ranges = [[-2400, 0], [-1200, 1200], [0, 2400], [0, 2400]]; -exPath = thisProcess.nowExecutingPath; -dir = exPath.dirname; -//popSize = 4; -dims = primes.size; -tuples = genTuples.value(); -//refUID = nil; -group = Group.new; -~group = group; -loadLedgerFile.value(dir +/+ ".." +/+ "resources" +/+ "piece_ledger.json"); -//passagesWeights = [1, 1, 1, 1, 1]; -//susWeights = [1, 1, 1]; -// order really matters!!!! -nameSpaces = [ - "music_data", "last_changes", "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", - "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", - "ranges", "step_probs_vals", "passages_weights", "hd_exp", "hd_invert", - "order", "sus_weights", "order_size", "passages_size", - "motif_edited", "order_edited" -]; - - -//------OSC funcs - -OSCdef(\load_ledger, {arg msg, time, addr, port; - loadLedgerFile.value(msg[1].asString); -}, \load_ledger); - -OSCdef(\load_model, {arg msg, time, addr, port; - var dict; - dict = loadModelFile.value(msg[1].asString); - setGlobalVars.value(dict); -}, \load_model); - -OSCdef(\save_ledger, {arg msg, time, addr, port; - msg.postln; - ledger = msgInterpret.value(msg[1].asString.parseJSON["ledger"], false).postln; - //loadLedgerJSON.value(msg[0]) - saveLedger.value(ledger, msg[2].asString); - //loadLedgerFile.value(msg[1].asString); -}, \save_ledger); - -OSCdef(\generate, {arg msg, time, addr, port; - var path, dict, durSeeds, musPath, modelString; - msg.postln; - - path = msg[1].asString; - - dict = loadModelFile.value(path); - setGlobalVars.value(dict, true); - - popSize = ranges.size; - - //refUID.postln; - - loadLedgerFile.value(ledgerPath); - if(ledger == nil, {ledger = ["tmp"]}); - if(ledger.last != "tmp", {ledger = ledger.add("tmp")}); - - if(refUID == nil, {lastXChanges = [initVoices.value().deepCopy]}); - if((refUID != nil) && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - lastXChanges = msgInterpret.value(file.readAllString.parseJSON["last_changes"]); - }); - - refUID.postln; - lastXChanges.collect({arg item; item.postln}); - - durSeeds = seedFunc.value({3.collect({rrand(100000, 999999)})}, durSeed).value.postln; - entrancesDurFunc = genDurFunc.valueArray(entrancesProbVals[..4] ++ [entrancesProbVals[5..]] ++ [durSeeds[0]]); - passagesDurFunc = genDurFunc.valueArray(passagesProbVals[..4] ++ [passagesProbVals[5..]] ++ [durSeeds[1]]); - exitsDurFunc = genDurFunc.valueArray(exitsProbVals[..4] ++ [exitsProbVals[5..]] ++ [durSeeds[2]]); - - if(orders == nil, { - orders = seedFunc.value(genOrders, orderSeed).valueArray(orderSize ++ passagesSize); - //addr.sendMsg("/order", stringifyToDepth.value(orders, 1)); - }); - - stepFunc = genStepFunc.valueArray(stepProbsVals[..1] ++ [stepProbsVals[2..]] ++ [motifSeed]); - seq = seedFunc.value(genMotif, motifSeed).value; - - lastXChanges.collect({arg item; item.postln}); - - dict = globalVarsToDict.value; - modelString = writeResources.value(path, dict); - - //addr.sendMsg("/generated", musPath, stringifyToDepth.value(seq, 3)); - //~seq = seq; - - addr.sendMsg("/generated", path, modelString, ledgerPath); -}, \generate); - - -OSCdef(\commit, {arg msg, time, addr, port; - var musicData, musicChanged, dict, newLedger, modelPath, musString, musFile, test1, test2, lastCurUID, commitType; - //msg.postln; - - /* - test1 = msg[1].asString.parseJSON; - test2 = (dir +/+ ".." +/+ "resources/tmp/tmp_music" ++ ".json").standardizePath.parseJSONFile; - msgInterpret.value(test1["music"])[0][0][0][1].class.postln; - msgInterpret.value(test2["music_data"])[0][0][0][1].class.postln; - (test1["music"] == test2["music_data"]).postln; - */ - - musicData = loadModelJSON.value(msg[1].asString.parseJSON)["music_data"].postln; - musicChanged = (musicData != seq).postln; - commitType = msg[2].asString; - - lastCurUID = curUID.deepCopy; - curUID = genUID.value; - - File.mkdir((dir +/+ ".." +/+ "resources" +/+ curUID).standardizePath); - File.copy(exPath, (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_code" ++ ".scd").standardizePath); - - modelPath = (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_mus_model" ++ ".json").standardizePath; - dict = globalVarsToDict.value; - if(musicChanged, { - seq = musicData; - dict["music_data"] = seq; - dict["motif_edited"] = "true" - }); - dict["cur_uid"] = curUID; - - writeResources.value(modelPath, dict); - - File.delete(ledgerPath ++ "_bak"); - File.copy(ledgerPath, ledgerPath ++ "_bak"); - File.delete(ledgerPath); - - if(commitType == "add", { - if(lastCurUID == "tmp", { - ledger = ledger.drop(-1).add(ledger.indexOf(curUID)); - }, { - ledger = ledger.add(curUID); - }) - }); - - if(commitType == "insert", {ledger = ledger.insert(lastCurUID, curUID)}); - - if(commitType == "replace", {ledger = ledger.put(lastCurUID, curUID)}); - - saveLedger.value(ledger, ledgerPath); - - addr.sendMsg("/committed", curUID, ledgerPath); - //refUID = curUID; - -}, \commit); - -OSCdef(\transport, {arg msg, time, addr, port; - msg.postln; - if(msg[1] == 0, { - group.set(\release, 2); - group.set(\gate, 0); - player.stop; - }, { - // the cued sequence can now be read from file, so this can be cleaned up - var cSize, patterns, pSeq, cuedSeek, indexStart, indexEnd, tmpLedger; - if(msg[1] == 1, { - pSeq = []; - cuedSeek = (seq != nil); - indexStart = msg[2].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.postln.parseJSON["music_data"]), path, indexStart + index, uid]); - file.close; - }); - }); - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - patterns = genPatterns.value(pSeq, addr); - }, { - pSeq = [loadModelJSON.value(msg[2].asString.parseJSON)["music_data"].postln]; - patterns = genPatterns.value(pSeq, addr, true); - }); - player = Pfset(pattern: patterns, cleanupFunc: { - addr.sendMsg("/transport", 0); - addr.sendMsg("/one_shot", 0); - }); - player = player.play - }); -}, \transport); - - -OSCdef(\transcribe_motif, {arg msg, time, addr, port; - var tSeq, refChord, refUID; - - msg.postln; - - tSeq = [loadModelJSON.value(msg[1].asString.parseJSON)["music_data"]]; - refUID = msg[2].asString.postln; - - if((refUID != "nil") && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }, { - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - }); - - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "lilypond" +/+ "includes").standardizePath, addr, "/transcribe_motif"); -}, \transcribe_motif); - - -OSCdef(\transcribe_all, {arg msg, time, addr, port; - var cSize, patterns, cuedSeek, indexStart, indexEnd, tmpLedger; - if(true, { - cuedSeek = (seq != nil); - indexStart = msg[1].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - - //tmp for testing transcription - indexEnd = (indexStart+5); - - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - var lilyPartLedgerFiles; - - lilyPartLedgerFiles = 4.collect({arg p; - File((dir +/+ ".." +/+ "lilypond" +/+ "includes" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly").standardizePath, "w"); - }); - - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file, fileString, tSeq, refUID, refChord; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - fileString = file.readAllString; - tSeq = msgInterpret.value(fileString.parseJSON["music_data"]); - refUID = msgInterpret.value(fileString.parseJSON["ref_uid"]); - file.close; - - //uid.postln; - //(refUID == "nil").postln; - - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - - if(refUID != "nil", { - path = (dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }); - - if(index != indexEnd, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath); - }, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath, addr, "/transcribe_all"); - }); - - lilyPartLedgerFiles.do({arg f, p; - f.write("\\include \".." +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly\"\n"); - }); - - }); - - lilyPartLedgerFiles.do({arg f; - f.close - }); - }); - /* - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - */ - }, { - - }); - -}, \transcribe_all); - -) - -~transcribe.value(~seq, dir); - -( -//synthdefs -~stringModelBusArray = 4.collect({Bus.audio(s, 1)}); -~sineBusArray = 4.collect({Bus.audio(s, 1)}); -~bassBusArray = 1.collect({Bus.audio(s, 1)}); -~hdustBusArray = 1.collect({Bus.audio(s, 1)}); -~samplerBusArray = 2.collect({Bus.audio(s, 1)}); -~sBuf = Buffer.alloc(s, 10, 2); -SynthDef(\string_model, {arg freq, gate = 1, sustain, amp, dur, attack, release = 1, busIndex = 0; - var trig, exc, sig1, sig2, noHarms; - noHarms = rrand(20, 40); - exc = Saw.ar(freq, TRand.ar(0.5, 1, Impulse.ar(freq))) * 0.001 + Dust.ar(10000, 0.01); - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.8).softclip; - //sig1 = HPF.ar(sig1, 300); - Out.ar(Select.kr(busIndex, ~stringModelBusArray), sig1 * amp * EnvGen.kr(Env.adsr(attack, 0.3, 0.9, release, 0.9, -3), gate, doneAction: 2)); - //Out.ar([0, 1], sig1 * EnvGen.kr(Env.asr(dur, 0.3, 1), gate, doneAction: 2)); -}).add; - -SynthDef(\sine, {arg freq, gate = 1, sustain, amp, dur, busIndex = 0; - var sig; - sig = SinOsc.ar(freq); - Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.asr(0.3, 0.4, 0.3), gate, timeScale: dur, doneAction: 2)); - //Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.sine(dur), gate, doneAction: 2)); -}).add; - -SynthDef(\mixer, {arg freq, gate = 1, sustain, amp, dur, out; - var nameSpaces, sigs; - - sigs = [~stringModelBusArray, ~sineBusArray/*, ~bassBusArray, ~hdustBusArray, ~samplerBusArray*/].collect({arg busArray, i; - var nameSpace, sig; - nameSpace = ['string', 'sine', 'bass', 'hdust', 'sampler'][i]; - sig = busArray.collect({arg bus, c; In.ar(bus, 1) * NamedControl.kr(\ ++ nameSpace ++ '_volume_' ++ c, 1, 0.1)}); - sig = sig.collect({arg channel, c; Pan2.ar(channel, NamedControl.kr(\ ++ nameSpace ++ '_pan_' ++ c, i / (busArray.size - 1), 0.1) * 2 - 1)}); - sig = sig.collect({arg channel, c; channel * NamedControl.kr(\ ++ nameSpace ++ '_mute_' ++ c, 1, 0.1)}); - sig = Mix.ar(sig) * pow(NamedControl.kr(\ ++ nameSpace ++ '_volume_master', 1, 0.1), 2); - }); - - sigs = Mix.ar(sigs / 4); - Out.ar(0, sigs) -}).add; - -SynthDef(\bass, { - var switches, drone; - switches = {|i| Dust.kr(0.1)} ! 9; - drone = {|i| var harm = pow(2, 2 - (i / 3).trunc), amp = (1 / pow(harm, 2)); - SinOsc.ar(60 * harm + TRand.kr(-3, 3, switches[i]), 0, amp)} ! 9; - Out.ar(~bassBusArray[0], Mix.new(drone) * 0.2); -}).add; - -SynthDef(\sampler, { - Out.ar(~samplerBusArray, PlayBuf.ar(2, ~sBuf, BufRateScale.kr(~sBuf), doneAction: 2)) -}).add; - -// main routine -SynthDef(\hdust, { - arg gate = 0; - var hierarchical_dust, low_sine, high_sine, brown_noise, white_noise; - // this triggers the combinations of sources - // it is similar to the Supercollider UGen called dust but with a hierarchical structure - hierarchical_dust = ( - TIRand.kr(0, 1, Impulse.kr(100)) * - TIRand.kr(0, 1, Impulse.kr(10)) * - TIRand.kr(0, 1, Impulse.kr(1)) * - TIRand.kr(0, 1, Impulse.kr(0.1)) - ); - // adjust the multiplier at the end of each line for adjusting levels - // note with each trigger, each source has a 1 in 3 chance of sounding - low_sine = SinOsc.ar(76.midicps / 16) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.1; - high_sine = SinOsc.ar(76.midicps * 8) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.01; - brown_noise = BrownNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.025; - white_noise = WhiteNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.02; - Out.ar(~hdustBusArray[0], - ((low_sine + high_sine + brown_noise + white_noise) ) - ); -}).add; - -) - -( -var bass, hdust, sampler, mixer; -/* -bass = Synth.tail(~group, \bass); -hdust = Synth.tail(~group, \hdust); -sampler = Synth.head(~group, \sampler); -*/ -mixer = Synth.tail(~group, \mixer); - -OSCdef(\mixer, {arg msg, time, addr, port; - mixer.set((msg[1] ++ '_' ++ msg[2] ++ '_' ++ msg[3]), msg[4]) -}, \mixer); - -/* -OSCdef(\sampler, {arg msg, time, addr, port; - msg.postln; - sampler.free; - ~sBuf.free; - ~sBuf = Buffer.read(s, msg[1].asString.postln, action: {sampler = Synth.head(~group, \sampler)}); -}, \sampler); -*/ -) - -/* old something -( -SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; - var trig, exc, sig1, sig2, noHarms, freqFinal, start, end; - noHarms = 30; - freq = WhiteNoise.ar * 3 + freq; - freqFinal = Duty.ar((1/freq), 0, freq); - trig = Changed.ar(freqFinal); - start = Demand.ar(trig, 0, Dwhite(-1, -0.75)); - end = Demand.ar(trig, 0, Dwhite(0.75, 1)); - exc = Phasor.ar(trig, (end - start) * freqFinal / SampleRate.ir, start, end, 0) * 0.001 + Dust.ar(10000, 0.01); - - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(2, 3)}) ], exc) * 0.5).softclip; - sig1 = HPF.ar(sig1, 300); - Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); -}).add; -) -*/ - diff --git a/resources/75837171/75837171_mus_model.json b/resources/75837171/75837171_mus_model.json deleted file mode 100644 index 2469541..0000000 --- a/resources/75837171/75837171_mus_model.json +++ /dev/null @@ -1,73 +0,0 @@ -{ -"music_data": -[ - [ - [ - [ [ [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ] ], 0 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 0, 0, 0 ], [ 1, 0, -1, 0, 0, 0 ], [ 0, -1, -1, 0, 0, 0 ] ], 0.5 ], - [ [ [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, 0 ], [ 1, 0, -1, 0, 0, 0 ], [ -1, 0, 0, 0, 0, 1 ] ], 6.25 ], - [ [ [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, 0 ], [ "Rest" ], [ -1, 0, 0, 0, 0, 1 ] ], 0 ], - [ [ [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ] ], 0.375 ], - [ [ [ "Rest" ], [ 1, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ] ], 0 ], - [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 1.375 ] - ] - ] -], -"last_changes": -[ - [ [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, 0 ], [ 1, 0, -1, 0, 0, 0 ], [ 1, 0, 0, 0, 0, -1 ] ], - [ [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, 0 ], [ 1, 0, -1, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ] ], - [ [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, 0 ], [ 1, 0, -1, 0, 0, 0 ], [ 0, 0, -1, 0, 0, 0 ] ], - [ [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, 0 ], [ 1, 0, -1, 0, 0, 0 ], [ 0, -1, -1, 0, 0, 0 ] ], - [ [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, 0 ], [ 1, 0, -1, 0, 0, 0 ], [ -1, 0, 0, 0, 0, 1 ] ] -], -"cur_uid": "75837171", -"ref_uid": "nil", -"order_seed": 276308, -"dur_seed": 563581, -"motifs_seed": 956658, -"entrances_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.26424870466321, 0.75675675675676, 0.5, 0.5, 0.58549222797927, 0.72635135135135, 1, 0.5 ], -"passages_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"exits_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"ranges": [ [ -384, 2400 ], [ -507, 2400 ], [ -282, 2237 ], [ -1200, 2053 ] ], -"step_probs_vals": [ 0, 1200, 0, 0.5, 0.5, 0.5, 1, 0.5 ], -"passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], -"hd_exp": 2, -"hd_invert": 0, -"order": -[ - [ [ 1, 3 ], [ 2, 2, 2, 2, 2, 2, 2, 2, 2 ], [ 0 ] ], - [ [ 3, 0, 2 ], [ 1, 1, 1, 1 ], [ ] ], - [ [ 2, 1, 0 ], [ 3, 3, 3, 3, 3, 3, 3, 3 ], [ ] ] -], -"sus_weights": [ 0.75, 0.69, 0.75 ], -"order_size": [ 2, 6 ], -"passages_size": [ 0, 10 ], -"motif_edited": "false", -"order_edited": "false" -} \ No newline at end of file diff --git a/resources/78f2229c/78f2229c_code.scd b/resources/78f2229c/78f2229c_code.scd deleted file mode 100644 index ab2dc17..0000000 --- a/resources/78f2229c/78f2229c_code.scd +++ /dev/null @@ -1,1046 +0,0 @@ -( -// helper funcs -var hsArrayToCents, pDist, hdSum, hsChordalDistance, hsArrayToFreq; - -// score funcs -var isInRange, spacingScore, rangeScore, intervalScore, inclusionScore; - -// subroutines -var genTuples, initVoices, genOrders, genSubMotif, updateVoices, genDurFunc, genStepFunc; - -// primary routines -var genMotif, genSecondarySeq; - -// audition funcs -var genPatterns, genMidiPatterns; - -// resource management funcs -var seedFunc, genUID, writeResources, stringifyToDepth, setSeeds, sanityCheck, -msgInterpret, loadLedgerFile, loadLedgerJSON, loadModelFile, loadModelJSON, -setGlobalVars, globalVarsToDict, saveLedger; - -// model vars -//(model and global vars mostly set by OSC funcs -var seq, lastXChanges, -curUID, refUID, orderSeed, durSeed, motifSeed, -entrancesProbVals, passagesProbVals, exitsProbVals, -ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, -orders, susWeights, orderSize, passagesSize, -motifEdited, orderEdited; - -// model aux vars -var entrancesDurFunc, passagesDurFunc, exitsDurFunc, stepFunc; - -// other global vars -var popSize, exPath, dir, primes, dims, tuples, -group, player, ledgerPath, ledger, currentlyPlayingUID, -nameSpaces; - -// install JSON quark -if(Quarks.isInstalled("JSONlib").not, { - Quarks.install("https://github.com/musikinformatik/JSONlib.git"); - thisProcess.recompile; - //HelpBrowser.openHelpFor("Classes/JSONlib"); -}); - - -//------helper funcs - -hsArrayToCents = { - arg hsArray; - hsArray.collect({arg dist, p; dist * 1200 * log2(primes[p][0]/primes[p][1])}).sum -}; - -pDist = { - arg array1, array2, signed = false; - var pDistance; - pDistance = hsArrayToCents.value(array1) - hsArrayToCents.value(array2); - if(signed, {pDistance}, {abs(pDistance)}) -}; - -hdSum = { - arg hsArrays; - var size, distances, mean; - size = hsArrays.size; - distances = (size - 1).collect({arg i; - ((i + 1)..(size - 1)).collect({arg j; - abs(hsArrays[i] - hsArrays[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsChordalDistance = { - arg hsArrays1, hsArrays2; - var size, distances, mean; - size = hsArrays1.size; - distances = hsArrays1.size.collect({arg i; - hsArrays2.size.collect({arg j; - abs(hsArrays1[i] - hsArrays2[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsArrayToFreq = { - arg array; - array.collect({arg dim, d; pow(primes[d][0]/primes[d][1], dim)}).product -}; - -//------score funcs - -/* -isInRange = { - arg hsArray, min, max; - var cents; - cents = hsArrayToCents.value(hsArray); - (cents >= min) && (cents <= max) -}; -*/ - -spacingScore = { - arg hsArrays, min; - var centsArray; - centsArray = hsArrays.collect({arg hsArray; hsArrayToCents.value(hsArray)}).sort({arg a, b; a < b}); - centsArray.differentiate.drop(1).collect({arg pDistance; if(pDistance >= min, {1}, {0.01})}).sum; -}; - -rangeScore = { - arg hsArray1, hsArray2, min, max, low, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - if((pDistance >= min) && (pDistance <= max), {1}, {low}); -}; - -intervalScore = { - arg hsArray1, hsArray2, mean, sd, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - //pDistance.gaussCurve(1, mean, sd) - stepFunc.value(pDistance); -}; - -inclusionScore = { - arg array, test, min = 0.01; - if(array.collect({arg v; v.hash}).includes(test.hash), {min}, {1}); -}; - - -//------subroutines - -genTuples = { - var tuples; - tuples = dims.collect({[-1, 0, 1]}).allTuples.select({arg tuple; (abs(tuple.drop(1)).sum <= 1) && (tuple[0] == 0)}); - tuples = tuples ++ tuples.collect({arg tuple; [-3, -2, -1, 1, 2, 3].collect({arg octTrans; tuple.deepCopy.put(0, octTrans)})}).flatten; -}; - -initVoices = { - var init, voicesInit; - voicesInit = popSize.collect({dims.collect({0})}); - /* - voicesInit = [dims.collect({0})]; - (popSize - 1).do({ - arg rep, new; - rep = dims.rand; - new = voicesInit.last.deepCopy; - new[rep] = new[rep] + [-1, 1].choose(); - voicesInit = voicesInit.add(new); - }); - */ - voicesInit.deepCopy; -}; - -genDurFunc = {arg chordProb, minPad, maxPad, minDur, maxDur, envData, seed; - var env, pTable, durFunc; - env = Env.pairs([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).asSignal(256).asList.asArray; - pTable = env.asRandomTable; - [chordProb, minPad, maxPad, minDur, maxDur, envData].postln; - durFunc = {arg allowChord, pad = false; - var res; - res = if(allowChord.not, { - pTable.tableRand * (maxDur - minDur) + minDur - }, { - if(1.0.rand < chordProb, {0}, {pTable.tableRand * (maxDur - minDur) + minDur}); - }).round(0.125); - if(pad, {res = res + rrand(minPad.asFloat, maxPad.asFloat).round(0.125)}); - if(res.asInteger == res, {res = res.asInteger}); - res - }; - seedFunc.value(durFunc, seed); -}; - -genStepFunc = {arg minStep, maxStep, envData, seed; - var envDataNorm, env, pTable, stepFunc; - [minStep, maxStep, envData].postln; - envDataNorm = ([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).flop; - envDataNorm = [envDataNorm[0].normalize(minStep, maxStep), envDataNorm[1]].flop; - env = Env.pairs(envDataNorm); - stepFunc = {arg pDist; - env.at(pDist).clip(0.001, 1); - }; - seedFunc.value(stepFunc, seed); -}; - -genOrders = {arg minMotifLength = 1, maxMotifLength = 5, minProgLength = 0, maxProgLength = 5; - ((maxMotifLength - minMotifLength).rand + minMotifLength).collect({ - var noProgIns, noSusIns, noSilentIns, prog, sus, silent, order; - noSusIns = [1, 2, 3].wchoose(susWeights.normalizeSum); - noProgIns = (popSize - noSusIns).rand + 1; - noSilentIns = popSize - noSusIns - noProgIns; - - # prog, sus, silent = (0..(popSize-1)).scramble.clumps([noProgIns, noSusIns, noSilentIns]); - - prog = (prog.scramble ++ ((maxProgLength - minProgLength).rand + minProgLength).collect({prog.choose}).scramble); - if(silent == nil, {silent = []}); - [sus.scramble, prog, silent.scramble] - }); -}; - -updateVoices = {arg ins, sus; - var voices, candidates, nWeights, nProbs, sel; - - voices = lastXChanges.deepCopy.last; - - candidates = sus.collect({arg v; tuples.collect({arg t; voices[v] + t})}).flatten; - candidates = difference(candidates.asSet, voices.asSet).asList; - nProbs = candidates.collect({arg candidate; - var stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore; - - //stepScore = intervalScore.value(voices[ins], candidate, 30, 400, 0.1); - stepScore = intervalScore.value(voices[ins], candidate, 100, 100); - recentlySoundedScore = inclusionScore.value(lastXChanges.flop[ins], candidate, 0); - isInRangeScore = rangeScore.value(candidate, candidate.collect({0}), ranges[ins][0], ranges[ins][1], 0, true); - regScore = spacingScore.value(voices.deepCopy.put(ins, candidate), 300); - hdScore = pow(hdSum.value(voices.deepCopy.put(ins, candidate)), hdExp); - if(hdInvert == 0, {hdScore = 1/hdScore}); - //maybe what you want here is a vector to another root and then favoring movement towards it. - //distScore = pow(hsChordalDistance.value(voices, voices.put(ins, candidate)), 2); - - [stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore] - }); - - nWeights = passagesWeights; - - //this handles nWeights of 0; mainly for testing - nProbs = nProbs.flop.select({arg scores, s; nWeights[s] != 0}).flop; - nWeights = nWeights.select({arg weight; weight != 0}); - nProbs = nProbs.flop.collect({arg scores, s; - if(scores.sum == 0, {scores}, {scores.normalizeSum * nWeights[s]}) - }); - nProbs = nProbs.flop.collect({arg scores, s; scores.product}).normalizeSum; - - sel = candidates.wchoose(nProbs); - - voices[ins] = sel; - lastXChanges = lastXChanges.add(voices).keep(-5); -}; - -genSubMotif = {arg order, orderIndex, lastState, repeatLast = false, startFromLast = false, isLastOrder = false; - var sus, prog, silent, flatOrder, res, isInChord, allowChord, pad, lastXChangesHold, voices, adder; - # sus, prog, silent = order; - flatOrder = silent ++ sus ++ prog; - lastXChangesHold = lastXChanges.deepCopy; - voices = lastState.deepCopy; - isInChord = popSize.collect({false}); - allowChord = false; - pad = false; - res = []; - "------generating motif".postln; - //need to figure out here if voices move between motifs - flatOrder.do({arg ins, i; - - if(prog.includes(ins) && repeatLast.not, {updateVoices.value(ins, sus)}); - adder = if(silent.includes(ins), {["Rest"]}, {lastXChanges.last.deepCopy[ins]}); - - if(voices[ins] != adder, { - var dur; - - if((sus ++ silent).includes(ins), { - allowChord = (ins != sus.last); - pad = (ins == sus.last); - }, { - if(i < (flatOrder.size - 1), { - allowChord = (isInChord[flatOrder[i + 1]] || (ins == flatOrder[i + 1])).not; - pad = false; - }, { - allowChord = false; - pad = true - }); - }); - if((orderIndex == 0) && sus.includes(ins), { - dur = entrancesDurFunc.value(allowChord, pad); - }, { - dur = passagesDurFunc.value(allowChord, pad); - }); - if(dur == 0, {isInChord[ins] = true}, {isInChord = popSize.collect({false})}); - - voices[ins] = adder; - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - - // pad ending - if(orderIndex == (orders.size - 1), { - (0..(popSize-1)).scramble.do({arg ins; - if(res.last.first[ins] != ["Rest"], { - var dur; - voices[ins] = ["Rest"]; - allowChord = (voices != popSize.collect({["Rest"]})); - pad = allowChord.not; - dur = exitsDurFunc.value(allowChord, pad); - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - }); - - //format and return - if(startFromLast, {lastXChanges = lastXChangesHold.deepCopy}); - res; -}; - - -//------primary routines - -genMotif = { - var repeats, fSeq, fDur, durAdd; - - repeats = 1; - fSeq = []; - - repeats.do({arg index; - var motif; - - motif = []; - - orders.do({arg order, o; - var lastState, subMotif; - lastState = if(o == 0, {popSize.collect({["Rest"]})}, {motif.last.last.first}); - subMotif = genSubMotif.value(order, o, lastState, isLastOrder: o == (orders.size - 1)); - motif = motif.add(subMotif); - - }); - - sanityCheck.value(motif, index); - - fSeq = fSeq.add(motif); - }); - - //round last duration to measure - fDur = fSeq.flatten.flatten.slice(nil, 1).sum; - durAdd = fDur.round(4) - fDur; - if(durAdd < 0, {durAdd = 4 - durAdd}); - fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] = fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] + durAdd; - - fSeq -}; - -genSecondarySeq = {arg seq; - var curdles, fSeq; - curdles = []; - while({curdles.sum < seq.size}, {curdles = curdles ++ [3.rand + 1]}); - - fSeq = seq.clumps(curdles).collect({arg clump, m; - var repeats, paddedSeq; - - //add rest - paddedSeq = clump.add([[[popSize.collect({["Rest"]}), 0.5.rand]]]); - - //implement repeats - repeats = [0.rand + 1, 1].wchoose([1, 0].normalizeSum); - repeats.collect({paddedSeq}); - }); - fSeq -}; - - -//------audition funcs - -/* -Event.addEventType(\osc, { - if (~addr.postln.notNil) { - ~addr.sendMsg(~indexPath, ~indexMsg); - ~addr.sendMsg(~seqPath, stringifyToDepth.value(~seqMsg, 3)); - //~addr.sendMsg("/STATE/OPEN", (dir.replace("supercollider", "resources") +/+ ~idMsg +/+ ~idMsg ++ "_gui_state" ++ ".state").standardizePath.postln); - }; -}); -*/ - -Event.addEventType(\osc, { - if (~addr.notNil) { - ~msg; - ~addr.sendMsg(~path, *~msg); - }; -}); - -genPatterns = {arg inSeq, addr, oneShot = false; - var voices, durs, pbinds, res, indices, sectionDurs, msg, ids, seq; - seq = inSeq.collect({arg mSeq; mSeq[0]}); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - pbinds = voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs, attacks, rels, amps; - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - //attacks = 2.collect({rrand(1, 3)}) ++ freqs.drop(2).collect({rrand(0.3, 0.5)}); - attacks = fDurs.collect({arg dur; dur * rrand(0.2, 0.4)}); - //rels = freqs.drop(2).collect({rrand(0.3, 0.5)}) ++ 2.collect({rrand(1, 3)}); - rels = (clumps.size - 1).collect({arg c; - if(clumps[c + 1][0] == ["Rest"], {rrand(1.0, 3.0)}, {rrand(0.3, 0.5)}); - }); - rels = rels.add(rrand(1.0, 3.0)); - amps = freqs.collect({rrand(0.6, 0.99)}); - - [ - Pbind( - \instrument, \string_model, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \attack, Pseq(attacks, 1), - \sustain, Pseq(fDurs, 1), - \release, Pseq(rels, 1), - //\amp, Pseq(amps, 1), - \amp, Pbrown(0.5, 1, 0.5), - \busIndex, v - ), - Pbind( - \instrument, \sine, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \sustain, Pseq(fDurs, 1), - \busIndex, v - ) - ] - }).flatten; - if(oneShot.not, { - msg = inSeq.collect({arg mSeq, m; mSeq[1..]}); - //ids = inSeq.collect({arg mSeq, m; mSeq[2]}); - sectionDurs = seq.collect({arg mSeq; mSeq.flatten2(mSeq.maxDepth - 5).flop[1].sum}); - pbinds = pbinds ++ - [ - Pbind( - \type, \osc, - \addr, addr, - \path, "/playing", - \msg, Pseq(msg, 1), - \dur, Pseq(sectionDurs, 1) - ); - ] - }); - res = Ppar(pbinds); - res -}; - -/* -genMidiPatterns = {arg seq; - var voices, durs, patterns, res, mOut, pbRange; - pbRange = 1; //semitones - change this as needed for your situation - mOut = MIDIOut.newByName("TiMidity", "TiMidity port 0").latency_(Server.default.latency); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - res = Ppar( - voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs; - - mOut.program(v, 70); - - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - - Pbind( - \type, \midi, - \chan, v, - \noteval, Pseq(freqs.cpsmidi - 24, 1), - \note, Pfunc({ | event | event[\noteval].floor }), - \dur, Pseq(fDurs, 1), - \midiout, mOut, - \amp, 1, - \bend, Pfunc({ - | event | - if (event[\note].isRest.not) { - var pitchbendvalue = event[\noteval].frac.linlin(0, pbRange, 8192, 8192*2).asInteger; - m.bend(v, pitchbendvalue); - }; - 0; // return something other than nil to avoid stopping the pattern - }), - ); - }); - ); - res -}; -*/ - - -//------resource management funcs - -genUID = {Date.seed.asHexString.toLower}; - -seedFunc = {arg func, seed; - var funcArgs, next; - next = Routine({loop{func.valueArray(funcArgs).yield }}); - next.randSeed_(seed); - {arg ...args; funcArgs = args; next.value} -}; - -stringifyToDepth = {arg data, maxDepth = 1; - var prettyString = "", rCount = 0, writeArray, indent; - - if(maxDepth == 0, { - data.asCompileString - }, { - indent = {arg size; size.collect({" "}).join("")}; - writeArray = {arg array; - prettyString = prettyString ++ indent.value(rCount) ++ "[\n"; - rCount = rCount + 1; - if(rCount < maxDepth, { - array.do({arg subArray; writeArray.value(subArray)}); - }, { - prettyString = prettyString ++ array.collect({arg subArray; - indent.value(rCount + 1) ++ subArray.asCompileString - }).join(",\n"); - }); - rCount = rCount - 1; - prettyString = prettyString ++ "\n" ++ indent.value(rCount) ++ "],\n"; - }; - - writeArray.value(data); - prettyString.replace(",\n\n", "\n").drop(-2); - }) -}; - -sanityCheck = {arg motif, index; - //print functions = very helpful - ("----------" + index + "------------").postln; - - motif.flatten.do({arg val, v; - if(v > 0, { - if(motif.flatten[v-1][0].hammingDistance(val[0]) > 1, {"problem 1".postln}); - if(motif.flatten[v-1][0].hammingDistance(val[0]) == 0, {"problem 2".postln}); - }); - val.postln - }); - "***********".postln; -}; - -msgInterpret = {arg in, escapeDoubleQuotes = true, escapeSingleQuotes = true; - var res; - - res = in; - if(res.isNil.not, { - if((res.isArray && res.isString.not), { - res = res.asCompileString; - res = res.replace(" ", "").replace("\n", "").replace("\t", ""); - if(escapeSingleQuotes, {res = res.replace("\'", "")}); - if(escapeDoubleQuotes, {res = res.replace("\"", "")}); - res = res.replace("Rest", "\"Rest\""); - res = res.interpret; - }, { - var tmpRes; - if(res.every({arg char; char.isDecDigit}), {tmpRes = res.asInteger}); - if(res.contains("."), {tmpRes = res.asFloat}); - if(tmpRes != nil, {res = tmpRes}); - }); - }); - res -}; - -writeResources = {arg path, dict; - var file, modelItems, resString; - file = File(path,"w"); - - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - - resString = nameSpaces.collect({arg nameSpace; - var depth = 0, insert = " "; - if(nameSpace == "music_data", {depth = 3; insert = "\n"}); - if(nameSpace == "last_changes", {depth = 1; insert = "\n"}); - if(nameSpace == "order", {depth = 1; insert = "\n"}); - if((nameSpace == "ref_uid") && (dict[nameSpace] == nil), {dict[nameSpace] = "nil"}); - "\"" ++ nameSpace ++ "\":" ++ insert ++ stringifyToDepth.value(dict[nameSpace], depth) - }).join(",\n"); - - resString = "{\n" ++ resString ++ "\n}"; - - file.write(resString); - file.close; - resString -}; - -loadModelFile = {arg path; loadModelJSON.value(File(path, "r").readAllString.parseJSON)}; - -loadModelJSON = {arg jsonObject; - var dict; - dict = Dictionary.with(*nameSpaces.collect({arg nS; nS->msgInterpret.value(jsonObject[nS])})); - dict -}; - -setGlobalVars = {arg dict, skipLastXChanges = false; - var tmpLastXChanges; - tmpLastXChanges = lastXChanges.deepCopy; - // order really matters!!!! - # seq, lastXChanges, curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited = nameSpaces.collect({arg nS; dict[nS]}); - if(skipLastXChanges, {lastXChanges = tmpLastXChanges}); - dict -}; - -globalVarsToDict = { - var modelItems, dict; - // order really matters!!!! - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - dict = Dictionary.with(*nameSpaces.collect({arg nS, n; nS->modelItems[n]})); -}; - -loadLedgerFile = {arg path; - ledgerPath = path; - loadLedgerJSON.value(File(ledgerPath, "r").readAllString.parseJSON) -}; - -loadLedgerJSON = {arg jsonObject; ledger = jsonObject["ledger"]}; - -saveLedger = {arg ledger, path; - var file; - file = File(path, "w"); - file.write("{\n\"ledger\":\n" ++ stringifyToDepth.value(ledger, 1) ++ "\n}"); - file.close; -}; - -//------global vars - -primes = [[2, 1], [3, 2], [5, 4], [7, 4], [11, 8], [13, 8]]; -//ranges = [[-2400, 0], [-1200, 1200], [0, 2400], [0, 2400]]; -exPath = thisProcess.nowExecutingPath; -dir = exPath.dirname; -//popSize = 4; -dims = primes.size; -tuples = genTuples.value(); -//refUID = nil; -group = Group.new; -~group = group; -loadLedgerFile.value(dir +/+ ".." +/+ "resources" +/+ "piece_ledger.json"); -//passagesWeights = [1, 1, 1, 1, 1]; -//susWeights = [1, 1, 1]; -// order really matters!!!! -nameSpaces = [ - "music_data", "last_changes", "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", - "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", - "ranges", "step_probs_vals", "passages_weights", "hd_exp", "hd_invert", - "order", "sus_weights", "order_size", "passages_size", - "motif_edited", "order_edited" -]; - - -//------OSC funcs - -OSCdef(\load_ledger, {arg msg, time, addr, port; - loadLedgerFile.value(msg[1].asString); -}, \load_ledger); - -OSCdef(\load_model, {arg msg, time, addr, port; - var dict; - dict = loadModelFile.value(msg[1].asString); - setGlobalVars.value(dict); -}, \load_model); - -OSCdef(\save_ledger, {arg msg, time, addr, port; - msg.postln; - ledger = msgInterpret.value(msg[1].asString.parseJSON["ledger"], false).postln; - //loadLedgerJSON.value(msg[0]) - saveLedger.value(ledger, msg[2].asString); - //loadLedgerFile.value(msg[1].asString); -}, \save_ledger); - -OSCdef(\generate, {arg msg, time, addr, port; - var path, dict, durSeeds, musPath, modelString; - msg.postln; - - path = msg[1].asString; - - dict = loadModelFile.value(path); - setGlobalVars.value(dict, true); - - popSize = ranges.size; - - //refUID.postln; - - loadLedgerFile.value(ledgerPath); - if(ledger == nil, {ledger = ["tmp"]}); - if(ledger.last != "tmp", {ledger = ledger.add("tmp")}); - - if(refUID == nil, {lastXChanges = [initVoices.value().deepCopy]}); - if((refUID != nil) && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - lastXChanges = msgInterpret.value(file.readAllString.parseJSON["last_changes"]); - }); - - refUID.postln; - lastXChanges.collect({arg item; item.postln}); - - durSeeds = seedFunc.value({3.collect({rrand(100000, 999999)})}, durSeed).value.postln; - entrancesDurFunc = genDurFunc.valueArray(entrancesProbVals[..4] ++ [entrancesProbVals[5..]] ++ [durSeeds[0]]); - passagesDurFunc = genDurFunc.valueArray(passagesProbVals[..4] ++ [passagesProbVals[5..]] ++ [durSeeds[1]]); - exitsDurFunc = genDurFunc.valueArray(exitsProbVals[..4] ++ [exitsProbVals[5..]] ++ [durSeeds[2]]); - - if(orders == nil, { - orders = seedFunc.value(genOrders, orderSeed).valueArray(orderSize ++ passagesSize); - //addr.sendMsg("/order", stringifyToDepth.value(orders, 1)); - }); - - stepFunc = genStepFunc.valueArray(stepProbsVals[..1] ++ [stepProbsVals[2..]] ++ [motifSeed]); - seq = seedFunc.value(genMotif, motifSeed).value; - - lastXChanges.collect({arg item; item.postln}); - - dict = globalVarsToDict.value; - modelString = writeResources.value(path, dict); - - //addr.sendMsg("/generated", musPath, stringifyToDepth.value(seq, 3)); - //~seq = seq; - - addr.sendMsg("/generated", path, modelString, ledgerPath); -}, \generate); - - -OSCdef(\commit, {arg msg, time, addr, port; - var musicData, musicChanged, dict, newLedger, modelPath, musString, musFile, test1, test2, lastCurUID, commitType; - //msg.postln; - - /* - test1 = msg[1].asString.parseJSON; - test2 = (dir +/+ ".." +/+ "resources/tmp/tmp_music" ++ ".json").standardizePath.parseJSONFile; - msgInterpret.value(test1["music"])[0][0][0][1].class.postln; - msgInterpret.value(test2["music_data"])[0][0][0][1].class.postln; - (test1["music"] == test2["music_data"]).postln; - */ - - musicData = loadModelJSON.value(msg[1].asString.parseJSON)["music_data"].postln; - musicChanged = (musicData != seq).postln; - commitType = msg[2].asString; - - lastCurUID = curUID.deepCopy; - curUID = genUID.value; - - File.mkdir((dir +/+ ".." +/+ "resources" +/+ curUID).standardizePath); - File.copy(exPath, (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_code" ++ ".scd").standardizePath); - - modelPath = (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_mus_model" ++ ".json").standardizePath; - dict = globalVarsToDict.value; - if(musicChanged, { - seq = musicData; - dict["music_data"] = seq; - dict["motif_edited"] = "true" - }); - dict["cur_uid"] = curUID; - - writeResources.value(modelPath, dict); - - File.delete(ledgerPath ++ "_bak"); - File.copy(ledgerPath, ledgerPath ++ "_bak"); - File.delete(ledgerPath); - - if(commitType == "add", { - if(lastCurUID == "tmp", { - ledger = ledger.drop(-1).add(curUID); - }, { - ledger = ledger.add(curUID); - }) - }); - - if(commitType == "insert", {ledger = ledger.insert(ledger.indexOf(lastCurUID), curUID)}); - - if(commitType == "replace", {ledger = ledger.put(ledger.indexOf(lastCurUID), curUID)}); - - saveLedger.value(ledger, ledgerPath); - - addr.sendMsg("/committed", curUID, ledgerPath); - //refUID = curUID; - -}, \commit); - -OSCdef(\transport, {arg msg, time, addr, port; - msg.postln; - if(msg[1] == 0, { - group.set(\release, 2); - group.set(\gate, 0); - player.stop; - }, { - // the cued sequence can now be read from file, so this can be cleaned up - var cSize, patterns, pSeq, cuedSeek, indexStart, indexEnd, tmpLedger; - if(msg[1] == 1, { - pSeq = []; - cuedSeek = (seq != nil); - indexStart = msg[2].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.postln.parseJSON["music_data"]), path, indexStart + index, uid]); - file.close; - }); - }); - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - patterns = genPatterns.value(pSeq, addr); - }, { - pSeq = [loadModelJSON.value(msg[2].asString.parseJSON)["music_data"].postln]; - patterns = genPatterns.value(pSeq, addr, true); - }); - player = Pfset(pattern: patterns, cleanupFunc: { - addr.sendMsg("/transport", 0); - addr.sendMsg("/one_shot", 0); - }); - player = player.play - }); -}, \transport); - - -OSCdef(\transcribe_motif, {arg msg, time, addr, port; - var tSeq, refChord, refUID; - - msg.postln; - - tSeq = [loadModelJSON.value(msg[1].asString.parseJSON)["music_data"]]; - refUID = msg[2].asString.postln; - - if((refUID != "nil") && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }, { - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - }); - - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "lilypond" +/+ "includes").standardizePath, addr, "/transcribe_motif"); -}, \transcribe_motif); - - -OSCdef(\transcribe_all, {arg msg, time, addr, port; - var cSize, patterns, cuedSeek, indexStart, indexEnd, tmpLedger; - if(true, { - cuedSeek = (seq != nil); - indexStart = msg[1].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - - //tmp for testing transcription - indexEnd = (indexStart+5); - - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - var lilyPartLedgerFiles; - - lilyPartLedgerFiles = 4.collect({arg p; - File((dir +/+ ".." +/+ "lilypond" +/+ "includes" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly").standardizePath, "w"); - }); - - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file, fileString, tSeq, refUID, refChord; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - fileString = file.readAllString; - tSeq = msgInterpret.value(fileString.parseJSON["music_data"]); - refUID = msgInterpret.value(fileString.parseJSON["ref_uid"]); - file.close; - - //uid.postln; - //(refUID == "nil").postln; - - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - - if(refUID != "nil", { - path = (dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }); - - if(index != indexEnd, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath); - }, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath, addr, "/transcribe_all"); - }); - - lilyPartLedgerFiles.do({arg f, p; - f.write("\\include \".." +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly\"\n"); - }); - - }); - - lilyPartLedgerFiles.do({arg f; - f.close - }); - }); - /* - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - */ - }, { - - }); - -}, \transcribe_all); - -) - -~transcribe.value(~seq, dir); - -( -//synthdefs -~stringModelBusArray = 4.collect({Bus.audio(s, 1)}); -~sineBusArray = 4.collect({Bus.audio(s, 1)}); -~bassBusArray = 1.collect({Bus.audio(s, 1)}); -~hdustBusArray = 1.collect({Bus.audio(s, 1)}); -~samplerBusArray = 2.collect({Bus.audio(s, 1)}); -~sBuf = Buffer.alloc(s, 10, 2); -SynthDef(\string_model, {arg freq, gate = 1, sustain, amp, dur, attack, release = 1, busIndex = 0; - var trig, exc, sig1, sig2, noHarms; - noHarms = rrand(20, 40); - exc = Saw.ar(freq, TRand.ar(0.5, 1, Impulse.ar(freq))) * 0.001 + Dust.ar(10000, 0.01); - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.8).softclip; - //sig1 = HPF.ar(sig1, 300); - Out.ar(Select.kr(busIndex, ~stringModelBusArray), sig1 * amp * EnvGen.kr(Env.adsr(attack, 0.3, 0.9, release, 0.9, -3), gate, doneAction: 2)); - //Out.ar([0, 1], sig1 * EnvGen.kr(Env.asr(dur, 0.3, 1), gate, doneAction: 2)); -}).add; - -SynthDef(\sine, {arg freq, gate = 1, sustain, amp, dur, busIndex = 0; - var sig; - sig = SinOsc.ar(freq); - Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.asr(0.3, 0.4, 0.3), gate, timeScale: dur, doneAction: 2)); - //Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.sine(dur), gate, doneAction: 2)); -}).add; - -SynthDef(\mixer, {arg freq, gate = 1, sustain, amp, dur, out; - var nameSpaces, sigs; - - sigs = [~stringModelBusArray, ~sineBusArray/*, ~bassBusArray, ~hdustBusArray, ~samplerBusArray*/].collect({arg busArray, i; - var nameSpace, sig; - nameSpace = ['string', 'sine', 'bass', 'hdust', 'sampler'][i]; - sig = busArray.collect({arg bus, c; In.ar(bus, 1) * NamedControl.kr(\ ++ nameSpace ++ '_volume_' ++ c, 1, 0.1)}); - sig = sig.collect({arg channel, c; Pan2.ar(channel, NamedControl.kr(\ ++ nameSpace ++ '_pan_' ++ c, i / (busArray.size - 1), 0.1) * 2 - 1)}); - sig = sig.collect({arg channel, c; channel * NamedControl.kr(\ ++ nameSpace ++ '_mute_' ++ c, 1, 0.1)}); - sig = Mix.ar(sig) * pow(NamedControl.kr(\ ++ nameSpace ++ '_volume_master', 1, 0.1), 2); - }); - - sigs = Mix.ar(sigs / 4); - Out.ar(0, sigs) -}).add; - -SynthDef(\bass, { - var switches, drone; - switches = {|i| Dust.kr(0.1)} ! 9; - drone = {|i| var harm = pow(2, 2 - (i / 3).trunc), amp = (1 / pow(harm, 2)); - SinOsc.ar(60 * harm + TRand.kr(-3, 3, switches[i]), 0, amp)} ! 9; - Out.ar(~bassBusArray[0], Mix.new(drone) * 0.2); -}).add; - -SynthDef(\sampler, { - Out.ar(~samplerBusArray, PlayBuf.ar(2, ~sBuf, BufRateScale.kr(~sBuf), doneAction: 2)) -}).add; - -// main routine -SynthDef(\hdust, { - arg gate = 0; - var hierarchical_dust, low_sine, high_sine, brown_noise, white_noise; - // this triggers the combinations of sources - // it is similar to the Supercollider UGen called dust but with a hierarchical structure - hierarchical_dust = ( - TIRand.kr(0, 1, Impulse.kr(100)) * - TIRand.kr(0, 1, Impulse.kr(10)) * - TIRand.kr(0, 1, Impulse.kr(1)) * - TIRand.kr(0, 1, Impulse.kr(0.1)) - ); - // adjust the multiplier at the end of each line for adjusting levels - // note with each trigger, each source has a 1 in 3 chance of sounding - low_sine = SinOsc.ar(76.midicps / 16) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.1; - high_sine = SinOsc.ar(76.midicps * 8) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.01; - brown_noise = BrownNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.025; - white_noise = WhiteNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.02; - Out.ar(~hdustBusArray[0], - ((low_sine + high_sine + brown_noise + white_noise) ) - ); -}).add; - -) - -( -var bass, hdust, sampler, mixer; -/* -bass = Synth.tail(~group, \bass); -hdust = Synth.tail(~group, \hdust); -sampler = Synth.head(~group, \sampler); -*/ -mixer = Synth.tail(~group, \mixer); - -OSCdef(\mixer, {arg msg, time, addr, port; - mixer.set((msg[1] ++ '_' ++ msg[2] ++ '_' ++ msg[3]), msg[4]) -}, \mixer); - -/* -OSCdef(\sampler, {arg msg, time, addr, port; - msg.postln; - sampler.free; - ~sBuf.free; - ~sBuf = Buffer.read(s, msg[1].asString.postln, action: {sampler = Synth.head(~group, \sampler)}); -}, \sampler); -*/ -) - -/* old something -( -SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; - var trig, exc, sig1, sig2, noHarms, freqFinal, start, end; - noHarms = 30; - freq = WhiteNoise.ar * 3 + freq; - freqFinal = Duty.ar((1/freq), 0, freq); - trig = Changed.ar(freqFinal); - start = Demand.ar(trig, 0, Dwhite(-1, -0.75)); - end = Demand.ar(trig, 0, Dwhite(0.75, 1)); - exc = Phasor.ar(trig, (end - start) * freqFinal / SampleRate.ir, start, end, 0) * 0.001 + Dust.ar(10000, 0.01); - - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(2, 3)}) ], exc) * 0.5).softclip; - sig1 = HPF.ar(sig1, 300); - Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); -}).add; -) -*/ - diff --git a/resources/78f2229c/78f2229c_mus_model.json b/resources/78f2229c/78f2229c_mus_model.json deleted file mode 100644 index 0efa597..0000000 --- a/resources/78f2229c/78f2229c_mus_model.json +++ /dev/null @@ -1,73 +0,0 @@ -{ -"music_data": -[ - [ - [ - [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ] ], 0 ], - [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ]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], 7.0 ] - ] - ] -], -"last_changes": -[ - [ [ 0, 1, 0, 0, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ], [ 1, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], - [ [ 0, 1, 0, 0, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ], [ 1, 0, 0, 0, 0, 0 ], [ -1, 1, -1, 0, 0, 0 ] ], - [ [ 0, 1, 0, 0, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ], [ 0, 1, -1, 0, 0, 0 ], [ -1, 1, -1, 0, 0, 0 ] ], - [ [ 0, 1, 0, 0, 0, 0 ], [ 2, 1, 0, 0, 0, -1 ], [ 0, 1, -1, 0, 0, 0 ], [ -1, 1, -1, 0, 0, 0 ] ], - [ [ 0, 1, 0, 0, 0, 0 ], [ 0, 1, 0, 1, 0, 0 ], [ 0, 1, -1, 0, 0, 0 ], [ -1, 1, -1, 0, 0, 0 ] ] -], -"cur_uid": "78f2229c", -"ref_uid": "nil", -"order_seed": 616702, -"dur_seed": 919274, -"motifs_seed": 913801, -"entrances_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.26424870466321, 0.75675675675676, 0.5, 0.5, 0.58549222797927, 0.72635135135135, 1, 0.5 ], -"passages_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"exits_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"ranges": [ [ -384, 2400 ], [ -507, 2400 ], [ -282, 2237 ], [ -1200, 2053 ] ], -"step_probs_vals": [ 0, 1200, 0, 0.5, 0.5, 0.5, 1, 0.5 ], -"passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], -"hd_exp": 2, -"hd_invert": 0, -"order": -[ - [ [ 3, 0 ], [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ], [ 2 ] ], - [ [ 3 ], [ 2, 0, 1, 2, 1 ], [ ] ], - [ [ 0, 2, 1 ], [ 3 ], [ ] ], - [ [ 0 ], [ 2, 1, 1 ], [ 3 ] ] -], -"sus_weights": [ 0.75, 0.69, 0.75 ], -"order_size": [ 2, 6 ], -"passages_size": [ 0, 10 ], -"motif_edited": "false", -"order_edited": "false" -} \ No newline at end of file diff --git a/resources/7ac10d34/lilypond/part_I.ly b/resources/7ac10d34/lilypond/part_I.ly deleted file mode 100644 index 7ffc0e0..0000000 --- a/resources/7ac10d34/lilypond/part_I.ly +++ /dev/null @@ -1,28 +0,0 @@ -{ - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" \break - { r2. r8[ d''8^\markup { \pad-markup #0.2 "+31"}] ~ } - \bar "|" - { d''1 ~ } - \bar "|" - { d''1 ~ } - \bar "|" - { d''1 ~ } - \bar "|" \break - { d''1 ~ } - \bar "|" - { d''1 ~ } - \bar "|" - { d''2. ~ d''8[ r8] } - \bar "|" - { r1 } - \bar "|" \break - { r1 } -\bar "||" -} \ No newline at end of file diff --git a/resources/7ac10d34/lilypond/part_II.ly b/resources/7ac10d34/lilypond/part_II.ly deleted file mode 100644 index d86a02b..0000000 --- a/resources/7ac10d34/lilypond/part_II.ly +++ /dev/null @@ -1,28 +0,0 @@ -{ - { r2 r8.[ gis'16^\markup { \pad-markup #0.2 "+41"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 13↑" }}] ~ gis'4 ~ } - \bar "|" - { gis'8[ g'8^\markup { \pad-markup #0.2 "+2"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 3↑" }}] ~ g'4 ~ g'16[ fis'8.^\markup { \pad-markup #0.2 "-49"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 11↑" }}] ~ fis'8.[ fis'16^\markup { \pad-markup #0.2 "+49"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 11↓" }}] ~ } - \bar "|" - { fis'2 ~ fis'8.[ f'16^\markup { \pad-markup #0.2 "-2"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 3↓" }}] ~ f'4 ~ } - \bar "|" - { f'4 e'4^\markup { \pad-markup #0.2 "-14"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 5↑" }} ~ e'2 ~ } - \bar "|" \break - { e'16[ d'8.^\markup { \pad-markup #0.2 "+31"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 7↓" }}] ~ d'2. ~ } - \bar "|" - { d'1 ~ } - \bar "|" - { d'1 ~ } - \bar "|" - { d'1 ~ } - \bar "|" \break - { d'1 ~ } - \bar "|" - { d'1 ~ } - \bar "|" - { d'1 ~ } - \bar "|" - { d'4 ~ d'16[ r8.] r2 } - \bar "|" \break - { r1 } -\bar "||" -} \ No newline at end of file diff --git a/resources/7ac10d34/lilypond/part_III.ly b/resources/7ac10d34/lilypond/part_III.ly deleted file mode 100644 index b8adb43..0000000 --- a/resources/7ac10d34/lilypond/part_III.ly +++ /dev/null @@ -1,28 +0,0 @@ -{ - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" \break - { r2. r8[ g'8^\markup { \pad-markup #0.2 "+29"}] ~ } - \bar "|" - { g'1 ~ } - \bar "|" - { g'1 ~ } - \bar "|" - { g'1 ~ } - \bar "|" \break - { g'1 ~ } - \bar "|" - { g'1 ~ } - \bar "|" - { g'1 ~ } - \bar "|" - { g'4 ~ g'16[ r8.] r2 } - \bar "|" \break - { r1 } -\bar "||" -} \ No newline at end of file diff --git a/resources/7ac10d34/lilypond/part_IV.ly b/resources/7ac10d34/lilypond/part_IV.ly deleted file mode 100644 index f8891f3..0000000 --- a/resources/7ac10d34/lilypond/part_IV.ly +++ /dev/null @@ -1,28 +0,0 @@ -{ - { c'4^\markup { \pad-markup #0.2 "+0"} ~ c'2. ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" \break - { c'1 ~ } - \bar "|" - { c'2 b4^\markup { \pad-markup #0.2 "+16"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "III"\normal-size-super " 5↑" }} ~ b4 ~ } - \bar "|" - { b16[ c'8.^\markup { \pad-markup #0.2 "+27"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "III"\normal-size-super " 3↓" }}] ~ c'4 ~ c'16[ a8.^\markup { \pad-markup #0.2 "+33"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 3↑" }}] ~ a16[ ais8.^\markup { \pad-markup #0.2 "+45"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 5↓" }}] ~ } - \bar "|" - { ais2 ~ ais8[ b8^\markup { \pad-markup #0.2 "-11"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "III"\normal-size-super " 13↓" }}] ~ b4 ~ } - \bar "|" \break - { b2 ~ b8[ ais8^\markup { \pad-markup #0.2 "-40"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "III"\normal-size-super " 7↓" }}] ~ ais4 ~ } - \bar "|" - { ais2 b4^\markup { \pad-markup #0.2 "+16"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "III"\normal-size-super " 5↑" }} ~ b4 ~ } - \bar "|" - { b4 c'4^\markup { \pad-markup #0.2 "+27"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "III"\normal-size-super " 3↓" }} ~ c'2 ~ } - \bar "|" - { c'4 ~ c'16[ r8.] r2 } - \bar "|" \break - { r1 } -\bar "||" -} \ No newline at end of file diff --git a/resources/7bda0503/7bda0503_code.scd b/resources/7bda0503/7bda0503_code.scd deleted file mode 100644 index eef8850..0000000 --- a/resources/7bda0503/7bda0503_code.scd +++ /dev/null @@ -1,1056 +0,0 @@ -( -// helper funcs -var hsArrayToCents, pDist, hdSum, hsChordalDistance, hsArrayToFreq; - -// score funcs -var isInRange, spacingScore, rangeScore, intervalScore, inclusionScore; - -// subroutines -var genTuples, initVoices, genOrders, genSubMotif, updateVoices, genDurFunc, genStepFunc; - -// primary routines -var genMotif, genSecondarySeq; - -// audition funcs -var genPatterns, genMidiPatterns; - -// resource management funcs -var seedFunc, genUID, writeResources, stringifyToDepth, setSeeds, sanityCheck, -msgInterpret, loadLedgerFile, loadLedgerJSON, loadModelFile, loadModelJSON, -setGlobalVars, globalVarsToDict, saveLedger; - -// model vars -//(model and global vars mostly set by OSC funcs -var seq, lastXChanges, -curUID, refUID, orderSeed, durSeed, motifSeed, -entrancesProbVals, passagesProbVals, exitsProbVals, -ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, -orders, susWeights, orderSize, passagesSize, -motifEdited, orderEdited; - -// model aux vars -var entrancesDurFunc, passagesDurFunc, exitsDurFunc, stepFunc; - -// other global vars -var popSize, exPath, dir, primes, dims, tuples, -group, player, ledgerPath, ledger, currentlyPlayingUID, -nameSpaces; - -// install JSON quark -if(Quarks.isInstalled("JSONlib").not, { - Quarks.install("https://github.com/musikinformatik/JSONlib.git"); - thisProcess.recompile; - //HelpBrowser.openHelpFor("Classes/JSONlib"); -}); - - -//------helper funcs - -hsArrayToCents = { - arg hsArray; - hsArray.collect({arg dist, p; dist * 1200 * log2(primes[p][0]/primes[p][1])}).sum -}; - -pDist = { - arg array1, array2, signed = false; - var pDistance; - pDistance = hsArrayToCents.value(array1) - hsArrayToCents.value(array2); - if(signed, {pDistance}, {abs(pDistance)}) -}; - -hdSum = { - arg hsArrays; - var size, distances, mean; - size = hsArrays.size; - distances = (size - 1).collect({arg i; - ((i + 1)..(size - 1)).collect({arg j; - abs(hsArrays[i] - hsArrays[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsChordalDistance = { - arg hsArrays1, hsArrays2; - var size, distances, mean; - size = hsArrays1.size; - distances = hsArrays1.size.collect({arg i; - hsArrays2.size.collect({arg j; - abs(hsArrays1[i] - hsArrays2[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsArrayToFreq = { - arg array; - array.collect({arg dim, d; pow(primes[d][0]/primes[d][1], dim)}).product -}; - -//------score funcs - -/* -isInRange = { - arg hsArray, min, max; - var cents; - cents = hsArrayToCents.value(hsArray); - (cents >= min) && (cents <= max) -}; -*/ - -spacingScore = { - arg hsArrays, min; - var centsArray; - centsArray = hsArrays.collect({arg hsArray; hsArrayToCents.value(hsArray)}).sort({arg a, b; a < b}); - centsArray.differentiate.drop(1).collect({arg pDistance; if(pDistance >= min, {1}, {0.01})}).sum; -}; - -rangeScore = { - arg hsArray1, hsArray2, min, max, low, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - if((pDistance >= min) && (pDistance <= max), {1}, {low}); -}; - -intervalScore = { - arg hsArray1, hsArray2, mean, sd, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - //pDistance.gaussCurve(1, mean, sd) - stepFunc.value(pDistance); -}; - -inclusionScore = { - arg array, test, min = 0.01; - if(array.collect({arg v; v.hash}).includes(test.hash), {min}, {1}); -}; - - -//------subroutines - -genTuples = { - var tuples; - tuples = dims.collect({[-1, 0, 1]}).allTuples.select({arg tuple; (abs(tuple.drop(1)).sum <= 1) && (tuple[0] == 0)}); - tuples = tuples ++ tuples.collect({arg tuple; [-3, -2, -1, 1, 2, 3].collect({arg octTrans; tuple.deepCopy.put(0, octTrans)})}).flatten; -}; - -initVoices = { - var init, voicesInit; - voicesInit = popSize.collect({dims.collect({0})}); - /* - voicesInit = [dims.collect({0})]; - (popSize - 1).do({ - arg rep, new; - rep = dims.rand; - new = voicesInit.last.deepCopy; - new[rep] = new[rep] + [-1, 1].choose(); - voicesInit = voicesInit.add(new); - }); - */ - voicesInit.deepCopy; -}; - -genDurFunc = {arg chordProb, minPad, maxPad, minDur, maxDur, envData, seed; - var env, pTable, durFunc; - env = Env.pairs([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).asSignal(256).asList.asArray; - pTable = env.asRandomTable; - [chordProb, minPad, maxPad, minDur, maxDur, envData].postln; - durFunc = {arg allowChord, pad = false; - var res; - res = if(allowChord.not, { - pTable.tableRand * (maxDur - minDur) + minDur - }, { - if(1.0.rand < chordProb, {0}, {pTable.tableRand * (maxDur - minDur) + minDur}); - }).round(0.125); - if(pad, {res = res + rrand(minPad.asFloat, maxPad.asFloat).round(0.125)}); - if(res.asInteger == res, {res = res.asInteger}); - res - }; - seedFunc.value(durFunc, seed); -}; - -genStepFunc = {arg minStep, maxStep, envData, seed; - var envDataNorm, env, pTable, stepFunc; - [minStep, maxStep, envData].postln; - envDataNorm = ([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).flop; - envDataNorm = [envDataNorm[0].normalize(minStep, maxStep), envDataNorm[1]].flop; - env = Env.pairs(envDataNorm); - stepFunc = {arg pDist; - env.at(pDist).clip(0.001, 1); - }; - seedFunc.value(stepFunc, seed); -}; - -genOrders = {arg minMotifLength = 1, maxMotifLength = 5, minProgLength = 0, maxProgLength = 5; - ((maxMotifLength - minMotifLength).rand + minMotifLength).collect({ - var noProgIns, noSusIns, noSilentIns, prog, sus, silent, order; - noSusIns = [1, 2, 3].wchoose(susWeights.normalizeSum); - noProgIns = (popSize - noSusIns).rand + 1; - noSilentIns = popSize - noSusIns - noProgIns; - - # prog, sus, silent = (0..(popSize-1)).scramble.clumps([noProgIns, noSusIns, noSilentIns]); - - prog = (prog.scramble ++ ((maxProgLength - minProgLength).rand + minProgLength).collect({prog.choose}).scramble); - if(silent == nil, {silent = []}); - [sus.scramble, prog, silent.scramble] - }); -}; - -updateVoices = {arg ins, sus; - var voices, candidates, nWeights, nProbs, sel; - - voices = lastXChanges.deepCopy.last; - - candidates = sus.collect({arg v; tuples.collect({arg t; voices[v] + t})}).flatten; - candidates = difference(candidates.asSet, voices.asSet).asList; - nProbs = candidates.collect({arg candidate; - var stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore; - - //stepScore = intervalScore.value(voices[ins], candidate, 30, 400, 0.1); - stepScore = intervalScore.value(voices[ins], candidate, 100, 100); - recentlySoundedScore = inclusionScore.value(lastXChanges.flop[ins], candidate, 0); - isInRangeScore = rangeScore.value(candidate, candidate.collect({0}), ranges[ins][0], ranges[ins][1], 0, true); - regScore = spacingScore.value(voices.deepCopy.put(ins, candidate), 300); - hdScore = pow(hdSum.value(voices.deepCopy.put(ins, candidate)), hdExp); - if(hdInvert == 0, {hdScore = 1/hdScore}); - //maybe what you want here is a vector to another root and then favoring movement towards it. - //distScore = pow(hsChordalDistance.value(voices, voices.put(ins, candidate)), 2); - - [stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore] - }); - - nWeights = passagesWeights; - - //this handles nWeights of 0; mainly for testing - nProbs = nProbs.flop.select({arg scores, s; nWeights[s] != 0}).flop; - nWeights = nWeights.select({arg weight; weight != 0}); - nProbs = nProbs.flop.collect({arg scores, s; - if(scores.sum == 0, {scores}, {scores.normalizeSum * nWeights[s]}) - }); - nProbs = nProbs.flop.collect({arg scores, s; scores.product}).normalizeSum; - - sel = candidates.wchoose(nProbs); - - voices[ins] = sel; - lastXChanges = lastXChanges.add(voices).keep(-5); -}; - -genSubMotif = {arg order, orderIndex, lastState, repeatLast = false, startFromLast = false, isLastOrder = false; - var sus, prog, silent, flatOrder, res, isInChord, allowChord, pad, lastXChangesHold, voices, adder; - # sus, prog, silent = order; - flatOrder = silent ++ sus ++ prog; - lastXChangesHold = lastXChanges.deepCopy; - voices = lastState.deepCopy; - isInChord = popSize.collect({false}); - allowChord = false; - pad = false; - res = []; - "------generating motif".postln; - //need to figure out here if voices move between motifs - flatOrder.do({arg ins, i; - - if(prog.includes(ins) && repeatLast.not, {updateVoices.value(ins, sus)}); - adder = if(silent.includes(ins), {["Rest"]}, {lastXChanges.last.deepCopy[ins]}); - - if(voices[ins] != adder, { - var dur; - - if((sus ++ silent).includes(ins), { - allowChord = (ins != sus.last); - pad = (ins == sus.last); - }, { - if(i < (flatOrder.size - 1), { - allowChord = (isInChord[flatOrder[i + 1]] || (ins == flatOrder[i + 1])).not; - pad = false; - }, { - allowChord = false; - pad = true - }); - }); - if((orderIndex == 0) && sus.includes(ins), { - dur = entrancesDurFunc.value(allowChord, pad); - }, { - dur = passagesDurFunc.value(allowChord, pad); - }); - if(dur == 0, {isInChord[ins] = true}, {isInChord = popSize.collect({false})}); - - voices[ins] = adder; - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - - // pad ending - if(orderIndex == (orders.size - 1), { - (0..(popSize-1)).scramble.do({arg ins; - if(res.last.first[ins] != ["Rest"], { - var dur; - voices[ins] = ["Rest"]; - allowChord = (voices != popSize.collect({["Rest"]})); - pad = allowChord.not; - dur = exitsDurFunc.value(allowChord, pad); - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - }); - - //format and return - if(startFromLast, {lastXChanges = lastXChangesHold.deepCopy}); - res; -}; - - -//------primary routines - -genMotif = { - var repeats, fSeq, fDur, durAdd; - - repeats = 1; - fSeq = []; - - repeats.do({arg index; - var motif; - - motif = []; - - orders.do({arg order, o; - var lastState, subMotif; - lastState = if(o == 0, {popSize.collect({["Rest"]})}, {motif.last.last.first}); - subMotif = genSubMotif.value(order, o, lastState, isLastOrder: o == (orders.size - 1)); - motif = motif.add(subMotif); - - }); - - sanityCheck.value(motif, index); - - fSeq = fSeq.add(motif); - }); - - //round last duration to measure - fDur = fSeq.flatten.flatten.slice(nil, 1).sum; - durAdd = fDur.round(4) - fDur; - if(durAdd < 0, {durAdd = 4 - durAdd}); - fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] = fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] + durAdd; - - fSeq -}; - -genSecondarySeq = {arg seq; - var curdles, fSeq; - curdles = []; - while({curdles.sum < seq.size}, {curdles = curdles ++ [3.rand + 1]}); - - fSeq = seq.clumps(curdles).collect({arg clump, m; - var repeats, paddedSeq; - - //add rest - paddedSeq = clump.add([[[popSize.collect({["Rest"]}), 0.5.rand]]]); - - //implement repeats - repeats = [0.rand + 1, 1].wchoose([1, 0].normalizeSum); - repeats.collect({paddedSeq}); - }); - fSeq -}; - - -//------audition funcs - -/* -Event.addEventType(\osc, { - if (~addr.postln.notNil) { - ~addr.sendMsg(~indexPath, ~indexMsg); - ~addr.sendMsg(~seqPath, stringifyToDepth.value(~seqMsg, 3)); - //~addr.sendMsg("/STATE/OPEN", (dir.replace("supercollider", "resources") +/+ ~idMsg +/+ ~idMsg ++ "_gui_state" ++ ".state").standardizePath.postln); - }; -}); -*/ - -Event.addEventType(\osc, { - if (~addr.notNil) { - ~msg; - ~addr.sendMsg(~path, *~msg); - }; -}); - -genPatterns = {arg inSeq, addr, oneShot = false; - var voices, durs, pbinds, res, indices, sectionDurs, msg, ids, seq; - seq = inSeq.collect({arg mSeq; mSeq[0]}); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - pbinds = voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs, attacks, rels, amps; - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - //attacks = 2.collect({rrand(1, 3)}) ++ freqs.drop(2).collect({rrand(0.3, 0.5)}); - attacks = fDurs.collect({arg dur; dur * rrand(0.2, 0.4)}); - //rels = freqs.drop(2).collect({rrand(0.3, 0.5)}) ++ 2.collect({rrand(1, 3)}); - rels = (clumps.size - 1).collect({arg c; - if(clumps[c + 1][0] == ["Rest"], {rrand(1.0, 3.0)}, {rrand(0.3, 0.5)}); - }); - rels = rels.add(rrand(1.0, 3.0)); - amps = freqs.collect({rrand(0.6, 0.99)}); - - [ - Pbind( - \instrument, \string_model, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \attack, Pseq(attacks, 1), - \sustain, Pseq(fDurs, 1), - \release, Pseq(rels, 1), - //\amp, Pseq(amps, 1), - \amp, Pbrown(0.5, 1, 0.5), - \busIndex, v - ), - Pbind( - \instrument, \sine, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \sustain, Pseq(fDurs, 1), - \busIndex, v - ) - ] - }).flatten; - if(oneShot.not, { - msg = inSeq.collect({arg mSeq, m; mSeq[1..]}); - //ids = inSeq.collect({arg mSeq, m; mSeq[2]}); - sectionDurs = seq.collect({arg mSeq; mSeq.flatten2(mSeq.maxDepth - 5).flop[1].sum}); - pbinds = pbinds ++ - [ - Pbind( - \type, \osc, - \addr, addr, - \path, "/playing", - \msg, Pseq(msg, 1), - \dur, Pseq(sectionDurs, 1) - ); - ] - }); - res = Ppar(pbinds); - res -}; - -/* -genMidiPatterns = {arg seq; - var voices, durs, patterns, res, mOut, pbRange; - pbRange = 1; //semitones - change this as needed for your situation - mOut = MIDIOut.newByName("TiMidity", "TiMidity port 0").latency_(Server.default.latency); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - res = Ppar( - voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs; - - mOut.program(v, 70); - - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - - Pbind( - \type, \midi, - \chan, v, - \noteval, Pseq(freqs.cpsmidi - 24, 1), - \note, Pfunc({ | event | event[\noteval].floor }), - \dur, Pseq(fDurs, 1), - \midiout, mOut, - \amp, 1, - \bend, Pfunc({ - | event | - if (event[\note].isRest.not) { - var pitchbendvalue = event[\noteval].frac.linlin(0, pbRange, 8192, 8192*2).asInteger; - m.bend(v, pitchbendvalue); - }; - 0; // return something other than nil to avoid stopping the pattern - }), - ); - }); - ); - res -}; -*/ - - -//------resource management funcs - -genUID = {Date.seed.asHexString.toLower}; - -seedFunc = {arg func, seed; - var funcArgs, next; - next = Routine({loop{func.valueArray(funcArgs).yield }}); - next.randSeed_(seed); - {arg ...args; funcArgs = args; next.value} -}; - -stringifyToDepth = {arg data, maxDepth = 1; - var prettyString = "", rCount = 0, writeArray, indent; - - if(maxDepth == 0, { - data.asCompileString - }, { - indent = {arg size; size.collect({" "}).join("")}; - writeArray = {arg array; - prettyString = prettyString ++ indent.value(rCount) ++ "[\n"; - rCount = rCount + 1; - if(rCount < maxDepth, { - array.do({arg subArray; writeArray.value(subArray)}); - }, { - prettyString = prettyString ++ array.collect({arg subArray; - indent.value(rCount + 1) ++ subArray.asCompileString - }).join(",\n"); - }); - rCount = rCount - 1; - prettyString = prettyString ++ "\n" ++ indent.value(rCount) ++ "],\n"; - }; - - writeArray.value(data); - prettyString.replace(",\n\n", "\n").drop(-2); - }) -}; - -sanityCheck = {arg motif, index; - //print functions = very helpful - ("----------" + index + "------------").postln; - - motif.flatten.do({arg val, v; - if(v > 0, { - if(motif.flatten[v-1][0].hammingDistance(val[0]) > 1, {"problem 1".postln}); - if(motif.flatten[v-1][0].hammingDistance(val[0]) == 0, {"problem 2".postln}); - }); - val.postln - }); - "***********".postln; -}; - -msgInterpret = {arg in, escapeDoubleQuotes = true, escapeSingleQuotes = true; - var res; - - res = in; - if(res.isNil.not, { - if((res.isArray && res.isString.not), { - res = res.asCompileString; - res = res.replace(" ", "").replace("\n", "").replace("\t", ""); - if(escapeSingleQuotes, {res = res.replace("\'", "")}); - if(escapeDoubleQuotes, {res = res.replace("\"", "")}); - res = res.replace("Rest", "\"Rest\""); - res = res.interpret; - }, { - var tmpRes; - if(res.every({arg char; char.isDecDigit}), {tmpRes = res.asInteger}); - if(res.contains("."), {tmpRes = res.asFloat}); - if(tmpRes != nil, {res = tmpRes}); - }); - }); - res -}; - -writeResources = {arg path, dict; - var file, modelItems, resString; - file = File(path,"w"); - - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - - resString = nameSpaces.collect({arg nameSpace; - var depth = 0, insert = " "; - if(nameSpace == "music_data", {depth = 3; insert = "\n"}); - if(nameSpace == "last_changes", {depth = 1; insert = "\n"}); - if(nameSpace == "order", {depth = 1; insert = "\n"}); - if((nameSpace == "ref_uid") && (dict[nameSpace] == nil), {dict[nameSpace] = "nil"}); - "\"" ++ nameSpace ++ "\":" ++ insert ++ stringifyToDepth.value(dict[nameSpace], depth) - }).join(",\n"); - - resString = "{\n" ++ resString ++ "\n}"; - - file.write(resString); - file.close; - resString -}; - -loadModelFile = {arg path; loadModelJSON.value(File(path, "r").readAllString.parseJSON)}; - -loadModelJSON = {arg jsonObject; - var dict; - dict = Dictionary.with(*nameSpaces.collect({arg nS; nS->msgInterpret.value(jsonObject[nS])})); - dict -}; - -setGlobalVars = {arg dict, skipLastXChanges = false; - var tmpLastXChanges; - tmpLastXChanges = lastXChanges.deepCopy; - // order really matters!!!! - # seq, lastXChanges, curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited = nameSpaces.collect({arg nS; dict[nS]}); - if(skipLastXChanges, {lastXChanges = tmpLastXChanges}); - dict -}; - -globalVarsToDict = { - var modelItems, dict; - // order really matters!!!! - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - dict = Dictionary.with(*nameSpaces.collect({arg nS, n; nS->modelItems[n]})); -}; - -loadLedgerFile = {arg path; - ledgerPath = path; - loadLedgerJSON.value(File(ledgerPath, "r").readAllString.parseJSON) -}; - -loadLedgerJSON = {arg jsonObject; ledger = jsonObject["ledger"]}; - -saveLedger = {arg ledger, path; - var file; - file = File(path, "w"); - file.write("{\n\"ledger\":\n" ++ stringifyToDepth.value(ledger, 1) ++ "\n}"); - file.close; -}; - -//------global vars - -primes = [[2, 1], [3, 2], [5, 4], [7, 4], [11, 8], [13, 8]]; -//ranges = [[-2400, 0], [-1200, 1200], [0, 2400], [0, 2400]]; -exPath = thisProcess.nowExecutingPath; -dir = exPath.dirname; -//popSize = 4; -dims = primes.size; -tuples = genTuples.value(); -//refUID = nil; -group = Group.new; -~group = group; -loadLedgerFile.value(dir +/+ ".." +/+ "resources" +/+ "piece_ledger.json"); -//passagesWeights = [1, 1, 1, 1, 1]; -//susWeights = [1, 1, 1]; -// order really matters!!!! -nameSpaces = [ - "music_data", "last_changes", "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", - "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", - "ranges", "step_probs_vals", "passages_weights", "hd_exp", "hd_invert", - "order", "sus_weights", "order_size", "passages_size", - "motif_edited", "order_edited" -]; - - -//------OSC funcs - -OSCdef(\load_ledger, {arg msg, time, addr, port; - loadLedgerFile.value(msg[1].asString); -}, \load_ledger); - -OSCdef(\load_model, {arg msg, time, addr, port; - var dict; - dict = loadModelFile.value(msg[1].asString); - setGlobalVars.value(dict); -}, \load_model); - -OSCdef(\save_ledger, {arg msg, time, addr, port; - msg.postln; - ledger = msgInterpret.value(msg[1].asString.parseJSON["ledger"], false).postln; - //loadLedgerJSON.value(msg[0]) - saveLedger.value(ledger, msg[2].asString); - //loadLedgerFile.value(msg[1].asString); -}, \save_ledger); - -OSCdef(\generate, {arg msg, time, addr, port; - var path, dict, durSeeds, musPath, modelString; - msg.postln; - - path = msg[1].asString; - - dict = loadModelFile.value(path); - setGlobalVars.value(dict, true); - - popSize = ranges.size; - - //refUID.postln; - - loadLedgerFile.value(ledgerPath); - if(ledger == nil, {ledger = ["tmp"]}); - if(ledger.last != "tmp", {ledger = ledger.add("tmp")}); - - if(refUID == nil, {lastXChanges = [initVoices.value().deepCopy]}); - if((refUID != nil) && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - lastXChanges = msgInterpret.value(file.readAllString.parseJSON["last_changes"]); - }); - - refUID.postln; - lastXChanges.collect({arg item; item.postln}); - - durSeeds = seedFunc.value({3.collect({rrand(100000, 999999)})}, durSeed).value.postln; - entrancesDurFunc = genDurFunc.valueArray(entrancesProbVals[..4] ++ [entrancesProbVals[5..]] ++ [durSeeds[0]]); - passagesDurFunc = genDurFunc.valueArray(passagesProbVals[..4] ++ [passagesProbVals[5..]] ++ [durSeeds[1]]); - exitsDurFunc = genDurFunc.valueArray(exitsProbVals[..4] ++ [exitsProbVals[5..]] ++ [durSeeds[2]]); - - if(orders == nil, { - orders = seedFunc.value(genOrders, orderSeed).valueArray(orderSize ++ passagesSize); - //addr.sendMsg("/order", stringifyToDepth.value(orders, 1)); - }); - - stepFunc = genStepFunc.valueArray(stepProbsVals[..1] ++ [stepProbsVals[2..]] ++ [motifSeed]); - seq = seedFunc.value(genMotif, motifSeed).value; - - lastXChanges.collect({arg item; item.postln}); - - dict = globalVarsToDict.value; - modelString = writeResources.value(path, dict); - - //addr.sendMsg("/generated", musPath, stringifyToDepth.value(seq, 3)); - //~seq = seq; - - addr.sendMsg("/generated", path, modelString, ledgerPath); -}, \generate); - - -OSCdef(\commit, {arg msg, time, addr, port; - var musicData, musicChanged, dict, newLedger, modelPath, musString, musFile, test1, test2, lastCurUID, commitType, commitPos, equalityLedger; - //msg.postln; - - /* - test1 = msg[1].asString.parseJSON; - test2 = (dir +/+ ".." +/+ "resources/tmp/tmp_music" ++ ".json").standardizePath.parseJSONFile; - msgInterpret.value(test1["music"])[0][0][0][1].class.postln; - msgInterpret.value(test2["music_data"])[0][0][0][1].class.postln; - (test1["music"] == test2["music_data"]).postln; - */ - - musicData = loadModelJSON.value(msg[1].asString.parseJSON)["music_data"].postln; - musicChanged = (musicData != seq).postln; - commitType = msg[2].asString; - commitPos = msg[3].postln.asInteger; - - lastCurUID = curUID.deepCopy; - curUID = genUID.value; - - File.mkdir((dir +/+ ".." +/+ "resources" +/+ curUID).standardizePath); - File.copy(exPath, (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_code" ++ ".scd").standardizePath); - - modelPath = (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_mus_model" ++ ".json").standardizePath; - dict = globalVarsToDict.value; - if(musicChanged, { - seq = musicData; - dict["music_data"] = seq; - dict["motif_edited"] = "true" - }); - dict["cur_uid"] = curUID; - - writeResources.value(modelPath, dict); - - File.delete(ledgerPath ++ "_bak"); - File.copy(ledgerPath, ledgerPath ++ "_bak"); - File.delete(ledgerPath); - - /* - if(commitType == "add", { - if(lastCurUID == "tmp", { - ledger = ledger.drop(-1).add(curUID); - }, { - ledger = ledger.add(curUID); - }) - }); - */ - - ledger.postln; - - if(commitType == "add", {ledger = ledger.add(curUID)}); - - if(commitType == "insert", {ledger = ledger.insert(commitPos - 1, curUID)}); - - if(commitType == "replace", {ledger = ledger.put(commitPos, curUID)}); - - equalityLedger = ledger.collect({arg item; item.asSymbol}); - if(equalityLedger.includes(\tmp).postln, {ledger = ledger.removeAt(equalityLedger.indexOf(\tmp).postln)}); - - saveLedger.value(ledger, ledgerPath); - - addr.sendMsg("/committed", curUID, ledgerPath); - //refUID = curUID; - -}, \commit); - -OSCdef(\transport, {arg msg, time, addr, port; - msg.postln; - if(msg[1] == 0, { - group.set(\release, 2); - group.set(\gate, 0); - player.stop; - }, { - // the cued sequence can now be read from file, so this can be cleaned up - var cSize, patterns, pSeq, cuedSeek, indexStart, indexEnd, tmpLedger; - if(msg[1] == 1, { - pSeq = []; - cuedSeek = (seq != nil); - indexStart = msg[2].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.postln.parseJSON["music_data"]), path, indexStart + index, uid]); - file.close; - }); - }); - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - patterns = genPatterns.value(pSeq, addr); - }, { - pSeq = [loadModelJSON.value(msg[2].asString.parseJSON)["music_data"].postln]; - patterns = genPatterns.value(pSeq, addr, true); - }); - player = Pfset(pattern: patterns, cleanupFunc: { - addr.sendMsg("/transport", 0); - addr.sendMsg("/one_shot", 0); - }); - player = player.play - }); -}, \transport); - - -OSCdef(\transcribe_motif, {arg msg, time, addr, port; - var tSeq, refChord, refUID; - - msg.postln; - - tSeq = [loadModelJSON.value(msg[1].asString.parseJSON)["music_data"]]; - refUID = msg[2].asString.postln; - - if((refUID != "nil") && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }, { - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - }); - - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "lilypond" +/+ "includes").standardizePath, addr, "/transcribe_motif"); -}, \transcribe_motif); - - -OSCdef(\transcribe_all, {arg msg, time, addr, port; - var cSize, patterns, cuedSeek, indexStart, indexEnd, tmpLedger; - if(true, { - cuedSeek = (seq != nil); - indexStart = msg[1].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - - //tmp for testing transcription - indexEnd = (indexStart+5); - - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - var lilyPartLedgerFiles; - - lilyPartLedgerFiles = 4.collect({arg p; - File((dir +/+ ".." +/+ "lilypond" +/+ "includes" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly").standardizePath, "w"); - }); - - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file, fileString, tSeq, refUID, refChord; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - fileString = file.readAllString; - tSeq = msgInterpret.value(fileString.parseJSON["music_data"]); - refUID = msgInterpret.value(fileString.parseJSON["ref_uid"]); - file.close; - - //uid.postln; - //(refUID == "nil").postln; - - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - - if(refUID != "nil", { - path = (dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }); - - if(index != indexEnd, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath); - }, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath, addr, "/transcribe_all"); - }); - - lilyPartLedgerFiles.do({arg f, p; - f.write("\\include \".." +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly\"\n"); - }); - - }); - - lilyPartLedgerFiles.do({arg f; - f.close - }); - }); - /* - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - */ - }, { - - }); - -}, \transcribe_all); - -) - -~transcribe.value(~seq, dir); - -( -//synthdefs -~stringModelBusArray = 4.collect({Bus.audio(s, 1)}); -~sineBusArray = 4.collect({Bus.audio(s, 1)}); -~bassBusArray = 1.collect({Bus.audio(s, 1)}); -~hdustBusArray = 1.collect({Bus.audio(s, 1)}); -~samplerBusArray = 2.collect({Bus.audio(s, 1)}); -~sBuf = Buffer.alloc(s, 10, 2); -SynthDef(\string_model, {arg freq, gate = 1, sustain, amp, dur, attack, release = 1, busIndex = 0; - var trig, exc, sig1, sig2, noHarms; - noHarms = rrand(20, 40); - exc = Saw.ar(freq, TRand.ar(0.5, 1, Impulse.ar(freq))) * 0.001 + Dust.ar(10000, 0.01); - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.8).softclip; - //sig1 = HPF.ar(sig1, 300); - Out.ar(Select.kr(busIndex, ~stringModelBusArray), sig1 * amp * EnvGen.kr(Env.adsr(attack, 0.3, 0.9, release, 0.9, -3), gate, doneAction: 2)); - //Out.ar([0, 1], sig1 * EnvGen.kr(Env.asr(dur, 0.3, 1), gate, doneAction: 2)); -}).add; - -SynthDef(\sine, {arg freq, gate = 1, sustain, amp, dur, busIndex = 0; - var sig; - sig = SinOsc.ar(freq); - Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.asr(0.3, 0.4, 0.3), gate, timeScale: dur, doneAction: 2)); - //Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.sine(dur), gate, doneAction: 2)); -}).add; - -SynthDef(\mixer, {arg freq, gate = 1, sustain, amp, dur, out; - var nameSpaces, sigs; - - sigs = [~stringModelBusArray, ~sineBusArray/*, ~bassBusArray, ~hdustBusArray, ~samplerBusArray*/].collect({arg busArray, i; - var nameSpace, sig; - nameSpace = ['string', 'sine', 'bass', 'hdust', 'sampler'][i]; - sig = busArray.collect({arg bus, c; In.ar(bus, 1) * NamedControl.kr(\ ++ nameSpace ++ '_volume_' ++ c, 1, 0.1)}); - sig = sig.collect({arg channel, c; Pan2.ar(channel, NamedControl.kr(\ ++ nameSpace ++ '_pan_' ++ c, i / (busArray.size - 1), 0.1) * 2 - 1)}); - sig = sig.collect({arg channel, c; channel * NamedControl.kr(\ ++ nameSpace ++ '_mute_' ++ c, 1, 0.1)}); - sig = Mix.ar(sig) * pow(NamedControl.kr(\ ++ nameSpace ++ '_volume_master', 1, 0.1), 2); - }); - - sigs = Mix.ar(sigs / 4); - Out.ar(0, sigs) -}).add; - -SynthDef(\bass, { - var switches, drone; - switches = {|i| Dust.kr(0.1)} ! 9; - drone = {|i| var harm = pow(2, 2 - (i / 3).trunc), amp = (1 / pow(harm, 2)); - SinOsc.ar(60 * harm + TRand.kr(-3, 3, switches[i]), 0, amp)} ! 9; - Out.ar(~bassBusArray[0], Mix.new(drone) * 0.2); -}).add; - -SynthDef(\sampler, { - Out.ar(~samplerBusArray, PlayBuf.ar(2, ~sBuf, BufRateScale.kr(~sBuf), doneAction: 2)) -}).add; - -// main routine -SynthDef(\hdust, { - arg gate = 0; - var hierarchical_dust, low_sine, high_sine, brown_noise, white_noise; - // this triggers the combinations of sources - // it is similar to the Supercollider UGen called dust but with a hierarchical structure - hierarchical_dust = ( - TIRand.kr(0, 1, Impulse.kr(100)) * - TIRand.kr(0, 1, Impulse.kr(10)) * - TIRand.kr(0, 1, Impulse.kr(1)) * - TIRand.kr(0, 1, Impulse.kr(0.1)) - ); - // adjust the multiplier at the end of each line for adjusting levels - // note with each trigger, each source has a 1 in 3 chance of sounding - low_sine = SinOsc.ar(76.midicps / 16) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.1; - high_sine = SinOsc.ar(76.midicps * 8) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.01; - brown_noise = BrownNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.025; - white_noise = WhiteNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.02; - Out.ar(~hdustBusArray[0], - ((low_sine + high_sine + brown_noise + white_noise) ) - ); -}).add; - -) - -( -var bass, hdust, sampler, mixer; -/* -bass = Synth.tail(~group, \bass); -hdust = Synth.tail(~group, \hdust); -sampler = Synth.head(~group, \sampler); -*/ -mixer = Synth.tail(~group, \mixer); - -OSCdef(\mixer, {arg msg, time, addr, port; - mixer.set((msg[1] ++ '_' ++ msg[2] ++ '_' ++ msg[3]), msg[4]) -}, \mixer); - -/* -OSCdef(\sampler, {arg msg, time, addr, port; - msg.postln; - sampler.free; - ~sBuf.free; - ~sBuf = Buffer.read(s, msg[1].asString.postln, action: {sampler = Synth.head(~group, \sampler)}); -}, \sampler); -*/ -) - -/* old something -( -SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; - var trig, exc, sig1, sig2, noHarms, freqFinal, start, end; - noHarms = 30; - freq = WhiteNoise.ar * 3 + freq; - freqFinal = Duty.ar((1/freq), 0, freq); - trig = Changed.ar(freqFinal); - start = Demand.ar(trig, 0, Dwhite(-1, -0.75)); - end = Demand.ar(trig, 0, Dwhite(0.75, 1)); - exc = Phasor.ar(trig, (end - start) * freqFinal / SampleRate.ir, start, end, 0) * 0.001 + Dust.ar(10000, 0.01); - - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(2, 3)}) ], exc) * 0.5).softclip; - sig1 = HPF.ar(sig1, 300); - Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); -}).add; -) -*/ - diff --git a/resources/7bda0503/7bda0503_mus_model.json b/resources/7bda0503/7bda0503_mus_model.json deleted file mode 100644 index d8f5552..0000000 --- a/resources/7bda0503/7bda0503_mus_model.json +++ /dev/null @@ -1,65 +0,0 @@ -{ -"music_data": -[ - [ - [ - [ [ [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ] ], 0 ], - [ [ [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ] ], 2.125 ], - [ [ [ 0, 0, 1, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ] ], 0.25 ], - [ [ [ 0, 0, 0, 1, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ] ], 0 ], - [ [ [ 0, 1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ] ], 3.75 ] - ], - [ - [ [ [ 0, 1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], 7.5 ], - [ [ [ 0, 1, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], 0.375 ], - [ [ [ 0, 1, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], 0.5 ], - [ [ [ 0, 1, 0, 0, 0, 0 ], [ 0, 1, 1, 0, 0, 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[ "Rest" ], [ "Rest" ] ], 5.125 ] - ] - ] -], -"last_changes": -[ - [ [ 0, 1, 0, 0, 0, 0 ], [ 1, 0, 1, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], - [ [ 0, 1, 0, 0, 0, 0 ], [ 2, 0, -1, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], - [ [ 0, 1, 0, 0, 0, 0 ], [ 2, 0, -1, 0, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], - [ [ 0, 1, 0, 0, 0, 0 ], [ 2, 0, -1, 0, 0, 0 ], [ 1, 0, -1, 0, 0, -1 ], [ 0, 0, 0, 0, 0, 0 ] ], - [ [ 0, 1, 0, 0, 0, 0 ], [ 2, 0, -1, 0, 0, 0 ], [ 0, 0, 0, 1, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ] -], -"cur_uid": "7bda0503", -"ref_uid": "nil", -"order_seed": 447097, -"dur_seed": 237668, -"motifs_seed": 975495, -"entrances_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.26424870466321, 0.75675675675676, 0.5, 0.5, 0.58549222797927, 0.72635135135135, 1, 0.5 ], -"passages_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"exits_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"ranges": [ [ -384, 2400 ], [ -507, 2400 ], [ -282, 2237 ], [ -1200, 2053 ] ], -"step_probs_vals": [ 0, 1200, 0, 0.5, 0.5, 0.5, 1, 0.5 ], -"passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], -"hd_exp": 2, -"hd_invert": 0, -"order": -[ - [ [ 1, 2 ], [ 0, 0, 0 ], [ 3 ] ], - [ [ 0, 2, 3 ], [ 1, 1, 1, 1, 1, 1, 1 ], [ ] ], - [ [ 3, 0, 1 ], [ 2, 2, 2 ], [ ] ] -], -"sus_weights": [ 0.75, 0.69, 0.75 ], -"order_size": [ 2, 6 ], -"passages_size": [ 0, 10 ], -"motif_edited": "false", -"order_edited": "false" -} \ No newline at end of file diff --git a/resources/7c1ab0e0/7c1ab0e0_code.scd b/resources/7c1ab0e0/7c1ab0e0_code.scd deleted file mode 100644 index ab2dc17..0000000 --- a/resources/7c1ab0e0/7c1ab0e0_code.scd +++ /dev/null @@ -1,1046 +0,0 @@ -( -// helper funcs -var hsArrayToCents, pDist, hdSum, hsChordalDistance, hsArrayToFreq; - -// score funcs -var isInRange, spacingScore, rangeScore, intervalScore, inclusionScore; - -// subroutines -var genTuples, initVoices, genOrders, genSubMotif, updateVoices, genDurFunc, genStepFunc; - -// primary routines -var genMotif, genSecondarySeq; - -// audition funcs -var genPatterns, genMidiPatterns; - -// resource management funcs -var seedFunc, genUID, writeResources, stringifyToDepth, setSeeds, sanityCheck, -msgInterpret, loadLedgerFile, loadLedgerJSON, loadModelFile, loadModelJSON, -setGlobalVars, globalVarsToDict, saveLedger; - -// model vars -//(model and global vars mostly set by OSC funcs -var seq, lastXChanges, -curUID, refUID, orderSeed, durSeed, motifSeed, -entrancesProbVals, passagesProbVals, exitsProbVals, -ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, -orders, susWeights, orderSize, passagesSize, -motifEdited, orderEdited; - -// model aux vars -var entrancesDurFunc, passagesDurFunc, exitsDurFunc, stepFunc; - -// other global vars -var popSize, exPath, dir, primes, dims, tuples, -group, player, ledgerPath, ledger, currentlyPlayingUID, -nameSpaces; - -// install JSON quark -if(Quarks.isInstalled("JSONlib").not, { - Quarks.install("https://github.com/musikinformatik/JSONlib.git"); - thisProcess.recompile; - //HelpBrowser.openHelpFor("Classes/JSONlib"); -}); - - -//------helper funcs - -hsArrayToCents = { - arg hsArray; - hsArray.collect({arg dist, p; dist * 1200 * log2(primes[p][0]/primes[p][1])}).sum -}; - -pDist = { - arg array1, array2, signed = false; - var pDistance; - pDistance = hsArrayToCents.value(array1) - hsArrayToCents.value(array2); - if(signed, {pDistance}, {abs(pDistance)}) -}; - -hdSum = { - arg hsArrays; - var size, distances, mean; - size = hsArrays.size; - distances = (size - 1).collect({arg i; - ((i + 1)..(size - 1)).collect({arg j; - abs(hsArrays[i] - hsArrays[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsChordalDistance = { - arg hsArrays1, hsArrays2; - var size, distances, mean; - size = hsArrays1.size; - distances = hsArrays1.size.collect({arg i; - hsArrays2.size.collect({arg j; - abs(hsArrays1[i] - hsArrays2[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsArrayToFreq = { - arg array; - array.collect({arg dim, d; pow(primes[d][0]/primes[d][1], dim)}).product -}; - -//------score funcs - -/* -isInRange = { - arg hsArray, min, max; - var cents; - cents = hsArrayToCents.value(hsArray); - (cents >= min) && (cents <= max) -}; -*/ - -spacingScore = { - arg hsArrays, min; - var centsArray; - centsArray = hsArrays.collect({arg hsArray; hsArrayToCents.value(hsArray)}).sort({arg a, b; a < b}); - centsArray.differentiate.drop(1).collect({arg pDistance; if(pDistance >= min, {1}, {0.01})}).sum; -}; - -rangeScore = { - arg hsArray1, hsArray2, min, max, low, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - if((pDistance >= min) && (pDistance <= max), {1}, {low}); -}; - -intervalScore = { - arg hsArray1, hsArray2, mean, sd, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - //pDistance.gaussCurve(1, mean, sd) - stepFunc.value(pDistance); -}; - -inclusionScore = { - arg array, test, min = 0.01; - if(array.collect({arg v; v.hash}).includes(test.hash), {min}, {1}); -}; - - -//------subroutines - -genTuples = { - var tuples; - tuples = dims.collect({[-1, 0, 1]}).allTuples.select({arg tuple; (abs(tuple.drop(1)).sum <= 1) && (tuple[0] == 0)}); - tuples = tuples ++ tuples.collect({arg tuple; [-3, -2, -1, 1, 2, 3].collect({arg octTrans; tuple.deepCopy.put(0, octTrans)})}).flatten; -}; - -initVoices = { - var init, voicesInit; - voicesInit = popSize.collect({dims.collect({0})}); - /* - voicesInit = [dims.collect({0})]; - (popSize - 1).do({ - arg rep, new; - rep = dims.rand; - new = voicesInit.last.deepCopy; - new[rep] = new[rep] + [-1, 1].choose(); - voicesInit = voicesInit.add(new); - }); - */ - voicesInit.deepCopy; -}; - -genDurFunc = {arg chordProb, minPad, maxPad, minDur, maxDur, envData, seed; - var env, pTable, durFunc; - env = Env.pairs([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).asSignal(256).asList.asArray; - pTable = env.asRandomTable; - [chordProb, minPad, maxPad, minDur, maxDur, envData].postln; - durFunc = {arg allowChord, pad = false; - var res; - res = if(allowChord.not, { - pTable.tableRand * (maxDur - minDur) + minDur - }, { - if(1.0.rand < chordProb, {0}, {pTable.tableRand * (maxDur - minDur) + minDur}); - }).round(0.125); - if(pad, {res = res + rrand(minPad.asFloat, maxPad.asFloat).round(0.125)}); - if(res.asInteger == res, {res = res.asInteger}); - res - }; - seedFunc.value(durFunc, seed); -}; - -genStepFunc = {arg minStep, maxStep, envData, seed; - var envDataNorm, env, pTable, stepFunc; - [minStep, maxStep, envData].postln; - envDataNorm = ([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).flop; - envDataNorm = [envDataNorm[0].normalize(minStep, maxStep), envDataNorm[1]].flop; - env = Env.pairs(envDataNorm); - stepFunc = {arg pDist; - env.at(pDist).clip(0.001, 1); - }; - seedFunc.value(stepFunc, seed); -}; - -genOrders = {arg minMotifLength = 1, maxMotifLength = 5, minProgLength = 0, maxProgLength = 5; - ((maxMotifLength - minMotifLength).rand + minMotifLength).collect({ - var noProgIns, noSusIns, noSilentIns, prog, sus, silent, order; - noSusIns = [1, 2, 3].wchoose(susWeights.normalizeSum); - noProgIns = (popSize - noSusIns).rand + 1; - noSilentIns = popSize - noSusIns - noProgIns; - - # prog, sus, silent = (0..(popSize-1)).scramble.clumps([noProgIns, noSusIns, noSilentIns]); - - prog = (prog.scramble ++ ((maxProgLength - minProgLength).rand + minProgLength).collect({prog.choose}).scramble); - if(silent == nil, {silent = []}); - [sus.scramble, prog, silent.scramble] - }); -}; - -updateVoices = {arg ins, sus; - var voices, candidates, nWeights, nProbs, sel; - - voices = lastXChanges.deepCopy.last; - - candidates = sus.collect({arg v; tuples.collect({arg t; voices[v] + t})}).flatten; - candidates = difference(candidates.asSet, voices.asSet).asList; - nProbs = candidates.collect({arg candidate; - var stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore; - - //stepScore = intervalScore.value(voices[ins], candidate, 30, 400, 0.1); - stepScore = intervalScore.value(voices[ins], candidate, 100, 100); - recentlySoundedScore = inclusionScore.value(lastXChanges.flop[ins], candidate, 0); - isInRangeScore = rangeScore.value(candidate, candidate.collect({0}), ranges[ins][0], ranges[ins][1], 0, true); - regScore = spacingScore.value(voices.deepCopy.put(ins, candidate), 300); - hdScore = pow(hdSum.value(voices.deepCopy.put(ins, candidate)), hdExp); - if(hdInvert == 0, {hdScore = 1/hdScore}); - //maybe what you want here is a vector to another root and then favoring movement towards it. - //distScore = pow(hsChordalDistance.value(voices, voices.put(ins, candidate)), 2); - - [stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore] - }); - - nWeights = passagesWeights; - - //this handles nWeights of 0; mainly for testing - nProbs = nProbs.flop.select({arg scores, s; nWeights[s] != 0}).flop; - nWeights = nWeights.select({arg weight; weight != 0}); - nProbs = nProbs.flop.collect({arg scores, s; - if(scores.sum == 0, {scores}, {scores.normalizeSum * nWeights[s]}) - }); - nProbs = nProbs.flop.collect({arg scores, s; scores.product}).normalizeSum; - - sel = candidates.wchoose(nProbs); - - voices[ins] = sel; - lastXChanges = lastXChanges.add(voices).keep(-5); -}; - -genSubMotif = {arg order, orderIndex, lastState, repeatLast = false, startFromLast = false, isLastOrder = false; - var sus, prog, silent, flatOrder, res, isInChord, allowChord, pad, lastXChangesHold, voices, adder; - # sus, prog, silent = order; - flatOrder = silent ++ sus ++ prog; - lastXChangesHold = lastXChanges.deepCopy; - voices = lastState.deepCopy; - isInChord = popSize.collect({false}); - allowChord = false; - pad = false; - res = []; - "------generating motif".postln; - //need to figure out here if voices move between motifs - flatOrder.do({arg ins, i; - - if(prog.includes(ins) && repeatLast.not, {updateVoices.value(ins, sus)}); - adder = if(silent.includes(ins), {["Rest"]}, {lastXChanges.last.deepCopy[ins]}); - - if(voices[ins] != adder, { - var dur; - - if((sus ++ silent).includes(ins), { - allowChord = (ins != sus.last); - pad = (ins == sus.last); - }, { - if(i < (flatOrder.size - 1), { - allowChord = (isInChord[flatOrder[i + 1]] || (ins == flatOrder[i + 1])).not; - pad = false; - }, { - allowChord = false; - pad = true - }); - }); - if((orderIndex == 0) && sus.includes(ins), { - dur = entrancesDurFunc.value(allowChord, pad); - }, { - dur = passagesDurFunc.value(allowChord, pad); - }); - if(dur == 0, {isInChord[ins] = true}, {isInChord = popSize.collect({false})}); - - voices[ins] = adder; - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - - // pad ending - if(orderIndex == (orders.size - 1), { - (0..(popSize-1)).scramble.do({arg ins; - if(res.last.first[ins] != ["Rest"], { - var dur; - voices[ins] = ["Rest"]; - allowChord = (voices != popSize.collect({["Rest"]})); - pad = allowChord.not; - dur = exitsDurFunc.value(allowChord, pad); - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - }); - - //format and return - if(startFromLast, {lastXChanges = lastXChangesHold.deepCopy}); - res; -}; - - -//------primary routines - -genMotif = { - var repeats, fSeq, fDur, durAdd; - - repeats = 1; - fSeq = []; - - repeats.do({arg index; - var motif; - - motif = []; - - orders.do({arg order, o; - var lastState, subMotif; - lastState = if(o == 0, {popSize.collect({["Rest"]})}, {motif.last.last.first}); - subMotif = genSubMotif.value(order, o, lastState, isLastOrder: o == (orders.size - 1)); - motif = motif.add(subMotif); - - }); - - sanityCheck.value(motif, index); - - fSeq = fSeq.add(motif); - }); - - //round last duration to measure - fDur = fSeq.flatten.flatten.slice(nil, 1).sum; - durAdd = fDur.round(4) - fDur; - if(durAdd < 0, {durAdd = 4 - durAdd}); - fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] = fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] + durAdd; - - fSeq -}; - -genSecondarySeq = {arg seq; - var curdles, fSeq; - curdles = []; - while({curdles.sum < seq.size}, {curdles = curdles ++ [3.rand + 1]}); - - fSeq = seq.clumps(curdles).collect({arg clump, m; - var repeats, paddedSeq; - - //add rest - paddedSeq = clump.add([[[popSize.collect({["Rest"]}), 0.5.rand]]]); - - //implement repeats - repeats = [0.rand + 1, 1].wchoose([1, 0].normalizeSum); - repeats.collect({paddedSeq}); - }); - fSeq -}; - - -//------audition funcs - -/* -Event.addEventType(\osc, { - if (~addr.postln.notNil) { - ~addr.sendMsg(~indexPath, ~indexMsg); - ~addr.sendMsg(~seqPath, stringifyToDepth.value(~seqMsg, 3)); - //~addr.sendMsg("/STATE/OPEN", (dir.replace("supercollider", "resources") +/+ ~idMsg +/+ ~idMsg ++ "_gui_state" ++ ".state").standardizePath.postln); - }; -}); -*/ - -Event.addEventType(\osc, { - if (~addr.notNil) { - ~msg; - ~addr.sendMsg(~path, *~msg); - }; -}); - -genPatterns = {arg inSeq, addr, oneShot = false; - var voices, durs, pbinds, res, indices, sectionDurs, msg, ids, seq; - seq = inSeq.collect({arg mSeq; mSeq[0]}); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - pbinds = voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs, attacks, rels, amps; - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - //attacks = 2.collect({rrand(1, 3)}) ++ freqs.drop(2).collect({rrand(0.3, 0.5)}); - attacks = fDurs.collect({arg dur; dur * rrand(0.2, 0.4)}); - //rels = freqs.drop(2).collect({rrand(0.3, 0.5)}) ++ 2.collect({rrand(1, 3)}); - rels = (clumps.size - 1).collect({arg c; - if(clumps[c + 1][0] == ["Rest"], {rrand(1.0, 3.0)}, {rrand(0.3, 0.5)}); - }); - rels = rels.add(rrand(1.0, 3.0)); - amps = freqs.collect({rrand(0.6, 0.99)}); - - [ - Pbind( - \instrument, \string_model, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \attack, Pseq(attacks, 1), - \sustain, Pseq(fDurs, 1), - \release, Pseq(rels, 1), - //\amp, Pseq(amps, 1), - \amp, Pbrown(0.5, 1, 0.5), - \busIndex, v - ), - Pbind( - \instrument, \sine, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \sustain, Pseq(fDurs, 1), - \busIndex, v - ) - ] - }).flatten; - if(oneShot.not, { - msg = inSeq.collect({arg mSeq, m; mSeq[1..]}); - //ids = inSeq.collect({arg mSeq, m; mSeq[2]}); - sectionDurs = seq.collect({arg mSeq; mSeq.flatten2(mSeq.maxDepth - 5).flop[1].sum}); - pbinds = pbinds ++ - [ - Pbind( - \type, \osc, - \addr, addr, - \path, "/playing", - \msg, Pseq(msg, 1), - \dur, Pseq(sectionDurs, 1) - ); - ] - }); - res = Ppar(pbinds); - res -}; - -/* -genMidiPatterns = {arg seq; - var voices, durs, patterns, res, mOut, pbRange; - pbRange = 1; //semitones - change this as needed for your situation - mOut = MIDIOut.newByName("TiMidity", "TiMidity port 0").latency_(Server.default.latency); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - res = Ppar( - voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs; - - mOut.program(v, 70); - - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - - Pbind( - \type, \midi, - \chan, v, - \noteval, Pseq(freqs.cpsmidi - 24, 1), - \note, Pfunc({ | event | event[\noteval].floor }), - \dur, Pseq(fDurs, 1), - \midiout, mOut, - \amp, 1, - \bend, Pfunc({ - | event | - if (event[\note].isRest.not) { - var pitchbendvalue = event[\noteval].frac.linlin(0, pbRange, 8192, 8192*2).asInteger; - m.bend(v, pitchbendvalue); - }; - 0; // return something other than nil to avoid stopping the pattern - }), - ); - }); - ); - res -}; -*/ - - -//------resource management funcs - -genUID = {Date.seed.asHexString.toLower}; - -seedFunc = {arg func, seed; - var funcArgs, next; - next = Routine({loop{func.valueArray(funcArgs).yield }}); - next.randSeed_(seed); - {arg ...args; funcArgs = args; next.value} -}; - -stringifyToDepth = {arg data, maxDepth = 1; - var prettyString = "", rCount = 0, writeArray, indent; - - if(maxDepth == 0, { - data.asCompileString - }, { - indent = {arg size; size.collect({" "}).join("")}; - writeArray = {arg array; - prettyString = prettyString ++ indent.value(rCount) ++ "[\n"; - rCount = rCount + 1; - if(rCount < maxDepth, { - array.do({arg subArray; writeArray.value(subArray)}); - }, { - prettyString = prettyString ++ array.collect({arg subArray; - indent.value(rCount + 1) ++ subArray.asCompileString - }).join(",\n"); - }); - rCount = rCount - 1; - prettyString = prettyString ++ "\n" ++ indent.value(rCount) ++ "],\n"; - }; - - writeArray.value(data); - prettyString.replace(",\n\n", "\n").drop(-2); - }) -}; - -sanityCheck = {arg motif, index; - //print functions = very helpful - ("----------" + index + "------------").postln; - - motif.flatten.do({arg val, v; - if(v > 0, { - if(motif.flatten[v-1][0].hammingDistance(val[0]) > 1, {"problem 1".postln}); - if(motif.flatten[v-1][0].hammingDistance(val[0]) == 0, {"problem 2".postln}); - }); - val.postln - }); - "***********".postln; -}; - -msgInterpret = {arg in, escapeDoubleQuotes = true, escapeSingleQuotes = true; - var res; - - res = in; - if(res.isNil.not, { - if((res.isArray && res.isString.not), { - res = res.asCompileString; - res = res.replace(" ", "").replace("\n", "").replace("\t", ""); - if(escapeSingleQuotes, {res = res.replace("\'", "")}); - if(escapeDoubleQuotes, {res = res.replace("\"", "")}); - res = res.replace("Rest", "\"Rest\""); - res = res.interpret; - }, { - var tmpRes; - if(res.every({arg char; char.isDecDigit}), {tmpRes = res.asInteger}); - if(res.contains("."), {tmpRes = res.asFloat}); - if(tmpRes != nil, {res = tmpRes}); - }); - }); - res -}; - -writeResources = {arg path, dict; - var file, modelItems, resString; - file = File(path,"w"); - - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - - resString = nameSpaces.collect({arg nameSpace; - var depth = 0, insert = " "; - if(nameSpace == "music_data", {depth = 3; insert = "\n"}); - if(nameSpace == "last_changes", {depth = 1; insert = "\n"}); - if(nameSpace == "order", {depth = 1; insert = "\n"}); - if((nameSpace == "ref_uid") && (dict[nameSpace] == nil), {dict[nameSpace] = "nil"}); - "\"" ++ nameSpace ++ "\":" ++ insert ++ stringifyToDepth.value(dict[nameSpace], depth) - }).join(",\n"); - - resString = "{\n" ++ resString ++ "\n}"; - - file.write(resString); - file.close; - resString -}; - -loadModelFile = {arg path; loadModelJSON.value(File(path, "r").readAllString.parseJSON)}; - -loadModelJSON = {arg jsonObject; - var dict; - dict = Dictionary.with(*nameSpaces.collect({arg nS; nS->msgInterpret.value(jsonObject[nS])})); - dict -}; - -setGlobalVars = {arg dict, skipLastXChanges = false; - var tmpLastXChanges; - tmpLastXChanges = lastXChanges.deepCopy; - // order really matters!!!! - # seq, lastXChanges, curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited = nameSpaces.collect({arg nS; dict[nS]}); - if(skipLastXChanges, {lastXChanges = tmpLastXChanges}); - dict -}; - -globalVarsToDict = { - var modelItems, dict; - // order really matters!!!! - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - dict = Dictionary.with(*nameSpaces.collect({arg nS, n; nS->modelItems[n]})); -}; - -loadLedgerFile = {arg path; - ledgerPath = path; - loadLedgerJSON.value(File(ledgerPath, "r").readAllString.parseJSON) -}; - -loadLedgerJSON = {arg jsonObject; ledger = jsonObject["ledger"]}; - -saveLedger = {arg ledger, path; - var file; - file = File(path, "w"); - file.write("{\n\"ledger\":\n" ++ stringifyToDepth.value(ledger, 1) ++ "\n}"); - file.close; -}; - -//------global vars - -primes = [[2, 1], [3, 2], [5, 4], [7, 4], [11, 8], [13, 8]]; -//ranges = [[-2400, 0], [-1200, 1200], [0, 2400], [0, 2400]]; -exPath = thisProcess.nowExecutingPath; -dir = exPath.dirname; -//popSize = 4; -dims = primes.size; -tuples = genTuples.value(); -//refUID = nil; -group = Group.new; -~group = group; -loadLedgerFile.value(dir +/+ ".." +/+ "resources" +/+ "piece_ledger.json"); -//passagesWeights = [1, 1, 1, 1, 1]; -//susWeights = [1, 1, 1]; -// order really matters!!!! -nameSpaces = [ - "music_data", "last_changes", "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", - "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", - "ranges", "step_probs_vals", "passages_weights", "hd_exp", "hd_invert", - "order", "sus_weights", "order_size", "passages_size", - "motif_edited", "order_edited" -]; - - -//------OSC funcs - -OSCdef(\load_ledger, {arg msg, time, addr, port; - loadLedgerFile.value(msg[1].asString); -}, \load_ledger); - -OSCdef(\load_model, {arg msg, time, addr, port; - var dict; - dict = loadModelFile.value(msg[1].asString); - setGlobalVars.value(dict); -}, \load_model); - -OSCdef(\save_ledger, {arg msg, time, addr, port; - msg.postln; - ledger = msgInterpret.value(msg[1].asString.parseJSON["ledger"], false).postln; - //loadLedgerJSON.value(msg[0]) - saveLedger.value(ledger, msg[2].asString); - //loadLedgerFile.value(msg[1].asString); -}, \save_ledger); - -OSCdef(\generate, {arg msg, time, addr, port; - var path, dict, durSeeds, musPath, modelString; - msg.postln; - - path = msg[1].asString; - - dict = loadModelFile.value(path); - setGlobalVars.value(dict, true); - - popSize = ranges.size; - - //refUID.postln; - - loadLedgerFile.value(ledgerPath); - if(ledger == nil, {ledger = ["tmp"]}); - if(ledger.last != "tmp", {ledger = ledger.add("tmp")}); - - if(refUID == nil, {lastXChanges = [initVoices.value().deepCopy]}); - if((refUID != nil) && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - lastXChanges = msgInterpret.value(file.readAllString.parseJSON["last_changes"]); - }); - - refUID.postln; - lastXChanges.collect({arg item; item.postln}); - - durSeeds = seedFunc.value({3.collect({rrand(100000, 999999)})}, durSeed).value.postln; - entrancesDurFunc = genDurFunc.valueArray(entrancesProbVals[..4] ++ [entrancesProbVals[5..]] ++ [durSeeds[0]]); - passagesDurFunc = genDurFunc.valueArray(passagesProbVals[..4] ++ [passagesProbVals[5..]] ++ [durSeeds[1]]); - exitsDurFunc = genDurFunc.valueArray(exitsProbVals[..4] ++ [exitsProbVals[5..]] ++ [durSeeds[2]]); - - if(orders == nil, { - orders = seedFunc.value(genOrders, orderSeed).valueArray(orderSize ++ passagesSize); - //addr.sendMsg("/order", stringifyToDepth.value(orders, 1)); - }); - - stepFunc = genStepFunc.valueArray(stepProbsVals[..1] ++ [stepProbsVals[2..]] ++ [motifSeed]); - seq = seedFunc.value(genMotif, motifSeed).value; - - lastXChanges.collect({arg item; item.postln}); - - dict = globalVarsToDict.value; - modelString = writeResources.value(path, dict); - - //addr.sendMsg("/generated", musPath, stringifyToDepth.value(seq, 3)); - //~seq = seq; - - addr.sendMsg("/generated", path, modelString, ledgerPath); -}, \generate); - - -OSCdef(\commit, {arg msg, time, addr, port; - var musicData, musicChanged, dict, newLedger, modelPath, musString, musFile, test1, test2, lastCurUID, commitType; - //msg.postln; - - /* - test1 = msg[1].asString.parseJSON; - test2 = (dir +/+ ".." +/+ "resources/tmp/tmp_music" ++ ".json").standardizePath.parseJSONFile; - msgInterpret.value(test1["music"])[0][0][0][1].class.postln; - msgInterpret.value(test2["music_data"])[0][0][0][1].class.postln; - (test1["music"] == test2["music_data"]).postln; - */ - - musicData = loadModelJSON.value(msg[1].asString.parseJSON)["music_data"].postln; - musicChanged = (musicData != seq).postln; - commitType = msg[2].asString; - - lastCurUID = curUID.deepCopy; - curUID = genUID.value; - - File.mkdir((dir +/+ ".." +/+ "resources" +/+ curUID).standardizePath); - File.copy(exPath, (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_code" ++ ".scd").standardizePath); - - modelPath = (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_mus_model" ++ ".json").standardizePath; - dict = globalVarsToDict.value; - if(musicChanged, { - seq = musicData; - dict["music_data"] = seq; - dict["motif_edited"] = "true" - }); - dict["cur_uid"] = curUID; - - writeResources.value(modelPath, dict); - - File.delete(ledgerPath ++ "_bak"); - File.copy(ledgerPath, ledgerPath ++ "_bak"); - File.delete(ledgerPath); - - if(commitType == "add", { - if(lastCurUID == "tmp", { - ledger = ledger.drop(-1).add(curUID); - }, { - ledger = ledger.add(curUID); - }) - }); - - if(commitType == "insert", {ledger = ledger.insert(ledger.indexOf(lastCurUID), curUID)}); - - if(commitType == "replace", {ledger = ledger.put(ledger.indexOf(lastCurUID), curUID)}); - - saveLedger.value(ledger, ledgerPath); - - addr.sendMsg("/committed", curUID, ledgerPath); - //refUID = curUID; - -}, \commit); - -OSCdef(\transport, {arg msg, time, addr, port; - msg.postln; - if(msg[1] == 0, { - group.set(\release, 2); - group.set(\gate, 0); - player.stop; - }, { - // the cued sequence can now be read from file, so this can be cleaned up - var cSize, patterns, pSeq, cuedSeek, indexStart, indexEnd, tmpLedger; - if(msg[1] == 1, { - pSeq = []; - cuedSeek = (seq != nil); - indexStart = msg[2].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.postln.parseJSON["music_data"]), path, indexStart + index, uid]); - file.close; - }); - }); - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - patterns = genPatterns.value(pSeq, addr); - }, { - pSeq = [loadModelJSON.value(msg[2].asString.parseJSON)["music_data"].postln]; - patterns = genPatterns.value(pSeq, addr, true); - }); - player = Pfset(pattern: patterns, cleanupFunc: { - addr.sendMsg("/transport", 0); - addr.sendMsg("/one_shot", 0); - }); - player = player.play - }); -}, \transport); - - -OSCdef(\transcribe_motif, {arg msg, time, addr, port; - var tSeq, refChord, refUID; - - msg.postln; - - tSeq = [loadModelJSON.value(msg[1].asString.parseJSON)["music_data"]]; - refUID = msg[2].asString.postln; - - if((refUID != "nil") && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }, { - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - }); - - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "lilypond" +/+ "includes").standardizePath, addr, "/transcribe_motif"); -}, \transcribe_motif); - - -OSCdef(\transcribe_all, {arg msg, time, addr, port; - var cSize, patterns, cuedSeek, indexStart, indexEnd, tmpLedger; - if(true, { - cuedSeek = (seq != nil); - indexStart = msg[1].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - - //tmp for testing transcription - indexEnd = (indexStart+5); - - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - var lilyPartLedgerFiles; - - lilyPartLedgerFiles = 4.collect({arg p; - File((dir +/+ ".." +/+ "lilypond" +/+ "includes" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly").standardizePath, "w"); - }); - - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file, fileString, tSeq, refUID, refChord; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - fileString = file.readAllString; - tSeq = msgInterpret.value(fileString.parseJSON["music_data"]); - refUID = msgInterpret.value(fileString.parseJSON["ref_uid"]); - file.close; - - //uid.postln; - //(refUID == "nil").postln; - - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - - if(refUID != "nil", { - path = (dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }); - - if(index != indexEnd, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath); - }, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath, addr, "/transcribe_all"); - }); - - lilyPartLedgerFiles.do({arg f, p; - f.write("\\include \".." +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly\"\n"); - }); - - }); - - lilyPartLedgerFiles.do({arg f; - f.close - }); - }); - /* - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - */ - }, { - - }); - -}, \transcribe_all); - -) - -~transcribe.value(~seq, dir); - -( -//synthdefs -~stringModelBusArray = 4.collect({Bus.audio(s, 1)}); -~sineBusArray = 4.collect({Bus.audio(s, 1)}); -~bassBusArray = 1.collect({Bus.audio(s, 1)}); -~hdustBusArray = 1.collect({Bus.audio(s, 1)}); -~samplerBusArray = 2.collect({Bus.audio(s, 1)}); -~sBuf = Buffer.alloc(s, 10, 2); -SynthDef(\string_model, {arg freq, gate = 1, sustain, amp, dur, attack, release = 1, busIndex = 0; - var trig, exc, sig1, sig2, noHarms; - noHarms = rrand(20, 40); - exc = Saw.ar(freq, TRand.ar(0.5, 1, Impulse.ar(freq))) * 0.001 + Dust.ar(10000, 0.01); - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.8).softclip; - //sig1 = HPF.ar(sig1, 300); - Out.ar(Select.kr(busIndex, ~stringModelBusArray), sig1 * amp * EnvGen.kr(Env.adsr(attack, 0.3, 0.9, release, 0.9, -3), gate, doneAction: 2)); - //Out.ar([0, 1], sig1 * EnvGen.kr(Env.asr(dur, 0.3, 1), gate, doneAction: 2)); -}).add; - -SynthDef(\sine, {arg freq, gate = 1, sustain, amp, dur, busIndex = 0; - var sig; - sig = SinOsc.ar(freq); - Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.asr(0.3, 0.4, 0.3), gate, timeScale: dur, doneAction: 2)); - //Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.sine(dur), gate, doneAction: 2)); -}).add; - -SynthDef(\mixer, {arg freq, gate = 1, sustain, amp, dur, out; - var nameSpaces, sigs; - - sigs = [~stringModelBusArray, ~sineBusArray/*, ~bassBusArray, ~hdustBusArray, ~samplerBusArray*/].collect({arg busArray, i; - var nameSpace, sig; - nameSpace = ['string', 'sine', 'bass', 'hdust', 'sampler'][i]; - sig = busArray.collect({arg bus, c; In.ar(bus, 1) * NamedControl.kr(\ ++ nameSpace ++ '_volume_' ++ c, 1, 0.1)}); - sig = sig.collect({arg channel, c; Pan2.ar(channel, NamedControl.kr(\ ++ nameSpace ++ '_pan_' ++ c, i / (busArray.size - 1), 0.1) * 2 - 1)}); - sig = sig.collect({arg channel, c; channel * NamedControl.kr(\ ++ nameSpace ++ '_mute_' ++ c, 1, 0.1)}); - sig = Mix.ar(sig) * pow(NamedControl.kr(\ ++ nameSpace ++ '_volume_master', 1, 0.1), 2); - }); - - sigs = Mix.ar(sigs / 4); - Out.ar(0, sigs) -}).add; - -SynthDef(\bass, { - var switches, drone; - switches = {|i| Dust.kr(0.1)} ! 9; - drone = {|i| var harm = pow(2, 2 - (i / 3).trunc), amp = (1 / pow(harm, 2)); - SinOsc.ar(60 * harm + TRand.kr(-3, 3, switches[i]), 0, amp)} ! 9; - Out.ar(~bassBusArray[0], Mix.new(drone) * 0.2); -}).add; - -SynthDef(\sampler, { - Out.ar(~samplerBusArray, PlayBuf.ar(2, ~sBuf, BufRateScale.kr(~sBuf), doneAction: 2)) -}).add; - -// main routine -SynthDef(\hdust, { - arg gate = 0; - var hierarchical_dust, low_sine, high_sine, brown_noise, white_noise; - // this triggers the combinations of sources - // it is similar to the Supercollider UGen called dust but with a hierarchical structure - hierarchical_dust = ( - TIRand.kr(0, 1, Impulse.kr(100)) * - TIRand.kr(0, 1, Impulse.kr(10)) * - TIRand.kr(0, 1, Impulse.kr(1)) * - TIRand.kr(0, 1, Impulse.kr(0.1)) - ); - // adjust the multiplier at the end of each line for adjusting levels - // note with each trigger, each source has a 1 in 3 chance of sounding - low_sine = SinOsc.ar(76.midicps / 16) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.1; - high_sine = SinOsc.ar(76.midicps * 8) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.01; - brown_noise = BrownNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.025; - white_noise = WhiteNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.02; - Out.ar(~hdustBusArray[0], - ((low_sine + high_sine + brown_noise + white_noise) ) - ); -}).add; - -) - -( -var bass, hdust, sampler, mixer; -/* -bass = Synth.tail(~group, \bass); -hdust = Synth.tail(~group, \hdust); -sampler = Synth.head(~group, \sampler); -*/ -mixer = Synth.tail(~group, \mixer); - -OSCdef(\mixer, {arg msg, time, addr, port; - mixer.set((msg[1] ++ '_' ++ msg[2] ++ '_' ++ msg[3]), msg[4]) -}, \mixer); - -/* -OSCdef(\sampler, {arg msg, time, addr, port; - msg.postln; - sampler.free; - ~sBuf.free; - ~sBuf = Buffer.read(s, msg[1].asString.postln, action: {sampler = Synth.head(~group, \sampler)}); -}, \sampler); -*/ -) - -/* old something -( -SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; - var trig, exc, sig1, sig2, noHarms, freqFinal, start, end; - noHarms = 30; - freq = WhiteNoise.ar * 3 + freq; - freqFinal = Duty.ar((1/freq), 0, freq); - trig = Changed.ar(freqFinal); - start = Demand.ar(trig, 0, Dwhite(-1, -0.75)); - end = Demand.ar(trig, 0, Dwhite(0.75, 1)); - exc = Phasor.ar(trig, (end - start) * freqFinal / SampleRate.ir, start, end, 0) * 0.001 + Dust.ar(10000, 0.01); - - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(2, 3)}) ], exc) * 0.5).softclip; - sig1 = HPF.ar(sig1, 300); - Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); -}).add; -) -*/ - diff --git a/resources/7c1ab0e0/7c1ab0e0_mus_model.json b/resources/7c1ab0e0/7c1ab0e0_mus_model.json deleted file mode 100644 index d6eb1aa..0000000 --- a/resources/7c1ab0e0/7c1ab0e0_mus_model.json +++ /dev/null @@ -1,51 +0,0 @@ -{ -"music_data": -[ - [ - [ - [ [ [ "Rest" ], [ 1, 0, 0, -1, -1, 0 ], [ "Rest" ], [ "Rest" ] ], 7.75 ], - [ [ [ "Rest" ], [ 1, 0, 0, -1, -1, 0 ], [ "Rest" ], [ 0, 0, 0, 0, -1, 0 ] ], 0.375 ], - [ [ [ "Rest" ], [ 1, 0, 0, -1, -1, 0 ], [ 2, 0, 0, -1, -1, -1 ], [ 0, 0, 0, 0, -1, 0 ] ], 7.875 ] - ], - [ - [ [ [ "Rest" ], [ 1, 0, 0, -1, -1, 0 ], [ "Rest" ], [ 0, 0, 0, 0, -1, 0 ] ], 0.25 ], - [ [ [ "Rest" ], [ 1, 0, 0, -1, -1, 0 ], [ "Rest" ], [ 1, 0, 0, -1, -1, -1 ] ], 0.375 ], - [ [ [ 3, -1, 0, -1, -1, 0 ], [ 1, 0, 0, -1, -1, 0 ], [ "Rest" ], [ 1, 0, 0, -1, -1, -1 ] ], 6.375 ], - [ [ [ 3, -1, 0, -1, -1, 0 ], [ "Rest" ], [ "Rest" ], [ 1, 0, 0, -1, -1, -1 ] ], 0 ], - [ [ [ 3, -1, 0, -1, -1, 0 ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 0 ], - [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 9.0 ] - ] - ] -], -"last_changes": -[ - [ [ 0, 1, 0, 0, 0, 0 ], [ 1, 0, 0, -1, -1, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ] ], - [ [ 0, 1, 0, 0, 0, 0 ], [ 1, 0, 0, -1, -1, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, -1, 0 ] ], - [ [ 0, 1, 0, 0, 0, 0 ], [ 1, 0, 0, -1, -1, 0 ], [ 2, 0, 0, -1, -1, -1 ], [ 0, 0, 0, 0, -1, 0 ] ], - [ [ 0, 1, 0, 0, 0, 0 ], [ 1, 0, 0, -1, -1, 0 ], [ 2, 0, 0, -1, -1, -1 ], [ 1, 0, 0, -1, -1, -1 ] ], - [ [ 3, -1, 0, -1, -1, 0 ], [ 1, 0, 0, -1, -1, 0 ], [ 2, 0, 0, -1, -1, -1 ], [ 1, 0, 0, -1, -1, -1 ] ] -], -"cur_uid": "7c1ab0e0", -"ref_uid": "4c01589b", -"order_seed": 804371, -"dur_seed": 780044, -"motifs_seed": 305398, -"entrances_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"passages_probs_vals": [ 0, 0, 10, 0, 0.5, 0.5, 0.5, 1, 0.5 ], -"exits_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"ranges": [ [ -384, 2400 ], [ -507, 2400 ], [ -282, 2237 ], [ -1200, 2053 ] ], -"step_probs_vals": [ 0, 1200, 0, 0.5, 0.5, 0.5, 1, 0.5 ], -"passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], -"hd_exp": 2, -"hd_invert": 0, -"order": -[ - [ [ 1 ], [ 3, 2 ], [ 0 ] ], - [ [ 1 ], [ 3, 0 ], [ 2 ] ] -], -"sus_weights": [ 1, 0, 0 ], -"order_size": [ 1, 3 ], -"passages_size": [ 0, 2 ], -"motif_edited": "false", -"order_edited": "false" -} \ No newline at end of file diff --git a/resources/7c7ba1aa/7c7ba1aa_code.scd b/resources/7c7ba1aa/7c7ba1aa_code.scd deleted file mode 100644 index 0bcd05a..0000000 --- a/resources/7c7ba1aa/7c7ba1aa_code.scd +++ /dev/null @@ -1,1053 +0,0 @@ -( -// helper funcs -var hsArrayToCents, pDist, hdSum, hsChordalDistance, hsArrayToFreq; - -// score funcs -var isInRange, spacingScore, rangeScore, intervalScore, inclusionScore; - -// subroutines -var genTuples, initVoices, genOrders, genSubMotif, updateVoices, genDurFunc, genStepFunc; - -// primary routines -var genMotif, genSecondarySeq; - -// audition funcs -var genPatterns, genMidiPatterns; - -// resource management funcs -var seedFunc, genUID, writeResources, stringifyToDepth, setSeeds, sanityCheck, -msgInterpret, loadLedgerFile, loadLedgerJSON, loadModelFile, loadModelJSON, -setGlobalVars, globalVarsToDict, saveLedger; - -// model vars -//(model and global vars mostly set by OSC funcs -var seq, lastXChanges, -curUID, refUID, orderSeed, durSeed, motifSeed, -entrancesProbVals, passagesProbVals, exitsProbVals, -ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, -orders, susWeights, orderSize, passagesSize, -motifEdited, orderEdited; - -// model aux vars -var entrancesDurFunc, passagesDurFunc, exitsDurFunc, stepFunc; - -// other global vars -var popSize, exPath, dir, primes, dims, tuples, -group, player, ledgerPath, ledger, currentlyPlayingUID, -nameSpaces; - -// install JSON quark -if(Quarks.isInstalled("JSONlib").not, { - Quarks.install("https://github.com/musikinformatik/JSONlib.git"); - thisProcess.recompile; - //HelpBrowser.openHelpFor("Classes/JSONlib"); -}); - - -//------helper funcs - -hsArrayToCents = { - arg hsArray; - hsArray.collect({arg dist, p; dist * 1200 * log2(primes[p][0]/primes[p][1])}).sum -}; - -pDist = { - arg array1, array2, signed = false; - var pDistance; - pDistance = hsArrayToCents.value(array1) - hsArrayToCents.value(array2); - if(signed, {pDistance}, {abs(pDistance)}) -}; - -hdSum = { - arg hsArrays; - var size, distances, mean; - size = hsArrays.size; - distances = (size - 1).collect({arg i; - ((i + 1)..(size - 1)).collect({arg j; - abs(hsArrays[i] - hsArrays[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsChordalDistance = { - arg hsArrays1, hsArrays2; - var size, distances, mean; - size = hsArrays1.size; - distances = hsArrays1.size.collect({arg i; - hsArrays2.size.collect({arg j; - abs(hsArrays1[i] - hsArrays2[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsArrayToFreq = { - arg array; - array.collect({arg dim, d; pow(primes[d][0]/primes[d][1], dim)}).product -}; - -//------score funcs - -/* -isInRange = { - arg hsArray, min, max; - var cents; - cents = hsArrayToCents.value(hsArray); - (cents >= min) && (cents <= max) -}; -*/ - -spacingScore = { - arg hsArrays, min; - var centsArray; - centsArray = hsArrays.collect({arg hsArray; hsArrayToCents.value(hsArray)}).sort({arg a, b; a < b}); - centsArray.differentiate.drop(1).collect({arg pDistance; if(pDistance >= min, {1}, {0.01})}).sum; -}; - -rangeScore = { - arg hsArray1, hsArray2, min, max, low, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - if((pDistance >= min) && (pDistance <= max), {1}, {low}); -}; - -intervalScore = { - arg hsArray1, hsArray2, mean, sd, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - //pDistance.gaussCurve(1, mean, sd) - stepFunc.value(pDistance); -}; - -inclusionScore = { - arg array, test, min = 0.01; - if(array.collect({arg v; v.hash}).includes(test.hash), {min}, {1}); -}; - - -//------subroutines - -genTuples = { - var tuples; - tuples = dims.collect({[-1, 0, 1]}).allTuples.select({arg tuple; (abs(tuple.drop(1)).sum <= 1) && (tuple[0] == 0)}); - tuples = tuples ++ tuples.collect({arg tuple; [-3, -2, -1, 1, 2, 3].collect({arg octTrans; tuple.deepCopy.put(0, octTrans)})}).flatten; -}; - -initVoices = { - var init, voicesInit; - voicesInit = popSize.collect({dims.collect({0})}); - /* - voicesInit = [dims.collect({0})]; - (popSize - 1).do({ - arg rep, new; - rep = dims.rand; - new = voicesInit.last.deepCopy; - new[rep] = new[rep] + [-1, 1].choose(); - voicesInit = voicesInit.add(new); - }); - */ - voicesInit.deepCopy; -}; - -genDurFunc = {arg chordProb, minPad, maxPad, minDur, maxDur, envData, seed; - var env, pTable, durFunc; - env = Env.pairs([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).asSignal(256).asList.asArray; - pTable = env.asRandomTable; - [chordProb, minPad, maxPad, minDur, maxDur, envData].postln; - durFunc = {arg allowChord, pad = false; - var res; - res = if(allowChord.not, { - pTable.tableRand * (maxDur - minDur) + minDur - }, { - if(1.0.rand < chordProb, {0}, {pTable.tableRand * (maxDur - minDur) + minDur}); - }).round(0.125); - if(pad, {res = res + rrand(minPad.asFloat, maxPad.asFloat).round(0.125)}); - if(res.asInteger == res, {res = res.asInteger}); - res - }; - seedFunc.value(durFunc, seed); -}; - -genStepFunc = {arg minStep, maxStep, envData, seed; - var envDataNorm, env, pTable, stepFunc; - [minStep, maxStep, envData].postln; - envDataNorm = ([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).flop; - envDataNorm = [envDataNorm[0].normalize(minStep, maxStep), envDataNorm[1]].flop; - env = Env.pairs(envDataNorm); - stepFunc = {arg pDist; - env.at(pDist).clip(0.001, 1); - }; - seedFunc.value(stepFunc, seed); -}; - -genOrders = {arg minMotifLength = 1, maxMotifLength = 5, minProgLength = 0, maxProgLength = 5; - ((maxMotifLength - minMotifLength).rand + minMotifLength).collect({ - var noProgIns, noSusIns, noSilentIns, prog, sus, silent, order; - noSusIns = [1, 2, 3].wchoose(susWeights.normalizeSum); - noProgIns = (popSize - noSusIns).rand + 1; - noSilentIns = popSize - noSusIns - noProgIns; - - # prog, sus, silent = (0..(popSize-1)).scramble.clumps([noProgIns, noSusIns, noSilentIns]); - - prog = (prog.scramble ++ ((maxProgLength - minProgLength).rand + minProgLength).collect({prog.choose}).scramble); - if(silent == nil, {silent = []}); - [sus.scramble, prog, silent.scramble] - }); -}; - -updateVoices = {arg ins, sus; - var voices, candidates, nWeights, nProbs, sel; - - voices = lastXChanges.deepCopy.last; - - candidates = sus.collect({arg v; tuples.collect({arg t; voices[v] + t})}).flatten; - candidates = difference(candidates.asSet, voices.asSet).asList; - nProbs = candidates.collect({arg candidate; - var stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore; - - //stepScore = intervalScore.value(voices[ins], candidate, 30, 400, 0.1); - stepScore = intervalScore.value(voices[ins], candidate, 100, 100); - recentlySoundedScore = inclusionScore.value(lastXChanges.flop[ins], candidate, 0); - isInRangeScore = rangeScore.value(candidate, candidate.collect({0}), ranges[ins][0], ranges[ins][1], 0, true); - regScore = spacingScore.value(voices.deepCopy.put(ins, candidate), 300); - hdScore = pow(hdSum.value(voices.deepCopy.put(ins, candidate)), hdExp); - if(hdInvert == 0, {hdScore = 1/hdScore}); - //maybe what you want here is a vector to another root and then favoring movement towards it. - //distScore = pow(hsChordalDistance.value(voices, voices.put(ins, candidate)), 2); - - [stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore] - }); - - nWeights = passagesWeights; - - //this handles nWeights of 0; mainly for testing - nProbs = nProbs.flop.select({arg scores, s; nWeights[s] != 0}).flop; - nWeights = nWeights.select({arg weight; weight != 0}); - nProbs = nProbs.flop.collect({arg scores, s; - if(scores.sum == 0, {scores}, {scores.normalizeSum * nWeights[s]}) - }); - nProbs = nProbs.flop.collect({arg scores, s; scores.product}).normalizeSum; - - sel = candidates.wchoose(nProbs); - - voices[ins] = sel; - lastXChanges = lastXChanges.add(voices).keep(-5); -}; - -genSubMotif = {arg order, orderIndex, lastState, repeatLast = false, startFromLast = false, isLastOrder = false; - var sus, prog, silent, flatOrder, res, isInChord, allowChord, pad, lastXChangesHold, voices, adder; - # sus, prog, silent = order; - flatOrder = silent ++ sus ++ prog; - lastXChangesHold = lastXChanges.deepCopy; - voices = lastState.deepCopy; - isInChord = popSize.collect({false}); - allowChord = false; - pad = false; - res = []; - "------generating motif".postln; - //need to figure out here if voices move between motifs - flatOrder.do({arg ins, i; - - if(prog.includes(ins) && repeatLast.not, {updateVoices.value(ins, sus)}); - adder = if(silent.includes(ins), {["Rest"]}, {lastXChanges.last.deepCopy[ins]}); - - if(voices[ins] != adder, { - var dur; - - if((sus ++ silent).includes(ins), { - allowChord = (ins != sus.last); - pad = (ins == sus.last); - }, { - if(i < (flatOrder.size - 1), { - allowChord = (isInChord[flatOrder[i + 1]] || (ins == flatOrder[i + 1])).not; - pad = false; - }, { - allowChord = false; - pad = true - }); - }); - if((orderIndex == 0) && sus.includes(ins), { - dur = entrancesDurFunc.value(allowChord, pad); - }, { - dur = passagesDurFunc.value(allowChord, pad); - }); - if(dur == 0, {isInChord[ins] = true}, {isInChord = popSize.collect({false})}); - - voices[ins] = adder; - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - - // pad ending - if(orderIndex == (orders.size - 1), { - (0..(popSize-1)).scramble.do({arg ins; - if(res.last.first[ins] != ["Rest"], { - var dur; - voices[ins] = ["Rest"]; - allowChord = (voices != popSize.collect({["Rest"]})); - pad = allowChord.not; - dur = exitsDurFunc.value(allowChord, pad); - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - }); - - //format and return - if(startFromLast, {lastXChanges = lastXChangesHold.deepCopy}); - res; -}; - - -//------primary routines - -genMotif = { - var repeats, fSeq, fDur, durAdd; - - repeats = 1; - fSeq = []; - - repeats.do({arg index; - var motif; - - motif = []; - - orders.do({arg order, o; - var lastState, subMotif; - lastState = if(o == 0, {popSize.collect({["Rest"]})}, {motif.last.last.first}); - subMotif = genSubMotif.value(order, o, lastState, isLastOrder: o == (orders.size - 1)); - motif = motif.add(subMotif); - - }); - - sanityCheck.value(motif, index); - - fSeq = fSeq.add(motif); - }); - - //round last duration to measure - fDur = fSeq.flatten.flatten.slice(nil, 1).sum; - durAdd = fDur.round(4) - fDur; - if(durAdd < 0, {durAdd = 4 - durAdd}); - fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] = fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] + durAdd; - - fSeq -}; - -genSecondarySeq = {arg seq; - var curdles, fSeq; - curdles = []; - while({curdles.sum < seq.size}, {curdles = curdles ++ [3.rand + 1]}); - - fSeq = seq.clumps(curdles).collect({arg clump, m; - var repeats, paddedSeq; - - //add rest - paddedSeq = clump.add([[[popSize.collect({["Rest"]}), 0.5.rand]]]); - - //implement repeats - repeats = [0.rand + 1, 1].wchoose([1, 0].normalizeSum); - repeats.collect({paddedSeq}); - }); - fSeq -}; - - -//------audition funcs - -/* -Event.addEventType(\osc, { - if (~addr.postln.notNil) { - ~addr.sendMsg(~indexPath, ~indexMsg); - ~addr.sendMsg(~seqPath, stringifyToDepth.value(~seqMsg, 3)); - //~addr.sendMsg("/STATE/OPEN", (dir.replace("supercollider", "resources") +/+ ~idMsg +/+ ~idMsg ++ "_gui_state" ++ ".state").standardizePath.postln); - }; -}); -*/ - -Event.addEventType(\osc, { - if (~addr.notNil) { - ~msg; - ~addr.sendMsg(~path, *~msg); - }; -}); - -genPatterns = {arg inSeq, addr, oneShot = false; - var voices, durs, pbinds, res, indices, sectionDurs, msg, ids, seq; - seq = inSeq.collect({arg mSeq; mSeq[0]}); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - pbinds = voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs, attacks, rels, amps; - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - //attacks = 2.collect({rrand(1, 3)}) ++ freqs.drop(2).collect({rrand(0.3, 0.5)}); - attacks = fDurs.collect({arg dur; dur * rrand(0.2, 0.4)}); - //rels = freqs.drop(2).collect({rrand(0.3, 0.5)}) ++ 2.collect({rrand(1, 3)}); - rels = (clumps.size - 1).collect({arg c; - if(clumps[c + 1][0] == ["Rest"], {rrand(1.0, 3.0)}, {rrand(0.3, 0.5)}); - }); - rels = rels.add(rrand(1.0, 3.0)); - amps = freqs.collect({rrand(0.6, 0.99)}); - - [ - Pbind( - \instrument, \string_model, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \attack, Pseq(attacks, 1), - \sustain, Pseq(fDurs, 1), - \release, Pseq(rels, 1), - //\amp, Pseq(amps, 1), - \amp, Pbrown(0.5, 1, 0.5), - \busIndex, v - ), - Pbind( - \instrument, \sine, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \sustain, Pseq(fDurs, 1), - \busIndex, v - ) - ] - }).flatten; - if(oneShot.not, { - msg = inSeq.collect({arg mSeq, m; mSeq[1..]}); - //ids = inSeq.collect({arg mSeq, m; mSeq[2]}); - sectionDurs = seq.collect({arg mSeq; mSeq.flatten2(mSeq.maxDepth - 5).flop[1].sum}); - pbinds = pbinds ++ - [ - Pbind( - \type, \osc, - \addr, addr, - \path, "/playing", - \msg, Pseq(msg, 1), - \dur, Pseq(sectionDurs, 1) - ); - ] - }); - res = Ppar(pbinds); - res -}; - -/* -genMidiPatterns = {arg seq; - var voices, durs, patterns, res, mOut, pbRange; - pbRange = 1; //semitones - change this as needed for your situation - mOut = MIDIOut.newByName("TiMidity", "TiMidity port 0").latency_(Server.default.latency); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - res = Ppar( - voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs; - - mOut.program(v, 70); - - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - - Pbind( - \type, \midi, - \chan, v, - \noteval, Pseq(freqs.cpsmidi - 24, 1), - \note, Pfunc({ | event | event[\noteval].floor }), - \dur, Pseq(fDurs, 1), - \midiout, mOut, - \amp, 1, - \bend, Pfunc({ - | event | - if (event[\note].isRest.not) { - var pitchbendvalue = event[\noteval].frac.linlin(0, pbRange, 8192, 8192*2).asInteger; - m.bend(v, pitchbendvalue); - }; - 0; // return something other than nil to avoid stopping the pattern - }), - ); - }); - ); - res -}; -*/ - - -//------resource management funcs - -genUID = {Date.seed.asHexString.toLower}; - -seedFunc = {arg func, seed; - var funcArgs, next; - next = Routine({loop{func.valueArray(funcArgs).yield }}); - next.randSeed_(seed); - {arg ...args; funcArgs = args; next.value} -}; - -stringifyToDepth = {arg data, maxDepth = 1; - var prettyString = "", rCount = 0, writeArray, indent; - - if(maxDepth == 0, { - data.asCompileString - }, { - indent = {arg size; size.collect({" "}).join("")}; - writeArray = {arg array; - prettyString = prettyString ++ indent.value(rCount) ++ "[\n"; - rCount = rCount + 1; - if(rCount < maxDepth, { - array.do({arg subArray; writeArray.value(subArray)}); - }, { - prettyString = prettyString ++ array.collect({arg subArray; - indent.value(rCount + 1) ++ subArray.asCompileString - }).join(",\n"); - }); - rCount = rCount - 1; - prettyString = prettyString ++ "\n" ++ indent.value(rCount) ++ "],\n"; - }; - - writeArray.value(data); - prettyString.replace(",\n\n", "\n").drop(-2); - }) -}; - -sanityCheck = {arg motif, index; - //print functions = very helpful - ("----------" + index + "------------").postln; - - motif.flatten.do({arg val, v; - if(v > 0, { - if(motif.flatten[v-1][0].hammingDistance(val[0]) > 1, {"problem 1".postln}); - if(motif.flatten[v-1][0].hammingDistance(val[0]) == 0, {"problem 2".postln}); - }); - val.postln - }); - "***********".postln; -}; - -msgInterpret = {arg in, escapeDoubleQuotes = true, escapeSingleQuotes = true; - var res; - - res = in; - if(res.isNil.not, { - if((res.isArray && res.isString.not), { - res = res.asCompileString; - res = res.replace(" ", "").replace("\n", "").replace("\t", ""); - if(escapeSingleQuotes, {res = res.replace("\'", "")}); - if(escapeDoubleQuotes, {res = res.replace("\"", "")}); - res = res.replace("Rest", "\"Rest\""); - res = res.interpret; - }, { - var tmpRes; - if(res.every({arg char; char.isDecDigit}), {tmpRes = res.asInteger}); - if(res.contains("."), {tmpRes = res.asFloat}); - if(tmpRes != nil, {res = tmpRes}); - }); - }); - res -}; - -writeResources = {arg path, dict; - var file, modelItems, resString; - file = File(path,"w"); - - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - - resString = nameSpaces.collect({arg nameSpace; - var depth = 0, insert = " "; - if(nameSpace == "music_data", {depth = 3; insert = "\n"}); - if(nameSpace == "last_changes", {depth = 1; insert = "\n"}); - if(nameSpace == "order", {depth = 1; insert = "\n"}); - if((nameSpace == "ref_uid") && (dict[nameSpace] == nil), {dict[nameSpace] = "nil"}); - "\"" ++ nameSpace ++ "\":" ++ insert ++ stringifyToDepth.value(dict[nameSpace], depth) - }).join(",\n"); - - resString = "{\n" ++ resString ++ "\n}"; - - file.write(resString); - file.close; - resString -}; - -loadModelFile = {arg path; loadModelJSON.value(File(path, "r").readAllString.parseJSON)}; - -loadModelJSON = {arg jsonObject; - var dict; - dict = Dictionary.with(*nameSpaces.collect({arg nS; nS->msgInterpret.value(jsonObject[nS])})); - dict -}; - -setGlobalVars = {arg dict, skipLastXChanges = false; - var tmpLastXChanges; - tmpLastXChanges = lastXChanges.deepCopy; - // order really matters!!!! - # seq, lastXChanges, curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited = nameSpaces.collect({arg nS; dict[nS]}); - if(skipLastXChanges, {lastXChanges = tmpLastXChanges}); - dict -}; - -globalVarsToDict = { - var modelItems, dict; - // order really matters!!!! - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - dict = Dictionary.with(*nameSpaces.collect({arg nS, n; nS->modelItems[n]})); -}; - -loadLedgerFile = {arg path; - ledgerPath = path; - loadLedgerJSON.value(File(ledgerPath, "r").readAllString.parseJSON) -}; - -loadLedgerJSON = {arg jsonObject; ledger = jsonObject["ledger"]}; - -saveLedger = {arg ledger, path; - var file; - file = File(path, "w"); - file.write("{\n\"ledger\":\n" ++ stringifyToDepth.value(ledger, 1) ++ "\n}"); - file.close; -}; - -//------global vars - -primes = [[2, 1], [3, 2], [5, 4], [7, 4], [11, 8], [13, 8]]; -//ranges = [[-2400, 0], [-1200, 1200], [0, 2400], [0, 2400]]; -exPath = thisProcess.nowExecutingPath; -dir = exPath.dirname; -//popSize = 4; -dims = primes.size; -tuples = genTuples.value(); -//refUID = nil; -group = Group.new; -~group = group; -loadLedgerFile.value(dir +/+ ".." +/+ "resources" +/+ "piece_ledger.json"); -//passagesWeights = [1, 1, 1, 1, 1]; -//susWeights = [1, 1, 1]; -// order really matters!!!! -nameSpaces = [ - "music_data", "last_changes", "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", - "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", - "ranges", "step_probs_vals", "passages_weights", "hd_exp", "hd_invert", - "order", "sus_weights", "order_size", "passages_size", - "motif_edited", "order_edited" -]; - - -//------OSC funcs - -OSCdef(\load_ledger, {arg msg, time, addr, port; - loadLedgerFile.value(msg[1].asString); -}, \load_ledger); - -OSCdef(\load_model, {arg msg, time, addr, port; - var dict; - dict = loadModelFile.value(msg[1].asString); - setGlobalVars.value(dict); -}, \load_model); - -OSCdef(\save_ledger, {arg msg, time, addr, port; - msg.postln; - ledger = msgInterpret.value(msg[1].asString.parseJSON["ledger"], false).postln; - //loadLedgerJSON.value(msg[0]) - saveLedger.value(ledger, msg[2].asString); - //loadLedgerFile.value(msg[1].asString); -}, \save_ledger); - -OSCdef(\generate, {arg msg, time, addr, port; - var path, dict, durSeeds, musPath, modelString; - msg.postln; - - path = msg[1].asString; - - dict = loadModelFile.value(path); - setGlobalVars.value(dict, true); - - popSize = ranges.size; - - //refUID.postln; - - loadLedgerFile.value(ledgerPath); - if(ledger == nil, {ledger = ["tmp"]}); - if(ledger.last != "tmp", {ledger = ledger.add("tmp")}); - - if(refUID == nil, {lastXChanges = [initVoices.value().deepCopy]}); - if((refUID != nil) && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - lastXChanges = msgInterpret.value(file.readAllString.parseJSON["last_changes"]); - }); - - refUID.postln; - lastXChanges.collect({arg item; item.postln}); - - durSeeds = seedFunc.value({3.collect({rrand(100000, 999999)})}, durSeed).value.postln; - entrancesDurFunc = genDurFunc.valueArray(entrancesProbVals[..4] ++ [entrancesProbVals[5..]] ++ [durSeeds[0]]); - passagesDurFunc = genDurFunc.valueArray(passagesProbVals[..4] ++ [passagesProbVals[5..]] ++ [durSeeds[1]]); - exitsDurFunc = genDurFunc.valueArray(exitsProbVals[..4] ++ [exitsProbVals[5..]] ++ [durSeeds[2]]); - - if(orders == nil, { - orders = seedFunc.value(genOrders, orderSeed).valueArray(orderSize ++ passagesSize); - //addr.sendMsg("/order", stringifyToDepth.value(orders, 1)); - }); - - stepFunc = genStepFunc.valueArray(stepProbsVals[..1] ++ [stepProbsVals[2..]] ++ [motifSeed]); - seq = seedFunc.value(genMotif, motifSeed).value; - - lastXChanges.collect({arg item; item.postln}); - - dict = globalVarsToDict.value; - modelString = writeResources.value(path, dict); - - //addr.sendMsg("/generated", musPath, stringifyToDepth.value(seq, 3)); - //~seq = seq; - - addr.sendMsg("/generated", path, modelString, ledgerPath); -}, \generate); - - -OSCdef(\commit, {arg msg, time, addr, port; - var musicData, musicChanged, dict, newLedger, modelPath, musString, musFile, test1, test2, lastCurUID, commitType, commitPos; - //msg.postln; - - /* - test1 = msg[1].asString.parseJSON; - test2 = (dir +/+ ".." +/+ "resources/tmp/tmp_music" ++ ".json").standardizePath.parseJSONFile; - msgInterpret.value(test1["music"])[0][0][0][1].class.postln; - msgInterpret.value(test2["music_data"])[0][0][0][1].class.postln; - (test1["music"] == test2["music_data"]).postln; - */ - - musicData = loadModelJSON.value(msg[1].asString.parseJSON)["music_data"].postln; - musicChanged = (musicData != seq).postln; - commitType = msg[2].asString; - commitPos = msg[3].postln.asInteger; - - lastCurUID = curUID.deepCopy; - curUID = genUID.value; - - File.mkdir((dir +/+ ".." +/+ "resources" +/+ curUID).standardizePath); - File.copy(exPath, (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_code" ++ ".scd").standardizePath); - - modelPath = (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_mus_model" ++ ".json").standardizePath; - dict = globalVarsToDict.value; - if(musicChanged, { - seq = musicData; - dict["music_data"] = seq; - dict["motif_edited"] = "true" - }); - dict["cur_uid"] = curUID; - - writeResources.value(modelPath, dict); - - File.delete(ledgerPath ++ "_bak"); - File.copy(ledgerPath, ledgerPath ++ "_bak"); - File.delete(ledgerPath); - - /* - if(commitType == "add", { - if(lastCurUID == "tmp", { - ledger = ledger.drop(-1).add(curUID); - }, { - ledger = ledger.add(curUID); - }) - }); - */ - - if(commitType == "add", {ledger = ledger.add(curUID)}); - - if(commitType == "insert", {ledger = ledger.insert(commitPos - 1, curUID)}); - - if(commitType == "replace", {ledger = ledger.put(commitPos, curUID)}); - - if(ledger.contains("tmp"), {ledger = ledger.removeAt(ledger.indexOf("tmp"))}); - - saveLedger.value(ledger, ledgerPath); - - addr.sendMsg("/committed", curUID, ledgerPath); - //refUID = curUID; - -}, \commit); - -OSCdef(\transport, {arg msg, time, addr, port; - msg.postln; - if(msg[1] == 0, { - group.set(\release, 2); - group.set(\gate, 0); - player.stop; - }, { - // the cued sequence can now be read from file, so this can be cleaned up - var cSize, patterns, pSeq, cuedSeek, indexStart, indexEnd, tmpLedger; - if(msg[1] == 1, { - pSeq = []; - cuedSeek = (seq != nil); - indexStart = msg[2].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.postln.parseJSON["music_data"]), path, indexStart + index, uid]); - file.close; - }); - }); - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - patterns = genPatterns.value(pSeq, addr); - }, { - pSeq = [loadModelJSON.value(msg[2].asString.parseJSON)["music_data"].postln]; - patterns = genPatterns.value(pSeq, addr, true); - }); - player = Pfset(pattern: patterns, cleanupFunc: { - addr.sendMsg("/transport", 0); - addr.sendMsg("/one_shot", 0); - }); - player = player.play - }); -}, \transport); - - -OSCdef(\transcribe_motif, {arg msg, time, addr, port; - var tSeq, refChord, refUID; - - msg.postln; - - tSeq = [loadModelJSON.value(msg[1].asString.parseJSON)["music_data"]]; - refUID = msg[2].asString.postln; - - if((refUID != "nil") && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }, { - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - }); - - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "lilypond" +/+ "includes").standardizePath, addr, "/transcribe_motif"); -}, \transcribe_motif); - - -OSCdef(\transcribe_all, {arg msg, time, addr, port; - var cSize, patterns, cuedSeek, indexStart, indexEnd, tmpLedger; - if(true, { - cuedSeek = (seq != nil); - indexStart = msg[1].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - - //tmp for testing transcription - indexEnd = (indexStart+5); - - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - var lilyPartLedgerFiles; - - lilyPartLedgerFiles = 4.collect({arg p; - File((dir +/+ ".." +/+ "lilypond" +/+ "includes" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly").standardizePath, "w"); - }); - - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file, fileString, tSeq, refUID, refChord; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - fileString = file.readAllString; - tSeq = msgInterpret.value(fileString.parseJSON["music_data"]); - refUID = msgInterpret.value(fileString.parseJSON["ref_uid"]); - file.close; - - //uid.postln; - //(refUID == "nil").postln; - - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - - if(refUID != "nil", { - path = (dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }); - - if(index != indexEnd, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath); - }, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath, addr, "/transcribe_all"); - }); - - lilyPartLedgerFiles.do({arg f, p; - f.write("\\include \".." +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly\"\n"); - }); - - }); - - lilyPartLedgerFiles.do({arg f; - f.close - }); - }); - /* - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - */ - }, { - - }); - -}, \transcribe_all); - -) - -~transcribe.value(~seq, dir); - -( -//synthdefs -~stringModelBusArray = 4.collect({Bus.audio(s, 1)}); -~sineBusArray = 4.collect({Bus.audio(s, 1)}); -~bassBusArray = 1.collect({Bus.audio(s, 1)}); -~hdustBusArray = 1.collect({Bus.audio(s, 1)}); -~samplerBusArray = 2.collect({Bus.audio(s, 1)}); -~sBuf = Buffer.alloc(s, 10, 2); -SynthDef(\string_model, {arg freq, gate = 1, sustain, amp, dur, attack, release = 1, busIndex = 0; - var trig, exc, sig1, sig2, noHarms; - noHarms = rrand(20, 40); - exc = Saw.ar(freq, TRand.ar(0.5, 1, Impulse.ar(freq))) * 0.001 + Dust.ar(10000, 0.01); - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.8).softclip; - //sig1 = HPF.ar(sig1, 300); - Out.ar(Select.kr(busIndex, ~stringModelBusArray), sig1 * amp * EnvGen.kr(Env.adsr(attack, 0.3, 0.9, release, 0.9, -3), gate, doneAction: 2)); - //Out.ar([0, 1], sig1 * EnvGen.kr(Env.asr(dur, 0.3, 1), gate, doneAction: 2)); -}).add; - -SynthDef(\sine, {arg freq, gate = 1, sustain, amp, dur, busIndex = 0; - var sig; - sig = SinOsc.ar(freq); - Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.asr(0.3, 0.4, 0.3), gate, timeScale: dur, doneAction: 2)); - //Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.sine(dur), gate, doneAction: 2)); -}).add; - -SynthDef(\mixer, {arg freq, gate = 1, sustain, amp, dur, out; - var nameSpaces, sigs; - - sigs = [~stringModelBusArray, ~sineBusArray/*, ~bassBusArray, ~hdustBusArray, ~samplerBusArray*/].collect({arg busArray, i; - var nameSpace, sig; - nameSpace = ['string', 'sine', 'bass', 'hdust', 'sampler'][i]; - sig = busArray.collect({arg bus, c; In.ar(bus, 1) * NamedControl.kr(\ ++ nameSpace ++ '_volume_' ++ c, 1, 0.1)}); - sig = sig.collect({arg channel, c; Pan2.ar(channel, NamedControl.kr(\ ++ nameSpace ++ '_pan_' ++ c, i / (busArray.size - 1), 0.1) * 2 - 1)}); - sig = sig.collect({arg channel, c; channel * NamedControl.kr(\ ++ nameSpace ++ '_mute_' ++ c, 1, 0.1)}); - sig = Mix.ar(sig) * pow(NamedControl.kr(\ ++ nameSpace ++ '_volume_master', 1, 0.1), 2); - }); - - sigs = Mix.ar(sigs / 4); - Out.ar(0, sigs) -}).add; - -SynthDef(\bass, { - var switches, drone; - switches = {|i| Dust.kr(0.1)} ! 9; - drone = {|i| var harm = pow(2, 2 - (i / 3).trunc), amp = (1 / pow(harm, 2)); - SinOsc.ar(60 * harm + TRand.kr(-3, 3, switches[i]), 0, amp)} ! 9; - Out.ar(~bassBusArray[0], Mix.new(drone) * 0.2); -}).add; - -SynthDef(\sampler, { - Out.ar(~samplerBusArray, PlayBuf.ar(2, ~sBuf, BufRateScale.kr(~sBuf), doneAction: 2)) -}).add; - -// main routine -SynthDef(\hdust, { - arg gate = 0; - var hierarchical_dust, low_sine, high_sine, brown_noise, white_noise; - // this triggers the combinations of sources - // it is similar to the Supercollider UGen called dust but with a hierarchical structure - hierarchical_dust = ( - TIRand.kr(0, 1, Impulse.kr(100)) * - TIRand.kr(0, 1, Impulse.kr(10)) * - TIRand.kr(0, 1, Impulse.kr(1)) * - TIRand.kr(0, 1, Impulse.kr(0.1)) - ); - // adjust the multiplier at the end of each line for adjusting levels - // note with each trigger, each source has a 1 in 3 chance of sounding - low_sine = SinOsc.ar(76.midicps / 16) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.1; - high_sine = SinOsc.ar(76.midicps * 8) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.01; - brown_noise = BrownNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.025; - white_noise = WhiteNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.02; - Out.ar(~hdustBusArray[0], - ((low_sine + high_sine + brown_noise + white_noise) ) - ); -}).add; - -) - -( -var bass, hdust, sampler, mixer; -/* -bass = Synth.tail(~group, \bass); -hdust = Synth.tail(~group, \hdust); -sampler = Synth.head(~group, \sampler); -*/ -mixer = Synth.tail(~group, \mixer); - -OSCdef(\mixer, {arg msg, time, addr, port; - mixer.set((msg[1] ++ '_' ++ msg[2] ++ '_' ++ msg[3]), msg[4]) -}, \mixer); - -/* -OSCdef(\sampler, {arg msg, time, addr, port; - msg.postln; - sampler.free; - ~sBuf.free; - ~sBuf = Buffer.read(s, msg[1].asString.postln, action: {sampler = Synth.head(~group, \sampler)}); -}, \sampler); -*/ -) - -/* old something -( -SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; - var trig, exc, sig1, sig2, noHarms, freqFinal, start, end; - noHarms = 30; - freq = WhiteNoise.ar * 3 + freq; - freqFinal = Duty.ar((1/freq), 0, freq); - trig = Changed.ar(freqFinal); - start = Demand.ar(trig, 0, Dwhite(-1, -0.75)); - end = Demand.ar(trig, 0, Dwhite(0.75, 1)); - exc = Phasor.ar(trig, (end - start) * freqFinal / SampleRate.ir, start, end, 0) * 0.001 + Dust.ar(10000, 0.01); - - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(2, 3)}) ], exc) * 0.5).softclip; - sig1 = HPF.ar(sig1, 300); - Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); -}).add; -) -*/ - diff --git a/resources/7c7ba1aa/7c7ba1aa_mus_model.json b/resources/7c7ba1aa/7c7ba1aa_mus_model.json deleted file mode 100644 index e70ff15..0000000 --- a/resources/7c7ba1aa/7c7ba1aa_mus_model.json +++ /dev/null @@ -1,61 +0,0 @@ -{ -"music_data": -[ - [ - [ - [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ] ], 9 ], - [ [ [ "Rest" ], [ "Rest" ], [ 1, -1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], 0.25 ], - [ [ [ "Rest" ], [ "Rest" ], [ 2, 0, 0, -1, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], 0.125 ], - [ [ [ "Rest" ], [ "Rest" ], [ 0, 0, 0, 1, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], 0 ], - [ [ [ "Rest" ], [ "Rest" ], [ 1, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], 0.125 ], - [ [ [ "Rest" ], [ "Rest" ], [ 1, 0, 1, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ]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.125 ], - [ [ [ "Rest" ], [ 2, -1, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ] ], 0 ], - [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 8.875 ] - ] - ] -], -"last_changes": -[ - [ [ 0, 0, 0, 0, 0, 0 ], [ 2, 0, 0, 0, 0, 0 ], [ 1, 1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], - [ [ 0, 0, 0, 0, 0, 0 ], [ 1, 1, -1, 0, 0, 0 ], [ 1, 1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], - [ [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, -1, 0, 0, 0 ], [ 1, 1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], - [ [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, 0 ], [ 1, 1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], - [ [ 0, 0, 0, 0, 0, 0 ], [ 2, -1, 0, 0, 0, 0 ], [ 1, 1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ] -], -"cur_uid": "7c7ba1aa", -"ref_uid": "nil", -"order_seed": 525340, -"dur_seed": 129734, -"motifs_seed": 613946, -"entrances_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.26424870466321, 0.75675675675676, 0.5, 0.5, 0.58549222797927, 0.72635135135135, 1, 0.5 ], -"passages_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"exits_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"ranges": [ [ -384, 2400 ], [ -507, 2400 ], [ -282, 2237 ], [ -1200, 2053 ] ], -"step_probs_vals": [ 0, 1200, 0, 0.5, 0.5, 0.5, 1, 0.5 ], -"passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], -"hd_exp": 2, -"hd_invert": 0, -"order": -[ - [ [ 3 ], [ 2, 2, 2, 2, 2, 2, 2 ], [ 0, 1 ] ], - [ [ 2, 3, 0 ], [ 1, 1, 1, 1, 1, 1 ], [ ] ] -], -"sus_weights": [ 0.75, 0.69, 0.75 ], -"order_size": [ 2, 6 ], -"passages_size": [ 0, 10 ], -"motif_edited": "false", -"order_edited": "false" -} \ No newline at end of file diff --git a/resources/7cc3121d/7cc3121d_code.scd b/resources/7cc3121d/7cc3121d_code.scd deleted file mode 100644 index 3eb3cbd..0000000 --- a/resources/7cc3121d/7cc3121d_code.scd +++ /dev/null @@ -1,1058 +0,0 @@ -( -// helper funcs -var hsArrayToCents, pDist, hdSum, hsChordalDistance, hsArrayToFreq; - -// score funcs -var isInRange, spacingScore, rangeScore, intervalScore, inclusionScore; - -// subroutines -var genTuples, initVoices, genOrders, genSubMotif, updateVoices, genDurFunc, genStepFunc; - -// primary routines -var genMotif, genSecondarySeq; - -// audition funcs -var genPatterns, genMidiPatterns; - -// resource management funcs -var seedFunc, genUID, writeResources, stringifyToDepth, setSeeds, sanityCheck, -msgInterpret, loadLedgerFile, loadLedgerJSON, loadModelFile, loadModelJSON, -setGlobalVars, globalVarsToDict, saveLedger; - -// model vars -//(model and global vars mostly set by OSC funcs -var seq, lastXChanges, -curUID, refUID, orderSeed, durSeed, motifSeed, -entrancesProbVals, passagesProbVals, exitsProbVals, -ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, -orders, susWeights, orderSize, passagesSize, -motifEdited, orderEdited; - -// model aux vars -var entrancesDurFunc, passagesDurFunc, exitsDurFunc, stepFunc; - -// other global vars -var popSize, exPath, dir, primes, dims, tuples, -group, player, ledgerPath, ledger, currentlyPlayingUID, -nameSpaces; - -// install JSON quark -if(Quarks.isInstalled("JSONlib").not, { - Quarks.install("https://github.com/musikinformatik/JSONlib.git"); - thisProcess.recompile; - //HelpBrowser.openHelpFor("Classes/JSONlib"); -}); - - -//------helper funcs - -hsArrayToCents = { - arg hsArray; - hsArray.collect({arg dist, p; dist * 1200 * log2(primes[p][0]/primes[p][1])}).sum -}; - -pDist = { - arg array1, array2, signed = false; - var pDistance; - pDistance = hsArrayToCents.value(array1) - hsArrayToCents.value(array2); - if(signed, {pDistance}, {abs(pDistance)}) -}; - -hdSum = { - arg hsArrays; - var size, distances, mean; - size = hsArrays.size; - distances = (size - 1).collect({arg i; - ((i + 1)..(size - 1)).collect({arg j; - abs(hsArrays[i] - hsArrays[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsChordalDistance = { - arg hsArrays1, hsArrays2; - var size, distances, mean; - size = hsArrays1.size; - distances = hsArrays1.size.collect({arg i; - hsArrays2.size.collect({arg j; - abs(hsArrays1[i] - hsArrays2[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsArrayToFreq = { - arg array; - array.collect({arg dim, d; pow(primes[d][0]/primes[d][1], dim)}).product -}; - -//------score funcs - -/* -isInRange = { - arg hsArray, min, max; - var cents; - cents = hsArrayToCents.value(hsArray); - (cents >= min) && (cents <= max) -}; -*/ - -spacingScore = { - arg hsArrays, min; - var centsArray; - centsArray = hsArrays.collect({arg hsArray; hsArrayToCents.value(hsArray)}).sort({arg a, b; a < b}); - centsArray.differentiate.drop(1).collect({arg pDistance; if(pDistance >= min, {1}, {0.01})}).sum; -}; - -rangeScore = { - arg hsArray1, hsArray2, min, max, low, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - if((pDistance >= min) && (pDistance <= max), {1}, {low}); -}; - -intervalScore = { - arg hsArray1, hsArray2, mean, sd, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - //pDistance.gaussCurve(1, mean, sd) - stepFunc.value(pDistance); -}; - -inclusionScore = { - arg array, test, min = 0.01; - if(array.collect({arg v; v.hash}).includes(test.hash), {min}, {1}); -}; - - -//------subroutines - -genTuples = { - var tuples; - tuples = dims.collect({[-1, 0, 1]}).allTuples.select({arg tuple; (abs(tuple.drop(1)).sum <= 1) && (tuple[0] == 0)}); - tuples = tuples ++ tuples.collect({arg tuple; [-3, -2, -1, 1, 2, 3].collect({arg octTrans; tuple.deepCopy.put(0, octTrans)})}).flatten; -}; - -initVoices = { - var init, voicesInit; - voicesInit = popSize.collect({dims.collect({0})}); - /* - voicesInit = [dims.collect({0})]; - (popSize - 1).do({ - arg rep, new; - rep = dims.rand; - new = voicesInit.last.deepCopy; - new[rep] = new[rep] + [-1, 1].choose(); - voicesInit = voicesInit.add(new); - }); - */ - voicesInit.deepCopy; -}; - -genDurFunc = {arg chordProb, minPad, maxPad, minDur, maxDur, envData, seed; - var env, pTable, durFunc; - env = Env.pairs([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).asSignal(256).asList.asArray; - pTable = env.asRandomTable; - [chordProb, minPad, maxPad, minDur, maxDur, envData].postln; - durFunc = {arg allowChord, pad = false; - var res; - res = if(allowChord.not, { - pTable.tableRand * (maxDur - minDur) + minDur - }, { - if(1.0.rand < chordProb, {0}, {pTable.tableRand * (maxDur - minDur) + minDur}); - }).round(0.125); - if(pad, {res = res + rrand(minPad.asFloat, maxPad.asFloat).round(0.125)}); - if(res.asInteger == res, {res = res.asInteger}); - res - }; - seedFunc.value(durFunc, seed); -}; - -genStepFunc = {arg minStep, maxStep, envData, seed; - var envDataNorm, env, pTable, stepFunc; - [minStep, maxStep, envData].postln; - envDataNorm = ([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).flop; - envDataNorm = [envDataNorm[0].normalize(minStep, maxStep), envDataNorm[1]].flop; - env = Env.pairs(envDataNorm); - stepFunc = {arg pDist; - env.at(pDist).clip(0.001, 1); - }; - seedFunc.value(stepFunc, seed); -}; - -genOrders = {arg minMotifLength = 1, maxMotifLength = 5, minProgLength = 0, maxProgLength = 5; - ((maxMotifLength - minMotifLength).rand + minMotifLength).collect({ - var noProgIns, noSusIns, noSilentIns, prog, sus, silent, order; - noSusIns = [1, 2, 3].wchoose(susWeights.normalizeSum); - noProgIns = (popSize - noSusIns).rand + 1; - noSilentIns = popSize - noSusIns - noProgIns; - - # prog, sus, silent = (0..(popSize-1)).scramble.clumps([noProgIns, noSusIns, noSilentIns]); - - prog = (prog.scramble ++ ((maxProgLength - minProgLength).rand + minProgLength).collect({prog.choose}).scramble); - if(silent == nil, {silent = []}); - [sus.scramble, prog, silent.scramble] - }); -}; - -updateVoices = {arg ins, sus; - var voices, candidates, nWeights, nProbs, sel; - - voices = lastXChanges.deepCopy.last; - - candidates = sus.collect({arg v; tuples.collect({arg t; voices[v] + t})}).flatten; - candidates = difference(candidates.asSet, voices.asSet).asList; - nProbs = candidates.collect({arg candidate; - var stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore; - - //stepScore = intervalScore.value(voices[ins], candidate, 30, 400, 0.1); - stepScore = intervalScore.value(voices[ins], candidate, 100, 100); - recentlySoundedScore = inclusionScore.value(lastXChanges.flop[ins], candidate, 0); - isInRangeScore = rangeScore.value(candidate, candidate.collect({0}), ranges[ins][0], ranges[ins][1], 0, true); - regScore = spacingScore.value(voices.deepCopy.put(ins, candidate), 300); - hdScore = pow(hdSum.value(voices.deepCopy.put(ins, candidate)), hdExp); - if(hdInvert == 0, {hdScore = 1/hdScore}); - //maybe what you want here is a vector to another root and then favoring movement towards it. - //distScore = pow(hsChordalDistance.value(voices, voices.put(ins, candidate)), 2); - - [stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore] - }); - - nWeights = passagesWeights; - - //this handles nWeights of 0; mainly for testing - nProbs = nProbs.flop.select({arg scores, s; nWeights[s] != 0}).flop; - nWeights = nWeights.select({arg weight; weight != 0}); - nProbs = nProbs.flop.collect({arg scores, s; - if(scores.sum == 0, {scores}, {scores.normalizeSum * nWeights[s]}) - }); - nProbs = nProbs.flop.collect({arg scores, s; scores.product}).normalizeSum; - - sel = candidates.wchoose(nProbs); - - voices[ins] = sel; - lastXChanges = lastXChanges.add(voices).keep(-5); -}; - -genSubMotif = {arg order, orderIndex, lastState, repeatLast = false, startFromLast = false, isLastOrder = false; - var sus, prog, silent, flatOrder, res, isInChord, allowChord, pad, lastXChangesHold, voices, adder; - # sus, prog, silent = order; - flatOrder = silent ++ sus ++ prog; - lastXChangesHold = lastXChanges.deepCopy; - voices = lastState.deepCopy; - isInChord = popSize.collect({false}); - allowChord = false; - pad = false; - res = []; - "------generating motif".postln; - //need to figure out here if voices move between motifs - flatOrder.do({arg ins, i; - - if(prog.includes(ins) && repeatLast.not, {updateVoices.value(ins, sus)}); - adder = if(silent.includes(ins), {["Rest"]}, {lastXChanges.last.deepCopy[ins]}); - - if(voices[ins] != adder, { - var dur; - - if((sus ++ silent).includes(ins), { - allowChord = (ins != sus.last); - pad = (ins == sus.last); - }, { - if(i < (flatOrder.size - 1), { - allowChord = (isInChord[flatOrder[i + 1]] || (ins == flatOrder[i + 1])).not; - pad = false; - }, { - allowChord = false; - pad = true - }); - }); - if((orderIndex == 0) && sus.includes(ins), { - dur = entrancesDurFunc.value(allowChord, pad); - }, { - dur = passagesDurFunc.value(allowChord, pad); - }); - if(dur == 0, {isInChord[ins] = true}, {isInChord = popSize.collect({false})}); - - voices[ins] = adder; - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - - // pad ending - if(orderIndex == (orders.size - 1), { - (0..(popSize-1)).scramble.do({arg ins; - if(res.last.first[ins] != ["Rest"], { - var dur; - voices[ins] = ["Rest"]; - allowChord = (voices != popSize.collect({["Rest"]})); - pad = allowChord.not; - dur = exitsDurFunc.value(allowChord, pad); - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - }); - - //format and return - if(startFromLast, {lastXChanges = lastXChangesHold.deepCopy}); - res; -}; - - -//------primary routines - -genMotif = { - var repeats, fSeq, fDur, durAdd; - - repeats = 1; - fSeq = []; - - repeats.do({arg index; - var motif; - - motif = []; - - orders.do({arg order, o; - var lastState, subMotif; - lastState = if(o == 0, {popSize.collect({["Rest"]})}, {motif.last.last.first}); - subMotif = genSubMotif.value(order, o, lastState, isLastOrder: o == (orders.size - 1)); - motif = motif.add(subMotif); - - }); - - sanityCheck.value(motif, index); - - fSeq = fSeq.add(motif); - }); - - //round last duration to measure - fDur = fSeq.flatten.flatten.slice(nil, 1).sum; - durAdd = fDur.round(4) - fDur; - if(durAdd < 0, {durAdd = 4 - durAdd}); - fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] = fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] + durAdd; - - fSeq -}; - -genSecondarySeq = {arg seq; - var curdles, fSeq; - curdles = []; - while({curdles.sum < seq.size}, {curdles = curdles ++ [3.rand + 1]}); - - fSeq = seq.clumps(curdles).collect({arg clump, m; - var repeats, paddedSeq; - - //add rest - paddedSeq = clump.add([[[popSize.collect({["Rest"]}), 0.5.rand]]]); - - //implement repeats - repeats = [0.rand + 1, 1].wchoose([1, 0].normalizeSum); - repeats.collect({paddedSeq}); - }); - fSeq -}; - - -//------audition funcs - -/* -Event.addEventType(\osc, { - if (~addr.postln.notNil) { - ~addr.sendMsg(~indexPath, ~indexMsg); - ~addr.sendMsg(~seqPath, stringifyToDepth.value(~seqMsg, 3)); - //~addr.sendMsg("/STATE/OPEN", (dir.replace("supercollider", "resources") +/+ ~idMsg +/+ ~idMsg ++ "_gui_state" ++ ".state").standardizePath.postln); - }; -}); -*/ - -Event.addEventType(\osc, { - if (~addr.notNil) { - ~msg; - ~addr.sendMsg(~path, *~msg); - }; -}); - -genPatterns = {arg inSeq, addr, oneShot = false; - var voices, durs, pbinds, res, indices, sectionDurs, msg, ids, seq; - seq = inSeq.collect({arg mSeq; mSeq[0]}); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - pbinds = voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs, attacks, rels, amps; - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - //attacks = 2.collect({rrand(1, 3)}) ++ freqs.drop(2).collect({rrand(0.3, 0.5)}); - attacks = fDurs.collect({arg dur; dur * rrand(0.2, 0.4)}); - //rels = freqs.drop(2).collect({rrand(0.3, 0.5)}) ++ 2.collect({rrand(1, 3)}); - rels = (clumps.size - 1).collect({arg c; - if(clumps[c + 1][0] == ["Rest"], {rrand(1.0, 3.0)}, {rrand(0.3, 0.5)}); - }); - rels = rels.add(rrand(1.0, 3.0)); - amps = freqs.collect({rrand(0.6, 0.99)}); - - [ - Pbind( - \instrument, \string_model, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \attack, Pseq(attacks, 1), - \sustain, Pseq(fDurs, 1), - \release, Pseq(rels, 1), - //\amp, Pseq(amps, 1), - \amp, Pbrown(0.5, 1, 0.5), - \busIndex, v - ), - Pbind( - \instrument, \sine, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \sustain, Pseq(fDurs, 1), - \busIndex, v - ) - ] - }).flatten; - if(oneShot.not, { - msg = inSeq.collect({arg mSeq, m; mSeq[1..]}); - //ids = inSeq.collect({arg mSeq, m; mSeq[2]}); - sectionDurs = seq.collect({arg mSeq; mSeq.flatten2(mSeq.maxDepth - 5).flop[1].sum}); - pbinds = pbinds ++ - [ - Pbind( - \type, \osc, - \addr, addr, - \path, "/playing", - \msg, Pseq(msg, 1), - \dur, Pseq(sectionDurs, 1) - ); - ] - }); - res = Ppar(pbinds); - res -}; - -/* -genMidiPatterns = {arg seq; - var voices, durs, patterns, res, mOut, pbRange; - pbRange = 1; //semitones - change this as needed for your situation - mOut = MIDIOut.newByName("TiMidity", "TiMidity port 0").latency_(Server.default.latency); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - res = Ppar( - voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs; - - mOut.program(v, 70); - - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - - Pbind( - \type, \midi, - \chan, v, - \noteval, Pseq(freqs.cpsmidi - 24, 1), - \note, Pfunc({ | event | event[\noteval].floor }), - \dur, Pseq(fDurs, 1), - \midiout, mOut, - \amp, 1, - \bend, Pfunc({ - | event | - if (event[\note].isRest.not) { - var pitchbendvalue = event[\noteval].frac.linlin(0, pbRange, 8192, 8192*2).asInteger; - m.bend(v, pitchbendvalue); - }; - 0; // return something other than nil to avoid stopping the pattern - }), - ); - }); - ); - res -}; -*/ - - -//------resource management funcs - -genUID = {Date.seed.asHexString.toLower}; - -seedFunc = {arg func, seed; - var funcArgs, next; - next = Routine({loop{func.valueArray(funcArgs).yield }}); - next.randSeed_(seed); - {arg ...args; funcArgs = args; next.value} -}; - -stringifyToDepth = {arg data, maxDepth = 1; - var prettyString = "", rCount = 0, writeArray, indent; - - if(maxDepth == 0, { - data.asCompileString - }, { - indent = {arg size; size.collect({" "}).join("")}; - writeArray = {arg array; - prettyString = prettyString ++ indent.value(rCount) ++ "[\n"; - rCount = rCount + 1; - if(rCount < maxDepth, { - array.do({arg subArray; writeArray.value(subArray)}); - }, { - prettyString = prettyString ++ array.collect({arg subArray; - indent.value(rCount + 1) ++ subArray.asCompileString - }).join(",\n"); - }); - rCount = rCount - 1; - prettyString = prettyString ++ "\n" ++ indent.value(rCount) ++ "],\n"; - }; - - writeArray.value(data); - prettyString.replace(",\n\n", "\n").drop(-2); - }) -}; - -sanityCheck = {arg motif, index; - //print functions = very helpful - ("----------" + index + "------------").postln; - - motif.flatten.do({arg val, v; - if(v > 0, { - if(motif.flatten[v-1][0].hammingDistance(val[0]) > 1, {"problem 1".postln}); - if(motif.flatten[v-1][0].hammingDistance(val[0]) == 0, {"problem 2".postln}); - }); - val.postln - }); - "***********".postln; -}; - -msgInterpret = {arg in, escapeDoubleQuotes = true, escapeSingleQuotes = true; - var res; - - res = in; - if(res.isNil.not, { - if((res.isArray && res.isString.not), { - res = res.asCompileString; - res = res.replace(" ", "").replace("\n", "").replace("\t", ""); - if(escapeSingleQuotes, {res = res.replace("\'", "")}); - if(escapeDoubleQuotes, {res = res.replace("\"", "")}); - res = res.replace("Rest", "\"Rest\""); - res = res.interpret; - }, { - var tmpRes; - if(res.every({arg char; char.isDecDigit}), {tmpRes = res.asInteger}); - if(res.contains("."), {tmpRes = res.asFloat}); - if(tmpRes != nil, {res = tmpRes}); - }); - }); - res -}; - -writeResources = {arg path, dict; - var file, modelItems, resString; - file = File(path,"w"); - - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - - resString = nameSpaces.collect({arg nameSpace; - var depth = 0, insert = " "; - if(nameSpace == "music_data", {depth = 3; insert = "\n"}); - if(nameSpace == "last_changes", {depth = 1; insert = "\n"}); - if(nameSpace == "order", {depth = 1; insert = "\n"}); - if((nameSpace == "ref_uid") && (dict[nameSpace] == nil), {dict[nameSpace] = "nil"}); - "\"" ++ nameSpace ++ "\":" ++ insert ++ stringifyToDepth.value(dict[nameSpace], depth) - }).join(",\n"); - - resString = "{\n" ++ resString ++ "\n}"; - - file.write(resString); - file.close; - resString -}; - -loadModelFile = {arg path; loadModelJSON.value(File(path, "r").readAllString.parseJSON)}; - -loadModelJSON = {arg jsonObject; - var dict; - dict = Dictionary.with(*nameSpaces.collect({arg nS; nS->msgInterpret.value(jsonObject[nS])})); - dict -}; - -setGlobalVars = {arg dict, skipLastXChanges = false; - var tmpLastXChanges; - tmpLastXChanges = lastXChanges.deepCopy; - // order really matters!!!! - # seq, lastXChanges, curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited = nameSpaces.collect({arg nS; dict[nS]}); - if(skipLastXChanges, {lastXChanges = tmpLastXChanges}); - dict -}; - -globalVarsToDict = { - var modelItems, dict; - // order really matters!!!! - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - dict = Dictionary.with(*nameSpaces.collect({arg nS, n; nS->modelItems[n]})); -}; - -loadLedgerFile = {arg path; - ledgerPath = path; - loadLedgerJSON.value(File(ledgerPath, "r").readAllString.parseJSON) -}; - -loadLedgerJSON = {arg jsonObject; ledger = jsonObject["ledger"]}; - -saveLedger = {arg ledger, path; - var file; - file = File(path, "w"); - file.write("{\n\"ledger\":\n" ++ stringifyToDepth.value(ledger, 1) ++ "\n}"); - file.close; -}; - -//------global vars - -primes = [[2, 1], [3, 2], [5, 4], [7, 4], [11, 8], [13, 8]]; -//ranges = [[-2400, 0], [-1200, 1200], [0, 2400], [0, 2400]]; -exPath = thisProcess.nowExecutingPath; -dir = exPath.dirname; -//popSize = 4; -dims = primes.size; -tuples = genTuples.value(); -//refUID = nil; -group = Group.new; -~group = group; -loadLedgerFile.value(dir +/+ ".." +/+ "resources" +/+ "piece_ledger.json"); -//passagesWeights = [1, 1, 1, 1, 1]; -//susWeights = [1, 1, 1]; -// order really matters!!!! -nameSpaces = [ - "music_data", "last_changes", "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", - "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", - "ranges", "step_probs_vals", "passages_weights", "hd_exp", "hd_invert", - "order", "sus_weights", "order_size", "passages_size", - "motif_edited", "order_edited" -]; - - -//------OSC funcs - -OSCdef(\load_ledger, {arg msg, time, addr, port; - loadLedgerFile.value(msg[1].asString); -}, \load_ledger); - -OSCdef(\load_model, {arg msg, time, addr, port; - var dict; - dict = loadModelFile.value(msg[1].asString); - setGlobalVars.value(dict); -}, \load_model); - -OSCdef(\save_ledger, {arg msg, time, addr, port; - msg.postln; - ledger = msgInterpret.value(msg[1].asString.parseJSON["ledger"], false).postln; - //loadLedgerJSON.value(msg[0]) - saveLedger.value(ledger, msg[2].asString); - //loadLedgerFile.value(msg[1].asString); -}, \save_ledger); - -OSCdef(\generate, {arg msg, time, addr, port; - var path, dict, durSeeds, musPath, modelString; - msg.postln; - - path = msg[1].asString; - - dict = loadModelFile.value(path); - setGlobalVars.value(dict, true); - - popSize = ranges.size; - - //refUID.postln; - - loadLedgerFile.value(ledgerPath); - if(ledger == nil, {ledger = ["tmp"]}); - if(ledger.last != "tmp", {ledger = ledger.add("tmp")}); - - if(refUID == nil, {lastXChanges = [initVoices.value().deepCopy]}); - if((refUID != nil) && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - lastXChanges = msgInterpret.value(file.readAllString.parseJSON["last_changes"]); - }); - - refUID.postln; - lastXChanges.collect({arg item; item.postln}); - - durSeeds = seedFunc.value({3.collect({rrand(100000, 999999)})}, durSeed).value.postln; - entrancesDurFunc = genDurFunc.valueArray(entrancesProbVals[..4] ++ [entrancesProbVals[5..]] ++ [durSeeds[0]]); - passagesDurFunc = genDurFunc.valueArray(passagesProbVals[..4] ++ [passagesProbVals[5..]] ++ [durSeeds[1]]); - exitsDurFunc = genDurFunc.valueArray(exitsProbVals[..4] ++ [exitsProbVals[5..]] ++ [durSeeds[2]]); - - if(orders == nil, { - orders = seedFunc.value(genOrders, orderSeed).valueArray(orderSize ++ passagesSize); - //addr.sendMsg("/order", stringifyToDepth.value(orders, 1)); - }); - - stepFunc = genStepFunc.valueArray(stepProbsVals[..1] ++ [stepProbsVals[2..]] ++ [motifSeed]); - seq = seedFunc.value(genMotif, motifSeed).value; - - lastXChanges.collect({arg item; item.postln}); - - dict = globalVarsToDict.value; - modelString = writeResources.value(path, dict); - - //addr.sendMsg("/generated", musPath, stringifyToDepth.value(seq, 3)); - //~seq = seq; - - addr.sendMsg("/generated", path, modelString, ledgerPath); -}, \generate); - - -OSCdef(\commit, {arg msg, time, addr, port; - var musicData, musicChanged, dict, newLedger, modelPath, musString, musFile, test1, test2, lastCurUID, commitType, commitPos, equalityLedger; - //msg.postln; - - /* - test1 = msg[1].asString.parseJSON; - test2 = (dir +/+ ".." +/+ "resources/tmp/tmp_music" ++ ".json").standardizePath.parseJSONFile; - msgInterpret.value(test1["music"])[0][0][0][1].class.postln; - msgInterpret.value(test2["music_data"])[0][0][0][1].class.postln; - (test1["music"] == test2["music_data"]).postln; - */ - - musicData = loadModelJSON.value(msg[1].asString.parseJSON)["music_data"].postln; - musicChanged = (musicData != seq).postln; - commitType = msg[2].asString; - commitPos = msg[3].postln.asInteger; - - lastCurUID = curUID.deepCopy; - curUID = genUID.value; - - File.mkdir((dir +/+ ".." +/+ "resources" +/+ curUID).standardizePath); - File.copy(exPath, (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_code" ++ ".scd").standardizePath); - - modelPath = (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_mus_model" ++ ".json").standardizePath; - dict = globalVarsToDict.value; - if(musicChanged, { - seq = musicData; - dict["music_data"] = seq; - dict["motif_edited"] = "true" - }); - dict["cur_uid"] = curUID; - - writeResources.value(modelPath, dict); - - File.delete(ledgerPath ++ "_bak"); - File.copy(ledgerPath, ledgerPath ++ "_bak"); - File.delete(ledgerPath); - - /* - if(commitType == "add", { - if(lastCurUID == "tmp", { - ledger = ledger.drop(-1).add(curUID); - }, { - ledger = ledger.add(curUID); - }) - }); - */ - - ledger.postln; - - if(commitType == "add", {ledger = ledger.add(curUID)}); - - if(commitType == "insert", {ledger = ledger.insert(commitPos + 1, curUID)}); - - if(commitType == "replace", {ledger = ledger.put(commitPos, curUID)}); - - equalityLedger = ledger.collect({arg item; item.asSymbol}); - if(equalityLedger.includes(\tmp).postln, {ledger.removeAt(equalityLedger.indexOf(\tmp).postln)}); - - ledger.postln; - - saveLedger.value(ledger, ledgerPath); - - addr.sendMsg("/committed", curUID, ledgerPath); - //refUID = curUID; - -}, \commit); - -OSCdef(\transport, {arg msg, time, addr, port; - msg.postln; - if(msg[1] == 0, { - group.set(\release, 2); - group.set(\gate, 0); - player.stop; - }, { - // the cued sequence can now be read from file, so this can be cleaned up - var cSize, patterns, pSeq, cuedSeek, indexStart, indexEnd, tmpLedger; - if(msg[1] == 1, { - pSeq = []; - cuedSeek = (seq != nil); - indexStart = msg[2].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.postln.parseJSON["music_data"]), path, indexStart + index, uid]); - file.close; - }); - }); - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - patterns = genPatterns.value(pSeq, addr); - }, { - pSeq = [loadModelJSON.value(msg[2].asString.parseJSON)["music_data"].postln]; - patterns = genPatterns.value(pSeq, addr, true); - }); - player = Pfset(pattern: patterns, cleanupFunc: { - addr.sendMsg("/transport", 0); - addr.sendMsg("/one_shot", 0); - }); - player = player.play - }); -}, \transport); - - -OSCdef(\transcribe_motif, {arg msg, time, addr, port; - var tSeq, refChord, refUID; - - msg.postln; - - tSeq = [loadModelJSON.value(msg[1].asString.parseJSON)["music_data"]]; - refUID = msg[2].asString.postln; - - if((refUID != "nil") && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }, { - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - }); - - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "lilypond" +/+ "includes").standardizePath, addr, "/transcribe_motif"); -}, \transcribe_motif); - - -OSCdef(\transcribe_all, {arg msg, time, addr, port; - var cSize, patterns, cuedSeek, indexStart, indexEnd, tmpLedger; - if(true, { - cuedSeek = (seq != nil); - indexStart = msg[1].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - - //tmp for testing transcription - indexEnd = (indexStart+5); - - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - var lilyPartLedgerFiles; - - lilyPartLedgerFiles = 4.collect({arg p; - File((dir +/+ ".." +/+ "lilypond" +/+ "includes" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly").standardizePath, "w"); - }); - - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file, fileString, tSeq, refUID, refChord; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - fileString = file.readAllString; - tSeq = msgInterpret.value(fileString.parseJSON["music_data"]); - refUID = msgInterpret.value(fileString.parseJSON["ref_uid"]); - file.close; - - //uid.postln; - //(refUID == "nil").postln; - - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - - if(refUID != "nil", { - path = (dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }); - - if(index != indexEnd, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath); - }, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath, addr, "/transcribe_all"); - }); - - lilyPartLedgerFiles.do({arg f, p; - f.write("\\include \".." +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly\"\n"); - }); - - }); - - lilyPartLedgerFiles.do({arg f; - f.close - }); - }); - /* - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - */ - }, { - - }); - -}, \transcribe_all); - -) - -~transcribe.value(~seq, dir); - -( -//synthdefs -~stringModelBusArray = 4.collect({Bus.audio(s, 1)}); -~sineBusArray = 4.collect({Bus.audio(s, 1)}); -~bassBusArray = 1.collect({Bus.audio(s, 1)}); -~hdustBusArray = 1.collect({Bus.audio(s, 1)}); -~samplerBusArray = 2.collect({Bus.audio(s, 1)}); -~sBuf = Buffer.alloc(s, 10, 2); -SynthDef(\string_model, {arg freq, gate = 1, sustain, amp, dur, attack, release = 1, busIndex = 0; - var trig, exc, sig1, sig2, noHarms; - noHarms = rrand(20, 40); - exc = Saw.ar(freq, TRand.ar(0.5, 1, Impulse.ar(freq))) * 0.001 + Dust.ar(10000, 0.01); - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.8).softclip; - //sig1 = HPF.ar(sig1, 300); - Out.ar(Select.kr(busIndex, ~stringModelBusArray), sig1 * amp * EnvGen.kr(Env.adsr(attack, 0.3, 0.9, release, 0.9, -3), gate, doneAction: 2)); - //Out.ar([0, 1], sig1 * EnvGen.kr(Env.asr(dur, 0.3, 1), gate, doneAction: 2)); -}).add; - -SynthDef(\sine, {arg freq, gate = 1, sustain, amp, dur, busIndex = 0; - var sig; - sig = SinOsc.ar(freq); - Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.asr(0.3, 0.4, 0.3), gate, timeScale: dur, doneAction: 2)); - //Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.sine(dur), gate, doneAction: 2)); -}).add; - -SynthDef(\mixer, {arg freq, gate = 1, sustain, amp, dur, out; - var nameSpaces, sigs; - - sigs = [~stringModelBusArray, ~sineBusArray/*, ~bassBusArray, ~hdustBusArray, ~samplerBusArray*/].collect({arg busArray, i; - var nameSpace, sig; - nameSpace = ['string', 'sine', 'bass', 'hdust', 'sampler'][i]; - sig = busArray.collect({arg bus, c; In.ar(bus, 1) * NamedControl.kr(\ ++ nameSpace ++ '_volume_' ++ c, 1, 0.1)}); - sig = sig.collect({arg channel, c; Pan2.ar(channel, NamedControl.kr(\ ++ nameSpace ++ '_pan_' ++ c, i / (busArray.size - 1), 0.1) * 2 - 1)}); - sig = sig.collect({arg channel, c; channel * NamedControl.kr(\ ++ nameSpace ++ '_mute_' ++ c, 1, 0.1)}); - sig = Mix.ar(sig) * pow(NamedControl.kr(\ ++ nameSpace ++ '_volume_master', 1, 0.1), 2); - }); - - sigs = Mix.ar(sigs / 4); - Out.ar(0, sigs) -}).add; - -SynthDef(\bass, { - var switches, drone; - switches = {|i| Dust.kr(0.1)} ! 9; - drone = {|i| var harm = pow(2, 2 - (i / 3).trunc), amp = (1 / pow(harm, 2)); - SinOsc.ar(60 * harm + TRand.kr(-3, 3, switches[i]), 0, amp)} ! 9; - Out.ar(~bassBusArray[0], Mix.new(drone) * 0.2); -}).add; - -SynthDef(\sampler, { - Out.ar(~samplerBusArray, PlayBuf.ar(2, ~sBuf, BufRateScale.kr(~sBuf), doneAction: 2)) -}).add; - -// main routine -SynthDef(\hdust, { - arg gate = 0; - var hierarchical_dust, low_sine, high_sine, brown_noise, white_noise; - // this triggers the combinations of sources - // it is similar to the Supercollider UGen called dust but with a hierarchical structure - hierarchical_dust = ( - TIRand.kr(0, 1, Impulse.kr(100)) * - TIRand.kr(0, 1, Impulse.kr(10)) * - TIRand.kr(0, 1, Impulse.kr(1)) * - TIRand.kr(0, 1, Impulse.kr(0.1)) - ); - // adjust the multiplier at the end of each line for adjusting levels - // note with each trigger, each source has a 1 in 3 chance of sounding - low_sine = SinOsc.ar(76.midicps / 16) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.1; - high_sine = SinOsc.ar(76.midicps * 8) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.01; - brown_noise = BrownNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.025; - white_noise = WhiteNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.02; - Out.ar(~hdustBusArray[0], - ((low_sine + high_sine + brown_noise + white_noise) ) - ); -}).add; - -) - -( -var bass, hdust, sampler, mixer; -/* -bass = Synth.tail(~group, \bass); -hdust = Synth.tail(~group, \hdust); -sampler = Synth.head(~group, \sampler); -*/ -mixer = Synth.tail(~group, \mixer); - -OSCdef(\mixer, {arg msg, time, addr, port; - mixer.set((msg[1] ++ '_' ++ msg[2] ++ '_' ++ msg[3]), msg[4]) -}, \mixer); - -/* -OSCdef(\sampler, {arg msg, time, addr, port; - msg.postln; - sampler.free; - ~sBuf.free; - ~sBuf = Buffer.read(s, msg[1].asString.postln, action: {sampler = Synth.head(~group, \sampler)}); -}, \sampler); -*/ -) - -/* old something -( -SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; - var trig, exc, sig1, sig2, noHarms, freqFinal, start, end; - noHarms = 30; - freq = WhiteNoise.ar * 3 + freq; - freqFinal = Duty.ar((1/freq), 0, freq); - trig = Changed.ar(freqFinal); - start = Demand.ar(trig, 0, Dwhite(-1, -0.75)); - end = Demand.ar(trig, 0, Dwhite(0.75, 1)); - exc = Phasor.ar(trig, (end - start) * freqFinal / SampleRate.ir, start, end, 0) * 0.001 + Dust.ar(10000, 0.01); - - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(2, 3)}) ], exc) * 0.5).softclip; - sig1 = HPF.ar(sig1, 300); - Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); -}).add; -) -*/ - diff --git a/resources/7cc3121d/7cc3121d_mus_model.json b/resources/7cc3121d/7cc3121d_mus_model.json deleted file mode 100644 index 53c2570..0000000 --- a/resources/7cc3121d/7cc3121d_mus_model.json +++ /dev/null @@ -1,91 +0,0 @@ -{ -"music_data": -[ - [ - [ - [ [ [ 0, -1, 0, 0, -1, 1 ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 0 ], - [ [ [ 0, -1, 0, 0, -1, 1 ], [ "Rest" ], [ 0, -1, 0, 0, -1, 1 ], [ "Rest" ] ], 0 ], - [ [ [ 0, -1, 0, 0, -1, 1 ], [ "Rest" ], [ 0, -1, 0, 0, -1, 1 ], [ 0, -1, 0, 0, -1, 1 ] ], 8.375 ], - [ [ [ 0, -1, 0, 0, -1, 1 ], [ -1, -1, 0, 0, -1, 2 ], [ 0, -1, 0, 0, -1, 1 ], [ 0, -1, 0, 0, -1, 1 ] ], 1.5 ], - [ [ [ 0, -1, 0, 0, -1, 1 ], [ -1, 0, 0, 0, -1, 1 ], [ 0, -1, 0, 0, -1, 1 ], [ 0, -1, 0, 0, -1, 1 ] ], 0.875 ], - [ [ [ 0, -1, 0, 0, -1, 1 ], [ 0, -2, 0, 0, -1, 1 ], [ 0, -1, 0, 0, -1, 1 ], [ 0, -1, 0, 0, -1, 1 ] ], 0.75 ], - [ [ [ 0, -1, 0, 0, -1, 1 ], [ -1, -1, 1, 0, -1, 1 ], [ 0, -1, 0, 0, -1, 1 ], [ 0, -1, 0, 0, -1, 1 ] ], 0.75 ], - [ [ [ 0, -1, 0, 0, -1, 1 ], [ 0, -1, 0, -1, -1, 1 ], [ 0, -1, 0, 0, -1, 1 ], [ 0, -1, 0, 0, -1, 1 ] ], 10.75 ] - ], - [ - [ [ [ 0, -1, 0, 0, -1, 1 ], [ 0, -1, 0, -1, -1, 1 ], [ 0, -1, 0, 0, -1, 1 ], [ 1, -1, 0, -1, -1, 1 ] ], 0.625 ], - [ [ [ 0, -1, 0, 0, -1, 1 ], [ 0, -1, 0, -1, -1, 1 ], [ -1, -1, 0, 1, -1, 1 ], [ 1, -1, 0, -1, -1, 1 ] ], 0.625 ], - [ [ [ 0, -1, 0, 0, -1, 1 ], [ -1, -1, 0, 0, -1, 1 ], [ -1, -1, 0, 1, -1, 1 ], [ 1, -1, 0, -1, -1, 1 ] ], 0.75 ], - [ [ [ 0, -1, 0, 0, -1, 1 ], [ 0, -1, 0, 0, -1, 0 ], [ -1, -1, 0, 1, -1, 1 ], [ 1, -1, 0, -1, -1, 1 ] ], 0.875 ], - [ [ [ 0, -1, 0, 0, -1, 1 ], [ 0, -1, 0, 0, -1, 0 ], [ -1, -1, 0, 1, -1, 1 ], [ 1, -1, 0, 0, -1, 0 ] ], 1.25 ], - [ [ [ 0, -1, 0, 0, -1, 1 ], [ 0, -1, 0, 0, -1, 0 ], [ 0, -1, -1, 0, -1, 1 ], [ 1, -1, 0, 0, -1, 0 ] ], 1.75 ], - [ [ [ 0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[ 0, -1, 0, 0, -1, 1 ], [ "Rest" ], [ -1, 0, 0, 0, 0, 0 ], [ -1, 0, 0, 0, 1, 1 ] ], 0 ], - [ [ [ "Rest" ], [ "Rest" ], [ -1, 0, 0, 0, 0, 0 ], [ -1, 0, 0, 0, 1, 1 ] ], 1.25 ], - [ [ [ "Rest" ], [ "Rest" ], [ -3, 0, 0, 0, 1, 2 ], [ -1, 0, 0, 0, 1, 1 ] ], 1.875 ], - [ [ [ "Rest" ], [ "Rest" ], [ -3, 1, 0, 0, 1, 1 ], [ -1, 0, 0, 0, 1, 1 ] ], 1.25 ], - [ [ [ "Rest" ], [ "Rest" ], [ -2, 0, -1, 0, 1, 1 ], [ -1, 0, 0, 0, 1, 1 ] ], 2 ], - [ [ [ "Rest" ], [ "Rest" ], [ -3, 0, 0, 1, 1, 1 ], [ -1, 0, 0, 0, 1, 1 ] ], 7.625 ], - [ [ [ "Rest" ], [ "Rest" ], [ -3, 0, 0, 1, 1, 1 ], [ "Rest" ] ], 1 ], - [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 8.375 ] - ] - ] -], -"last_changes": -[ - [ [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], - [ [ 1, -1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], - [ [ 0, 0, -1, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], - [ [ -1, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], - [ [ 0, -1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ] -], -"cur_uid": "7cc3121d", -"ref_uid": "nil", -"order_seed": 209164, -"dur_seed": 417909, -"motifs_seed": 885208, -"entrances_probs_vals": [ 0.34, 0, 10, 0.5, 2, 0, 0.5, 0.24509803921569, 0.89189189189189, 0.5, 1, 0.5, 0.5, 0.8562091503268, 0.69932432432432, 1, 0.5 ], -"passages_probs_vals": [ 0.34, 0, 10, 0.5, 2, 0, 0.5, 0.24509803921569, 0.89189189189189, 0.5, 1, 0.5, 0.5, 0.8562091503268, 0.69932432432432, 1, 0.5 ], -"exits_probs_vals": [ 0.34, 0, 10, 0.5, 2, 0, 0.5, 0.24509803921569, 0.89189189189189, 0.5, 1, 0.5, 0.5, 0.8562091503268, 0.69932432432432, 1, 0.5 ], -"ranges": [ [ -1200, 2400 ], [ -1200, 2400 ], [ -1200, 2400 ], [ -1200, 2400 ] ], -"step_probs_vals": [ 0, 1200, 0, 0.5, 0.5, 0.5, 1, 0.5 ], -"passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], -"hd_exp": 2, -"hd_invert": 0, -"order": -[ - [ [ 2 ], [ 0, 0, 0, 0 ], [ 1, 3 ] ] -], -"sus_weights": [ 0.75, 0.75, 0.75 ], -"order_size": [ 1, 10 ], -"passages_size": [ 0, 10 ], -"motif_edited": "true", -"order_edited": "false" -} \ No newline at end of file diff --git a/resources/7e170ef8/lilypond/part_I.ly b/resources/7e170ef8/lilypond/part_I.ly deleted file mode 100644 index 89a8fe6..0000000 --- a/resources/7e170ef8/lilypond/part_I.ly +++ /dev/null @@ -1,36 +0,0 @@ -{ - { r2. r8[ e'8^\markup { \pad-markup #0.2 "-14"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 5↑" }}] ~ } - \bar "|" - { e'8.[ f'16^\markup { \pad-markup #0.2 "-2"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 3↓" }}] ~ f'4 ~ f'8[ e'8^\markup { \pad-markup #0.2 "-41"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 13↓" }}] ~ e'4 ~ } - \bar "|" - { e'4 ~ e'16[ fis'8.^\markup { \pad-markup #0.2 "-49"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 11↑" }}] ~ fis'16[ g'8.^\markup { \pad-markup #0.2 "+2"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 3↑" }}] ~ g'4 ~ } - \bar "|" - { g'8.[ gis'16^\markup { \pad-markup #0.2 "+14"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 5↓" }}] ~ gis'2. ~ } - \bar "|" \break - { gis'2. ~ gis'8.[ fis'16^\markup { \pad-markup #0.2 "-49"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 11↑" }}] ~ } - \bar "|" - { fis'2. ~ fis'16[ fis'8.^\markup { \pad-markup #0.2 "+49"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 11↓" }}] ~ } - \bar "|" - { fis'2 ~ fis'8.[ gis'16^\markup { \pad-markup #0.2 "+41"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "III"\normal-size-super " 1↑" }}] ~ gis'4 ~ } - \bar "|" - { gis'1 ~ } - \bar "|" \break - { gis'2 gis'4^\markup { \pad-markup #0.2 "+14"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "III"\normal-size-super " 1↑" }} ~ gis'4 ~ } - \bar "|" - { gis'1 ~ } - \bar "|" - { gis'1 ~ } - \bar "|" - { gis'1 ~ } - \bar "|" \break - { gis'1 ~ } - \bar "|" - { gis'2. ~ gis'16[ ais'8.^\markup { \pad-markup #0.2 "-31"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 7↑" }}] ~ } - \bar "|" - { ais'4 ~ ais'8.[ c''16^\markup { \pad-markup #0.2 "+0"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 1↑" }}] ~ c''2 ~ } - \bar "|" - { c''16[ cis''8.^\markup { \pad-markup #0.2 "+39"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "III"\normal-size-super " 13↑" }}] ~ cis''2 ~ cis''16[ d''8.^\markup { \pad-markup #0.2 "+31"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 1↑" }}] ~ } - \bar "|" \break - { d''4 ~ d''8.[ r16] r2 } -\bar "||" -} \ No newline at end of file diff --git a/resources/7e170ef8/lilypond/part_II.ly b/resources/7e170ef8/lilypond/part_II.ly deleted file mode 100644 index 8fb37ef..0000000 --- a/resources/7e170ef8/lilypond/part_II.ly +++ /dev/null @@ -1,36 +0,0 @@ -{ - { c'4^\markup { \pad-markup #0.2 "+0"} ~ c'2. ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" \break - { c'2. ~ c'8.[ d'16^\markup { \pad-markup #0.2 "+31"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 7↓" }}] ~ } - \bar "|" - { d'1 ~ } - \bar "|" - { d'1 ~ } - \bar "|" - { d'1 ~ } - \bar "|" \break - { d'1 ~ } - \bar "|" - { d'8.[ r16] r2. } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" \break - { r1 } - \bar "|" - { r2. r16[ d'8.^\markup { \pad-markup #0.2 "+31"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 7↓" }}] ~ } - \bar "|" - { d'1 ~ } - \bar "|" - { d'1 ~ } - \bar "|" \break - { d'4 ~ d'8.[ r16] r2 } -\bar "||" -} \ No newline at end of file diff --git a/resources/7e170ef8/lilypond/part_III.ly b/resources/7e170ef8/lilypond/part_III.ly deleted file mode 100644 index 950394c..0000000 --- a/resources/7e170ef8/lilypond/part_III.ly +++ /dev/null @@ -1,36 +0,0 @@ -{ - { r2. r8[ ais8^\markup { \pad-markup #0.2 "-31"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 7↑" }}] ~ } - \bar "|" - { ais1 ~ } - \bar "|" - { ais4 ~ ais16[ g8.^\markup { \pad-markup #0.2 "+2"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 3↑" }}] ~ g16[ gis8.^\markup { \pad-markup #0.2 "+41"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 13↑" }}] ~ gis4 ~ } - \bar "|" - { gis8.[ gis16^\markup { \pad-markup #0.2 "+14"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "I"\normal-size-super " 1↑" }}] ~ gis2. ~ } - \bar "|" \break - { gis2. ~ gis8.[ ais16^\markup { \pad-markup #0.2 "-31"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 7↑" }}] ~ } - \bar "|" - { ais1 ~ } - \bar "|" - { ais2 ~ ais8.[ gis16^\markup { \pad-markup #0.2 "+41"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 13↑" }}] ~ gis4 ~ } - \bar "|" - { gis2 ~ gis16[ gis8.^\markup { \pad-markup #0.2 "+14"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 5↓" }}] ~ gis4 ~ } - \bar "|" \break - { gis1 ~ } - \bar "|" - { gis2. ~ gis8[ g8^\markup { \pad-markup #0.2 "+2"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 3↑" }}] ~ } - \bar "|" - { g4 ~ g8[ ais8^\markup { \pad-markup #0.2 "+45"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "I"\normal-size-super " 7↓" }}] ~ ais4 ~ ais8.[ d'16^\markup { \pad-markup #0.2 "-35"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "I"\normal-size-super " 11↑" }}] ~ } - \bar "|" - { d'2. cis'4^\markup { \pad-markup #0.2 "+12"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "I"\normal-size-super " 3↓" }} ~ } - \bar "|" \break - { cis'2 ~ cis'8[ e'8^\markup { \pad-markup #0.2 "-14"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 5↑" }}] ~ e'4 ~ } - \bar "|" - { e'8.[ f'16^\markup { \pad-markup #0.2 "-2"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 3↓" }}] ~ f'2. ~ } - \bar "|" - { f'1 ~ } - \bar "|" - { f'1 ~ } - \bar "|" \break - { f'4 ~ f'8.[ r16] r2 } -\bar "||" -} \ No newline at end of file diff --git a/resources/7e170ef8/lilypond/part_IV.ly b/resources/7e170ef8/lilypond/part_IV.ly deleted file mode 100644 index efb5038..0000000 --- a/resources/7e170ef8/lilypond/part_IV.ly +++ /dev/null @@ -1,36 +0,0 @@ -{ - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" \break - { r8[ c'8^\markup { \pad-markup #0.2 "+0"}] ~ c'2. ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" \break - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" \break - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" - { c'1 ~ } - \bar "|" \break - { c'4 ~ c'8.[ r16] r2 } -\bar "||" -} \ No newline at end of file diff --git a/resources/7e42825a/7e42825a_code.scd b/resources/7e42825a/7e42825a_code.scd deleted file mode 100644 index 55bfebd..0000000 --- a/resources/7e42825a/7e42825a_code.scd +++ /dev/null @@ -1,1033 +0,0 @@ -( -// helper funcs -var hsArrayToCents, pDist, hdSum, hsChordalDistance, hsArrayToFreq; - -// score funcs -var isInRange, spacingScore, rangeScore, intervalScore, inclusionScore; - -// subroutines -var genTuples, initVoices, genOrders, genSubMotif, updateVoices, genDurFunc, genStepFunc; - -// primary routines -var genMotif, genSecondarySeq; - -// audition funcs -var genPatterns, genMidiPatterns; - -// resource management funcs -var seedFunc, genUID, writeResources, stringifyToDepth, setSeeds, sanityCheck, -msgInterpret, loadLedgerFile, loadLedgerJSON, loadModelFile, loadModelJSON, -setGlobalVars, globalVarsToDict, saveLedger; - -// model vars -//(model and global vars mostly set by OSC funcs -var seq, lastXChanges, -curUID, refUID, orderSeed, durSeed, motifSeed, -entrancesProbVals, passagesProbVals, exitsProbVals, -ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, -orders, susWeights, orderSize, passagesSize, -motifEdited, orderEdited; - -// model aux vars -var entrancesDurFunc, passagesDurFunc, exitsDurFunc, stepFunc; - -// other global vars -var popSize, exPath, dir, primes, dims, tuples, -group, player, ledgerPath, ledger, currentlyPlayingUID, -nameSpaces; - -// install JSON quark -if(Quarks.isInstalled("JSONlib").not, { - Quarks.install("https://github.com/musikinformatik/JSONlib.git"); - thisProcess.recompile; - //HelpBrowser.openHelpFor("Classes/JSONlib"); -}); - - -//------helper funcs - -hsArrayToCents = { - arg hsArray; - hsArray.collect({arg dist, p; dist * 1200 * log2(primes[p][0]/primes[p][1])}).sum -}; - -pDist = { - arg array1, array2, signed = false; - var pDistance; - pDistance = hsArrayToCents.value(array1) - hsArrayToCents.value(array2); - if(signed, {pDistance}, {abs(pDistance)}) -}; - -hdSum = { - arg hsArrays; - var size, distances, mean; - size = hsArrays.size; - distances = (size - 1).collect({arg i; - ((i + 1)..(size - 1)).collect({arg j; - abs(hsArrays[i] - hsArrays[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsChordalDistance = { - arg hsArrays1, hsArrays2; - var size, distances, mean; - size = hsArrays1.size; - distances = hsArrays1.size.collect({arg i; - hsArrays2.size.collect({arg j; - abs(hsArrays1[i] - hsArrays2[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsArrayToFreq = { - arg array; - array.collect({arg dim, d; pow(primes[d][0]/primes[d][1], dim)}).product -}; - -//------score funcs - -/* -isInRange = { - arg hsArray, min, max; - var cents; - cents = hsArrayToCents.value(hsArray); - (cents >= min) && (cents <= max) -}; -*/ - -spacingScore = { - arg hsArrays, min; - var centsArray; - centsArray = hsArrays.collect({arg hsArray; hsArrayToCents.value(hsArray)}).sort({arg a, b; a < b}); - centsArray.differentiate.drop(1).collect({arg pDistance; if(pDistance >= min, {1}, {0.01})}).sum; -}; - -rangeScore = { - arg hsArray1, hsArray2, min, max, low, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - if((pDistance >= min) && (pDistance <= max), {1}, {low}); -}; - -intervalScore = { - arg hsArray1, hsArray2, mean, sd, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - //pDistance.gaussCurve(1, mean, sd) - stepFunc.value(pDistance); -}; - -inclusionScore = { - arg array, test, min = 0.01; - if(array.collect({arg v; v.hash}).includes(test.hash), {min}, {1}); -}; - - -//------subroutines - -genTuples = { - var tuples; - tuples = dims.collect({[-1, 0, 1]}).allTuples.select({arg tuple; (abs(tuple.drop(1)).sum <= 1) && (tuple[0] == 0)}); - tuples = tuples ++ tuples.collect({arg tuple; [-3, -2, -1, 1, 2, 3].collect({arg octTrans; tuple.deepCopy.put(0, octTrans)})}).flatten; -}; - -initVoices = { - var init, voicesInit; - voicesInit = popSize.collect({dims.collect({0})}); - /* - voicesInit = [dims.collect({0})]; - (popSize - 1).do({ - arg rep, new; - rep = dims.rand; - new = voicesInit.last.deepCopy; - new[rep] = new[rep] + [-1, 1].choose(); - voicesInit = voicesInit.add(new); - }); - */ - voicesInit.deepCopy; -}; - -genDurFunc = {arg chordProb, minPad, maxPad, minDur, maxDur, envData, seed; - var env, pTable, durFunc; - env = Env.pairs([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).asSignal(256).asList.asArray; - pTable = env.asRandomTable; - [chordProb, minPad, maxPad, minDur, maxDur, envData].postln; - durFunc = {arg allowChord, pad = false; - var res; - res = if(allowChord.not, { - pTable.tableRand * (maxDur - minDur) + minDur - }, { - if(1.0.rand < chordProb, {0}, {pTable.tableRand * (maxDur - minDur) + minDur}); - }).round(0.125); - if(pad, {res = res + rrand(minPad.asFloat, maxPad.asFloat).round(0.125)}); - if(res.asInteger == res, {res = res.asInteger}); - res - }; - seedFunc.value(durFunc, seed); -}; - -genStepFunc = {arg minStep, maxStep, envData, seed; - var envDataNorm, env, pTable, stepFunc; - [minStep, maxStep, envData].postln; - envDataNorm = ([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).flop; - envDataNorm = [envDataNorm[0].normalize(minStep, maxStep), envDataNorm[1]].flop; - env = Env.pairs(envDataNorm); - stepFunc = {arg pDist; - env.at(pDist).clip(0.001, 1); - }; - seedFunc.value(stepFunc, seed); -}; - -genOrders = {arg minMotifLength = 1, maxMotifLength = 5, minProgLength = 0, maxProgLength = 5; - ((maxMotifLength - minMotifLength).rand + minMotifLength).collect({ - var noProgIns, noSusIns, noSilentIns, prog, sus, silent, order; - noSusIns = [1, 2, 3].wchoose(susWeights.normalizeSum); - noProgIns = (popSize - noSusIns).rand + 1; - noSilentIns = popSize - noSusIns - noProgIns; - - # prog, sus, silent = (0..(popSize-1)).scramble.clumps([noProgIns, noSusIns, noSilentIns]); - - prog = (prog.scramble ++ ((maxProgLength - minProgLength).rand + minProgLength).collect({prog.choose}).scramble); - if(silent == nil, {silent = []}); - [sus.scramble, prog, silent.scramble] - }); -}; - -updateVoices = {arg ins, sus; - var voices, candidates, nWeights, nProbs, sel; - - voices = lastXChanges.deepCopy.last; - - candidates = sus.collect({arg v; tuples.collect({arg t; voices[v] + t})}).flatten; - candidates = difference(candidates.asSet, voices.asSet).asList; - nProbs = candidates.collect({arg candidate; - var stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore; - - //stepScore = intervalScore.value(voices[ins], candidate, 30, 400, 0.1); - stepScore = intervalScore.value(voices[ins], candidate, 100, 100); - recentlySoundedScore = inclusionScore.value(lastXChanges.flop[ins], candidate, 0); - isInRangeScore = rangeScore.value(candidate, candidate.collect({0}), ranges[ins][0], ranges[ins][1], 0, true); - regScore = spacingScore.value(voices.deepCopy.put(ins, candidate), 300); - hdScore = pow(hdSum.value(voices.deepCopy.put(ins, candidate)), hdExp); - if(hdInvert == 0, {hdScore = 1/hdScore}); - //maybe what you want here is a vector to another root and then favoring movement towards it. - //distScore = pow(hsChordalDistance.value(voices, voices.put(ins, candidate)), 2); - - [stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore] - }); - - nWeights = passagesWeights; - - //this handles nWeights of 0; mainly for testing - nProbs = nProbs.flop.select({arg scores, s; nWeights[s] != 0}).flop; - nWeights = nWeights.select({arg weight; weight != 0}); - nProbs = nProbs.flop.collect({arg scores, s; - if(scores.sum == 0, {scores}, {scores.normalizeSum * nWeights[s]}) - }); - nProbs = nProbs.flop.collect({arg scores, s; scores.product}).normalizeSum; - - sel = candidates.wchoose(nProbs); - - voices[ins] = sel; - lastXChanges = lastXChanges.add(voices).keep(-5); -}; - -genSubMotif = {arg order, orderIndex, lastState, repeatLast = false, startFromLast = false, isLastOrder = false; - var sus, prog, silent, flatOrder, res, isInChord, allowChord, pad, lastXChangesHold, voices, adder; - # sus, prog, silent = order; - flatOrder = silent ++ sus ++ prog; - lastXChangesHold = lastXChanges.deepCopy; - voices = lastState.deepCopy; - isInChord = popSize.collect({false}); - allowChord = false; - pad = false; - res = []; - "------generating motif".postln; - //need to figure out here if voices move between motifs - flatOrder.do({arg ins, i; - - if(prog.includes(ins) && repeatLast.not, {updateVoices.value(ins, sus)}); - adder = if(silent.includes(ins), {["Rest"]}, {lastXChanges.last.deepCopy[ins]}); - - if(voices[ins] != adder, { - var dur; - - if((sus ++ silent).includes(ins), { - allowChord = (ins != sus.last); - pad = (ins == sus.last); - }, { - if(i < (flatOrder.size - 1), { - allowChord = (isInChord[flatOrder[i + 1]] || (ins == flatOrder[i + 1])).not; - pad = false; - }, { - allowChord = false; - pad = true - }); - }); - if((orderIndex == 0) && sus.includes(ins), { - dur = entrancesDurFunc.value(allowChord, pad); - }, { - dur = passagesDurFunc.value(allowChord, pad); - }); - if(dur == 0, {isInChord[ins] = true}, {isInChord = popSize.collect({false})}); - - voices[ins] = adder; - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - - // pad ending - if(orderIndex == (orders.size - 1), { - (0..(popSize-1)).scramble.do({arg ins; - if(res.last.first[ins] != ["Rest"], { - var dur; - voices[ins] = ["Rest"]; - allowChord = (voices != popSize.collect({["Rest"]})); - pad = allowChord.not; - dur = exitsDurFunc.value(allowChord, pad); - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - }); - - //format and return - if(startFromLast, {lastXChanges = lastXChangesHold.deepCopy}); - res; -}; - - -//------primary routines - -genMotif = { - var repeats, fSeq, fDur, durAdd; - - repeats = 1; - fSeq = []; - - repeats.do({arg index; - var motif; - - motif = []; - - orders.do({arg order, o; - var lastState, subMotif; - lastState = if(o == 0, {popSize.collect({["Rest"]})}, {motif.last.last.first}); - subMotif = genSubMotif.value(order, o, lastState, isLastOrder: o == (orders.size - 1)); - motif = motif.add(subMotif); - - }); - - sanityCheck.value(motif, index); - - fSeq = fSeq.add(motif); - }); - - //round last duration to measure - fDur = fSeq.flatten.flatten.slice(nil, 1).sum; - durAdd = fDur.round(4) - fDur; - if(durAdd < 0, {durAdd = 4 - durAdd}); - fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] = fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] + durAdd; - - fSeq -}; - -genSecondarySeq = {arg seq; - var curdles, fSeq; - curdles = []; - while({curdles.sum < seq.size}, {curdles = curdles ++ [3.rand + 1]}); - - fSeq = seq.clumps(curdles).collect({arg clump, m; - var repeats, paddedSeq; - - //add rest - paddedSeq = clump.add([[[popSize.collect({["Rest"]}), 0.5.rand]]]); - - //implement repeats - repeats = [0.rand + 1, 1].wchoose([1, 0].normalizeSum); - repeats.collect({paddedSeq}); - }); - fSeq -}; - - -//------audition funcs - -/* -Event.addEventType(\osc, { - if (~addr.postln.notNil) { - ~addr.sendMsg(~indexPath, ~indexMsg); - ~addr.sendMsg(~seqPath, stringifyToDepth.value(~seqMsg, 3)); - //~addr.sendMsg("/STATE/OPEN", (dir.replace("supercollider", "resources") +/+ ~idMsg +/+ ~idMsg ++ "_gui_state" ++ ".state").standardizePath.postln); - }; -}); -*/ - -Event.addEventType(\osc, { - if (~addr.notNil) { - ~msg; - ~addr.sendMsg(~path, *~msg); - }; -}); - -genPatterns = {arg inSeq, addr, oneShot = false; - var voices, durs, pbinds, res, indices, sectionDurs, msg, ids, seq; - seq = inSeq.collect({arg mSeq; mSeq[0]}); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - pbinds = voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs, attacks, rels, amps; - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - //attacks = 2.collect({rrand(1, 3)}) ++ freqs.drop(2).collect({rrand(0.3, 0.5)}); - attacks = fDurs.collect({arg dur; dur * rrand(0.2, 0.4)}); - //rels = freqs.drop(2).collect({rrand(0.3, 0.5)}) ++ 2.collect({rrand(1, 3)}); - rels = (clumps.size - 1).collect({arg c; - if(clumps[c + 1][0] == ["Rest"], {rrand(1.0, 3.0)}, {rrand(0.3, 0.5)}); - }); - rels = rels.add(rrand(1.0, 3.0)); - amps = freqs.collect({rrand(0.6, 0.99)}); - - [ - Pbind( - \instrument, \string_model, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \attack, Pseq(attacks, 1), - \sustain, Pseq(fDurs, 1), - \release, Pseq(rels, 1), - //\amp, Pseq(amps, 1), - \amp, Pbrown(0.5, 1, 0.5), - \busIndex, v - ), - Pbind( - \instrument, \sine, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \sustain, Pseq(fDurs, 1), - \busIndex, v - ) - ] - }).flatten; - if(oneShot.not, { - msg = inSeq.collect({arg mSeq, m; mSeq[1..]}); - //ids = inSeq.collect({arg mSeq, m; mSeq[2]}); - sectionDurs = seq.collect({arg mSeq; mSeq.flatten2(mSeq.maxDepth - 5).flop[1].sum}); - pbinds = pbinds ++ - [ - Pbind( - \type, \osc, - \addr, addr, - \path, "/playing", - \msg, Pseq(msg, 1), - \dur, Pseq(sectionDurs, 1) - ); - ] - }); - res = Ppar(pbinds); - res -}; - -/* -genMidiPatterns = {arg seq; - var voices, durs, patterns, res, mOut, pbRange; - pbRange = 1; //semitones - change this as needed for your situation - mOut = MIDIOut.newByName("TiMidity", "TiMidity port 0").latency_(Server.default.latency); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - res = Ppar( - voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs; - - mOut.program(v, 70); - - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - - Pbind( - \type, \midi, - \chan, v, - \noteval, Pseq(freqs.cpsmidi - 24, 1), - \note, Pfunc({ | event | event[\noteval].floor }), - \dur, Pseq(fDurs, 1), - \midiout, mOut, - \amp, 1, - \bend, Pfunc({ - | event | - if (event[\note].isRest.not) { - var pitchbendvalue = event[\noteval].frac.linlin(0, pbRange, 8192, 8192*2).asInteger; - m.bend(v, pitchbendvalue); - }; - 0; // return something other than nil to avoid stopping the pattern - }), - ); - }); - ); - res -}; -*/ - - -//------resource management funcs - -genUID = {Date.seed.asHexString.toLower}; - -seedFunc = {arg func, seed; - var funcArgs, next; - next = Routine({loop{func.valueArray(funcArgs).yield }}); - next.randSeed_(seed); - {arg ...args; funcArgs = args; next.value} -}; - -stringifyToDepth = {arg data, maxDepth = 1; - var prettyString = "", rCount = 0, writeArray, indent; - - if(maxDepth == 0, { - data.asCompileString - }, { - indent = {arg size; size.collect({" "}).join("")}; - writeArray = {arg array; - prettyString = prettyString ++ indent.value(rCount) ++ "[\n"; - rCount = rCount + 1; - if(rCount < maxDepth, { - array.do({arg subArray; writeArray.value(subArray)}); - }, { - prettyString = prettyString ++ array.collect({arg subArray; - indent.value(rCount + 1) ++ subArray.asCompileString - }).join(",\n"); - }); - rCount = rCount - 1; - prettyString = prettyString ++ "\n" ++ indent.value(rCount) ++ "],\n"; - }; - - writeArray.value(data); - prettyString.replace(",\n\n", "\n").drop(-2); - }) -}; - -sanityCheck = {arg motif, index; - //print functions = very helpful - ("----------" + index + "------------").postln; - - motif.flatten.do({arg val, v; - if(v > 0, { - if(motif.flatten[v-1][0].hammingDistance(val[0]) > 1, {"problem 1".postln}); - if(motif.flatten[v-1][0].hammingDistance(val[0]) == 0, {"problem 2".postln}); - }); - val.postln - }); - "***********".postln; -}; - -msgInterpret = {arg in, escapeDoubleQuotes = true, escapeSingleQuotes = true; - var res; - - res = in; - if(res.isNil.not, { - if((res.isArray && res.isString.not), { - res = res.asCompileString; - res = res.replace(" ", "").replace("\n", "").replace("\t", ""); - if(escapeSingleQuotes, {res = res.replace("\'", "")}); - if(escapeDoubleQuotes, {res = res.replace("\"", "")}); - res = res.replace("Rest", "\"Rest\""); - res = res.interpret; - }, { - var tmpRes; - if(res.every({arg char; char.isDecDigit}), {tmpRes = res.asInteger}); - if(res.contains("."), {tmpRes = res.asFloat}); - if(tmpRes != nil, {res = tmpRes}); - }); - }); - res -}; - -writeResources = {arg path, dict; - var file, modelItems, resString; - file = File(path,"w"); - - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - - resString = nameSpaces.collect({arg nameSpace; - var depth = 0, insert = " "; - if(nameSpace == "music_data", {depth = 3; insert = "\n"}); - if(nameSpace == "last_changes", {depth = 1; insert = "\n"}); - if(nameSpace == "order", {depth = 1; insert = "\n"}); - if((nameSpace == "ref_uid") && (dict[nameSpace] == nil), {dict[nameSpace] = "nil"}); - "\"" ++ nameSpace ++ "\":" ++ insert ++ stringifyToDepth.value(dict[nameSpace], depth) - }).join(",\n"); - - resString = "{\n" ++ resString ++ "\n}"; - - file.write(resString); - file.close; - resString -}; - -loadModelFile = {arg path; loadModelJSON.value(File(path, "r").readAllString.parseJSON)}; - -loadModelJSON = {arg jsonObject; - var dict; - dict = Dictionary.with(*nameSpaces.collect({arg nS; nS->msgInterpret.value(jsonObject[nS])})); - dict -}; - -setGlobalVars = {arg dict, skipLastXChanges = false; - var tmpLastXChanges; - tmpLastXChanges = lastXChanges.deepCopy; - // order really matters!!!! - # seq, lastXChanges, curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited = nameSpaces.collect({arg nS; dict[nS]}); - if(skipLastXChanges, {lastXChanges = tmpLastXChanges}); - dict -}; - -globalVarsToDict = { - var modelItems, dict; - // order really matters!!!! - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - dict = Dictionary.with(*nameSpaces.collect({arg nS, n; nS->modelItems[n]})); -}; - -loadLedgerFile = {arg path; - ledgerPath = path; - loadLedgerJSON.value(File(ledgerPath, "r").readAllString.parseJSON) -}; - -loadLedgerJSON = {arg jsonObject; ledger = jsonObject["ledger"]}; - -saveLedger = {arg ledger, path; - var file; - file = File(path, "w"); - file.write("{\n\"ledger\":\n" ++ stringifyToDepth.value(ledger, 1) ++ "\n}"); - file.close; -}; - -//------global vars - -primes = [[2, 1], [3, 2], [5, 4], [7, 4], [11, 8], [13, 8]]; -//ranges = [[-2400, 0], [-1200, 1200], [0, 2400], [0, 2400]]; -exPath = thisProcess.nowExecutingPath; -dir = exPath.dirname; -//popSize = 4; -dims = primes.size; -tuples = genTuples.value(); -//refUID = nil; -group = Group.new; -~group = group; -loadLedgerFile.value(dir +/+ ".." +/+ "resources" +/+ "piece_ledger.json"); -//passagesWeights = [1, 1, 1, 1, 1]; -//susWeights = [1, 1, 1]; -// order really matters!!!! -nameSpaces = [ - "music_data", "last_changes", "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", - "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", - "ranges", "step_probs_vals", "passages_weights", "hd_exp", "hd_invert", - "order", "sus_weights", "order_size", "passages_size", - "motif_edited", "order_edited" -]; - - -//------OSC funcs - -OSCdef(\load_ledger, {arg msg, time, addr, port; - loadLedgerFile.value(msg[1].asString); -}, \load_ledger); - -OSCdef(\load_model, {arg msg, time, addr, port; - var dict; - dict = loadModelFile.value(msg[1].asString); - setGlobalVars.value(dict); -}, \load_model); - -OSCdef(\save_ledger, {arg msg, time, addr, port; - msg.postln; - ledger = msgInterpret.value(msg[1].asString.parseJSON["ledger"], false).postln; - //loadLedgerJSON.value(msg[0]) - saveLedger.value(ledger, msg[2].asString); - //loadLedgerFile.value(msg[1].asString); -}, \save_ledger); - -OSCdef(\generate, {arg msg, time, addr, port; - var path, dict, durSeeds, musPath, modelString; - msg.postln; - - path = msg[1].asString; - - dict = loadModelFile.value(path); - setGlobalVars.value(dict, true); - - popSize = ranges.size; - - //refUID.postln; - - loadLedgerFile.value(ledgerPath); - if(ledger == nil, {ledger = ["tmp"]}); - if(ledger.last != "tmp", {ledger = ledger.add("tmp")}); - - if(refUID == nil, {lastXChanges = [initVoices.value().deepCopy]}); - if((refUID != nil) && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - lastXChanges = msgInterpret.value(file.readAllString.parseJSON["last_changes"]); - }); - - refUID.postln; - lastXChanges.collect({arg item; item.postln}); - - durSeeds = seedFunc.value({3.collect({rrand(100000, 999999)})}, durSeed).value.postln; - entrancesDurFunc = genDurFunc.valueArray(entrancesProbVals[..4] ++ [entrancesProbVals[5..]] ++ [durSeeds[0]]); - passagesDurFunc = genDurFunc.valueArray(passagesProbVals[..4] ++ [passagesProbVals[5..]] ++ [durSeeds[1]]); - exitsDurFunc = genDurFunc.valueArray(exitsProbVals[..4] ++ [exitsProbVals[5..]] ++ [durSeeds[2]]); - - if(orders == nil, { - orders = seedFunc.value(genOrders, orderSeed).valueArray(orderSize ++ passagesSize); - //addr.sendMsg("/order", stringifyToDepth.value(orders, 1)); - }); - - stepFunc = genStepFunc.valueArray(stepProbsVals[..1] ++ [stepProbsVals[2..]] ++ [motifSeed]); - seq = seedFunc.value(genMotif, motifSeed).value; - - lastXChanges.collect({arg item; item.postln}); - - dict = globalVarsToDict.value; - modelString = writeResources.value(path, dict); - - //addr.sendMsg("/generated", musPath, stringifyToDepth.value(seq, 3)); - //~seq = seq; - - addr.sendMsg("/generated", path, modelString, ledgerPath); -}, \generate); - - -OSCdef(\commit, {arg msg, time, addr, port; - var musicData, musicChanged, dict, newLedger, modelPath, musString, musFile, test1, test2; - //msg.postln; - - /* - test1 = msg[1].asString.parseJSON; - test2 = (dir +/+ ".." +/+ "resources/tmp/tmp_music" ++ ".json").standardizePath.parseJSONFile; - msgInterpret.value(test1["music"])[0][0][0][1].class.postln; - msgInterpret.value(test2["music_data"])[0][0][0][1].class.postln; - (test1["music"] == test2["music_data"]).postln; - */ - - musicData = loadModelJSON.value(msg[1].asString.parseJSON)["music_data"].postln; - musicChanged = (musicData != seq).postln; - - curUID = genUID.value; - - File.mkdir((dir +/+ ".." +/+ "resources" +/+ curUID).standardizePath); - File.copy(exPath, (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_code" ++ ".scd").standardizePath); - - modelPath = (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_mus_model" ++ ".json").standardizePath; - dict = globalVarsToDict.value; - if(musicChanged, { - seq = musicData; - dict["music_data"] = seq; - dict["motif_edited"] = "true" - }); - dict["cur_uid"] = curUID; - - writeResources.value(modelPath, dict); - - File.delete(ledgerPath ++ "_bak"); - File.copy(ledgerPath, ledgerPath ++ "_bak"); - File.delete(ledgerPath); - ledger = ledger.drop(-1).add(curUID); - - saveLedger.value(ledger, ledgerPath); - - addr.sendMsg("/committed", curUID, ledgerPath); - //refUID = curUID; - -}, \commit); - -OSCdef(\transport, {arg msg, time, addr, port; - msg.postln; - if(msg[1] == 0, { - group.set(\release, 2); - group.set(\gate, 0); - player.stop; - }, { - // the cued sequence can now be read from file, so this can be cleaned up - var cSize, patterns, pSeq, cuedSeek, indexStart, indexEnd, tmpLedger; - if(msg[1] == 1, { - pSeq = []; - cuedSeek = (seq != nil); - indexStart = msg[2].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.postln.parseJSON["music_data"]), path, indexStart + index, uid]); - file.close; - }); - }); - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - patterns = genPatterns.value(pSeq, addr); - }, { - pSeq = [loadModelJSON.value(msg[2].asString.parseJSON)["music_data"].postln]; - patterns = genPatterns.value(pSeq, addr, true); - }); - player = Pfset(pattern: patterns, cleanupFunc: { - addr.sendMsg("/transport", 0); - addr.sendMsg("/one_shot", 0); - }); - player = player.play - }); -}, \transport); - - -OSCdef(\transcribe_motif, {arg msg, time, addr, port; - var tSeq, refChord, refUID; - - msg.postln; - - tSeq = [loadModelJSON.value(msg[1].asString.parseJSON)["music_data"]]; - refUID = msg[2].asString.postln; - - if((refUID != "nil") && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }, { - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - }); - - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "lilypond" +/+ "includes").standardizePath, addr, "/transcribe_motif"); -}, \transcribe_motif); - - -OSCdef(\transcribe_all, {arg msg, time, addr, port; - var cSize, patterns, cuedSeek, indexStart, indexEnd, tmpLedger; - if(true, { - cuedSeek = (seq != nil); - indexStart = msg[1].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - - //tmp for testing transcription - indexEnd = (indexStart+5); - - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - var lilyPartLedgerFiles; - - lilyPartLedgerFiles = 4.collect({arg p; - File((dir +/+ ".." +/+ "lilypond" +/+ "includes" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly").standardizePath, "w"); - }); - - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file, fileString, tSeq, refUID, refChord; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - fileString = file.readAllString; - tSeq = msgInterpret.value(fileString.parseJSON["music_data"]); - refUID = msgInterpret.value(fileString.parseJSON["ref_uid"]); - file.close; - - //uid.postln; - //(refUID == "nil").postln; - - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - - if(refUID != "nil", { - path = (dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }); - - if(index != indexEnd, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath); - }, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath, addr, "/transcribe_all"); - }); - - lilyPartLedgerFiles.do({arg f, p; - f.write("\\include \".." +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly\"\n"); - }); - - }); - - lilyPartLedgerFiles.do({arg f; - f.close - }); - }); - /* - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - */ - }, { - - }); - -}, \transcribe_all); - -) - -~transcribe.value(~seq, dir); - -( -//synthdefs -~stringModelBusArray = 4.collect({Bus.audio(s, 1)}); -~sineBusArray = 4.collect({Bus.audio(s, 1)}); -~bassBusArray = 1.collect({Bus.audio(s, 1)}); -~hdustBusArray = 1.collect({Bus.audio(s, 1)}); -~samplerBusArray = 2.collect({Bus.audio(s, 1)}); -~sBuf = Buffer.alloc(s, 10, 2); -SynthDef(\string_model, {arg freq, gate = 1, sustain, amp, dur, attack, release = 1, busIndex = 0; - var trig, exc, sig1, sig2, noHarms; - noHarms = rrand(20, 40); - exc = Saw.ar(freq, TRand.ar(0.5, 1, Impulse.ar(freq))) * 0.001 + Dust.ar(10000, 0.01); - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.8).softclip; - //sig1 = HPF.ar(sig1, 300); - Out.ar(Select.kr(busIndex, ~stringModelBusArray), sig1 * amp * EnvGen.kr(Env.adsr(attack, 0.3, 0.9, release, 0.9, -3), gate, doneAction: 2)); - //Out.ar([0, 1], sig1 * EnvGen.kr(Env.asr(dur, 0.3, 1), gate, doneAction: 2)); -}).add; - -SynthDef(\sine, {arg freq, gate = 1, sustain, amp, dur, busIndex = 0; - var sig; - sig = SinOsc.ar(freq); - Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.asr(0.3, 0.4, 0.3), gate, timeScale: dur, doneAction: 2)); - //Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.sine(dur), gate, doneAction: 2)); -}).add; - -SynthDef(\mixer, {arg freq, gate = 1, sustain, amp, dur, out; - var nameSpaces, sigs; - - sigs = [~stringModelBusArray, ~sineBusArray/*, ~bassBusArray, ~hdustBusArray, ~samplerBusArray*/].collect({arg busArray, i; - var nameSpace, sig; - nameSpace = ['string', 'sine', 'bass', 'hdust', 'sampler'][i]; - sig = busArray.collect({arg bus, c; In.ar(bus, 1) * NamedControl.kr(\ ++ nameSpace ++ '_volume_' ++ c, 1, 0.1)}); - sig = sig.collect({arg channel, c; Pan2.ar(channel, NamedControl.kr(\ ++ nameSpace ++ '_pan_' ++ c, i / (busArray.size - 1), 0.1) * 2 - 1)}); - sig = sig.collect({arg channel, c; channel * NamedControl.kr(\ ++ nameSpace ++ '_mute_' ++ c, 1, 0.1)}); - sig = Mix.ar(sig) * pow(NamedControl.kr(\ ++ nameSpace ++ '_volume_master', 1, 0.1), 2); - }); - - sigs = Mix.ar(sigs / 4); - Out.ar(0, sigs) -}).add; - -SynthDef(\bass, { - var switches, drone; - switches = {|i| Dust.kr(0.1)} ! 9; - drone = {|i| var harm = pow(2, 2 - (i / 3).trunc), amp = (1 / pow(harm, 2)); - SinOsc.ar(60 * harm + TRand.kr(-3, 3, switches[i]), 0, amp)} ! 9; - Out.ar(~bassBusArray[0], Mix.new(drone) * 0.2); -}).add; - -SynthDef(\sampler, { - Out.ar(~samplerBusArray, PlayBuf.ar(2, ~sBuf, BufRateScale.kr(~sBuf), doneAction: 2)) -}).add; - -// main routine -SynthDef(\hdust, { - arg gate = 0; - var hierarchical_dust, low_sine, high_sine, brown_noise, white_noise; - // this triggers the combinations of sources - // it is similar to the Supercollider UGen called dust but with a hierarchical structure - hierarchical_dust = ( - TIRand.kr(0, 1, Impulse.kr(100)) * - TIRand.kr(0, 1, Impulse.kr(10)) * - TIRand.kr(0, 1, Impulse.kr(1)) * - TIRand.kr(0, 1, Impulse.kr(0.1)) - ); - // adjust the multiplier at the end of each line for adjusting levels - // note with each trigger, each source has a 1 in 3 chance of sounding - low_sine = SinOsc.ar(76.midicps / 16) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.1; - high_sine = SinOsc.ar(76.midicps * 8) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.01; - brown_noise = BrownNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.025; - white_noise = WhiteNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.02; - Out.ar(~hdustBusArray[0], - ((low_sine + high_sine + brown_noise + white_noise) ) - ); -}).add; - -) - -( -var bass, hdust, sampler, mixer; -/* -bass = Synth.tail(~group, \bass); -hdust = Synth.tail(~group, \hdust); -sampler = Synth.head(~group, \sampler); -*/ -mixer = Synth.tail(~group, \mixer); - -OSCdef(\mixer, {arg msg, time, addr, port; - mixer.set((msg[1] ++ '_' ++ msg[2] ++ '_' ++ msg[3]), msg[4]) -}, \mixer); - -/* -OSCdef(\sampler, {arg msg, time, addr, port; - msg.postln; - sampler.free; - ~sBuf.free; - ~sBuf = Buffer.read(s, msg[1].asString.postln, action: {sampler = Synth.head(~group, \sampler)}); -}, \sampler); -*/ -) - -/* old something -( -SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; - var trig, exc, sig1, sig2, noHarms, freqFinal, start, end; - noHarms = 30; - freq = WhiteNoise.ar * 3 + freq; - freqFinal = Duty.ar((1/freq), 0, freq); - trig = Changed.ar(freqFinal); - start = Demand.ar(trig, 0, Dwhite(-1, -0.75)); - end = Demand.ar(trig, 0, Dwhite(0.75, 1)); - exc = Phasor.ar(trig, (end - start) * freqFinal / SampleRate.ir, start, end, 0) * 0.001 + Dust.ar(10000, 0.01); - - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(2, 3)}) ], exc) * 0.5).softclip; - sig1 = HPF.ar(sig1, 300); - Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); -}).add; -) -*/ - diff --git a/resources/7e42825a/7e42825a_mus_model.json b/resources/7e42825a/7e42825a_mus_model.json deleted file mode 100644 index e69de29..0000000 diff --git a/resources/7ebbb471/7ebbb471_code.scd b/resources/7ebbb471/7ebbb471_code.scd deleted file mode 100644 index 3eb3cbd..0000000 --- a/resources/7ebbb471/7ebbb471_code.scd +++ /dev/null @@ -1,1058 +0,0 @@ -( -// helper funcs -var hsArrayToCents, pDist, hdSum, hsChordalDistance, hsArrayToFreq; - -// score funcs -var isInRange, spacingScore, rangeScore, intervalScore, inclusionScore; - -// subroutines -var genTuples, initVoices, genOrders, genSubMotif, updateVoices, genDurFunc, genStepFunc; - -// primary routines -var genMotif, genSecondarySeq; - -// audition funcs -var genPatterns, genMidiPatterns; - -// resource management funcs -var seedFunc, genUID, writeResources, stringifyToDepth, setSeeds, sanityCheck, -msgInterpret, loadLedgerFile, loadLedgerJSON, loadModelFile, loadModelJSON, -setGlobalVars, globalVarsToDict, saveLedger; - -// model vars -//(model and global vars mostly set by OSC funcs -var seq, lastXChanges, -curUID, refUID, orderSeed, durSeed, motifSeed, -entrancesProbVals, passagesProbVals, exitsProbVals, -ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, -orders, susWeights, orderSize, passagesSize, -motifEdited, orderEdited; - -// model aux vars -var entrancesDurFunc, passagesDurFunc, exitsDurFunc, stepFunc; - -// other global vars -var popSize, exPath, dir, primes, dims, tuples, -group, player, ledgerPath, ledger, currentlyPlayingUID, -nameSpaces; - -// install JSON quark -if(Quarks.isInstalled("JSONlib").not, { - Quarks.install("https://github.com/musikinformatik/JSONlib.git"); - thisProcess.recompile; - //HelpBrowser.openHelpFor("Classes/JSONlib"); -}); - - -//------helper funcs - -hsArrayToCents = { - arg hsArray; - hsArray.collect({arg dist, p; dist * 1200 * log2(primes[p][0]/primes[p][1])}).sum -}; - -pDist = { - arg array1, array2, signed = false; - var pDistance; - pDistance = hsArrayToCents.value(array1) - hsArrayToCents.value(array2); - if(signed, {pDistance}, {abs(pDistance)}) -}; - -hdSum = { - arg hsArrays; - var size, distances, mean; - size = hsArrays.size; - distances = (size - 1).collect({arg i; - ((i + 1)..(size - 1)).collect({arg j; - abs(hsArrays[i] - hsArrays[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsChordalDistance = { - arg hsArrays1, hsArrays2; - var size, distances, mean; - size = hsArrays1.size; - distances = hsArrays1.size.collect({arg i; - hsArrays2.size.collect({arg j; - abs(hsArrays1[i] - hsArrays2[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum - }); - }).flat; - mean = distances.sum / distances.size; - distances.sum - //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) -}; - -hsArrayToFreq = { - arg array; - array.collect({arg dim, d; pow(primes[d][0]/primes[d][1], dim)}).product -}; - -//------score funcs - -/* -isInRange = { - arg hsArray, min, max; - var cents; - cents = hsArrayToCents.value(hsArray); - (cents >= min) && (cents <= max) -}; -*/ - -spacingScore = { - arg hsArrays, min; - var centsArray; - centsArray = hsArrays.collect({arg hsArray; hsArrayToCents.value(hsArray)}).sort({arg a, b; a < b}); - centsArray.differentiate.drop(1).collect({arg pDistance; if(pDistance >= min, {1}, {0.01})}).sum; -}; - -rangeScore = { - arg hsArray1, hsArray2, min, max, low, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - if((pDistance >= min) && (pDistance <= max), {1}, {low}); -}; - -intervalScore = { - arg hsArray1, hsArray2, mean, sd, signed = false; - var pDistance; - pDistance = pDist.value(hsArray1, hsArray2, signed); - //pDistance.gaussCurve(1, mean, sd) - stepFunc.value(pDistance); -}; - -inclusionScore = { - arg array, test, min = 0.01; - if(array.collect({arg v; v.hash}).includes(test.hash), {min}, {1}); -}; - - -//------subroutines - -genTuples = { - var tuples; - tuples = dims.collect({[-1, 0, 1]}).allTuples.select({arg tuple; (abs(tuple.drop(1)).sum <= 1) && (tuple[0] == 0)}); - tuples = tuples ++ tuples.collect({arg tuple; [-3, -2, -1, 1, 2, 3].collect({arg octTrans; tuple.deepCopy.put(0, octTrans)})}).flatten; -}; - -initVoices = { - var init, voicesInit; - voicesInit = popSize.collect({dims.collect({0})}); - /* - voicesInit = [dims.collect({0})]; - (popSize - 1).do({ - arg rep, new; - rep = dims.rand; - new = voicesInit.last.deepCopy; - new[rep] = new[rep] + [-1, 1].choose(); - voicesInit = voicesInit.add(new); - }); - */ - voicesInit.deepCopy; -}; - -genDurFunc = {arg chordProb, minPad, maxPad, minDur, maxDur, envData, seed; - var env, pTable, durFunc; - env = Env.pairs([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).asSignal(256).asList.asArray; - pTable = env.asRandomTable; - [chordProb, minPad, maxPad, minDur, maxDur, envData].postln; - durFunc = {arg allowChord, pad = false; - var res; - res = if(allowChord.not, { - pTable.tableRand * (maxDur - minDur) + minDur - }, { - if(1.0.rand < chordProb, {0}, {pTable.tableRand * (maxDur - minDur) + minDur}); - }).round(0.125); - if(pad, {res = res + rrand(minPad.asFloat, maxPad.asFloat).round(0.125)}); - if(res.asInteger == res, {res = res.asInteger}); - res - }; - seedFunc.value(durFunc, seed); -}; - -genStepFunc = {arg minStep, maxStep, envData, seed; - var envDataNorm, env, pTable, stepFunc; - [minStep, maxStep, envData].postln; - envDataNorm = ([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).flop; - envDataNorm = [envDataNorm[0].normalize(minStep, maxStep), envDataNorm[1]].flop; - env = Env.pairs(envDataNorm); - stepFunc = {arg pDist; - env.at(pDist).clip(0.001, 1); - }; - seedFunc.value(stepFunc, seed); -}; - -genOrders = {arg minMotifLength = 1, maxMotifLength = 5, minProgLength = 0, maxProgLength = 5; - ((maxMotifLength - minMotifLength).rand + minMotifLength).collect({ - var noProgIns, noSusIns, noSilentIns, prog, sus, silent, order; - noSusIns = [1, 2, 3].wchoose(susWeights.normalizeSum); - noProgIns = (popSize - noSusIns).rand + 1; - noSilentIns = popSize - noSusIns - noProgIns; - - # prog, sus, silent = (0..(popSize-1)).scramble.clumps([noProgIns, noSusIns, noSilentIns]); - - prog = (prog.scramble ++ ((maxProgLength - minProgLength).rand + minProgLength).collect({prog.choose}).scramble); - if(silent == nil, {silent = []}); - [sus.scramble, prog, silent.scramble] - }); -}; - -updateVoices = {arg ins, sus; - var voices, candidates, nWeights, nProbs, sel; - - voices = lastXChanges.deepCopy.last; - - candidates = sus.collect({arg v; tuples.collect({arg t; voices[v] + t})}).flatten; - candidates = difference(candidates.asSet, voices.asSet).asList; - nProbs = candidates.collect({arg candidate; - var stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore; - - //stepScore = intervalScore.value(voices[ins], candidate, 30, 400, 0.1); - stepScore = intervalScore.value(voices[ins], candidate, 100, 100); - recentlySoundedScore = inclusionScore.value(lastXChanges.flop[ins], candidate, 0); - isInRangeScore = rangeScore.value(candidate, candidate.collect({0}), ranges[ins][0], ranges[ins][1], 0, true); - regScore = spacingScore.value(voices.deepCopy.put(ins, candidate), 300); - hdScore = pow(hdSum.value(voices.deepCopy.put(ins, candidate)), hdExp); - if(hdInvert == 0, {hdScore = 1/hdScore}); - //maybe what you want here is a vector to another root and then favoring movement towards it. - //distScore = pow(hsChordalDistance.value(voices, voices.put(ins, candidate)), 2); - - [stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore] - }); - - nWeights = passagesWeights; - - //this handles nWeights of 0; mainly for testing - nProbs = nProbs.flop.select({arg scores, s; nWeights[s] != 0}).flop; - nWeights = nWeights.select({arg weight; weight != 0}); - nProbs = nProbs.flop.collect({arg scores, s; - if(scores.sum == 0, {scores}, {scores.normalizeSum * nWeights[s]}) - }); - nProbs = nProbs.flop.collect({arg scores, s; scores.product}).normalizeSum; - - sel = candidates.wchoose(nProbs); - - voices[ins] = sel; - lastXChanges = lastXChanges.add(voices).keep(-5); -}; - -genSubMotif = {arg order, orderIndex, lastState, repeatLast = false, startFromLast = false, isLastOrder = false; - var sus, prog, silent, flatOrder, res, isInChord, allowChord, pad, lastXChangesHold, voices, adder; - # sus, prog, silent = order; - flatOrder = silent ++ sus ++ prog; - lastXChangesHold = lastXChanges.deepCopy; - voices = lastState.deepCopy; - isInChord = popSize.collect({false}); - allowChord = false; - pad = false; - res = []; - "------generating motif".postln; - //need to figure out here if voices move between motifs - flatOrder.do({arg ins, i; - - if(prog.includes(ins) && repeatLast.not, {updateVoices.value(ins, sus)}); - adder = if(silent.includes(ins), {["Rest"]}, {lastXChanges.last.deepCopy[ins]}); - - if(voices[ins] != adder, { - var dur; - - if((sus ++ silent).includes(ins), { - allowChord = (ins != sus.last); - pad = (ins == sus.last); - }, { - if(i < (flatOrder.size - 1), { - allowChord = (isInChord[flatOrder[i + 1]] || (ins == flatOrder[i + 1])).not; - pad = false; - }, { - allowChord = false; - pad = true - }); - }); - if((orderIndex == 0) && sus.includes(ins), { - dur = entrancesDurFunc.value(allowChord, pad); - }, { - dur = passagesDurFunc.value(allowChord, pad); - }); - if(dur == 0, {isInChord[ins] = true}, {isInChord = popSize.collect({false})}); - - voices[ins] = adder; - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - - // pad ending - if(orderIndex == (orders.size - 1), { - (0..(popSize-1)).scramble.do({arg ins; - if(res.last.first[ins] != ["Rest"], { - var dur; - voices[ins] = ["Rest"]; - allowChord = (voices != popSize.collect({["Rest"]})); - pad = allowChord.not; - dur = exitsDurFunc.value(allowChord, pad); - res = res.add([voices.deepCopy.postln, dur]); - }); - }); - }); - - //format and return - if(startFromLast, {lastXChanges = lastXChangesHold.deepCopy}); - res; -}; - - -//------primary routines - -genMotif = { - var repeats, fSeq, fDur, durAdd; - - repeats = 1; - fSeq = []; - - repeats.do({arg index; - var motif; - - motif = []; - - orders.do({arg order, o; - var lastState, subMotif; - lastState = if(o == 0, {popSize.collect({["Rest"]})}, {motif.last.last.first}); - subMotif = genSubMotif.value(order, o, lastState, isLastOrder: o == (orders.size - 1)); - motif = motif.add(subMotif); - - }); - - sanityCheck.value(motif, index); - - fSeq = fSeq.add(motif); - }); - - //round last duration to measure - fDur = fSeq.flatten.flatten.slice(nil, 1).sum; - durAdd = fDur.round(4) - fDur; - if(durAdd < 0, {durAdd = 4 - durAdd}); - fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] = fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] + durAdd; - - fSeq -}; - -genSecondarySeq = {arg seq; - var curdles, fSeq; - curdles = []; - while({curdles.sum < seq.size}, {curdles = curdles ++ [3.rand + 1]}); - - fSeq = seq.clumps(curdles).collect({arg clump, m; - var repeats, paddedSeq; - - //add rest - paddedSeq = clump.add([[[popSize.collect({["Rest"]}), 0.5.rand]]]); - - //implement repeats - repeats = [0.rand + 1, 1].wchoose([1, 0].normalizeSum); - repeats.collect({paddedSeq}); - }); - fSeq -}; - - -//------audition funcs - -/* -Event.addEventType(\osc, { - if (~addr.postln.notNil) { - ~addr.sendMsg(~indexPath, ~indexMsg); - ~addr.sendMsg(~seqPath, stringifyToDepth.value(~seqMsg, 3)); - //~addr.sendMsg("/STATE/OPEN", (dir.replace("supercollider", "resources") +/+ ~idMsg +/+ ~idMsg ++ "_gui_state" ++ ".state").standardizePath.postln); - }; -}); -*/ - -Event.addEventType(\osc, { - if (~addr.notNil) { - ~msg; - ~addr.sendMsg(~path, *~msg); - }; -}); - -genPatterns = {arg inSeq, addr, oneShot = false; - var voices, durs, pbinds, res, indices, sectionDurs, msg, ids, seq; - seq = inSeq.collect({arg mSeq; mSeq[0]}); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - pbinds = voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs, attacks, rels, amps; - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - //attacks = 2.collect({rrand(1, 3)}) ++ freqs.drop(2).collect({rrand(0.3, 0.5)}); - attacks = fDurs.collect({arg dur; dur * rrand(0.2, 0.4)}); - //rels = freqs.drop(2).collect({rrand(0.3, 0.5)}) ++ 2.collect({rrand(1, 3)}); - rels = (clumps.size - 1).collect({arg c; - if(clumps[c + 1][0] == ["Rest"], {rrand(1.0, 3.0)}, {rrand(0.3, 0.5)}); - }); - rels = rels.add(rrand(1.0, 3.0)); - amps = freqs.collect({rrand(0.6, 0.99)}); - - [ - Pbind( - \instrument, \string_model, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \attack, Pseq(attacks, 1), - \sustain, Pseq(fDurs, 1), - \release, Pseq(rels, 1), - //\amp, Pseq(amps, 1), - \amp, Pbrown(0.5, 1, 0.5), - \busIndex, v - ), - Pbind( - \instrument, \sine, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \sustain, Pseq(fDurs, 1), - \busIndex, v - ) - ] - }).flatten; - if(oneShot.not, { - msg = inSeq.collect({arg mSeq, m; mSeq[1..]}); - //ids = inSeq.collect({arg mSeq, m; mSeq[2]}); - sectionDurs = seq.collect({arg mSeq; mSeq.flatten2(mSeq.maxDepth - 5).flop[1].sum}); - pbinds = pbinds ++ - [ - Pbind( - \type, \osc, - \addr, addr, - \path, "/playing", - \msg, Pseq(msg, 1), - \dur, Pseq(sectionDurs, 1) - ); - ] - }); - res = Ppar(pbinds); - res -}; - -/* -genMidiPatterns = {arg seq; - var voices, durs, patterns, res, mOut, pbRange; - pbRange = 1; //semitones - change this as needed for your situation - mOut = MIDIOut.newByName("TiMidity", "TiMidity port 0").latency_(Server.default.latency); - # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - res = Ppar( - voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs; - - mOut.program(v, 70); - - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - - Pbind( - \type, \midi, - \chan, v, - \noteval, Pseq(freqs.cpsmidi - 24, 1), - \note, Pfunc({ | event | event[\noteval].floor }), - \dur, Pseq(fDurs, 1), - \midiout, mOut, - \amp, 1, - \bend, Pfunc({ - | event | - if (event[\note].isRest.not) { - var pitchbendvalue = event[\noteval].frac.linlin(0, pbRange, 8192, 8192*2).asInteger; - m.bend(v, pitchbendvalue); - }; - 0; // return something other than nil to avoid stopping the pattern - }), - ); - }); - ); - res -}; -*/ - - -//------resource management funcs - -genUID = {Date.seed.asHexString.toLower}; - -seedFunc = {arg func, seed; - var funcArgs, next; - next = Routine({loop{func.valueArray(funcArgs).yield }}); - next.randSeed_(seed); - {arg ...args; funcArgs = args; next.value} -}; - -stringifyToDepth = {arg data, maxDepth = 1; - var prettyString = "", rCount = 0, writeArray, indent; - - if(maxDepth == 0, { - data.asCompileString - }, { - indent = {arg size; size.collect({" "}).join("")}; - writeArray = {arg array; - prettyString = prettyString ++ indent.value(rCount) ++ "[\n"; - rCount = rCount + 1; - if(rCount < maxDepth, { - array.do({arg subArray; writeArray.value(subArray)}); - }, { - prettyString = prettyString ++ array.collect({arg subArray; - indent.value(rCount + 1) ++ subArray.asCompileString - }).join(",\n"); - }); - rCount = rCount - 1; - prettyString = prettyString ++ "\n" ++ indent.value(rCount) ++ "],\n"; - }; - - writeArray.value(data); - prettyString.replace(",\n\n", "\n").drop(-2); - }) -}; - -sanityCheck = {arg motif, index; - //print functions = very helpful - ("----------" + index + "------------").postln; - - motif.flatten.do({arg val, v; - if(v > 0, { - if(motif.flatten[v-1][0].hammingDistance(val[0]) > 1, {"problem 1".postln}); - if(motif.flatten[v-1][0].hammingDistance(val[0]) == 0, {"problem 2".postln}); - }); - val.postln - }); - "***********".postln; -}; - -msgInterpret = {arg in, escapeDoubleQuotes = true, escapeSingleQuotes = true; - var res; - - res = in; - if(res.isNil.not, { - if((res.isArray && res.isString.not), { - res = res.asCompileString; - res = res.replace(" ", "").replace("\n", "").replace("\t", ""); - if(escapeSingleQuotes, {res = res.replace("\'", "")}); - if(escapeDoubleQuotes, {res = res.replace("\"", "")}); - res = res.replace("Rest", "\"Rest\""); - res = res.interpret; - }, { - var tmpRes; - if(res.every({arg char; char.isDecDigit}), {tmpRes = res.asInteger}); - if(res.contains("."), {tmpRes = res.asFloat}); - if(tmpRes != nil, {res = tmpRes}); - }); - }); - res -}; - -writeResources = {arg path, dict; - var file, modelItems, resString; - file = File(path,"w"); - - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - - resString = nameSpaces.collect({arg nameSpace; - var depth = 0, insert = " "; - if(nameSpace == "music_data", {depth = 3; insert = "\n"}); - if(nameSpace == "last_changes", {depth = 1; insert = "\n"}); - if(nameSpace == "order", {depth = 1; insert = "\n"}); - if((nameSpace == "ref_uid") && (dict[nameSpace] == nil), {dict[nameSpace] = "nil"}); - "\"" ++ nameSpace ++ "\":" ++ insert ++ stringifyToDepth.value(dict[nameSpace], depth) - }).join(",\n"); - - resString = "{\n" ++ resString ++ "\n}"; - - file.write(resString); - file.close; - resString -}; - -loadModelFile = {arg path; loadModelJSON.value(File(path, "r").readAllString.parseJSON)}; - -loadModelJSON = {arg jsonObject; - var dict; - dict = Dictionary.with(*nameSpaces.collect({arg nS; nS->msgInterpret.value(jsonObject[nS])})); - dict -}; - -setGlobalVars = {arg dict, skipLastXChanges = false; - var tmpLastXChanges; - tmpLastXChanges = lastXChanges.deepCopy; - // order really matters!!!! - # seq, lastXChanges, curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited = nameSpaces.collect({arg nS; dict[nS]}); - if(skipLastXChanges, {lastXChanges = tmpLastXChanges}); - dict -}; - -globalVarsToDict = { - var modelItems, dict; - // order really matters!!!! - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited - ]; - dict = Dictionary.with(*nameSpaces.collect({arg nS, n; nS->modelItems[n]})); -}; - -loadLedgerFile = {arg path; - ledgerPath = path; - loadLedgerJSON.value(File(ledgerPath, "r").readAllString.parseJSON) -}; - -loadLedgerJSON = {arg jsonObject; ledger = jsonObject["ledger"]}; - -saveLedger = {arg ledger, path; - var file; - file = File(path, "w"); - file.write("{\n\"ledger\":\n" ++ stringifyToDepth.value(ledger, 1) ++ "\n}"); - file.close; -}; - -//------global vars - -primes = [[2, 1], [3, 2], [5, 4], [7, 4], [11, 8], [13, 8]]; -//ranges = [[-2400, 0], [-1200, 1200], [0, 2400], [0, 2400]]; -exPath = thisProcess.nowExecutingPath; -dir = exPath.dirname; -//popSize = 4; -dims = primes.size; -tuples = genTuples.value(); -//refUID = nil; -group = Group.new; -~group = group; -loadLedgerFile.value(dir +/+ ".." +/+ "resources" +/+ "piece_ledger.json"); -//passagesWeights = [1, 1, 1, 1, 1]; -//susWeights = [1, 1, 1]; -// order really matters!!!! -nameSpaces = [ - "music_data", "last_changes", "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", - "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", - "ranges", "step_probs_vals", "passages_weights", "hd_exp", "hd_invert", - "order", "sus_weights", "order_size", "passages_size", - "motif_edited", "order_edited" -]; - - -//------OSC funcs - -OSCdef(\load_ledger, {arg msg, time, addr, port; - loadLedgerFile.value(msg[1].asString); -}, \load_ledger); - -OSCdef(\load_model, {arg msg, time, addr, port; - var dict; - dict = loadModelFile.value(msg[1].asString); - setGlobalVars.value(dict); -}, \load_model); - -OSCdef(\save_ledger, {arg msg, time, addr, port; - msg.postln; - ledger = msgInterpret.value(msg[1].asString.parseJSON["ledger"], false).postln; - //loadLedgerJSON.value(msg[0]) - saveLedger.value(ledger, msg[2].asString); - //loadLedgerFile.value(msg[1].asString); -}, \save_ledger); - -OSCdef(\generate, {arg msg, time, addr, port; - var path, dict, durSeeds, musPath, modelString; - msg.postln; - - path = msg[1].asString; - - dict = loadModelFile.value(path); - setGlobalVars.value(dict, true); - - popSize = ranges.size; - - //refUID.postln; - - loadLedgerFile.value(ledgerPath); - if(ledger == nil, {ledger = ["tmp"]}); - if(ledger.last != "tmp", {ledger = ledger.add("tmp")}); - - if(refUID == nil, {lastXChanges = [initVoices.value().deepCopy]}); - if((refUID != nil) && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - lastXChanges = msgInterpret.value(file.readAllString.parseJSON["last_changes"]); - }); - - refUID.postln; - lastXChanges.collect({arg item; item.postln}); - - durSeeds = seedFunc.value({3.collect({rrand(100000, 999999)})}, durSeed).value.postln; - entrancesDurFunc = genDurFunc.valueArray(entrancesProbVals[..4] ++ [entrancesProbVals[5..]] ++ [durSeeds[0]]); - passagesDurFunc = genDurFunc.valueArray(passagesProbVals[..4] ++ [passagesProbVals[5..]] ++ [durSeeds[1]]); - exitsDurFunc = genDurFunc.valueArray(exitsProbVals[..4] ++ [exitsProbVals[5..]] ++ [durSeeds[2]]); - - if(orders == nil, { - orders = seedFunc.value(genOrders, orderSeed).valueArray(orderSize ++ passagesSize); - //addr.sendMsg("/order", stringifyToDepth.value(orders, 1)); - }); - - stepFunc = genStepFunc.valueArray(stepProbsVals[..1] ++ [stepProbsVals[2..]] ++ [motifSeed]); - seq = seedFunc.value(genMotif, motifSeed).value; - - lastXChanges.collect({arg item; item.postln}); - - dict = globalVarsToDict.value; - modelString = writeResources.value(path, dict); - - //addr.sendMsg("/generated", musPath, stringifyToDepth.value(seq, 3)); - //~seq = seq; - - addr.sendMsg("/generated", path, modelString, ledgerPath); -}, \generate); - - -OSCdef(\commit, {arg msg, time, addr, port; - var musicData, musicChanged, dict, newLedger, modelPath, musString, musFile, test1, test2, lastCurUID, commitType, commitPos, equalityLedger; - //msg.postln; - - /* - test1 = msg[1].asString.parseJSON; - test2 = (dir +/+ ".." +/+ "resources/tmp/tmp_music" ++ ".json").standardizePath.parseJSONFile; - msgInterpret.value(test1["music"])[0][0][0][1].class.postln; - msgInterpret.value(test2["music_data"])[0][0][0][1].class.postln; - (test1["music"] == test2["music_data"]).postln; - */ - - musicData = loadModelJSON.value(msg[1].asString.parseJSON)["music_data"].postln; - musicChanged = (musicData != seq).postln; - commitType = msg[2].asString; - commitPos = msg[3].postln.asInteger; - - lastCurUID = curUID.deepCopy; - curUID = genUID.value; - - File.mkdir((dir +/+ ".." +/+ "resources" +/+ curUID).standardizePath); - File.copy(exPath, (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_code" ++ ".scd").standardizePath); - - modelPath = (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_mus_model" ++ ".json").standardizePath; - dict = globalVarsToDict.value; - if(musicChanged, { - seq = musicData; - dict["music_data"] = seq; - dict["motif_edited"] = "true" - }); - dict["cur_uid"] = curUID; - - writeResources.value(modelPath, dict); - - File.delete(ledgerPath ++ "_bak"); - File.copy(ledgerPath, ledgerPath ++ "_bak"); - File.delete(ledgerPath); - - /* - if(commitType == "add", { - if(lastCurUID == "tmp", { - ledger = ledger.drop(-1).add(curUID); - }, { - ledger = ledger.add(curUID); - }) - }); - */ - - ledger.postln; - - if(commitType == "add", {ledger = ledger.add(curUID)}); - - if(commitType == "insert", {ledger = ledger.insert(commitPos + 1, curUID)}); - - if(commitType == "replace", {ledger = ledger.put(commitPos, curUID)}); - - equalityLedger = ledger.collect({arg item; item.asSymbol}); - if(equalityLedger.includes(\tmp).postln, {ledger.removeAt(equalityLedger.indexOf(\tmp).postln)}); - - ledger.postln; - - saveLedger.value(ledger, ledgerPath); - - addr.sendMsg("/committed", curUID, ledgerPath); - //refUID = curUID; - -}, \commit); - -OSCdef(\transport, {arg msg, time, addr, port; - msg.postln; - if(msg[1] == 0, { - group.set(\release, 2); - group.set(\gate, 0); - player.stop; - }, { - // the cued sequence can now be read from file, so this can be cleaned up - var cSize, patterns, pSeq, cuedSeek, indexStart, indexEnd, tmpLedger; - if(msg[1] == 1, { - pSeq = []; - cuedSeek = (seq != nil); - indexStart = msg[2].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.postln.parseJSON["music_data"]), path, indexStart + index, uid]); - file.close; - }); - }); - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - patterns = genPatterns.value(pSeq, addr); - }, { - pSeq = [loadModelJSON.value(msg[2].asString.parseJSON)["music_data"].postln]; - patterns = genPatterns.value(pSeq, addr, true); - }); - player = Pfset(pattern: patterns, cleanupFunc: { - addr.sendMsg("/transport", 0); - addr.sendMsg("/one_shot", 0); - }); - player = player.play - }); -}, \transport); - - -OSCdef(\transcribe_motif, {arg msg, time, addr, port; - var tSeq, refChord, refUID; - - msg.postln; - - tSeq = [loadModelJSON.value(msg[1].asString.parseJSON)["music_data"]]; - refUID = msg[2].asString.postln; - - if((refUID != "nil") && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }, { - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - }); - - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "lilypond" +/+ "includes").standardizePath, addr, "/transcribe_motif"); -}, \transcribe_motif); - - -OSCdef(\transcribe_all, {arg msg, time, addr, port; - var cSize, patterns, cuedSeek, indexStart, indexEnd, tmpLedger; - if(true, { - cuedSeek = (seq != nil); - indexStart = msg[1].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - - //tmp for testing transcription - indexEnd = (indexStart+5); - - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - var lilyPartLedgerFiles; - - lilyPartLedgerFiles = 4.collect({arg p; - File((dir +/+ ".." +/+ "lilypond" +/+ "includes" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly").standardizePath, "w"); - }); - - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file, fileString, tSeq, refUID, refChord; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - fileString = file.readAllString; - tSeq = msgInterpret.value(fileString.parseJSON["music_data"]); - refUID = msgInterpret.value(fileString.parseJSON["ref_uid"]); - file.close; - - //uid.postln; - //(refUID == "nil").postln; - - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - - if(refUID != "nil", { - path = (dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }); - - if(index != indexEnd, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath); - }, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath, addr, "/transcribe_all"); - }); - - lilyPartLedgerFiles.do({arg f, p; - f.write("\\include \".." +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly\"\n"); - }); - - }); - - lilyPartLedgerFiles.do({arg f; - f.close - }); - }); - /* - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - */ - }, { - - }); - -}, \transcribe_all); - -) - -~transcribe.value(~seq, dir); - -( -//synthdefs -~stringModelBusArray = 4.collect({Bus.audio(s, 1)}); -~sineBusArray = 4.collect({Bus.audio(s, 1)}); -~bassBusArray = 1.collect({Bus.audio(s, 1)}); -~hdustBusArray = 1.collect({Bus.audio(s, 1)}); -~samplerBusArray = 2.collect({Bus.audio(s, 1)}); -~sBuf = Buffer.alloc(s, 10, 2); -SynthDef(\string_model, {arg freq, gate = 1, sustain, amp, dur, attack, release = 1, busIndex = 0; - var trig, exc, sig1, sig2, noHarms; - noHarms = rrand(20, 40); - exc = Saw.ar(freq, TRand.ar(0.5, 1, Impulse.ar(freq))) * 0.001 + Dust.ar(10000, 0.01); - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.8).softclip; - //sig1 = HPF.ar(sig1, 300); - Out.ar(Select.kr(busIndex, ~stringModelBusArray), sig1 * amp * EnvGen.kr(Env.adsr(attack, 0.3, 0.9, release, 0.9, -3), gate, doneAction: 2)); - //Out.ar([0, 1], sig1 * EnvGen.kr(Env.asr(dur, 0.3, 1), gate, doneAction: 2)); -}).add; - -SynthDef(\sine, {arg freq, gate = 1, sustain, amp, dur, busIndex = 0; - var sig; - sig = SinOsc.ar(freq); - Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.asr(0.3, 0.4, 0.3), gate, timeScale: dur, doneAction: 2)); - //Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.sine(dur), gate, doneAction: 2)); -}).add; - -SynthDef(\mixer, {arg freq, gate = 1, sustain, amp, dur, out; - var nameSpaces, sigs; - - sigs = [~stringModelBusArray, ~sineBusArray/*, ~bassBusArray, ~hdustBusArray, ~samplerBusArray*/].collect({arg busArray, i; - var nameSpace, sig; - nameSpace = ['string', 'sine', 'bass', 'hdust', 'sampler'][i]; - sig = busArray.collect({arg bus, c; In.ar(bus, 1) * NamedControl.kr(\ ++ nameSpace ++ '_volume_' ++ c, 1, 0.1)}); - sig = sig.collect({arg channel, c; Pan2.ar(channel, NamedControl.kr(\ ++ nameSpace ++ '_pan_' ++ c, i / (busArray.size - 1), 0.1) * 2 - 1)}); - sig = sig.collect({arg channel, c; channel * NamedControl.kr(\ ++ nameSpace ++ '_mute_' ++ c, 1, 0.1)}); - sig = Mix.ar(sig) * pow(NamedControl.kr(\ ++ nameSpace ++ '_volume_master', 1, 0.1), 2); - }); - - sigs = Mix.ar(sigs / 4); - Out.ar(0, sigs) -}).add; - -SynthDef(\bass, { - var switches, drone; - switches = {|i| Dust.kr(0.1)} ! 9; - drone = {|i| var harm = pow(2, 2 - (i / 3).trunc), amp = (1 / pow(harm, 2)); - SinOsc.ar(60 * harm + TRand.kr(-3, 3, switches[i]), 0, amp)} ! 9; - Out.ar(~bassBusArray[0], Mix.new(drone) * 0.2); -}).add; - -SynthDef(\sampler, { - Out.ar(~samplerBusArray, PlayBuf.ar(2, ~sBuf, BufRateScale.kr(~sBuf), doneAction: 2)) -}).add; - -// main routine -SynthDef(\hdust, { - arg gate = 0; - var hierarchical_dust, low_sine, high_sine, brown_noise, white_noise; - // this triggers the combinations of sources - // it is similar to the Supercollider UGen called dust but with a hierarchical structure - hierarchical_dust = ( - TIRand.kr(0, 1, Impulse.kr(100)) * - TIRand.kr(0, 1, Impulse.kr(10)) * - TIRand.kr(0, 1, Impulse.kr(1)) * - TIRand.kr(0, 1, Impulse.kr(0.1)) - ); - // adjust the multiplier at the end of each line for adjusting levels - // note with each trigger, each source has a 1 in 3 chance of sounding - low_sine = SinOsc.ar(76.midicps / 16) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.1; - high_sine = SinOsc.ar(76.midicps * 8) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.01; - brown_noise = BrownNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.025; - white_noise = WhiteNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.02; - Out.ar(~hdustBusArray[0], - ((low_sine + high_sine + brown_noise + white_noise) ) - ); -}).add; - -) - -( -var bass, hdust, sampler, mixer; -/* -bass = Synth.tail(~group, \bass); -hdust = Synth.tail(~group, \hdust); -sampler = Synth.head(~group, \sampler); -*/ -mixer = Synth.tail(~group, \mixer); - -OSCdef(\mixer, {arg msg, time, addr, port; - mixer.set((msg[1] ++ '_' ++ msg[2] ++ '_' ++ msg[3]), msg[4]) -}, \mixer); - -/* -OSCdef(\sampler, {arg msg, time, addr, port; - msg.postln; - sampler.free; - ~sBuf.free; - ~sBuf = Buffer.read(s, msg[1].asString.postln, action: {sampler = Synth.head(~group, \sampler)}); -}, \sampler); -*/ -) - -/* old something -( -SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; - var trig, exc, sig1, sig2, noHarms, freqFinal, start, end; - noHarms = 30; - freq = WhiteNoise.ar * 3 + freq; - freqFinal = Duty.ar((1/freq), 0, freq); - trig = Changed.ar(freqFinal); - start = Demand.ar(trig, 0, Dwhite(-1, -0.75)); - end = Demand.ar(trig, 0, Dwhite(0.75, 1)); - exc = Phasor.ar(trig, (end - start) * freqFinal / SampleRate.ir, start, end, 0) * 0.001 + Dust.ar(10000, 0.01); - - sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), - Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(2, 3)}) ], exc) * 0.5).softclip; - sig1 = HPF.ar(sig1, 300); - Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); -}).add; -) -*/ - diff --git a/resources/7ebbb471/7ebbb471_mus_model.json b/resources/7ebbb471/7ebbb471_mus_model.json deleted file mode 100644 index 0c12431..0000000 --- a/resources/7ebbb471/7ebbb471_mus_model.json +++ /dev/null @@ -1,60 +0,0 @@ -{ -"music_data": -[ - [ - [ - [ [ [ 1, -1, 0, -1, 1, 0 ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 0.625 ], - [ [ [ 1, -1, 0, -1, 1, 0 ], [ "Rest" ], [ "Rest" ], [ 1, 0, 0, -1, 1, 0 ] ], 0 ], - [ [ [ 1, -1, 0, -1, 1, 0 ], [ "Rest" ], [ 2, -1, 0, -1, 1, -1 ], [ 1, 0, 0, -1, 1, 0 ] ], 1.75 ], - [ [ [ 1, -1, 0, -1, 1, 0 ], [ "Rest" ], [ 2, -1, 0, -1, 1, -1 ], [ 2, -1, 0, -1, 0, 0 ] ], 1.875 ], - [ [ [ 1, -1, 0, -1, 1, 0 ], [ "Rest" ], [ 2, -1, 0, -1, 1, -1 ], [ 1, -1, 0, -1, 2, 0 ] ], 1.5 ], - [ [ [ 1, -1, 0, -1, 1, 0 ], [ "Rest" ], [ 2, -1, 0, -1, 1, -1 ], [ 1, -1, 1, -1, 1, 0 ] ], 0.75 ], - [ [ [ 1, -1, 0, -1, 1, 0 ], [ "Rest" ], [ 2, -1, 0, -1, 1, -1 ], [ 2, -1, 0, -2, 1, 0 ] ], 1.25 ], - [ [ [ 1, -1, 0, -1, 1, 0 ], [ "Rest" ], [ 2, -1, 0, -1, 1, -1 ], [ 0, -1, 0, 0, 1, 0 ] ], 1.625 ], - [ [ [ 1, -1, 0, -1, 1, 0 ], [ "Rest" ], [ 2, -1, 0, -1, 1, -1 ], [ 1, 0, 0, -1, 1, 0 ] ], 1.875 ] - ], - [ - [ [ [ 1, -1, 0, -1, 1, 0 ], [ 2, -2, 0, -1, 1, 0 ], [ 2, -1, 0, -1, 1, -1 ], [ 1, 0, 0, -1, 1, 0 ] ], 1 ], - [ [ [ 1, -1, 0, -1, 1, 0 ], [ 2, -2, 0, -1, 1, 0 ], [ 1, -1, 0, -1, 2, 0 ], [ 1, 0, 0, -1, 1, 0 ] ], 1.125 ], - [ [ [ 1, -1, 0, -1, 1, 0 ], [ 2, -2, 0, -1, 1, 0 ], [ 1, 0, -1, -1, 1, 0 ], [ 1, 0, 0, -1, 1, 0 ] ], 0.75 ], - [ [ [ 1, -1, 0, -1, 1, 0 ], [ 2, -2, 0, -1, 1, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 1, 0, 0, -1, 1, 0 ] ], 1.5 ], - [ [ [ 1, -1, 0, -1, 1, 0 ], [ 2, -2, 0, -1, 1, 0 ], [ 1, -2, 0, -1, 1, 1 ], [ 1, 0, 0, -1, 1, 0 ] ], 1.5 ], - [ [ [ 1, -1, 0, -1, 1, 0 ], [ 2, -2, 0, -1, 1, 0 ], [ 1, 0, 0, -1, 1, -1 ], [ 1, 0, 0, -1, 1, 0 ] ], 1.75 ], - [ [ [ 1, -1, 0, -1, 1, 0 ], [ 2, -2, 0, -1, 1, 0 ], [ "Rest" ], [ 1, 0, 0, -1, 1, 0 ] ], 1.125 ], - [ [ [ 1, -1, 0, -1, 1, 0 ], [ 2, -2, 0, -1, 1, 0 ], [ "Rest" ], [ "Rest" ] ], 0.5 ], - [ [ [ 1, -1, 0, -1, 1, 0 ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 0 ], - [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 1.25 ] - ] - ] -], -"last_changes": -[ - [ [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], - [ [ 1, -1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], - [ [ 0, 0, -1, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], - [ [ -1, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], - [ [ 0, -1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ] -], -"cur_uid": "7ebbb471", -"ref_uid": "nil", -"order_seed": 209164, -"dur_seed": 417909, -"motifs_seed": 885208, -"entrances_probs_vals": [ 0.34, 0, 10, 0.5, 2, 0, 0.5, 0.24509803921569, 0.89189189189189, 0.5, 1, 0.5, 0.5, 0.8562091503268, 0.69932432432432, 1, 0.5 ], -"passages_probs_vals": [ 0.34, 0, 10, 0.5, 2, 0, 0.5, 0.24509803921569, 0.89189189189189, 0.5, 1, 0.5, 0.5, 0.8562091503268, 0.69932432432432, 1, 0.5 ], -"exits_probs_vals": [ 0.34, 0, 10, 0.5, 2, 0, 0.5, 0.24509803921569, 0.89189189189189, 0.5, 1, 0.5, 0.5, 0.8562091503268, 0.69932432432432, 1, 0.5 ], -"ranges": [ [ -1200, 2400 ], [ -1200, 2400 ], [ -1200, 2400 ], [ -1200, 2400 ] ], -"step_probs_vals": [ 0, 1200, 0, 0.5, 0.5, 0.5, 1, 0.5 ], -"passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], -"hd_exp": 2, -"hd_invert": 0, -"order": -[ - [ [ 2 ], [ 0, 0, 0, 0 ], [ 1, 3 ] ] -], -"sus_weights": [ 0.75, 0.75, 0.75 ], -"order_size": [ 1, 10 ], -"passages_size": [ 0, 10 ], -"motif_edited": "true", -"order_edited": "false" -} \ No newline at end of file diff --git a/resources/7ebbb471/lilypond/part_I.ly b/resources/7ebbb471/lilypond/part_I.ly deleted file mode 100644 index 2bcfd04..0000000 --- a/resources/7ebbb471/lilypond/part_I.ly +++ /dev/null @@ -1,24 +0,0 @@ -{ - { r4 r16[ gis'8.^\markup { \pad-markup #0.2 "-18"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 3↑" }}] ~ gis'2 ~ } - \bar "|" - { gis'8.[ g'16^\markup { \pad-markup #0.2 "+29"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 11↓" }}] ~ g'2. ~ } - \bar "|" - { g'8[ fis'8^\markup { \pad-markup #0.2 "+32"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 11↑" }}] ~ fis'2 ~ fis'8[ f'8^\markup { \pad-markup #0.2 "-33"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 5↑" }}] ~ } - \bar "|" - { f'4 dis'4^\markup { \pad-markup #0.2 "+12"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 7↓" }} ~ dis'4 ~ dis'8[ ais8^\markup { \pad-markup #0.2 "+49"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 7↑" }}] ~ } - \bar "|" \break - { ais2 ~ ais8.[ gis'16^\markup { \pad-markup #0.2 "-18"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 3↑" }}] ~ gis'4 ~ } - \bar "|" - { gis'1 ~ } - \bar "|" - { gis'1 ~ } - \bar "|" - { gis'1 ~ } - \bar "|" \break - { gis'1 ~ } - \bar "|" - { gis'1 } - \bar "|" - { r1 } -\bar "||" -} \ No newline at end of file diff --git a/resources/7ebbb471/lilypond/part_II.ly b/resources/7ebbb471/lilypond/part_II.ly deleted file mode 100644 index edf9d76..0000000 --- a/resources/7ebbb471/lilypond/part_II.ly +++ /dev/null @@ -1,24 +0,0 @@ -{ - { r4 r16[ e'8.^\markup { \pad-markup #0.2 "+40"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 13↓" }}] ~ e'2 ~ } - \bar "|" - { e'1 ~ } - \bar "|" - { e'1 ~ } - \bar "|" - { e'1 ~ } - \bar "|" \break - { e'1 ~ } - \bar "|" - { e'1 ~ } - \bar "|" - { e'8[ fis'8^\markup { \pad-markup #0.2 "+32"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 11↑" }}] ~ fis'4 ~ fis'8.[ e'16^\markup { \pad-markup #0.2 "-4"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "I"\normal-size-super " 5↓" }}] ~ e'4 ~ } - \bar "|" - { e'16[ d'8.^\markup { \pad-markup #0.2 "+31"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "I"\normal-size-super " 11↓" }}] ~ d'2 ~ d'16[ d'8.^\markup { \pad-markup #0.2 "+19"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "III"\normal-size-super " 13↑" }}] ~ } - \bar "|" \break - { d'2 ~ d'16[ b8.^\markup { \pad-markup #0.2 "+42"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "I"\normal-size-super " 13↓" }}] ~ b4 ~ } - \bar "|" - { b4 ~ b8.[ r16] r2 } - \bar "|" - { r1 } -\bar "||" -} \ No newline at end of file diff --git a/resources/7ebbb471/lilypond/part_III.ly b/resources/7ebbb471/lilypond/part_III.ly deleted file mode 100644 index 6b17e60..0000000 --- a/resources/7ebbb471/lilypond/part_III.ly +++ /dev/null @@ -1,24 +0,0 @@ -{ - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" - { r1 } - \bar "|" \break - { r1 } - \bar "|" - { r2 r8[ fis'8^\markup { \pad-markup #0.2 "-21"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 3↓" }}] ~ fis'4 ~ } - \bar "|" - { fis'1 ~ } - \bar "|" - { fis'1 ~ } - \bar "|" \break - { fis'1 ~ } - \bar "|" - { fis'1 ~ } - \bar "|" - { fis'4 r2. } -\bar "||" -} \ No newline at end of file diff --git a/resources/7ebbb471/lilypond/part_IV.ly b/resources/7ebbb471/lilypond/part_IV.ly deleted file mode 100644 index cb68938..0000000 --- a/resources/7ebbb471/lilypond/part_IV.ly +++ /dev/null @@ -1,24 +0,0 @@ -{ - { cis'4^\markup { \pad-markup #0.2 "-19"} ~ cis'2. ~ } - \bar "|" - { cis'1 ~ } - \bar "|" - { cis'1 ~ } - \bar "|" - { cis'1 ~ } - \bar "|" \break - { cis'1 ~ } - \bar "|" - { cis'1 ~ } - \bar "|" - { cis'1 ~ } - \bar "|" - { cis'1 ~ } - \bar "|" \break - { cis'1 ~ } - \bar "|" - { cis'1 ~ } - \bar "|" - { cis'4 r2. } -\bar "||" -} \ No newline at end of file diff --git a/resources/piece_ledger.json_bak_bak b/resources/piece_ledger.json_bak_bak deleted file mode 100644 index aa529be..0000000 --- a/resources/piece_ledger.json_bak_bak +++ /dev/null @@ -1,17 +0,0 @@ -{ -ledger: -[ - 314491, - 314491, - 314491, - 314491, - 127947, - 389839, - 333441, - 175649, - 936089, - 936089, - 947477, - 947477 -] -} \ No newline at end of file diff --git a/resources/314s49e1/314s49e1_code.scd b/resources/piece_ledger/314s49e1/314s49e1_code.scd similarity index 100% rename from resources/314s49e1/314s49e1_code.scd rename to resources/piece_ledger/314s49e1/314s49e1_code.scd diff --git a/resources/314s49e1/314s49e1_mus_model.json b/resources/piece_ledger/314s49e1/314s49e1_mus_model.json similarity index 100% rename from resources/314s49e1/314s49e1_mus_model.json rename to resources/piece_ledger/314s49e1/314s49e1_mus_model.json diff --git a/resources/46a0e6a8/46a0e6a8_code.scd b/resources/piece_ledger/46a0e6a8/46a0e6a8_code.scd similarity index 100% rename from resources/46a0e6a8/46a0e6a8_code.scd rename to resources/piece_ledger/46a0e6a8/46a0e6a8_code.scd diff --git a/resources/46a0e6a8/46a0e6a8_mus_model.json b/resources/piece_ledger/46a0e6a8/46a0e6a8_mus_model.json similarity index 100% rename from resources/46a0e6a8/46a0e6a8_mus_model.json rename to resources/piece_ledger/46a0e6a8/46a0e6a8_mus_model.json diff --git a/resources/4c01589b/4c01589b_code.scd b/resources/piece_ledger/4c01589b/4c01589b_code.scd similarity index 100% rename from resources/4c01589b/4c01589b_code.scd rename to resources/piece_ledger/4c01589b/4c01589b_code.scd diff --git a/resources/4c01589b/4c01589b_gui_state.json b/resources/piece_ledger/4c01589b/4c01589b_gui_state.json similarity index 100% rename from resources/4c01589b/4c01589b_gui_state.json rename to resources/piece_ledger/4c01589b/4c01589b_gui_state.json diff --git a/resources/4c01589b/4c01589b_mus_model.json b/resources/piece_ledger/4c01589b/4c01589b_mus_model.json similarity index 100% rename from resources/4c01589b/4c01589b_mus_model.json rename to resources/piece_ledger/4c01589b/4c01589b_mus_model.json diff --git a/resources/4cf4476d/4cf4476d_code.scd b/resources/piece_ledger/4cf4476d/4cf4476d_code.scd similarity index 100% rename from resources/4cf4476d/4cf4476d_code.scd rename to resources/piece_ledger/4cf4476d/4cf4476d_code.scd diff --git a/resources/4cf4476d/4cf4476d_mus_model.json b/resources/piece_ledger/4cf4476d/4cf4476d_mus_model.json similarity index 100% rename from resources/4cf4476d/4cf4476d_mus_model.json rename to resources/piece_ledger/4cf4476d/4cf4476d_mus_model.json diff --git a/resources/55930f4d/55930f4d_code.scd b/resources/piece_ledger/55930f4d/55930f4d_code.scd similarity index 100% rename from resources/55930f4d/55930f4d_code.scd rename to resources/piece_ledger/55930f4d/55930f4d_code.scd diff --git a/resources/55930f4d/55930f4d_mus_model.json b/resources/piece_ledger/55930f4d/55930f4d_mus_model.json similarity index 100% rename from resources/55930f4d/55930f4d_mus_model.json rename to resources/piece_ledger/55930f4d/55930f4d_mus_model.json diff --git a/resources/5cf1e9ab/5cf1e9ab_code.scd b/resources/piece_ledger/5cf1e9ab/5cf1e9ab_code.scd similarity index 100% rename from resources/5cf1e9ab/5cf1e9ab_code.scd rename to resources/piece_ledger/5cf1e9ab/5cf1e9ab_code.scd diff --git a/resources/5cf1e9ab/5cf1e9ab_mus_model.json b/resources/piece_ledger/5cf1e9ab/5cf1e9ab_mus_model.json similarity index 100% rename from resources/5cf1e9ab/5cf1e9ab_mus_model.json rename to resources/piece_ledger/5cf1e9ab/5cf1e9ab_mus_model.json diff --git a/resources/5e947063/5e947063_code.scd b/resources/piece_ledger/5e947063/5e947063_code.scd similarity index 100% rename from resources/5e947063/5e947063_code.scd rename to resources/piece_ledger/5e947063/5e947063_code.scd diff --git a/resources/5e947063/5e947063_mus_model.json b/resources/piece_ledger/5e947063/5e947063_mus_model.json similarity index 100% rename from resources/5e947063/5e947063_mus_model.json rename to resources/piece_ledger/5e947063/5e947063_mus_model.json diff --git a/resources/628d5c8b/628d5c8b_code.scd b/resources/piece_ledger/628d5c8b/628d5c8b_code.scd similarity index 100% rename from resources/628d5c8b/628d5c8b_code.scd rename to resources/piece_ledger/628d5c8b/628d5c8b_code.scd diff --git a/resources/628d5c8b/628d5c8b_mus_model.json b/resources/piece_ledger/628d5c8b/628d5c8b_mus_model.json similarity index 100% rename from resources/628d5c8b/628d5c8b_mus_model.json rename to resources/piece_ledger/628d5c8b/628d5c8b_mus_model.json diff --git a/resources/62b894e8/62b894e8_code.scd b/resources/piece_ledger/62b894e8/62b894e8_code.scd similarity index 100% rename from resources/62b894e8/62b894e8_code.scd rename to resources/piece_ledger/62b894e8/62b894e8_code.scd diff --git a/resources/62b894e8/62b894e8_mus_model.json b/resources/piece_ledger/62b894e8/62b894e8_mus_model.json similarity index 100% rename from resources/62b894e8/62b894e8_mus_model.json rename to resources/piece_ledger/62b894e8/62b894e8_mus_model.json diff --git a/resources/640eeed3/640eeed3_code.scd b/resources/piece_ledger/640eeed3/640eeed3_code.scd similarity index 100% rename from resources/640eeed3/640eeed3_code.scd rename to resources/piece_ledger/640eeed3/640eeed3_code.scd diff --git a/resources/640eeed3/640eeed3_mus_model.json b/resources/piece_ledger/640eeed3/640eeed3_mus_model.json similarity index 100% rename from resources/640eeed3/640eeed3_mus_model.json rename to resources/piece_ledger/640eeed3/640eeed3_mus_model.json diff --git a/resources/6506161e/6506161e_code.scd b/resources/piece_ledger/6506161e/6506161e_code.scd similarity index 100% rename from resources/6506161e/6506161e_code.scd rename to resources/piece_ledger/6506161e/6506161e_code.scd diff --git a/resources/6506161e/6506161e_mus_model.json b/resources/piece_ledger/6506161e/6506161e_mus_model.json similarity index 100% rename from resources/6506161e/6506161e_mus_model.json rename to resources/piece_ledger/6506161e/6506161e_mus_model.json diff --git a/resources/69a72421/69a72421_code.scd b/resources/piece_ledger/69a72421/69a72421_code.scd similarity index 100% rename from resources/69a72421/69a72421_code.scd rename to resources/piece_ledger/69a72421/69a72421_code.scd diff --git a/resources/69a72421/69a72421_mus_model.json b/resources/piece_ledger/69a72421/69a72421_mus_model.json similarity index 100% rename from resources/69a72421/69a72421_mus_model.json rename to resources/piece_ledger/69a72421/69a72421_mus_model.json diff --git a/resources/6abf27d4/6abf27d4_code.scd b/resources/piece_ledger/6abf27d4/6abf27d4_code.scd similarity index 100% rename from resources/6abf27d4/6abf27d4_code.scd rename to resources/piece_ledger/6abf27d4/6abf27d4_code.scd diff --git a/resources/6abf27d4/6abf27d4_mus_model.json b/resources/piece_ledger/6abf27d4/6abf27d4_mus_model.json similarity index 100% rename from resources/6abf27d4/6abf27d4_mus_model.json rename to resources/piece_ledger/6abf27d4/6abf27d4_mus_model.json diff --git a/resources/6be1486c/6be1486c_code.scd b/resources/piece_ledger/6be1486c/6be1486c_code.scd similarity index 100% rename from resources/6be1486c/6be1486c_code.scd rename to resources/piece_ledger/6be1486c/6be1486c_code.scd diff --git a/resources/6be1486c/6be1486c_mus_model.json b/resources/piece_ledger/6be1486c/6be1486c_mus_model.json similarity index 100% rename from resources/6be1486c/6be1486c_mus_model.json rename to resources/piece_ledger/6be1486c/6be1486c_mus_model.json diff --git a/resources/7000ae3e/7000ae3e_code.scd b/resources/piece_ledger/7000ae3e/7000ae3e_code.scd similarity index 100% rename from resources/7000ae3e/7000ae3e_code.scd rename to resources/piece_ledger/7000ae3e/7000ae3e_code.scd diff --git a/resources/7000ae3e/7000ae3e_mus_model.json b/resources/piece_ledger/7000ae3e/7000ae3e_mus_model.json similarity index 100% rename from resources/7000ae3e/7000ae3e_mus_model.json rename to resources/piece_ledger/7000ae3e/7000ae3e_mus_model.json diff --git a/resources/7aa8c429/7aa8c429_code.scd b/resources/piece_ledger/7aa8c429/7aa8c429_code.scd similarity index 100% rename from resources/7aa8c429/7aa8c429_code.scd rename to resources/piece_ledger/7aa8c429/7aa8c429_code.scd diff --git a/resources/7aa8c429/7aa8c429_mus_model.json b/resources/piece_ledger/7aa8c429/7aa8c429_mus_model.json similarity index 100% rename from resources/7aa8c429/7aa8c429_mus_model.json rename to resources/piece_ledger/7aa8c429/7aa8c429_mus_model.json diff --git a/resources/7ac10d34/7ac10d34_code.scd b/resources/piece_ledger/7ac10d34/7ac10d34_code.scd similarity index 100% rename from resources/7ac10d34/7ac10d34_code.scd rename to resources/piece_ledger/7ac10d34/7ac10d34_code.scd diff --git a/resources/7ac10d34/7ac10d34_gui_state.json b/resources/piece_ledger/7ac10d34/7ac10d34_gui_state.json similarity index 100% rename from resources/7ac10d34/7ac10d34_gui_state.json rename to resources/piece_ledger/7ac10d34/7ac10d34_gui_state.json diff --git a/resources/7ac10d34/7ac10d34_mus_model.json b/resources/piece_ledger/7ac10d34/7ac10d34_mus_model.json similarity index 100% rename from resources/7ac10d34/7ac10d34_mus_model.json rename to resources/piece_ledger/7ac10d34/7ac10d34_mus_model.json diff --git a/resources/7e170ef8/7e170ef8_code.scd b/resources/piece_ledger/7e170ef8/7e170ef8_code.scd similarity index 100% rename from resources/7e170ef8/7e170ef8_code.scd rename to resources/piece_ledger/7e170ef8/7e170ef8_code.scd diff --git a/resources/7e170ef8/7e170ef8_gui_state.json b/resources/piece_ledger/7e170ef8/7e170ef8_gui_state.json similarity index 100% rename from resources/7e170ef8/7e170ef8_gui_state.json rename to resources/piece_ledger/7e170ef8/7e170ef8_gui_state.json diff --git a/resources/7e170ef8/7e170ef8_mus_model.json b/resources/piece_ledger/7e170ef8/7e170ef8_mus_model.json similarity index 100% rename from resources/7e170ef8/7e170ef8_mus_model.json rename to resources/piece_ledger/7e170ef8/7e170ef8_mus_model.json diff --git a/resources/7ead41c3/7ead41c3_code.scd b/resources/piece_ledger/7ead41c3/7ead41c3_code.scd similarity index 100% rename from resources/7ead41c3/7ead41c3_code.scd rename to resources/piece_ledger/7ead41c3/7ead41c3_code.scd diff --git a/resources/7ead41c3/7ead41c3_mus_model.json b/resources/piece_ledger/7ead41c3/7ead41c3_mus_model.json similarity index 100% rename from resources/7ead41c3/7ead41c3_mus_model.json rename to resources/piece_ledger/7ead41c3/7ead41c3_mus_model.json diff --git a/resources/314491/314491_code.scd b/resources/piece_ledger_pas/314s49e1/314s49e1_code.scd similarity index 100% rename from resources/314491/314491_code.scd rename to resources/piece_ledger_pas/314s49e1/314s49e1_code.scd diff --git a/resources/314491/314491_music.json b/resources/piece_ledger_pas/314s49e1/314s49e1_mus_model.json similarity index 98% rename from resources/314491/314491_music.json rename to resources/piece_ledger_pas/314s49e1/314s49e1_mus_model.json index ef5284d..c78a753 100644 --- a/resources/314491/314491_music.json +++ b/resources/piece_ledger_pas/314s49e1/314s49e1_mus_model.json @@ -1,5 +1,5 @@ { -music_data: +"music_data": [ [ [ @@ -55,14 +55,14 @@ music_data: [ [ [ 1, -1, 0, 0, 0, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 0, -1, 0, 0, 0, 0 ] ], 0.75 ], [ [ [ 1, -1, 0, 0, 0, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 1, -1, 0, 0, -2, 0 ] ], 1.375 ], [ [ [ 2, -2, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 1, -1, 0, 0, -2, 0 ] ], 0.875 ], - [ [ [ 2, -2, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 0, -1, 0, 0, -1, 1 ] ], 1.375 ], + [ [ [ 2, -2, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 0, -1, 0, 0, -1, 1 ] ], 3.375 ], [ [ [ 2, -2, 0, 0, -1, 0 ], [ "Rest" ], [ "Rest" ], [ 0, -1, 0, 0, -1, 1 ] ], 1.5 ], [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ 0, -1, 0, 0, -1, 1 ] ], 1.375 ], [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 1.0 ] ] ] ], -last_changes: +"last_changes": [ [ [ 1, -1, 0, 0, 0, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 0, 0, 0, 0, -1, 0 ], [ 1, -1, -1, 0, -1, 0 ] ], [ [ 1, -1, 0, 0, 0, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 0, 0, 0, 0, -1, 0 ], [ 0, -1, 0, 0, 0, 0 ] ], @@ -70,6 +70,5 @@ last_changes: [ [ 2, -2, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 0, 0, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -2, 0 ] ], [ [ 2, -2, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 0, 0, 0, 0, -1, 0 ], [ 0, -1, 0, 0, -1, 1 ] ] ], -seed: 314491, -ref_seed: nil +"ref_uid": "nil" } \ No newline at end of file diff --git a/resources/449aeaa6/449aeaa6_code.scd b/resources/piece_ledger_pas/449aeaa6/449aeaa6_code.scd similarity index 100% rename from resources/449aeaa6/449aeaa6_code.scd rename to resources/piece_ledger_pas/449aeaa6/449aeaa6_code.scd diff --git a/resources/449aeaa6/449aeaa6_mus_model.json b/resources/piece_ledger_pas/449aeaa6/449aeaa6_mus_model.json similarity index 100% rename from resources/449aeaa6/449aeaa6_mus_model.json rename to resources/piece_ledger_pas/449aeaa6/449aeaa6_mus_model.json diff --git a/resources/46210507/46210507_code.scd b/resources/piece_ledger_pas/46210507/46210507_code.scd similarity index 100% rename from resources/46210507/46210507_code.scd rename to resources/piece_ledger_pas/46210507/46210507_code.scd diff --git a/resources/46210507/46210507_mus_model.json b/resources/piece_ledger_pas/46210507/46210507_mus_model.json similarity index 100% rename from resources/46210507/46210507_mus_model.json rename to resources/piece_ledger_pas/46210507/46210507_mus_model.json diff --git a/resources/4b96f62d/4b96f62d_code.scd b/resources/piece_ledger_pas/4b96f62d/4b96f62d_code.scd similarity index 100% rename from resources/4b96f62d/4b96f62d_code.scd rename to resources/piece_ledger_pas/4b96f62d/4b96f62d_code.scd diff --git a/resources/4b96f62d/4b96f62d_mus_model.json b/resources/piece_ledger_pas/4b96f62d/4b96f62d_mus_model.json similarity index 100% rename from resources/4b96f62d/4b96f62d_mus_model.json rename to resources/piece_ledger_pas/4b96f62d/4b96f62d_mus_model.json diff --git a/resources/50fec831/50fec831_code.scd b/resources/piece_ledger_pas/50fec831/50fec831_code.scd similarity index 100% rename from resources/50fec831/50fec831_code.scd rename to resources/piece_ledger_pas/50fec831/50fec831_code.scd diff --git a/resources/50fec831/50fec831_mus_model.json b/resources/piece_ledger_pas/50fec831/50fec831_mus_model.json similarity index 100% rename from resources/50fec831/50fec831_mus_model.json rename to resources/piece_ledger_pas/50fec831/50fec831_mus_model.json diff --git a/resources/5267b235/5267b235_code.scd b/resources/piece_ledger_pas/5267b235/5267b235_code.scd similarity index 100% rename from resources/5267b235/5267b235_code.scd rename to resources/piece_ledger_pas/5267b235/5267b235_code.scd diff --git a/resources/5267b235/5267b235_mus_model.json b/resources/piece_ledger_pas/5267b235/5267b235_mus_model.json similarity index 100% rename from resources/5267b235/5267b235_mus_model.json rename to resources/piece_ledger_pas/5267b235/5267b235_mus_model.json diff --git a/resources/5625a95a/5625a95a_code.scd b/resources/piece_ledger_pas/5625a95a/5625a95a_code.scd similarity index 100% rename from resources/5625a95a/5625a95a_code.scd rename to resources/piece_ledger_pas/5625a95a/5625a95a_code.scd diff --git a/resources/5625a95a/5625a95a_mus_model.json b/resources/piece_ledger_pas/5625a95a/5625a95a_mus_model.json similarity index 100% rename from resources/5625a95a/5625a95a_mus_model.json rename to resources/piece_ledger_pas/5625a95a/5625a95a_mus_model.json diff --git a/resources/475efb26/475efb26_code.scd b/resources/piece_ledger_pas/628d5c8b/628d5c8b_code.scd similarity index 53% rename from resources/475efb26/475efb26_code.scd rename to resources/piece_ledger_pas/628d5c8b/628d5c8b_code.scd index 55bfebd..90f0b1e 100644 --- a/resources/475efb26/475efb26_code.scd +++ b/resources/piece_ledger_pas/628d5c8b/628d5c8b_code.scd @@ -6,7 +6,7 @@ var hsArrayToCents, pDist, hdSum, hsChordalDistance, hsArrayToFreq; var isInRange, spacingScore, rangeScore, intervalScore, inclusionScore; // subroutines -var genTuples, initVoices, genOrders, genSubMotif, updateVoices, genDurFunc, genStepFunc; +var genTuples, initVoices, genOrders, genSubMotif, updateVoices, genDurFunc; // primary routines var genMotif, genSecondarySeq; @@ -16,25 +16,21 @@ var genPatterns, genMidiPatterns; // resource management funcs var seedFunc, genUID, writeResources, stringifyToDepth, setSeeds, sanityCheck, -msgInterpret, loadLedgerFile, loadLedgerJSON, loadModelFile, loadModelJSON, -setGlobalVars, globalVarsToDict, saveLedger; +msgInterpret, loadLedgerFile, loadLedgerJSON, loadModelFile, loadModelJSON; // model vars //(model and global vars mostly set by OSC funcs -var seq, lastXChanges, -curUID, refUID, orderSeed, durSeed, motifSeed, +var curUID, refUID, orderSeed, durSeed, motifSeed, entrancesProbVals, passagesProbVals, exitsProbVals, -ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, -orders, susWeights, orderSize, passagesSize, -motifEdited, orderEdited; +ranges, orders, susWeights, passagesWeights, passagesSize, orderSize; // model aux vars -var entrancesDurFunc, passagesDurFunc, exitsDurFunc, stepFunc; +var entrancesDurFunc, passagesDurFunc, exitsDurFunc; // other global vars -var popSize, exPath, dir, primes, dims, tuples, -group, player, ledgerPath, ledger, currentlyPlayingUID, -nameSpaces; +var lastXChanges, popSize, exPath, dir, primes, dims, tuples, +seq, group, player, ledgerPath, ledger, currentlyPlayingUID; + // install JSON quark if(Quarks.isInstalled("JSONlib").not, { @@ -120,8 +116,7 @@ intervalScore = { arg hsArray1, hsArray2, mean, sd, signed = false; var pDistance; pDistance = pDist.value(hsArray1, hsArray2, signed); - //pDistance.gaussCurve(1, mean, sd) - stepFunc.value(pDistance); + pDistance.gaussCurve(1, mean, sd) }; inclusionScore = { @@ -154,37 +149,23 @@ initVoices = { voicesInit.deepCopy; }; -genDurFunc = {arg chordProb, minPad, maxPad, minDur, maxDur, envData, seed; +genDurFunc = {arg chordProb, min, max, envData, seed; var env, pTable, durFunc; env = Env.pairs([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).asSignal(256).asList.asArray; pTable = env.asRandomTable; - [chordProb, minPad, maxPad, minDur, maxDur, envData].postln; - durFunc = {arg allowChord, pad = false; + durFunc = {arg allowChord; var res; res = if(allowChord.not, { - pTable.tableRand * (maxDur - minDur) + minDur + pTable.tableRand * (max - min) + min }, { - if(1.0.rand < chordProb, {0}, {pTable.tableRand * (maxDur - minDur) + minDur}); + if(1.0.rand < chordProb, {0}, {pTable.tableRand * (max - min) + min}); }).round(0.125); - if(pad, {res = res + rrand(minPad.asFloat, maxPad.asFloat).round(0.125)}); if(res.asInteger == res, {res = res.asInteger}); res }; seedFunc.value(durFunc, seed); }; -genStepFunc = {arg minStep, maxStep, envData, seed; - var envDataNorm, env, pTable, stepFunc; - [minStep, maxStep, envData].postln; - envDataNorm = ([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).flop; - envDataNorm = [envDataNorm[0].normalize(minStep, maxStep), envDataNorm[1]].flop; - env = Env.pairs(envDataNorm); - stepFunc = {arg pDist; - env.at(pDist).clip(0.001, 1); - }; - seedFunc.value(stepFunc, seed); -}; - genOrders = {arg minMotifLength = 1, maxMotifLength = 5, minProgLength = 0, maxProgLength = 5; ((maxMotifLength - minMotifLength).rand + minMotifLength).collect({ var noProgIns, noSusIns, noSilentIns, prog, sus, silent, order; @@ -215,8 +196,7 @@ updateVoices = {arg ins, sus; recentlySoundedScore = inclusionScore.value(lastXChanges.flop[ins], candidate, 0); isInRangeScore = rangeScore.value(candidate, candidate.collect({0}), ranges[ins][0], ranges[ins][1], 0, true); regScore = spacingScore.value(voices.deepCopy.put(ins, candidate), 300); - hdScore = pow(hdSum.value(voices.deepCopy.put(ins, candidate)), hdExp); - if(hdInvert == 0, {hdScore = 1/hdScore}); + hdScore = 1/pow(hdSum.value(voices.deepCopy.put(ins, candidate)), 2); //maybe what you want here is a vector to another root and then favoring movement towards it. //distScore = pow(hsChordalDistance.value(voices, voices.put(ins, candidate)), 2); @@ -240,14 +220,13 @@ updateVoices = {arg ins, sus; }; genSubMotif = {arg order, orderIndex, lastState, repeatLast = false, startFromLast = false, isLastOrder = false; - var sus, prog, silent, flatOrder, res, isInChord, allowChord, pad, lastXChangesHold, voices, adder; + var sus, prog, silent, flatOrder, res, isInChord, allowChord, lastXChangesHold, voices, adder; # sus, prog, silent = order; flatOrder = silent ++ sus ++ prog; lastXChangesHold = lastXChanges.deepCopy; voices = lastState.deepCopy; isInChord = popSize.collect({false}); allowChord = false; - pad = false; res = []; "------generating motif".postln; //need to figure out here if voices move between motifs @@ -259,23 +238,18 @@ genSubMotif = {arg order, orderIndex, lastState, repeatLast = false, startFromLa if(voices[ins] != adder, { var dur; - if((sus ++ silent).includes(ins), { - allowChord = (ins != sus.last); - pad = (ins == sus.last); + allowChord = if((sus ++ silent).includes(ins), { + //(sus ++ silent).includes(ins) && (ins != sus.last); + ins != sus.last; }, { - if(i < (flatOrder.size - 1), { - allowChord = (isInChord[flatOrder[i + 1]] || (ins == flatOrder[i + 1])).not; - pad = false; - }, { - allowChord = false; - pad = true - }); + if(i < (flatOrder.size - 1), {(isInChord[flatOrder[i + 1]] || (ins == flatOrder[i + 1])).not}, {false}); }); if((orderIndex == 0) && sus.includes(ins), { - dur = entrancesDurFunc.value(allowChord, pad); + dur = entrancesDurFunc.value(allowChord); }, { - dur = passagesDurFunc.value(allowChord, pad); + dur = passagesDurFunc.value(allowChord); }); + //dur = passagesDurFunc.value(allowChord); if(dur == 0, {isInChord[ins] = true}, {isInChord = popSize.collect({false})}); voices[ins] = adder; @@ -290,15 +264,14 @@ genSubMotif = {arg order, orderIndex, lastState, repeatLast = false, startFromLa var dur; voices[ins] = ["Rest"]; allowChord = (voices != popSize.collect({["Rest"]})); - pad = allowChord.not; - dur = exitsDurFunc.value(allowChord, pad); + dur = exitsDurFunc.value(allowChord); res = res.add([voices.deepCopy.postln, dur]); }); }); }); //format and return - if(startFromLast, {lastXChanges = lastXChangesHold.deepCopy}); + if(startFromLast, {lastXChanges = lastXChangesHold}); res; }; @@ -306,7 +279,7 @@ genSubMotif = {arg order, orderIndex, lastState, repeatLast = false, startFromLa //------primary routines genMotif = { - var repeats, fSeq, fDur, durAdd; + var repeats, fSeq; repeats = 1; fSeq = []; @@ -328,13 +301,6 @@ genMotif = { fSeq = fSeq.add(motif); }); - - //round last duration to measure - fDur = fSeq.flatten.flatten.slice(nil, 1).sum; - durAdd = fDur.round(4) - fDur; - if(durAdd < 0, {durAdd = 4 - durAdd}); - fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] = fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] + durAdd; - fSeq }; @@ -370,69 +336,48 @@ Event.addEventType(\osc, { */ Event.addEventType(\osc, { - if (~addr.notNil) { - ~msg; + if (~addr.postln.notNil) { + ~msg.postln; ~addr.sendMsg(~path, *~msg); }; }); -genPatterns = {arg inSeq, addr, oneShot = false; - var voices, durs, pbinds, res, indices, sectionDurs, msg, ids, seq; +genPatterns = {arg inSeq, addr; + var voices, durs, patterns, res, indices, sectionDurs, msg, ids, seq; seq = inSeq.collect({arg mSeq; mSeq[0]}); # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - pbinds = voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs, attacks, rels, amps; - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - //attacks = 2.collect({rrand(1, 3)}) ++ freqs.drop(2).collect({rrand(0.3, 0.5)}); - attacks = fDurs.collect({arg dur; dur * rrand(0.2, 0.4)}); - //rels = freqs.drop(2).collect({rrand(0.3, 0.5)}) ++ 2.collect({rrand(1, 3)}); - rels = (clumps.size - 1).collect({arg c; - if(clumps[c + 1][0] == ["Rest"], {rrand(1.0, 3.0)}, {rrand(0.3, 0.5)}); - }); - rels = rels.add(rrand(1.0, 3.0)); - amps = freqs.collect({rrand(0.6, 0.99)}); + msg = inSeq.collect({arg mSeq, m; mSeq[1..]}); + //ids = inSeq.collect({arg mSeq, m; mSeq[2]}); + sectionDurs = seq.collect({arg mSeq; mSeq.flatten2(mSeq.maxDepth - 5).flop[1].sum}); + res = Ppar( + voices.flop.collect({arg voice; + var clumps, hdScores, freqs, fDurs; + clumps = voice.separate({arg a, b; a != b }); + freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); + fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - [ - Pbind( - \instrument, \string_model, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \attack, Pseq(attacks, 1), - \sustain, Pseq(fDurs, 1), - \release, Pseq(rels, 1), - //\amp, Pseq(amps, 1), - \amp, Pbrown(0.5, 1, 0.5), - \busIndex, v - ), Pbind( - \instrument, \sine, + \instrument, \test, \group, group, \freq, Pseq(freqs, 1), \dur, Pseq(fDurs, 1), - \sustain, Pseq(fDurs, 1), - \busIndex, v + \sustain, Pseq(fDurs, 1) ) - ] - }).flatten; - if(oneShot.not, { - msg = inSeq.collect({arg mSeq, m; mSeq[1..]}); - //ids = inSeq.collect({arg mSeq, m; mSeq[2]}); - sectionDurs = seq.collect({arg mSeq; mSeq.flatten2(mSeq.maxDepth - 5).flop[1].sum}); - pbinds = pbinds ++ + }) ++ [ Pbind( \type, \osc, \addr, addr, + //\indexPath, "/cur_play_index", + //\indexMsg, Pseq(indices, 1), + //\seqPath, "/mus_seq", + //\seqMsg, Pseq(seq, 1), \path, "/playing", \msg, Pseq(msg, 1), \dur, Pseq(sectionDurs, 1) ); ] - }); - res = Ppar(pbinds); + ); res }; @@ -540,35 +485,39 @@ msgInterpret = {arg in, escapeDoubleQuotes = true, escapeSingleQuotes = true; res = res.replace("Rest", "\"Rest\""); res = res.interpret; }, { - var tmpRes; - if(res.every({arg char; char.isDecDigit}), {tmpRes = res.asInteger}); - if(res.contains("."), {tmpRes = res.asFloat}); - if(tmpRes != nil, {res = tmpRes}); + //res.postln; + if(res.every({arg char; char.isDecDigit}), {res = res.asInteger}); }); }); res }; -writeResources = {arg path, dict; - var file, modelItems, resString; +writeResources = {arg path; + var file, nameSpaces, modelItems, resString; file = File(path,"w"); + nameSpaces = [ + "music_data", "last_changes", + "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", + "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", + "ranges", "passages_weights", "order", "sus_weights", "order_size", "passages_size" + ]; + modelItems = [ seq, lastXChanges, curUID, refUID, orderSeed, durSeed, motifSeed, entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited + ranges, passagesWeights, orders, susWeights, orderSize, passagesSize ]; - resString = nameSpaces.collect({arg nameSpace; - var depth = 0, insert = " "; + resString = [nameSpaces, modelItems].flop.collect({arg item; + var nameSpace, modelItem, depth = 0, insert = " "; + # nameSpace, modelItem = item; if(nameSpace == "music_data", {depth = 3; insert = "\n"}); if(nameSpace == "last_changes", {depth = 1; insert = "\n"}); if(nameSpace == "order", {depth = 1; insert = "\n"}); - if((nameSpace == "ref_uid") && (dict[nameSpace] == nil), {dict[nameSpace] = "nil"}); - "\"" ++ nameSpace ++ "\":" ++ insert ++ stringifyToDepth.value(dict[nameSpace], depth) + if((nameSpace == "ref_uid") && (modelItem == nil), {modelItem = "nil"}); + "\"" ++ nameSpace ++ "\":" ++ insert ++ stringifyToDepth.value(modelItem, depth) }).join(",\n"); resString = "{\n" ++ resString ++ "\n}"; @@ -581,36 +530,25 @@ writeResources = {arg path, dict; loadModelFile = {arg path; loadModelJSON.value(File(path, "r").readAllString.parseJSON)}; loadModelJSON = {arg jsonObject; - var dict; - dict = Dictionary.with(*nameSpaces.collect({arg nS; nS->msgInterpret.value(jsonObject[nS])})); - dict -}; + var nameSpaces, data; -setGlobalVars = {arg dict, skipLastXChanges = false; - var tmpLastXChanges; - tmpLastXChanges = lastXChanges.deepCopy; - // order really matters!!!! - # seq, lastXChanges, curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited = nameSpaces.collect({arg nS; dict[nS]}); - if(skipLastXChanges, {lastXChanges = tmpLastXChanges}); - dict -}; + //model = File(path, "r").readAllString.parseJSON; -globalVarsToDict = { - var modelItems, dict; - // order really matters!!!! - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited + nameSpaces = [ + "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", + "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", + "ranges", "passages_weights", "order", "sus_weights", "order_size", "passages_size" ]; - dict = Dictionary.with(*nameSpaces.collect({arg nS, n; nS->modelItems[n]})); + + data = nameSpaces.collect({arg nS; msgInterpret.value(jsonObject[nS])}); + + //data.postln; + + # curUID, refUID, orderSeed, durSeed, motifSeed, + entrancesProbVals, passagesProbVals, exitsProbVals, + ranges, passagesWeights, orders, susWeights, orderSize, passagesSize = data; + + popSize = ranges.size; }; loadLedgerFile = {arg path; @@ -620,13 +558,6 @@ loadLedgerFile = {arg path; loadLedgerJSON = {arg jsonObject; ledger = jsonObject["ledger"]}; -saveLedger = {arg ledger, path; - var file; - file = File(path, "w"); - file.write("{\n\"ledger\":\n" ++ stringifyToDepth.value(ledger, 1) ++ "\n}"); - file.close; -}; - //------global vars primes = [[2, 1], [3, 2], [5, 4], [7, 4], [11, 8], [13, 8]]; @@ -638,18 +569,9 @@ dims = primes.size; tuples = genTuples.value(); //refUID = nil; group = Group.new; -~group = group; loadLedgerFile.value(dir +/+ ".." +/+ "resources" +/+ "piece_ledger.json"); //passagesWeights = [1, 1, 1, 1, 1]; //susWeights = [1, 1, 1]; -// order really matters!!!! -nameSpaces = [ - "music_data", "last_changes", "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", - "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", - "ranges", "step_probs_vals", "passages_weights", "hd_exp", "hd_invert", - "order", "sus_weights", "order_size", "passages_size", - "motif_edited", "order_edited" -]; //------OSC funcs @@ -659,29 +581,17 @@ OSCdef(\load_ledger, {arg msg, time, addr, port; }, \load_ledger); OSCdef(\load_model, {arg msg, time, addr, port; - var dict; - dict = loadModelFile.value(msg[1].asString); - setGlobalVars.value(dict); + loadModelFile.value(msg[1].asString); }, \load_model); -OSCdef(\save_ledger, {arg msg, time, addr, port; - msg.postln; - ledger = msgInterpret.value(msg[1].asString.parseJSON["ledger"], false).postln; - //loadLedgerJSON.value(msg[0]) - saveLedger.value(ledger, msg[2].asString); - //loadLedgerFile.value(msg[1].asString); -}, \save_ledger); OSCdef(\generate, {arg msg, time, addr, port; - var path, dict, durSeeds, musPath, modelString; + var path, durSeeds, musPath, modelString; msg.postln; path = msg[1].asString; - dict = loadModelFile.value(path); - setGlobalVars.value(dict, true); - - popSize = ranges.size; + loadModelFile.value(path); //refUID.postln; @@ -689,44 +599,35 @@ OSCdef(\generate, {arg msg, time, addr, port; if(ledger == nil, {ledger = ["tmp"]}); if(ledger.last != "tmp", {ledger = ledger.add("tmp")}); - if(refUID == nil, {lastXChanges = [initVoices.value().deepCopy]}); - if((refUID != nil) && (refUID != "tmp"), { + lastXChanges = if(refUID == nil, { + [initVoices.value().deepCopy]; + }, { var file; file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - lastXChanges = msgInterpret.value(file.readAllString.parseJSON["last_changes"]); + msgInterpret.value(file.readAllString.parseJSON["last_changes"]); }); - refUID.postln; - lastXChanges.collect({arg item; item.postln}); - durSeeds = seedFunc.value({3.collect({rrand(100000, 999999)})}, durSeed).value.postln; - entrancesDurFunc = genDurFunc.valueArray(entrancesProbVals[..4] ++ [entrancesProbVals[5..]] ++ [durSeeds[0]]); - passagesDurFunc = genDurFunc.valueArray(passagesProbVals[..4] ++ [passagesProbVals[5..]] ++ [durSeeds[1]]); - exitsDurFunc = genDurFunc.valueArray(exitsProbVals[..4] ++ [exitsProbVals[5..]] ++ [durSeeds[2]]); + entrancesDurFunc = genDurFunc.valueArray(entrancesProbVals[..2] ++ [entrancesProbVals[3..]] ++ [durSeeds[0]]); + passagesDurFunc = genDurFunc.valueArray(passagesProbVals[..2] ++ [passagesProbVals[3..]] ++ [durSeeds[1]]); + exitsDurFunc = genDurFunc.valueArray(exitsProbVals[..2] ++ [exitsProbVals[3..]] ++ [durSeeds[2]]); if(orders == nil, { orders = seedFunc.value(genOrders, orderSeed).valueArray(orderSize ++ passagesSize); //addr.sendMsg("/order", stringifyToDepth.value(orders, 1)); }); - - stepFunc = genStepFunc.valueArray(stepProbsVals[..1] ++ [stepProbsVals[2..]] ++ [motifSeed]); seq = seedFunc.value(genMotif, motifSeed).value; - lastXChanges.collect({arg item; item.postln}); - - dict = globalVarsToDict.value; - modelString = writeResources.value(path, dict); + modelString = writeResources.value(path); //addr.sendMsg("/generated", musPath, stringifyToDepth.value(seq, 3)); - //~seq = seq; - - addr.sendMsg("/generated", path, modelString, ledgerPath); + addr.sendMsg("/generated", path, modelString); }, \generate); OSCdef(\commit, {arg msg, time, addr, port; - var musicData, musicChanged, dict, newLedger, modelPath, musString, musFile, test1, test2; - //msg.postln; + var newLedger, modelPath, musString, musFile, test1, test2; + msg.postln; /* test1 = msg[1].asString.parseJSON; @@ -736,159 +637,47 @@ OSCdef(\commit, {arg msg, time, addr, port; (test1["music"] == test2["music_data"]).postln; */ - musicData = loadModelJSON.value(msg[1].asString.parseJSON)["music_data"].postln; - musicChanged = (musicData != seq).postln; - curUID = genUID.value; - File.mkdir((dir +/+ ".." +/+ "resources" +/+ curUID).standardizePath); File.copy(exPath, (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_code" ++ ".scd").standardizePath); modelPath = (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_mus_model" ++ ".json").standardizePath; - dict = globalVarsToDict.value; - if(musicChanged, { - seq = musicData; - dict["music_data"] = seq; - dict["motif_edited"] = "true" - }); - dict["cur_uid"] = curUID; - - writeResources.value(modelPath, dict); + writeResources.value(modelPath); File.delete(ledgerPath ++ "_bak"); File.copy(ledgerPath, ledgerPath ++ "_bak"); File.delete(ledgerPath); + newLedger = File(ledgerPath, "w"); ledger = ledger.drop(-1).add(curUID); - - saveLedger.value(ledger, ledgerPath); + newLedger.write("{\n\"ledger\":\n" ++ stringifyToDepth.value(ledger, 1) ++ "\n}"); + newLedger.close; addr.sendMsg("/committed", curUID, ledgerPath); //refUID = curUID; - }, \commit); OSCdef(\transport, {arg msg, time, addr, port; msg.postln; if(msg[1] == 0, { - group.set(\release, 2); - group.set(\gate, 0); player.stop; + group.set(\gate, 0); }, { // the cued sequence can now be read from file, so this can be cleaned up var cSize, patterns, pSeq, cuedSeek, indexStart, indexEnd, tmpLedger; - if(msg[1] == 1, { - pSeq = []; - cuedSeek = (seq != nil); - indexStart = msg[2].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.postln.parseJSON["music_data"]), path, indexStart + index, uid]); - file.close; - }); - }); - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - patterns = genPatterns.value(pSeq, addr); - }, { - pSeq = [loadModelJSON.value(msg[2].asString.parseJSON)["music_data"].postln]; - patterns = genPatterns.value(pSeq, addr, true); - }); - player = Pfset(pattern: patterns, cleanupFunc: { - addr.sendMsg("/transport", 0); - addr.sendMsg("/one_shot", 0); - }); - player = player.play - }); -}, \transport); - - -OSCdef(\transcribe_motif, {arg msg, time, addr, port; - var tSeq, refChord, refUID; - - msg.postln; - - tSeq = [loadModelJSON.value(msg[1].asString.parseJSON)["music_data"]]; - refUID = msg[2].asString.postln; - - if((refUID != "nil") && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }, { - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - }); - - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "lilypond" +/+ "includes").standardizePath, addr, "/transcribe_motif"); -}, \transcribe_motif); - - -OSCdef(\transcribe_all, {arg msg, time, addr, port; - var cSize, patterns, cuedSeek, indexStart, indexEnd, tmpLedger; - if(true, { + pSeq = []; cuedSeek = (seq != nil); - indexStart = msg[1].asInteger; + indexStart = msg[2].asInteger; indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - - //tmp for testing transcription - indexEnd = (indexStart+5); - //ledger.postln; if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - var lilyPartLedgerFiles; - - lilyPartLedgerFiles = 4.collect({arg p; - File((dir +/+ ".." +/+ "lilypond" +/+ "includes" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly").standardizePath, "w"); - }); - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file, fileString, tSeq, refUID, refChord; + var path, file; path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; file = File(path, "r"); - fileString = file.readAllString; - tSeq = msgInterpret.value(fileString.parseJSON["music_data"]); - refUID = msgInterpret.value(fileString.parseJSON["ref_uid"]); + pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, indexStart + index, uid]); file.close; - - //uid.postln; - //(refUID == "nil").postln; - - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - - if(refUID != "nil", { - path = (dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }); - - if(index != indexEnd, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath); - }, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath, addr, "/transcribe_all"); - }); - - lilyPartLedgerFiles.do({arg f, p; - f.write("\\include \".." +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly\"\n"); - }); - - }); - - lilyPartLedgerFiles.do({arg f; - f.close }); }); - /* if(cuedSeek, { var path, file; path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; @@ -896,121 +685,29 @@ OSCdef(\transcribe_all, {arg msg, time, addr, port; pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); file.close; }); - */ - }, { - + patterns = genPatterns.value(pSeq, addr); + player = Pfset(pattern: patterns, cleanupFunc: { + addr.sendMsg("/transport", 0); + }); + player = player.play }); - -}, \transcribe_all); +}, \transport); ) -~transcribe.value(~seq, dir); - ( -//synthdefs -~stringModelBusArray = 4.collect({Bus.audio(s, 1)}); -~sineBusArray = 4.collect({Bus.audio(s, 1)}); -~bassBusArray = 1.collect({Bus.audio(s, 1)}); -~hdustBusArray = 1.collect({Bus.audio(s, 1)}); -~samplerBusArray = 2.collect({Bus.audio(s, 1)}); -~sBuf = Buffer.alloc(s, 10, 2); -SynthDef(\string_model, {arg freq, gate = 1, sustain, amp, dur, attack, release = 1, busIndex = 0; +SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; var trig, exc, sig1, sig2, noHarms; - noHarms = rrand(20, 40); + noHarms = 30; exc = Saw.ar(freq, TRand.ar(0.5, 1, Impulse.ar(freq))) * 0.001 + Dust.ar(10000, 0.01); sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.8).softclip; - //sig1 = HPF.ar(sig1, 300); - Out.ar(Select.kr(busIndex, ~stringModelBusArray), sig1 * amp * EnvGen.kr(Env.adsr(attack, 0.3, 0.9, release, 0.9, -3), gate, doneAction: 2)); - //Out.ar([0, 1], sig1 * EnvGen.kr(Env.asr(dur, 0.3, 1), gate, doneAction: 2)); -}).add; - -SynthDef(\sine, {arg freq, gate = 1, sustain, amp, dur, busIndex = 0; - var sig; - sig = SinOsc.ar(freq); - Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.asr(0.3, 0.4, 0.3), gate, timeScale: dur, doneAction: 2)); - //Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.sine(dur), gate, doneAction: 2)); -}).add; - -SynthDef(\mixer, {arg freq, gate = 1, sustain, amp, dur, out; - var nameSpaces, sigs; - - sigs = [~stringModelBusArray, ~sineBusArray/*, ~bassBusArray, ~hdustBusArray, ~samplerBusArray*/].collect({arg busArray, i; - var nameSpace, sig; - nameSpace = ['string', 'sine', 'bass', 'hdust', 'sampler'][i]; - sig = busArray.collect({arg bus, c; In.ar(bus, 1) * NamedControl.kr(\ ++ nameSpace ++ '_volume_' ++ c, 1, 0.1)}); - sig = sig.collect({arg channel, c; Pan2.ar(channel, NamedControl.kr(\ ++ nameSpace ++ '_pan_' ++ c, i / (busArray.size - 1), 0.1) * 2 - 1)}); - sig = sig.collect({arg channel, c; channel * NamedControl.kr(\ ++ nameSpace ++ '_mute_' ++ c, 1, 0.1)}); - sig = Mix.ar(sig) * pow(NamedControl.kr(\ ++ nameSpace ++ '_volume_master', 1, 0.1), 2); - }); - - sigs = Mix.ar(sigs / 4); - Out.ar(0, sigs) -}).add; - -SynthDef(\bass, { - var switches, drone; - switches = {|i| Dust.kr(0.1)} ! 9; - drone = {|i| var harm = pow(2, 2 - (i / 3).trunc), amp = (1 / pow(harm, 2)); - SinOsc.ar(60 * harm + TRand.kr(-3, 3, switches[i]), 0, amp)} ! 9; - Out.ar(~bassBusArray[0], Mix.new(drone) * 0.2); -}).add; - -SynthDef(\sampler, { - Out.ar(~samplerBusArray, PlayBuf.ar(2, ~sBuf, BufRateScale.kr(~sBuf), doneAction: 2)) -}).add; - -// main routine -SynthDef(\hdust, { - arg gate = 0; - var hierarchical_dust, low_sine, high_sine, brown_noise, white_noise; - // this triggers the combinations of sources - // it is similar to the Supercollider UGen called dust but with a hierarchical structure - hierarchical_dust = ( - TIRand.kr(0, 1, Impulse.kr(100)) * - TIRand.kr(0, 1, Impulse.kr(10)) * - TIRand.kr(0, 1, Impulse.kr(1)) * - TIRand.kr(0, 1, Impulse.kr(0.1)) - ); - // adjust the multiplier at the end of each line for adjusting levels - // note with each trigger, each source has a 1 in 3 chance of sounding - low_sine = SinOsc.ar(76.midicps / 16) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.1; - high_sine = SinOsc.ar(76.midicps * 8) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.01; - brown_noise = BrownNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.025; - white_noise = WhiteNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.02; - Out.ar(~hdustBusArray[0], - ((low_sine + high_sine + brown_noise + white_noise) ) - ); + Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.5).softclip; + sig1 = HPF.ar(sig1, 300); + Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); }).add; - ) -( -var bass, hdust, sampler, mixer; -/* -bass = Synth.tail(~group, \bass); -hdust = Synth.tail(~group, \hdust); -sampler = Synth.head(~group, \sampler); -*/ -mixer = Synth.tail(~group, \mixer); - -OSCdef(\mixer, {arg msg, time, addr, port; - mixer.set((msg[1] ++ '_' ++ msg[2] ++ '_' ++ msg[3]), msg[4]) -}, \mixer); - -/* -OSCdef(\sampler, {arg msg, time, addr, port; - msg.postln; - sampler.free; - ~sBuf.free; - ~sBuf = Buffer.read(s, msg[1].asString.postln, action: {sampler = Synth.head(~group, \sampler)}); -}, \sampler); -*/ -) - -/* old something ( SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; var trig, exc, sig1, sig2, noHarms, freqFinal, start, end; @@ -1029,5 +726,16 @@ SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); }).add; ) -*/ + + +"{\"a\": 1}".parseYAML["a"].asInteger; +"{\"a\": 1}".parseJSON["a"].isNumber; + +1223423434123.asHexString.toLower + +Date.getDate.rawSeconds +Date.seed.asHexString.toLower + +n = NetAddr("localhost", 8080); +n.sendMsg("/GET/#", (NetAddr.localAddr.hostname ++ ":" ++ NetAddr.localAddr.port), "/passage_probs_vals"); \ No newline at end of file diff --git a/resources/piece_ledger_pas/628d5c8b/628d5c8b_mus_model.json b/resources/piece_ledger_pas/628d5c8b/628d5c8b_mus_model.json new file mode 100644 index 0000000..a7c647e --- /dev/null +++ b/resources/piece_ledger_pas/628d5c8b/628d5c8b_mus_model.json @@ -0,0 +1,56 @@ +{ +"music_data": +[ + [ + [ + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 0.625 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ], [ 0, 1, 0, 0, 0, 0 ] ], 0 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 1, 0, 0, 0, 0, -1 ], [ 0, 1, 0, 0, 0, 0 ] ], 1.75 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 1, 0, 0, 0, 0, -1 ], [ 1, 0, 0, 0, -1, 0 ] ], 1.875 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 1, 0, 0, 0, 0, -1 ], [ 0, 0, 0, 0, 1, 0 ] ], 1.5 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 1, 0, 0, 0, 0, -1 ], [ 0, 0, 1, 0, 0, 0 ] ], 0.75 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 1, 0, 0, 0, 0, -1 ], [ 1, 0, 0, -1, 0, 0 ] ], 1.25 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 1, 0, 0, 0, 0, -1 ], [ -1, 0, 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[ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 1, 0 ], [ 0, 1, 0, 0, 0, 0 ] ], + [ [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ 0, 1, -1, 0, 0, 0 ], [ 0, 1, 0, 0, 0, 0 ] ], + [ [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ 0, 1, 0, 0, -1, 0 ], [ 0, 1, 0, 0, 0, 0 ] ], + [ [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ 0, -1, 0, 0, 0, 1 ], [ 0, 1, 0, 0, 0, 0 ] ], + [ [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ 0, 1, 0, 0, 0, -1 ], [ 0, 1, 0, 0, 0, 0 ] ] +], +"cur_uid": "628d5c8b", +"ref_uid": "7e170ef8", +"order_seed": 227004, +"dur_seed": 357129, +"motifs_seed": 170994, +"entrances_probs_vals": [ 0.75, 0.5, 2, 0, 0.5, 0.26424870466321, 0.75675675675676, 0.5, 0.5, 0.58549222797927, 0.72635135135135, 1, 0.5 ], +"passages_probs_vals": [ 0.75, 0.5, 2, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], +"exits_probs_vals": [ 0.75, 0.5, 2, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], +"ranges": [ [ 65, 727 ], [ 799, 1758 ], [ -282, 1013 ], [ -282, 799 ] ], +"passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], +"order": +[ + [ [ 0 ], [ 3, 2, 3, 3, 3, 3, 3, 3 ], [ 1 ] ], + [ [ 0, 3, 1 ], [ 2, 2, 2, 2, 2 ], [ ] ] +], +"sus_weights": [ 0.75, 0.69, 0.75 ], +"order_size": [ 2, 6 ], +"passages_size": [ 0, 10 ] +} \ No newline at end of file diff --git a/resources/6409252e/6409252e_code.scd b/resources/piece_ledger_pas/6409252e/6409252e_code.scd similarity index 100% rename from resources/6409252e/6409252e_code.scd rename to resources/piece_ledger_pas/6409252e/6409252e_code.scd diff --git a/resources/6409252e/6409252e_mus_model.json b/resources/piece_ledger_pas/6409252e/6409252e_mus_model.json similarity index 100% rename from resources/6409252e/6409252e_mus_model.json rename to resources/piece_ledger_pas/6409252e/6409252e_mus_model.json diff --git a/resources/6a3f7c7c/6a3f7c7c_code.scd b/resources/piece_ledger_pas/6a3f7c7c/6a3f7c7c_code.scd similarity index 100% rename from resources/6a3f7c7c/6a3f7c7c_code.scd rename to resources/piece_ledger_pas/6a3f7c7c/6a3f7c7c_code.scd diff --git a/resources/6a3f7c7c/6a3f7c7c_mus_model.json b/resources/piece_ledger_pas/6a3f7c7c/6a3f7c7c_mus_model.json similarity index 100% rename from resources/6a3f7c7c/6a3f7c7c_mus_model.json rename to resources/piece_ledger_pas/6a3f7c7c/6a3f7c7c_mus_model.json diff --git a/resources/6881b4ac/6881b4ac_code.scd b/resources/piece_ledger_pas/6abf27d4/6abf27d4_code.scd similarity index 63% rename from resources/6881b4ac/6881b4ac_code.scd rename to resources/piece_ledger_pas/6abf27d4/6abf27d4_code.scd index 55bfebd..127f295 100644 --- a/resources/6881b4ac/6881b4ac_code.scd +++ b/resources/piece_ledger_pas/6abf27d4/6abf27d4_code.scd @@ -6,7 +6,7 @@ var hsArrayToCents, pDist, hdSum, hsChordalDistance, hsArrayToFreq; var isInRange, spacingScore, rangeScore, intervalScore, inclusionScore; // subroutines -var genTuples, initVoices, genOrders, genSubMotif, updateVoices, genDurFunc, genStepFunc; +var genTuples, initVoices, genOrders, genSubMotif, updateVoices, genDurFunc; // primary routines var genMotif, genSecondarySeq; @@ -17,19 +17,18 @@ var genPatterns, genMidiPatterns; // resource management funcs var seedFunc, genUID, writeResources, stringifyToDepth, setSeeds, sanityCheck, msgInterpret, loadLedgerFile, loadLedgerJSON, loadModelFile, loadModelJSON, -setGlobalVars, globalVarsToDict, saveLedger; +setGlobalVars, globalVarsToDict; // model vars //(model and global vars mostly set by OSC funcs var seq, lastXChanges, curUID, refUID, orderSeed, durSeed, motifSeed, entrancesProbVals, passagesProbVals, exitsProbVals, -ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, -orders, susWeights, orderSize, passagesSize, +ranges, passagesWeights, orders, susWeights, orderSize, passagesSize, motifEdited, orderEdited; // model aux vars -var entrancesDurFunc, passagesDurFunc, exitsDurFunc, stepFunc; +var entrancesDurFunc, passagesDurFunc, exitsDurFunc; // other global vars var popSize, exPath, dir, primes, dims, tuples, @@ -120,8 +119,7 @@ intervalScore = { arg hsArray1, hsArray2, mean, sd, signed = false; var pDistance; pDistance = pDist.value(hsArray1, hsArray2, signed); - //pDistance.gaussCurve(1, mean, sd) - stepFunc.value(pDistance); + pDistance.gaussCurve(1, mean, sd) }; inclusionScore = { @@ -173,18 +171,6 @@ genDurFunc = {arg chordProb, minPad, maxPad, minDur, maxDur, envData, seed; seedFunc.value(durFunc, seed); }; -genStepFunc = {arg minStep, maxStep, envData, seed; - var envDataNorm, env, pTable, stepFunc; - [minStep, maxStep, envData].postln; - envDataNorm = ([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).flop; - envDataNorm = [envDataNorm[0].normalize(minStep, maxStep), envDataNorm[1]].flop; - env = Env.pairs(envDataNorm); - stepFunc = {arg pDist; - env.at(pDist).clip(0.001, 1); - }; - seedFunc.value(stepFunc, seed); -}; - genOrders = {arg minMotifLength = 1, maxMotifLength = 5, minProgLength = 0, maxProgLength = 5; ((maxMotifLength - minMotifLength).rand + minMotifLength).collect({ var noProgIns, noSusIns, noSilentIns, prog, sus, silent, order; @@ -215,8 +201,7 @@ updateVoices = {arg ins, sus; recentlySoundedScore = inclusionScore.value(lastXChanges.flop[ins], candidate, 0); isInRangeScore = rangeScore.value(candidate, candidate.collect({0}), ranges[ins][0], ranges[ins][1], 0, true); regScore = spacingScore.value(voices.deepCopy.put(ins, candidate), 300); - hdScore = pow(hdSum.value(voices.deepCopy.put(ins, candidate)), hdExp); - if(hdInvert == 0, {hdScore = 1/hdScore}); + hdScore = 1/pow(hdSum.value(voices.deepCopy.put(ins, candidate)), 2); //maybe what you want here is a vector to another root and then favoring movement towards it. //distScore = pow(hsChordalDistance.value(voices, voices.put(ins, candidate)), 2); @@ -298,7 +283,7 @@ genSubMotif = {arg order, orderIndex, lastState, repeatLast = false, startFromLa }); //format and return - if(startFromLast, {lastXChanges = lastXChangesHold.deepCopy}); + if(startFromLast, {lastXChanges = lastXChangesHold}); res; }; @@ -306,7 +291,7 @@ genSubMotif = {arg order, orderIndex, lastState, repeatLast = false, startFromLa //------primary routines genMotif = { - var repeats, fSeq, fDur, durAdd; + var repeats, fSeq; repeats = 1; fSeq = []; @@ -328,13 +313,6 @@ genMotif = { fSeq = fSeq.add(motif); }); - - //round last duration to measure - fDur = fSeq.flatten.flatten.slice(nil, 1).sum; - durAdd = fDur.round(4) - fDur; - if(durAdd < 0, {durAdd = 4 - durAdd}); - fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] = fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] + durAdd; - fSeq }; @@ -370,69 +348,48 @@ Event.addEventType(\osc, { */ Event.addEventType(\osc, { - if (~addr.notNil) { - ~msg; + if (~addr.postln.notNil) { + ~msg.postln; ~addr.sendMsg(~path, *~msg); }; }); -genPatterns = {arg inSeq, addr, oneShot = false; - var voices, durs, pbinds, res, indices, sectionDurs, msg, ids, seq; +genPatterns = {arg inSeq, addr; + var voices, durs, patterns, res, indices, sectionDurs, msg, ids, seq; seq = inSeq.collect({arg mSeq; mSeq[0]}); # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - pbinds = voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs, attacks, rels, amps; - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - //attacks = 2.collect({rrand(1, 3)}) ++ freqs.drop(2).collect({rrand(0.3, 0.5)}); - attacks = fDurs.collect({arg dur; dur * rrand(0.2, 0.4)}); - //rels = freqs.drop(2).collect({rrand(0.3, 0.5)}) ++ 2.collect({rrand(1, 3)}); - rels = (clumps.size - 1).collect({arg c; - if(clumps[c + 1][0] == ["Rest"], {rrand(1.0, 3.0)}, {rrand(0.3, 0.5)}); - }); - rels = rels.add(rrand(1.0, 3.0)); - amps = freqs.collect({rrand(0.6, 0.99)}); + msg = inSeq.collect({arg mSeq, m; mSeq[1..]}); + //ids = inSeq.collect({arg mSeq, m; mSeq[2]}); + sectionDurs = seq.collect({arg mSeq; mSeq.flatten2(mSeq.maxDepth - 5).flop[1].sum}); + res = Ppar( + voices.flop.collect({arg voice; + var clumps, hdScores, freqs, fDurs; + clumps = voice.separate({arg a, b; a != b }); + freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); + fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - [ Pbind( - \instrument, \string_model, + \instrument, \test, \group, group, \freq, Pseq(freqs, 1), \dur, Pseq(fDurs, 1), - \attack, Pseq(attacks, 1), - \sustain, Pseq(fDurs, 1), - \release, Pseq(rels, 1), - //\amp, Pseq(amps, 1), - \amp, Pbrown(0.5, 1, 0.5), - \busIndex, v - ), - Pbind( - \instrument, \sine, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \sustain, Pseq(fDurs, 1), - \busIndex, v + \sustain, Pseq(fDurs, 1) ) - ] - }).flatten; - if(oneShot.not, { - msg = inSeq.collect({arg mSeq, m; mSeq[1..]}); - //ids = inSeq.collect({arg mSeq, m; mSeq[2]}); - sectionDurs = seq.collect({arg mSeq; mSeq.flatten2(mSeq.maxDepth - 5).flop[1].sum}); - pbinds = pbinds ++ + }) ++ [ Pbind( \type, \osc, \addr, addr, + //\indexPath, "/cur_play_index", + //\indexMsg, Pseq(indices, 1), + //\seqPath, "/mus_seq", + //\seqMsg, Pseq(seq, 1), \path, "/playing", \msg, Pseq(msg, 1), \dur, Pseq(sectionDurs, 1) ); ] - }); - res = Ppar(pbinds); + ); res }; @@ -540,15 +497,44 @@ msgInterpret = {arg in, escapeDoubleQuotes = true, escapeSingleQuotes = true; res = res.replace("Rest", "\"Rest\""); res = res.interpret; }, { - var tmpRes; - if(res.every({arg char; char.isDecDigit}), {tmpRes = res.asInteger}); - if(res.contains("."), {tmpRes = res.asFloat}); - if(tmpRes != nil, {res = tmpRes}); + //res.postln; + if(res.every({arg char; char.isDecDigit}), {res = res.asInteger}); }); }); res }; +/* +writeResources = {arg path; + var file, modelItems, resString; + file = File(path,"w"); + + modelItems = [ + seq, lastXChanges, + curUID, refUID, orderSeed, durSeed, motifSeed, + entrancesProbVals, passagesProbVals, exitsProbVals, + ranges, passagesWeights, orders, susWeights, orderSize, passagesSize, + motifEdited, orderEdited + ]; + + resString = [nameSpaces, modelItems].flop.collect({arg item; + var nameSpace, modelItem, depth = 0, insert = " "; + # nameSpace, modelItem = item; + if(nameSpace == "music_data", {depth = 3; insert = "\n"}); + if(nameSpace == "last_changes", {depth = 1; insert = "\n"}); + if(nameSpace == "order", {depth = 1; insert = "\n"}); + if((nameSpace == "ref_uid") && (modelItem == nil), {modelItem = "nil"}); + "\"" ++ nameSpace ++ "\":" ++ insert ++ stringifyToDepth.value(modelItem, depth) + }).join(",\n"); + + resString = "{\n" ++ resString ++ "\n}"; + + file.write(resString); + file.close; + resString +}; +*/ + writeResources = {arg path, dict; var file, modelItems, resString; file = File(path,"w"); @@ -557,8 +543,7 @@ writeResources = {arg path, dict; seq, lastXChanges, curUID, refUID, orderSeed, durSeed, motifSeed, entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, + ranges, passagesWeights, orders, susWeights, orderSize, passagesSize, motifEdited, orderEdited ]; @@ -582,20 +567,17 @@ loadModelFile = {arg path; loadModelJSON.value(File(path, "r").readAllString.par loadModelJSON = {arg jsonObject; var dict; + //model = File(path, "r").readAllString.parseJSON; dict = Dictionary.with(*nameSpaces.collect({arg nS; nS->msgInterpret.value(jsonObject[nS])})); dict }; -setGlobalVars = {arg dict, skipLastXChanges = false; - var tmpLastXChanges; - tmpLastXChanges = lastXChanges.deepCopy; +setGlobalVars = {arg dict; // order really matters!!!! # seq, lastXChanges, curUID, refUID, orderSeed, durSeed, motifSeed, entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, + ranges, passagesWeights, orders, susWeights, orderSize, passagesSize, motifEdited, orderEdited = nameSpaces.collect({arg nS; dict[nS]}); - if(skipLastXChanges, {lastXChanges = tmpLastXChanges}); dict }; @@ -606,8 +588,7 @@ globalVarsToDict = { seq, lastXChanges, curUID, refUID, orderSeed, durSeed, motifSeed, entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, + ranges, passagesWeights, orders, susWeights, orderSize, passagesSize, motifEdited, orderEdited ]; dict = Dictionary.with(*nameSpaces.collect({arg nS, n; nS->modelItems[n]})); @@ -620,13 +601,6 @@ loadLedgerFile = {arg path; loadLedgerJSON = {arg jsonObject; ledger = jsonObject["ledger"]}; -saveLedger = {arg ledger, path; - var file; - file = File(path, "w"); - file.write("{\n\"ledger\":\n" ++ stringifyToDepth.value(ledger, 1) ++ "\n}"); - file.close; -}; - //------global vars primes = [[2, 1], [3, 2], [5, 4], [7, 4], [11, 8], [13, 8]]; @@ -638,7 +612,6 @@ dims = primes.size; tuples = genTuples.value(); //refUID = nil; group = Group.new; -~group = group; loadLedgerFile.value(dir +/+ ".." +/+ "resources" +/+ "piece_ledger.json"); //passagesWeights = [1, 1, 1, 1, 1]; //susWeights = [1, 1, 1]; @@ -646,8 +619,7 @@ loadLedgerFile.value(dir +/+ ".." +/+ "resources" +/+ "piece_ledger.json"); nameSpaces = [ "music_data", "last_changes", "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", - "ranges", "step_probs_vals", "passages_weights", "hd_exp", "hd_invert", - "order", "sus_weights", "order_size", "passages_size", + "ranges", "passages_weights", "order", "sus_weights", "order_size", "passages_size", "motif_edited", "order_edited" ]; @@ -664,13 +636,6 @@ OSCdef(\load_model, {arg msg, time, addr, port; setGlobalVars.value(dict); }, \load_model); -OSCdef(\save_ledger, {arg msg, time, addr, port; - msg.postln; - ledger = msgInterpret.value(msg[1].asString.parseJSON["ledger"], false).postln; - //loadLedgerJSON.value(msg[0]) - saveLedger.value(ledger, msg[2].asString); - //loadLedgerFile.value(msg[1].asString); -}, \save_ledger); OSCdef(\generate, {arg msg, time, addr, port; var path, dict, durSeeds, musPath, modelString; @@ -679,7 +644,7 @@ OSCdef(\generate, {arg msg, time, addr, port; path = msg[1].asString; dict = loadModelFile.value(path); - setGlobalVars.value(dict, true); + setGlobalVars.value(dict); popSize = ranges.size; @@ -689,16 +654,14 @@ OSCdef(\generate, {arg msg, time, addr, port; if(ledger == nil, {ledger = ["tmp"]}); if(ledger.last != "tmp", {ledger = ledger.add("tmp")}); - if(refUID == nil, {lastXChanges = [initVoices.value().deepCopy]}); - if((refUID != nil) && (refUID != "tmp"), { + lastXChanges = if(refUID == nil, { + [initVoices.value().deepCopy]; + }, { var file; file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - lastXChanges = msgInterpret.value(file.readAllString.parseJSON["last_changes"]); + msgInterpret.value(file.readAllString.parseJSON["last_changes"]); }); - refUID.postln; - lastXChanges.collect({arg item; item.postln}); - durSeeds = seedFunc.value({3.collect({rrand(100000, 999999)})}, durSeed).value.postln; entrancesDurFunc = genDurFunc.valueArray(entrancesProbVals[..4] ++ [entrancesProbVals[5..]] ++ [durSeeds[0]]); passagesDurFunc = genDurFunc.valueArray(passagesProbVals[..4] ++ [passagesProbVals[5..]] ++ [durSeeds[1]]); @@ -708,19 +671,13 @@ OSCdef(\generate, {arg msg, time, addr, port; orders = seedFunc.value(genOrders, orderSeed).valueArray(orderSize ++ passagesSize); //addr.sendMsg("/order", stringifyToDepth.value(orders, 1)); }); - - stepFunc = genStepFunc.valueArray(stepProbsVals[..1] ++ [stepProbsVals[2..]] ++ [motifSeed]); seq = seedFunc.value(genMotif, motifSeed).value; - lastXChanges.collect({arg item; item.postln}); - dict = globalVarsToDict.value; modelString = writeResources.value(path, dict); //addr.sendMsg("/generated", musPath, stringifyToDepth.value(seq, 3)); - //~seq = seq; - - addr.sendMsg("/generated", path, modelString, ledgerPath); + addr.sendMsg("/generated", path, modelString); }, \generate); @@ -737,6 +694,7 @@ OSCdef(\commit, {arg msg, time, addr, port; */ musicData = loadModelJSON.value(msg[1].asString.parseJSON)["music_data"].postln; + dict.postln; musicChanged = (musicData != seq).postln; curUID = genUID.value; @@ -746,11 +704,7 @@ OSCdef(\commit, {arg msg, time, addr, port; modelPath = (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_mus_model" ++ ".json").standardizePath; dict = globalVarsToDict.value; - if(musicChanged, { - seq = musicData; - dict["music_data"] = seq; - dict["motif_edited"] = "true" - }); + if(musicChanged, {dict["motif_edited"] = "true"}); dict["cur_uid"] = curUID; writeResources.value(modelPath, dict); @@ -758,9 +712,10 @@ OSCdef(\commit, {arg msg, time, addr, port; File.delete(ledgerPath ++ "_bak"); File.copy(ledgerPath, ledgerPath ++ "_bak"); File.delete(ledgerPath); + newLedger = File(ledgerPath, "w"); ledger = ledger.drop(-1).add(curUID); - - saveLedger.value(ledger, ledgerPath); + newLedger.write("{\n\"ledger\":\n" ++ stringifyToDepth.value(ledger, 1) ++ "\n}"); + newLedger.close; addr.sendMsg("/committed", curUID, ledgerPath); //refUID = curUID; @@ -770,125 +725,25 @@ OSCdef(\commit, {arg msg, time, addr, port; OSCdef(\transport, {arg msg, time, addr, port; msg.postln; if(msg[1] == 0, { - group.set(\release, 2); - group.set(\gate, 0); player.stop; + group.set(\gate, 0); }, { // the cued sequence can now be read from file, so this can be cleaned up var cSize, patterns, pSeq, cuedSeek, indexStart, indexEnd, tmpLedger; - if(msg[1] == 1, { - pSeq = []; - cuedSeek = (seq != nil); - indexStart = msg[2].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.postln.parseJSON["music_data"]), path, indexStart + index, uid]); - file.close; - }); - }); - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - patterns = genPatterns.value(pSeq, addr); - }, { - pSeq = [loadModelJSON.value(msg[2].asString.parseJSON)["music_data"].postln]; - patterns = genPatterns.value(pSeq, addr, true); - }); - player = Pfset(pattern: patterns, cleanupFunc: { - addr.sendMsg("/transport", 0); - addr.sendMsg("/one_shot", 0); - }); - player = player.play - }); -}, \transport); - - -OSCdef(\transcribe_motif, {arg msg, time, addr, port; - var tSeq, refChord, refUID; - - msg.postln; - - tSeq = [loadModelJSON.value(msg[1].asString.parseJSON)["music_data"]]; - refUID = msg[2].asString.postln; - - if((refUID != "nil") && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }, { - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - }); - - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "lilypond" +/+ "includes").standardizePath, addr, "/transcribe_motif"); -}, \transcribe_motif); - - -OSCdef(\transcribe_all, {arg msg, time, addr, port; - var cSize, patterns, cuedSeek, indexStart, indexEnd, tmpLedger; - if(true, { + pSeq = []; cuedSeek = (seq != nil); - indexStart = msg[1].asInteger; + indexStart = msg[2].asInteger; indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - - //tmp for testing transcription - indexEnd = (indexStart+5); - //ledger.postln; if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - var lilyPartLedgerFiles; - - lilyPartLedgerFiles = 4.collect({arg p; - File((dir +/+ ".." +/+ "lilypond" +/+ "includes" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly").standardizePath, "w"); - }); - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file, fileString, tSeq, refUID, refChord; + var path, file; path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; file = File(path, "r"); - fileString = file.readAllString; - tSeq = msgInterpret.value(fileString.parseJSON["music_data"]); - refUID = msgInterpret.value(fileString.parseJSON["ref_uid"]); + pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, indexStart + index, uid]); file.close; - - //uid.postln; - //(refUID == "nil").postln; - - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - - if(refUID != "nil", { - path = (dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }); - - if(index != indexEnd, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath); - }, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath, addr, "/transcribe_all"); - }); - - lilyPartLedgerFiles.do({arg f, p; - f.write("\\include \".." +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly\"\n"); - }); - - }); - - lilyPartLedgerFiles.do({arg f; - f.close }); }); - /* if(cuedSeek, { var path, file; path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; @@ -896,121 +751,30 @@ OSCdef(\transcribe_all, {arg msg, time, addr, port; pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); file.close; }); - */ - }, { - + patterns = genPatterns.value(pSeq, addr); + player = Pfset(pattern: patterns, cleanupFunc: { + addr.sendMsg("/transport", 0); + }); + player = player.play }); - -}, \transcribe_all); +}, \transport); ) -~transcribe.value(~seq, dir); - ( -//synthdefs -~stringModelBusArray = 4.collect({Bus.audio(s, 1)}); -~sineBusArray = 4.collect({Bus.audio(s, 1)}); -~bassBusArray = 1.collect({Bus.audio(s, 1)}); -~hdustBusArray = 1.collect({Bus.audio(s, 1)}); -~samplerBusArray = 2.collect({Bus.audio(s, 1)}); -~sBuf = Buffer.alloc(s, 10, 2); -SynthDef(\string_model, {arg freq, gate = 1, sustain, amp, dur, attack, release = 1, busIndex = 0; +SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; var trig, exc, sig1, sig2, noHarms; - noHarms = rrand(20, 40); + noHarms = 30; exc = Saw.ar(freq, TRand.ar(0.5, 1, Impulse.ar(freq))) * 0.001 + Dust.ar(10000, 0.01); sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.8).softclip; - //sig1 = HPF.ar(sig1, 300); - Out.ar(Select.kr(busIndex, ~stringModelBusArray), sig1 * amp * EnvGen.kr(Env.adsr(attack, 0.3, 0.9, release, 0.9, -3), gate, doneAction: 2)); + Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.5).softclip; + sig1 = HPF.ar(sig1, 300); + Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); //Out.ar([0, 1], sig1 * EnvGen.kr(Env.asr(dur, 0.3, 1), gate, doneAction: 2)); }).add; - -SynthDef(\sine, {arg freq, gate = 1, sustain, amp, dur, busIndex = 0; - var sig; - sig = SinOsc.ar(freq); - Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.asr(0.3, 0.4, 0.3), gate, timeScale: dur, doneAction: 2)); - //Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.sine(dur), gate, doneAction: 2)); -}).add; - -SynthDef(\mixer, {arg freq, gate = 1, sustain, amp, dur, out; - var nameSpaces, sigs; - - sigs = [~stringModelBusArray, ~sineBusArray/*, ~bassBusArray, ~hdustBusArray, ~samplerBusArray*/].collect({arg busArray, i; - var nameSpace, sig; - nameSpace = ['string', 'sine', 'bass', 'hdust', 'sampler'][i]; - sig = busArray.collect({arg bus, c; In.ar(bus, 1) * NamedControl.kr(\ ++ nameSpace ++ '_volume_' ++ c, 1, 0.1)}); - sig = sig.collect({arg channel, c; Pan2.ar(channel, NamedControl.kr(\ ++ nameSpace ++ '_pan_' ++ c, i / (busArray.size - 1), 0.1) * 2 - 1)}); - sig = sig.collect({arg channel, c; channel * NamedControl.kr(\ ++ nameSpace ++ '_mute_' ++ c, 1, 0.1)}); - sig = Mix.ar(sig) * pow(NamedControl.kr(\ ++ nameSpace ++ '_volume_master', 1, 0.1), 2); - }); - - sigs = Mix.ar(sigs / 4); - Out.ar(0, sigs) -}).add; - -SynthDef(\bass, { - var switches, drone; - switches = {|i| Dust.kr(0.1)} ! 9; - drone = {|i| var harm = pow(2, 2 - (i / 3).trunc), amp = (1 / pow(harm, 2)); - SinOsc.ar(60 * harm + TRand.kr(-3, 3, switches[i]), 0, amp)} ! 9; - Out.ar(~bassBusArray[0], Mix.new(drone) * 0.2); -}).add; - -SynthDef(\sampler, { - Out.ar(~samplerBusArray, PlayBuf.ar(2, ~sBuf, BufRateScale.kr(~sBuf), doneAction: 2)) -}).add; - -// main routine -SynthDef(\hdust, { - arg gate = 0; - var hierarchical_dust, low_sine, high_sine, brown_noise, white_noise; - // this triggers the combinations of sources - // it is similar to the Supercollider UGen called dust but with a hierarchical structure - hierarchical_dust = ( - TIRand.kr(0, 1, Impulse.kr(100)) * - TIRand.kr(0, 1, Impulse.kr(10)) * - TIRand.kr(0, 1, Impulse.kr(1)) * - TIRand.kr(0, 1, Impulse.kr(0.1)) - ); - // adjust the multiplier at the end of each line for adjusting levels - // note with each trigger, each source has a 1 in 3 chance of sounding - low_sine = SinOsc.ar(76.midicps / 16) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.1; - high_sine = SinOsc.ar(76.midicps * 8) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.01; - brown_noise = BrownNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.025; - white_noise = WhiteNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.02; - Out.ar(~hdustBusArray[0], - ((low_sine + high_sine + brown_noise + white_noise) ) - ); -}).add; - -) - -( -var bass, hdust, sampler, mixer; -/* -bass = Synth.tail(~group, \bass); -hdust = Synth.tail(~group, \hdust); -sampler = Synth.head(~group, \sampler); -*/ -mixer = Synth.tail(~group, \mixer); - -OSCdef(\mixer, {arg msg, time, addr, port; - mixer.set((msg[1] ++ '_' ++ msg[2] ++ '_' ++ msg[3]), msg[4]) -}, \mixer); - -/* -OSCdef(\sampler, {arg msg, time, addr, port; - msg.postln; - sampler.free; - ~sBuf.free; - ~sBuf = Buffer.read(s, msg[1].asString.postln, action: {sampler = Synth.head(~group, \sampler)}); -}, \sampler); -*/ ) -/* old something ( SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; var trig, exc, sig1, sig2, noHarms, freqFinal, start, end; @@ -1029,5 +793,16 @@ SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); }).add; ) -*/ + + +"{\"a\": 1}".parseYAML["a"].asInteger; +"{\"a\": 1}".parseJSON["a"].isNumber; + +1223423434123.asHexString.toLower + +Date.getDate.rawSeconds +Date.seed.asHexString.toLower + +n = NetAddr("localhost", 8080); +n.sendMsg("/GET/#", (NetAddr.localAddr.hostname ++ ":" ++ NetAddr.localAddr.port), "/passage_probs_vals"); \ No newline at end of file diff --git a/resources/piece_ledger_pas/6abf27d4/6abf27d4_mus_model.json b/resources/piece_ledger_pas/6abf27d4/6abf27d4_mus_model.json new file mode 100644 index 0000000..818ccbc --- /dev/null +++ b/resources/piece_ledger_pas/6abf27d4/6abf27d4_mus_model.json @@ -0,0 +1,93 @@ +{ +"music_data": +[ + [ + [ + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 0 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ] ], 0 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], 8.375 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ -1, 0, 0, 0, 0,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 0 ], [ -1, 1, 0, 0, 1, -1 ], [ -1, 1, 0, 0, 2, 0 ] ], 9.75 ] + ], + [ + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ -1, 1, 0, 0, 1, -1 ], [ -1, 1, 0, 0, 2, 0 ] ], 0 ], + [ [ [ "Rest" ], [ "Rest" ], [ -1, 1, 0, 0, 1, -1 ], [ -1, 1, 0, 0, 2, 0 ] ], 1.25 ], + [ [ [ "Rest" ], [ "Rest" ], [ -3, 1, 0, 0, 2, 1 ], [ -1, 1, 0, 0, 2, 0 ] ], 1.875 ], + [ [ [ "Rest" ], [ "Rest" ], [ -3, 2, 0, 0, 2, 0 ], [ -1, 1, 0, 0, 2, 0 ] ], 1.25 ], + [ [ [ "Rest" ], [ "Rest" ], [ -2, 1, -1, 0, 2, 0 ], [ -1, 1, 0, 0, 2, 0 ] ], 2 ], + [ [ [ "Rest" ], [ "Rest" ], [ -3, 1, 0, 1, 2, 0 ], [ -1, 1, 0, 0, 2, 0 ] ], 7.625 ], + [ [ [ "Rest" ], [ "Rest" ], [ -3, 1, 0, 1, 2, 0 ], [ "Rest" ] ], 1 ], + [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 8.375 ] + ] + ] +], +"last_changes": +[ + [ [ 0, 0, 0, 0, 0, 0 ], [ -2, 1, 0, 0, 1, 0 ], [ -1, 1, 0, 0, 1, -1 ], [ -1, 1, 0, 0, 2, 0 ] ], + [ [ 0, 0, 0, 0, 0, 0 ], [ -2, 1, 0, 0, 1, 0 ], [ -3, 1, 0, 0, 2, 1 ], [ -1, 1, 0, 0, 2, 0 ] ], + [ [ 0, 0, 0, 0, 0, 0 ], [ -2, 1, 0, 0, 1, 0 ], [ -3, 2, 0, 0, 2, 0 ], [ -1, 1, 0, 0, 2, 0 ] ], + [ [ 0, 0, 0, 0, 0, 0 ], [ -2, 1, 0, 0, 1, 0 ], [ -2, 1, -1, 0, 2, 0 ], [ -1, 1, 0, 0, 2, 0 ] ], + [ [ 0, 0, 0, 0, 0, 0 ], [ -2, 1, 0, 0, 1, 0 ], [ -3, 1, 0, 1, 2, 0 ], [ -1, 1, 0, 0, 2, 0 ] ] +], +"cur_uid": "6abf27d4", +"ref_uid": "nil", +"order_seed": 587621, +"dur_seed": 706606, +"motifs_seed": 392608, +"entrances_probs_vals": [ 0.34, 6.468253968254, 9.2857142857143, 0.5, 2, 0, 0.5, 0.24509803921569, 0.89189189189189, 0.5, 1, 0.5, 0.5, 0.8562091503268, 0.69932432432432, 1, 0.5 ], +"passages_probs_vals": [ 0.34, 6.468253968254, 9.2857142857143, 0.5, 2, 0, 0.5, 0.24509803921569, 0.89189189189189, 0.5, 1, 0.5, 0.5, 0.8562091503268, 0.69932432432432, 1, 0.5 ], +"exits_probs_vals": [ 0.34, 6.468253968254, 9.2857142857143, 0.5, 2, 0, 0.5, 0.24509803921569, 0.89189189189189, 0.5, 1, 0.5, 0.5, 0.8562091503268, 0.69932432432432, 1, 0.5 ], +"ranges": [ [ -1200, 2400 ], [ -1200, 2400 ], [ -1200, 2400 ], [ -1200, 2400 ] ], +"passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], +"order": +[ + [ [ 0, 2, 3 ], [ 1, 1, 1, 1, 1 ], [ ] ], + [ [ 0 ], [ 3, 2, 1, 1, 3, 2, 3, 2, 1, 2 ], [ ] ], + [ [ 0, 3, 2 ], [ 1, 1, 1, 1, 1, 1 ], [ ] ], + [ [ 1, 2, 0 ], [ 3, 3, 3, 3, 3 ], [ ] ], + [ [ 1, 3, 0 ], [ 2, 2, 2, 2, 2 ], [ ] ], + [ [ 3 ], [ 2, 2, 2, 2 ], [ 1, 0 ] ] +], +"sus_weights": [ 0.75, 0.75, 0.75 ], +"order_size": [ 1, 10 ], +"passages_size": [ 0, 10 ], +"motif_edited": "false", +"order_edited": "false" +} \ No newline at end of file diff --git a/resources/6d0c2f19/6d0c2f19_code.scd b/resources/piece_ledger_pas/6d0c2f19/6d0c2f19_code.scd similarity index 100% rename from resources/6d0c2f19/6d0c2f19_code.scd rename to resources/piece_ledger_pas/6d0c2f19/6d0c2f19_code.scd diff --git a/resources/6d0c2f19/6d0c2f19_mus_model.json b/resources/piece_ledger_pas/6d0c2f19/6d0c2f19_mus_model.json similarity index 100% rename from resources/6d0c2f19/6d0c2f19_mus_model.json rename to resources/piece_ledger_pas/6d0c2f19/6d0c2f19_mus_model.json diff --git a/resources/6d743c5c/6d743c5c_code.scd b/resources/piece_ledger_pas/6d743c5c/6d743c5c_code.scd similarity index 100% rename from resources/6d743c5c/6d743c5c_code.scd rename to resources/piece_ledger_pas/6d743c5c/6d743c5c_code.scd diff --git a/resources/6d743c5c/6d743c5c_mus_model.json b/resources/piece_ledger_pas/6d743c5c/6d743c5c_mus_model.json similarity index 100% rename from resources/6d743c5c/6d743c5c_mus_model.json rename to resources/piece_ledger_pas/6d743c5c/6d743c5c_mus_model.json diff --git a/resources/6f1305ed/6f1305ed_code.scd b/resources/piece_ledger_pas/6f1305ed/6f1305ed_code.scd similarity index 100% rename from resources/6f1305ed/6f1305ed_code.scd rename to resources/piece_ledger_pas/6f1305ed/6f1305ed_code.scd diff --git a/resources/6f1305ed/6f1305ed_mus_model.json b/resources/piece_ledger_pas/6f1305ed/6f1305ed_mus_model.json similarity index 100% rename from resources/6f1305ed/6f1305ed_mus_model.json rename to resources/piece_ledger_pas/6f1305ed/6f1305ed_mus_model.json diff --git a/resources/703e109b/703e109b_code.scd b/resources/piece_ledger_pas/703e109b/703e109b_code.scd similarity index 100% rename from resources/703e109b/703e109b_code.scd rename to resources/piece_ledger_pas/703e109b/703e109b_code.scd diff --git a/resources/703e109b/703e109b_mus_model.json b/resources/piece_ledger_pas/703e109b/703e109b_mus_model.json similarity index 100% rename from resources/703e109b/703e109b_mus_model.json rename to resources/piece_ledger_pas/703e109b/703e109b_mus_model.json diff --git a/resources/74faf83f/74faf83f_code.scd b/resources/piece_ledger_pas/74faf83f/74faf83f_code.scd similarity index 100% rename from resources/74faf83f/74faf83f_code.scd rename to resources/piece_ledger_pas/74faf83f/74faf83f_code.scd diff --git a/resources/74faf83f/74faf83f_mus_model.json b/resources/piece_ledger_pas/74faf83f/74faf83f_mus_model.json similarity index 100% rename from resources/74faf83f/74faf83f_mus_model.json rename to resources/piece_ledger_pas/74faf83f/74faf83f_mus_model.json diff --git a/resources/46b6952a/46b6952a_code.scd b/resources/piece_ledger_pas/7ac10d34/7ac10d34_code.scd similarity index 100% rename from resources/46b6952a/46b6952a_code.scd rename to resources/piece_ledger_pas/7ac10d34/7ac10d34_code.scd diff --git a/resources/46b6952a/46b6952a_gui_state.json b/resources/piece_ledger_pas/7ac10d34/7ac10d34_gui_state.json similarity index 99% rename from resources/46b6952a/46b6952a_gui_state.json rename to resources/piece_ledger_pas/7ac10d34/7ac10d34_gui_state.json index ea5446c..84e6edd 100644 --- a/resources/46b6952a/46b6952a_gui_state.json +++ b/resources/piece_ledger_pas/7ac10d34/7ac10d34_gui_state.json @@ -1355,5 +1355,5 @@ 0 ], "ref_uid": "6f1a789f", - "cur_uid": "46b6952a" + "cur_uid": "7ac10d34" } \ No newline at end of file diff --git a/resources/piece_ledger_pas/7ac10d34/7ac10d34_mus_model.json b/resources/piece_ledger_pas/7ac10d34/7ac10d34_mus_model.json new file mode 100644 index 0000000..73f197b --- /dev/null +++ b/resources/piece_ledger_pas/7ac10d34/7ac10d34_mus_model.json @@ -0,0 +1,59 @@ +{ +"music_data": +[ + [ + [ + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 1.375 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 0, 0, 0, 0, 0, 1 ], [ "Rest" ] ], 0.875 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 0, 1, 0, 0, 0, 0 ], [ "Rest" ] ], 0.875 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 0, 0, 0, 0, 1, 0 ],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[ [ [ 2, -1, 0, -2, 0, 0 ], [ 2, -1, 0, -1, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ] ], 1.75 ], + [ [ [ 1, -1, 1, -1, 0, 0 ], [ 2, -1, 0, -1, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ] ], 1.5 ], + [ [ [ 2, -2, 0, -1, 0, 0 ], [ 2, -1, 0, -1, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ] ], 1.25 ], + [ [ [ 2, -2, 0, -1, 0, 0 ], [ 2, -1, 0, -1, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ "Rest" ] ], 0.875 ], + [ [ [ 2, -2, 0, -1, 0, 0 ], [ 2, -1, 0, -1, 0, 0 ], [ "Rest" ], [ "Rest" ] ], 0 ], + [ [ [ 2, -2, 0, -1, 0, 0 ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 0 ], + [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 1.375 ] + ] + ] +], +"last_changes": +[ + [ [ 1, 0, -1, -1, 0, 0 ], [ 2, -1, 0, -1, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ] ], + [ [ 2, -1, 0, -1, 0, -1 ], [ 2, -1, 0, -1, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ] ], + [ [ 2, -1, 0, -2, 0, 0 ], [ 2, -1, 0, -1, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ] ], + [ [ 1, -1, 1, -1, 0, 0 ], [ 2, -1, 0, -1, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ] ], + [ [ 2, -2, 0, -1, 0, 0 ], [ 2, -1, 0, -1, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ] ] +], +"cur_uid": "7ac10d34", +"ref_uid": "46b6952a", +"order_seed": 638872, +"dur_seed": 225879, +"motifs_seed": 992393, +"entrances_probs_vals": [ 0.75, 0.5, 2, 0, 0.5, 0.26424870466321, 0.75675675675676, 0.5, 0.5, 0.58549222797927, 0.72635135135135, 1, 0.5 ], +"passages_probs_vals": [ 0.75, 0.5, 2, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], +"exits_probs_vals": [ 0.75, 0.5, 2, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], +"ranges": [ [ -384, 2400 ], [ -507, 2400 ], [ -282, 2237 ], [ -1200, 2053 ] ], +"passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], +"order": +[ + [ [ 0 ], [ 2, 2, 2, 2, 2, 2, 2 ], [ 3, 1 ] ], + [ [ 1, 2, 3 ], [ 0, 0, 0, 0, 0, 0, 0, 0 ], [ ] ] +], +"sus_weights": [ 0.75, 0.69, 0.75 ], +"order_size": [ 2, 6 ], +"passages_size": [ 0, 10 ] +} \ No newline at end of file diff --git a/resources/7bf874ce/7bf874ce_code.scd b/resources/piece_ledger_pas/7bf874ce/7bf874ce_code.scd similarity index 100% rename from resources/7bf874ce/7bf874ce_code.scd rename to resources/piece_ledger_pas/7bf874ce/7bf874ce_code.scd diff --git a/resources/7bf874ce/7bf874ce_mus_model.json b/resources/piece_ledger_pas/7bf874ce/7bf874ce_mus_model.json similarity index 100% rename from resources/7bf874ce/7bf874ce_mus_model.json rename to resources/piece_ledger_pas/7bf874ce/7bf874ce_mus_model.json diff --git a/resources/7c7a96a2/7c7a96a2_code.scd b/resources/piece_ledger_pas/7c7a96a2/7c7a96a2_code.scd similarity index 100% rename from resources/7c7a96a2/7c7a96a2_code.scd rename to resources/piece_ledger_pas/7c7a96a2/7c7a96a2_code.scd diff --git a/resources/7c7a96a2/7c7a96a2_mus_model.json b/resources/piece_ledger_pas/7c7a96a2/7c7a96a2_mus_model.json similarity index 100% rename from resources/7c7a96a2/7c7a96a2_mus_model.json rename to resources/piece_ledger_pas/7c7a96a2/7c7a96a2_mus_model.json diff --git a/resources/7c8bc6df/7c8bc6df_code.scd b/resources/piece_ledger_pas/7c8bc6df/7c8bc6df_code.scd similarity index 100% rename from resources/7c8bc6df/7c8bc6df_code.scd rename to resources/piece_ledger_pas/7c8bc6df/7c8bc6df_code.scd diff --git a/resources/7c8bc6df/7c8bc6df_mus_model.json b/resources/piece_ledger_pas/7c8bc6df/7c8bc6df_mus_model.json similarity index 100% rename from resources/7c8bc6df/7c8bc6df_mus_model.json rename to resources/piece_ledger_pas/7c8bc6df/7c8bc6df_mus_model.json diff --git a/resources/piece_ledger_pas/7e170ef8/7e170ef8_code.scd b/resources/piece_ledger_pas/7e170ef8/7e170ef8_code.scd new file mode 100644 index 0000000..b11446a --- /dev/null +++ b/resources/piece_ledger_pas/7e170ef8/7e170ef8_code.scd @@ -0,0 +1,718 @@ +( +// helper funcs +var hsArrayToCents, pDist, hdSum, hsChordalDistance, hsArrayToFreq; + +// score funcs +var isInRange, spacingScore, rangeScore, intervalScore, inclusionScore; + +// subroutines +var genTuples, initVoices, genOrders, genSubMotif, updateVoices, genDurFunc; + +// primary routines +var genMotif, genSecondarySeq; + +// audition funcs +var genPatterns, genMidiPatterns; + +// resource management funcs +var seedFunc, genUID, writeResources, stringifyToDepth, setSeeds, sanityCheck, +msgInterpret, loadLedgerFile, loadLedgerJSON, loadModelFile, loadModelJSON; + +// model vars +//(model and global vars mostly set by OSC funcs +var curUID, refUID, orderSeed, durSeed, motifSeed, +entrancesProbVals, passagesProbVals, exitsProbVals, +ranges, orders, susWeights, passagesWeights, passagesSize, orderSize; + +// model aux vars +var entrancesDurFunc, passagesDurFunc, exitsDurFunc; + +// other global vars +var lastXChanges, popSize, exPath, dir, primes, dims, tuples, +seq, group, player, ledgerPath, ledger, currentlyPlayingUID; + + +// install JSON quark +if(Quarks.isInstalled("JSONlib").not, { + Quarks.install("https://github.com/musikinformatik/JSONlib.git"); + thisProcess.recompile; + //HelpBrowser.openHelpFor("Classes/JSONlib"); +}); + + +//------helper funcs + +hsArrayToCents = { + arg hsArray; + hsArray.collect({arg dist, p; dist * 1200 * log2(primes[p][0]/primes[p][1])}).sum +}; + +pDist = { + arg array1, array2, signed = false; + var pDistance; + pDistance = hsArrayToCents.value(array1) - hsArrayToCents.value(array2); + if(signed, {pDistance}, {abs(pDistance)}) +}; + +hdSum = { + arg hsArrays; + var size, distances, mean; + size = hsArrays.size; + distances = (size - 1).collect({arg i; + ((i + 1)..(size - 1)).collect({arg j; + abs(hsArrays[i] - hsArrays[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum + }); + }).flat; + mean = distances.sum / distances.size; + distances.sum + //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) +}; + +hsChordalDistance = { + arg hsArrays1, hsArrays2; + var size, distances, mean; + size = hsArrays1.size; + distances = hsArrays1.size.collect({arg i; + hsArrays2.size.collect({arg j; + abs(hsArrays1[i] - hsArrays2[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum + }); + }).flat; + mean = distances.sum / distances.size; + distances.sum + //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) +}; + +hsArrayToFreq = { + arg array; + array.collect({arg dim, d; pow(primes[d][0]/primes[d][1], dim)}).product +}; + +//------score funcs + +/* +isInRange = { + arg hsArray, min, max; + var cents; + cents = hsArrayToCents.value(hsArray); + (cents >= min) && (cents <= max) +}; +*/ + +spacingScore = { + arg hsArrays, min; + var centsArray; + centsArray = hsArrays.collect({arg hsArray; hsArrayToCents.value(hsArray)}).sort({arg a, b; a < b}); + centsArray.differentiate.drop(1).collect({arg pDistance; if(pDistance >= min, {1}, {0.01})}).sum; +}; + +rangeScore = { + arg hsArray1, hsArray2, min, max, low, signed = false; + var pDistance; + pDistance = pDist.value(hsArray1, hsArray2, signed); + if((pDistance >= min) && (pDistance <= max), {1}, {low}); +}; + +intervalScore = { + arg hsArray1, hsArray2, mean, sd, signed = false; + var pDistance; + pDistance = pDist.value(hsArray1, hsArray2, signed); + pDistance.gaussCurve(1, mean, sd) +}; + +inclusionScore = { + arg array, test, min = 0.01; + if(array.collect({arg v; v.hash}).includes(test.hash), {min}, {1}); +}; + + +//------subroutines + +genTuples = { + var tuples; + tuples = dims.collect({[-1, 0, 1]}).allTuples.select({arg tuple; (abs(tuple.drop(1)).sum <= 1) && (tuple[0] == 0)}); + tuples = tuples ++ tuples.collect({arg tuple; [-3, -2, -1, 1, 2, 3].collect({arg octTrans; tuple.deepCopy.put(0, octTrans)})}).flatten; +}; + +initVoices = { + var init, voicesInit; + voicesInit = popSize.collect({dims.collect({0})}); + /* + voicesInit = [dims.collect({0})]; + (popSize - 1).do({ + arg rep, new; + rep = dims.rand; + new = voicesInit.last.deepCopy; + new[rep] = new[rep] + [-1, 1].choose(); + voicesInit = voicesInit.add(new); + }); + */ + voicesInit.deepCopy; +}; + +genDurFunc = {arg chordProb, min, max, envData; + var env, pTable, durFunc; + env = Env.pairs([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).asSignal(256).asList.asArray; + pTable = env.asRandomTable; + durFunc = {arg allowChord; + var res; + res = if(allowChord.not, { + pTable.tableRand * (max - min) + min + }, { + if(1.0.rand < chordProb, {0}, {pTable.tableRand * (max - min) + min}); + }).round(0.125); + if(res.asInteger == res, {res = res.asInteger}); + res + }; + seedFunc.value(durFunc, durSeed); +}; + +genOrders = {arg minMotifLength = 1, maxMotifLength = 5, minProgLength = 0, maxProgLength = 5; + ((maxMotifLength - minMotifLength).rand + minMotifLength).collect({ + var noProgIns, noSusIns, noSilentIns, prog, sus, silent, order; + noSusIns = [1, 2, 3].wchoose(susWeights.normalizeSum); + noProgIns = (popSize - noSusIns).rand + 1; + noSilentIns = popSize - noSusIns - noProgIns; + + # prog, sus, silent = (0..(popSize-1)).scramble.clumps([noProgIns, noSusIns, noSilentIns]); + + prog = (prog.scramble ++ ((maxProgLength - minProgLength).rand + minProgLength).collect({prog.choose}).scramble); + if(silent == nil, {silent = []}); + [sus.scramble, prog, silent.scramble] + }); +}; + +updateVoices = {arg ins, sus; + var voices, candidates, nWeights, nProbs, sel; + + voices = lastXChanges.deepCopy.last; + + candidates = sus.collect({arg v; tuples.collect({arg t; voices[v] + t})}).flatten; + candidates = difference(candidates.asSet, voices.asSet).asList; + nProbs = candidates.collect({arg candidate; + var stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore; + + //stepScore = intervalScore.value(voices[ins], candidate, 30, 400, 0.1); + stepScore = intervalScore.value(voices[ins], candidate, 100, 100); + recentlySoundedScore = inclusionScore.value(lastXChanges.flop[ins], candidate, 0); + isInRangeScore = rangeScore.value(candidate, candidate.collect({0}), ranges[ins][0], ranges[ins][1], 0, true); + regScore = spacingScore.value(voices.deepCopy.put(ins, candidate), 300); + hdScore = 1/pow(hdSum.value(voices.deepCopy.put(ins, candidate)), 2); + //maybe what you want here is a vector to another root and then favoring movement towards it. + //distScore = pow(hsChordalDistance.value(voices, voices.put(ins, candidate)), 2); + + [stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore] + }); + + nWeights = passagesWeights; + + //this handles nWeights of 0; mainly for testing + nProbs = nProbs.flop.select({arg scores, s; nWeights[s] != 0}).flop; + nWeights = nWeights.select({arg weight; weight != 0}); + nProbs = nProbs.flop.collect({arg scores, s; + if(scores.sum == 0, {scores}, {scores.normalizeSum * nWeights[s]}) + }); + nProbs = nProbs.flop.collect({arg scores, s; scores.product}).normalizeSum; + + sel = candidates.wchoose(nProbs); + + voices[ins] = sel; + lastXChanges = lastXChanges.add(voices).keep(-5); +}; + +genSubMotif = {arg order, lastState, repeatLast = false, startFromLast = false, isLastOrder = false; + var sus, prog, silent, flatOrder, res, isInChord, allowChord, lastXChangesHold, voices, adder; + # sus, prog, silent = order; + flatOrder = silent ++ sus ++ prog; + lastXChangesHold = lastXChanges.deepCopy; + voices = lastState.deepCopy; + isInChord = popSize.collect({false}); + allowChord = false; + res = []; + "------generating motif".postln; + //need to figure out here if voices move between motifs + flatOrder.do({arg ins, i; + + if(prog.includes(ins) && repeatLast.not, {updateVoices.value(ins, sus)}); + adder = if(silent.includes(ins), {["Rest"]}, {lastXChanges.last.deepCopy[ins]}); + + if(voices[ins] != adder, { + var dur; + allowChord = if((sus ++ silent).includes(ins), { + (sus ++ silent).includes(ins) && (ins != sus.last); + }, { + if(i < (flatOrder.size - 1), {(isInChord[flatOrder[i + 1]] || (ins == flatOrder[i + 1])).not}, {false}); + }); + dur = passagesDurFunc.value(allowChord); + if(dur == 0, {isInChord[ins] = true}, {isInChord = popSize.collect({false})}); + + voices[ins] = adder; + res = res.add([voices.deepCopy.postln, dur]); + }); + }); + + // pad ending + if(isLastOrder, { + (0..(popSize-1)).scramble.do({arg ins; + if(res.last.first[ins] != ["Rest"], { + var dur; + voices[ins] = ["Rest"]; + allowChord = (voices != popSize.collect({["Rest"]})); + dur = passagesDurFunc.value(allowChord); + res = res.add([voices.deepCopy.postln, dur]); + }); + }); + }); + + //format and return + if(startFromLast, {lastXChanges = lastXChangesHold}); + res; +}; + + +//------primary routines + +genMotif = { + var repeats, fSeq; + + repeats = 1; + fSeq = []; + + repeats.do({arg index; + var motif; + + motif = []; + + orders.do({arg order, o; + var lastState, subMotif; + lastState = if(o == 0, {popSize.collect({["Rest"]})}, {motif.last.last.first}); + subMotif = genSubMotif.value(order, lastState, isLastOrder: o == (orders.size - 1)); + motif = motif.add(subMotif); + + }); + + sanityCheck.value(motif, index); + + fSeq = fSeq.add(motif); + }); + fSeq +}; + +genSecondarySeq = {arg seq; + var curdles, fSeq; + curdles = []; + while({curdles.sum < seq.size}, {curdles = curdles ++ [3.rand + 1]}); + + fSeq = seq.clumps(curdles).collect({arg clump, m; + var repeats, paddedSeq; + + //add rest + paddedSeq = clump.add([[[popSize.collect({["Rest"]}), 0.5.rand]]]); + + //implement repeats + repeats = [0.rand + 1, 1].wchoose([1, 0].normalizeSum); + repeats.collect({paddedSeq}); + }); + fSeq +}; + + +//------audition funcs + +Event.addEventType(\osc, { + if (~addr.postln.notNil) { + ~addr.sendMsg(~indexPath, ~indexMsg); + ~addr.sendMsg(~seqPath, stringifyToDepth.value(~seqMsg, 3)); + //~addr.sendMsg("/STATE/OPEN", (dir.replace("supercollider", "resources") +/+ ~idMsg +/+ ~idMsg ++ "_gui_state" ++ ".state").standardizePath.postln); + }; +}); + +genPatterns = {arg inSeq, addr; + var voices, durs, patterns, res, indices, sectionDurs, ids, seq; + seq = inSeq.collect({arg mSeq; mSeq[0]}); + # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; + indices = inSeq.collect({arg mSeq, m; mSeq[1]}); + ids = inSeq.collect({arg mSeq, m; mSeq[2]}); + sectionDurs = seq.collect({arg mSeq; mSeq.flatten2(mSeq.maxDepth - 5).flop[1].sum}); + res = Ppar( + voices.flop.collect({arg voice; + var clumps, hdScores, freqs, fDurs; + clumps = voice.separate({arg a, b; a != b }); + freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); + fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); + + Pbind( + \instrument, \test, + \group, group, + \freq, Pseq(freqs, 1), + \dur, Pseq(fDurs, 1), + \sustain, Pseq(fDurs, 1) + ) + }) ++ + [ + Pbind( + \type, \osc, + \addr, addr, + \indexPath, "/cur_play_index", + \indexMsg, Pseq(indices.postln, 1), + \seqPath, "/mus_seq", + \seqMsg, Pseq(seq, 1), + \dur, Pseq(sectionDurs, 1) + ); + ] + ); + res +}; + +/* +genMidiPatterns = {arg seq; + var voices, durs, patterns, res, mOut, pbRange; + pbRange = 1; //semitones - change this as needed for your situation + mOut = MIDIOut.newByName("TiMidity", "TiMidity port 0").latency_(Server.default.latency); + # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; + res = Ppar( + voices.flop.collect({arg voice, v; + var clumps, hdScores, freqs, fDurs; + + mOut.program(v, 70); + + clumps = voice.separate({arg a, b; a != b }); + freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); + fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); + + Pbind( + \type, \midi, + \chan, v, + \noteval, Pseq(freqs.cpsmidi - 24, 1), + \note, Pfunc({ | event | event[\noteval].floor }), + \dur, Pseq(fDurs, 1), + \midiout, mOut, + \amp, 1, + \bend, Pfunc({ + | event | + if (event[\note].isRest.not) { + var pitchbendvalue = event[\noteval].frac.linlin(0, pbRange, 8192, 8192*2).asInteger; + m.bend(v, pitchbendvalue); + }; + 0; // return something other than nil to avoid stopping the pattern + }), + ); + }); + ); + res +}; +*/ + + +//------resource management funcs + +genUID = {Date.seed.asHexString.toLower}; + +seedFunc = {arg func, seed; + var funcArgs, next; + next = Routine({loop{func.valueArray(funcArgs).yield }}); + next.randSeed_(seed); + {arg ...args; funcArgs = args; next.value} +}; + +stringifyToDepth = {arg data, maxDepth = 1; + var prettyString = "", rCount = 0, writeArray, indent; + + if(maxDepth == 0, { + data.asCompileString + }, { + indent = {arg size; size.collect({" "}).join("")}; + writeArray = {arg array; + prettyString = prettyString ++ indent.value(rCount) ++ "[\n"; + rCount = rCount + 1; + if(rCount < (maxDepth - 0), { + array.do({arg subArray; writeArray.value(subArray)}); + }, { + prettyString = prettyString ++ array.collect({arg subArray; + indent.value(rCount + 1) ++ subArray.asCompileString + }).join(",\n"); + }); + rCount = rCount - 1; + prettyString = prettyString ++ "\n" ++ indent.value(rCount) ++ "],\n"; + }; + + writeArray.value(data); + prettyString.replace(",\n\n", "\n").drop(-2); + }) +}; + +sanityCheck = {arg motif, index; + //print functions = very helpful + ("----------" + index + "------------").postln; + + motif.flatten.do({arg val, v; + if(v > 0, { + if(motif.flatten[v-1][0].hammingDistance(val[0]) > 1, {"problem 1".postln}); + if(motif.flatten[v-1][0].hammingDistance(val[0]) == 0, {"problem 2".postln}); + }); + val.postln + }); + "***********".postln; +}; + +msgInterpret = {arg in, escapeDoubleQuotes = true, escapeSingleQuotes = true; + var res; + + res = in; + if(res.isNil.not, { + if((res.isArray && res.isString.not), { + res = res.asCompileString; + res = res.replace(" ", "").replace("\n", "").replace("\t", ""); + if(escapeSingleQuotes, {res = res.replace("\'", "")}); + if(escapeDoubleQuotes, {res = res.replace("\"", "")}); + res = res.replace("Rest", "\"Rest\""); + res = res.interpret; + }, { + //res.postln; + if(res.every({arg char; char.isDecDigit}), {res = res.asInteger}); + }); + }); + res +}; + +writeResources = {arg path; + var file, nameSpaces, modelItems, resString; + file = File(path,"w"); + + nameSpaces = [ + "music_data", "last_changes", + "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", + "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", + "ranges", "passages_weights", "order", "sus_weights", "order_size", "passages_size" + ]; + + modelItems = [ + seq, lastXChanges, + curUID, refUID, orderSeed, durSeed, motifSeed, + entrancesProbVals, passagesProbVals, exitsProbVals, + ranges, passagesWeights, orders, susWeights, orderSize, passagesSize + ]; + + resString = [nameSpaces, modelItems].flop.collect({arg item; + var nameSpace, modelItem, depth = 0, insert = " "; + # nameSpace, modelItem = item; + if(nameSpace == "music_data", {depth = 3; insert = "\n"}); + if(nameSpace == "last_changes", {depth = 1; insert = "\n"}); + if(nameSpace == "order", {depth = 1; insert = "\n"}); + "\"" ++ nameSpace ++ "\":" ++ insert ++ stringifyToDepth.value(modelItem.postln, depth).postln + }).join(",\n"); + + resString = "{\n" ++ resString ++ "\n}"; + + file.write(resString); + file.close; +}; + +loadModelFile = {arg path; loadModelJSON.value(File(path, "r").readAllString.parseJSON)}; + +loadModelJSON = {arg model; + var nameSpaces, data; + + //model = File(path, "r").readAllString.parseJSON; + + nameSpaces = [ + "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", + "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", + "ranges", "passages_weights", "order", "sus_weights", "order_size", "passages_size" + ]; + + data = nameSpaces.collect({arg nS; msgInterpret.value(model[nS]).postln}); + + data.postln; + + # curUID, refUID, orderSeed, durSeed, motifSeed, + entrancesProbVals, passagesProbVals, exitsProbVals, + ranges, passagesWeights, orders, susWeights, orderSize, passagesSize = data; + + popSize = ranges.size; +}; + +loadLedgerFile = {arg path; + ledgerPath = path; + loadLedgerJSON.value(File(ledgerPath, "r").readAllString.parseJSON) +}; + +loadLedgerJSON = {arg ledger; ledger = ledger["ledger"]}; + +//------global vars + +primes = [[2, 1], [3, 2], [5, 4], [7, 4], [11, 8], [13, 8]]; +//ranges = [[-2400, 0], [-1200, 1200], [0, 2400], [0, 2400]]; +exPath = thisProcess.nowExecutingPath; +dir = exPath.dirname; +//popSize = 4; +dims = primes.size; +tuples = genTuples.value(); +//refUID = nil; +group = Group.new; +loadLedgerFile.value(dir +/+ ".." +/+ "resources" +/+ "piece_ledger.json"); +//passagesWeights = [1, 1, 1, 1, 1]; +//susWeights = [1, 1, 1]; + + +//------OSC funcs + +OSCdef(\load_ledger, {arg msg, time, addr, port; + loadLedgerFile.value(msg[1].asString); +}, \load_ledger); + +OSCdef(\load_model, {arg msg, time, addr, port; + loadModelFile.value(msg[1].asString); +}, \load_model); + + +OSCdef(\generate, {arg msg, time, addr, port; + var path, dFormat, condition, musPath; + msg.postln; + + path = msg[1].asString; + + loadModelFile.value(path); + + refUID.postln; + + loadLedgerFile.value(ledgerPath); + if(ledger.last != "tmp", {ledger = ledger.add("tmp")}); + + lastXChanges = if(refUID == nil, { + [initVoices.value().deepCopy]; + }, { + var file; + refUID.postln; + file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); + msgInterpret.value(file.readAllString.parseJSON["last_changes"]); + }); + + entrancesDurFunc = genDurFunc.valueArray(entrancesProbVals[..2] ++ [entrancesProbVals[3..]]); + passagesDurFunc = genDurFunc.valueArray(passagesProbVals[..2] ++ [passagesProbVals[3..]]); + exitsDurFunc = genDurFunc.valueArray(exitsProbVals[..2] ++ [exitsProbVals[3..]]); + + if(orders == nil, { + orders = seedFunc.value(genOrders, orderSeed).valueArray(orderSize ++ passagesSize); + addr.sendMsg("/order", stringifyToDepth.value(orders, 1)); + }); + seq = seedFunc.value(genMotif, motifSeed).value; + + //musPath = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; + writeResources.value(path); + + //orders = nil; + //addr.sendMsg("/current_uid", curUID); + //addr.sendMsg("/ledger", prettifyArray.value(ledger, 1).replace("\"", "")); + //addr.sendMsg("/ledger_size", ledger.size); + //addr.sendMsg("/mus_seq", prettifyArray.value(seq, 3)); + addr.sendMsg("/generated", musPath, stringifyToDepth.value(seq, 3)); +}, \generate); + + +OSCdef(\commit, {arg msg, time, addr, port; + var newLedger, modelPath, musString, musFile, test1, test2; + msg.postln; + + /* + test1 = msg[1].asString.parseJSON; + test2 = (dir +/+ ".." +/+ "resources/tmp/tmp_music" ++ ".json").standardizePath.parseJSONFile; + msgInterpret.value(test1["music"])[0][0][0][1].class.postln; + msgInterpret.value(test2["music_data"])[0][0][0][1].class.postln; + (test1["music"] == test2["music_data"]).postln; + */ + + curUID = genUID.value; + File.mkdir((dir +/+ ".." +/+ "resources" +/+ curUID).standardizePath); + File.copy(exPath, (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_code" ++ ".scd").standardizePath); + + modelPath = (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_mus_model" ++ ".json").standardizePath; + writeResources.value(modelPath); + + File.delete(ledgerPath.postln ++ "_bak"); + File.copy(ledgerPath, ledgerPath ++ "_bak"); + File.delete(ledgerPath); + newLedger = File(ledgerPath.postln, "w"); + ledger = ledger.postln.drop(-1).add(curUID); + newLedger.write("{\n\"ledger\":\n" ++ stringifyToDepth.value(ledger, 1) ++ "\n}"); + newLedger.close; + + addr.sendMsg("/committed", curUID, ledgerPath); + //refUID = curUID; +}, \commit); + +OSCdef(\transport, {arg msg, time, addr, port; + msg.postln; + if(msg[1] == 0, { + player.stop; + group.set(\gate, 0); + }, { + // the cued sequence can now be read from file, so this can be cleaned up + var cSize, patterns, pSeq, cuedSeek, indexStart, indexEnd, tmpLedger; + pSeq = []; + cuedSeek = (seq != nil); + indexStart = msg[2].asInteger; + indexEnd = ledger.size - if(cuedSeek, {2}, {1}); + if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { + ledger[indexStart..indexEnd].do({arg uid, index; + var file; + (indexStart + index).postln; + file = File((dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_music" ++ ".json").standardizePath, "r"); + pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), indexStart + index, uid]); + file.close; + }); + }); + if(cuedSeek, {pSeq = pSeq.add([seq, ledger.size - 1])}); + patterns = genPatterns.value(pSeq, addr); + player = Pfset(pattern: patterns, cleanupFunc: { + addr.sendMsg("/transport", 0); + }); + player = player.play + }); +}, \transport); + +) + +( +SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; + var trig, exc, sig1, sig2, noHarms; + noHarms = 30; + exc = Saw.ar(freq, TRand.ar(0.5, 1, Impulse.ar(freq))) * 0.001 + Dust.ar(10000, 0.01); + sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), + Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), + Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.5).softclip; + sig1 = HPF.ar(sig1, 300); + Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); +}).add; +) + +( +SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; + var trig, exc, sig1, sig2, noHarms, freqFinal, start, end; + noHarms = 30; + freq = WhiteNoise.ar * 3 + freq; + freqFinal = Duty.ar((1/freq), 0, freq); + trig = Changed.ar(freqFinal); + start = Demand.ar(trig, 0, Dwhite(-1, -0.75)); + end = Demand.ar(trig, 0, Dwhite(0.75, 1)); + exc = Phasor.ar(trig, (end - start) * freqFinal / SampleRate.ir, start, end, 0) * 0.001 + Dust.ar(10000, 0.01); + + sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), + Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), + Array.fill(noHarms, {rrand(2, 3)}) ], exc) * 0.5).softclip; + sig1 = HPF.ar(sig1, 300); + Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); +}).add; +) + + + +"{\"a\": 1}".parseYAML["a"].asInteger; +"{\"a\": 1}".parseJSON["a"].isNumber; + +1223423434123.asHexString.toLower + +Date.getDate.rawSeconds +Date.seed.asHexString.toLower + +n = NetAddr("localhost", 8080); +n.sendMsg("/GET/#", (NetAddr.localAddr.hostname ++ ":" ++ NetAddr.localAddr.port), "/passage_probs_vals"); \ No newline at end of file diff --git a/resources/piece_ledger_pas/7e170ef8/7e170ef8_gui_state.json b/resources/piece_ledger_pas/7e170ef8/7e170ef8_gui_state.json new file mode 100644 index 0000000..704cf3a --- /dev/null +++ b/resources/piece_ledger_pas/7e170ef8/7e170ef8_gui_state.json @@ -0,0 +1,1359 @@ +{ + "motif_label": "motif", + "seeds_label": "seeds", + "order": "[\n [ [ 3, 1, 0 ], [ 2 ], [ ] ],\n [ [ 1, 2 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 3 ] ],\n [ [ 3, 2 ], [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ], [ 0 ] ],\n [ [ 2, 3 ], [ 0, 1, 0 ], [ ] ]\n]", + "order_lock": 1, + "order_size": [ + 3, + 8 + ], + "order_size_v2": 8, + "order_size_v1": 3, + "order_size_panel": -1, + "passage_size_v2": 8, + "passage_size_v1": 2, + "passage_size_panel": -1, + "sus_weights": [ + null, + null, + null + ], + "range_matrix": [ + null, + null, + null, + null + ], + "instrumentation": [ + 0, + 0 + ], + "entrances_probs_sync": "passages", + "entrances": -1, + "passages_probs_sync": "passages", + "passages": -1, + "exits_probs_sync": "passages", + "exits": -1, + "dur_panel": 0, + "durations": -1, + "passages_weights": [ + null, + null, + null, + null, + null + ], + "weights": -1, + "seeds_tab_panel": 0, + "weights_seed_lock": 0, + "weights_seed": 534103, + "sus_weights/0_slider_val": 0.21, + "sus_weights/0_slider_slider": 0.21, + "sus_weights/0_slider_input": 0.21, + "sus_weights/0_slider_label": 1, + "sus_weights/0_slider": -1, + "sus_weights/1_slider_val": 0.35, + "sus_weights/1_slider_slider": 0.35, + "sus_weights/1_slider_input": 0.35, + "sus_weights/1_slider_label": 2, + "sus_weights/1_slider": -1, + "sus_weights/2_slider_val": 0.21, + "sus_weights/2_slider_slider": 0.21, + "sus_weights/2_slider_input": 0.21, + "sus_weights/2_slider_label": 3, + "sus_weights/2_slider": -1, + "passages_weights/0_slider_val": 0.49, + "passages_weights/0_slider_slider": 0.49, + "passages_weights/0_slider_input": 0.49, + "passages_weights/0_slider_label": "step", + "passages_weights/0_slider": -1, + "passages_weights/1_slider_val": 0.53, + "passages_weights/1_slider_slider": 0.53, + "passages_weights/1_slider_input": 0.53, + "passages_weights/1_slider_label": "dc", + "passages_weights/1_slider": -1, + "passages_weights/2_slider_val": 0.35, + "passages_weights/2_slider_slider": 0.35, + "passages_weights/2_slider_input": 0.35, + "passages_weights/2_slider_label": "range", + "passages_weights/2_slider": -1, + "passages_weights/3_slider_val": 0.59, + "passages_weights/3_slider_slider": 0.59, + "passages_weights/3_slider_input": 0.59, + "passages_weights/3_slider_label": "registration", + "passages_weights/3_slider": -1, + "passages_weights/4_slider_val": 0.39, + "passages_weights/4_slider_slider": 0.39, + "passages_weights/4_slider_input": 0.39, + "passages_weights/4_slider_label": "hd", + "passages_weights/4_slider": -1, + "range_matrix/0_val_input_min": -853.2067988668555, + "range_matrix/0_val_rslider": [ + -853.2067988668555, + 401 + ], + "range_matrix/0_val_input_max": 401, + "range_matrix/0_val": -1, + "range_matrix/1_val_input_min": -659, + "range_matrix/1_val_rslider": [ + -659, + 880 + ], + "range_matrix/1_val_input_max": 880, + "range_matrix/1_val": -1, + "range_matrix/2_val_input_min": -241, + "range_matrix/2_val_rslider": [ + -241, + 1869 + ], + "range_matrix/2_val_input_max": 1869, + "range_matrix/2_val": -1, + "range_matrix/3_val_input_min": -27, + "range_matrix/3_val_rslider": [ + -27, + 2063 + ], + "range_matrix/3_val_input_max": 2063, + "range_matrix/3_val": -1, + "entrances_probs_chord_slider_val": 0.66, + "entrances_probs_chord_slider_slider": 0.66, + "entrances_probs_chord_slider_input": 0.66, + "entrances_probs_chord_slider_label": "chord prob", + "entrances_probs_chord_slider": -1, + "entrances_probs_vals": [ + 0.63, + 0, + 5, + 0, + 0.5, + 0.23316062176165803, + 0.7094594594594594, + 0.3963730569948187, + 0.8716216216216216, + 0.4948186528497409, + 0.5912162162162162, + 0.5362694300518135, + 0.8614864864864865, + 0.6424870466321243, + 0.5912162162162162, + 0.7901554404145078, + 0.8277027027027027, + 1, + 0.5 + ], + "entrances_probs": -1, + "passages_probs_chord_slider_val": 0.63, + "passages_probs_chord_slider_slider": 0.63, + "passages_probs_chord_slider_input": 0.63, + "passages_probs_chord_slider_label": "chord prob", + "passages_probs_chord_slider": -1, + "passages_probs_vals": [ + 0.63, + 0, + 5, + 0, + 0.5, + 0.23316062176165803, + 0.7094594594594594, + 0.3963730569948187, + 0.8716216216216216, + 0.4948186528497409, + 0.5912162162162162, + 0.5362694300518135, + 0.8614864864864865, + 0.6424870466321243, + 0.5912162162162162, + 0.7901554404145078, + 0.8277027027027027, + 1, + 0.5 + ], + "passages_probs": -1, + "exits_probs_chord_slider_val": 0, + "exits_probs_chord_slider_slider": 0, + "exits_probs_chord_slider_input": 0, + "exits_probs_chord_slider_label": "chord prob", + "exits_probs_chord_slider": -1, + "exits_probs_vals": [ + 0, + 0, + 5, + 0, + 0.5, + 0.23316062176165803, + 0.7094594594594594, + 0.4948186528497409, + 0.5912162162162162, + 0.7901554404145078, + 0.8277027027027027, + 1, + 0.5 + ], + "exits_probs": -1, + "step_env_env_vals": [ + 0, + 5, + 0, + 0, + 0, + 0, + 0.14609053497942387, + 0.7613636363636364, + 0.20164609053497942, + 0.26136363636363635, + 0.24279835390946503, + 0.7215909090909092, + 0.39094650205761317, + 0.875, + 0.4567901234567901, + 0.44318181818181823, + 0.5432098765432098, + 0.34659090909090906, + 0.6481481481481481, + 0.8011363636363636, + 0.6810699588477366, + 0.5170454545454546, + 0.8868312757201646, + 0.49431818181818177, + 0.8868312757201646, + 0.49431818181818177 + ], + "step_env_env_canvas": [ + [ + 0, + 0 + ], + [ + 0, + 0 + ], + [ + 0.14609053497942387, + 0.7613636363636364 + ], + [ + 0.20164609053497942, + 0.26136363636363635 + ], + [ + 0.24279835390946503, + 0.7215909090909092 + ], + [ + 0.39094650205761317, + 0.875 + ], + [ + 0.4567901234567901, + 0.44318181818181823 + ], + [ + 0.5432098765432098, + 0.34659090909090906 + ], + [ + 0.6481481481481481, + 0.8011363636363636 + ], + [ + 0.6810699588477366, + 0.5170454545454546 + ], + [ + 0.8868312757201646, + 0.49431818181818177 + ], + [ + 0.8868312757201646, + 0.49431818181818177 + ], + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "step_env_env_size": 12, + "step_env_env_flatten": 0, + "step_env_env_rslider": [ + 0, + 5 + ], + "step_env_env_rslider_v2": 5, + "step_env_env_rslider_v1": 0, + "step_env_env_mpos": "", + "step_env_env": -1, + "entrances_probs_dur_env_vals": [ + 0.515267175572519, + 4.599236641221374, + 0, + 0.5, + 0.2772020725388601, + 0.7972972972972973, + 0.45077720207253885, + 0.8783783783783784, + 0.5, + 0.5, + 0.727979274611399, + 0.45270270270270274, + 0.7357512953367875, + 0.6486486486486487, + 0.8911917098445595, + 0.7905405405405406, + 1, + 0.5 + ], + "entrances_probs_dur_env_canvas": [ + [ + 0, + 0.5 + ], + [ + 0.2772020725388601, + 0.7972972972972973 + ], + [ + 0.45077720207253885, + 0.8783783783783784 + ], + [ + 0.5, + 0.5 + ], + [ + 0.727979274611399, + 0.45270270270270274 + ], + [ + 0.7357512953367875, + 0.6486486486486487 + ], + [ + 0.8911917098445595, + 0.7905405405405406 + ], + [ + 1, + 0.5 + ], + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "entrances_probs_dur_env_size": 8, + "entrances_probs_dur_env_flatten": 0, + "entrances_probs_dur_env_rslider": [ + 0.515267175572519, + 4.599236641221374 + ], + "entrances_probs_dur_env_rslider_v2": 4.599236641221374, + "entrances_probs_dur_env_rslider_v1": 0.515267175572519, + "entrances_probs_dur_env_mpos": "", + "entrances_probs_dur_env": -1, + "passages_probs_dur_env_vals": [ + 0, + 5, + 0, + 0.5, + 0.23316062176165803, + 0.7094594594594594, + 0.3963730569948187, + 0.8716216216216216, + 0.4948186528497409, + 0.5912162162162162, + 0.5362694300518135, + 0.8614864864864865, + 0.6424870466321243, + 0.5912162162162162, + 0.7901554404145078, + 0.8277027027027027, + 1, + 0.5 + ], + "passages_probs_dur_env_canvas": [ + [ + 0, + 0.5 + ], + [ + 0.23316062176165803, + 0.7094594594594594 + ], + [ + 0.3963730569948187, + 0.8716216216216216 + ], + [ + 0.4948186528497409, + 0.5912162162162162 + ], + [ + 0.5362694300518135, + 0.8614864864864865 + ], + [ + 0.6424870466321243, + 0.5912162162162162 + ], + [ + 0.7901554404145078, + 0.8277027027027027 + ], + [ + 1, + 0.5 + ], + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "passages_probs_dur_env_size": 8, + "passages_probs_dur_env_flatten": 0, + "passages_probs_dur_env_rslider": [ + 0, + 5 + ], + "passages_probs_dur_env_rslider_v2": 5, + "passages_probs_dur_env_rslider_v1": 0, + "passages_probs_dur_env_mpos": "", + "passages_probs_dur_env": -1, + "exits_probs_dur_env_vals": [ + 0, + 5, + 0, + 0.5, + 0.5, + 0.5, + 1, + 0.5 + ], + "exits_probs_dur_env_canvas": [ + [ + 0, + 0.5 + ], + [ + 0.5, + 0.5 + ], + [ + 1, + 0.5 + ], + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "exits_probs_dur_env_size": 3, + "exits_probs_dur_env_flatten": 0, + "exits_probs_dur_env_rslider": [ + 0, + 5 + ], + "exits_probs_dur_env_rslider_v2": 5, + "exits_probs_dur_env_rslider_v1": 0, + "exits_probs_dur_env_mpos": "", + "exits_probs_dur_env": -1, + "mus_seq": [ + [ + [ + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + "Rest" + ], + [ + "Rest" + ] + ], + 0 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + "Rest" + ] + ], + 1.75 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.75 + ], + [ + [ + [ + 0, + 1, + -3, + 0, + 2, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0.75 + ], + [ + [ + [ + 1, + 1, + -2, + -2, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0.625 + ], + [ + [ + [ + 1, + 1, + -3, + -1, + 0, + 0 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0.625 + ], + [ + [ + [ + 1, + 0, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.75 + ] + ], + [ + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.75 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 1, + -2, + 0, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.375 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 2, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0.75 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 1, + -2, + -1, + 2, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.75 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 0, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.875 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1 + ] + ], + [ + [ + [ + [ + 1, + 0, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0 + ], + [ + [ + [ + 1, + 0, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 2, + 0, + -3, + -1, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.625 + ], + [ + [ + [ + 1, + 0, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 1, + -1, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.75 + ], + [ + [ + [ + 1, + 0, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 1, + -1, + -1, + 1, + 0 + ], + [ + "Rest" + ] + ], + 0 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 1, + -1, + -1, + 1, + 0 + ], + [ + "Rest" + ] + ], + 1.875 + ], + [ + [ + [ + "Rest" + ], + [ + "Rest" + ], + [ + 0, + 1, + -1, + -1, + 1, + 0 + ], + [ + "Rest" + ] + ], + 0 + ], + [ + [ + [ + "Rest" + ], + [ + "Rest" + ], + [ + "Rest" + ], + [ + "Rest" + ] + ], + 0.875 + ] + ] + ] + ], + "root": [ + 0.20743639921722112, + 0 + ], + "order_seed": 798574, + "dur_seed": 884869, + "passages_size": [ + 0, + 10 + ], + "dur_seed_lock": 1, + "order_seed_lock": 0, + "seeds_panel": -1, + "motif_panel": [ + 0, + 0 + ], + "ref_uid": "6f1a789f", + "cur_uid": "7e170ef8" +} \ No newline at end of file diff --git a/resources/piece_ledger_pas/7e170ef8/7e170ef8_mus_model.json b/resources/piece_ledger_pas/7e170ef8/7e170ef8_mus_model.json new file mode 100644 index 0000000..c9b8807 --- /dev/null +++ b/resources/piece_ledger_pas/7e170ef8/7e170ef8_mus_model.json @@ -0,0 +1,79 @@ +{ +"music_data": +[ + [ + [ + [ [ [ "Rest" ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ] ], 1.75 ], + [ [ [ "Rest" ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 1, 0, 0, 0 ]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est" ] ], 0 ], + [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 1 ] + ] + ] +], +"last_changes": +[ + [ [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 1, 0, -1, 0, 0, 0 ] ], + [ [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 0, 0, 0, 1, 0, 0 ] ], + [ [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 1, 0, 0, 0, 0, 0 ] ], + [ [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 1, -1, 0, 0, 0, 1 ] ], + [ [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ] ] +], +"cur_uid": "7e170ef8", +"ref_uid": "nil", +"order_seed": 142640, +"dur_seed": 629022, +"motifs_seed": 973728, +"entrances_probs_vals": [ 0.75, 0.5, 2, 0, 0.5, 0.26424870466321, 0.75675675675676, 0.5, 0.5, 0.58549222797927, 0.72635135135135, 1, 0.5 ], +"passages_probs_vals": [ 0.75, 0.5, 2, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], +"exits_probs_vals": [ 0.75, 0.5, 2, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], +"ranges": [ [ -384, 2400 ], [ -507, 2400 ], [ -282, 2237 ], [ -1200, 2053 ] ], +"passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], +"order": +[ + [ [ 2 ], [ 3, 1, 3, 3, 3, 1, 1, 3, 3, 1 ], [ 0 ] ], + [ [ 0 ], [ 1, 2, 3, 3, 1, 3, 1, 3 ], [ ] ], + [ [ 0, 3 ], [ 1, 1, 1, 1, 1, 1 ], [ 2 ] ], + [ [ 1, 2, 0 ], [ 3, 3, 3, 3 ], [ ] ] +], +"sus_weights": [ 0.75, 0.69, 0.75 ], +"order_size": [ 2, 6 ], +"passages_size": [ 0, 10 ] +} \ No newline at end of file diff --git a/resources/7fd4d544/7fd4d544_code.scd b/resources/piece_ledger_pas/7fd4d544/7fd4d544_code.scd similarity index 100% rename from resources/7fd4d544/7fd4d544_code.scd rename to resources/piece_ledger_pas/7fd4d544/7fd4d544_code.scd diff --git a/resources/7fd4d544/7fd4d544_mus_model.json b/resources/piece_ledger_pas/7fd4d544/7fd4d544_mus_model.json similarity index 100% rename from resources/7fd4d544/7fd4d544_mus_model.json rename to resources/piece_ledger_pas/7fd4d544/7fd4d544_mus_model.json diff --git a/resources/piece_ledger_sq1_candidates/314s49e1/314s49e1_code.scd b/resources/piece_ledger_sq1_candidates/314s49e1/314s49e1_code.scd new file mode 100644 index 0000000..2d77a32 --- /dev/null +++ b/resources/piece_ledger_sq1_candidates/314s49e1/314s49e1_code.scd @@ -0,0 +1,581 @@ +( +// helper funcs +var hsArrayToCents, pDist, hdSum, hsChordalDistance, hsArrayToFreq; + +// score funcs +var isInRange, spacingScore, rangeScore, intervalScore, inclusionScore; + +// subroutines +var genTuples, initVoices, genOrder, genSubMotif, updateVoices; + +// primary routines +var genMotif, genSecondarySeq; + +// audition funcs +var genPatterns, genMidiPatterns; + +// resource management funcs +var writeResources, prettifyArray, setSeeds, sanityCheck, msgInterpret; + +// global vars (many set by OSC funcs at bottom) +var refSeed, seed, lastXChanges, popSize, exPath, dir, primes, dims, tuples, ranges, durFunc, seq, group, player; + + +//------helper funcs + +hsArrayToCents = { + arg hsArray; + hsArray.collect({arg dist, p; dist * 1200 * log2(primes[p][0]/primes[p][1])}).sum +}; + +pDist = { + arg array1, array2, signed = false; + var pDistance; + pDistance = hsArrayToCents.value(array1) - hsArrayToCents.value(array2); + if(signed, {pDistance}, {abs(pDistance)}) +}; + +hdSum = { + arg hsArrays; + var size, distances, mean; + size = hsArrays.size; + distances = (size - 1).collect({arg i; + ((i + 1)..(size - 1)).collect({arg j; + abs(hsArrays[i] - hsArrays[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum + }); + }).flat; + mean = distances.sum / distances.size; + distances.sum + //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) +}; + +hsChordalDistance = { + arg hsArrays1, hsArrays2; + var size, distances, mean; + size = hsArrays1.size; + distances = hsArrays1.size.collect({arg i; + hsArrays2.size.collect({arg j; + abs(hsArrays1[i] - hsArrays2[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum + }); + }).flat; + mean = distances.sum / distances.size; + distances.sum + //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) +}; + +hsArrayToFreq = { + arg array; + array.collect({arg dim, d; pow(primes[d][0]/primes[d][1], dim)}).product +}; + + +//------score funcs + +/* +isInRange = { + arg hsArray, min, max; + var cents; + cents = hsArrayToCents.value(hsArray); + (cents >= min) && (cents <= max) +}; +*/ + +spacingScore = { + arg hsArrays, min; + var centsArray; + centsArray = hsArrays.collect({arg hsArray; hsArrayToCents.value(hsArray)}).sort({arg a, b; a < b}); + centsArray.differentiate.drop(1).collect({arg pDistance; if(pDistance >= min, {1}, {0.01})}).sum; +}; + +rangeScore = { + arg hsArray1, hsArray2, min, max, low, signed = false; + var pDistance; + pDistance = pDist.value(hsArray1, hsArray2, signed); + if((pDistance >= min) && (pDistance <= max), {1}, {low}); +}; + +intervalScore = { + arg hsArray1, hsArray2, mean, sd, signed = false; + var pDistance; + pDistance = pDist.value(hsArray1, hsArray2, signed); + pDistance.gaussCurve(1, mean, sd) +}; + +inclusionScore = { + arg array, test, min = 0.01; + if(array.collect({arg v; v.hash}).includes(test.hash), {min}, {1}); +}; + + +//------subroutines + +genTuples = { + var tuples; + tuples = dims.collect({[-1, 0, 1]}).allTuples.select({arg tuple; (abs(tuple.drop(1)).sum <= 1) && (tuple[0] == 0)}); + tuples = tuples ++ tuples.collect({arg tuple; [-3, -2, -1, 1, 2, 3].collect({arg octTrans; tuple.deepCopy.put(0, octTrans)})}).flatten; +}; + +initVoices = { + var init, voicesInit; + voicesInit = popSize.collect({dims.collect({0})}); + /* + voicesInit = [dims.collect({0})]; + (popSize - 1).do({ + arg rep, new; + rep = dims.rand; + new = voicesInit.last.deepCopy; + new[rep] = new[rep] + [-1, 1].choose(); + voicesInit = voicesInit.add(new); + }); + */ + voicesInit.deepCopy; +}; + +genOrder = {arg minLength = 0, maxLength = 5; + var noProgIns, noSusIns, noSilentIns, prog, sus, silent, order; + noProgIns = (popSize - 1).rand + 1; + noSusIns = (popSize - noProgIns).rand + 1; + noSilentIns = popSize - noSusIns - noProgIns; + + # prog, sus, silent = (0..(popSize-1)).scramble.clumps([noProgIns, noSusIns, noSilentIns]); + + prog = (prog.scramble ++ ((maxLength - minLength).rand + minLength).collect({prog.choose}).scramble); + if(silent == nil, {silent = []}); + [sus.scramble, prog, silent.scramble] +}; + +updateVoices = {arg ins, sus; + var voices, candidates, nWeights, nProbs, sel; + + voices = lastXChanges.deepCopy.last; + + candidates = sus.collect({arg v; tuples.collect({arg t; voices[v] + t})}).flatten; + candidates = difference(candidates.asSet, voices.asSet).asList; + nProbs = candidates.collect({arg candidate; + var stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore; + + //stepScore = intervalScore.value(voices[ins], candidate, 30, 400, 0.1); + stepScore = intervalScore.value(voices[ins], candidate, 100, 100); + recentlySoundedScore = inclusionScore.value(lastXChanges.flop[ins], candidate, 0); + isInRangeScore = rangeScore.value(candidate, candidate.collect({0}), ranges[ins][0], ranges[ins][1], 0, true); + regScore = spacingScore.value(voices.deepCopy.put(ins, candidate), 300); + hdScore = 1/pow(hdSum.value(voices.deepCopy.put(ins, candidate)), 2); + //maybe what you want here is a vector to another root and then favoring movement towards it. + //distScore = pow(hsChordalDistance.value(voices, voices.put(ins, candidate)), 2); + + [stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore] + }); + + nWeights = [1, 1, 1, 1, 1]; + + //this handles nWeights of 0; mainly for testing + nProbs = nProbs.flop.select({arg scores, s; nWeights[s] != 0}).flop; + nWeights = nWeights.select({arg weight; weight != 0}); + nProbs = nProbs.flop.collect({arg scores, s; + if(scores.sum == 0, {scores}, {scores.normalizeSum * nWeights[s]}) + }); + nProbs = nProbs.flop.collect({arg scores, s; scores.product}).normalizeSum; + + sel = candidates.wchoose(nProbs); + + voices[ins] = sel; + lastXChanges = lastXChanges.add(voices).keep(-5); +}; + +genSubMotif = {arg order, lastState, repeatLast = false, startFromLast = false, isLastOrder = false; + var sus, prog, silent, res, lastIns, lastXChangesHold, voices, adder; + # sus, prog, silent = order; + lastXChangesHold = lastXChanges.deepCopy; + voices = lastState.deepCopy; + lastIns = nil; + res = []; + "------generating motif".postln; + //need to figure out here if voices move between motifs + (silent ++ sus ++ prog).do({arg ins, i; + + if(prog.includes(ins) && repeatLast.not, {updateVoices.value(ins, sus)}); + adder = if(silent.includes(ins), {["Rest"]}, {lastXChanges.last.deepCopy[ins]}); + + if(voices[ins] != adder, { + var dur; + //dur = [durFunc.value(), 0].wchoose([1, 0].normalizeSum); + dur = durFunc.value(lastIns, ins); + voices[ins] = adder; + res = res.add([voices.deepCopy.postln, dur.round(0.125)]); + }); + + lastIns = ins; + }); + + // pad ending + if(isLastOrder, { + (0..(popSize-1)).scramble.do({arg ins; + if(res.last.first[ins] != ["Rest"], { + var dur; + voices[ins] = ["Rest"]; + //dur = [durFunc.value(), 0].wchoose([1, 0].normalizeSum); + dur = durFunc.value(lastIns, ins); + res = res.add([voices.deepCopy.postln, dur.round(0.125)]); + }); + lastIns = ins; + }); + }); + + //format and return + if(startFromLast, {lastXChanges = lastXChangesHold}); + res; +}; + + +//------primary routines + +genMotif = {arg inOrders; + var orders, repeats, fSeq; + + repeats = 1; + fSeq = []; + + repeats.do({arg index; + var motif; + + motif = []; + orders = inOrders; + + orders.do({arg order, o; + var lastState, subMotif; + lastState = if(o == 0, {popSize.collect({["Rest"]})}, {motif.last.last.first}); + subMotif = genSubMotif.value(order, lastState, isLastOrder: o == (orders.size - 1)); + motif = motif.add(subMotif); + + }); + + sanityCheck.value(motif, index); + + fSeq = fSeq.add(motif); + }); + fSeq +}; + +genSecondarySeq = {arg seq; + var curdles, fSeq; + curdles = []; + while({curdles.sum < seq.size}, {curdles = curdles ++ [3.rand + 1]}); + + fSeq = seq.clumps(curdles).collect({arg clump, m; + var repeats, paddedSeq; + + //add rest + paddedSeq = clump.add([[[popSize.collect({["Rest"]}), 0.5.rand]]]); + + //implement repeats + repeats = [0.rand + 1, 1].wchoose([1, 0].normalizeSum); + repeats.collect({paddedSeq}); + }); + fSeq +}; + + +//------audition funcs + +genPatterns = {arg seq; + var voices, durs, patterns, res; + # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; + res = Ppar( + voices.flop.collect({arg voice; + var clumps, hdScores, freqs, fDurs; + clumps = voice.separate({arg a, b; a != b }); + freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); + fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); + + Pbind( + \instrument, \test, + \group, group, + \freq, Pseq(freqs, 1), + \dur, Pseq(fDurs, 1), + \sustain, Pseq(fDurs, 1) + ); + }); + ); + res +}; + +genMidiPatterns = {arg seq; + var voices, durs, patterns, res, mOut, pbRange; + pbRange = 1; //semitones - change this as needed for your situation + mOut = MIDIOut.newByName("TiMidity", "TiMidity port 0").latency_(Server.default.latency); + # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; + res = Ppar( + voices.flop.collect({arg voice, v; + var clumps, hdScores, freqs, fDurs; + + mOut.program(v, 70); + + clumps = voice.separate({arg a, b; a != b }); + freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); + fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); + + Pbind( + \type, \midi, + \chan, v, + \noteval, Pseq(freqs.cpsmidi - 24, 1), + \note, Pfunc({ | event | event[\noteval].floor }), + \dur, Pseq(fDurs, 1), + \midiout, mOut, + \amp, 1, + \bend, Pfunc({ + | event | + if (event[\note].isRest.not) { + var pitchbendvalue = event[\noteval].frac.linlin(0, pbRange, 8192, 8192*2).asInteger; + m.bend(v, pitchbendvalue); + }; + 0; // return something other than nil to avoid stopping the pattern + }), + ); + }); + ); + res +}; + + +//------resource management funcs + +setSeeds = {arg inRefSeed, inSeed; + refSeed = if(inRefSeed.isNumber, {inRefSeed.asInteger}, {nil}); + seed = if(inSeed > 1, {inSeed.asInteger}, {rrand(100000, 999999)}); + thisThread.randSeed = seed; +}; + +prettifyArray = {arg data, finDepth = 1; + var prettyString = "", rCount = 0, writeArray; + + writeArray = {arg array; + var depth, indent; + depth = array.maxDepth; + indent = rCount.collect({" "}).join(""); + prettyString = prettyString ++ indent ++ "[\n"; + rCount = rCount + 1; + if(depth > 5, { + array.do({arg subArray; + writeArray.value(subArray); + }); + }, { + array.do({arg data, d; + prettyString = prettyString ++ indent ++ " " ++ data.asCompileString ++ if(d != (array.size - 1), {",\n"}, {""}); + }); + }); + rCount = rCount - 1; + if(rCount < (finDepth - 1), {prettyString = prettyString.drop((finDepth - 1).neg)}); + //if(rCount == 0, {prettyString = prettyString.drop((finDepth - 1).neg)}); + prettyString = prettyString ++ "\n" ++ indent ++ "]" ++ if(rCount > 0, {",\n"}, {""}); + }; + + writeArray.value(data); + prettyString +}; + +writeResources = {arg seq, path; + var dir, file, resString; + file = File(path,"w"); + + resString = "{\nmusic_data:\n"; + resString = resString ++ prettifyArray.value(seq, 3); + + resString = resString ++ ",\nlast_changes:\n"; + resString = resString ++ prettifyArray.value(lastXChanges, 1); + + resString = resString ++ ",\nseed: " ++ seed ++ ",\nref_seed: " ++ refSeed ++ "\n}"; + + file.write(resString); + file.close; +}; + +sanityCheck = {arg motif, index; + //print functions - very helpful + ("----------" + index + "------------").postln; + + motif.flatten.do({arg val, v; + if(v > 0, { + if(motif.flatten[v-1][0].hammingDistance(val[0]) > 1, {"problem 1".postln}); + if(motif.flatten[v-1][0].hammingDistance(val[0]) == 0, {"problem 2".postln}); + }); + val.postln + }); + "***********".postln; +}; + +msgInterpret = {arg in; + var res; + res = in.asCompileString; + res = res.replace(" ", "").replace("\n", "").replace("\t", ""); + res = res.replace("\'", "").replace("\"", "").replace("Rest", "\"Rest\""); + res.interpret +}; + + +//------global vars + +primes = [[2, 1], [3, 2], [5, 4], [7, 4], [11, 8], [13, 8]]; +ranges = [[-2400, 0], [-1200, 1200], [0, 2400], [0, 2400]]; +exPath = thisProcess.nowExecutingPath; +dir = exPath.dirname; +popSize = 4; +dims = primes.size; +tuples = genTuples.value(); +refSeed = nil; +group = Group.new; + + +//------OSC funcs + +OSCdef(\gen, {arg msg, time, addr, port; + var orders, condition; + msg.postln; + durFunc = nil; + + addr.sendMsg("/STATE/SEND"); + + { + while({durFunc == nil}, {0.1.wait}); + setSeeds.value(msg[1].postln, msg[2]); + + lastXChanges = if(refSeed == nil, { + [initVoices.value().deepCopy]; + }, { + var file; + file = File((dir +/+ "resources" +/+ refSeed ++ "_music" ++ ".json").standardizePath, "r"); + msgInterpret.value(file.readAllString.parseJSON["last_changes"]); + }); + + if(msg.size == 4, { + orders = msgInterpret.value(msg[3]); + }, { + var minLength, maxLength; + minLength = msg[3]; + maxLength = msg[4]; + orders = ((maxLength - minLength).rand + minLength).collect({genOrder.value(msg[5], msg[6])}); + }); + + orders.postln; + seed.postln; + refSeed.postln; + + seq = genMotif.value(orders); + //patterns = genPatterns.value(seq); + addr.sendMsg("/current_seed", seed); + addr.sendMsg("/order", prettifyArray.value(orders, 1)); + addr.sendMsg("/mus_seq", prettifyArray.value(seq, 3)); + }.fork; + +}, \gen); + +OSCdef(\commit, {arg msg, time, addr, port; + var ledgerPath, oldLedger, newLedger, musSeq; + //msg.postln; + seed.postln; + //File.copy(exPath, (dir +/+ "resources" +/+ seed ++ "_code" ++ ".scd").standardizePath); + //addr.sendMsg("/SESSION/SAVE", (dir +/+ "resources" +/+ seed ++ "_gui_session" ++ ".json").standardizePath); + //addr.sendMsg("/STATE/SAVE", (dir +/+ "resources" +/+ seed ++ "_gui_state" ++ ".state").standardizePath); + + writeResources.value(seq, (dir +/+ "resources" +/+ seed ++ "_music" ++ ".json").standardizePath); + + ledgerPath = (dir +/+ "resources" +/+ "piece_ledger" ++ ".json").standardizePath; + oldLedger = File(ledgerPath, "r"); + musSeq = msgInterpret.value(oldLedger.readAllString.parseJSON["ledger"]); + oldLedger.close; + File.delete(ledgerPath ++ "_bak"); + File.copy(ledgerPath, ledgerPath ++ "_bak"); + File.delete(ledgerPath); + newLedger = File(ledgerPath, "w"); + musSeq = musSeq.add(seed); + newLedger.write("{\nledger:\n" ++ prettifyArray.value(musSeq, 1) ++ "\n}"); + newLedger.close; + + //refSeed = seed; +}, \commit); + +OSCdef(\transport, {arg msg, time, addr, port; + msg.postln; + if(msg[1] == 0, { + player.stop; + group.set(\gate, 0); + }, { + var cSize, ledgerPath, ledger, patterns, pSeq; + ledgerPath = (dir +/+ "resources" +/+ "piece_ledger" ++ ".json").standardizePath; + ledger = msgInterpret.value(File(ledgerPath, "r").readAllString.parseJSON["ledger"]); + pSeq = []; + if(msg[2].asString != "all", {ledger = ledger.keep(msg[2].asInteger - 1)}); + ledger.do({arg rSeed; + var file; + file = File((dir +/+ "resources" +/+ rSeed.postln ++ "_music" ++ ".json").standardizePath, "r"); + pSeq = pSeq.add(msgInterpret.value(file.readAllString.parseJSON["music_data"])); + file.close; + }); + pSeq = pSeq.add(seq); + patterns = genPatterns.value(pSeq); + player = Pfset(pattern: patterns, cleanupFunc: { + addr.sendMsg("/transport", 0); + }); + player = player.play + }); +}, \transport); + +OSCdef(\range, {arg msg; + msg.postln; + ranges[msg[1]][msg[2]] = msg[3] +}, \range); + +OSCdef(\dur_probs_env, {arg msg; + var env, pTable, min, max, cProb; + msg.postln; + env = Env.pairs([[0, 0]] ++ msg[4..].clump(2) ++ [[1, 0]]).asSignal(256).asList.asArray; + pTable = env.asRandomTable; + min = msg[1]; + max = msg[2]; + cProb = msg[3]; + durFunc = {arg lIns, cIns; + if(lIns.postln == cIns.postln, { + pTable.tableRand * (max - min) + min + }, { + if(1.0.rand < cProb.postln, {0}, {pTable.tableRand * (max - min) + min}).postln; + }); + }; +}, \dur_probs_env); +) + +( +SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; + var trig, exc, sig1, sig2, noHarms; + noHarms = 30; + exc = Saw.ar(freq, TRand.ar(0.5, 1, Impulse.ar(freq))) * 0.001 + Dust.ar(10000, 0.01); + sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), + Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), + Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.5).softclip; + sig1 = HPF.ar(sig1, 300); + Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); +}).add; +) + +( +SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; + var trig, exc, sig1, sig2, noHarms, freqFinal, start, end; + noHarms = 30; + freq = WhiteNoise.ar * 3 + freq; + freqFinal = Duty.ar((1/freq), 0, freq); + trig = Changed.ar(freqFinal); + start = Demand.ar(trig, 0, Dwhite(-1, -0.75)); + end = Demand.ar(trig, 0, Dwhite(0.75, 1)); + exc = Phasor.ar(trig, (end - start) * freqFinal / SampleRate.ir, start, end, 0) * 0.001 + Dust.ar(10000, 0.01); + + sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), + Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), + Array.fill(noHarms, {rrand(2, 3)}) ], exc) * 0.5).softclip; + sig1 = HPF.ar(sig1, 300); + Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); +}).add; +) + + +File((~dir +/+ "resources" +/+ 517313 ++ "_music" ++ ".json").standardizePath, "r").readAllString.parseJSON["last_changes"].asString.interpret[0][0][0].isNumber + +"{\"a\": 1}".parseYAML["a"].asInteger; +"{\"a\": 1}".parseJSON["a"].isNumber; \ No newline at end of file diff --git a/resources/piece_ledger_sq1_candidates/314s49e1/314s49e1_mus_model.json b/resources/piece_ledger_sq1_candidates/314s49e1/314s49e1_mus_model.json new file mode 100644 index 0000000..c78a753 --- /dev/null +++ b/resources/piece_ledger_sq1_candidates/314s49e1/314s49e1_mus_model.json @@ -0,0 +1,74 @@ +{ +"music_data": +[ + [ + [ + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 0.875 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ] ], 0.625 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, -1 ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ] ], 1.5 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 1, 0, 0, 0 ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ] ], 0.875 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ] ], 0.875 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ 0, 1, 0, 0, 0, 0 ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ] ], 1.0 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 1, 0, 0 ], [ "Rest" ], [ 0, 0, 0,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], [ 0, -1, 0, 0, -1, 1 ] ], 1.125 ], + [ [ [ 1, -1, 0, 1, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 1, -1, -1, 0, -1, 0 ] ], 1.0 ], + [ [ [ 1, 0, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 1, -1, -1, 0, -1, 0 ] ], 0.75 ], + [ [ [ 1, -1, 0, 0, 0, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 1, -1, -1, 0, -1, 0 ] ], 0.625 ], + [ [ [ 1, -1, 0, 0, 0, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 0, -1, 0, 0, 0, 0 ] ], 0.75 ], + [ [ [ 1, -1, 0, 0, 0, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 1, -1, 0, 0, -2, 0 ] ], 1.375 ], + [ [ [ 2, -2, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 1, -1, 0, 0, -2, 0 ] ], 0.875 ], + [ [ [ 2, -2, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 0, -1, 0, 0, -1, 1 ] ], 3.375 ], + [ [ [ 2, -2, 0, 0, -1, 0 ], [ "Rest" ], [ "Rest" ], [ 0, -1, 0, 0, -1, 1 ] ], 1.5 ], + [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ 0, -1, 0, 0, -1, 1 ] ], 1.375 ], + [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 1.0 ] + ] + ] +], +"last_changes": +[ + [ [ 1, -1, 0, 0, 0, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 0, 0, 0, 0, -1, 0 ], [ 1, -1, -1, 0, -1, 0 ] ], + [ [ 1, -1, 0, 0, 0, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 0, 0, 0, 0, -1, 0 ], [ 0, -1, 0, 0, 0, 0 ] ], + [ [ 1, -1, 0, 0, 0, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 0, 0, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -2, 0 ] ], + [ [ 2, -2, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 0, 0, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -2, 0 ] ], + [ [ 2, -2, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 0, 0, 0, 0, -1, 0 ], [ 0, -1, 0, 0, -1, 1 ] ] +], +"ref_uid": "nil" +} \ No newline at end of file diff --git a/resources/4a8a6e53/4a8a6e53_code.scd b/resources/piece_ledger_sq1_candidates/4a8a6e53/4a8a6e53_code.scd similarity index 100% rename from resources/4a8a6e53/4a8a6e53_code.scd rename to resources/piece_ledger_sq1_candidates/4a8a6e53/4a8a6e53_code.scd diff --git a/resources/4a8a6e53/4a8a6e53_mus_model.json b/resources/piece_ledger_sq1_candidates/4a8a6e53/4a8a6e53_mus_model.json similarity index 100% rename from resources/4a8a6e53/4a8a6e53_mus_model.json rename to resources/piece_ledger_sq1_candidates/4a8a6e53/4a8a6e53_mus_model.json diff --git a/resources/piece_ledger_sq1_candidates/4c01589b/4c01589b_code.scd b/resources/piece_ledger_sq1_candidates/4c01589b/4c01589b_code.scd new file mode 100644 index 0000000..b11446a --- /dev/null +++ b/resources/piece_ledger_sq1_candidates/4c01589b/4c01589b_code.scd @@ -0,0 +1,718 @@ +( +// helper funcs +var hsArrayToCents, pDist, hdSum, hsChordalDistance, hsArrayToFreq; + +// score funcs +var isInRange, spacingScore, rangeScore, intervalScore, inclusionScore; + +// subroutines +var genTuples, initVoices, genOrders, genSubMotif, updateVoices, genDurFunc; + +// primary routines +var genMotif, genSecondarySeq; + +// audition funcs +var genPatterns, genMidiPatterns; + +// resource management funcs +var seedFunc, genUID, writeResources, stringifyToDepth, setSeeds, sanityCheck, +msgInterpret, loadLedgerFile, loadLedgerJSON, loadModelFile, loadModelJSON; + +// model vars +//(model and global vars mostly set by OSC funcs +var curUID, refUID, orderSeed, durSeed, motifSeed, +entrancesProbVals, passagesProbVals, exitsProbVals, +ranges, orders, susWeights, passagesWeights, passagesSize, orderSize; + +// model aux vars +var entrancesDurFunc, passagesDurFunc, exitsDurFunc; + +// other global vars +var lastXChanges, popSize, exPath, dir, primes, dims, tuples, +seq, group, player, ledgerPath, ledger, currentlyPlayingUID; + + +// install JSON quark +if(Quarks.isInstalled("JSONlib").not, { + Quarks.install("https://github.com/musikinformatik/JSONlib.git"); + thisProcess.recompile; + //HelpBrowser.openHelpFor("Classes/JSONlib"); +}); + + +//------helper funcs + +hsArrayToCents = { + arg hsArray; + hsArray.collect({arg dist, p; dist * 1200 * log2(primes[p][0]/primes[p][1])}).sum +}; + +pDist = { + arg array1, array2, signed = false; + var pDistance; + pDistance = hsArrayToCents.value(array1) - hsArrayToCents.value(array2); + if(signed, {pDistance}, {abs(pDistance)}) +}; + +hdSum = { + arg hsArrays; + var size, distances, mean; + size = hsArrays.size; + distances = (size - 1).collect({arg i; + ((i + 1)..(size - 1)).collect({arg j; + abs(hsArrays[i] - hsArrays[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum + }); + }).flat; + mean = distances.sum / distances.size; + distances.sum + //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) +}; + +hsChordalDistance = { + arg hsArrays1, hsArrays2; + var size, distances, mean; + size = hsArrays1.size; + distances = hsArrays1.size.collect({arg i; + hsArrays2.size.collect({arg j; + abs(hsArrays1[i] - hsArrays2[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum + }); + }).flat; + mean = distances.sum / distances.size; + distances.sum + //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) +}; + +hsArrayToFreq = { + arg array; + array.collect({arg dim, d; pow(primes[d][0]/primes[d][1], dim)}).product +}; + +//------score funcs + +/* +isInRange = { + arg hsArray, min, max; + var cents; + cents = hsArrayToCents.value(hsArray); + (cents >= min) && (cents <= max) +}; +*/ + +spacingScore = { + arg hsArrays, min; + var centsArray; + centsArray = hsArrays.collect({arg hsArray; hsArrayToCents.value(hsArray)}).sort({arg a, b; a < b}); + centsArray.differentiate.drop(1).collect({arg pDistance; if(pDistance >= min, {1}, {0.01})}).sum; +}; + +rangeScore = { + arg hsArray1, hsArray2, min, max, low, signed = false; + var pDistance; + pDistance = pDist.value(hsArray1, hsArray2, signed); + if((pDistance >= min) && (pDistance <= max), {1}, {low}); +}; + +intervalScore = { + arg hsArray1, hsArray2, mean, sd, signed = false; + var pDistance; + pDistance = pDist.value(hsArray1, hsArray2, signed); + pDistance.gaussCurve(1, mean, sd) +}; + +inclusionScore = { + arg array, test, min = 0.01; + if(array.collect({arg v; v.hash}).includes(test.hash), {min}, {1}); +}; + + +//------subroutines + +genTuples = { + var tuples; + tuples = dims.collect({[-1, 0, 1]}).allTuples.select({arg tuple; (abs(tuple.drop(1)).sum <= 1) && (tuple[0] == 0)}); + tuples = tuples ++ tuples.collect({arg tuple; [-3, -2, -1, 1, 2, 3].collect({arg octTrans; tuple.deepCopy.put(0, octTrans)})}).flatten; +}; + +initVoices = { + var init, voicesInit; + voicesInit = popSize.collect({dims.collect({0})}); + /* + voicesInit = [dims.collect({0})]; + (popSize - 1).do({ + arg rep, new; + rep = dims.rand; + new = voicesInit.last.deepCopy; + new[rep] = new[rep] + [-1, 1].choose(); + voicesInit = voicesInit.add(new); + }); + */ + voicesInit.deepCopy; +}; + +genDurFunc = {arg chordProb, min, max, envData; + var env, pTable, durFunc; + env = Env.pairs([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).asSignal(256).asList.asArray; + pTable = env.asRandomTable; + durFunc = {arg allowChord; + var res; + res = if(allowChord.not, { + pTable.tableRand * (max - min) + min + }, { + if(1.0.rand < chordProb, {0}, {pTable.tableRand * (max - min) + min}); + }).round(0.125); + if(res.asInteger == res, {res = res.asInteger}); + res + }; + seedFunc.value(durFunc, durSeed); +}; + +genOrders = {arg minMotifLength = 1, maxMotifLength = 5, minProgLength = 0, maxProgLength = 5; + ((maxMotifLength - minMotifLength).rand + minMotifLength).collect({ + var noProgIns, noSusIns, noSilentIns, prog, sus, silent, order; + noSusIns = [1, 2, 3].wchoose(susWeights.normalizeSum); + noProgIns = (popSize - noSusIns).rand + 1; + noSilentIns = popSize - noSusIns - noProgIns; + + # prog, sus, silent = (0..(popSize-1)).scramble.clumps([noProgIns, noSusIns, noSilentIns]); + + prog = (prog.scramble ++ ((maxProgLength - minProgLength).rand + minProgLength).collect({prog.choose}).scramble); + if(silent == nil, {silent = []}); + [sus.scramble, prog, silent.scramble] + }); +}; + +updateVoices = {arg ins, sus; + var voices, candidates, nWeights, nProbs, sel; + + voices = lastXChanges.deepCopy.last; + + candidates = sus.collect({arg v; tuples.collect({arg t; voices[v] + t})}).flatten; + candidates = difference(candidates.asSet, voices.asSet).asList; + nProbs = candidates.collect({arg candidate; + var stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore; + + //stepScore = intervalScore.value(voices[ins], candidate, 30, 400, 0.1); + stepScore = intervalScore.value(voices[ins], candidate, 100, 100); + recentlySoundedScore = inclusionScore.value(lastXChanges.flop[ins], candidate, 0); + isInRangeScore = rangeScore.value(candidate, candidate.collect({0}), ranges[ins][0], ranges[ins][1], 0, true); + regScore = spacingScore.value(voices.deepCopy.put(ins, candidate), 300); + hdScore = 1/pow(hdSum.value(voices.deepCopy.put(ins, candidate)), 2); + //maybe what you want here is a vector to another root and then favoring movement towards it. + //distScore = pow(hsChordalDistance.value(voices, voices.put(ins, candidate)), 2); + + [stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore] + }); + + nWeights = passagesWeights; + + //this handles nWeights of 0; mainly for testing + nProbs = nProbs.flop.select({arg scores, s; nWeights[s] != 0}).flop; + nWeights = nWeights.select({arg weight; weight != 0}); + nProbs = nProbs.flop.collect({arg scores, s; + if(scores.sum == 0, {scores}, {scores.normalizeSum * nWeights[s]}) + }); + nProbs = nProbs.flop.collect({arg scores, s; scores.product}).normalizeSum; + + sel = candidates.wchoose(nProbs); + + voices[ins] = sel; + lastXChanges = lastXChanges.add(voices).keep(-5); +}; + +genSubMotif = {arg order, lastState, repeatLast = false, startFromLast = false, isLastOrder = false; + var sus, prog, silent, flatOrder, res, isInChord, allowChord, lastXChangesHold, voices, adder; + # sus, prog, silent = order; + flatOrder = silent ++ sus ++ prog; + lastXChangesHold = lastXChanges.deepCopy; + voices = lastState.deepCopy; + isInChord = popSize.collect({false}); + allowChord = false; + res = []; + "------generating motif".postln; + //need to figure out here if voices move between motifs + flatOrder.do({arg ins, i; + + if(prog.includes(ins) && repeatLast.not, {updateVoices.value(ins, sus)}); + adder = if(silent.includes(ins), {["Rest"]}, {lastXChanges.last.deepCopy[ins]}); + + if(voices[ins] != adder, { + var dur; + allowChord = if((sus ++ silent).includes(ins), { + (sus ++ silent).includes(ins) && (ins != sus.last); + }, { + if(i < (flatOrder.size - 1), {(isInChord[flatOrder[i + 1]] || (ins == flatOrder[i + 1])).not}, {false}); + }); + dur = passagesDurFunc.value(allowChord); + if(dur == 0, {isInChord[ins] = true}, {isInChord = popSize.collect({false})}); + + voices[ins] = adder; + res = res.add([voices.deepCopy.postln, dur]); + }); + }); + + // pad ending + if(isLastOrder, { + (0..(popSize-1)).scramble.do({arg ins; + if(res.last.first[ins] != ["Rest"], { + var dur; + voices[ins] = ["Rest"]; + allowChord = (voices != popSize.collect({["Rest"]})); + dur = passagesDurFunc.value(allowChord); + res = res.add([voices.deepCopy.postln, dur]); + }); + }); + }); + + //format and return + if(startFromLast, {lastXChanges = lastXChangesHold}); + res; +}; + + +//------primary routines + +genMotif = { + var repeats, fSeq; + + repeats = 1; + fSeq = []; + + repeats.do({arg index; + var motif; + + motif = []; + + orders.do({arg order, o; + var lastState, subMotif; + lastState = if(o == 0, {popSize.collect({["Rest"]})}, {motif.last.last.first}); + subMotif = genSubMotif.value(order, lastState, isLastOrder: o == (orders.size - 1)); + motif = motif.add(subMotif); + + }); + + sanityCheck.value(motif, index); + + fSeq = fSeq.add(motif); + }); + fSeq +}; + +genSecondarySeq = {arg seq; + var curdles, fSeq; + curdles = []; + while({curdles.sum < seq.size}, {curdles = curdles ++ [3.rand + 1]}); + + fSeq = seq.clumps(curdles).collect({arg clump, m; + var repeats, paddedSeq; + + //add rest + paddedSeq = clump.add([[[popSize.collect({["Rest"]}), 0.5.rand]]]); + + //implement repeats + repeats = [0.rand + 1, 1].wchoose([1, 0].normalizeSum); + repeats.collect({paddedSeq}); + }); + fSeq +}; + + +//------audition funcs + +Event.addEventType(\osc, { + if (~addr.postln.notNil) { + ~addr.sendMsg(~indexPath, ~indexMsg); + ~addr.sendMsg(~seqPath, stringifyToDepth.value(~seqMsg, 3)); + //~addr.sendMsg("/STATE/OPEN", (dir.replace("supercollider", "resources") +/+ ~idMsg +/+ ~idMsg ++ "_gui_state" ++ ".state").standardizePath.postln); + }; +}); + +genPatterns = {arg inSeq, addr; + var voices, durs, patterns, res, indices, sectionDurs, ids, seq; + seq = inSeq.collect({arg mSeq; mSeq[0]}); + # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; + indices = inSeq.collect({arg mSeq, m; mSeq[1]}); + ids = inSeq.collect({arg mSeq, m; mSeq[2]}); + sectionDurs = seq.collect({arg mSeq; mSeq.flatten2(mSeq.maxDepth - 5).flop[1].sum}); + res = Ppar( + voices.flop.collect({arg voice; + var clumps, hdScores, freqs, fDurs; + clumps = voice.separate({arg a, b; a != b }); + freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); + fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); + + Pbind( + \instrument, \test, + \group, group, + \freq, Pseq(freqs, 1), + \dur, Pseq(fDurs, 1), + \sustain, Pseq(fDurs, 1) + ) + }) ++ + [ + Pbind( + \type, \osc, + \addr, addr, + \indexPath, "/cur_play_index", + \indexMsg, Pseq(indices.postln, 1), + \seqPath, "/mus_seq", + \seqMsg, Pseq(seq, 1), + \dur, Pseq(sectionDurs, 1) + ); + ] + ); + res +}; + +/* +genMidiPatterns = {arg seq; + var voices, durs, patterns, res, mOut, pbRange; + pbRange = 1; //semitones - change this as needed for your situation + mOut = MIDIOut.newByName("TiMidity", "TiMidity port 0").latency_(Server.default.latency); + # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; + res = Ppar( + voices.flop.collect({arg voice, v; + var clumps, hdScores, freqs, fDurs; + + mOut.program(v, 70); + + clumps = voice.separate({arg a, b; a != b }); + freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); + fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); + + Pbind( + \type, \midi, + \chan, v, + \noteval, Pseq(freqs.cpsmidi - 24, 1), + \note, Pfunc({ | event | event[\noteval].floor }), + \dur, Pseq(fDurs, 1), + \midiout, mOut, + \amp, 1, + \bend, Pfunc({ + | event | + if (event[\note].isRest.not) { + var pitchbendvalue = event[\noteval].frac.linlin(0, pbRange, 8192, 8192*2).asInteger; + m.bend(v, pitchbendvalue); + }; + 0; // return something other than nil to avoid stopping the pattern + }), + ); + }); + ); + res +}; +*/ + + +//------resource management funcs + +genUID = {Date.seed.asHexString.toLower}; + +seedFunc = {arg func, seed; + var funcArgs, next; + next = Routine({loop{func.valueArray(funcArgs).yield }}); + next.randSeed_(seed); + {arg ...args; funcArgs = args; next.value} +}; + +stringifyToDepth = {arg data, maxDepth = 1; + var prettyString = "", rCount = 0, writeArray, indent; + + if(maxDepth == 0, { + data.asCompileString + }, { + indent = {arg size; size.collect({" "}).join("")}; + writeArray = {arg array; + prettyString = prettyString ++ indent.value(rCount) ++ "[\n"; + rCount = rCount + 1; + if(rCount < (maxDepth - 0), { + array.do({arg subArray; writeArray.value(subArray)}); + }, { + prettyString = prettyString ++ array.collect({arg subArray; + indent.value(rCount + 1) ++ subArray.asCompileString + }).join(",\n"); + }); + rCount = rCount - 1; + prettyString = prettyString ++ "\n" ++ indent.value(rCount) ++ "],\n"; + }; + + writeArray.value(data); + prettyString.replace(",\n\n", "\n").drop(-2); + }) +}; + +sanityCheck = {arg motif, index; + //print functions = very helpful + ("----------" + index + "------------").postln; + + motif.flatten.do({arg val, v; + if(v > 0, { + if(motif.flatten[v-1][0].hammingDistance(val[0]) > 1, {"problem 1".postln}); + if(motif.flatten[v-1][0].hammingDistance(val[0]) == 0, {"problem 2".postln}); + }); + val.postln + }); + "***********".postln; +}; + +msgInterpret = {arg in, escapeDoubleQuotes = true, escapeSingleQuotes = true; + var res; + + res = in; + if(res.isNil.not, { + if((res.isArray && res.isString.not), { + res = res.asCompileString; + res = res.replace(" ", "").replace("\n", "").replace("\t", ""); + if(escapeSingleQuotes, {res = res.replace("\'", "")}); + if(escapeDoubleQuotes, {res = res.replace("\"", "")}); + res = res.replace("Rest", "\"Rest\""); + res = res.interpret; + }, { + //res.postln; + if(res.every({arg char; char.isDecDigit}), {res = res.asInteger}); + }); + }); + res +}; + +writeResources = {arg path; + var file, nameSpaces, modelItems, resString; + file = File(path,"w"); + + nameSpaces = [ + "music_data", "last_changes", + "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", + "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", + "ranges", "passages_weights", "order", "sus_weights", "order_size", "passages_size" + ]; + + modelItems = [ + seq, lastXChanges, + curUID, refUID, orderSeed, durSeed, motifSeed, + entrancesProbVals, passagesProbVals, exitsProbVals, + ranges, passagesWeights, orders, susWeights, orderSize, passagesSize + ]; + + resString = [nameSpaces, modelItems].flop.collect({arg item; + var nameSpace, modelItem, depth = 0, insert = " "; + # nameSpace, modelItem = item; + if(nameSpace == "music_data", {depth = 3; insert = "\n"}); + if(nameSpace == "last_changes", {depth = 1; insert = "\n"}); + if(nameSpace == "order", {depth = 1; insert = "\n"}); + "\"" ++ nameSpace ++ "\":" ++ insert ++ stringifyToDepth.value(modelItem.postln, depth).postln + }).join(",\n"); + + resString = "{\n" ++ resString ++ "\n}"; + + file.write(resString); + file.close; +}; + +loadModelFile = {arg path; loadModelJSON.value(File(path, "r").readAllString.parseJSON)}; + +loadModelJSON = {arg model; + var nameSpaces, data; + + //model = File(path, "r").readAllString.parseJSON; + + nameSpaces = [ + "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", + "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", + "ranges", "passages_weights", "order", "sus_weights", "order_size", "passages_size" + ]; + + data = nameSpaces.collect({arg nS; msgInterpret.value(model[nS]).postln}); + + data.postln; + + # curUID, refUID, orderSeed, durSeed, motifSeed, + entrancesProbVals, passagesProbVals, exitsProbVals, + ranges, passagesWeights, orders, susWeights, orderSize, passagesSize = data; + + popSize = ranges.size; +}; + +loadLedgerFile = {arg path; + ledgerPath = path; + loadLedgerJSON.value(File(ledgerPath, "r").readAllString.parseJSON) +}; + +loadLedgerJSON = {arg ledger; ledger = ledger["ledger"]}; + +//------global vars + +primes = [[2, 1], [3, 2], [5, 4], [7, 4], [11, 8], [13, 8]]; +//ranges = [[-2400, 0], [-1200, 1200], [0, 2400], [0, 2400]]; +exPath = thisProcess.nowExecutingPath; +dir = exPath.dirname; +//popSize = 4; +dims = primes.size; +tuples = genTuples.value(); +//refUID = nil; +group = Group.new; +loadLedgerFile.value(dir +/+ ".." +/+ "resources" +/+ "piece_ledger.json"); +//passagesWeights = [1, 1, 1, 1, 1]; +//susWeights = [1, 1, 1]; + + +//------OSC funcs + +OSCdef(\load_ledger, {arg msg, time, addr, port; + loadLedgerFile.value(msg[1].asString); +}, \load_ledger); + +OSCdef(\load_model, {arg msg, time, addr, port; + loadModelFile.value(msg[1].asString); +}, \load_model); + + +OSCdef(\generate, {arg msg, time, addr, port; + var path, dFormat, condition, musPath; + msg.postln; + + path = msg[1].asString; + + loadModelFile.value(path); + + refUID.postln; + + loadLedgerFile.value(ledgerPath); + if(ledger.last != "tmp", {ledger = ledger.add("tmp")}); + + lastXChanges = if(refUID == nil, { + [initVoices.value().deepCopy]; + }, { + var file; + refUID.postln; + file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); + msgInterpret.value(file.readAllString.parseJSON["last_changes"]); + }); + + entrancesDurFunc = genDurFunc.valueArray(entrancesProbVals[..2] ++ [entrancesProbVals[3..]]); + passagesDurFunc = genDurFunc.valueArray(passagesProbVals[..2] ++ [passagesProbVals[3..]]); + exitsDurFunc = genDurFunc.valueArray(exitsProbVals[..2] ++ [exitsProbVals[3..]]); + + if(orders == nil, { + orders = seedFunc.value(genOrders, orderSeed).valueArray(orderSize ++ passagesSize); + addr.sendMsg("/order", stringifyToDepth.value(orders, 1)); + }); + seq = seedFunc.value(genMotif, motifSeed).value; + + //musPath = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; + writeResources.value(path); + + //orders = nil; + //addr.sendMsg("/current_uid", curUID); + //addr.sendMsg("/ledger", prettifyArray.value(ledger, 1).replace("\"", "")); + //addr.sendMsg("/ledger_size", ledger.size); + //addr.sendMsg("/mus_seq", prettifyArray.value(seq, 3)); + addr.sendMsg("/generated", musPath, stringifyToDepth.value(seq, 3)); +}, \generate); + + +OSCdef(\commit, {arg msg, time, addr, port; + var newLedger, modelPath, musString, musFile, test1, test2; + msg.postln; + + /* + test1 = msg[1].asString.parseJSON; + test2 = (dir +/+ ".." +/+ "resources/tmp/tmp_music" ++ ".json").standardizePath.parseJSONFile; + msgInterpret.value(test1["music"])[0][0][0][1].class.postln; + msgInterpret.value(test2["music_data"])[0][0][0][1].class.postln; + (test1["music"] == test2["music_data"]).postln; + */ + + curUID = genUID.value; + File.mkdir((dir +/+ ".." +/+ "resources" +/+ curUID).standardizePath); + File.copy(exPath, (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_code" ++ ".scd").standardizePath); + + modelPath = (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_mus_model" ++ ".json").standardizePath; + writeResources.value(modelPath); + + File.delete(ledgerPath.postln ++ "_bak"); + File.copy(ledgerPath, ledgerPath ++ "_bak"); + File.delete(ledgerPath); + newLedger = File(ledgerPath.postln, "w"); + ledger = ledger.postln.drop(-1).add(curUID); + newLedger.write("{\n\"ledger\":\n" ++ stringifyToDepth.value(ledger, 1) ++ "\n}"); + newLedger.close; + + addr.sendMsg("/committed", curUID, ledgerPath); + //refUID = curUID; +}, \commit); + +OSCdef(\transport, {arg msg, time, addr, port; + msg.postln; + if(msg[1] == 0, { + player.stop; + group.set(\gate, 0); + }, { + // the cued sequence can now be read from file, so this can be cleaned up + var cSize, patterns, pSeq, cuedSeek, indexStart, indexEnd, tmpLedger; + pSeq = []; + cuedSeek = (seq != nil); + indexStart = msg[2].asInteger; + indexEnd = ledger.size - if(cuedSeek, {2}, {1}); + if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { + ledger[indexStart..indexEnd].do({arg uid, index; + var file; + (indexStart + index).postln; + file = File((dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_music" ++ ".json").standardizePath, "r"); + pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), indexStart + index, uid]); + file.close; + }); + }); + if(cuedSeek, {pSeq = pSeq.add([seq, ledger.size - 1])}); + patterns = genPatterns.value(pSeq, addr); + player = Pfset(pattern: patterns, cleanupFunc: { + addr.sendMsg("/transport", 0); + }); + player = player.play + }); +}, \transport); + +) + +( +SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; + var trig, exc, sig1, sig2, noHarms; + noHarms = 30; + exc = Saw.ar(freq, TRand.ar(0.5, 1, Impulse.ar(freq))) * 0.001 + Dust.ar(10000, 0.01); + sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), + Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), + Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.5).softclip; + sig1 = HPF.ar(sig1, 300); + Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); +}).add; +) + +( +SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; + var trig, exc, sig1, sig2, noHarms, freqFinal, start, end; + noHarms = 30; + freq = WhiteNoise.ar * 3 + freq; + freqFinal = Duty.ar((1/freq), 0, freq); + trig = Changed.ar(freqFinal); + start = Demand.ar(trig, 0, Dwhite(-1, -0.75)); + end = Demand.ar(trig, 0, Dwhite(0.75, 1)); + exc = Phasor.ar(trig, (end - start) * freqFinal / SampleRate.ir, start, end, 0) * 0.001 + Dust.ar(10000, 0.01); + + sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), + Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), + Array.fill(noHarms, {rrand(2, 3)}) ], exc) * 0.5).softclip; + sig1 = HPF.ar(sig1, 300); + Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); +}).add; +) + + + +"{\"a\": 1}".parseYAML["a"].asInteger; +"{\"a\": 1}".parseJSON["a"].isNumber; + +1223423434123.asHexString.toLower + +Date.getDate.rawSeconds +Date.seed.asHexString.toLower + +n = NetAddr("localhost", 8080); +n.sendMsg("/GET/#", (NetAddr.localAddr.hostname ++ ":" ++ NetAddr.localAddr.port), "/passage_probs_vals"); \ No newline at end of file diff --git a/resources/piece_ledger_sq1_candidates/4c01589b/4c01589b_gui_state.json b/resources/piece_ledger_sq1_candidates/4c01589b/4c01589b_gui_state.json new file mode 100644 index 0000000..2bc73d6 --- /dev/null +++ b/resources/piece_ledger_sq1_candidates/4c01589b/4c01589b_gui_state.json @@ -0,0 +1,1359 @@ +{ + "motif_label": "motif", + "seeds_label": "seeds", + "order": "[\n [ [ 3, 1, 0 ], [ 2 ], [ ] ],\n [ [ 1, 2 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 3 ] ],\n [ [ 3, 2 ], [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ], [ 0 ] ],\n [ [ 2, 3 ], [ 0, 1, 0 ], [ ] ]\n]", + "order_lock": 1, + "order_size": [ + 3, + 8 + ], + "order_size_v2": 8, + "order_size_v1": 3, + "order_size_panel": -1, + "passage_size_v2": 8, + "passage_size_v1": 2, + "passage_size_panel": -1, + "sus_weights": [ + null, + null, + null + ], + "range_matrix": [ + null, + null, + null, + null + ], + "instrumentation": [ + 0, + 0 + ], + "entrances_probs_sync": "passages", + "entrances": -1, + "passages_probs_sync": "passages", + "passages": -1, + "exits_probs_sync": "passages", + "exits": -1, + "dur_panel": 0, + "durations": -1, + "passages_weights": [ + null, + null, + null, + null, + null + ], + "weights": -1, + "seeds_tab_panel": 0, + "weights_seed_lock": 0, + "weights_seed": 534103, + "sus_weights/0_slider_val": 0.21, + "sus_weights/0_slider_slider": 0.21, + "sus_weights/0_slider_input": 0.21, + "sus_weights/0_slider_label": 1, + "sus_weights/0_slider": -1, + "sus_weights/1_slider_val": 0.35, + "sus_weights/1_slider_slider": 0.35, + "sus_weights/1_slider_input": 0.35, + "sus_weights/1_slider_label": 2, + "sus_weights/1_slider": -1, + "sus_weights/2_slider_val": 0.21, + "sus_weights/2_slider_slider": 0.21, + "sus_weights/2_slider_input": 0.21, + "sus_weights/2_slider_label": 3, + "sus_weights/2_slider": -1, + "passages_weights/0_slider_val": 0.49, + "passages_weights/0_slider_slider": 0.49, + "passages_weights/0_slider_input": 0.49, + "passages_weights/0_slider_label": "step", + "passages_weights/0_slider": -1, + "passages_weights/1_slider_val": 0.53, + "passages_weights/1_slider_slider": 0.53, + "passages_weights/1_slider_input": 0.53, + "passages_weights/1_slider_label": "dc", + "passages_weights/1_slider": -1, + "passages_weights/2_slider_val": 0.35, + "passages_weights/2_slider_slider": 0.35, + "passages_weights/2_slider_input": 0.35, + "passages_weights/2_slider_label": "range", + "passages_weights/2_slider": -1, + "passages_weights/3_slider_val": 0.59, + "passages_weights/3_slider_slider": 0.59, + "passages_weights/3_slider_input": 0.59, + "passages_weights/3_slider_label": "registration", + "passages_weights/3_slider": -1, + "passages_weights/4_slider_val": 0.39, + "passages_weights/4_slider_slider": 0.39, + "passages_weights/4_slider_input": 0.39, + "passages_weights/4_slider_label": "hd", + "passages_weights/4_slider": -1, + "range_matrix/0_val_input_min": -853.2067988668555, + "range_matrix/0_val_rslider": [ + -853.2067988668555, + 401 + ], + "range_matrix/0_val_input_max": 401, + "range_matrix/0_val": -1, + "range_matrix/1_val_input_min": -659, + "range_matrix/1_val_rslider": [ + -659, + 880 + ], + "range_matrix/1_val_input_max": 880, + "range_matrix/1_val": -1, + "range_matrix/2_val_input_min": -241, + "range_matrix/2_val_rslider": [ + -241, + 1869 + ], + "range_matrix/2_val_input_max": 1869, + "range_matrix/2_val": -1, + "range_matrix/3_val_input_min": -27, + "range_matrix/3_val_rslider": [ + -27, + 2063 + ], + "range_matrix/3_val_input_max": 2063, + "range_matrix/3_val": -1, + "entrances_probs_chord_slider_val": 0.66, + "entrances_probs_chord_slider_slider": 0.66, + "entrances_probs_chord_slider_input": 0.66, + "entrances_probs_chord_slider_label": "chord prob", + "entrances_probs_chord_slider": -1, + "entrances_probs_vals": [ + 0.63, + 0, + 5, + 0, + 0.5, + 0.23316062176165803, + 0.7094594594594594, + 0.3963730569948187, + 0.8716216216216216, + 0.4948186528497409, + 0.5912162162162162, + 0.5362694300518135, + 0.8614864864864865, + 0.6424870466321243, + 0.5912162162162162, + 0.7901554404145078, + 0.8277027027027027, + 1, + 0.5 + ], + "entrances_probs": -1, + "passages_probs_chord_slider_val": 0.63, + "passages_probs_chord_slider_slider": 0.63, + "passages_probs_chord_slider_input": 0.63, + "passages_probs_chord_slider_label": "chord prob", + "passages_probs_chord_slider": -1, + "passages_probs_vals": [ + 0.63, + 0, + 5, + 0, + 0.5, + 0.23316062176165803, + 0.7094594594594594, + 0.3963730569948187, + 0.8716216216216216, + 0.4948186528497409, + 0.5912162162162162, + 0.5362694300518135, + 0.8614864864864865, + 0.6424870466321243, + 0.5912162162162162, + 0.7901554404145078, + 0.8277027027027027, + 1, + 0.5 + ], + "passages_probs": -1, + "exits_probs_chord_slider_val": 0, + "exits_probs_chord_slider_slider": 0, + "exits_probs_chord_slider_input": 0, + "exits_probs_chord_slider_label": "chord prob", + "exits_probs_chord_slider": -1, + "exits_probs_vals": [ + 0, + 0, + 5, + 0, + 0.5, + 0.23316062176165803, + 0.7094594594594594, + 0.4948186528497409, + 0.5912162162162162, + 0.7901554404145078, + 0.8277027027027027, + 1, + 0.5 + ], + "exits_probs": -1, + "step_env_env_vals": [ + 0, + 5, + 0, + 0, + 0, + 0, + 0.14609053497942387, + 0.7613636363636364, + 0.20164609053497942, + 0.26136363636363635, + 0.24279835390946503, + 0.7215909090909092, + 0.39094650205761317, + 0.875, + 0.4567901234567901, + 0.44318181818181823, + 0.5432098765432098, + 0.34659090909090906, + 0.6481481481481481, + 0.8011363636363636, + 0.6810699588477366, + 0.5170454545454546, + 0.8868312757201646, + 0.49431818181818177, + 0.8868312757201646, + 0.49431818181818177 + ], + "step_env_env_canvas": [ + [ + 0, + 0 + ], + [ + 0, + 0 + ], + [ + 0.14609053497942387, + 0.7613636363636364 + ], + [ + 0.20164609053497942, + 0.26136363636363635 + ], + [ + 0.24279835390946503, + 0.7215909090909092 + ], + [ + 0.39094650205761317, + 0.875 + ], + [ + 0.4567901234567901, + 0.44318181818181823 + ], + [ + 0.5432098765432098, + 0.34659090909090906 + ], + [ + 0.6481481481481481, + 0.8011363636363636 + ], + [ + 0.6810699588477366, + 0.5170454545454546 + ], + [ + 0.8868312757201646, + 0.49431818181818177 + ], + [ + 0.8868312757201646, + 0.49431818181818177 + ], + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "step_env_env_size": 12, + "step_env_env_flatten": 0, + "step_env_env_rslider": [ + 0, + 5 + ], + "step_env_env_rslider_v2": 5, + "step_env_env_rslider_v1": 0, + "step_env_env_mpos": "", + "step_env_env": -1, + "entrances_probs_dur_env_vals": [ + 0.515267175572519, + 4.599236641221374, + 0, + 0.5, + 0.2772020725388601, + 0.7972972972972973, + 0.45077720207253885, + 0.8783783783783784, + 0.5, + 0.5, + 0.727979274611399, + 0.45270270270270274, + 0.7357512953367875, + 0.6486486486486487, + 0.8911917098445595, + 0.7905405405405406, + 1, + 0.5 + ], + "entrances_probs_dur_env_canvas": [ + [ + 0, + 0.5 + ], + [ + 0.2772020725388601, + 0.7972972972972973 + ], + [ + 0.45077720207253885, + 0.8783783783783784 + ], + [ + 0.5, + 0.5 + ], + [ + 0.727979274611399, + 0.45270270270270274 + ], + [ + 0.7357512953367875, + 0.6486486486486487 + ], + [ + 0.8911917098445595, + 0.7905405405405406 + ], + [ + 1, + 0.5 + ], + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "entrances_probs_dur_env_size": 8, + "entrances_probs_dur_env_flatten": 0, + "entrances_probs_dur_env_rslider": [ + 0.515267175572519, + 4.599236641221374 + ], + "entrances_probs_dur_env_rslider_v2": 4.599236641221374, + "entrances_probs_dur_env_rslider_v1": 0.515267175572519, + "entrances_probs_dur_env_mpos": "", + "entrances_probs_dur_env": -1, + "passages_probs_dur_env_vals": [ + 0, + 5, + 0, + 0.5, + 0.23316062176165803, + 0.7094594594594594, + 0.3963730569948187, + 0.8716216216216216, + 0.4948186528497409, + 0.5912162162162162, + 0.5362694300518135, + 0.8614864864864865, + 0.6424870466321243, + 0.5912162162162162, + 0.7901554404145078, + 0.8277027027027027, + 1, + 0.5 + ], + "passages_probs_dur_env_canvas": [ + [ + 0, + 0.5 + ], + [ + 0.23316062176165803, + 0.7094594594594594 + ], + [ + 0.3963730569948187, + 0.8716216216216216 + ], + [ + 0.4948186528497409, + 0.5912162162162162 + ], + [ + 0.5362694300518135, + 0.8614864864864865 + ], + [ + 0.6424870466321243, + 0.5912162162162162 + ], + [ + 0.7901554404145078, + 0.8277027027027027 + ], + [ + 1, + 0.5 + ], + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "passages_probs_dur_env_size": 8, + "passages_probs_dur_env_flatten": 0, + "passages_probs_dur_env_rslider": [ + 0, + 5 + ], + "passages_probs_dur_env_rslider_v2": 5, + "passages_probs_dur_env_rslider_v1": 0, + "passages_probs_dur_env_mpos": "", + "passages_probs_dur_env": -1, + "exits_probs_dur_env_vals": [ + 0, + 5, + 0, + 0.5, + 0.5, + 0.5, + 1, + 0.5 + ], + "exits_probs_dur_env_canvas": [ + [ + 0, + 0.5 + ], + [ + 0.5, + 0.5 + ], + [ + 1, + 0.5 + ], + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "exits_probs_dur_env_size": 3, + "exits_probs_dur_env_flatten": 0, + "exits_probs_dur_env_rslider": [ + 0, + 5 + ], + "exits_probs_dur_env_rslider_v2": 5, + "exits_probs_dur_env_rslider_v1": 0, + "exits_probs_dur_env_mpos": "", + "exits_probs_dur_env": -1, + "mus_seq": [ + [ + [ + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + "Rest" + ], + [ + "Rest" + ] + ], + 0 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + "Rest" + ] + ], + 1.75 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.75 + ], + [ + [ + [ + 0, + 1, + -3, + 0, + 2, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0.75 + ], + [ + [ + [ + 1, + 1, + -2, + -2, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0.625 + ], + [ + [ + [ + 1, + 1, + -3, + -1, + 0, + 0 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0.625 + ], + [ + [ + [ + 1, + 0, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.75 + ] + ], + [ + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.75 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 1, + -2, + 0, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.375 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 2, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0.75 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 1, + -2, + -1, + 2, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.75 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 0, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.875 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1 + ] + ], + [ + [ + [ + [ + 1, + 0, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0 + ], + [ + [ + [ + 1, + 0, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 2, + 0, + -3, + -1, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.625 + ], + [ + [ + [ + 1, + 0, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 1, + -1, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.75 + ], + [ + [ + [ + 1, + 0, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 1, + -1, + -1, + 1, + 0 + ], + [ + "Rest" + ] + ], + 0 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 1, + -1, + -1, + 1, + 0 + ], + [ + "Rest" + ] + ], + 1.875 + ], + [ + [ + [ + "Rest" + ], + [ + "Rest" + ], + [ + 0, + 1, + -1, + -1, + 1, + 0 + ], + [ + "Rest" + ] + ], + 0 + ], + [ + [ + [ + "Rest" + ], + [ + "Rest" + ], + [ + "Rest" + ], + [ + "Rest" + ] + ], + 0.875 + ] + ] + ] + ], + "root": [ + 0.20743639921722112, + 0 + ], + "order_seed": 798574, + "dur_seed": 884869, + "passages_size": [ + 0, + 10 + ], + "dur_seed_lock": 1, + "order_seed_lock": 0, + "seeds_panel": -1, + "motif_panel": [ + 0, + 0 + ], + "ref_uid": "6f1a789f", + "cur_uid": "4c01589b" +} \ No newline at end of file diff --git a/resources/730ad6b9/730ad6b9_mus_model.json b/resources/piece_ledger_sq1_candidates/4c01589b/4c01589b_mus_model.json similarity index 74% rename from resources/730ad6b9/730ad6b9_mus_model.json rename to resources/piece_ledger_sq1_candidates/4c01589b/4c01589b_mus_model.json index 0dad1eb..436b630 100644 --- a/resources/730ad6b9/730ad6b9_mus_model.json +++ b/resources/piece_ledger_sq1_candidates/4c01589b/4c01589b_mus_model.json @@ -55,36 +55,31 @@ ], "last_changes": [ - [ [ 1, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, 1 ], [ 0, 1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, -1 ] ], - [ [ 1, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, 1 ], [ 1, 0, 0, 0, 0, -1 ], [ 0, 0, 0, 0, 0, -1 ] ], - [ [ 1, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, 1 ], [ 1, 0, 0, 0, 0, -1 ], [ -1, 1, 0, 0, 0, 0 ] ], - [ [ 1, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, 1 ], [ 0, 0, 1, 0, 0, 0 ], [ -1, 1, 0, 0, 0, 0 ] ], - [ [ 1, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, 1 ], [ 0, 0, 1, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ] ] + [ [ 0, 1, 0, 0, 0, 0 ], [ -1, 0, 0, 0, 0, 1 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ] ], + [ [ 0, 1, 0, 0, 0, 0 ], [ 0, 0, -1, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ] ], + [ [ 0, 1, 0, 0, 0, 0 ], [ -1, 1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ] ], + [ [ 0, 1, 0, 0, 0, 0 ], [ 1, -1, 0, -1, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ] ], + [ [ 0, 1, 0, 0, 0, 0 ], [ 1, 0, 0, -1, -1, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ] ] ], -"cur_uid": "730ad6b9", +"cur_uid": "4c01589b", "ref_uid": "nil", -"order_seed": 415291, -"dur_seed": 904411, -"motifs_seed": 527037, -"entrances_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.26424870466321, 0.75675675675676, 0.5, 0.5, 0.58549222797927, 0.72635135135135, 1, 0.5 ], -"passages_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], -"exits_probs_vals": [ 0.75, 0, 10, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], +"order_seed": 720097, +"dur_seed": 979064, +"motifs_seed": 718021, +"entrances_probs_vals": [ 0.75, 0.5, 2, 0, 0.5, 0.26424870466321, 0.75675675675676, 0.5, 0.5, 0.58549222797927, 0.72635135135135, 1, 0.5 ], +"passages_probs_vals": [ 0.75, 0.5, 2, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], +"exits_probs_vals": [ 0.75, 0.5, 2, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], "ranges": [ [ -384, 2400 ], [ -507, 2400 ], [ -282, 2237 ], [ -1200, 2053 ] ], -"step_probs_vals": [ 0, 1200, 0, 0.5, 0.5, 0.5, 1, 0.5 ], "passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], -"hd_exp": 2, -"hd_invert": 0, "order": [ - [ [ 3, 1 ], [ 0, 2, 0, 0, 0, 0, 0, 0 ], [ ] ], - [ [ 0, 2, 1 ], [ 3, 3, 3 ], [ ] ], - [ [ 3, 0, 2 ], [ 1, 1, 1, 1, 1, 1, 1, 1, 1 ], [ ] ], - [ [ 2 ], [ 1, 3, 3, 1, 3, 3, 1, 1 ], [ 0 ] ], - [ [ 0 ], [ 2, 1, 3, 2, 3, 3, 1, 2, 3, 2, 3 ], [ ] ] + [ [ 2 ], [ 1, 3, 0, 1, 1, 3, 0, 0, 3, 0, 0, 3 ], [ ] ], + [ [ 1, 0, 3 ], [ 2, 2, 2, 2, 2, 2, 2, 2 ], [ ] ], + [ [ 3, 2, 0 ], [ 1, 1, 1, 1 ], [ ] ], + [ [ 0 ], [ 2 ], [ 3, 1 ] ], + [ [ 0, 2, 3 ], [ 1, 1, 1, 1, 1, 1 ], [ ] ] ], "sus_weights": [ 0.75, 0.69, 0.75 ], "order_size": [ 2, 6 ], -"passages_size": [ 0, 10 ], -"motif_edited": "true", -"order_edited": "false" +"passages_size": [ 0, 10 ] } \ No newline at end of file diff --git a/resources/72dbaa4c/72dbaa4c_code.scd b/resources/piece_ledger_sq1_candidates/628d5c8b/628d5c8b_code.scd similarity index 53% rename from resources/72dbaa4c/72dbaa4c_code.scd rename to resources/piece_ledger_sq1_candidates/628d5c8b/628d5c8b_code.scd index 55bfebd..90f0b1e 100644 --- a/resources/72dbaa4c/72dbaa4c_code.scd +++ b/resources/piece_ledger_sq1_candidates/628d5c8b/628d5c8b_code.scd @@ -6,7 +6,7 @@ var hsArrayToCents, pDist, hdSum, hsChordalDistance, hsArrayToFreq; var isInRange, spacingScore, rangeScore, intervalScore, inclusionScore; // subroutines -var genTuples, initVoices, genOrders, genSubMotif, updateVoices, genDurFunc, genStepFunc; +var genTuples, initVoices, genOrders, genSubMotif, updateVoices, genDurFunc; // primary routines var genMotif, genSecondarySeq; @@ -16,25 +16,21 @@ var genPatterns, genMidiPatterns; // resource management funcs var seedFunc, genUID, writeResources, stringifyToDepth, setSeeds, sanityCheck, -msgInterpret, loadLedgerFile, loadLedgerJSON, loadModelFile, loadModelJSON, -setGlobalVars, globalVarsToDict, saveLedger; +msgInterpret, loadLedgerFile, loadLedgerJSON, loadModelFile, loadModelJSON; // model vars //(model and global vars mostly set by OSC funcs -var seq, lastXChanges, -curUID, refUID, orderSeed, durSeed, motifSeed, +var curUID, refUID, orderSeed, durSeed, motifSeed, entrancesProbVals, passagesProbVals, exitsProbVals, -ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, -orders, susWeights, orderSize, passagesSize, -motifEdited, orderEdited; +ranges, orders, susWeights, passagesWeights, passagesSize, orderSize; // model aux vars -var entrancesDurFunc, passagesDurFunc, exitsDurFunc, stepFunc; +var entrancesDurFunc, passagesDurFunc, exitsDurFunc; // other global vars -var popSize, exPath, dir, primes, dims, tuples, -group, player, ledgerPath, ledger, currentlyPlayingUID, -nameSpaces; +var lastXChanges, popSize, exPath, dir, primes, dims, tuples, +seq, group, player, ledgerPath, ledger, currentlyPlayingUID; + // install JSON quark if(Quarks.isInstalled("JSONlib").not, { @@ -120,8 +116,7 @@ intervalScore = { arg hsArray1, hsArray2, mean, sd, signed = false; var pDistance; pDistance = pDist.value(hsArray1, hsArray2, signed); - //pDistance.gaussCurve(1, mean, sd) - stepFunc.value(pDistance); + pDistance.gaussCurve(1, mean, sd) }; inclusionScore = { @@ -154,37 +149,23 @@ initVoices = { voicesInit.deepCopy; }; -genDurFunc = {arg chordProb, minPad, maxPad, minDur, maxDur, envData, seed; +genDurFunc = {arg chordProb, min, max, envData, seed; var env, pTable, durFunc; env = Env.pairs([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).asSignal(256).asList.asArray; pTable = env.asRandomTable; - [chordProb, minPad, maxPad, minDur, maxDur, envData].postln; - durFunc = {arg allowChord, pad = false; + durFunc = {arg allowChord; var res; res = if(allowChord.not, { - pTable.tableRand * (maxDur - minDur) + minDur + pTable.tableRand * (max - min) + min }, { - if(1.0.rand < chordProb, {0}, {pTable.tableRand * (maxDur - minDur) + minDur}); + if(1.0.rand < chordProb, {0}, {pTable.tableRand * (max - min) + min}); }).round(0.125); - if(pad, {res = res + rrand(minPad.asFloat, maxPad.asFloat).round(0.125)}); if(res.asInteger == res, {res = res.asInteger}); res }; seedFunc.value(durFunc, seed); }; -genStepFunc = {arg minStep, maxStep, envData, seed; - var envDataNorm, env, pTable, stepFunc; - [minStep, maxStep, envData].postln; - envDataNorm = ([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).flop; - envDataNorm = [envDataNorm[0].normalize(minStep, maxStep), envDataNorm[1]].flop; - env = Env.pairs(envDataNorm); - stepFunc = {arg pDist; - env.at(pDist).clip(0.001, 1); - }; - seedFunc.value(stepFunc, seed); -}; - genOrders = {arg minMotifLength = 1, maxMotifLength = 5, minProgLength = 0, maxProgLength = 5; ((maxMotifLength - minMotifLength).rand + minMotifLength).collect({ var noProgIns, noSusIns, noSilentIns, prog, sus, silent, order; @@ -215,8 +196,7 @@ updateVoices = {arg ins, sus; recentlySoundedScore = inclusionScore.value(lastXChanges.flop[ins], candidate, 0); isInRangeScore = rangeScore.value(candidate, candidate.collect({0}), ranges[ins][0], ranges[ins][1], 0, true); regScore = spacingScore.value(voices.deepCopy.put(ins, candidate), 300); - hdScore = pow(hdSum.value(voices.deepCopy.put(ins, candidate)), hdExp); - if(hdInvert == 0, {hdScore = 1/hdScore}); + hdScore = 1/pow(hdSum.value(voices.deepCopy.put(ins, candidate)), 2); //maybe what you want here is a vector to another root and then favoring movement towards it. //distScore = pow(hsChordalDistance.value(voices, voices.put(ins, candidate)), 2); @@ -240,14 +220,13 @@ updateVoices = {arg ins, sus; }; genSubMotif = {arg order, orderIndex, lastState, repeatLast = false, startFromLast = false, isLastOrder = false; - var sus, prog, silent, flatOrder, res, isInChord, allowChord, pad, lastXChangesHold, voices, adder; + var sus, prog, silent, flatOrder, res, isInChord, allowChord, lastXChangesHold, voices, adder; # sus, prog, silent = order; flatOrder = silent ++ sus ++ prog; lastXChangesHold = lastXChanges.deepCopy; voices = lastState.deepCopy; isInChord = popSize.collect({false}); allowChord = false; - pad = false; res = []; "------generating motif".postln; //need to figure out here if voices move between motifs @@ -259,23 +238,18 @@ genSubMotif = {arg order, orderIndex, lastState, repeatLast = false, startFromLa if(voices[ins] != adder, { var dur; - if((sus ++ silent).includes(ins), { - allowChord = (ins != sus.last); - pad = (ins == sus.last); + allowChord = if((sus ++ silent).includes(ins), { + //(sus ++ silent).includes(ins) && (ins != sus.last); + ins != sus.last; }, { - if(i < (flatOrder.size - 1), { - allowChord = (isInChord[flatOrder[i + 1]] || (ins == flatOrder[i + 1])).not; - pad = false; - }, { - allowChord = false; - pad = true - }); + if(i < (flatOrder.size - 1), {(isInChord[flatOrder[i + 1]] || (ins == flatOrder[i + 1])).not}, {false}); }); if((orderIndex == 0) && sus.includes(ins), { - dur = entrancesDurFunc.value(allowChord, pad); + dur = entrancesDurFunc.value(allowChord); }, { - dur = passagesDurFunc.value(allowChord, pad); + dur = passagesDurFunc.value(allowChord); }); + //dur = passagesDurFunc.value(allowChord); if(dur == 0, {isInChord[ins] = true}, {isInChord = popSize.collect({false})}); voices[ins] = adder; @@ -290,15 +264,14 @@ genSubMotif = {arg order, orderIndex, lastState, repeatLast = false, startFromLa var dur; voices[ins] = ["Rest"]; allowChord = (voices != popSize.collect({["Rest"]})); - pad = allowChord.not; - dur = exitsDurFunc.value(allowChord, pad); + dur = exitsDurFunc.value(allowChord); res = res.add([voices.deepCopy.postln, dur]); }); }); }); //format and return - if(startFromLast, {lastXChanges = lastXChangesHold.deepCopy}); + if(startFromLast, {lastXChanges = lastXChangesHold}); res; }; @@ -306,7 +279,7 @@ genSubMotif = {arg order, orderIndex, lastState, repeatLast = false, startFromLa //------primary routines genMotif = { - var repeats, fSeq, fDur, durAdd; + var repeats, fSeq; repeats = 1; fSeq = []; @@ -328,13 +301,6 @@ genMotif = { fSeq = fSeq.add(motif); }); - - //round last duration to measure - fDur = fSeq.flatten.flatten.slice(nil, 1).sum; - durAdd = fDur.round(4) - fDur; - if(durAdd < 0, {durAdd = 4 - durAdd}); - fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] = fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] + durAdd; - fSeq }; @@ -370,69 +336,48 @@ Event.addEventType(\osc, { */ Event.addEventType(\osc, { - if (~addr.notNil) { - ~msg; + if (~addr.postln.notNil) { + ~msg.postln; ~addr.sendMsg(~path, *~msg); }; }); -genPatterns = {arg inSeq, addr, oneShot = false; - var voices, durs, pbinds, res, indices, sectionDurs, msg, ids, seq; +genPatterns = {arg inSeq, addr; + var voices, durs, patterns, res, indices, sectionDurs, msg, ids, seq; seq = inSeq.collect({arg mSeq; mSeq[0]}); # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - pbinds = voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs, attacks, rels, amps; - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - //attacks = 2.collect({rrand(1, 3)}) ++ freqs.drop(2).collect({rrand(0.3, 0.5)}); - attacks = fDurs.collect({arg dur; dur * rrand(0.2, 0.4)}); - //rels = freqs.drop(2).collect({rrand(0.3, 0.5)}) ++ 2.collect({rrand(1, 3)}); - rels = (clumps.size - 1).collect({arg c; - if(clumps[c + 1][0] == ["Rest"], {rrand(1.0, 3.0)}, {rrand(0.3, 0.5)}); - }); - rels = rels.add(rrand(1.0, 3.0)); - amps = freqs.collect({rrand(0.6, 0.99)}); + msg = inSeq.collect({arg mSeq, m; mSeq[1..]}); + //ids = inSeq.collect({arg mSeq, m; mSeq[2]}); + sectionDurs = seq.collect({arg mSeq; mSeq.flatten2(mSeq.maxDepth - 5).flop[1].sum}); + res = Ppar( + voices.flop.collect({arg voice; + var clumps, hdScores, freqs, fDurs; + clumps = voice.separate({arg a, b; a != b }); + freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); + fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - [ - Pbind( - \instrument, \string_model, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \attack, Pseq(attacks, 1), - \sustain, Pseq(fDurs, 1), - \release, Pseq(rels, 1), - //\amp, Pseq(amps, 1), - \amp, Pbrown(0.5, 1, 0.5), - \busIndex, v - ), Pbind( - \instrument, \sine, + \instrument, \test, \group, group, \freq, Pseq(freqs, 1), \dur, Pseq(fDurs, 1), - \sustain, Pseq(fDurs, 1), - \busIndex, v + \sustain, Pseq(fDurs, 1) ) - ] - }).flatten; - if(oneShot.not, { - msg = inSeq.collect({arg mSeq, m; mSeq[1..]}); - //ids = inSeq.collect({arg mSeq, m; mSeq[2]}); - sectionDurs = seq.collect({arg mSeq; mSeq.flatten2(mSeq.maxDepth - 5).flop[1].sum}); - pbinds = pbinds ++ + }) ++ [ Pbind( \type, \osc, \addr, addr, + //\indexPath, "/cur_play_index", + //\indexMsg, Pseq(indices, 1), + //\seqPath, "/mus_seq", + //\seqMsg, Pseq(seq, 1), \path, "/playing", \msg, Pseq(msg, 1), \dur, Pseq(sectionDurs, 1) ); ] - }); - res = Ppar(pbinds); + ); res }; @@ -540,35 +485,39 @@ msgInterpret = {arg in, escapeDoubleQuotes = true, escapeSingleQuotes = true; res = res.replace("Rest", "\"Rest\""); res = res.interpret; }, { - var tmpRes; - if(res.every({arg char; char.isDecDigit}), {tmpRes = res.asInteger}); - if(res.contains("."), {tmpRes = res.asFloat}); - if(tmpRes != nil, {res = tmpRes}); + //res.postln; + if(res.every({arg char; char.isDecDigit}), {res = res.asInteger}); }); }); res }; -writeResources = {arg path, dict; - var file, modelItems, resString; +writeResources = {arg path; + var file, nameSpaces, modelItems, resString; file = File(path,"w"); + nameSpaces = [ + "music_data", "last_changes", + "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", + "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", + "ranges", "passages_weights", "order", "sus_weights", "order_size", "passages_size" + ]; + modelItems = [ seq, lastXChanges, curUID, refUID, orderSeed, durSeed, motifSeed, entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited + ranges, passagesWeights, orders, susWeights, orderSize, passagesSize ]; - resString = nameSpaces.collect({arg nameSpace; - var depth = 0, insert = " "; + resString = [nameSpaces, modelItems].flop.collect({arg item; + var nameSpace, modelItem, depth = 0, insert = " "; + # nameSpace, modelItem = item; if(nameSpace == "music_data", {depth = 3; insert = "\n"}); if(nameSpace == "last_changes", {depth = 1; insert = "\n"}); if(nameSpace == "order", {depth = 1; insert = "\n"}); - if((nameSpace == "ref_uid") && (dict[nameSpace] == nil), {dict[nameSpace] = "nil"}); - "\"" ++ nameSpace ++ "\":" ++ insert ++ stringifyToDepth.value(dict[nameSpace], depth) + if((nameSpace == "ref_uid") && (modelItem == nil), {modelItem = "nil"}); + "\"" ++ nameSpace ++ "\":" ++ insert ++ stringifyToDepth.value(modelItem, depth) }).join(",\n"); resString = "{\n" ++ resString ++ "\n}"; @@ -581,36 +530,25 @@ writeResources = {arg path, dict; loadModelFile = {arg path; loadModelJSON.value(File(path, "r").readAllString.parseJSON)}; loadModelJSON = {arg jsonObject; - var dict; - dict = Dictionary.with(*nameSpaces.collect({arg nS; nS->msgInterpret.value(jsonObject[nS])})); - dict -}; + var nameSpaces, data; -setGlobalVars = {arg dict, skipLastXChanges = false; - var tmpLastXChanges; - tmpLastXChanges = lastXChanges.deepCopy; - // order really matters!!!! - # seq, lastXChanges, curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited = nameSpaces.collect({arg nS; dict[nS]}); - if(skipLastXChanges, {lastXChanges = tmpLastXChanges}); - dict -}; + //model = File(path, "r").readAllString.parseJSON; -globalVarsToDict = { - var modelItems, dict; - // order really matters!!!! - modelItems = [ - seq, lastXChanges, - curUID, refUID, orderSeed, durSeed, motifSeed, - entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, - motifEdited, orderEdited + nameSpaces = [ + "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", + "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", + "ranges", "passages_weights", "order", "sus_weights", "order_size", "passages_size" ]; - dict = Dictionary.with(*nameSpaces.collect({arg nS, n; nS->modelItems[n]})); + + data = nameSpaces.collect({arg nS; msgInterpret.value(jsonObject[nS])}); + + //data.postln; + + # curUID, refUID, orderSeed, durSeed, motifSeed, + entrancesProbVals, passagesProbVals, exitsProbVals, + ranges, passagesWeights, orders, susWeights, orderSize, passagesSize = data; + + popSize = ranges.size; }; loadLedgerFile = {arg path; @@ -620,13 +558,6 @@ loadLedgerFile = {arg path; loadLedgerJSON = {arg jsonObject; ledger = jsonObject["ledger"]}; -saveLedger = {arg ledger, path; - var file; - file = File(path, "w"); - file.write("{\n\"ledger\":\n" ++ stringifyToDepth.value(ledger, 1) ++ "\n}"); - file.close; -}; - //------global vars primes = [[2, 1], [3, 2], [5, 4], [7, 4], [11, 8], [13, 8]]; @@ -638,18 +569,9 @@ dims = primes.size; tuples = genTuples.value(); //refUID = nil; group = Group.new; -~group = group; loadLedgerFile.value(dir +/+ ".." +/+ "resources" +/+ "piece_ledger.json"); //passagesWeights = [1, 1, 1, 1, 1]; //susWeights = [1, 1, 1]; -// order really matters!!!! -nameSpaces = [ - "music_data", "last_changes", "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", - "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", - "ranges", "step_probs_vals", "passages_weights", "hd_exp", "hd_invert", - "order", "sus_weights", "order_size", "passages_size", - "motif_edited", "order_edited" -]; //------OSC funcs @@ -659,29 +581,17 @@ OSCdef(\load_ledger, {arg msg, time, addr, port; }, \load_ledger); OSCdef(\load_model, {arg msg, time, addr, port; - var dict; - dict = loadModelFile.value(msg[1].asString); - setGlobalVars.value(dict); + loadModelFile.value(msg[1].asString); }, \load_model); -OSCdef(\save_ledger, {arg msg, time, addr, port; - msg.postln; - ledger = msgInterpret.value(msg[1].asString.parseJSON["ledger"], false).postln; - //loadLedgerJSON.value(msg[0]) - saveLedger.value(ledger, msg[2].asString); - //loadLedgerFile.value(msg[1].asString); -}, \save_ledger); OSCdef(\generate, {arg msg, time, addr, port; - var path, dict, durSeeds, musPath, modelString; + var path, durSeeds, musPath, modelString; msg.postln; path = msg[1].asString; - dict = loadModelFile.value(path); - setGlobalVars.value(dict, true); - - popSize = ranges.size; + loadModelFile.value(path); //refUID.postln; @@ -689,44 +599,35 @@ OSCdef(\generate, {arg msg, time, addr, port; if(ledger == nil, {ledger = ["tmp"]}); if(ledger.last != "tmp", {ledger = ledger.add("tmp")}); - if(refUID == nil, {lastXChanges = [initVoices.value().deepCopy]}); - if((refUID != nil) && (refUID != "tmp"), { + lastXChanges = if(refUID == nil, { + [initVoices.value().deepCopy]; + }, { var file; file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - lastXChanges = msgInterpret.value(file.readAllString.parseJSON["last_changes"]); + msgInterpret.value(file.readAllString.parseJSON["last_changes"]); }); - refUID.postln; - lastXChanges.collect({arg item; item.postln}); - durSeeds = seedFunc.value({3.collect({rrand(100000, 999999)})}, durSeed).value.postln; - entrancesDurFunc = genDurFunc.valueArray(entrancesProbVals[..4] ++ [entrancesProbVals[5..]] ++ [durSeeds[0]]); - passagesDurFunc = genDurFunc.valueArray(passagesProbVals[..4] ++ [passagesProbVals[5..]] ++ [durSeeds[1]]); - exitsDurFunc = genDurFunc.valueArray(exitsProbVals[..4] ++ [exitsProbVals[5..]] ++ [durSeeds[2]]); + entrancesDurFunc = genDurFunc.valueArray(entrancesProbVals[..2] ++ [entrancesProbVals[3..]] ++ [durSeeds[0]]); + passagesDurFunc = genDurFunc.valueArray(passagesProbVals[..2] ++ [passagesProbVals[3..]] ++ [durSeeds[1]]); + exitsDurFunc = genDurFunc.valueArray(exitsProbVals[..2] ++ [exitsProbVals[3..]] ++ [durSeeds[2]]); if(orders == nil, { orders = seedFunc.value(genOrders, orderSeed).valueArray(orderSize ++ passagesSize); //addr.sendMsg("/order", stringifyToDepth.value(orders, 1)); }); - - stepFunc = genStepFunc.valueArray(stepProbsVals[..1] ++ [stepProbsVals[2..]] ++ [motifSeed]); seq = seedFunc.value(genMotif, motifSeed).value; - lastXChanges.collect({arg item; item.postln}); - - dict = globalVarsToDict.value; - modelString = writeResources.value(path, dict); + modelString = writeResources.value(path); //addr.sendMsg("/generated", musPath, stringifyToDepth.value(seq, 3)); - //~seq = seq; - - addr.sendMsg("/generated", path, modelString, ledgerPath); + addr.sendMsg("/generated", path, modelString); }, \generate); OSCdef(\commit, {arg msg, time, addr, port; - var musicData, musicChanged, dict, newLedger, modelPath, musString, musFile, test1, test2; - //msg.postln; + var newLedger, modelPath, musString, musFile, test1, test2; + msg.postln; /* test1 = msg[1].asString.parseJSON; @@ -736,159 +637,47 @@ OSCdef(\commit, {arg msg, time, addr, port; (test1["music"] == test2["music_data"]).postln; */ - musicData = loadModelJSON.value(msg[1].asString.parseJSON)["music_data"].postln; - musicChanged = (musicData != seq).postln; - curUID = genUID.value; - File.mkdir((dir +/+ ".." +/+ "resources" +/+ curUID).standardizePath); File.copy(exPath, (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_code" ++ ".scd").standardizePath); modelPath = (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_mus_model" ++ ".json").standardizePath; - dict = globalVarsToDict.value; - if(musicChanged, { - seq = musicData; - dict["music_data"] = seq; - dict["motif_edited"] = "true" - }); - dict["cur_uid"] = curUID; - - writeResources.value(modelPath, dict); + writeResources.value(modelPath); File.delete(ledgerPath ++ "_bak"); File.copy(ledgerPath, ledgerPath ++ "_bak"); File.delete(ledgerPath); + newLedger = File(ledgerPath, "w"); ledger = ledger.drop(-1).add(curUID); - - saveLedger.value(ledger, ledgerPath); + newLedger.write("{\n\"ledger\":\n" ++ stringifyToDepth.value(ledger, 1) ++ "\n}"); + newLedger.close; addr.sendMsg("/committed", curUID, ledgerPath); //refUID = curUID; - }, \commit); OSCdef(\transport, {arg msg, time, addr, port; msg.postln; if(msg[1] == 0, { - group.set(\release, 2); - group.set(\gate, 0); player.stop; + group.set(\gate, 0); }, { // the cued sequence can now be read from file, so this can be cleaned up var cSize, patterns, pSeq, cuedSeek, indexStart, indexEnd, tmpLedger; - if(msg[1] == 1, { - pSeq = []; - cuedSeek = (seq != nil); - indexStart = msg[2].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.postln.parseJSON["music_data"]), path, indexStart + index, uid]); - file.close; - }); - }); - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - patterns = genPatterns.value(pSeq, addr); - }, { - pSeq = [loadModelJSON.value(msg[2].asString.parseJSON)["music_data"].postln]; - patterns = genPatterns.value(pSeq, addr, true); - }); - player = Pfset(pattern: patterns, cleanupFunc: { - addr.sendMsg("/transport", 0); - addr.sendMsg("/one_shot", 0); - }); - player = player.play - }); -}, \transport); - - -OSCdef(\transcribe_motif, {arg msg, time, addr, port; - var tSeq, refChord, refUID; - - msg.postln; - - tSeq = [loadModelJSON.value(msg[1].asString.parseJSON)["music_data"]]; - refUID = msg[2].asString.postln; - - if((refUID != "nil") && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }, { - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - }); - - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "lilypond" +/+ "includes").standardizePath, addr, "/transcribe_motif"); -}, \transcribe_motif); - - -OSCdef(\transcribe_all, {arg msg, time, addr, port; - var cSize, patterns, cuedSeek, indexStart, indexEnd, tmpLedger; - if(true, { + pSeq = []; cuedSeek = (seq != nil); - indexStart = msg[1].asInteger; + indexStart = msg[2].asInteger; indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - - //tmp for testing transcription - indexEnd = (indexStart+5); - //ledger.postln; if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - var lilyPartLedgerFiles; - - lilyPartLedgerFiles = 4.collect({arg p; - File((dir +/+ ".." +/+ "lilypond" +/+ "includes" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly").standardizePath, "w"); - }); - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file, fileString, tSeq, refUID, refChord; + var path, file; path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; file = File(path, "r"); - fileString = file.readAllString; - tSeq = msgInterpret.value(fileString.parseJSON["music_data"]); - refUID = msgInterpret.value(fileString.parseJSON["ref_uid"]); + pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, indexStart + index, uid]); file.close; - - //uid.postln; - //(refUID == "nil").postln; - - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - - if(refUID != "nil", { - path = (dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }); - - if(index != indexEnd, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath); - }, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath, addr, "/transcribe_all"); - }); - - lilyPartLedgerFiles.do({arg f, p; - f.write("\\include \".." +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly\"\n"); - }); - - }); - - lilyPartLedgerFiles.do({arg f; - f.close }); }); - /* if(cuedSeek, { var path, file; path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; @@ -896,121 +685,29 @@ OSCdef(\transcribe_all, {arg msg, time, addr, port; pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); file.close; }); - */ - }, { - + patterns = genPatterns.value(pSeq, addr); + player = Pfset(pattern: patterns, cleanupFunc: { + addr.sendMsg("/transport", 0); + }); + player = player.play }); - -}, \transcribe_all); +}, \transport); ) -~transcribe.value(~seq, dir); - ( -//synthdefs -~stringModelBusArray = 4.collect({Bus.audio(s, 1)}); -~sineBusArray = 4.collect({Bus.audio(s, 1)}); -~bassBusArray = 1.collect({Bus.audio(s, 1)}); -~hdustBusArray = 1.collect({Bus.audio(s, 1)}); -~samplerBusArray = 2.collect({Bus.audio(s, 1)}); -~sBuf = Buffer.alloc(s, 10, 2); -SynthDef(\string_model, {arg freq, gate = 1, sustain, amp, dur, attack, release = 1, busIndex = 0; +SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; var trig, exc, sig1, sig2, noHarms; - noHarms = rrand(20, 40); + noHarms = 30; exc = Saw.ar(freq, TRand.ar(0.5, 1, Impulse.ar(freq))) * 0.001 + Dust.ar(10000, 0.01); sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.8).softclip; - //sig1 = HPF.ar(sig1, 300); - Out.ar(Select.kr(busIndex, ~stringModelBusArray), sig1 * amp * EnvGen.kr(Env.adsr(attack, 0.3, 0.9, release, 0.9, -3), gate, doneAction: 2)); - //Out.ar([0, 1], sig1 * EnvGen.kr(Env.asr(dur, 0.3, 1), gate, doneAction: 2)); -}).add; - -SynthDef(\sine, {arg freq, gate = 1, sustain, amp, dur, busIndex = 0; - var sig; - sig = SinOsc.ar(freq); - Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.asr(0.3, 0.4, 0.3), gate, timeScale: dur, doneAction: 2)); - //Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.sine(dur), gate, doneAction: 2)); -}).add; - -SynthDef(\mixer, {arg freq, gate = 1, sustain, amp, dur, out; - var nameSpaces, sigs; - - sigs = [~stringModelBusArray, ~sineBusArray/*, ~bassBusArray, ~hdustBusArray, ~samplerBusArray*/].collect({arg busArray, i; - var nameSpace, sig; - nameSpace = ['string', 'sine', 'bass', 'hdust', 'sampler'][i]; - sig = busArray.collect({arg bus, c; In.ar(bus, 1) * NamedControl.kr(\ ++ nameSpace ++ '_volume_' ++ c, 1, 0.1)}); - sig = sig.collect({arg channel, c; Pan2.ar(channel, NamedControl.kr(\ ++ nameSpace ++ '_pan_' ++ c, i / (busArray.size - 1), 0.1) * 2 - 1)}); - sig = sig.collect({arg channel, c; channel * NamedControl.kr(\ ++ nameSpace ++ '_mute_' ++ c, 1, 0.1)}); - sig = Mix.ar(sig) * pow(NamedControl.kr(\ ++ nameSpace ++ '_volume_master', 1, 0.1), 2); - }); - - sigs = Mix.ar(sigs / 4); - Out.ar(0, sigs) -}).add; - -SynthDef(\bass, { - var switches, drone; - switches = {|i| Dust.kr(0.1)} ! 9; - drone = {|i| var harm = pow(2, 2 - (i / 3).trunc), amp = (1 / pow(harm, 2)); - SinOsc.ar(60 * harm + TRand.kr(-3, 3, switches[i]), 0, amp)} ! 9; - Out.ar(~bassBusArray[0], Mix.new(drone) * 0.2); -}).add; - -SynthDef(\sampler, { - Out.ar(~samplerBusArray, PlayBuf.ar(2, ~sBuf, BufRateScale.kr(~sBuf), doneAction: 2)) -}).add; - -// main routine -SynthDef(\hdust, { - arg gate = 0; - var hierarchical_dust, low_sine, high_sine, brown_noise, white_noise; - // this triggers the combinations of sources - // it is similar to the Supercollider UGen called dust but with a hierarchical structure - hierarchical_dust = ( - TIRand.kr(0, 1, Impulse.kr(100)) * - TIRand.kr(0, 1, Impulse.kr(10)) * - TIRand.kr(0, 1, Impulse.kr(1)) * - TIRand.kr(0, 1, Impulse.kr(0.1)) - ); - // adjust the multiplier at the end of each line for adjusting levels - // note with each trigger, each source has a 1 in 3 chance of sounding - low_sine = SinOsc.ar(76.midicps / 16) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.1; - high_sine = SinOsc.ar(76.midicps * 8) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.01; - brown_noise = BrownNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.025; - white_noise = WhiteNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.02; - Out.ar(~hdustBusArray[0], - ((low_sine + high_sine + brown_noise + white_noise) ) - ); + Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.5).softclip; + sig1 = HPF.ar(sig1, 300); + Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); }).add; - ) -( -var bass, hdust, sampler, mixer; -/* -bass = Synth.tail(~group, \bass); -hdust = Synth.tail(~group, \hdust); -sampler = Synth.head(~group, \sampler); -*/ -mixer = Synth.tail(~group, \mixer); - -OSCdef(\mixer, {arg msg, time, addr, port; - mixer.set((msg[1] ++ '_' ++ msg[2] ++ '_' ++ msg[3]), msg[4]) -}, \mixer); - -/* -OSCdef(\sampler, {arg msg, time, addr, port; - msg.postln; - sampler.free; - ~sBuf.free; - ~sBuf = Buffer.read(s, msg[1].asString.postln, action: {sampler = Synth.head(~group, \sampler)}); -}, \sampler); -*/ -) - -/* old something ( SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; var trig, exc, sig1, sig2, noHarms, freqFinal, start, end; @@ -1029,5 +726,16 @@ SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); }).add; ) -*/ + + +"{\"a\": 1}".parseYAML["a"].asInteger; +"{\"a\": 1}".parseJSON["a"].isNumber; + +1223423434123.asHexString.toLower + +Date.getDate.rawSeconds +Date.seed.asHexString.toLower + +n = NetAddr("localhost", 8080); +n.sendMsg("/GET/#", (NetAddr.localAddr.hostname ++ ":" ++ NetAddr.localAddr.port), "/passage_probs_vals"); \ No newline at end of file diff --git a/resources/piece_ledger_sq1_candidates/628d5c8b/628d5c8b_mus_model.json b/resources/piece_ledger_sq1_candidates/628d5c8b/628d5c8b_mus_model.json new file mode 100644 index 0000000..a7c647e --- /dev/null +++ b/resources/piece_ledger_sq1_candidates/628d5c8b/628d5c8b_mus_model.json @@ -0,0 +1,56 @@ +{ +"music_data": +[ + [ + [ + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 0.625 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ], [ 0, 1, 0, 0, 0, 0 ] ], 0 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 1, 0, 0, 0, 0, -1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 0 ], [ 0, -1, 0, 0, 0, 1 ], [ 0, 1, 0, 0, 0, 0 ] ], 1.5 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ 0, 1, 0, 0, 0, -1 ], [ 0, 1, 0, 0, 0, 0 ] ], 1.75 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ "Rest" ], [ 0, 1, 0, 0, 0, 0 ] ], 1.125 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ] ], 0.5 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 0 ], + [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 1.25 ] + ] + ] +], +"last_changes": +[ + [ [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 1, 0 ], [ 0, 1, 0, 0, 0, 0 ] ], + [ [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ 0, 1, -1, 0, 0, 0 ], [ 0, 1, 0, 0, 0, 0 ] ], + [ [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ 0, 1, 0, 0, -1, 0 ], [ 0, 1, 0, 0, 0, 0 ] ], + [ [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ 0, -1, 0, 0, 0, 1 ], [ 0, 1, 0, 0, 0, 0 ] ], + [ [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ 0, 1, 0, 0, 0, -1 ], [ 0, 1, 0, 0, 0, 0 ] ] +], +"cur_uid": "628d5c8b", +"ref_uid": "7e170ef8", +"order_seed": 227004, +"dur_seed": 357129, +"motifs_seed": 170994, +"entrances_probs_vals": [ 0.75, 0.5, 2, 0, 0.5, 0.26424870466321, 0.75675675675676, 0.5, 0.5, 0.58549222797927, 0.72635135135135, 1, 0.5 ], +"passages_probs_vals": [ 0.75, 0.5, 2, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], +"exits_probs_vals": [ 0.75, 0.5, 2, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], +"ranges": [ [ 65, 727 ], [ 799, 1758 ], [ -282, 1013 ], [ -282, 799 ] ], +"passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], +"order": +[ + [ [ 0 ], [ 3, 2, 3, 3, 3, 3, 3, 3 ], [ 1 ] ], + [ [ 0, 3, 1 ], [ 2, 2, 2, 2, 2 ], [ ] ] +], +"sus_weights": [ 0.75, 0.69, 0.75 ], +"order_size": [ 2, 6 ], +"passages_size": [ 0, 10 ] +} \ No newline at end of file diff --git a/resources/66f6a618/66f6a618_code.scd b/resources/piece_ledger_sq1_candidates/66f6a618/66f6a618_code.scd similarity index 100% rename from resources/66f6a618/66f6a618_code.scd rename to resources/piece_ledger_sq1_candidates/66f6a618/66f6a618_code.scd diff --git a/resources/66f6a618/66f6a618_mus_model.json b/resources/piece_ledger_sq1_candidates/66f6a618/66f6a618_mus_model.json similarity index 100% rename from resources/66f6a618/66f6a618_mus_model.json rename to resources/piece_ledger_sq1_candidates/66f6a618/66f6a618_mus_model.json diff --git a/resources/53ad554b/53ad554b_code.scd b/resources/piece_ledger_sq1_candidates/6abf27d4/6abf27d4_code.scd similarity index 63% rename from resources/53ad554b/53ad554b_code.scd rename to resources/piece_ledger_sq1_candidates/6abf27d4/6abf27d4_code.scd index 55bfebd..127f295 100644 --- a/resources/53ad554b/53ad554b_code.scd +++ b/resources/piece_ledger_sq1_candidates/6abf27d4/6abf27d4_code.scd @@ -6,7 +6,7 @@ var hsArrayToCents, pDist, hdSum, hsChordalDistance, hsArrayToFreq; var isInRange, spacingScore, rangeScore, intervalScore, inclusionScore; // subroutines -var genTuples, initVoices, genOrders, genSubMotif, updateVoices, genDurFunc, genStepFunc; +var genTuples, initVoices, genOrders, genSubMotif, updateVoices, genDurFunc; // primary routines var genMotif, genSecondarySeq; @@ -17,19 +17,18 @@ var genPatterns, genMidiPatterns; // resource management funcs var seedFunc, genUID, writeResources, stringifyToDepth, setSeeds, sanityCheck, msgInterpret, loadLedgerFile, loadLedgerJSON, loadModelFile, loadModelJSON, -setGlobalVars, globalVarsToDict, saveLedger; +setGlobalVars, globalVarsToDict; // model vars //(model and global vars mostly set by OSC funcs var seq, lastXChanges, curUID, refUID, orderSeed, durSeed, motifSeed, entrancesProbVals, passagesProbVals, exitsProbVals, -ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, -orders, susWeights, orderSize, passagesSize, +ranges, passagesWeights, orders, susWeights, orderSize, passagesSize, motifEdited, orderEdited; // model aux vars -var entrancesDurFunc, passagesDurFunc, exitsDurFunc, stepFunc; +var entrancesDurFunc, passagesDurFunc, exitsDurFunc; // other global vars var popSize, exPath, dir, primes, dims, tuples, @@ -120,8 +119,7 @@ intervalScore = { arg hsArray1, hsArray2, mean, sd, signed = false; var pDistance; pDistance = pDist.value(hsArray1, hsArray2, signed); - //pDistance.gaussCurve(1, mean, sd) - stepFunc.value(pDistance); + pDistance.gaussCurve(1, mean, sd) }; inclusionScore = { @@ -173,18 +171,6 @@ genDurFunc = {arg chordProb, minPad, maxPad, minDur, maxDur, envData, seed; seedFunc.value(durFunc, seed); }; -genStepFunc = {arg minStep, maxStep, envData, seed; - var envDataNorm, env, pTable, stepFunc; - [minStep, maxStep, envData].postln; - envDataNorm = ([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).flop; - envDataNorm = [envDataNorm[0].normalize(minStep, maxStep), envDataNorm[1]].flop; - env = Env.pairs(envDataNorm); - stepFunc = {arg pDist; - env.at(pDist).clip(0.001, 1); - }; - seedFunc.value(stepFunc, seed); -}; - genOrders = {arg minMotifLength = 1, maxMotifLength = 5, minProgLength = 0, maxProgLength = 5; ((maxMotifLength - minMotifLength).rand + minMotifLength).collect({ var noProgIns, noSusIns, noSilentIns, prog, sus, silent, order; @@ -215,8 +201,7 @@ updateVoices = {arg ins, sus; recentlySoundedScore = inclusionScore.value(lastXChanges.flop[ins], candidate, 0); isInRangeScore = rangeScore.value(candidate, candidate.collect({0}), ranges[ins][0], ranges[ins][1], 0, true); regScore = spacingScore.value(voices.deepCopy.put(ins, candidate), 300); - hdScore = pow(hdSum.value(voices.deepCopy.put(ins, candidate)), hdExp); - if(hdInvert == 0, {hdScore = 1/hdScore}); + hdScore = 1/pow(hdSum.value(voices.deepCopy.put(ins, candidate)), 2); //maybe what you want here is a vector to another root and then favoring movement towards it. //distScore = pow(hsChordalDistance.value(voices, voices.put(ins, candidate)), 2); @@ -298,7 +283,7 @@ genSubMotif = {arg order, orderIndex, lastState, repeatLast = false, startFromLa }); //format and return - if(startFromLast, {lastXChanges = lastXChangesHold.deepCopy}); + if(startFromLast, {lastXChanges = lastXChangesHold}); res; }; @@ -306,7 +291,7 @@ genSubMotif = {arg order, orderIndex, lastState, repeatLast = false, startFromLa //------primary routines genMotif = { - var repeats, fSeq, fDur, durAdd; + var repeats, fSeq; repeats = 1; fSeq = []; @@ -328,13 +313,6 @@ genMotif = { fSeq = fSeq.add(motif); }); - - //round last duration to measure - fDur = fSeq.flatten.flatten.slice(nil, 1).sum; - durAdd = fDur.round(4) - fDur; - if(durAdd < 0, {durAdd = 4 - durAdd}); - fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] = fSeq[0][orders.size - 1][fSeq[0][orders.size - 1].size - 1][1] + durAdd; - fSeq }; @@ -370,69 +348,48 @@ Event.addEventType(\osc, { */ Event.addEventType(\osc, { - if (~addr.notNil) { - ~msg; + if (~addr.postln.notNil) { + ~msg.postln; ~addr.sendMsg(~path, *~msg); }; }); -genPatterns = {arg inSeq, addr, oneShot = false; - var voices, durs, pbinds, res, indices, sectionDurs, msg, ids, seq; +genPatterns = {arg inSeq, addr; + var voices, durs, patterns, res, indices, sectionDurs, msg, ids, seq; seq = inSeq.collect({arg mSeq; mSeq[0]}); # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; - pbinds = voices.flop.collect({arg voice, v; - var clumps, hdScores, freqs, fDurs, attacks, rels, amps; - clumps = voice.separate({arg a, b; a != b }); - freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); - fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - //attacks = 2.collect({rrand(1, 3)}) ++ freqs.drop(2).collect({rrand(0.3, 0.5)}); - attacks = fDurs.collect({arg dur; dur * rrand(0.2, 0.4)}); - //rels = freqs.drop(2).collect({rrand(0.3, 0.5)}) ++ 2.collect({rrand(1, 3)}); - rels = (clumps.size - 1).collect({arg c; - if(clumps[c + 1][0] == ["Rest"], {rrand(1.0, 3.0)}, {rrand(0.3, 0.5)}); - }); - rels = rels.add(rrand(1.0, 3.0)); - amps = freqs.collect({rrand(0.6, 0.99)}); + msg = inSeq.collect({arg mSeq, m; mSeq[1..]}); + //ids = inSeq.collect({arg mSeq, m; mSeq[2]}); + sectionDurs = seq.collect({arg mSeq; mSeq.flatten2(mSeq.maxDepth - 5).flop[1].sum}); + res = Ppar( + voices.flop.collect({arg voice; + var clumps, hdScores, freqs, fDurs; + clumps = voice.separate({arg a, b; a != b }); + freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); + fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); - [ Pbind( - \instrument, \string_model, + \instrument, \test, \group, group, \freq, Pseq(freqs, 1), \dur, Pseq(fDurs, 1), - \attack, Pseq(attacks, 1), - \sustain, Pseq(fDurs, 1), - \release, Pseq(rels, 1), - //\amp, Pseq(amps, 1), - \amp, Pbrown(0.5, 1, 0.5), - \busIndex, v - ), - Pbind( - \instrument, \sine, - \group, group, - \freq, Pseq(freqs, 1), - \dur, Pseq(fDurs, 1), - \sustain, Pseq(fDurs, 1), - \busIndex, v + \sustain, Pseq(fDurs, 1) ) - ] - }).flatten; - if(oneShot.not, { - msg = inSeq.collect({arg mSeq, m; mSeq[1..]}); - //ids = inSeq.collect({arg mSeq, m; mSeq[2]}); - sectionDurs = seq.collect({arg mSeq; mSeq.flatten2(mSeq.maxDepth - 5).flop[1].sum}); - pbinds = pbinds ++ + }) ++ [ Pbind( \type, \osc, \addr, addr, + //\indexPath, "/cur_play_index", + //\indexMsg, Pseq(indices, 1), + //\seqPath, "/mus_seq", + //\seqMsg, Pseq(seq, 1), \path, "/playing", \msg, Pseq(msg, 1), \dur, Pseq(sectionDurs, 1) ); ] - }); - res = Ppar(pbinds); + ); res }; @@ -540,15 +497,44 @@ msgInterpret = {arg in, escapeDoubleQuotes = true, escapeSingleQuotes = true; res = res.replace("Rest", "\"Rest\""); res = res.interpret; }, { - var tmpRes; - if(res.every({arg char; char.isDecDigit}), {tmpRes = res.asInteger}); - if(res.contains("."), {tmpRes = res.asFloat}); - if(tmpRes != nil, {res = tmpRes}); + //res.postln; + if(res.every({arg char; char.isDecDigit}), {res = res.asInteger}); }); }); res }; +/* +writeResources = {arg path; + var file, modelItems, resString; + file = File(path,"w"); + + modelItems = [ + seq, lastXChanges, + curUID, refUID, orderSeed, durSeed, motifSeed, + entrancesProbVals, passagesProbVals, exitsProbVals, + ranges, passagesWeights, orders, susWeights, orderSize, passagesSize, + motifEdited, orderEdited + ]; + + resString = [nameSpaces, modelItems].flop.collect({arg item; + var nameSpace, modelItem, depth = 0, insert = " "; + # nameSpace, modelItem = item; + if(nameSpace == "music_data", {depth = 3; insert = "\n"}); + if(nameSpace == "last_changes", {depth = 1; insert = "\n"}); + if(nameSpace == "order", {depth = 1; insert = "\n"}); + if((nameSpace == "ref_uid") && (modelItem == nil), {modelItem = "nil"}); + "\"" ++ nameSpace ++ "\":" ++ insert ++ stringifyToDepth.value(modelItem, depth) + }).join(",\n"); + + resString = "{\n" ++ resString ++ "\n}"; + + file.write(resString); + file.close; + resString +}; +*/ + writeResources = {arg path, dict; var file, modelItems, resString; file = File(path,"w"); @@ -557,8 +543,7 @@ writeResources = {arg path, dict; seq, lastXChanges, curUID, refUID, orderSeed, durSeed, motifSeed, entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, + ranges, passagesWeights, orders, susWeights, orderSize, passagesSize, motifEdited, orderEdited ]; @@ -582,20 +567,17 @@ loadModelFile = {arg path; loadModelJSON.value(File(path, "r").readAllString.par loadModelJSON = {arg jsonObject; var dict; + //model = File(path, "r").readAllString.parseJSON; dict = Dictionary.with(*nameSpaces.collect({arg nS; nS->msgInterpret.value(jsonObject[nS])})); dict }; -setGlobalVars = {arg dict, skipLastXChanges = false; - var tmpLastXChanges; - tmpLastXChanges = lastXChanges.deepCopy; +setGlobalVars = {arg dict; // order really matters!!!! # seq, lastXChanges, curUID, refUID, orderSeed, durSeed, motifSeed, entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, + ranges, passagesWeights, orders, susWeights, orderSize, passagesSize, motifEdited, orderEdited = nameSpaces.collect({arg nS; dict[nS]}); - if(skipLastXChanges, {lastXChanges = tmpLastXChanges}); dict }; @@ -606,8 +588,7 @@ globalVarsToDict = { seq, lastXChanges, curUID, refUID, orderSeed, durSeed, motifSeed, entrancesProbVals, passagesProbVals, exitsProbVals, - ranges, stepProbsVals, passagesWeights, hdExp, hdInvert, - orders, susWeights, orderSize, passagesSize, + ranges, passagesWeights, orders, susWeights, orderSize, passagesSize, motifEdited, orderEdited ]; dict = Dictionary.with(*nameSpaces.collect({arg nS, n; nS->modelItems[n]})); @@ -620,13 +601,6 @@ loadLedgerFile = {arg path; loadLedgerJSON = {arg jsonObject; ledger = jsonObject["ledger"]}; -saveLedger = {arg ledger, path; - var file; - file = File(path, "w"); - file.write("{\n\"ledger\":\n" ++ stringifyToDepth.value(ledger, 1) ++ "\n}"); - file.close; -}; - //------global vars primes = [[2, 1], [3, 2], [5, 4], [7, 4], [11, 8], [13, 8]]; @@ -638,7 +612,6 @@ dims = primes.size; tuples = genTuples.value(); //refUID = nil; group = Group.new; -~group = group; loadLedgerFile.value(dir +/+ ".." +/+ "resources" +/+ "piece_ledger.json"); //passagesWeights = [1, 1, 1, 1, 1]; //susWeights = [1, 1, 1]; @@ -646,8 +619,7 @@ loadLedgerFile.value(dir +/+ ".." +/+ "resources" +/+ "piece_ledger.json"); nameSpaces = [ "music_data", "last_changes", "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", - "ranges", "step_probs_vals", "passages_weights", "hd_exp", "hd_invert", - "order", "sus_weights", "order_size", "passages_size", + "ranges", "passages_weights", "order", "sus_weights", "order_size", "passages_size", "motif_edited", "order_edited" ]; @@ -664,13 +636,6 @@ OSCdef(\load_model, {arg msg, time, addr, port; setGlobalVars.value(dict); }, \load_model); -OSCdef(\save_ledger, {arg msg, time, addr, port; - msg.postln; - ledger = msgInterpret.value(msg[1].asString.parseJSON["ledger"], false).postln; - //loadLedgerJSON.value(msg[0]) - saveLedger.value(ledger, msg[2].asString); - //loadLedgerFile.value(msg[1].asString); -}, \save_ledger); OSCdef(\generate, {arg msg, time, addr, port; var path, dict, durSeeds, musPath, modelString; @@ -679,7 +644,7 @@ OSCdef(\generate, {arg msg, time, addr, port; path = msg[1].asString; dict = loadModelFile.value(path); - setGlobalVars.value(dict, true); + setGlobalVars.value(dict); popSize = ranges.size; @@ -689,16 +654,14 @@ OSCdef(\generate, {arg msg, time, addr, port; if(ledger == nil, {ledger = ["tmp"]}); if(ledger.last != "tmp", {ledger = ledger.add("tmp")}); - if(refUID == nil, {lastXChanges = [initVoices.value().deepCopy]}); - if((refUID != nil) && (refUID != "tmp"), { + lastXChanges = if(refUID == nil, { + [initVoices.value().deepCopy]; + }, { var file; file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - lastXChanges = msgInterpret.value(file.readAllString.parseJSON["last_changes"]); + msgInterpret.value(file.readAllString.parseJSON["last_changes"]); }); - refUID.postln; - lastXChanges.collect({arg item; item.postln}); - durSeeds = seedFunc.value({3.collect({rrand(100000, 999999)})}, durSeed).value.postln; entrancesDurFunc = genDurFunc.valueArray(entrancesProbVals[..4] ++ [entrancesProbVals[5..]] ++ [durSeeds[0]]); passagesDurFunc = genDurFunc.valueArray(passagesProbVals[..4] ++ [passagesProbVals[5..]] ++ [durSeeds[1]]); @@ -708,19 +671,13 @@ OSCdef(\generate, {arg msg, time, addr, port; orders = seedFunc.value(genOrders, orderSeed).valueArray(orderSize ++ passagesSize); //addr.sendMsg("/order", stringifyToDepth.value(orders, 1)); }); - - stepFunc = genStepFunc.valueArray(stepProbsVals[..1] ++ [stepProbsVals[2..]] ++ [motifSeed]); seq = seedFunc.value(genMotif, motifSeed).value; - lastXChanges.collect({arg item; item.postln}); - dict = globalVarsToDict.value; modelString = writeResources.value(path, dict); //addr.sendMsg("/generated", musPath, stringifyToDepth.value(seq, 3)); - //~seq = seq; - - addr.sendMsg("/generated", path, modelString, ledgerPath); + addr.sendMsg("/generated", path, modelString); }, \generate); @@ -737,6 +694,7 @@ OSCdef(\commit, {arg msg, time, addr, port; */ musicData = loadModelJSON.value(msg[1].asString.parseJSON)["music_data"].postln; + dict.postln; musicChanged = (musicData != seq).postln; curUID = genUID.value; @@ -746,11 +704,7 @@ OSCdef(\commit, {arg msg, time, addr, port; modelPath = (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_mus_model" ++ ".json").standardizePath; dict = globalVarsToDict.value; - if(musicChanged, { - seq = musicData; - dict["music_data"] = seq; - dict["motif_edited"] = "true" - }); + if(musicChanged, {dict["motif_edited"] = "true"}); dict["cur_uid"] = curUID; writeResources.value(modelPath, dict); @@ -758,9 +712,10 @@ OSCdef(\commit, {arg msg, time, addr, port; File.delete(ledgerPath ++ "_bak"); File.copy(ledgerPath, ledgerPath ++ "_bak"); File.delete(ledgerPath); + newLedger = File(ledgerPath, "w"); ledger = ledger.drop(-1).add(curUID); - - saveLedger.value(ledger, ledgerPath); + newLedger.write("{\n\"ledger\":\n" ++ stringifyToDepth.value(ledger, 1) ++ "\n}"); + newLedger.close; addr.sendMsg("/committed", curUID, ledgerPath); //refUID = curUID; @@ -770,125 +725,25 @@ OSCdef(\commit, {arg msg, time, addr, port; OSCdef(\transport, {arg msg, time, addr, port; msg.postln; if(msg[1] == 0, { - group.set(\release, 2); - group.set(\gate, 0); player.stop; + group.set(\gate, 0); }, { // the cued sequence can now be read from file, so this can be cleaned up var cSize, patterns, pSeq, cuedSeek, indexStart, indexEnd, tmpLedger; - if(msg[1] == 1, { - pSeq = []; - cuedSeek = (seq != nil); - indexStart = msg[2].asInteger; - indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - //ledger.postln; - if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.postln.parseJSON["music_data"]), path, indexStart + index, uid]); - file.close; - }); - }); - if(cuedSeek, { - var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); - file.close; - }); - patterns = genPatterns.value(pSeq, addr); - }, { - pSeq = [loadModelJSON.value(msg[2].asString.parseJSON)["music_data"].postln]; - patterns = genPatterns.value(pSeq, addr, true); - }); - player = Pfset(pattern: patterns, cleanupFunc: { - addr.sendMsg("/transport", 0); - addr.sendMsg("/one_shot", 0); - }); - player = player.play - }); -}, \transport); - - -OSCdef(\transcribe_motif, {arg msg, time, addr, port; - var tSeq, refChord, refUID; - - msg.postln; - - tSeq = [loadModelJSON.value(msg[1].asString.parseJSON)["music_data"]]; - refUID = msg[2].asString.postln; - - if((refUID != "nil") && (refUID != "tmp"), { - var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }, { - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - }); - - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "lilypond" +/+ "includes").standardizePath, addr, "/transcribe_motif"); -}, \transcribe_motif); - - -OSCdef(\transcribe_all, {arg msg, time, addr, port; - var cSize, patterns, cuedSeek, indexStart, indexEnd, tmpLedger; - if(true, { + pSeq = []; cuedSeek = (seq != nil); - indexStart = msg[1].asInteger; + indexStart = msg[2].asInteger; indexEnd = ledger.size - if(cuedSeek, {2}, {1}); - - //tmp for testing transcription - indexEnd = (indexStart+5); - //ledger.postln; if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { - var lilyPartLedgerFiles; - - lilyPartLedgerFiles = 4.collect({arg p; - File((dir +/+ ".." +/+ "lilypond" +/+ "includes" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly").standardizePath, "w"); - }); - ledger[indexStart..indexEnd].do({arg uid, index; - var path, file, fileString, tSeq, refUID, refChord; + var path, file; path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; file = File(path, "r"); - fileString = file.readAllString; - tSeq = msgInterpret.value(fileString.parseJSON["music_data"]); - refUID = msgInterpret.value(fileString.parseJSON["ref_uid"]); + pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, indexStart + index, uid]); file.close; - - //uid.postln; - //(refUID == "nil").postln; - - refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - - if(refUID != "nil", { - path = (dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath; - file = File(path, "r"); - refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; - file.close; - }); - - if(index != indexEnd, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath); - }, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath, addr, "/transcribe_all"); - }); - - lilyPartLedgerFiles.do({arg f, p; - f.write("\\include \".." +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly\"\n"); - }); - - }); - - lilyPartLedgerFiles.do({arg f; - f.close }); }); - /* if(cuedSeek, { var path, file; path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; @@ -896,121 +751,30 @@ OSCdef(\transcribe_all, {arg msg, time, addr, port; pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); file.close; }); - */ - }, { - + patterns = genPatterns.value(pSeq, addr); + player = Pfset(pattern: patterns, cleanupFunc: { + addr.sendMsg("/transport", 0); + }); + player = player.play }); - -}, \transcribe_all); +}, \transport); ) -~transcribe.value(~seq, dir); - ( -//synthdefs -~stringModelBusArray = 4.collect({Bus.audio(s, 1)}); -~sineBusArray = 4.collect({Bus.audio(s, 1)}); -~bassBusArray = 1.collect({Bus.audio(s, 1)}); -~hdustBusArray = 1.collect({Bus.audio(s, 1)}); -~samplerBusArray = 2.collect({Bus.audio(s, 1)}); -~sBuf = Buffer.alloc(s, 10, 2); -SynthDef(\string_model, {arg freq, gate = 1, sustain, amp, dur, attack, release = 1, busIndex = 0; +SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; var trig, exc, sig1, sig2, noHarms; - noHarms = rrand(20, 40); + noHarms = 30; exc = Saw.ar(freq, TRand.ar(0.5, 1, Impulse.ar(freq))) * 0.001 + Dust.ar(10000, 0.01); sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), - Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.8).softclip; - //sig1 = HPF.ar(sig1, 300); - Out.ar(Select.kr(busIndex, ~stringModelBusArray), sig1 * amp * EnvGen.kr(Env.adsr(attack, 0.3, 0.9, release, 0.9, -3), gate, doneAction: 2)); + Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.5).softclip; + sig1 = HPF.ar(sig1, 300); + Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); //Out.ar([0, 1], sig1 * EnvGen.kr(Env.asr(dur, 0.3, 1), gate, doneAction: 2)); }).add; - -SynthDef(\sine, {arg freq, gate = 1, sustain, amp, dur, busIndex = 0; - var sig; - sig = SinOsc.ar(freq); - Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.asr(0.3, 0.4, 0.3), gate, timeScale: dur, doneAction: 2)); - //Out.ar(Select.kr(busIndex, ~sineBusArray), sig * EnvGen.kr(Env.sine(dur), gate, doneAction: 2)); -}).add; - -SynthDef(\mixer, {arg freq, gate = 1, sustain, amp, dur, out; - var nameSpaces, sigs; - - sigs = [~stringModelBusArray, ~sineBusArray/*, ~bassBusArray, ~hdustBusArray, ~samplerBusArray*/].collect({arg busArray, i; - var nameSpace, sig; - nameSpace = ['string', 'sine', 'bass', 'hdust', 'sampler'][i]; - sig = busArray.collect({arg bus, c; In.ar(bus, 1) * NamedControl.kr(\ ++ nameSpace ++ '_volume_' ++ c, 1, 0.1)}); - sig = sig.collect({arg channel, c; Pan2.ar(channel, NamedControl.kr(\ ++ nameSpace ++ '_pan_' ++ c, i / (busArray.size - 1), 0.1) * 2 - 1)}); - sig = sig.collect({arg channel, c; channel * NamedControl.kr(\ ++ nameSpace ++ '_mute_' ++ c, 1, 0.1)}); - sig = Mix.ar(sig) * pow(NamedControl.kr(\ ++ nameSpace ++ '_volume_master', 1, 0.1), 2); - }); - - sigs = Mix.ar(sigs / 4); - Out.ar(0, sigs) -}).add; - -SynthDef(\bass, { - var switches, drone; - switches = {|i| Dust.kr(0.1)} ! 9; - drone = {|i| var harm = pow(2, 2 - (i / 3).trunc), amp = (1 / pow(harm, 2)); - SinOsc.ar(60 * harm + TRand.kr(-3, 3, switches[i]), 0, amp)} ! 9; - Out.ar(~bassBusArray[0], Mix.new(drone) * 0.2); -}).add; - -SynthDef(\sampler, { - Out.ar(~samplerBusArray, PlayBuf.ar(2, ~sBuf, BufRateScale.kr(~sBuf), doneAction: 2)) -}).add; - -// main routine -SynthDef(\hdust, { - arg gate = 0; - var hierarchical_dust, low_sine, high_sine, brown_noise, white_noise; - // this triggers the combinations of sources - // it is similar to the Supercollider UGen called dust but with a hierarchical structure - hierarchical_dust = ( - TIRand.kr(0, 1, Impulse.kr(100)) * - TIRand.kr(0, 1, Impulse.kr(10)) * - TIRand.kr(0, 1, Impulse.kr(1)) * - TIRand.kr(0, 1, Impulse.kr(0.1)) - ); - // adjust the multiplier at the end of each line for adjusting levels - // note with each trigger, each source has a 1 in 3 chance of sounding - low_sine = SinOsc.ar(76.midicps / 16) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.1; - high_sine = SinOsc.ar(76.midicps * 8) * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.01; - brown_noise = BrownNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.025; - white_noise = WhiteNoise.ar() * (TIRand.kr(0, 2, hierarchical_dust) < 1) * 0.02; - Out.ar(~hdustBusArray[0], - ((low_sine + high_sine + brown_noise + white_noise) ) - ); -}).add; - -) - -( -var bass, hdust, sampler, mixer; -/* -bass = Synth.tail(~group, \bass); -hdust = Synth.tail(~group, \hdust); -sampler = Synth.head(~group, \sampler); -*/ -mixer = Synth.tail(~group, \mixer); - -OSCdef(\mixer, {arg msg, time, addr, port; - mixer.set((msg[1] ++ '_' ++ msg[2] ++ '_' ++ msg[3]), msg[4]) -}, \mixer); - -/* -OSCdef(\sampler, {arg msg, time, addr, port; - msg.postln; - sampler.free; - ~sBuf.free; - ~sBuf = Buffer.read(s, msg[1].asString.postln, action: {sampler = Synth.head(~group, \sampler)}); -}, \sampler); -*/ ) -/* old something ( SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; var trig, exc, sig1, sig2, noHarms, freqFinal, start, end; @@ -1029,5 +793,16 @@ SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); }).add; ) -*/ + + +"{\"a\": 1}".parseYAML["a"].asInteger; +"{\"a\": 1}".parseJSON["a"].isNumber; + +1223423434123.asHexString.toLower + +Date.getDate.rawSeconds +Date.seed.asHexString.toLower + +n = NetAddr("localhost", 8080); +n.sendMsg("/GET/#", (NetAddr.localAddr.hostname ++ ":" ++ NetAddr.localAddr.port), "/passage_probs_vals"); \ No newline at end of file diff --git a/resources/piece_ledger_sq1_candidates/6abf27d4/6abf27d4_mus_model.json b/resources/piece_ledger_sq1_candidates/6abf27d4/6abf27d4_mus_model.json new file mode 100644 index 0000000..818ccbc --- /dev/null +++ b/resources/piece_ledger_sq1_candidates/6abf27d4/6abf27d4_mus_model.json @@ -0,0 +1,93 @@ +{ +"music_data": +[ + [ + [ + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "R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 0, 0 ], [ -2, 1, 0, 0, 1, 0 ], [ 0, 0, 0, 0, -1, 0 ], [ -1, 1, 0, 0, 2, 0 ] ], 1.625 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ -2, 1, 0, 0, 1, 0 ], [ 0, -1, 0, 0, 0, 0 ], [ -1, 1, 0, 0, 2, 0 ] ], 1 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ -2, 1, 0, 0, 1, 0 ], [ -1, 1, 0, 0, 1, -1 ], [ -1, 1, 0, 0, 2, 0 ] ], 9.75 ] + ], + [ + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ -1, 1, 0, 0, 1, -1 ], [ -1, 1, 0, 0, 2, 0 ] ], 0 ], + [ [ [ "Rest" ], [ "Rest" ], [ -1, 1, 0, 0, 1, -1 ], [ -1, 1, 0, 0, 2, 0 ] ], 1.25 ], + [ [ [ "Rest" ], [ "Rest" ], [ -3, 1, 0, 0, 2, 1 ], [ -1, 1, 0, 0, 2, 0 ] ], 1.875 ], + [ [ [ "Rest" ], [ "Rest" ], [ -3, 2, 0, 0, 2, 0 ], [ -1, 1, 0, 0, 2, 0 ] ], 1.25 ], + [ [ [ "Rest" ], [ "Rest" ], [ -2, 1, -1, 0, 2, 0 ], [ -1, 1, 0, 0, 2, 0 ] ], 2 ], + [ [ [ "Rest" ], [ "Rest" ], [ -3, 1, 0, 1, 2, 0 ], [ -1, 1, 0, 0, 2, 0 ] ], 7.625 ], + [ [ [ "Rest" ], [ "Rest" ], [ -3, 1, 0, 1, 2, 0 ], [ "Rest" ] ], 1 ], + [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 8.375 ] + ] + ] +], +"last_changes": +[ + [ [ 0, 0, 0, 0, 0, 0 ], [ -2, 1, 0, 0, 1, 0 ], [ -1, 1, 0, 0, 1, -1 ], [ -1, 1, 0, 0, 2, 0 ] ], + [ [ 0, 0, 0, 0, 0, 0 ], [ -2, 1, 0, 0, 1, 0 ], [ -3, 1, 0, 0, 2, 1 ], [ -1, 1, 0, 0, 2, 0 ] ], + [ [ 0, 0, 0, 0, 0, 0 ], [ -2, 1, 0, 0, 1, 0 ], [ -3, 2, 0, 0, 2, 0 ], [ -1, 1, 0, 0, 2, 0 ] ], + [ [ 0, 0, 0, 0, 0, 0 ], [ -2, 1, 0, 0, 1, 0 ], [ -2, 1, -1, 0, 2, 0 ], [ -1, 1, 0, 0, 2, 0 ] ], + [ [ 0, 0, 0, 0, 0, 0 ], [ -2, 1, 0, 0, 1, 0 ], [ -3, 1, 0, 1, 2, 0 ], [ -1, 1, 0, 0, 2, 0 ] ] +], +"cur_uid": "6abf27d4", +"ref_uid": "nil", +"order_seed": 587621, +"dur_seed": 706606, +"motifs_seed": 392608, +"entrances_probs_vals": [ 0.34, 6.468253968254, 9.2857142857143, 0.5, 2, 0, 0.5, 0.24509803921569, 0.89189189189189, 0.5, 1, 0.5, 0.5, 0.8562091503268, 0.69932432432432, 1, 0.5 ], +"passages_probs_vals": [ 0.34, 6.468253968254, 9.2857142857143, 0.5, 2, 0, 0.5, 0.24509803921569, 0.89189189189189, 0.5, 1, 0.5, 0.5, 0.8562091503268, 0.69932432432432, 1, 0.5 ], +"exits_probs_vals": [ 0.34, 6.468253968254, 9.2857142857143, 0.5, 2, 0, 0.5, 0.24509803921569, 0.89189189189189, 0.5, 1, 0.5, 0.5, 0.8562091503268, 0.69932432432432, 1, 0.5 ], +"ranges": [ [ -1200, 2400 ], [ -1200, 2400 ], [ -1200, 2400 ], [ -1200, 2400 ] ], +"passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], +"order": +[ + [ [ 0, 2, 3 ], [ 1, 1, 1, 1, 1 ], [ ] ], + [ [ 0 ], [ 3, 2, 1, 1, 3, 2, 3, 2, 1, 2 ], [ ] ], + [ [ 0, 3, 2 ], [ 1, 1, 1, 1, 1, 1 ], [ ] ], + [ [ 1, 2, 0 ], [ 3, 3, 3, 3, 3 ], [ ] ], + [ [ 1, 3, 0 ], [ 2, 2, 2, 2, 2 ], [ ] ], + [ [ 3 ], [ 2, 2, 2, 2 ], [ 1, 0 ] ] +], +"sus_weights": [ 0.75, 0.75, 0.75 ], +"order_size": [ 1, 10 ], +"passages_size": [ 0, 10 ], +"motif_edited": "false", +"order_edited": "false" +} \ No newline at end of file diff --git a/resources/piece_ledger_sq1_candidates/7ac10d34/7ac10d34_code.scd b/resources/piece_ledger_sq1_candidates/7ac10d34/7ac10d34_code.scd new file mode 100644 index 0000000..65c17df --- /dev/null +++ b/resources/piece_ledger_sq1_candidates/7ac10d34/7ac10d34_code.scd @@ -0,0 +1,719 @@ +( +// helper funcs +var hsArrayToCents, pDist, hdSum, hsChordalDistance, hsArrayToFreq; + +// score funcs +var isInRange, spacingScore, rangeScore, intervalScore, inclusionScore; + +// subroutines +var genTuples, initVoices, genOrders, genSubMotif, updateVoices, genDurFunc; + +// primary routines +var genMotif, genSecondarySeq; + +// audition funcs +var genPatterns, genMidiPatterns; + +// resource management funcs +var seedFunc, genUID, writeResources, stringifyToDepth, setSeeds, sanityCheck, +msgInterpret, loadLedgerFile, loadLedgerJSON, loadModelFile, loadModelJSON; + +// model vars +//(model and global vars mostly set by OSC funcs +var curUID, refUID, orderSeed, durSeed, motifSeed, +entrancesProbVals, passagesProbVals, exitsProbVals, +ranges, orders, susWeights, passagesWeights, passagesSize, orderSize; + +// model aux vars +var entrancesDurFunc, passagesDurFunc, exitsDurFunc; + +// other global vars +var lastXChanges, popSize, exPath, dir, primes, dims, tuples, +seq, group, player, ledgerPath, ledger, currentlyPlayingUID; + + +// install JSON quark +if(Quarks.isInstalled("JSONlib").not, { + Quarks.install("https://github.com/musikinformatik/JSONlib.git"); + thisProcess.recompile; + //HelpBrowser.openHelpFor("Classes/JSONlib"); +}); + + +//------helper funcs + +hsArrayToCents = { + arg hsArray; + hsArray.collect({arg dist, p; dist * 1200 * log2(primes[p][0]/primes[p][1])}).sum +}; + +pDist = { + arg array1, array2, signed = false; + var pDistance; + pDistance = hsArrayToCents.value(array1) - hsArrayToCents.value(array2); + if(signed, {pDistance}, {abs(pDistance)}) +}; + +hdSum = { + arg hsArrays; + var size, distances, mean; + size = hsArrays.size; + distances = (size - 1).collect({arg i; + ((i + 1)..(size - 1)).collect({arg j; + abs(hsArrays[i] - hsArrays[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum + }); + }).flat; + mean = distances.sum / distances.size; + distances.sum + //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) +}; + +hsChordalDistance = { + arg hsArrays1, hsArrays2; + var size, distances, mean; + size = hsArrays1.size; + distances = hsArrays1.size.collect({arg i; + hsArrays2.size.collect({arg j; + abs(hsArrays1[i] - hsArrays2[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum + }); + }).flat; + mean = distances.sum / distances.size; + distances.sum + //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) +}; + +hsArrayToFreq = { + arg array; + array.collect({arg dim, d; pow(primes[d][0]/primes[d][1], dim)}).product +}; + +//------score funcs + +/* +isInRange = { + arg hsArray, min, max; + var cents; + cents = hsArrayToCents.value(hsArray); + (cents >= min) && (cents <= max) +}; +*/ + +spacingScore = { + arg hsArrays, min; + var centsArray; + centsArray = hsArrays.collect({arg hsArray; hsArrayToCents.value(hsArray)}).sort({arg a, b; a < b}); + centsArray.differentiate.drop(1).collect({arg pDistance; if(pDistance >= min, {1}, {0.01})}).sum; +}; + +rangeScore = { + arg hsArray1, hsArray2, min, max, low, signed = false; + var pDistance; + pDistance = pDist.value(hsArray1, hsArray2, signed); + if((pDistance >= min) && (pDistance <= max), {1}, {low}); +}; + +intervalScore = { + arg hsArray1, hsArray2, mean, sd, signed = false; + var pDistance; + pDistance = pDist.value(hsArray1, hsArray2, signed); + pDistance.gaussCurve(1, mean, sd) +}; + +inclusionScore = { + arg array, test, min = 0.01; + if(array.collect({arg v; v.hash}).includes(test.hash), {min}, {1}); +}; + + +//------subroutines + +genTuples = { + var tuples; + tuples = dims.collect({[-1, 0, 1]}).allTuples.select({arg tuple; (abs(tuple.drop(1)).sum <= 1) && (tuple[0] == 0)}); + tuples = tuples ++ tuples.collect({arg tuple; [-3, -2, -1, 1, 2, 3].collect({arg octTrans; tuple.deepCopy.put(0, octTrans)})}).flatten; +}; + +initVoices = { + var init, voicesInit; + voicesInit = popSize.collect({dims.collect({0})}); + /* + voicesInit = [dims.collect({0})]; + (popSize - 1).do({ + arg rep, new; + rep = dims.rand; + new = voicesInit.last.deepCopy; + new[rep] = new[rep] + [-1, 1].choose(); + voicesInit = voicesInit.add(new); + }); + */ + voicesInit.deepCopy; +}; + +genDurFunc = {arg chordProb, min, max, envData; + var env, pTable, durFunc; + env = Env.pairs([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).asSignal(256).asList.asArray; + pTable = env.asRandomTable; + durFunc = {arg allowChord; + var res; + res = if(allowChord.not, { + pTable.tableRand * (max - min) + min + }, { + if(1.0.rand < chordProb, {0}, {pTable.tableRand * (max - min) + min}); + }).round(0.125); + if(res.asInteger == res, {res = res.asInteger}); + res + }; + seedFunc.value(durFunc, durSeed); +}; + +genOrders = {arg minMotifLength = 1, maxMotifLength = 5, minProgLength = 0, maxProgLength = 5; + ((maxMotifLength - minMotifLength).rand + minMotifLength).collect({ + var noProgIns, noSusIns, noSilentIns, prog, sus, silent, order; + noSusIns = [1, 2, 3].wchoose(susWeights.normalizeSum); + noProgIns = (popSize - noSusIns).rand + 1; + noSilentIns = popSize - noSusIns - noProgIns; + + # prog, sus, silent = (0..(popSize-1)).scramble.clumps([noProgIns, noSusIns, noSilentIns]); + + prog = (prog.scramble ++ ((maxProgLength - minProgLength).rand + minProgLength).collect({prog.choose}).scramble); + if(silent == nil, {silent = []}); + [sus.scramble, prog, silent.scramble] + }); +}; + +updateVoices = {arg ins, sus; + var voices, candidates, nWeights, nProbs, sel; + + voices = lastXChanges.deepCopy.last; + + candidates = sus.collect({arg v; tuples.collect({arg t; voices[v] + t})}).flatten; + candidates = difference(candidates.asSet, voices.asSet).asList; + nProbs = candidates.collect({arg candidate; + var stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore; + + //stepScore = intervalScore.value(voices[ins], candidate, 30, 400, 0.1); + stepScore = intervalScore.value(voices[ins], candidate, 100, 100); + recentlySoundedScore = inclusionScore.value(lastXChanges.flop[ins], candidate, 0); + isInRangeScore = rangeScore.value(candidate, candidate.collect({0}), ranges[ins][0], ranges[ins][1], 0, true); + regScore = spacingScore.value(voices.deepCopy.put(ins, candidate), 300); + hdScore = 1/pow(hdSum.value(voices.deepCopy.put(ins, candidate)), 2); + //maybe what you want here is a vector to another root and then favoring movement towards it. + //distScore = pow(hsChordalDistance.value(voices, voices.put(ins, candidate)), 2); + + [stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore] + }); + + nWeights = passagesWeights; + + //this handles nWeights of 0; mainly for testing + nProbs = nProbs.flop.select({arg scores, s; nWeights[s] != 0}).flop; + nWeights = nWeights.select({arg weight; weight != 0}); + nProbs = nProbs.flop.collect({arg scores, s; + if(scores.sum == 0, {scores}, {scores.normalizeSum * nWeights[s]}) + }); + nProbs = nProbs.flop.collect({arg scores, s; scores.product}).normalizeSum; + + sel = candidates.wchoose(nProbs); + + voices[ins] = sel; + lastXChanges = lastXChanges.add(voices).keep(-5); +}; + +genSubMotif = {arg order, lastState, repeatLast = false, startFromLast = false, isLastOrder = false; + var sus, prog, silent, flatOrder, res, isInChord, allowChord, lastXChangesHold, voices, adder; + # sus, prog, silent = order; + flatOrder = silent ++ sus ++ prog; + lastXChangesHold = lastXChanges.deepCopy; + voices = lastState.deepCopy; + isInChord = popSize.collect({false}); + allowChord = false; + res = []; + "------generating motif".postln; + //need to figure out here if voices move between motifs + flatOrder.do({arg ins, i; + + if(prog.includes(ins) && repeatLast.not, {updateVoices.value(ins, sus)}); + adder = if(silent.includes(ins), {["Rest"]}, {lastXChanges.last.deepCopy[ins]}); + + if(voices[ins] != adder, { + var dur; + allowChord = if((sus ++ silent).includes(ins), { + (sus ++ silent).includes(ins) && (ins != sus.last); + }, { + if(i < (flatOrder.size - 1), {(isInChord[flatOrder[i + 1]] || (ins == flatOrder[i + 1])).not}, {false}); + }); + dur = passagesDurFunc.value(allowChord); + if(dur == 0, {isInChord[ins] = true}, {isInChord = popSize.collect({false})}); + + voices[ins] = adder; + res = res.add([voices.deepCopy.postln, dur]); + }); + }); + + // pad ending + if(isLastOrder, { + (0..(popSize-1)).scramble.do({arg ins; + if(res.last.first[ins] != ["Rest"], { + var dur; + voices[ins] = ["Rest"]; + allowChord = (voices != popSize.collect({["Rest"]})); + dur = passagesDurFunc.value(allowChord); + res = res.add([voices.deepCopy.postln, dur]); + }); + }); + }); + + //format and return + if(startFromLast, {lastXChanges = lastXChangesHold}); + res; +}; + + +//------primary routines + +genMotif = { + var repeats, fSeq; + + repeats = 1; + fSeq = []; + + repeats.do({arg index; + var motif; + + motif = []; + + orders.do({arg order, o; + var lastState, subMotif; + lastState = if(o == 0, {popSize.collect({["Rest"]})}, {motif.last.last.first}); + subMotif = genSubMotif.value(order, lastState, isLastOrder: o == (orders.size - 1)); + motif = motif.add(subMotif); + + }); + + sanityCheck.value(motif, index); + + fSeq = fSeq.add(motif); + }); + fSeq +}; + +genSecondarySeq = {arg seq; + var curdles, fSeq; + curdles = []; + while({curdles.sum < seq.size}, {curdles = curdles ++ [3.rand + 1]}); + + fSeq = seq.clumps(curdles).collect({arg clump, m; + var repeats, paddedSeq; + + //add rest + paddedSeq = clump.add([[[popSize.collect({["Rest"]}), 0.5.rand]]]); + + //implement repeats + repeats = [0.rand + 1, 1].wchoose([1, 0].normalizeSum); + repeats.collect({paddedSeq}); + }); + fSeq +}; + + +//------audition funcs + +Event.addEventType(\osc, { + if (~addr.postln.notNil) { + ~addr.sendMsg(~indexPath, ~indexMsg); + ~addr.sendMsg(~seqPath, stringifyToDepth.value(~seqMsg, 3)); + //~addr.sendMsg("/STATE/OPEN", (dir.replace("supercollider", "resources") +/+ ~idMsg +/+ ~idMsg ++ "_gui_state" ++ ".state").standardizePath.postln); + }; +}); + +genPatterns = {arg inSeq, addr; + var voices, durs, patterns, res, indices, sectionDurs, ids, seq; + seq = inSeq.collect({arg mSeq; mSeq[0]}); + # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; + indices = inSeq.collect({arg mSeq, m; mSeq[1]}); + ids = inSeq.collect({arg mSeq, m; mSeq[2]}); + sectionDurs = seq.collect({arg mSeq; mSeq.flatten2(mSeq.maxDepth - 5).flop[1].sum}); + res = Ppar( + voices.flop.collect({arg voice; + var clumps, hdScores, freqs, fDurs; + clumps = voice.separate({arg a, b; a != b }); + freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); + fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); + + Pbind( + \instrument, \test, + \group, group, + \freq, Pseq(freqs, 1), + \dur, Pseq(fDurs, 1), + \sustain, Pseq(fDurs, 1) + ) + }) ++ + [ + Pbind( + \type, \osc, + \addr, addr, + \indexPath, "/cur_play_index", + \indexMsg, Pseq(indices.postln, 1), + \seqPath, "/mus_seq", + \seqMsg, Pseq(seq, 1), + \dur, Pseq(sectionDurs, 1) + ); + ] + ); + res +}; + +/* +genMidiPatterns = {arg seq; + var voices, durs, patterns, res, mOut, pbRange; + pbRange = 1; //semitones - change this as needed for your situation + mOut = MIDIOut.newByName("TiMidity", "TiMidity port 0").latency_(Server.default.latency); + # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; + res = Ppar( + voices.flop.collect({arg voice, v; + var clumps, hdScores, freqs, fDurs; + + mOut.program(v, 70); + + clumps = voice.separate({arg a, b; a != b }); + freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); + fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); + + Pbind( + \type, \midi, + \chan, v, + \noteval, Pseq(freqs.cpsmidi - 24, 1), + \note, Pfunc({ | event | event[\noteval].floor }), + \dur, Pseq(fDurs, 1), + \midiout, mOut, + \amp, 1, + \bend, Pfunc({ + | event | + if (event[\note].isRest.not) { + var pitchbendvalue = event[\noteval].frac.linlin(0, pbRange, 8192, 8192*2).asInteger; + m.bend(v, pitchbendvalue); + }; + 0; // return something other than nil to avoid stopping the pattern + }), + ); + }); + ); + res +}; +*/ + + +//------resource management funcs + +genUID = {Date.seed.asHexString.toLower}; + +seedFunc = {arg func, seed; + var funcArgs, next; + next = Routine({loop{func.valueArray(funcArgs).yield }}); + next.randSeed_(seed); + {arg ...args; funcArgs = args; next.value} +}; + +stringifyToDepth = {arg data, maxDepth = 1; + var prettyString = "", rCount = 0, writeArray, indent; + + if(maxDepth == 0, { + data.asCompileString + }, { + indent = {arg size; size.collect({" "}).join("")}; + writeArray = {arg array; + prettyString = prettyString ++ indent.value(rCount) ++ "[\n"; + rCount = rCount + 1; + if(rCount < (maxDepth - 0), { + array.do({arg subArray; writeArray.value(subArray)}); + }, { + prettyString = prettyString ++ array.collect({arg subArray; + indent.value(rCount + 1) ++ subArray.asCompileString + }).join(",\n"); + }); + rCount = rCount - 1; + prettyString = prettyString ++ "\n" ++ indent.value(rCount) ++ "],\n"; + }; + + writeArray.value(data); + prettyString.replace(",\n\n", "\n").drop(-2); + }) +}; + +sanityCheck = {arg motif, index; + //print functions = very helpful + ("----------" + index + "------------").postln; + + motif.flatten.do({arg val, v; + if(v > 0, { + if(motif.flatten[v-1][0].hammingDistance(val[0]) > 1, {"problem 1".postln}); + if(motif.flatten[v-1][0].hammingDistance(val[0]) == 0, {"problem 2".postln}); + }); + val.postln + }); + "***********".postln; +}; + +msgInterpret = {arg in, escapeDoubleQuotes = true, escapeSingleQuotes = true; + var res; + + res = in; + if(res.isNil.not, { + if((res.isArray && res.isString.not), { + res = res.asCompileString; + res = res.replace(" ", "").replace("\n", "").replace("\t", ""); + if(escapeSingleQuotes, {res = res.replace("\'", "")}); + if(escapeDoubleQuotes, {res = res.replace("\"", "")}); + res = res.replace("Rest", "\"Rest\""); + res = res.interpret; + }, { + //res.postln; + if(res.every({arg char; char.isDecDigit}), {res = res.asInteger}); + }); + }); + res +}; + +writeResources = {arg path; + var file, nameSpaces, modelItems, resString; + file = File(path,"w"); + + nameSpaces = [ + "music_data", "last_changes", + "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", + "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", + "ranges", "passages_weights", "order", "sus_weights", "order_size", "passages_size" + ]; + + modelItems = [ + seq, lastXChanges, + curUID, refUID, orderSeed, durSeed, motifSeed, + entrancesProbVals, passagesProbVals, exitsProbVals, + ranges, passagesWeights, orders, susWeights, orderSize, passagesSize + ]; + + resString = [nameSpaces, modelItems].flop.collect({arg item; + var nameSpace, modelItem, depth = 0, insert = " "; + # nameSpace, modelItem = item; + if(nameSpace == "music_data", {depth = 3; insert = "\n"}); + if(nameSpace == "last_changes", {depth = 1; insert = "\n"}); + if(nameSpace == "order", {depth = 1; insert = "\n"}); + "\"" ++ nameSpace ++ "\":" ++ insert ++ stringifyToDepth.value(modelItem.postln, depth).postln + }).join(",\n"); + + resString = "{\n" ++ resString ++ "\n}"; + + file.write(resString); + file.close; +}; + +loadModelFile = {arg path; loadModelJSON.value(File(path, "r").readAllString.parseJSON)}; + +loadModelJSON = {arg model; + var nameSpaces, data; + + //model = File(path, "r").readAllString.parseJSON; + + nameSpaces = [ + "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", + "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", + "ranges", "passages_weights", "order", "sus_weights", "order_size", "passages_size" + ]; + + data = nameSpaces.collect({arg nS; msgInterpret.value(model[nS]).postln}); + + data.postln; + + # curUID, refUID, orderSeed, durSeed, motifSeed, + entrancesProbVals, passagesProbVals, exitsProbVals, + ranges, passagesWeights, orders, susWeights, orderSize, passagesSize = data; + + popSize = ranges.size; +}; + +loadLedgerFile = {arg path; + ledgerPath = path; + loadLedgerJSON.value(File(ledgerPath, "r").readAllString.parseJSON) +}; + +loadLedgerJSON = {arg ledger; ledger = ledger["ledger"]}; + +//------global vars + +primes = [[2, 1], [3, 2], [5, 4], [7, 4], [11, 8], [13, 8]]; +//ranges = [[-2400, 0], [-1200, 1200], [0, 2400], [0, 2400]]; +exPath = thisProcess.nowExecutingPath; +dir = exPath.dirname; +//popSize = 4; +dims = primes.size; +tuples = genTuples.value(); +//refUID = nil; +group = Group.new; +loadLedgerFile.value(dir +/+ ".." +/+ "resources" +/+ "piece_ledger.json"); +//passagesWeights = [1, 1, 1, 1, 1]; +//susWeights = [1, 1, 1]; + + +//------OSC funcs + +OSCdef(\load_ledger, {arg msg, time, addr, port; + loadLedgerFile.value(msg[1].asString); +}, \load_ledger); + +OSCdef(\load_model, {arg msg, time, addr, port; + loadModelFile.value(msg[1].asString); +}, \load_model); + + +OSCdef(\generate, {arg msg, time, addr, port; + var path, dFormat, condition, musPath; + msg.postln; + + path = msg[1].asString; + + loadModelFile.value(path); + + refUID.postln; + + loadLedgerFile.value(ledgerPath); + if(ledger == nil, {ledger = ["tmp"]}); + if(ledger.last != "tmp", {ledger = ledger.add("tmp")}); + + lastXChanges = if(refUID == nil, { + [initVoices.value().deepCopy]; + }, { + var file; + refUID.postln; + file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); + msgInterpret.value(file.readAllString.parseJSON["last_changes"]); + }); + + entrancesDurFunc = genDurFunc.valueArray(entrancesProbVals[..2] ++ [entrancesProbVals[3..]]); + passagesDurFunc = genDurFunc.valueArray(passagesProbVals[..2] ++ [passagesProbVals[3..]]); + exitsDurFunc = genDurFunc.valueArray(exitsProbVals[..2] ++ [exitsProbVals[3..]]); + + if(orders == nil, { + orders = seedFunc.value(genOrders, orderSeed).valueArray(orderSize ++ passagesSize); + addr.sendMsg("/order", stringifyToDepth.value(orders, 1)); + }); + seq = seedFunc.value(genMotif, motifSeed).value; + + //musPath = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; + writeResources.value(path); + + //orders = nil; + //addr.sendMsg("/current_uid", curUID); + //addr.sendMsg("/ledger", prettifyArray.value(ledger, 1).replace("\"", "")); + //addr.sendMsg("/ledger_size", ledger.size); + //addr.sendMsg("/mus_seq", prettifyArray.value(seq, 3)); + addr.sendMsg("/generated", musPath, stringifyToDepth.value(seq, 3)); +}, \generate); + + +OSCdef(\commit, {arg msg, time, addr, port; + var newLedger, modelPath, musString, musFile, test1, test2; + msg.postln; + + /* + test1 = msg[1].asString.parseJSON; + test2 = (dir +/+ ".." +/+ "resources/tmp/tmp_music" ++ ".json").standardizePath.parseJSONFile; + msgInterpret.value(test1["music"])[0][0][0][1].class.postln; + msgInterpret.value(test2["music_data"])[0][0][0][1].class.postln; + (test1["music"] == test2["music_data"]).postln; + */ + + curUID = genUID.value; + File.mkdir((dir +/+ ".." +/+ "resources" +/+ curUID).standardizePath); + File.copy(exPath, (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_code" ++ ".scd").standardizePath); + + modelPath = (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_mus_model" ++ ".json").standardizePath; + writeResources.value(modelPath); + + File.delete(ledgerPath.postln ++ "_bak"); + File.copy(ledgerPath, ledgerPath ++ "_bak"); + File.delete(ledgerPath); + newLedger = File(ledgerPath.postln, "w"); + ledger = ledger.postln.drop(-1).add(curUID); + newLedger.write("{\n\"ledger\":\n" ++ stringifyToDepth.value(ledger, 1) ++ "\n}"); + newLedger.close; + + addr.sendMsg("/committed", curUID, ledgerPath); + //refUID = curUID; +}, \commit); + +OSCdef(\transport, {arg msg, time, addr, port; + msg.postln; + if(msg[1] == 0, { + player.stop; + group.set(\gate, 0); + }, { + // the cued sequence can now be read from file, so this can be cleaned up + var cSize, patterns, pSeq, cuedSeek, indexStart, indexEnd, tmpLedger; + pSeq = []; + cuedSeek = (seq != nil); + indexStart = msg[2].asInteger; + indexEnd = ledger.size - if(cuedSeek, {2}, {1}); + if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { + ledger[indexStart..indexEnd].do({arg uid, index; + var file; + (indexStart + index).postln; + file = File((dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_music" ++ ".json").standardizePath, "r"); + pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), indexStart + index, uid]); + file.close; + }); + }); + if(cuedSeek, {pSeq = pSeq.add([seq, ledger.size - 1])}); + patterns = genPatterns.value(pSeq, addr); + player = Pfset(pattern: patterns, cleanupFunc: { + addr.sendMsg("/transport", 0); + }); + player = player.play + }); +}, \transport); + +) + +( +SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; + var trig, exc, sig1, sig2, noHarms; + noHarms = 30; + exc = Saw.ar(freq, TRand.ar(0.5, 1, Impulse.ar(freq))) * 0.001 + Dust.ar(10000, 0.01); + sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), + Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), + Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.5).softclip; + sig1 = HPF.ar(sig1, 300); + Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); +}).add; +) + +( +SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; + var trig, exc, sig1, sig2, noHarms, freqFinal, start, end; + noHarms = 30; + freq = WhiteNoise.ar * 3 + freq; + freqFinal = Duty.ar((1/freq), 0, freq); + trig = Changed.ar(freqFinal); + start = Demand.ar(trig, 0, Dwhite(-1, -0.75)); + end = Demand.ar(trig, 0, Dwhite(0.75, 1)); + exc = Phasor.ar(trig, (end - start) * freqFinal / SampleRate.ir, start, end, 0) * 0.001 + Dust.ar(10000, 0.01); + + sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), + Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), + Array.fill(noHarms, {rrand(2, 3)}) ], exc) * 0.5).softclip; + sig1 = HPF.ar(sig1, 300); + Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); +}).add; +) + + + +"{\"a\": 1}".parseYAML["a"].asInteger; +"{\"a\": 1}".parseJSON["a"].isNumber; + +1223423434123.asHexString.toLower + +Date.getDate.rawSeconds +Date.seed.asHexString.toLower + +n = NetAddr("localhost", 8080); +n.sendMsg("/GET/#", (NetAddr.localAddr.hostname ++ ":" ++ NetAddr.localAddr.port), "/passage_probs_vals"); \ No newline at end of file diff --git a/resources/piece_ledger_sq1_candidates/7ac10d34/7ac10d34_gui_state.json b/resources/piece_ledger_sq1_candidates/7ac10d34/7ac10d34_gui_state.json new file mode 100644 index 0000000..84e6edd --- /dev/null +++ b/resources/piece_ledger_sq1_candidates/7ac10d34/7ac10d34_gui_state.json @@ -0,0 +1,1359 @@ +{ + "motif_label": "motif", + "seeds_label": "seeds", + "order": "[\n [ [ 3, 1, 0 ], [ 2 ], [ ] ],\n [ [ 1, 2 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 3 ] ],\n [ [ 3, 2 ], [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ], [ 0 ] ],\n [ [ 2, 3 ], [ 0, 1, 0 ], [ ] ]\n]", + "order_lock": 1, + "order_size": [ + 3, + 8 + ], + "order_size_v2": 8, + "order_size_v1": 3, + "order_size_panel": -1, + "passage_size_v2": 8, + "passage_size_v1": 2, + "passage_size_panel": -1, + "sus_weights": [ + null, + null, + null + ], + "range_matrix": [ + null, + null, + null, + null + ], + "instrumentation": [ + 0, + 0 + ], + "entrances_probs_sync": "passages", + "entrances": -1, + "passages_probs_sync": "passages", + "passages": -1, + "exits_probs_sync": "passages", + "exits": -1, + "dur_panel": 0, + "durations": -1, + "passages_weights": [ + null, + null, + null, + null, + null + ], + "weights": -1, + "seeds_tab_panel": 0, + "weights_seed_lock": 0, + "weights_seed": 534103, + "sus_weights/0_slider_val": 0.21, + "sus_weights/0_slider_slider": 0.21, + "sus_weights/0_slider_input": 0.21, + "sus_weights/0_slider_label": 1, + "sus_weights/0_slider": -1, + "sus_weights/1_slider_val": 0.35, + "sus_weights/1_slider_slider": 0.35, + "sus_weights/1_slider_input": 0.35, + "sus_weights/1_slider_label": 2, + "sus_weights/1_slider": -1, + "sus_weights/2_slider_val": 0.21, + "sus_weights/2_slider_slider": 0.21, + "sus_weights/2_slider_input": 0.21, + "sus_weights/2_slider_label": 3, + "sus_weights/2_slider": -1, + "passages_weights/0_slider_val": 0.49, + "passages_weights/0_slider_slider": 0.49, + "passages_weights/0_slider_input": 0.49, + "passages_weights/0_slider_label": "step", + "passages_weights/0_slider": -1, + "passages_weights/1_slider_val": 0.53, + "passages_weights/1_slider_slider": 0.53, + "passages_weights/1_slider_input": 0.53, + "passages_weights/1_slider_label": "dc", + "passages_weights/1_slider": -1, + "passages_weights/2_slider_val": 0.35, + "passages_weights/2_slider_slider": 0.35, + "passages_weights/2_slider_input": 0.35, + "passages_weights/2_slider_label": "range", + "passages_weights/2_slider": -1, + "passages_weights/3_slider_val": 0.59, + "passages_weights/3_slider_slider": 0.59, + "passages_weights/3_slider_input": 0.59, + "passages_weights/3_slider_label": "registration", + "passages_weights/3_slider": -1, + "passages_weights/4_slider_val": 0.39, + "passages_weights/4_slider_slider": 0.39, + "passages_weights/4_slider_input": 0.39, + "passages_weights/4_slider_label": "hd", + "passages_weights/4_slider": -1, + "range_matrix/0_val_input_min": -853.2067988668555, + "range_matrix/0_val_rslider": [ + -853.2067988668555, + 401 + ], + "range_matrix/0_val_input_max": 401, + "range_matrix/0_val": -1, + "range_matrix/1_val_input_min": -659, + "range_matrix/1_val_rslider": [ + -659, + 880 + ], + "range_matrix/1_val_input_max": 880, + "range_matrix/1_val": -1, + "range_matrix/2_val_input_min": -241, + "range_matrix/2_val_rslider": [ + -241, + 1869 + ], + "range_matrix/2_val_input_max": 1869, + "range_matrix/2_val": -1, + "range_matrix/3_val_input_min": -27, + "range_matrix/3_val_rslider": [ + -27, + 2063 + ], + "range_matrix/3_val_input_max": 2063, + "range_matrix/3_val": -1, + "entrances_probs_chord_slider_val": 0.66, + "entrances_probs_chord_slider_slider": 0.66, + "entrances_probs_chord_slider_input": 0.66, + "entrances_probs_chord_slider_label": "chord prob", + "entrances_probs_chord_slider": -1, + "entrances_probs_vals": [ + 0.63, + 0, + 5, + 0, + 0.5, + 0.23316062176165803, + 0.7094594594594594, + 0.3963730569948187, + 0.8716216216216216, + 0.4948186528497409, + 0.5912162162162162, + 0.5362694300518135, + 0.8614864864864865, + 0.6424870466321243, + 0.5912162162162162, + 0.7901554404145078, + 0.8277027027027027, + 1, + 0.5 + ], + "entrances_probs": -1, + "passages_probs_chord_slider_val": 0.63, + "passages_probs_chord_slider_slider": 0.63, + "passages_probs_chord_slider_input": 0.63, + "passages_probs_chord_slider_label": "chord prob", + "passages_probs_chord_slider": -1, + "passages_probs_vals": [ + 0.63, + 0, + 5, + 0, + 0.5, + 0.23316062176165803, + 0.7094594594594594, + 0.3963730569948187, + 0.8716216216216216, + 0.4948186528497409, + 0.5912162162162162, + 0.5362694300518135, + 0.8614864864864865, + 0.6424870466321243, + 0.5912162162162162, + 0.7901554404145078, + 0.8277027027027027, + 1, + 0.5 + ], + "passages_probs": -1, + "exits_probs_chord_slider_val": 0, + "exits_probs_chord_slider_slider": 0, + "exits_probs_chord_slider_input": 0, + "exits_probs_chord_slider_label": "chord prob", + "exits_probs_chord_slider": -1, + "exits_probs_vals": [ + 0, + 0, + 5, + 0, + 0.5, + 0.23316062176165803, + 0.7094594594594594, + 0.4948186528497409, + 0.5912162162162162, + 0.7901554404145078, + 0.8277027027027027, + 1, + 0.5 + ], + "exits_probs": -1, + "step_env_env_vals": [ + 0, + 5, + 0, + 0, + 0, + 0, + 0.14609053497942387, + 0.7613636363636364, + 0.20164609053497942, + 0.26136363636363635, + 0.24279835390946503, + 0.7215909090909092, + 0.39094650205761317, + 0.875, + 0.4567901234567901, + 0.44318181818181823, + 0.5432098765432098, + 0.34659090909090906, + 0.6481481481481481, + 0.8011363636363636, + 0.6810699588477366, + 0.5170454545454546, + 0.8868312757201646, + 0.49431818181818177, + 0.8868312757201646, + 0.49431818181818177 + ], + "step_env_env_canvas": [ + [ + 0, + 0 + ], + [ + 0, + 0 + ], + [ + 0.14609053497942387, + 0.7613636363636364 + ], + [ + 0.20164609053497942, + 0.26136363636363635 + ], + [ + 0.24279835390946503, + 0.7215909090909092 + ], + [ + 0.39094650205761317, + 0.875 + ], + [ + 0.4567901234567901, + 0.44318181818181823 + ], + [ + 0.5432098765432098, + 0.34659090909090906 + ], + [ + 0.6481481481481481, + 0.8011363636363636 + ], + [ + 0.6810699588477366, + 0.5170454545454546 + ], + [ + 0.8868312757201646, + 0.49431818181818177 + ], + [ + 0.8868312757201646, + 0.49431818181818177 + ], + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "step_env_env_size": 12, + "step_env_env_flatten": 0, + "step_env_env_rslider": [ + 0, + 5 + ], + "step_env_env_rslider_v2": 5, + "step_env_env_rslider_v1": 0, + "step_env_env_mpos": "", + "step_env_env": -1, + "entrances_probs_dur_env_vals": [ + 0.515267175572519, + 4.599236641221374, + 0, + 0.5, + 0.2772020725388601, + 0.7972972972972973, + 0.45077720207253885, + 0.8783783783783784, + 0.5, + 0.5, + 0.727979274611399, + 0.45270270270270274, + 0.7357512953367875, + 0.6486486486486487, + 0.8911917098445595, + 0.7905405405405406, + 1, + 0.5 + ], + "entrances_probs_dur_env_canvas": [ + [ + 0, + 0.5 + ], + [ + 0.2772020725388601, + 0.7972972972972973 + ], + [ + 0.45077720207253885, + 0.8783783783783784 + ], + [ + 0.5, + 0.5 + ], + [ + 0.727979274611399, + 0.45270270270270274 + ], + [ + 0.7357512953367875, + 0.6486486486486487 + ], + [ + 0.8911917098445595, + 0.7905405405405406 + ], + [ + 1, + 0.5 + ], + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "entrances_probs_dur_env_size": 8, + "entrances_probs_dur_env_flatten": 0, + "entrances_probs_dur_env_rslider": [ + 0.515267175572519, + 4.599236641221374 + ], + "entrances_probs_dur_env_rslider_v2": 4.599236641221374, + "entrances_probs_dur_env_rslider_v1": 0.515267175572519, + "entrances_probs_dur_env_mpos": "", + "entrances_probs_dur_env": -1, + "passages_probs_dur_env_vals": [ + 0, + 5, + 0, + 0.5, + 0.23316062176165803, + 0.7094594594594594, + 0.3963730569948187, + 0.8716216216216216, + 0.4948186528497409, + 0.5912162162162162, + 0.5362694300518135, + 0.8614864864864865, + 0.6424870466321243, + 0.5912162162162162, + 0.7901554404145078, + 0.8277027027027027, + 1, + 0.5 + ], + "passages_probs_dur_env_canvas": [ + [ + 0, + 0.5 + ], + [ + 0.23316062176165803, + 0.7094594594594594 + ], + [ + 0.3963730569948187, + 0.8716216216216216 + ], + [ + 0.4948186528497409, + 0.5912162162162162 + ], + [ + 0.5362694300518135, + 0.8614864864864865 + ], + [ + 0.6424870466321243, + 0.5912162162162162 + ], + [ + 0.7901554404145078, + 0.8277027027027027 + ], + [ + 1, + 0.5 + ], + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "passages_probs_dur_env_size": 8, + "passages_probs_dur_env_flatten": 0, + "passages_probs_dur_env_rslider": [ + 0, + 5 + ], + "passages_probs_dur_env_rslider_v2": 5, + "passages_probs_dur_env_rslider_v1": 0, + "passages_probs_dur_env_mpos": "", + "passages_probs_dur_env": -1, + "exits_probs_dur_env_vals": [ + 0, + 5, + 0, + 0.5, + 0.5, + 0.5, + 1, + 0.5 + ], + "exits_probs_dur_env_canvas": [ + [ + 0, + 0.5 + ], + [ + 0.5, + 0.5 + ], + [ + 1, + 0.5 + ], + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "exits_probs_dur_env_size": 3, + "exits_probs_dur_env_flatten": 0, + "exits_probs_dur_env_rslider": [ + 0, + 5 + ], + "exits_probs_dur_env_rslider_v2": 5, + "exits_probs_dur_env_rslider_v1": 0, + "exits_probs_dur_env_mpos": "", + "exits_probs_dur_env": -1, + "mus_seq": [ + [ + [ + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + "Rest" + ], + [ + "Rest" + ] + ], + 0 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + "Rest" + ] + ], + 1.75 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.75 + ], + [ + [ + [ + 0, + 1, + -3, + 0, + 2, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0.75 + ], + [ + [ + [ + 1, + 1, + -2, + -2, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0.625 + ], + [ + [ + [ + 1, + 1, + -3, + -1, + 0, + 0 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0.625 + ], + [ + [ + [ + 1, + 0, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.75 + ] + ], + [ + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.75 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 1, + -2, + 0, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.375 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 2, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0.75 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 1, + -2, + -1, + 2, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.75 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 0, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.875 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1 + ] + ], + [ + [ + [ + [ + 1, + 0, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0 + ], + [ + [ + [ + 1, + 0, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 2, + 0, + -3, + -1, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.625 + ], + [ + [ + [ + 1, + 0, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 1, + -1, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.75 + ], + [ + [ + [ + 1, + 0, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 1, + -1, + -1, + 1, + 0 + ], + [ + "Rest" + ] + ], + 0 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 1, + -1, + -1, + 1, + 0 + ], + [ + "Rest" + ] + ], + 1.875 + ], + [ + [ + [ + "Rest" + ], + [ + "Rest" + ], + [ + 0, + 1, + -1, + -1, + 1, + 0 + ], + [ + "Rest" + ] + ], + 0 + ], + [ + [ + [ + "Rest" + ], + [ + "Rest" + ], + [ + "Rest" + ], + [ + "Rest" + ] + ], + 0.875 + ] + ] + ] + ], + "root": [ + 0.20743639921722112, + 0 + ], + "order_seed": 798574, + "dur_seed": 884869, + "passages_size": [ + 0, + 10 + ], + "dur_seed_lock": 1, + "order_seed_lock": 0, + "seeds_panel": -1, + "motif_panel": [ + 0, + 0 + ], + "ref_uid": "6f1a789f", + "cur_uid": "7ac10d34" +} \ No newline at end of file diff --git a/resources/piece_ledger_sq1_candidates/7ac10d34/7ac10d34_mus_model.json b/resources/piece_ledger_sq1_candidates/7ac10d34/7ac10d34_mus_model.json new file mode 100644 index 0000000..73f197b --- /dev/null +++ b/resources/piece_ledger_sq1_candidates/7ac10d34/7ac10d34_mus_model.json @@ -0,0 +1,59 @@ +{ +"music_data": +[ + [ + [ + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 1.375 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 0, 0, 0, 0, 0, 1 ], [ "Rest" ] ], 0.875 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 0, 1, 0, 0, 0, 0 ], [ "Rest" ] ], 0.875 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 0, 0, 0, 0, 1, 0 ], [ "Rest" ] ], 0.75 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 1, 0, 0, 0, -1, 0 ], [ "Rest" ] ], 1.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] ], 1.75 ], + [ [ [ 1, -1, 1, -1, 0, 0 ], [ 2, -1, 0, -1, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ] ], 1.5 ], + [ [ [ 2, -2, 0, -1, 0, 0 ], [ 2, -1, 0, -1, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ] ], 1.25 ], + [ [ [ 2, -2, 0, -1, 0, 0 ], [ 2, -1, 0, -1, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ "Rest" ] ], 0.875 ], + [ [ [ 2, -2, 0, -1, 0, 0 ], [ 2, -1, 0, -1, 0, 0 ], [ "Rest" ], [ "Rest" ] ], 0 ], + [ [ [ 2, -2, 0, -1, 0, 0 ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 0 ], + [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 1.375 ] + ] + ] +], +"last_changes": +[ + [ [ 1, 0, -1, -1, 0, 0 ], [ 2, -1, 0, -1, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ] ], + [ [ 2, -1, 0, -1, 0, -1 ], [ 2, -1, 0, -1, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ] ], + [ [ 2, -1, 0, -2, 0, 0 ], [ 2, -1, 0, -1, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ] ], + [ [ 1, -1, 1, -1, 0, 0 ], [ 2, -1, 0, -1, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ] ], + [ [ 2, -2, 0, -1, 0, 0 ], [ 2, -1, 0, -1, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ] ] +], +"cur_uid": "7ac10d34", +"ref_uid": "46b6952a", +"order_seed": 638872, +"dur_seed": 225879, +"motifs_seed": 992393, +"entrances_probs_vals": [ 0.75, 0.5, 2, 0, 0.5, 0.26424870466321, 0.75675675675676, 0.5, 0.5, 0.58549222797927, 0.72635135135135, 1, 0.5 ], +"passages_probs_vals": [ 0.75, 0.5, 2, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], +"exits_probs_vals": [ 0.75, 0.5, 2, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], +"ranges": [ [ -384, 2400 ], [ -507, 2400 ], [ -282, 2237 ], [ -1200, 2053 ] ], +"passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], +"order": +[ + [ [ 0 ], [ 2, 2, 2, 2, 2, 2, 2 ], [ 3, 1 ] ], + [ [ 1, 2, 3 ], [ 0, 0, 0, 0, 0, 0, 0, 0 ], [ ] ] +], +"sus_weights": [ 0.75, 0.69, 0.75 ], +"order_size": [ 2, 6 ], +"passages_size": [ 0, 10 ] +} \ No newline at end of file diff --git a/resources/piece_ledger_sq1_candidates/7e170ef8/7e170ef8_code.scd b/resources/piece_ledger_sq1_candidates/7e170ef8/7e170ef8_code.scd new file mode 100644 index 0000000..b11446a --- /dev/null +++ b/resources/piece_ledger_sq1_candidates/7e170ef8/7e170ef8_code.scd @@ -0,0 +1,718 @@ +( +// helper funcs +var hsArrayToCents, pDist, hdSum, hsChordalDistance, hsArrayToFreq; + +// score funcs +var isInRange, spacingScore, rangeScore, intervalScore, inclusionScore; + +// subroutines +var genTuples, initVoices, genOrders, genSubMotif, updateVoices, genDurFunc; + +// primary routines +var genMotif, genSecondarySeq; + +// audition funcs +var genPatterns, genMidiPatterns; + +// resource management funcs +var seedFunc, genUID, writeResources, stringifyToDepth, setSeeds, sanityCheck, +msgInterpret, loadLedgerFile, loadLedgerJSON, loadModelFile, loadModelJSON; + +// model vars +//(model and global vars mostly set by OSC funcs +var curUID, refUID, orderSeed, durSeed, motifSeed, +entrancesProbVals, passagesProbVals, exitsProbVals, +ranges, orders, susWeights, passagesWeights, passagesSize, orderSize; + +// model aux vars +var entrancesDurFunc, passagesDurFunc, exitsDurFunc; + +// other global vars +var lastXChanges, popSize, exPath, dir, primes, dims, tuples, +seq, group, player, ledgerPath, ledger, currentlyPlayingUID; + + +// install JSON quark +if(Quarks.isInstalled("JSONlib").not, { + Quarks.install("https://github.com/musikinformatik/JSONlib.git"); + thisProcess.recompile; + //HelpBrowser.openHelpFor("Classes/JSONlib"); +}); + + +//------helper funcs + +hsArrayToCents = { + arg hsArray; + hsArray.collect({arg dist, p; dist * 1200 * log2(primes[p][0]/primes[p][1])}).sum +}; + +pDist = { + arg array1, array2, signed = false; + var pDistance; + pDistance = hsArrayToCents.value(array1) - hsArrayToCents.value(array2); + if(signed, {pDistance}, {abs(pDistance)}) +}; + +hdSum = { + arg hsArrays; + var size, distances, mean; + size = hsArrays.size; + distances = (size - 1).collect({arg i; + ((i + 1)..(size - 1)).collect({arg j; + abs(hsArrays[i] - hsArrays[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum + }); + }).flat; + mean = distances.sum / distances.size; + distances.sum + //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) +}; + +hsChordalDistance = { + arg hsArrays1, hsArrays2; + var size, distances, mean; + size = hsArrays1.size; + distances = hsArrays1.size.collect({arg i; + hsArrays2.size.collect({arg j; + abs(hsArrays1[i] - hsArrays2[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum + }); + }).flat; + mean = distances.sum / distances.size; + distances.sum + //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) +}; + +hsArrayToFreq = { + arg array; + array.collect({arg dim, d; pow(primes[d][0]/primes[d][1], dim)}).product +}; + +//------score funcs + +/* +isInRange = { + arg hsArray, min, max; + var cents; + cents = hsArrayToCents.value(hsArray); + (cents >= min) && (cents <= max) +}; +*/ + +spacingScore = { + arg hsArrays, min; + var centsArray; + centsArray = hsArrays.collect({arg hsArray; hsArrayToCents.value(hsArray)}).sort({arg a, b; a < b}); + centsArray.differentiate.drop(1).collect({arg pDistance; if(pDistance >= min, {1}, {0.01})}).sum; +}; + +rangeScore = { + arg hsArray1, hsArray2, min, max, low, signed = false; + var pDistance; + pDistance = pDist.value(hsArray1, hsArray2, signed); + if((pDistance >= min) && (pDistance <= max), {1}, {low}); +}; + +intervalScore = { + arg hsArray1, hsArray2, mean, sd, signed = false; + var pDistance; + pDistance = pDist.value(hsArray1, hsArray2, signed); + pDistance.gaussCurve(1, mean, sd) +}; + +inclusionScore = { + arg array, test, min = 0.01; + if(array.collect({arg v; v.hash}).includes(test.hash), {min}, {1}); +}; + + +//------subroutines + +genTuples = { + var tuples; + tuples = dims.collect({[-1, 0, 1]}).allTuples.select({arg tuple; (abs(tuple.drop(1)).sum <= 1) && (tuple[0] == 0)}); + tuples = tuples ++ tuples.collect({arg tuple; [-3, -2, -1, 1, 2, 3].collect({arg octTrans; tuple.deepCopy.put(0, octTrans)})}).flatten; +}; + +initVoices = { + var init, voicesInit; + voicesInit = popSize.collect({dims.collect({0})}); + /* + voicesInit = [dims.collect({0})]; + (popSize - 1).do({ + arg rep, new; + rep = dims.rand; + new = voicesInit.last.deepCopy; + new[rep] = new[rep] + [-1, 1].choose(); + voicesInit = voicesInit.add(new); + }); + */ + voicesInit.deepCopy; +}; + +genDurFunc = {arg chordProb, min, max, envData; + var env, pTable, durFunc; + env = Env.pairs([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).asSignal(256).asList.asArray; + pTable = env.asRandomTable; + durFunc = {arg allowChord; + var res; + res = if(allowChord.not, { + pTable.tableRand * (max - min) + min + }, { + if(1.0.rand < chordProb, {0}, {pTable.tableRand * (max - min) + min}); + }).round(0.125); + if(res.asInteger == res, {res = res.asInteger}); + res + }; + seedFunc.value(durFunc, durSeed); +}; + +genOrders = {arg minMotifLength = 1, maxMotifLength = 5, minProgLength = 0, maxProgLength = 5; + ((maxMotifLength - minMotifLength).rand + minMotifLength).collect({ + var noProgIns, noSusIns, noSilentIns, prog, sus, silent, order; + noSusIns = [1, 2, 3].wchoose(susWeights.normalizeSum); + noProgIns = (popSize - noSusIns).rand + 1; + noSilentIns = popSize - noSusIns - noProgIns; + + # prog, sus, silent = (0..(popSize-1)).scramble.clumps([noProgIns, noSusIns, noSilentIns]); + + prog = (prog.scramble ++ ((maxProgLength - minProgLength).rand + minProgLength).collect({prog.choose}).scramble); + if(silent == nil, {silent = []}); + [sus.scramble, prog, silent.scramble] + }); +}; + +updateVoices = {arg ins, sus; + var voices, candidates, nWeights, nProbs, sel; + + voices = lastXChanges.deepCopy.last; + + candidates = sus.collect({arg v; tuples.collect({arg t; voices[v] + t})}).flatten; + candidates = difference(candidates.asSet, voices.asSet).asList; + nProbs = candidates.collect({arg candidate; + var stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore; + + //stepScore = intervalScore.value(voices[ins], candidate, 30, 400, 0.1); + stepScore = intervalScore.value(voices[ins], candidate, 100, 100); + recentlySoundedScore = inclusionScore.value(lastXChanges.flop[ins], candidate, 0); + isInRangeScore = rangeScore.value(candidate, candidate.collect({0}), ranges[ins][0], ranges[ins][1], 0, true); + regScore = spacingScore.value(voices.deepCopy.put(ins, candidate), 300); + hdScore = 1/pow(hdSum.value(voices.deepCopy.put(ins, candidate)), 2); + //maybe what you want here is a vector to another root and then favoring movement towards it. + //distScore = pow(hsChordalDistance.value(voices, voices.put(ins, candidate)), 2); + + [stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore] + }); + + nWeights = passagesWeights; + + //this handles nWeights of 0; mainly for testing + nProbs = nProbs.flop.select({arg scores, s; nWeights[s] != 0}).flop; + nWeights = nWeights.select({arg weight; weight != 0}); + nProbs = nProbs.flop.collect({arg scores, s; + if(scores.sum == 0, {scores}, {scores.normalizeSum * nWeights[s]}) + }); + nProbs = nProbs.flop.collect({arg scores, s; scores.product}).normalizeSum; + + sel = candidates.wchoose(nProbs); + + voices[ins] = sel; + lastXChanges = lastXChanges.add(voices).keep(-5); +}; + +genSubMotif = {arg order, lastState, repeatLast = false, startFromLast = false, isLastOrder = false; + var sus, prog, silent, flatOrder, res, isInChord, allowChord, lastXChangesHold, voices, adder; + # sus, prog, silent = order; + flatOrder = silent ++ sus ++ prog; + lastXChangesHold = lastXChanges.deepCopy; + voices = lastState.deepCopy; + isInChord = popSize.collect({false}); + allowChord = false; + res = []; + "------generating motif".postln; + //need to figure out here if voices move between motifs + flatOrder.do({arg ins, i; + + if(prog.includes(ins) && repeatLast.not, {updateVoices.value(ins, sus)}); + adder = if(silent.includes(ins), {["Rest"]}, {lastXChanges.last.deepCopy[ins]}); + + if(voices[ins] != adder, { + var dur; + allowChord = if((sus ++ silent).includes(ins), { + (sus ++ silent).includes(ins) && (ins != sus.last); + }, { + if(i < (flatOrder.size - 1), {(isInChord[flatOrder[i + 1]] || (ins == flatOrder[i + 1])).not}, {false}); + }); + dur = passagesDurFunc.value(allowChord); + if(dur == 0, {isInChord[ins] = true}, {isInChord = popSize.collect({false})}); + + voices[ins] = adder; + res = res.add([voices.deepCopy.postln, dur]); + }); + }); + + // pad ending + if(isLastOrder, { + (0..(popSize-1)).scramble.do({arg ins; + if(res.last.first[ins] != ["Rest"], { + var dur; + voices[ins] = ["Rest"]; + allowChord = (voices != popSize.collect({["Rest"]})); + dur = passagesDurFunc.value(allowChord); + res = res.add([voices.deepCopy.postln, dur]); + }); + }); + }); + + //format and return + if(startFromLast, {lastXChanges = lastXChangesHold}); + res; +}; + + +//------primary routines + +genMotif = { + var repeats, fSeq; + + repeats = 1; + fSeq = []; + + repeats.do({arg index; + var motif; + + motif = []; + + orders.do({arg order, o; + var lastState, subMotif; + lastState = if(o == 0, {popSize.collect({["Rest"]})}, {motif.last.last.first}); + subMotif = genSubMotif.value(order, lastState, isLastOrder: o == (orders.size - 1)); + motif = motif.add(subMotif); + + }); + + sanityCheck.value(motif, index); + + fSeq = fSeq.add(motif); + }); + fSeq +}; + +genSecondarySeq = {arg seq; + var curdles, fSeq; + curdles = []; + while({curdles.sum < seq.size}, {curdles = curdles ++ [3.rand + 1]}); + + fSeq = seq.clumps(curdles).collect({arg clump, m; + var repeats, paddedSeq; + + //add rest + paddedSeq = clump.add([[[popSize.collect({["Rest"]}), 0.5.rand]]]); + + //implement repeats + repeats = [0.rand + 1, 1].wchoose([1, 0].normalizeSum); + repeats.collect({paddedSeq}); + }); + fSeq +}; + + +//------audition funcs + +Event.addEventType(\osc, { + if (~addr.postln.notNil) { + ~addr.sendMsg(~indexPath, ~indexMsg); + ~addr.sendMsg(~seqPath, stringifyToDepth.value(~seqMsg, 3)); + //~addr.sendMsg("/STATE/OPEN", (dir.replace("supercollider", "resources") +/+ ~idMsg +/+ ~idMsg ++ "_gui_state" ++ ".state").standardizePath.postln); + }; +}); + +genPatterns = {arg inSeq, addr; + var voices, durs, patterns, res, indices, sectionDurs, ids, seq; + seq = inSeq.collect({arg mSeq; mSeq[0]}); + # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; + indices = inSeq.collect({arg mSeq, m; mSeq[1]}); + ids = inSeq.collect({arg mSeq, m; mSeq[2]}); + sectionDurs = seq.collect({arg mSeq; mSeq.flatten2(mSeq.maxDepth - 5).flop[1].sum}); + res = Ppar( + voices.flop.collect({arg voice; + var clumps, hdScores, freqs, fDurs; + clumps = voice.separate({arg a, b; a != b }); + freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); + fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); + + Pbind( + \instrument, \test, + \group, group, + \freq, Pseq(freqs, 1), + \dur, Pseq(fDurs, 1), + \sustain, Pseq(fDurs, 1) + ) + }) ++ + [ + Pbind( + \type, \osc, + \addr, addr, + \indexPath, "/cur_play_index", + \indexMsg, Pseq(indices.postln, 1), + \seqPath, "/mus_seq", + \seqMsg, Pseq(seq, 1), + \dur, Pseq(sectionDurs, 1) + ); + ] + ); + res +}; + +/* +genMidiPatterns = {arg seq; + var voices, durs, patterns, res, mOut, pbRange; + pbRange = 1; //semitones - change this as needed for your situation + mOut = MIDIOut.newByName("TiMidity", "TiMidity port 0").latency_(Server.default.latency); + # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; + res = Ppar( + voices.flop.collect({arg voice, v; + var clumps, hdScores, freqs, fDurs; + + mOut.program(v, 70); + + clumps = voice.separate({arg a, b; a != b }); + freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); + fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); + + Pbind( + \type, \midi, + \chan, v, + \noteval, Pseq(freqs.cpsmidi - 24, 1), + \note, Pfunc({ | event | event[\noteval].floor }), + \dur, Pseq(fDurs, 1), + \midiout, mOut, + \amp, 1, + \bend, Pfunc({ + | event | + if (event[\note].isRest.not) { + var pitchbendvalue = event[\noteval].frac.linlin(0, pbRange, 8192, 8192*2).asInteger; + m.bend(v, pitchbendvalue); + }; + 0; // return something other than nil to avoid stopping the pattern + }), + ); + }); + ); + res +}; +*/ + + +//------resource management funcs + +genUID = {Date.seed.asHexString.toLower}; + +seedFunc = {arg func, seed; + var funcArgs, next; + next = Routine({loop{func.valueArray(funcArgs).yield }}); + next.randSeed_(seed); + {arg ...args; funcArgs = args; next.value} +}; + +stringifyToDepth = {arg data, maxDepth = 1; + var prettyString = "", rCount = 0, writeArray, indent; + + if(maxDepth == 0, { + data.asCompileString + }, { + indent = {arg size; size.collect({" "}).join("")}; + writeArray = {arg array; + prettyString = prettyString ++ indent.value(rCount) ++ "[\n"; + rCount = rCount + 1; + if(rCount < (maxDepth - 0), { + array.do({arg subArray; writeArray.value(subArray)}); + }, { + prettyString = prettyString ++ array.collect({arg subArray; + indent.value(rCount + 1) ++ subArray.asCompileString + }).join(",\n"); + }); + rCount = rCount - 1; + prettyString = prettyString ++ "\n" ++ indent.value(rCount) ++ "],\n"; + }; + + writeArray.value(data); + prettyString.replace(",\n\n", "\n").drop(-2); + }) +}; + +sanityCheck = {arg motif, index; + //print functions = very helpful + ("----------" + index + "------------").postln; + + motif.flatten.do({arg val, v; + if(v > 0, { + if(motif.flatten[v-1][0].hammingDistance(val[0]) > 1, {"problem 1".postln}); + if(motif.flatten[v-1][0].hammingDistance(val[0]) == 0, {"problem 2".postln}); + }); + val.postln + }); + "***********".postln; +}; + +msgInterpret = {arg in, escapeDoubleQuotes = true, escapeSingleQuotes = true; + var res; + + res = in; + if(res.isNil.not, { + if((res.isArray && res.isString.not), { + res = res.asCompileString; + res = res.replace(" ", "").replace("\n", "").replace("\t", ""); + if(escapeSingleQuotes, {res = res.replace("\'", "")}); + if(escapeDoubleQuotes, {res = res.replace("\"", "")}); + res = res.replace("Rest", "\"Rest\""); + res = res.interpret; + }, { + //res.postln; + if(res.every({arg char; char.isDecDigit}), {res = res.asInteger}); + }); + }); + res +}; + +writeResources = {arg path; + var file, nameSpaces, modelItems, resString; + file = File(path,"w"); + + nameSpaces = [ + "music_data", "last_changes", + "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", + "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", + "ranges", "passages_weights", "order", "sus_weights", "order_size", "passages_size" + ]; + + modelItems = [ + seq, lastXChanges, + curUID, refUID, orderSeed, durSeed, motifSeed, + entrancesProbVals, passagesProbVals, exitsProbVals, + ranges, passagesWeights, orders, susWeights, orderSize, passagesSize + ]; + + resString = [nameSpaces, modelItems].flop.collect({arg item; + var nameSpace, modelItem, depth = 0, insert = " "; + # nameSpace, modelItem = item; + if(nameSpace == "music_data", {depth = 3; insert = "\n"}); + if(nameSpace == "last_changes", {depth = 1; insert = "\n"}); + if(nameSpace == "order", {depth = 1; insert = "\n"}); + "\"" ++ nameSpace ++ "\":" ++ insert ++ stringifyToDepth.value(modelItem.postln, depth).postln + }).join(",\n"); + + resString = "{\n" ++ resString ++ "\n}"; + + file.write(resString); + file.close; +}; + +loadModelFile = {arg path; loadModelJSON.value(File(path, "r").readAllString.parseJSON)}; + +loadModelJSON = {arg model; + var nameSpaces, data; + + //model = File(path, "r").readAllString.parseJSON; + + nameSpaces = [ + "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", + "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", + "ranges", "passages_weights", "order", "sus_weights", "order_size", "passages_size" + ]; + + data = nameSpaces.collect({arg nS; msgInterpret.value(model[nS]).postln}); + + data.postln; + + # curUID, refUID, orderSeed, durSeed, motifSeed, + entrancesProbVals, passagesProbVals, exitsProbVals, + ranges, passagesWeights, orders, susWeights, orderSize, passagesSize = data; + + popSize = ranges.size; +}; + +loadLedgerFile = {arg path; + ledgerPath = path; + loadLedgerJSON.value(File(ledgerPath, "r").readAllString.parseJSON) +}; + +loadLedgerJSON = {arg ledger; ledger = ledger["ledger"]}; + +//------global vars + +primes = [[2, 1], [3, 2], [5, 4], [7, 4], [11, 8], [13, 8]]; +//ranges = [[-2400, 0], [-1200, 1200], [0, 2400], [0, 2400]]; +exPath = thisProcess.nowExecutingPath; +dir = exPath.dirname; +//popSize = 4; +dims = primes.size; +tuples = genTuples.value(); +//refUID = nil; +group = Group.new; +loadLedgerFile.value(dir +/+ ".." +/+ "resources" +/+ "piece_ledger.json"); +//passagesWeights = [1, 1, 1, 1, 1]; +//susWeights = [1, 1, 1]; + + +//------OSC funcs + +OSCdef(\load_ledger, {arg msg, time, addr, port; + loadLedgerFile.value(msg[1].asString); +}, \load_ledger); + +OSCdef(\load_model, {arg msg, time, addr, port; + loadModelFile.value(msg[1].asString); +}, \load_model); + + +OSCdef(\generate, {arg msg, time, addr, port; + var path, dFormat, condition, musPath; + msg.postln; + + path = msg[1].asString; + + loadModelFile.value(path); + + refUID.postln; + + loadLedgerFile.value(ledgerPath); + if(ledger.last != "tmp", {ledger = ledger.add("tmp")}); + + lastXChanges = if(refUID == nil, { + [initVoices.value().deepCopy]; + }, { + var file; + refUID.postln; + file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); + msgInterpret.value(file.readAllString.parseJSON["last_changes"]); + }); + + entrancesDurFunc = genDurFunc.valueArray(entrancesProbVals[..2] ++ [entrancesProbVals[3..]]); + passagesDurFunc = genDurFunc.valueArray(passagesProbVals[..2] ++ [passagesProbVals[3..]]); + exitsDurFunc = genDurFunc.valueArray(exitsProbVals[..2] ++ [exitsProbVals[3..]]); + + if(orders == nil, { + orders = seedFunc.value(genOrders, orderSeed).valueArray(orderSize ++ passagesSize); + addr.sendMsg("/order", stringifyToDepth.value(orders, 1)); + }); + seq = seedFunc.value(genMotif, motifSeed).value; + + //musPath = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; + writeResources.value(path); + + //orders = nil; + //addr.sendMsg("/current_uid", curUID); + //addr.sendMsg("/ledger", prettifyArray.value(ledger, 1).replace("\"", "")); + //addr.sendMsg("/ledger_size", ledger.size); + //addr.sendMsg("/mus_seq", prettifyArray.value(seq, 3)); + addr.sendMsg("/generated", musPath, stringifyToDepth.value(seq, 3)); +}, \generate); + + +OSCdef(\commit, {arg msg, time, addr, port; + var newLedger, modelPath, musString, musFile, test1, test2; + msg.postln; + + /* + test1 = msg[1].asString.parseJSON; + test2 = (dir +/+ ".." +/+ "resources/tmp/tmp_music" ++ ".json").standardizePath.parseJSONFile; + msgInterpret.value(test1["music"])[0][0][0][1].class.postln; + msgInterpret.value(test2["music_data"])[0][0][0][1].class.postln; + (test1["music"] == test2["music_data"]).postln; + */ + + curUID = genUID.value; + File.mkdir((dir +/+ ".." +/+ "resources" +/+ curUID).standardizePath); + File.copy(exPath, (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_code" ++ ".scd").standardizePath); + + modelPath = (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_mus_model" ++ ".json").standardizePath; + writeResources.value(modelPath); + + File.delete(ledgerPath.postln ++ "_bak"); + File.copy(ledgerPath, ledgerPath ++ "_bak"); + File.delete(ledgerPath); + newLedger = File(ledgerPath.postln, "w"); + ledger = ledger.postln.drop(-1).add(curUID); + newLedger.write("{\n\"ledger\":\n" ++ stringifyToDepth.value(ledger, 1) ++ "\n}"); + newLedger.close; + + addr.sendMsg("/committed", curUID, ledgerPath); + //refUID = curUID; +}, \commit); + +OSCdef(\transport, {arg msg, time, addr, port; + msg.postln; + if(msg[1] == 0, { + player.stop; + group.set(\gate, 0); + }, { + // the cued sequence can now be read from file, so this can be cleaned up + var cSize, patterns, pSeq, cuedSeek, indexStart, indexEnd, tmpLedger; + pSeq = []; + cuedSeek = (seq != nil); + indexStart = msg[2].asInteger; + indexEnd = ledger.size - if(cuedSeek, {2}, {1}); + if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { + ledger[indexStart..indexEnd].do({arg uid, index; + var file; + (indexStart + index).postln; + file = File((dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_music" ++ ".json").standardizePath, "r"); + pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), indexStart + index, uid]); + file.close; + }); + }); + if(cuedSeek, {pSeq = pSeq.add([seq, ledger.size - 1])}); + patterns = genPatterns.value(pSeq, addr); + player = Pfset(pattern: patterns, cleanupFunc: { + addr.sendMsg("/transport", 0); + }); + player = player.play + }); +}, \transport); + +) + +( +SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; + var trig, exc, sig1, sig2, noHarms; + noHarms = 30; + exc = Saw.ar(freq, TRand.ar(0.5, 1, Impulse.ar(freq))) * 0.001 + Dust.ar(10000, 0.01); + sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), + Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), + Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.5).softclip; + sig1 = HPF.ar(sig1, 300); + Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); +}).add; +) + +( +SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; + var trig, exc, sig1, sig2, noHarms, freqFinal, start, end; + noHarms = 30; + freq = WhiteNoise.ar * 3 + freq; + freqFinal = Duty.ar((1/freq), 0, freq); + trig = Changed.ar(freqFinal); + start = Demand.ar(trig, 0, Dwhite(-1, -0.75)); + end = Demand.ar(trig, 0, Dwhite(0.75, 1)); + exc = Phasor.ar(trig, (end - start) * freqFinal / SampleRate.ir, start, end, 0) * 0.001 + Dust.ar(10000, 0.01); + + sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), + Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), + Array.fill(noHarms, {rrand(2, 3)}) ], exc) * 0.5).softclip; + sig1 = HPF.ar(sig1, 300); + Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); +}).add; +) + + + +"{\"a\": 1}".parseYAML["a"].asInteger; +"{\"a\": 1}".parseJSON["a"].isNumber; + +1223423434123.asHexString.toLower + +Date.getDate.rawSeconds +Date.seed.asHexString.toLower + +n = NetAddr("localhost", 8080); +n.sendMsg("/GET/#", (NetAddr.localAddr.hostname ++ ":" ++ NetAddr.localAddr.port), "/passage_probs_vals"); \ No newline at end of file diff --git a/resources/piece_ledger_sq1_candidates/7e170ef8/7e170ef8_gui_state.json b/resources/piece_ledger_sq1_candidates/7e170ef8/7e170ef8_gui_state.json new file mode 100644 index 0000000..704cf3a --- /dev/null +++ b/resources/piece_ledger_sq1_candidates/7e170ef8/7e170ef8_gui_state.json @@ -0,0 +1,1359 @@ +{ + "motif_label": "motif", + "seeds_label": "seeds", + "order": "[\n [ [ 3, 1, 0 ], [ 2 ], [ ] ],\n [ [ 1, 2 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 3 ] ],\n [ [ 3, 2 ], [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ], [ 0 ] ],\n [ [ 2, 3 ], [ 0, 1, 0 ], [ ] ]\n]", + "order_lock": 1, + "order_size": [ + 3, + 8 + ], + "order_size_v2": 8, + "order_size_v1": 3, + "order_size_panel": -1, + "passage_size_v2": 8, + "passage_size_v1": 2, + "passage_size_panel": -1, + "sus_weights": [ + null, + null, + null + ], + "range_matrix": [ + null, + null, + null, + null + ], + "instrumentation": [ + 0, + 0 + ], + "entrances_probs_sync": "passages", + "entrances": -1, + "passages_probs_sync": "passages", + "passages": -1, + "exits_probs_sync": "passages", + "exits": -1, + "dur_panel": 0, + "durations": -1, + "passages_weights": [ + null, + null, + null, + null, + null + ], + "weights": -1, + "seeds_tab_panel": 0, + "weights_seed_lock": 0, + "weights_seed": 534103, + "sus_weights/0_slider_val": 0.21, + "sus_weights/0_slider_slider": 0.21, + "sus_weights/0_slider_input": 0.21, + "sus_weights/0_slider_label": 1, + "sus_weights/0_slider": -1, + "sus_weights/1_slider_val": 0.35, + "sus_weights/1_slider_slider": 0.35, + "sus_weights/1_slider_input": 0.35, + "sus_weights/1_slider_label": 2, + "sus_weights/1_slider": -1, + "sus_weights/2_slider_val": 0.21, + "sus_weights/2_slider_slider": 0.21, + "sus_weights/2_slider_input": 0.21, + "sus_weights/2_slider_label": 3, + "sus_weights/2_slider": -1, + "passages_weights/0_slider_val": 0.49, + "passages_weights/0_slider_slider": 0.49, + "passages_weights/0_slider_input": 0.49, + "passages_weights/0_slider_label": "step", + "passages_weights/0_slider": -1, + "passages_weights/1_slider_val": 0.53, + "passages_weights/1_slider_slider": 0.53, + "passages_weights/1_slider_input": 0.53, + "passages_weights/1_slider_label": "dc", + "passages_weights/1_slider": -1, + "passages_weights/2_slider_val": 0.35, + "passages_weights/2_slider_slider": 0.35, + "passages_weights/2_slider_input": 0.35, + "passages_weights/2_slider_label": "range", + "passages_weights/2_slider": -1, + "passages_weights/3_slider_val": 0.59, + "passages_weights/3_slider_slider": 0.59, + "passages_weights/3_slider_input": 0.59, + "passages_weights/3_slider_label": "registration", + "passages_weights/3_slider": -1, + "passages_weights/4_slider_val": 0.39, + "passages_weights/4_slider_slider": 0.39, + "passages_weights/4_slider_input": 0.39, + "passages_weights/4_slider_label": "hd", + "passages_weights/4_slider": -1, + "range_matrix/0_val_input_min": -853.2067988668555, + "range_matrix/0_val_rslider": [ + -853.2067988668555, + 401 + ], + "range_matrix/0_val_input_max": 401, + "range_matrix/0_val": -1, + "range_matrix/1_val_input_min": -659, + "range_matrix/1_val_rslider": [ + -659, + 880 + ], + "range_matrix/1_val_input_max": 880, + "range_matrix/1_val": -1, + "range_matrix/2_val_input_min": -241, + "range_matrix/2_val_rslider": [ + -241, + 1869 + ], + "range_matrix/2_val_input_max": 1869, + "range_matrix/2_val": -1, + "range_matrix/3_val_input_min": -27, + "range_matrix/3_val_rslider": [ + -27, + 2063 + ], + "range_matrix/3_val_input_max": 2063, + "range_matrix/3_val": -1, + "entrances_probs_chord_slider_val": 0.66, + "entrances_probs_chord_slider_slider": 0.66, + "entrances_probs_chord_slider_input": 0.66, + "entrances_probs_chord_slider_label": "chord prob", + "entrances_probs_chord_slider": -1, + "entrances_probs_vals": [ + 0.63, + 0, + 5, + 0, + 0.5, + 0.23316062176165803, + 0.7094594594594594, + 0.3963730569948187, + 0.8716216216216216, + 0.4948186528497409, + 0.5912162162162162, + 0.5362694300518135, + 0.8614864864864865, + 0.6424870466321243, + 0.5912162162162162, + 0.7901554404145078, + 0.8277027027027027, + 1, + 0.5 + ], + "entrances_probs": -1, + "passages_probs_chord_slider_val": 0.63, + "passages_probs_chord_slider_slider": 0.63, + "passages_probs_chord_slider_input": 0.63, + "passages_probs_chord_slider_label": "chord prob", + "passages_probs_chord_slider": -1, + "passages_probs_vals": [ + 0.63, + 0, + 5, + 0, + 0.5, + 0.23316062176165803, + 0.7094594594594594, + 0.3963730569948187, + 0.8716216216216216, + 0.4948186528497409, + 0.5912162162162162, + 0.5362694300518135, + 0.8614864864864865, + 0.6424870466321243, + 0.5912162162162162, + 0.7901554404145078, + 0.8277027027027027, + 1, + 0.5 + ], + "passages_probs": -1, + "exits_probs_chord_slider_val": 0, + "exits_probs_chord_slider_slider": 0, + "exits_probs_chord_slider_input": 0, + "exits_probs_chord_slider_label": "chord prob", + "exits_probs_chord_slider": -1, + "exits_probs_vals": [ + 0, + 0, + 5, + 0, + 0.5, + 0.23316062176165803, + 0.7094594594594594, + 0.4948186528497409, + 0.5912162162162162, + 0.7901554404145078, + 0.8277027027027027, + 1, + 0.5 + ], + "exits_probs": -1, + "step_env_env_vals": [ + 0, + 5, + 0, + 0, + 0, + 0, + 0.14609053497942387, + 0.7613636363636364, + 0.20164609053497942, + 0.26136363636363635, + 0.24279835390946503, + 0.7215909090909092, + 0.39094650205761317, + 0.875, + 0.4567901234567901, + 0.44318181818181823, + 0.5432098765432098, + 0.34659090909090906, + 0.6481481481481481, + 0.8011363636363636, + 0.6810699588477366, + 0.5170454545454546, + 0.8868312757201646, + 0.49431818181818177, + 0.8868312757201646, + 0.49431818181818177 + ], + "step_env_env_canvas": [ + [ + 0, + 0 + ], + [ + 0, + 0 + ], + [ + 0.14609053497942387, + 0.7613636363636364 + ], + [ + 0.20164609053497942, + 0.26136363636363635 + ], + [ + 0.24279835390946503, + 0.7215909090909092 + ], + [ + 0.39094650205761317, + 0.875 + ], + [ + 0.4567901234567901, + 0.44318181818181823 + ], + [ + 0.5432098765432098, + 0.34659090909090906 + ], + [ + 0.6481481481481481, + 0.8011363636363636 + ], + [ + 0.6810699588477366, + 0.5170454545454546 + ], + [ + 0.8868312757201646, + 0.49431818181818177 + ], + [ + 0.8868312757201646, + 0.49431818181818177 + ], + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "step_env_env_size": 12, + "step_env_env_flatten": 0, + "step_env_env_rslider": [ + 0, + 5 + ], + "step_env_env_rslider_v2": 5, + "step_env_env_rslider_v1": 0, + "step_env_env_mpos": "", + "step_env_env": -1, + "entrances_probs_dur_env_vals": [ + 0.515267175572519, + 4.599236641221374, + 0, + 0.5, + 0.2772020725388601, + 0.7972972972972973, + 0.45077720207253885, + 0.8783783783783784, + 0.5, + 0.5, + 0.727979274611399, + 0.45270270270270274, + 0.7357512953367875, + 0.6486486486486487, + 0.8911917098445595, + 0.7905405405405406, + 1, + 0.5 + ], + "entrances_probs_dur_env_canvas": [ + [ + 0, + 0.5 + ], + [ + 0.2772020725388601, + 0.7972972972972973 + ], + [ + 0.45077720207253885, + 0.8783783783783784 + ], + [ + 0.5, + 0.5 + ], + [ + 0.727979274611399, + 0.45270270270270274 + ], + [ + 0.7357512953367875, + 0.6486486486486487 + ], + [ + 0.8911917098445595, + 0.7905405405405406 + ], + [ + 1, + 0.5 + ], + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "entrances_probs_dur_env_size": 8, + "entrances_probs_dur_env_flatten": 0, + "entrances_probs_dur_env_rslider": [ + 0.515267175572519, + 4.599236641221374 + ], + "entrances_probs_dur_env_rslider_v2": 4.599236641221374, + "entrances_probs_dur_env_rslider_v1": 0.515267175572519, + "entrances_probs_dur_env_mpos": "", + "entrances_probs_dur_env": -1, + "passages_probs_dur_env_vals": [ + 0, + 5, + 0, + 0.5, + 0.23316062176165803, + 0.7094594594594594, + 0.3963730569948187, + 0.8716216216216216, + 0.4948186528497409, + 0.5912162162162162, + 0.5362694300518135, + 0.8614864864864865, + 0.6424870466321243, + 0.5912162162162162, + 0.7901554404145078, + 0.8277027027027027, + 1, + 0.5 + ], + "passages_probs_dur_env_canvas": [ + [ + 0, + 0.5 + ], + [ + 0.23316062176165803, + 0.7094594594594594 + ], + [ + 0.3963730569948187, + 0.8716216216216216 + ], + [ + 0.4948186528497409, + 0.5912162162162162 + ], + [ + 0.5362694300518135, + 0.8614864864864865 + ], + [ + 0.6424870466321243, + 0.5912162162162162 + ], + [ + 0.7901554404145078, + 0.8277027027027027 + ], + [ + 1, + 0.5 + ], + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "passages_probs_dur_env_size": 8, + "passages_probs_dur_env_flatten": 0, + "passages_probs_dur_env_rslider": [ + 0, + 5 + ], + "passages_probs_dur_env_rslider_v2": 5, + "passages_probs_dur_env_rslider_v1": 0, + "passages_probs_dur_env_mpos": "", + "passages_probs_dur_env": -1, + "exits_probs_dur_env_vals": [ + 0, + 5, + 0, + 0.5, + 0.5, + 0.5, + 1, + 0.5 + ], + "exits_probs_dur_env_canvas": [ + [ + 0, + 0.5 + ], + [ + 0.5, + 0.5 + ], + [ + 1, + 0.5 + ], + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "exits_probs_dur_env_size": 3, + "exits_probs_dur_env_flatten": 0, + "exits_probs_dur_env_rslider": [ + 0, + 5 + ], + "exits_probs_dur_env_rslider_v2": 5, + "exits_probs_dur_env_rslider_v1": 0, + "exits_probs_dur_env_mpos": "", + "exits_probs_dur_env": -1, + "mus_seq": [ + [ + [ + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + "Rest" + ], + [ + "Rest" + ] + ], + 0 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + "Rest" + ] + ], + 1.75 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.75 + ], + [ + [ + [ + 0, + 1, + -3, + 0, + 2, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0.75 + ], + [ + [ + [ + 1, + 1, + -2, + -2, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0.625 + ], + [ + [ + [ + 1, + 1, + -3, + -1, + 0, + 0 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0.625 + ], + [ + [ + [ + 1, + 0, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.75 + ] + ], + [ + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.75 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 1, + -2, + 0, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.375 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 2, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0.75 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 1, + -2, + -1, + 2, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.75 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 0, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.875 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1 + ] + ], + [ + [ + [ + [ + 1, + 0, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0 + ], + [ + [ + [ + 1, + 0, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 2, + 0, + -3, + -1, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.625 + ], + [ + [ + [ + 1, + 0, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 1, + -1, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.75 + ], + [ + [ + [ + 1, + 0, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 1, + -1, + -1, + 1, + 0 + ], + [ + "Rest" + ] + ], + 0 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 1, + -1, + -1, + 1, + 0 + ], + [ + "Rest" + ] + ], + 1.875 + ], + [ + [ + [ + "Rest" + ], + [ + "Rest" + ], + [ + 0, + 1, + -1, + -1, + 1, + 0 + ], + [ + "Rest" + ] + ], + 0 + ], + [ + [ + [ + "Rest" + ], + [ + "Rest" + ], + [ + "Rest" + ], + [ + "Rest" + ] + ], + 0.875 + ] + ] + ] + ], + "root": [ + 0.20743639921722112, + 0 + ], + "order_seed": 798574, + "dur_seed": 884869, + "passages_size": [ + 0, + 10 + ], + "dur_seed_lock": 1, + "order_seed_lock": 0, + "seeds_panel": -1, + "motif_panel": [ + 0, + 0 + ], + "ref_uid": "6f1a789f", + "cur_uid": "7e170ef8" +} \ No newline at end of file diff --git a/resources/piece_ledger_sq1_candidates/7e170ef8/7e170ef8_mus_model.json b/resources/piece_ledger_sq1_candidates/7e170ef8/7e170ef8_mus_model.json new file mode 100644 index 0000000..c9b8807 --- /dev/null +++ b/resources/piece_ledger_sq1_candidates/7e170ef8/7e170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 0, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ "Rest" ] ], 0 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ] ], 0 ], + [ [ [ "Rest" ], [ 1, -1, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ] ], 0 ], + [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 1 ] + ] + ] +], +"last_changes": +[ + [ [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 1, 0, -1, 0, 0, 0 ] ], + [ [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 0, 0, 0, 1, 0, 0 ] ], + [ [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 1, 0, 0, 0, 0, 0 ] ], + [ [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 1, -1, 0, 0, 0, 1 ] ], + [ [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ] ] +], +"cur_uid": "7e170ef8", +"ref_uid": "nil", +"order_seed": 142640, +"dur_seed": 629022, +"motifs_seed": 973728, +"entrances_probs_vals": [ 0.75, 0.5, 2, 0, 0.5, 0.26424870466321, 0.75675675675676, 0.5, 0.5, 0.58549222797927, 0.72635135135135, 1, 0.5 ], +"passages_probs_vals": [ 0.75, 0.5, 2, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], +"exits_probs_vals": [ 0.75, 0.5, 2, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], +"ranges": [ [ -384, 2400 ], [ -507, 2400 ], [ -282, 2237 ], [ -1200, 2053 ] ], +"passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], +"order": +[ + [ [ 2 ], [ 3, 1, 3, 3, 3, 1, 1, 3, 3, 1 ], [ 0 ] ], + [ [ 0 ], [ 1, 2, 3, 3, 1, 3, 1, 3 ], [ ] ], + [ [ 0, 3 ], [ 1, 1, 1, 1, 1, 1 ], [ 2 ] ], + [ [ 1, 2, 0 ], [ 3, 3, 3, 3 ], [ ] ] +], +"sus_weights": [ 0.75, 0.69, 0.75 ], +"order_size": [ 2, 6 ], +"passages_size": [ 0, 10 ] +} \ No newline at end of file diff --git a/resources/46985d14/46985d14_code.scd b/resources/piece_ledger_sq1_candidates_stitch/46985d14/46985d14_code.scd similarity index 100% rename from resources/46985d14/46985d14_code.scd rename to resources/piece_ledger_sq1_candidates_stitch/46985d14/46985d14_code.scd diff --git a/resources/46985d14/46985d14_mus_model.json b/resources/piece_ledger_sq1_candidates_stitch/46985d14/46985d14_mus_model.json similarity index 100% rename from resources/46985d14/46985d14_mus_model.json rename to resources/piece_ledger_sq1_candidates_stitch/46985d14/46985d14_mus_model.json diff --git a/resources/46985d14/lilypond/part_I.ly b/resources/piece_ledger_sq1_candidates_stitch/46985d14/lilypond/part_I.ly similarity index 100% rename from resources/46985d14/lilypond/part_I.ly rename to resources/piece_ledger_sq1_candidates_stitch/46985d14/lilypond/part_I.ly diff --git a/resources/46985d14/lilypond/part_II.ly b/resources/piece_ledger_sq1_candidates_stitch/46985d14/lilypond/part_II.ly similarity index 100% rename from resources/46985d14/lilypond/part_II.ly rename to resources/piece_ledger_sq1_candidates_stitch/46985d14/lilypond/part_II.ly diff --git a/resources/46985d14/lilypond/part_III.ly b/resources/piece_ledger_sq1_candidates_stitch/46985d14/lilypond/part_III.ly similarity index 100% rename from resources/46985d14/lilypond/part_III.ly rename to resources/piece_ledger_sq1_candidates_stitch/46985d14/lilypond/part_III.ly diff --git a/resources/46985d14/lilypond/part_IV.ly b/resources/piece_ledger_sq1_candidates_stitch/46985d14/lilypond/part_IV.ly similarity index 100% rename from resources/46985d14/lilypond/part_IV.ly rename to resources/piece_ledger_sq1_candidates_stitch/46985d14/lilypond/part_IV.ly diff --git a/resources/490b1e6e/490b1e6e_code.scd b/resources/piece_ledger_sq1_candidates_stitch/490b1e6e/490b1e6e_code.scd similarity index 100% rename from resources/490b1e6e/490b1e6e_code.scd rename to resources/piece_ledger_sq1_candidates_stitch/490b1e6e/490b1e6e_code.scd diff --git a/resources/490b1e6e/490b1e6e_mus_model.json b/resources/piece_ledger_sq1_candidates_stitch/490b1e6e/490b1e6e_mus_model.json similarity index 100% rename from resources/490b1e6e/490b1e6e_mus_model.json rename to resources/piece_ledger_sq1_candidates_stitch/490b1e6e/490b1e6e_mus_model.json diff --git a/resources/490b1e6e/lilypond/part_I.ly b/resources/piece_ledger_sq1_candidates_stitch/490b1e6e/lilypond/part_I.ly similarity index 100% rename from resources/490b1e6e/lilypond/part_I.ly rename to resources/piece_ledger_sq1_candidates_stitch/490b1e6e/lilypond/part_I.ly diff --git a/resources/490b1e6e/lilypond/part_II.ly b/resources/piece_ledger_sq1_candidates_stitch/490b1e6e/lilypond/part_II.ly similarity index 100% rename from resources/490b1e6e/lilypond/part_II.ly rename to resources/piece_ledger_sq1_candidates_stitch/490b1e6e/lilypond/part_II.ly diff --git a/resources/490b1e6e/lilypond/part_III.ly b/resources/piece_ledger_sq1_candidates_stitch/490b1e6e/lilypond/part_III.ly similarity index 100% rename from resources/490b1e6e/lilypond/part_III.ly rename to resources/piece_ledger_sq1_candidates_stitch/490b1e6e/lilypond/part_III.ly diff --git a/resources/490b1e6e/lilypond/part_IV.ly b/resources/piece_ledger_sq1_candidates_stitch/490b1e6e/lilypond/part_IV.ly similarity index 100% rename from resources/490b1e6e/lilypond/part_IV.ly rename to resources/piece_ledger_sq1_candidates_stitch/490b1e6e/lilypond/part_IV.ly diff --git a/resources/445b7057/445b7057_code.scd b/resources/piece_ledger_sq1_candidates_stitch/4a8a6e53/4a8a6e53_code.scd similarity index 100% rename from resources/445b7057/445b7057_code.scd rename to resources/piece_ledger_sq1_candidates_stitch/4a8a6e53/4a8a6e53_code.scd diff --git a/resources/64b535ef/64b535ef_mus_model.json b/resources/piece_ledger_sq1_candidates_stitch/4a8a6e53/4a8a6e53_mus_model.json similarity index 53% rename from resources/64b535ef/64b535ef_mus_model.json rename to resources/piece_ledger_sq1_candidates_stitch/4a8a6e53/4a8a6e53_mus_model.json index f9a31aa..715f342 100644 --- a/resources/64b535ef/64b535ef_mus_model.json +++ b/resources/piece_ledger_sq1_candidates_stitch/4a8a6e53/4a8a6e53_mus_model.json @@ -4,60 +4,60 @@ [ [ [ [ [ "Rest" ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ] ], 0.875 ], - [ [ [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ] ], 0.625 ], - [ [ [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, -1 ] ], 1.5 ], - [ [ [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 1, 0, 0, 0 ] ], 0.875 ], - [ [ [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ] ], 0.875 ], - [ [ [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 1, 0, 0, 0, 0 ] ], 1 ], - [ [ [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 1, 0, 0 ] ], 1 ], - [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-1, 1 ], [ 1, -1, 0, 1, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ] ], 1.125 ], - [ [ [ "Rest" ], [ 1, -1, -1, 0, -1, 0 ], [ 1, -1, 0, 1, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ] ], 1 ], - [ [ [ "Rest" ], [ 1, -1, -1, 0, -1, 0 ], [ 1, 0, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ] ], 0.75 ], - [ [ [ "Rest" ], [ 1, -1, -1, 0, -1, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ 1, -1, 0, 0, -1, 0 ] ], 0.625 ], - [ [ [ "Rest" ], [ 0, -1, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ 1, -1, 0, 0, -1, 0 ] ], 0.75 ], - [ [ [ "Rest" ], [ 1, -1, 0, 0, -2, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ 1, -1, 0, 0, -1, 0 ] ], 1.375 ], - [ [ [ "Rest" ], [ 1, -1, 0, 0, -2, 0 ], [ 2, -2, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ] ], 0.875 ], - [ [ [ "Rest" ], [ 0, -1, 0, 0, -1, 1 ], [ 2, -2, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ] ], 3.375 ], - [ [ [ "Rest" ], [ 0, -1, 0, 0, -1, 1 ], [ 2, -2, 0, 0, -1, 0 ], [ "Rest" ] ], 1.5 ], - [ [ [ "Rest" ], [ 0, -1, 0, 0, -1, 1 ], [ "Rest" ], [ "Rest" ] ], 1.375 ], + [ [ [ 1, 0, 0, -1, -1, 0 ], [ "Rest" ], [ 2, 0, 0, 0, -1, -1 ], [ 1, -1, 0, 0, -1, 0 ] ], 0.75 ], + [ [ [ 0, -1, 0, 1, -1, 0 ], [ "Rest" ], [ 2, 0, 0, 0, -1, -1 ], [ 1, -1, 0, 0, -1, 0 ] ], 1 ], + [ [ [ 0, -1, 0, 1, -1, 0 ], [ "Rest" ], [ 2, -1, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ] ], 0.875 ], + [ [ [ 0, -1, 0, 0, -1, 1 ], [ "Rest" ], [ 2, -1, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ] ], 1.25 ], + [ [ [ 0, -1, 0, 0, -1, 1 ], [ "Rest" ], [ 1, -1, 0, 1, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ] ], 1.125 ], + [ [ [ 1, -1, -1, 0, -1, 0 ], [ "Rest" ], [ 1, -1, 0, 1, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ] ], 1 ], + [ [ [ 1, -1, -1, 0, -1, 0 ], [ "Rest" ], [ 1, 0, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ] ], 0.75 ], + [ [ [ 1, -1, -1, 0, -1, 0 ], [ "Rest" ], [ 1, -1, 0, 0, 0, 0 ], [ 1, -1, 0, 0, -1, 0 ] ], 0.625 ], + [ [ [ 0, -1, 0, 0, 0, 0 ], [ "Rest" ], [ 1, -1, 0, 0, 0, 0 ], [ 1, -1, 0, 0, -1, 0 ] ], 0.75 ], + [ [ [ 1, -1, 0, 0, -2, 0 ], [ "Rest" ], [ 1, -1, 0, 0, 0, 0 ], [ 1, -1, 0, 0, -1, 0 ] ], 1.375 ], + [ [ [ 1, -1, 0, 0, -2, 0 ], [ "Rest" ], [ 2, -2, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ] ], 0.875 ], + [ [ [ 0, -1, 0, 0, -1, 1 ], [ "Rest" ], [ 2, -2, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ] ], 3.375 ], + [ [ [ 0, -1, 0, 0, -1, 1 ], [ "Rest" ], [ 2, -2, 0, 0, -1, 0 ], [ "Rest" ] ], 1.5 ], + [ [ [ 0, -1, 0, 0, -1, 1 ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 1.375 ], [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 1 ] ] ] @@ -70,7 +70,7 @@ [ [ 0, 0, 0, 1, 0, -1 ], [ 0, 0, 0, 0, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ], [ 0, 0, 0, 0, -1, 0 ] ], [ [ 1, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ], [ 0, 0, 0, 0, -1, 0 ] ] ], -"cur_uid": "64b535ef", +"cur_uid": "4a8a6e53", "ref_uid": "nil", "order_seed": 320463, "dur_seed": 903977, diff --git a/resources/4a8a6e53/lilypond/part_I.ly b/resources/piece_ledger_sq1_candidates_stitch/4a8a6e53/lilypond/part_I.ly similarity index 100% rename from resources/4a8a6e53/lilypond/part_I.ly rename to resources/piece_ledger_sq1_candidates_stitch/4a8a6e53/lilypond/part_I.ly diff --git a/resources/4a8a6e53/lilypond/part_II.ly b/resources/piece_ledger_sq1_candidates_stitch/4a8a6e53/lilypond/part_II.ly similarity index 100% rename from resources/4a8a6e53/lilypond/part_II.ly rename to resources/piece_ledger_sq1_candidates_stitch/4a8a6e53/lilypond/part_II.ly diff --git a/resources/4a8a6e53/lilypond/part_III.ly b/resources/piece_ledger_sq1_candidates_stitch/4a8a6e53/lilypond/part_III.ly similarity index 100% rename from resources/4a8a6e53/lilypond/part_III.ly rename to resources/piece_ledger_sq1_candidates_stitch/4a8a6e53/lilypond/part_III.ly diff --git a/resources/4a8a6e53/lilypond/part_IV.ly b/resources/piece_ledger_sq1_candidates_stitch/4a8a6e53/lilypond/part_IV.ly similarity index 100% rename from resources/4a8a6e53/lilypond/part_IV.ly rename to resources/piece_ledger_sq1_candidates_stitch/4a8a6e53/lilypond/part_IV.ly diff --git a/resources/5e54c468/5e54c468_code.scd b/resources/piece_ledger_sq1_candidates_stitch/5e54c468/5e54c468_code.scd similarity index 100% rename from resources/5e54c468/5e54c468_code.scd rename to resources/piece_ledger_sq1_candidates_stitch/5e54c468/5e54c468_code.scd diff --git a/resources/5e54c468/5e54c468_mus_model.json b/resources/piece_ledger_sq1_candidates_stitch/5e54c468/5e54c468_mus_model.json similarity index 100% rename from resources/5e54c468/5e54c468_mus_model.json rename to resources/piece_ledger_sq1_candidates_stitch/5e54c468/5e54c468_mus_model.json diff --git a/resources/piece_ledger_sq1_candidates_stitch/5e54c468/lilypond/part_I.ly b/resources/piece_ledger_sq1_candidates_stitch/5e54c468/lilypond/part_I.ly new file mode 100644 index 0000000..98ddfc8 --- /dev/null +++ b/resources/piece_ledger_sq1_candidates_stitch/5e54c468/lilypond/part_I.ly @@ -0,0 +1,44 @@ +{ + { r1 } + \bar "|" + { r2 r16[ a'8.^\markup { \pad-markup #0.2 "-6"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 5↓" }}] ~ a'4 ~ } + \bar "|" + { a'16[ gis'8.^\markup { \pad-markup #0.2 "+26"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 5↑" }}] ~ gis'2. ~ } + \bar "|" + { gis'1 ~ } + \bar "|" + { gis'1 ~ } + \bar "|" + { gis'1 ~ } + \bar "|" + { gis'1 ~ } + \bar "|" + { gis'1 ~ } + \bar "|" + { gis'4 r2. } + \bar "|" + { r1 } + \bar "|" + { r1 } + \bar "|" + { r4 r8.[ gis'16^\markup { \pad-markup #0.2 "+26"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "III"\normal-size-super " 5↑" }}] ~ gis'2 ~ } + \bar "|" + { gis'1 ~ } + \bar "|" + { gis'1 ~ } + \bar "|" + { gis'1 ~ } + \bar "|" + { gis'1 ~ } + \bar "|" + { gis'2. r4 } + \bar "|" + { r1 } + \bar "|" + { r1 } + \bar "|" + { r1 } + \bar "|" + { r1 } +\bar "||" +} \ No newline at end of file diff --git a/resources/piece_ledger_sq1_candidates_stitch/5e54c468/lilypond/part_II.ly b/resources/piece_ledger_sq1_candidates_stitch/5e54c468/lilypond/part_II.ly new file mode 100644 index 0000000..6b51d38 --- /dev/null +++ b/resources/piece_ledger_sq1_candidates_stitch/5e54c468/lilypond/part_II.ly @@ -0,0 +1,44 @@ +{ + { e1^\markup { \pad-markup #0.2 "+40"} ~ } + \bar "|" + { e1 ~ } + \bar "|" + { e1 ~ } + \bar "|" + { e1 } + \bar "|" + { r1 } + \bar "|" + { r1 } + \bar "|" + { r1 } + \bar "|" + { r1 } + \bar "|" + { r2 r8[ d''8^\markup { \pad-markup #0.2 "+9"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "III"\normal-size-super " 7↑" }}] ~ d''4 ~ } + \bar "|" + { d''8.[ cis''16^\markup { \pad-markup #0.2 "-19"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "III"\normal-size-super " 13↑" }}] ~ cis''2. ~ } + \bar "|" + { cis''1 ~ } + \bar "|" + { cis''1 ~ } + \bar "|" + { cis''1 ~ } + \bar "|" + { cis''1 ~ } + \bar "|" + { cis''1 ~ } + \bar "|" + { cis''1 ~ } + \bar "|" + { cis''1 ~ } + \bar "|" + { cis''2. r4 } + \bar "|" + { r1 } + \bar "|" + { r1 } + \bar "|" + { r1 } +\bar "||" +} \ No newline at end of file diff --git a/resources/piece_ledger_sq1_candidates_stitch/5e54c468/lilypond/part_III.ly b/resources/piece_ledger_sq1_candidates_stitch/5e54c468/lilypond/part_III.ly new file mode 100644 index 0000000..2632120 --- /dev/null +++ b/resources/piece_ledger_sq1_candidates_stitch/5e54c468/lilypond/part_III.ly @@ -0,0 +1,44 @@ +{ + { fis'1^\markup { \pad-markup #0.2 "-21"} ~ } + \bar "|" + { fis'1 ~ } + \bar "|" + { fis'1 ~ } + \bar "|" + { fis'1 ~ } + \bar "|" + { fis'1 } + \bar "|" + { e'1^\markup { \pad-markup #0.2 "+40"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "IV"\normal-size-super " 13↓" }} ~ } + \bar "|" + { e'1 ~ } + \bar "|" + { e'1 ~ } + \bar "|" + { e'1 ~ } + \bar "|" + { e'1 ~ } + \bar "|" + { e'1 ~ } + \bar "|" + { e'2. ~ e'8[ dis'8^\markup { \pad-markup #0.2 "+12"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 7↓" }}] ~ } + \bar "|" + { dis'2 dis'2^\markup { \pad-markup #0.2 "+28"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "I"\normal-size-super " 3↑" }} ~ } + \bar "|" + { dis'1 ~ } + \bar "|" + { dis'4 ~ dis'8[ f'8^\markup { \pad-markup #0.2 "-33"}_\markup { \lower #3 \pad-markup #0.2 \concat{ "II"\normal-size-super " 5↑" }}] ~ f'4 ~ f'8[ fis'8^\markup { \pad-markup #0.2 "-21"}] ~ } + \bar "|" + { fis'1 ~ } + \bar "|" + { fis'1 ~ } + \bar "|" + { fis'2. r4 } + \bar "|" + { r1 } + \bar "|" + { r1 } + \bar "|" + { r1 } +\bar "||" +} \ No newline at end of file diff --git a/resources/piece_ledger_sq1_candidates_stitch/5e54c468/lilypond/part_IV.ly b/resources/piece_ledger_sq1_candidates_stitch/5e54c468/lilypond/part_IV.ly new file mode 100644 index 0000000..1f3a4d8 --- /dev/null +++ b/resources/piece_ledger_sq1_candidates_stitch/5e54c468/lilypond/part_IV.ly @@ -0,0 +1,44 @@ +{ + { r4 r16[ cis'8.^\markup { \pad-markup #0.2 "-19"}] ~ cis'2 ~ } + \bar "|" + { cis'1 ~ } + \bar "|" + { cis'1 ~ } + \bar "|" + { cis'1 ~ } + \bar "|" + { cis'1 ~ } + \bar "|" + { cis'1 ~ } + \bar "|" + { cis'1 ~ } + \bar "|" + { cis'1 ~ } + \bar "|" + { cis'4 r2. } + \bar "|" + { r1 } + \bar "|" + { r1 } + \bar "|" + { r1 } + \bar "|" + { r1 } + \bar "|" + { r1 } + \bar "|" + { r1 } + \bar "|" + { r1 } + \bar "|" + { r1 } + \bar "|" + { r1 } + \bar "|" + { r1 } + \bar "|" + { r1 } + \bar "|" + { r1 } +\bar "||" +} \ No newline at end of file diff --git a/resources/535cc132/535cc132_code.scd b/resources/piece_ledger_sq1_candidates_stitch/66f6a618/66f6a618_code.scd similarity index 100% rename from resources/535cc132/535cc132_code.scd rename to resources/piece_ledger_sq1_candidates_stitch/66f6a618/66f6a618_code.scd diff --git a/resources/piece_ledger_sq1_candidates_stitch/66f6a618/66f6a618_mus_model.json b/resources/piece_ledger_sq1_candidates_stitch/66f6a618/66f6a618_mus_model.json new file mode 100644 index 0000000..9b60dbd --- /dev/null +++ b/resources/piece_ledger_sq1_candidates_stitch/66f6a618/66f6a618_mus_model.json @@ -0,0 +1,91 @@ +{ +"music_data": +[ + [ + [ + [ [ [ "Rest" ], [ "Rest" ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ] ], 0 ], + [ [ [ "Rest" ], [ 1, -1, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ] ], 0 ], + [ [ [ "Rest" ], [ 1, -1, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ] ], 8.375 ], + [ [ [ 0, -1, 0, 0, -1, 1 ], [ 1, -1, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ] ], 1.5 ], + [ [ [ 0, 0, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ] ], 0.875 ], + [ [ [ 1, -2, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ] ], 0.75 ], + [ [ [ 0, -1, 1, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ] ], 0.75 ], + [ [ [ 1, -1, 0, -1, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ] ], 10.75 ] + ], + [ + [ [ [ 1, -1, 0, -1, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 2, -1, 0, -1, -1, 0 ] ], 0.625 ], + [ [ [ 1, -1, 0, -1, -1, 0 ], [ 0, -1, 0, 1, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 2, -1, 0, -1, -1, 0 ] ], 0.625 ], + [ [ [ 0, -1, 0, 0, -1, 0 ], [ 0, -1, 0, 1, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 2, -1, 0, -1, -1, 0 ] ], 0.75 ], + [ [ [ 1, -1, 0, 0, -1, -1 ], [ 0, -1, 0, 1, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 2, -1, 0, -1, -1, 0 ] ], 0.875 ], + [ [ [ 1, -1, 0, 0, -1, -1 ], [ 0, -1, 0, 1, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 2, -1, 0, 0, -1, -1 ] ], 1.25 ], + [ [ [ 1, -1, 0, 0, -1, -1 ], [ 1, -1, -1, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 2, -1, 0, 0, -1, -1 ] ], 1.75 ], + [ [ [ 1, -1, 0, 0, -1, -1 ], [ 1, -1, -1, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 1, -1, 0, 0, 0, 0 ] ], 0 ], + [ [ [ 1, -1, 0, 0, -1, -1 ], [ 0, -1, 0, 0, -1, 1 ], [ 1, -1, 0, 0, -1, 0 ], [ 1, -1, 0, 0, 0, 0 ] ], 0 ], + [ [ [ 0, -1, 1, 0, -1, 0 ], [ 0, -1, 0, 0, -1, 1 ], [ 1, -1, 0, 0, -1, 0 ], [ 1, -1, 0, 0, 0, 0 ] ], 1.875 ], + [ [ [ 0, -1, 1, 0, -1, 0 ], [ 0, 0, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 1, -1, 0, 0, 0, 0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], + [ [ [ "Rest" ], [ -2, 0, 0, 1, 1, 0 ], [ "Rest" ], [ 0, 0, 0, 0, 1, 0 ] ], 7.625 ], + [ [ [ "Rest" ], [ -2, 0, 0, 1, 1, 0 ], [ "Rest" ], [ "Rest" ] ], 1 ], + [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 8.375 ] + ] + ] +], +"last_changes": +[ + [ [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], + [ [ 1, -1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], + [ [ 0, 0, -1, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], + [ [ -1, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], + [ [ 0, -1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ] +], +"cur_uid": "66f6a618", +"ref_uid": "nil", +"order_seed": 209164, +"dur_seed": 417909, +"motifs_seed": 885208, +"entrances_probs_vals": [ 0.34, 0, 10, 0.5, 2, 0, 0.5, 0.24509803921569, 0.89189189189189, 0.5, 1, 0.5, 0.5, 0.8562091503268, 0.69932432432432, 1, 0.5 ], +"passages_probs_vals": [ 0.34, 0, 10, 0.5, 2, 0, 0.5, 0.24509803921569, 0.89189189189189, 0.5, 1, 0.5, 0.5, 0.8562091503268, 0.69932432432432, 1, 0.5 ], +"exits_probs_vals": [ 0.34, 0, 10, 0.5, 2, 0, 0.5, 0.24509803921569, 0.89189189189189, 0.5, 1, 0.5, 0.5, 0.8562091503268, 0.69932432432432, 1, 0.5 ], +"ranges": [ [ -1200, 2400 ], [ -1200, 2400 ], [ -1200, 2400 ], [ -1200, 2400 ] ], +"step_probs_vals": [ 0, 1200, 0, 0.5, 0.5, 0.5, 1, 0.5 ], +"passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], +"hd_exp": 2, +"hd_invert": 0, +"order": +[ + [ [ 2 ], [ 0, 0, 0, 0 ], [ 1, 3 ] ] +], +"sus_weights": [ 0.75, 0.75, 0.75 ], +"order_size": [ 1, 10 ], +"passages_size": [ 0, 10 ], +"motif_edited": "true", +"order_edited": "false" +} \ No newline at end of file diff --git a/resources/66f6a618/lilypond/part_I.ly b/resources/piece_ledger_sq1_candidates_stitch/66f6a618/lilypond/part_I.ly similarity index 100% rename from resources/66f6a618/lilypond/part_I.ly rename to resources/piece_ledger_sq1_candidates_stitch/66f6a618/lilypond/part_I.ly diff --git a/resources/66f6a618/lilypond/part_II.ly b/resources/piece_ledger_sq1_candidates_stitch/66f6a618/lilypond/part_II.ly similarity index 100% rename from resources/66f6a618/lilypond/part_II.ly rename to resources/piece_ledger_sq1_candidates_stitch/66f6a618/lilypond/part_II.ly diff --git a/resources/66f6a618/lilypond/part_III.ly b/resources/piece_ledger_sq1_candidates_stitch/66f6a618/lilypond/part_III.ly similarity index 100% rename from resources/66f6a618/lilypond/part_III.ly rename to resources/piece_ledger_sq1_candidates_stitch/66f6a618/lilypond/part_III.ly diff --git a/resources/66f6a618/lilypond/part_IV.ly b/resources/piece_ledger_sq1_candidates_stitch/66f6a618/lilypond/part_IV.ly similarity index 100% rename from resources/66f6a618/lilypond/part_IV.ly rename to resources/piece_ledger_sq1_candidates_stitch/66f6a618/lilypond/part_IV.ly diff --git a/resources/6fb60ab6/6fb60ab6_code.scd b/resources/piece_ledger_sq1_candidates_stitch/6fb60ab6/6fb60ab6_code.scd similarity index 100% rename from resources/6fb60ab6/6fb60ab6_code.scd rename to resources/piece_ledger_sq1_candidates_stitch/6fb60ab6/6fb60ab6_code.scd diff --git a/resources/6fb60ab6/6fb60ab6_mus_model.json b/resources/piece_ledger_sq1_candidates_stitch/6fb60ab6/6fb60ab6_mus_model.json similarity index 100% rename from resources/6fb60ab6/6fb60ab6_mus_model.json rename to resources/piece_ledger_sq1_candidates_stitch/6fb60ab6/6fb60ab6_mus_model.json diff --git a/resources/6fb60ab6/lilypond/part_I.ly b/resources/piece_ledger_sq1_candidates_stitch/6fb60ab6/lilypond/part_I.ly similarity index 100% rename from resources/6fb60ab6/lilypond/part_I.ly rename to resources/piece_ledger_sq1_candidates_stitch/6fb60ab6/lilypond/part_I.ly diff --git a/resources/6fb60ab6/lilypond/part_II.ly b/resources/piece_ledger_sq1_candidates_stitch/6fb60ab6/lilypond/part_II.ly similarity index 100% rename from resources/6fb60ab6/lilypond/part_II.ly rename to resources/piece_ledger_sq1_candidates_stitch/6fb60ab6/lilypond/part_II.ly diff --git a/resources/6fb60ab6/lilypond/part_III.ly b/resources/piece_ledger_sq1_candidates_stitch/6fb60ab6/lilypond/part_III.ly similarity index 100% rename from resources/6fb60ab6/lilypond/part_III.ly rename to resources/piece_ledger_sq1_candidates_stitch/6fb60ab6/lilypond/part_III.ly diff --git a/resources/6fb60ab6/lilypond/part_IV.ly b/resources/piece_ledger_sq1_candidates_stitch/6fb60ab6/lilypond/part_IV.ly similarity index 100% rename from resources/6fb60ab6/lilypond/part_IV.ly rename to resources/piece_ledger_sq1_candidates_stitch/6fb60ab6/lilypond/part_IV.ly diff --git a/resources/761e4585/761e4585_code.scd b/resources/piece_ledger_sq1_candidates_stitch/761e4585/761e4585_code.scd similarity index 100% rename from resources/761e4585/761e4585_code.scd rename to resources/piece_ledger_sq1_candidates_stitch/761e4585/761e4585_code.scd diff --git a/resources/761e4585/761e4585_mus_model.json b/resources/piece_ledger_sq1_candidates_stitch/761e4585/761e4585_mus_model.json similarity index 100% rename from resources/761e4585/761e4585_mus_model.json rename to resources/piece_ledger_sq1_candidates_stitch/761e4585/761e4585_mus_model.json diff --git a/resources/761e4585/lilypond/part_I.ly b/resources/piece_ledger_sq1_candidates_stitch/761e4585/lilypond/part_I.ly similarity index 100% rename from resources/761e4585/lilypond/part_I.ly rename to resources/piece_ledger_sq1_candidates_stitch/761e4585/lilypond/part_I.ly diff --git a/resources/761e4585/lilypond/part_II.ly b/resources/piece_ledger_sq1_candidates_stitch/761e4585/lilypond/part_II.ly similarity index 100% rename from resources/761e4585/lilypond/part_II.ly rename to resources/piece_ledger_sq1_candidates_stitch/761e4585/lilypond/part_II.ly diff --git a/resources/761e4585/lilypond/part_III.ly b/resources/piece_ledger_sq1_candidates_stitch/761e4585/lilypond/part_III.ly similarity index 100% rename from resources/761e4585/lilypond/part_III.ly rename to resources/piece_ledger_sq1_candidates_stitch/761e4585/lilypond/part_III.ly diff --git a/resources/761e4585/lilypond/part_IV.ly b/resources/piece_ledger_sq1_candidates_stitch/761e4585/lilypond/part_IV.ly similarity index 100% rename from resources/761e4585/lilypond/part_IV.ly rename to resources/piece_ledger_sq1_candidates_stitch/761e4585/lilypond/part_IV.ly diff --git a/resources/piece_ledger_sq1_candidates_stitch/tmp/tmp_mus_model.json b/resources/piece_ledger_sq1_candidates_stitch/tmp/tmp_mus_model.json new file mode 100644 index 0000000..a11fbdb --- /dev/null +++ b/resources/piece_ledger_sq1_candidates_stitch/tmp/tmp_mus_model.json @@ -0,0 +1,103 @@ +{ +"music_data": +[ + [ + [ + [ [ [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ] ], 3.125 ], + [ [ [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 0, 0, -1, 0, 0, 0 ] ], 1.875 ], + [ [ [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 1, 0, 0, 0 ], [ 0, 0, -1, 0, 0, 0 ] ], 1.875 ], + [ [ [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 1, 0, 0, 0 ], [ 0, 0,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0, -1, -1, 2, 1 ] ], 3.25 ] + ], + [ + [ [ [ 1, 0, -1, -1, 1, 0 ], [ 2, 0, -1, -1, 2, -1 ], [ "Rest" ], [ 0, 0, -1, -1, 2, 1 ] ], 0 ], + [ [ [ -1, 0, -1, -1, 2, 1 ], [ 2, 0, -1, -1, 2, -1 ], [ "Rest" ], [ 0, 0, -1, -1, 2, 1 ] ], 0.625 ], + [ [ [ 0, 1, -1, -1, 2, -1 ], [ 2, 0, -1, -1, 2, -1 ], [ "Rest" ], [ 0, 0, -1, -1, 2, 1 ] ], 1.125 ], + [ [ [ 0, -1, -1, -1, 2, 1 ], [ 2, 0, -1, -1, 2, -1 ], [ "Rest" ], [ 0, 0, -1, -1, 2, 1 ] ], 1.625 ], + [ [ [ -1, 0, -1, -1, 3, 1 ], [ 2, 0, -1, -1, 2, -1 ], [ "Rest" ], [ 0, 0, -1, -1, 2, 1 ] ], 0.75 ], + [ [ [ 1, 0, -1, -1, 2, 0 ], [ 2, 0, -1, -1, 2, -1 ], [ "Rest" ], [ 0, 0, -1, -1, 2, 1 ] ], 0.875 ], + [ [ [ 1, 0, -1, -1, 2, -1 ], [ 2, 0, -1, -1, 2, -1 ], [ "Rest" ], [ 0, 0, -1, -1, 2, 1 ] ], 0.75 ], + [ [ [ 1, 0, -2, -1, 2, -1 ], [ 2, 0, -1, -1, 2, -1 ], [ "Rest" ], [ 0, 0, -1, -1, 2, 1 ] ], 5.25 ], + [ [ [ "Rest" ], [ 2, 0, -1, -1, 2, -1 ], [ "Rest" ], [ 0, 0, -1, -1, 2, 1 ] ], 0.875 ], + [ [ [ "Rest" ], [ 2, 0, -1, -1, 2, -1 ], [ "Rest" ], [ "Rest" ] ], 0 ], + [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 7.0 ] + ] + ] +], +"last_changes": +[ + [ [ 0, -1, -1, -1, 2, 1 ], [ 2, 0, -1, -1, 2, -1 ], [ 2, 0, -1, -1, 2, 0 ], [ 0, 0, -1, -1, 2, 1 ] ], + [ [ -1, 0, -1, -1, 3, 1 ], [ 2, 0, -1, -1, 2, -1 ], [ 2, 0, -1, -1, 2, 0 ], [ 0, 0, -1, -1, 2, 1 ] ], + [ [ 1, 0, -1, -1, 2, 0 ], [ 2, 0, -1, -1, 2, -1 ], [ 2, 0, -1, -1, 2, 0 ], [ 0, 0, -1, -1, 2, 1 ] ], + [ [ 1, 0, -1, -1, 2, -1 ], [ 2, 0, -1, -1, 2, -1 ], [ 2, 0, -1, -1, 2, 0 ], [ 0, 0, -1, -1, 2, 1 ] ], + [ [ 1, 0, -2, -1, 2, -1 ], [ 2, 0, -1, -1, 2, -1 ], [ 2, 0, -1, -1, 2, 0 ], [ 0, 0, -1, -1, 2, 1 ] ] +], +"cur_uid": "tmp", +"ref_uid": "nil", +"order_seed": 776924, +"dur_seed": 832007, +"motifs_seed": 729341, +"entrances_probs_vals": [ 0.34, 0.99, 3.1746031746032, 0.5, 2, 0, 0.5, 0.24509803921569, 0.89189189189189, 0.5, 1, 0.5, 0.5, 0.8562091503268, 0.69932432432432, 1, 0.5 ], +"passages_probs_vals": [ 0.34, 1.5873015873016, 4.7222222222222, 0.5, 2, 0, 0.5, 0.24509803921569, 0.89189189189189, 0.5, 1, 0.5, 0.5, 0.8562091503268, 0.69932432432432, 1, 0.5 ], +"exits_probs_vals": [ 0.34, 0.32, 1.9444444444444, 0.5, 2, 0, 0.5, 0.24509803921569, 0.89189189189189, 0.5, 1, 0.5, 0.5, 0.8562091503268, 0.69932432432432, 1, 0.5 ], +"ranges": [ [ -1200, 2400 ], [ -1200, 2400 ], [ -1200, 2400 ], [ -1200, 2400 ] ], +"step_probs_vals": [ 0, 1200, 0, 0.5, 0.5, 0.5, 1, 0.5 ], +"passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], +"hd_exp": 2, +"hd_invert": 0, +"order": +[ + [ [ 1 ], [ 3, 2, 3, 2, 3, 3, 2, 3, 2, 3, 3 ], [ 0 ] ], + [ [ 3 ], [ 0, 1, 2, 0, 1, 2, 2 ], [ ] ], + [ [ 2, 3, 1 ], [ 0, 0, 0 ], [ ] ], + [ [ 1, 3, 0 ], [ 2 ], [ ] ], + [ [ 1, 0 ], [ 3, 2, 2, 3, 3, 2, 3, 2, 2 ], [ ] ], + [ [ 0, 2 ], [ 3, 1, 3 ], [ ] ], + [ [ 1, 3 ], [ 0, 0, 0, 0, 0, 0, 0 ], [ 2 ] ] +], +"sus_weights": [ 0.75, 0.75, 0.75 ], +"order_size": [ 1, 10 ], +"passages_size": [ 0, 10 ], +"motif_edited": "false", +"order_edited": "false" +} \ No newline at end of file diff --git a/resources/piece_ledger_transcribe_test.json_bak_bak b/resources/piece_ledger_transcribe_test.json_bak_bak deleted file mode 100644 index beb5d37..0000000 --- a/resources/piece_ledger_transcribe_test.json_bak_bak +++ /dev/null @@ -1,11 +0,0 @@ -{ -"ledger": -[ - "314s49e1", - "4c01589b", - "7e170ef8", - "7ac10d34", - "640eeed3", - "497509c8" -] -} \ No newline at end of file diff --git a/resources/piece_ledger_transcribe_test/314s49e1/314s49e1_code.scd b/resources/piece_ledger_transcribe_test/314s49e1/314s49e1_code.scd new file mode 100644 index 0000000..2d77a32 --- /dev/null +++ b/resources/piece_ledger_transcribe_test/314s49e1/314s49e1_code.scd @@ -0,0 +1,581 @@ +( +// helper funcs +var hsArrayToCents, pDist, hdSum, hsChordalDistance, hsArrayToFreq; + +// score funcs +var isInRange, spacingScore, rangeScore, intervalScore, inclusionScore; + +// subroutines +var genTuples, initVoices, genOrder, genSubMotif, updateVoices; + +// primary routines +var genMotif, genSecondarySeq; + +// audition funcs +var genPatterns, genMidiPatterns; + +// resource management funcs +var writeResources, prettifyArray, setSeeds, sanityCheck, msgInterpret; + +// global vars (many set by OSC funcs at bottom) +var refSeed, seed, lastXChanges, popSize, exPath, dir, primes, dims, tuples, ranges, durFunc, seq, group, player; + + +//------helper funcs + +hsArrayToCents = { + arg hsArray; + hsArray.collect({arg dist, p; dist * 1200 * log2(primes[p][0]/primes[p][1])}).sum +}; + +pDist = { + arg array1, array2, signed = false; + var pDistance; + pDistance = hsArrayToCents.value(array1) - hsArrayToCents.value(array2); + if(signed, {pDistance}, {abs(pDistance)}) +}; + +hdSum = { + arg hsArrays; + var size, distances, mean; + size = hsArrays.size; + distances = (size - 1).collect({arg i; + ((i + 1)..(size - 1)).collect({arg j; + abs(hsArrays[i] - hsArrays[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum + }); + }).flat; + mean = distances.sum / distances.size; + distances.sum + //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) +}; + +hsChordalDistance = { + arg hsArrays1, hsArrays2; + var size, distances, mean; + size = hsArrays1.size; + distances = hsArrays1.size.collect({arg i; + hsArrays2.size.collect({arg j; + abs(hsArrays1[i] - hsArrays2[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum + }); + }).flat; + mean = distances.sum / distances.size; + distances.sum + //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) +}; + +hsArrayToFreq = { + arg array; + array.collect({arg dim, d; pow(primes[d][0]/primes[d][1], dim)}).product +}; + + +//------score funcs + +/* +isInRange = { + arg hsArray, min, max; + var cents; + cents = hsArrayToCents.value(hsArray); + (cents >= min) && (cents <= max) +}; +*/ + +spacingScore = { + arg hsArrays, min; + var centsArray; + centsArray = hsArrays.collect({arg hsArray; hsArrayToCents.value(hsArray)}).sort({arg a, b; a < b}); + centsArray.differentiate.drop(1).collect({arg pDistance; if(pDistance >= min, {1}, {0.01})}).sum; +}; + +rangeScore = { + arg hsArray1, hsArray2, min, max, low, signed = false; + var pDistance; + pDistance = pDist.value(hsArray1, hsArray2, signed); + if((pDistance >= min) && (pDistance <= max), {1}, {low}); +}; + +intervalScore = { + arg hsArray1, hsArray2, mean, sd, signed = false; + var pDistance; + pDistance = pDist.value(hsArray1, hsArray2, signed); + pDistance.gaussCurve(1, mean, sd) +}; + +inclusionScore = { + arg array, test, min = 0.01; + if(array.collect({arg v; v.hash}).includes(test.hash), {min}, {1}); +}; + + +//------subroutines + +genTuples = { + var tuples; + tuples = dims.collect({[-1, 0, 1]}).allTuples.select({arg tuple; (abs(tuple.drop(1)).sum <= 1) && (tuple[0] == 0)}); + tuples = tuples ++ tuples.collect({arg tuple; [-3, -2, -1, 1, 2, 3].collect({arg octTrans; tuple.deepCopy.put(0, octTrans)})}).flatten; +}; + +initVoices = { + var init, voicesInit; + voicesInit = popSize.collect({dims.collect({0})}); + /* + voicesInit = [dims.collect({0})]; + (popSize - 1).do({ + arg rep, new; + rep = dims.rand; + new = voicesInit.last.deepCopy; + new[rep] = new[rep] + [-1, 1].choose(); + voicesInit = voicesInit.add(new); + }); + */ + voicesInit.deepCopy; +}; + +genOrder = {arg minLength = 0, maxLength = 5; + var noProgIns, noSusIns, noSilentIns, prog, sus, silent, order; + noProgIns = (popSize - 1).rand + 1; + noSusIns = (popSize - noProgIns).rand + 1; + noSilentIns = popSize - noSusIns - noProgIns; + + # prog, sus, silent = (0..(popSize-1)).scramble.clumps([noProgIns, noSusIns, noSilentIns]); + + prog = (prog.scramble ++ ((maxLength - minLength).rand + minLength).collect({prog.choose}).scramble); + if(silent == nil, {silent = []}); + [sus.scramble, prog, silent.scramble] +}; + +updateVoices = {arg ins, sus; + var voices, candidates, nWeights, nProbs, sel; + + voices = lastXChanges.deepCopy.last; + + candidates = sus.collect({arg v; tuples.collect({arg t; voices[v] + t})}).flatten; + candidates = difference(candidates.asSet, voices.asSet).asList; + nProbs = candidates.collect({arg candidate; + var stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore; + + //stepScore = intervalScore.value(voices[ins], candidate, 30, 400, 0.1); + stepScore = intervalScore.value(voices[ins], candidate, 100, 100); + recentlySoundedScore = inclusionScore.value(lastXChanges.flop[ins], candidate, 0); + isInRangeScore = rangeScore.value(candidate, candidate.collect({0}), ranges[ins][0], ranges[ins][1], 0, true); + regScore = spacingScore.value(voices.deepCopy.put(ins, candidate), 300); + hdScore = 1/pow(hdSum.value(voices.deepCopy.put(ins, candidate)), 2); + //maybe what you want here is a vector to another root and then favoring movement towards it. + //distScore = pow(hsChordalDistance.value(voices, voices.put(ins, candidate)), 2); + + [stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore] + }); + + nWeights = [1, 1, 1, 1, 1]; + + //this handles nWeights of 0; mainly for testing + nProbs = nProbs.flop.select({arg scores, s; nWeights[s] != 0}).flop; + nWeights = nWeights.select({arg weight; weight != 0}); + nProbs = nProbs.flop.collect({arg scores, s; + if(scores.sum == 0, {scores}, {scores.normalizeSum * nWeights[s]}) + }); + nProbs = nProbs.flop.collect({arg scores, s; scores.product}).normalizeSum; + + sel = candidates.wchoose(nProbs); + + voices[ins] = sel; + lastXChanges = lastXChanges.add(voices).keep(-5); +}; + +genSubMotif = {arg order, lastState, repeatLast = false, startFromLast = false, isLastOrder = false; + var sus, prog, silent, res, lastIns, lastXChangesHold, voices, adder; + # sus, prog, silent = order; + lastXChangesHold = lastXChanges.deepCopy; + voices = lastState.deepCopy; + lastIns = nil; + res = []; + "------generating motif".postln; + //need to figure out here if voices move between motifs + (silent ++ sus ++ prog).do({arg ins, i; + + if(prog.includes(ins) && repeatLast.not, {updateVoices.value(ins, sus)}); + adder = if(silent.includes(ins), {["Rest"]}, {lastXChanges.last.deepCopy[ins]}); + + if(voices[ins] != adder, { + var dur; + //dur = [durFunc.value(), 0].wchoose([1, 0].normalizeSum); + dur = durFunc.value(lastIns, ins); + voices[ins] = adder; + res = res.add([voices.deepCopy.postln, dur.round(0.125)]); + }); + + lastIns = ins; + }); + + // pad ending + if(isLastOrder, { + (0..(popSize-1)).scramble.do({arg ins; + if(res.last.first[ins] != ["Rest"], { + var dur; + voices[ins] = ["Rest"]; + //dur = [durFunc.value(), 0].wchoose([1, 0].normalizeSum); + dur = durFunc.value(lastIns, ins); + res = res.add([voices.deepCopy.postln, dur.round(0.125)]); + }); + lastIns = ins; + }); + }); + + //format and return + if(startFromLast, {lastXChanges = lastXChangesHold}); + res; +}; + + +//------primary routines + +genMotif = {arg inOrders; + var orders, repeats, fSeq; + + repeats = 1; + fSeq = []; + + repeats.do({arg index; + var motif; + + motif = []; + orders = inOrders; + + orders.do({arg order, o; + var lastState, subMotif; + lastState = if(o == 0, {popSize.collect({["Rest"]})}, {motif.last.last.first}); + subMotif = genSubMotif.value(order, lastState, isLastOrder: o == (orders.size - 1)); + motif = motif.add(subMotif); + + }); + + sanityCheck.value(motif, index); + + fSeq = fSeq.add(motif); + }); + fSeq +}; + +genSecondarySeq = {arg seq; + var curdles, fSeq; + curdles = []; + while({curdles.sum < seq.size}, {curdles = curdles ++ [3.rand + 1]}); + + fSeq = seq.clumps(curdles).collect({arg clump, m; + var repeats, paddedSeq; + + //add rest + paddedSeq = clump.add([[[popSize.collect({["Rest"]}), 0.5.rand]]]); + + //implement repeats + repeats = [0.rand + 1, 1].wchoose([1, 0].normalizeSum); + repeats.collect({paddedSeq}); + }); + fSeq +}; + + +//------audition funcs + +genPatterns = {arg seq; + var voices, durs, patterns, res; + # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; + res = Ppar( + voices.flop.collect({arg voice; + var clumps, hdScores, freqs, fDurs; + clumps = voice.separate({arg a, b; a != b }); + freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); + fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); + + Pbind( + \instrument, \test, + \group, group, + \freq, Pseq(freqs, 1), + \dur, Pseq(fDurs, 1), + \sustain, Pseq(fDurs, 1) + ); + }); + ); + res +}; + +genMidiPatterns = {arg seq; + var voices, durs, patterns, res, mOut, pbRange; + pbRange = 1; //semitones - change this as needed for your situation + mOut = MIDIOut.newByName("TiMidity", "TiMidity port 0").latency_(Server.default.latency); + # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; + res = Ppar( + voices.flop.collect({arg voice, v; + var clumps, hdScores, freqs, fDurs; + + mOut.program(v, 70); + + clumps = voice.separate({arg a, b; a != b }); + freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); + fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); + + Pbind( + \type, \midi, + \chan, v, + \noteval, Pseq(freqs.cpsmidi - 24, 1), + \note, Pfunc({ | event | event[\noteval].floor }), + \dur, Pseq(fDurs, 1), + \midiout, mOut, + \amp, 1, + \bend, Pfunc({ + | event | + if (event[\note].isRest.not) { + var pitchbendvalue = event[\noteval].frac.linlin(0, pbRange, 8192, 8192*2).asInteger; + m.bend(v, pitchbendvalue); + }; + 0; // return something other than nil to avoid stopping the pattern + }), + ); + }); + ); + res +}; + + +//------resource management funcs + +setSeeds = {arg inRefSeed, inSeed; + refSeed = if(inRefSeed.isNumber, {inRefSeed.asInteger}, {nil}); + seed = if(inSeed > 1, {inSeed.asInteger}, {rrand(100000, 999999)}); + thisThread.randSeed = seed; +}; + +prettifyArray = {arg data, finDepth = 1; + var prettyString = "", rCount = 0, writeArray; + + writeArray = {arg array; + var depth, indent; + depth = array.maxDepth; + indent = rCount.collect({" "}).join(""); + prettyString = prettyString ++ indent ++ "[\n"; + rCount = rCount + 1; + if(depth > 5, { + array.do({arg subArray; + writeArray.value(subArray); + }); + }, { + array.do({arg data, d; + prettyString = prettyString ++ indent ++ " " ++ data.asCompileString ++ if(d != (array.size - 1), {",\n"}, {""}); + }); + }); + rCount = rCount - 1; + if(rCount < (finDepth - 1), {prettyString = prettyString.drop((finDepth - 1).neg)}); + //if(rCount == 0, {prettyString = prettyString.drop((finDepth - 1).neg)}); + prettyString = prettyString ++ "\n" ++ indent ++ "]" ++ if(rCount > 0, {",\n"}, {""}); + }; + + writeArray.value(data); + prettyString +}; + +writeResources = {arg seq, path; + var dir, file, resString; + file = File(path,"w"); + + resString = "{\nmusic_data:\n"; + resString = resString ++ prettifyArray.value(seq, 3); + + resString = resString ++ ",\nlast_changes:\n"; + resString = resString ++ prettifyArray.value(lastXChanges, 1); + + resString = resString ++ ",\nseed: " ++ seed ++ ",\nref_seed: " ++ refSeed ++ "\n}"; + + file.write(resString); + file.close; +}; + +sanityCheck = {arg motif, index; + //print functions - very helpful + ("----------" + index + "------------").postln; + + motif.flatten.do({arg val, v; + if(v > 0, { + if(motif.flatten[v-1][0].hammingDistance(val[0]) > 1, {"problem 1".postln}); + if(motif.flatten[v-1][0].hammingDistance(val[0]) == 0, {"problem 2".postln}); + }); + val.postln + }); + "***********".postln; +}; + +msgInterpret = {arg in; + var res; + res = in.asCompileString; + res = res.replace(" ", "").replace("\n", "").replace("\t", ""); + res = res.replace("\'", "").replace("\"", "").replace("Rest", "\"Rest\""); + res.interpret +}; + + +//------global vars + +primes = [[2, 1], [3, 2], [5, 4], [7, 4], [11, 8], [13, 8]]; +ranges = [[-2400, 0], [-1200, 1200], [0, 2400], [0, 2400]]; +exPath = thisProcess.nowExecutingPath; +dir = exPath.dirname; +popSize = 4; +dims = primes.size; +tuples = genTuples.value(); +refSeed = nil; +group = Group.new; + + +//------OSC funcs + +OSCdef(\gen, {arg msg, time, addr, port; + var orders, condition; + msg.postln; + durFunc = nil; + + addr.sendMsg("/STATE/SEND"); + + { + while({durFunc == nil}, {0.1.wait}); + setSeeds.value(msg[1].postln, msg[2]); + + lastXChanges = if(refSeed == nil, { + [initVoices.value().deepCopy]; + }, { + var file; + file = File((dir +/+ "resources" +/+ refSeed ++ "_music" ++ ".json").standardizePath, "r"); + msgInterpret.value(file.readAllString.parseJSON["last_changes"]); + }); + + if(msg.size == 4, { + orders = msgInterpret.value(msg[3]); + }, { + var minLength, maxLength; + minLength = msg[3]; + maxLength = msg[4]; + orders = ((maxLength - minLength).rand + minLength).collect({genOrder.value(msg[5], msg[6])}); + }); + + orders.postln; + seed.postln; + refSeed.postln; + + seq = genMotif.value(orders); + //patterns = genPatterns.value(seq); + addr.sendMsg("/current_seed", seed); + addr.sendMsg("/order", prettifyArray.value(orders, 1)); + addr.sendMsg("/mus_seq", prettifyArray.value(seq, 3)); + }.fork; + +}, \gen); + +OSCdef(\commit, {arg msg, time, addr, port; + var ledgerPath, oldLedger, newLedger, musSeq; + //msg.postln; + seed.postln; + //File.copy(exPath, (dir +/+ "resources" +/+ seed ++ "_code" ++ ".scd").standardizePath); + //addr.sendMsg("/SESSION/SAVE", (dir +/+ "resources" +/+ seed ++ "_gui_session" ++ ".json").standardizePath); + //addr.sendMsg("/STATE/SAVE", (dir +/+ "resources" +/+ seed ++ "_gui_state" ++ ".state").standardizePath); + + writeResources.value(seq, (dir +/+ "resources" +/+ seed ++ "_music" ++ ".json").standardizePath); + + ledgerPath = (dir +/+ "resources" +/+ "piece_ledger" ++ ".json").standardizePath; + oldLedger = File(ledgerPath, "r"); + musSeq = msgInterpret.value(oldLedger.readAllString.parseJSON["ledger"]); + oldLedger.close; + File.delete(ledgerPath ++ "_bak"); + File.copy(ledgerPath, ledgerPath ++ "_bak"); + File.delete(ledgerPath); + newLedger = File(ledgerPath, "w"); + musSeq = musSeq.add(seed); + newLedger.write("{\nledger:\n" ++ prettifyArray.value(musSeq, 1) ++ "\n}"); + newLedger.close; + + //refSeed = seed; +}, \commit); + +OSCdef(\transport, {arg msg, time, addr, port; + msg.postln; + if(msg[1] == 0, { + player.stop; + group.set(\gate, 0); + }, { + var cSize, ledgerPath, ledger, patterns, pSeq; + ledgerPath = (dir +/+ "resources" +/+ "piece_ledger" ++ ".json").standardizePath; + ledger = msgInterpret.value(File(ledgerPath, "r").readAllString.parseJSON["ledger"]); + pSeq = []; + if(msg[2].asString != "all", {ledger = ledger.keep(msg[2].asInteger - 1)}); + ledger.do({arg rSeed; + var file; + file = File((dir +/+ "resources" +/+ rSeed.postln ++ "_music" ++ ".json").standardizePath, "r"); + pSeq = pSeq.add(msgInterpret.value(file.readAllString.parseJSON["music_data"])); + file.close; + }); + pSeq = pSeq.add(seq); + patterns = genPatterns.value(pSeq); + player = Pfset(pattern: patterns, cleanupFunc: { + addr.sendMsg("/transport", 0); + }); + player = player.play + }); +}, \transport); + +OSCdef(\range, {arg msg; + msg.postln; + ranges[msg[1]][msg[2]] = msg[3] +}, \range); + +OSCdef(\dur_probs_env, {arg msg; + var env, pTable, min, max, cProb; + msg.postln; + env = Env.pairs([[0, 0]] ++ msg[4..].clump(2) ++ [[1, 0]]).asSignal(256).asList.asArray; + pTable = env.asRandomTable; + min = msg[1]; + max = msg[2]; + cProb = msg[3]; + durFunc = {arg lIns, cIns; + if(lIns.postln == cIns.postln, { + pTable.tableRand * (max - min) + min + }, { + if(1.0.rand < cProb.postln, {0}, {pTable.tableRand * (max - min) + min}).postln; + }); + }; +}, \dur_probs_env); +) + +( +SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; + var trig, exc, sig1, sig2, noHarms; + noHarms = 30; + exc = Saw.ar(freq, TRand.ar(0.5, 1, Impulse.ar(freq))) * 0.001 + Dust.ar(10000, 0.01); + sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), + Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), + Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.5).softclip; + sig1 = HPF.ar(sig1, 300); + Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); +}).add; +) + +( +SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; + var trig, exc, sig1, sig2, noHarms, freqFinal, start, end; + noHarms = 30; + freq = WhiteNoise.ar * 3 + freq; + freqFinal = Duty.ar((1/freq), 0, freq); + trig = Changed.ar(freqFinal); + start = Demand.ar(trig, 0, Dwhite(-1, -0.75)); + end = Demand.ar(trig, 0, Dwhite(0.75, 1)); + exc = Phasor.ar(trig, (end - start) * freqFinal / SampleRate.ir, start, end, 0) * 0.001 + Dust.ar(10000, 0.01); + + sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), + Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), + Array.fill(noHarms, {rrand(2, 3)}) ], exc) * 0.5).softclip; + sig1 = HPF.ar(sig1, 300); + Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); +}).add; +) + + +File((~dir +/+ "resources" +/+ 517313 ++ "_music" ++ ".json").standardizePath, "r").readAllString.parseJSON["last_changes"].asString.interpret[0][0][0].isNumber + +"{\"a\": 1}".parseYAML["a"].asInteger; +"{\"a\": 1}".parseJSON["a"].isNumber; \ No newline at end of file diff --git a/resources/piece_ledger_transcribe_test/314s49e1/314s49e1_mus_model.json b/resources/piece_ledger_transcribe_test/314s49e1/314s49e1_mus_model.json new file mode 100644 index 0000000..c78a753 --- /dev/null +++ b/resources/piece_ledger_transcribe_test/314s49e1/314s49e1_mus_model.json @@ -0,0 +1,74 @@ +{ +"music_data": +[ + [ + [ + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 0.875 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ] ], 0.625 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0, -1 ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ] ], 1.5 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 1, 0, 0, 0 ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ] ], 0.875 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ] ], 0.875 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ 0, 1, 0, 0, 0, 0 ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ] ], 1.0 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 1, 0, 0 ], [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, 0, -1, 0 ], [ "Rest" ], [ 0, -1, 0, 0, -1, 1 ] ], 1.125 ], + [ [ [ 1, -1, 0, 1, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 1, -1, -1, 0, -1, 0 ] ], 1.0 ], + [ [ [ 1, 0, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 1, -1, -1, 0, -1, 0 ] ], 0.75 ], + [ [ [ 1, -1, 0, 0, 0, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 1, -1, -1, 0, -1, 0 ] ], 0.625 ], + [ [ [ 1, -1, 0, 0, 0, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 0, -1, 0, 0, 0, 0 ] ], 0.75 ], + [ [ [ 1, -1, 0, 0, 0, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 1, -1, 0, 0, -2, 0 ] ], 1.375 ], + [ [ [ 2, -2, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 1, -1, 0, 0, -2, 0 ] ], 0.875 ], + [ [ [ 2, -2, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ "Rest" ], [ 0, -1, 0, 0, -1, 1 ] ], 3.375 ], + [ [ [ 2, -2, 0, 0, -1, 0 ], [ "Rest" ], [ "Rest" ], [ 0, -1, 0, 0, -1, 1 ] ], 1.5 ], + [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ 0, -1, 0, 0, -1, 1 ] ], 1.375 ], + [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 1.0 ] + ] + ] +], +"last_changes": +[ + [ [ 1, -1, 0, 0, 0, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 0, 0, 0, 0, -1, 0 ], [ 1, -1, -1, 0, -1, 0 ] ], + [ [ 1, -1, 0, 0, 0, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 0, 0, 0, 0, -1, 0 ], [ 0, -1, 0, 0, 0, 0 ] ], + [ [ 1, -1, 0, 0, 0, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 0, 0, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -2, 0 ] ], + [ [ 2, -2, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 0, 0, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -2, 0 ] ], + [ [ 2, -2, 0, 0, -1, 0 ], [ 1, -1, 0, 0, -1, 0 ], [ 0, 0, 0, 0, -1, 0 ], [ 0, -1, 0, 0, -1, 1 ] ] +], +"ref_uid": "nil" +} \ No newline at end of file diff --git a/resources/43c05737/43c05737_code.scd b/resources/piece_ledger_transcribe_test/43c05737/43c05737_code.scd similarity index 100% rename from resources/43c05737/43c05737_code.scd rename to resources/piece_ledger_transcribe_test/43c05737/43c05737_code.scd diff --git a/resources/43c05737/43c05737_mus_model.json b/resources/piece_ledger_transcribe_test/43c05737/43c05737_mus_model.json similarity index 100% rename from resources/43c05737/43c05737_mus_model.json rename to resources/piece_ledger_transcribe_test/43c05737/43c05737_mus_model.json diff --git a/resources/46631d0e/46631d0e_code.scd b/resources/piece_ledger_transcribe_test/46631d0e/46631d0e_code.scd similarity index 100% rename from resources/46631d0e/46631d0e_code.scd rename to resources/piece_ledger_transcribe_test/46631d0e/46631d0e_code.scd diff --git a/resources/46631d0e/46631d0e_mus_model.json b/resources/piece_ledger_transcribe_test/46631d0e/46631d0e_mus_model.json similarity index 100% rename from resources/46631d0e/46631d0e_mus_model.json rename to resources/piece_ledger_transcribe_test/46631d0e/46631d0e_mus_model.json diff --git a/resources/47770d57/47770d57_code.scd b/resources/piece_ledger_transcribe_test/47770d57/47770d57_code.scd similarity index 100% rename from resources/47770d57/47770d57_code.scd rename to resources/piece_ledger_transcribe_test/47770d57/47770d57_code.scd diff --git a/resources/47770d57/47770d57_mus_model.json b/resources/piece_ledger_transcribe_test/47770d57/47770d57_mus_model.json similarity index 100% rename from resources/47770d57/47770d57_mus_model.json rename to resources/piece_ledger_transcribe_test/47770d57/47770d57_mus_model.json diff --git a/resources/4828752f/4828752f_code.scd b/resources/piece_ledger_transcribe_test/4828752f/4828752f_code.scd similarity index 100% rename from resources/4828752f/4828752f_code.scd rename to resources/piece_ledger_transcribe_test/4828752f/4828752f_code.scd diff --git a/resources/4828752f/4828752f_mus_model.json b/resources/piece_ledger_transcribe_test/4828752f/4828752f_mus_model.json similarity index 100% rename from resources/4828752f/4828752f_mus_model.json rename to resources/piece_ledger_transcribe_test/4828752f/4828752f_mus_model.json diff --git a/resources/49258e97/49258e97_code.scd b/resources/piece_ledger_transcribe_test/49258e97/49258e97_code.scd similarity index 100% rename from resources/49258e97/49258e97_code.scd rename to resources/piece_ledger_transcribe_test/49258e97/49258e97_code.scd diff --git a/resources/49258e97/49258e97_mus_model.json b/resources/piece_ledger_transcribe_test/49258e97/49258e97_mus_model.json similarity index 100% rename from resources/49258e97/49258e97_mus_model.json rename to resources/piece_ledger_transcribe_test/49258e97/49258e97_mus_model.json diff --git a/resources/497509c8/497509c8_code.scd b/resources/piece_ledger_transcribe_test/497509c8/497509c8_code.scd similarity index 100% rename from resources/497509c8/497509c8_code.scd rename to resources/piece_ledger_transcribe_test/497509c8/497509c8_code.scd diff --git a/resources/497509c8/497509c8_mus_model.json b/resources/piece_ledger_transcribe_test/497509c8/497509c8_mus_model.json similarity index 100% rename from resources/497509c8/497509c8_mus_model.json rename to resources/piece_ledger_transcribe_test/497509c8/497509c8_mus_model.json diff --git a/resources/piece_ledger_transcribe_test/4c01589b/4c01589b_code.scd b/resources/piece_ledger_transcribe_test/4c01589b/4c01589b_code.scd new file mode 100644 index 0000000..b11446a --- /dev/null +++ b/resources/piece_ledger_transcribe_test/4c01589b/4c01589b_code.scd @@ -0,0 +1,718 @@ +( +// helper funcs +var hsArrayToCents, pDist, hdSum, hsChordalDistance, hsArrayToFreq; + +// score funcs +var isInRange, spacingScore, rangeScore, intervalScore, inclusionScore; + +// subroutines +var genTuples, initVoices, genOrders, genSubMotif, updateVoices, genDurFunc; + +// primary routines +var genMotif, genSecondarySeq; + +// audition funcs +var genPatterns, genMidiPatterns; + +// resource management funcs +var seedFunc, genUID, writeResources, stringifyToDepth, setSeeds, sanityCheck, +msgInterpret, loadLedgerFile, loadLedgerJSON, loadModelFile, loadModelJSON; + +// model vars +//(model and global vars mostly set by OSC funcs +var curUID, refUID, orderSeed, durSeed, motifSeed, +entrancesProbVals, passagesProbVals, exitsProbVals, +ranges, orders, susWeights, passagesWeights, passagesSize, orderSize; + +// model aux vars +var entrancesDurFunc, passagesDurFunc, exitsDurFunc; + +// other global vars +var lastXChanges, popSize, exPath, dir, primes, dims, tuples, +seq, group, player, ledgerPath, ledger, currentlyPlayingUID; + + +// install JSON quark +if(Quarks.isInstalled("JSONlib").not, { + Quarks.install("https://github.com/musikinformatik/JSONlib.git"); + thisProcess.recompile; + //HelpBrowser.openHelpFor("Classes/JSONlib"); +}); + + +//------helper funcs + +hsArrayToCents = { + arg hsArray; + hsArray.collect({arg dist, p; dist * 1200 * log2(primes[p][0]/primes[p][1])}).sum +}; + +pDist = { + arg array1, array2, signed = false; + var pDistance; + pDistance = hsArrayToCents.value(array1) - hsArrayToCents.value(array2); + if(signed, {pDistance}, {abs(pDistance)}) +}; + +hdSum = { + arg hsArrays; + var size, distances, mean; + size = hsArrays.size; + distances = (size - 1).collect({arg i; + ((i + 1)..(size - 1)).collect({arg j; + abs(hsArrays[i] - hsArrays[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum + }); + }).flat; + mean = distances.sum / distances.size; + distances.sum + //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) +}; + +hsChordalDistance = { + arg hsArrays1, hsArrays2; + var size, distances, mean; + size = hsArrays1.size; + distances = hsArrays1.size.collect({arg i; + hsArrays2.size.collect({arg j; + abs(hsArrays1[i] - hsArrays2[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum + }); + }).flat; + mean = distances.sum / distances.size; + distances.sum + //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) +}; + +hsArrayToFreq = { + arg array; + array.collect({arg dim, d; pow(primes[d][0]/primes[d][1], dim)}).product +}; + +//------score funcs + +/* +isInRange = { + arg hsArray, min, max; + var cents; + cents = hsArrayToCents.value(hsArray); + (cents >= min) && (cents <= max) +}; +*/ + +spacingScore = { + arg hsArrays, min; + var centsArray; + centsArray = hsArrays.collect({arg hsArray; hsArrayToCents.value(hsArray)}).sort({arg a, b; a < b}); + centsArray.differentiate.drop(1).collect({arg pDistance; if(pDistance >= min, {1}, {0.01})}).sum; +}; + +rangeScore = { + arg hsArray1, hsArray2, min, max, low, signed = false; + var pDistance; + pDistance = pDist.value(hsArray1, hsArray2, signed); + if((pDistance >= min) && (pDistance <= max), {1}, {low}); +}; + +intervalScore = { + arg hsArray1, hsArray2, mean, sd, signed = false; + var pDistance; + pDistance = pDist.value(hsArray1, hsArray2, signed); + pDistance.gaussCurve(1, mean, sd) +}; + +inclusionScore = { + arg array, test, min = 0.01; + if(array.collect({arg v; v.hash}).includes(test.hash), {min}, {1}); +}; + + +//------subroutines + +genTuples = { + var tuples; + tuples = dims.collect({[-1, 0, 1]}).allTuples.select({arg tuple; (abs(tuple.drop(1)).sum <= 1) && (tuple[0] == 0)}); + tuples = tuples ++ tuples.collect({arg tuple; [-3, -2, -1, 1, 2, 3].collect({arg octTrans; tuple.deepCopy.put(0, octTrans)})}).flatten; +}; + +initVoices = { + var init, voicesInit; + voicesInit = popSize.collect({dims.collect({0})}); + /* + voicesInit = [dims.collect({0})]; + (popSize - 1).do({ + arg rep, new; + rep = dims.rand; + new = voicesInit.last.deepCopy; + new[rep] = new[rep] + [-1, 1].choose(); + voicesInit = voicesInit.add(new); + }); + */ + voicesInit.deepCopy; +}; + +genDurFunc = {arg chordProb, min, max, envData; + var env, pTable, durFunc; + env = Env.pairs([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).asSignal(256).asList.asArray; + pTable = env.asRandomTable; + durFunc = {arg allowChord; + var res; + res = if(allowChord.not, { + pTable.tableRand * (max - min) + min + }, { + if(1.0.rand < chordProb, {0}, {pTable.tableRand * (max - min) + min}); + }).round(0.125); + if(res.asInteger == res, {res = res.asInteger}); + res + }; + seedFunc.value(durFunc, durSeed); +}; + +genOrders = {arg minMotifLength = 1, maxMotifLength = 5, minProgLength = 0, maxProgLength = 5; + ((maxMotifLength - minMotifLength).rand + minMotifLength).collect({ + var noProgIns, noSusIns, noSilentIns, prog, sus, silent, order; + noSusIns = [1, 2, 3].wchoose(susWeights.normalizeSum); + noProgIns = (popSize - noSusIns).rand + 1; + noSilentIns = popSize - noSusIns - noProgIns; + + # prog, sus, silent = (0..(popSize-1)).scramble.clumps([noProgIns, noSusIns, noSilentIns]); + + prog = (prog.scramble ++ ((maxProgLength - minProgLength).rand + minProgLength).collect({prog.choose}).scramble); + if(silent == nil, {silent = []}); + [sus.scramble, prog, silent.scramble] + }); +}; + +updateVoices = {arg ins, sus; + var voices, candidates, nWeights, nProbs, sel; + + voices = lastXChanges.deepCopy.last; + + candidates = sus.collect({arg v; tuples.collect({arg t; voices[v] + t})}).flatten; + candidates = difference(candidates.asSet, voices.asSet).asList; + nProbs = candidates.collect({arg candidate; + var stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore; + + //stepScore = intervalScore.value(voices[ins], candidate, 30, 400, 0.1); + stepScore = intervalScore.value(voices[ins], candidate, 100, 100); + recentlySoundedScore = inclusionScore.value(lastXChanges.flop[ins], candidate, 0); + isInRangeScore = rangeScore.value(candidate, candidate.collect({0}), ranges[ins][0], ranges[ins][1], 0, true); + regScore = spacingScore.value(voices.deepCopy.put(ins, candidate), 300); + hdScore = 1/pow(hdSum.value(voices.deepCopy.put(ins, candidate)), 2); + //maybe what you want here is a vector to another root and then favoring movement towards it. + //distScore = pow(hsChordalDistance.value(voices, voices.put(ins, candidate)), 2); + + [stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore] + }); + + nWeights = passagesWeights; + + //this handles nWeights of 0; mainly for testing + nProbs = nProbs.flop.select({arg scores, s; nWeights[s] != 0}).flop; + nWeights = nWeights.select({arg weight; weight != 0}); + nProbs = nProbs.flop.collect({arg scores, s; + if(scores.sum == 0, {scores}, {scores.normalizeSum * nWeights[s]}) + }); + nProbs = nProbs.flop.collect({arg scores, s; scores.product}).normalizeSum; + + sel = candidates.wchoose(nProbs); + + voices[ins] = sel; + lastXChanges = lastXChanges.add(voices).keep(-5); +}; + +genSubMotif = {arg order, lastState, repeatLast = false, startFromLast = false, isLastOrder = false; + var sus, prog, silent, flatOrder, res, isInChord, allowChord, lastXChangesHold, voices, adder; + # sus, prog, silent = order; + flatOrder = silent ++ sus ++ prog; + lastXChangesHold = lastXChanges.deepCopy; + voices = lastState.deepCopy; + isInChord = popSize.collect({false}); + allowChord = false; + res = []; + "------generating motif".postln; + //need to figure out here if voices move between motifs + flatOrder.do({arg ins, i; + + if(prog.includes(ins) && repeatLast.not, {updateVoices.value(ins, sus)}); + adder = if(silent.includes(ins), {["Rest"]}, {lastXChanges.last.deepCopy[ins]}); + + if(voices[ins] != adder, { + var dur; + allowChord = if((sus ++ silent).includes(ins), { + (sus ++ silent).includes(ins) && (ins != sus.last); + }, { + if(i < (flatOrder.size - 1), {(isInChord[flatOrder[i + 1]] || (ins == flatOrder[i + 1])).not}, {false}); + }); + dur = passagesDurFunc.value(allowChord); + if(dur == 0, {isInChord[ins] = true}, {isInChord = popSize.collect({false})}); + + voices[ins] = adder; + res = res.add([voices.deepCopy.postln, dur]); + }); + }); + + // pad ending + if(isLastOrder, { + (0..(popSize-1)).scramble.do({arg ins; + if(res.last.first[ins] != ["Rest"], { + var dur; + voices[ins] = ["Rest"]; + allowChord = (voices != popSize.collect({["Rest"]})); + dur = passagesDurFunc.value(allowChord); + res = res.add([voices.deepCopy.postln, dur]); + }); + }); + }); + + //format and return + if(startFromLast, {lastXChanges = lastXChangesHold}); + res; +}; + + +//------primary routines + +genMotif = { + var repeats, fSeq; + + repeats = 1; + fSeq = []; + + repeats.do({arg index; + var motif; + + motif = []; + + orders.do({arg order, o; + var lastState, subMotif; + lastState = if(o == 0, {popSize.collect({["Rest"]})}, {motif.last.last.first}); + subMotif = genSubMotif.value(order, lastState, isLastOrder: o == (orders.size - 1)); + motif = motif.add(subMotif); + + }); + + sanityCheck.value(motif, index); + + fSeq = fSeq.add(motif); + }); + fSeq +}; + +genSecondarySeq = {arg seq; + var curdles, fSeq; + curdles = []; + while({curdles.sum < seq.size}, {curdles = curdles ++ [3.rand + 1]}); + + fSeq = seq.clumps(curdles).collect({arg clump, m; + var repeats, paddedSeq; + + //add rest + paddedSeq = clump.add([[[popSize.collect({["Rest"]}), 0.5.rand]]]); + + //implement repeats + repeats = [0.rand + 1, 1].wchoose([1, 0].normalizeSum); + repeats.collect({paddedSeq}); + }); + fSeq +}; + + +//------audition funcs + +Event.addEventType(\osc, { + if (~addr.postln.notNil) { + ~addr.sendMsg(~indexPath, ~indexMsg); + ~addr.sendMsg(~seqPath, stringifyToDepth.value(~seqMsg, 3)); + //~addr.sendMsg("/STATE/OPEN", (dir.replace("supercollider", "resources") +/+ ~idMsg +/+ ~idMsg ++ "_gui_state" ++ ".state").standardizePath.postln); + }; +}); + +genPatterns = {arg inSeq, addr; + var voices, durs, patterns, res, indices, sectionDurs, ids, seq; + seq = inSeq.collect({arg mSeq; mSeq[0]}); + # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; + indices = inSeq.collect({arg mSeq, m; mSeq[1]}); + ids = inSeq.collect({arg mSeq, m; mSeq[2]}); + sectionDurs = seq.collect({arg mSeq; mSeq.flatten2(mSeq.maxDepth - 5).flop[1].sum}); + res = Ppar( + voices.flop.collect({arg voice; + var clumps, hdScores, freqs, fDurs; + clumps = voice.separate({arg a, b; a != b }); + freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); + fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); + + Pbind( + \instrument, \test, + \group, group, + \freq, Pseq(freqs, 1), + \dur, Pseq(fDurs, 1), + \sustain, Pseq(fDurs, 1) + ) + }) ++ + [ + Pbind( + \type, \osc, + \addr, addr, + \indexPath, "/cur_play_index", + \indexMsg, Pseq(indices.postln, 1), + \seqPath, "/mus_seq", + \seqMsg, Pseq(seq, 1), + \dur, Pseq(sectionDurs, 1) + ); + ] + ); + res +}; + +/* +genMidiPatterns = {arg seq; + var voices, durs, patterns, res, mOut, pbRange; + pbRange = 1; //semitones - change this as needed for your situation + mOut = MIDIOut.newByName("TiMidity", "TiMidity port 0").latency_(Server.default.latency); + # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; + res = Ppar( + voices.flop.collect({arg voice, v; + var clumps, hdScores, freqs, fDurs; + + mOut.program(v, 70); + + clumps = voice.separate({arg a, b; a != b }); + freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); + fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); + + Pbind( + \type, \midi, + \chan, v, + \noteval, Pseq(freqs.cpsmidi - 24, 1), + \note, Pfunc({ | event | event[\noteval].floor }), + \dur, Pseq(fDurs, 1), + \midiout, mOut, + \amp, 1, + \bend, Pfunc({ + | event | + if (event[\note].isRest.not) { + var pitchbendvalue = event[\noteval].frac.linlin(0, pbRange, 8192, 8192*2).asInteger; + m.bend(v, pitchbendvalue); + }; + 0; // return something other than nil to avoid stopping the pattern + }), + ); + }); + ); + res +}; +*/ + + +//------resource management funcs + +genUID = {Date.seed.asHexString.toLower}; + +seedFunc = {arg func, seed; + var funcArgs, next; + next = Routine({loop{func.valueArray(funcArgs).yield }}); + next.randSeed_(seed); + {arg ...args; funcArgs = args; next.value} +}; + +stringifyToDepth = {arg data, maxDepth = 1; + var prettyString = "", rCount = 0, writeArray, indent; + + if(maxDepth == 0, { + data.asCompileString + }, { + indent = {arg size; size.collect({" "}).join("")}; + writeArray = {arg array; + prettyString = prettyString ++ indent.value(rCount) ++ "[\n"; + rCount = rCount + 1; + if(rCount < (maxDepth - 0), { + array.do({arg subArray; writeArray.value(subArray)}); + }, { + prettyString = prettyString ++ array.collect({arg subArray; + indent.value(rCount + 1) ++ subArray.asCompileString + }).join(",\n"); + }); + rCount = rCount - 1; + prettyString = prettyString ++ "\n" ++ indent.value(rCount) ++ "],\n"; + }; + + writeArray.value(data); + prettyString.replace(",\n\n", "\n").drop(-2); + }) +}; + +sanityCheck = {arg motif, index; + //print functions = very helpful + ("----------" + index + "------------").postln; + + motif.flatten.do({arg val, v; + if(v > 0, { + if(motif.flatten[v-1][0].hammingDistance(val[0]) > 1, {"problem 1".postln}); + if(motif.flatten[v-1][0].hammingDistance(val[0]) == 0, {"problem 2".postln}); + }); + val.postln + }); + "***********".postln; +}; + +msgInterpret = {arg in, escapeDoubleQuotes = true, escapeSingleQuotes = true; + var res; + + res = in; + if(res.isNil.not, { + if((res.isArray && res.isString.not), { + res = res.asCompileString; + res = res.replace(" ", "").replace("\n", "").replace("\t", ""); + if(escapeSingleQuotes, {res = res.replace("\'", "")}); + if(escapeDoubleQuotes, {res = res.replace("\"", "")}); + res = res.replace("Rest", "\"Rest\""); + res = res.interpret; + }, { + //res.postln; + if(res.every({arg char; char.isDecDigit}), {res = res.asInteger}); + }); + }); + res +}; + +writeResources = {arg path; + var file, nameSpaces, modelItems, resString; + file = File(path,"w"); + + nameSpaces = [ + "music_data", "last_changes", + "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", + "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", + "ranges", "passages_weights", "order", "sus_weights", "order_size", "passages_size" + ]; + + modelItems = [ + seq, lastXChanges, + curUID, refUID, orderSeed, durSeed, motifSeed, + entrancesProbVals, passagesProbVals, exitsProbVals, + ranges, passagesWeights, orders, susWeights, orderSize, passagesSize + ]; + + resString = [nameSpaces, modelItems].flop.collect({arg item; + var nameSpace, modelItem, depth = 0, insert = " "; + # nameSpace, modelItem = item; + if(nameSpace == "music_data", {depth = 3; insert = "\n"}); + if(nameSpace == "last_changes", {depth = 1; insert = "\n"}); + if(nameSpace == "order", {depth = 1; insert = "\n"}); + "\"" ++ nameSpace ++ "\":" ++ insert ++ stringifyToDepth.value(modelItem.postln, depth).postln + }).join(",\n"); + + resString = "{\n" ++ resString ++ "\n}"; + + file.write(resString); + file.close; +}; + +loadModelFile = {arg path; loadModelJSON.value(File(path, "r").readAllString.parseJSON)}; + +loadModelJSON = {arg model; + var nameSpaces, data; + + //model = File(path, "r").readAllString.parseJSON; + + nameSpaces = [ + "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", + "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", + "ranges", "passages_weights", "order", "sus_weights", "order_size", "passages_size" + ]; + + data = nameSpaces.collect({arg nS; msgInterpret.value(model[nS]).postln}); + + data.postln; + + # curUID, refUID, orderSeed, durSeed, motifSeed, + entrancesProbVals, passagesProbVals, exitsProbVals, + ranges, passagesWeights, orders, susWeights, orderSize, passagesSize = data; + + popSize = ranges.size; +}; + +loadLedgerFile = {arg path; + ledgerPath = path; + loadLedgerJSON.value(File(ledgerPath, "r").readAllString.parseJSON) +}; + +loadLedgerJSON = {arg ledger; ledger = ledger["ledger"]}; + +//------global vars + +primes = [[2, 1], [3, 2], [5, 4], [7, 4], [11, 8], [13, 8]]; +//ranges = [[-2400, 0], [-1200, 1200], [0, 2400], [0, 2400]]; +exPath = thisProcess.nowExecutingPath; +dir = exPath.dirname; +//popSize = 4; +dims = primes.size; +tuples = genTuples.value(); +//refUID = nil; +group = Group.new; +loadLedgerFile.value(dir +/+ ".." +/+ "resources" +/+ "piece_ledger.json"); +//passagesWeights = [1, 1, 1, 1, 1]; +//susWeights = [1, 1, 1]; + + +//------OSC funcs + +OSCdef(\load_ledger, {arg msg, time, addr, port; + loadLedgerFile.value(msg[1].asString); +}, \load_ledger); + +OSCdef(\load_model, {arg msg, time, addr, port; + loadModelFile.value(msg[1].asString); +}, \load_model); + + +OSCdef(\generate, {arg msg, time, addr, port; + var path, dFormat, condition, musPath; + msg.postln; + + path = msg[1].asString; + + loadModelFile.value(path); + + refUID.postln; + + loadLedgerFile.value(ledgerPath); + if(ledger.last != "tmp", {ledger = ledger.add("tmp")}); + + lastXChanges = if(refUID == nil, { + [initVoices.value().deepCopy]; + }, { + var file; + refUID.postln; + file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); + msgInterpret.value(file.readAllString.parseJSON["last_changes"]); + }); + + entrancesDurFunc = genDurFunc.valueArray(entrancesProbVals[..2] ++ [entrancesProbVals[3..]]); + passagesDurFunc = genDurFunc.valueArray(passagesProbVals[..2] ++ [passagesProbVals[3..]]); + exitsDurFunc = genDurFunc.valueArray(exitsProbVals[..2] ++ [exitsProbVals[3..]]); + + if(orders == nil, { + orders = seedFunc.value(genOrders, orderSeed).valueArray(orderSize ++ passagesSize); + addr.sendMsg("/order", stringifyToDepth.value(orders, 1)); + }); + seq = seedFunc.value(genMotif, motifSeed).value; + + //musPath = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; + writeResources.value(path); + + //orders = nil; + //addr.sendMsg("/current_uid", curUID); + //addr.sendMsg("/ledger", prettifyArray.value(ledger, 1).replace("\"", "")); + //addr.sendMsg("/ledger_size", ledger.size); + //addr.sendMsg("/mus_seq", prettifyArray.value(seq, 3)); + addr.sendMsg("/generated", musPath, stringifyToDepth.value(seq, 3)); +}, \generate); + + +OSCdef(\commit, {arg msg, time, addr, port; + var newLedger, modelPath, musString, musFile, test1, test2; + msg.postln; + + /* + test1 = msg[1].asString.parseJSON; + test2 = (dir +/+ ".." +/+ "resources/tmp/tmp_music" ++ ".json").standardizePath.parseJSONFile; + msgInterpret.value(test1["music"])[0][0][0][1].class.postln; + msgInterpret.value(test2["music_data"])[0][0][0][1].class.postln; + (test1["music"] == test2["music_data"]).postln; + */ + + curUID = genUID.value; + File.mkdir((dir +/+ ".." +/+ "resources" +/+ curUID).standardizePath); + File.copy(exPath, (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_code" ++ ".scd").standardizePath); + + modelPath = (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_mus_model" ++ ".json").standardizePath; + writeResources.value(modelPath); + + File.delete(ledgerPath.postln ++ "_bak"); + File.copy(ledgerPath, ledgerPath ++ "_bak"); + File.delete(ledgerPath); + newLedger = File(ledgerPath.postln, "w"); + ledger = ledger.postln.drop(-1).add(curUID); + newLedger.write("{\n\"ledger\":\n" ++ stringifyToDepth.value(ledger, 1) ++ "\n}"); + newLedger.close; + + addr.sendMsg("/committed", curUID, ledgerPath); + //refUID = curUID; +}, \commit); + +OSCdef(\transport, {arg msg, time, addr, port; + msg.postln; + if(msg[1] == 0, { + player.stop; + group.set(\gate, 0); + }, { + // the cued sequence can now be read from file, so this can be cleaned up + var cSize, patterns, pSeq, cuedSeek, indexStart, indexEnd, tmpLedger; + pSeq = []; + cuedSeek = (seq != nil); + indexStart = msg[2].asInteger; + indexEnd = ledger.size - if(cuedSeek, {2}, {1}); + if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { + ledger[indexStart..indexEnd].do({arg uid, index; + var file; + (indexStart + index).postln; + file = File((dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_music" ++ ".json").standardizePath, "r"); + pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), indexStart + index, uid]); + file.close; + }); + }); + if(cuedSeek, {pSeq = pSeq.add([seq, ledger.size - 1])}); + patterns = genPatterns.value(pSeq, addr); + player = Pfset(pattern: patterns, cleanupFunc: { + addr.sendMsg("/transport", 0); + }); + player = player.play + }); +}, \transport); + +) + +( +SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; + var trig, exc, sig1, sig2, noHarms; + noHarms = 30; + exc = Saw.ar(freq, TRand.ar(0.5, 1, Impulse.ar(freq))) * 0.001 + Dust.ar(10000, 0.01); + sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), + Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), + Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.5).softclip; + sig1 = HPF.ar(sig1, 300); + Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); +}).add; +) + +( +SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; + var trig, exc, sig1, sig2, noHarms, freqFinal, start, end; + noHarms = 30; + freq = WhiteNoise.ar * 3 + freq; + freqFinal = Duty.ar((1/freq), 0, freq); + trig = Changed.ar(freqFinal); + start = Demand.ar(trig, 0, Dwhite(-1, -0.75)); + end = Demand.ar(trig, 0, Dwhite(0.75, 1)); + exc = Phasor.ar(trig, (end - start) * freqFinal / SampleRate.ir, start, end, 0) * 0.001 + Dust.ar(10000, 0.01); + + sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), + Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), + Array.fill(noHarms, {rrand(2, 3)}) ], exc) * 0.5).softclip; + sig1 = HPF.ar(sig1, 300); + Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); +}).add; +) + + + +"{\"a\": 1}".parseYAML["a"].asInteger; +"{\"a\": 1}".parseJSON["a"].isNumber; + +1223423434123.asHexString.toLower + +Date.getDate.rawSeconds +Date.seed.asHexString.toLower + +n = NetAddr("localhost", 8080); +n.sendMsg("/GET/#", (NetAddr.localAddr.hostname ++ ":" ++ NetAddr.localAddr.port), "/passage_probs_vals"); \ No newline at end of file diff --git a/resources/piece_ledger_transcribe_test/4c01589b/4c01589b_gui_state.json b/resources/piece_ledger_transcribe_test/4c01589b/4c01589b_gui_state.json new file mode 100644 index 0000000..2bc73d6 --- /dev/null +++ b/resources/piece_ledger_transcribe_test/4c01589b/4c01589b_gui_state.json @@ -0,0 +1,1359 @@ +{ + "motif_label": "motif", + "seeds_label": "seeds", + "order": "[\n [ [ 3, 1, 0 ], [ 2 ], [ ] ],\n [ [ 1, 2 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 3 ] ],\n [ [ 3, 2 ], [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ], [ 0 ] ],\n [ [ 2, 3 ], [ 0, 1, 0 ], [ ] ]\n]", + "order_lock": 1, + "order_size": [ + 3, + 8 + ], + "order_size_v2": 8, + "order_size_v1": 3, + "order_size_panel": -1, + "passage_size_v2": 8, + "passage_size_v1": 2, + "passage_size_panel": -1, + "sus_weights": [ + null, + null, + null + ], + "range_matrix": [ + null, + null, + null, + null + ], + "instrumentation": [ + 0, + 0 + ], + "entrances_probs_sync": "passages", + "entrances": -1, + "passages_probs_sync": "passages", + "passages": -1, + "exits_probs_sync": "passages", + "exits": -1, + "dur_panel": 0, + "durations": -1, + "passages_weights": [ + null, + null, + null, + null, + null + ], + "weights": -1, + "seeds_tab_panel": 0, + "weights_seed_lock": 0, + "weights_seed": 534103, + "sus_weights/0_slider_val": 0.21, + "sus_weights/0_slider_slider": 0.21, + "sus_weights/0_slider_input": 0.21, + "sus_weights/0_slider_label": 1, + "sus_weights/0_slider": -1, + "sus_weights/1_slider_val": 0.35, + "sus_weights/1_slider_slider": 0.35, + "sus_weights/1_slider_input": 0.35, + "sus_weights/1_slider_label": 2, + "sus_weights/1_slider": -1, + "sus_weights/2_slider_val": 0.21, + "sus_weights/2_slider_slider": 0.21, + "sus_weights/2_slider_input": 0.21, + "sus_weights/2_slider_label": 3, + "sus_weights/2_slider": -1, + "passages_weights/0_slider_val": 0.49, + "passages_weights/0_slider_slider": 0.49, + "passages_weights/0_slider_input": 0.49, + "passages_weights/0_slider_label": "step", + "passages_weights/0_slider": -1, + "passages_weights/1_slider_val": 0.53, + "passages_weights/1_slider_slider": 0.53, + "passages_weights/1_slider_input": 0.53, + "passages_weights/1_slider_label": "dc", + "passages_weights/1_slider": -1, + "passages_weights/2_slider_val": 0.35, + "passages_weights/2_slider_slider": 0.35, + "passages_weights/2_slider_input": 0.35, + "passages_weights/2_slider_label": "range", + "passages_weights/2_slider": -1, + "passages_weights/3_slider_val": 0.59, + "passages_weights/3_slider_slider": 0.59, + "passages_weights/3_slider_input": 0.59, + "passages_weights/3_slider_label": "registration", + "passages_weights/3_slider": -1, + "passages_weights/4_slider_val": 0.39, + "passages_weights/4_slider_slider": 0.39, + "passages_weights/4_slider_input": 0.39, + "passages_weights/4_slider_label": "hd", + "passages_weights/4_slider": -1, + "range_matrix/0_val_input_min": -853.2067988668555, + "range_matrix/0_val_rslider": [ + -853.2067988668555, + 401 + ], + "range_matrix/0_val_input_max": 401, + "range_matrix/0_val": -1, + "range_matrix/1_val_input_min": -659, + "range_matrix/1_val_rslider": [ + -659, + 880 + ], + "range_matrix/1_val_input_max": 880, + "range_matrix/1_val": -1, + "range_matrix/2_val_input_min": -241, + "range_matrix/2_val_rslider": [ + -241, + 1869 + ], + "range_matrix/2_val_input_max": 1869, + "range_matrix/2_val": -1, + "range_matrix/3_val_input_min": -27, + "range_matrix/3_val_rslider": [ + -27, + 2063 + ], + "range_matrix/3_val_input_max": 2063, + "range_matrix/3_val": -1, + "entrances_probs_chord_slider_val": 0.66, + "entrances_probs_chord_slider_slider": 0.66, + "entrances_probs_chord_slider_input": 0.66, + "entrances_probs_chord_slider_label": "chord prob", + "entrances_probs_chord_slider": -1, + "entrances_probs_vals": [ + 0.63, + 0, + 5, + 0, + 0.5, + 0.23316062176165803, + 0.7094594594594594, + 0.3963730569948187, + 0.8716216216216216, + 0.4948186528497409, + 0.5912162162162162, + 0.5362694300518135, + 0.8614864864864865, + 0.6424870466321243, + 0.5912162162162162, + 0.7901554404145078, + 0.8277027027027027, + 1, + 0.5 + ], + "entrances_probs": -1, + "passages_probs_chord_slider_val": 0.63, + "passages_probs_chord_slider_slider": 0.63, + "passages_probs_chord_slider_input": 0.63, + "passages_probs_chord_slider_label": "chord prob", + "passages_probs_chord_slider": -1, + "passages_probs_vals": [ + 0.63, + 0, + 5, + 0, + 0.5, + 0.23316062176165803, + 0.7094594594594594, + 0.3963730569948187, + 0.8716216216216216, + 0.4948186528497409, + 0.5912162162162162, + 0.5362694300518135, + 0.8614864864864865, + 0.6424870466321243, + 0.5912162162162162, + 0.7901554404145078, + 0.8277027027027027, + 1, + 0.5 + ], + "passages_probs": -1, + "exits_probs_chord_slider_val": 0, + "exits_probs_chord_slider_slider": 0, + "exits_probs_chord_slider_input": 0, + "exits_probs_chord_slider_label": "chord prob", + "exits_probs_chord_slider": -1, + "exits_probs_vals": [ + 0, + 0, + 5, + 0, + 0.5, + 0.23316062176165803, + 0.7094594594594594, + 0.4948186528497409, + 0.5912162162162162, + 0.7901554404145078, + 0.8277027027027027, + 1, + 0.5 + ], + "exits_probs": -1, + "step_env_env_vals": [ + 0, + 5, + 0, + 0, + 0, + 0, + 0.14609053497942387, + 0.7613636363636364, + 0.20164609053497942, + 0.26136363636363635, + 0.24279835390946503, + 0.7215909090909092, + 0.39094650205761317, + 0.875, + 0.4567901234567901, + 0.44318181818181823, + 0.5432098765432098, + 0.34659090909090906, + 0.6481481481481481, + 0.8011363636363636, + 0.6810699588477366, + 0.5170454545454546, + 0.8868312757201646, + 0.49431818181818177, + 0.8868312757201646, + 0.49431818181818177 + ], + "step_env_env_canvas": [ + [ + 0, + 0 + ], + [ + 0, + 0 + ], + [ + 0.14609053497942387, + 0.7613636363636364 + ], + [ + 0.20164609053497942, + 0.26136363636363635 + ], + [ + 0.24279835390946503, + 0.7215909090909092 + ], + [ + 0.39094650205761317, + 0.875 + ], + [ + 0.4567901234567901, + 0.44318181818181823 + ], + [ + 0.5432098765432098, + 0.34659090909090906 + ], + [ + 0.6481481481481481, + 0.8011363636363636 + ], + [ + 0.6810699588477366, + 0.5170454545454546 + ], + [ + 0.8868312757201646, + 0.49431818181818177 + ], + [ + 0.8868312757201646, + 0.49431818181818177 + ], + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "step_env_env_size": 12, + "step_env_env_flatten": 0, + "step_env_env_rslider": [ + 0, + 5 + ], + "step_env_env_rslider_v2": 5, + "step_env_env_rslider_v1": 0, + "step_env_env_mpos": "", + "step_env_env": -1, + "entrances_probs_dur_env_vals": [ + 0.515267175572519, + 4.599236641221374, + 0, + 0.5, + 0.2772020725388601, + 0.7972972972972973, + 0.45077720207253885, + 0.8783783783783784, + 0.5, + 0.5, + 0.727979274611399, + 0.45270270270270274, + 0.7357512953367875, + 0.6486486486486487, + 0.8911917098445595, + 0.7905405405405406, + 1, + 0.5 + ], + "entrances_probs_dur_env_canvas": [ + [ + 0, + 0.5 + ], + [ + 0.2772020725388601, + 0.7972972972972973 + ], + [ + 0.45077720207253885, + 0.8783783783783784 + ], + [ + 0.5, + 0.5 + ], + [ + 0.727979274611399, + 0.45270270270270274 + ], + [ + 0.7357512953367875, + 0.6486486486486487 + ], + [ + 0.8911917098445595, + 0.7905405405405406 + ], + [ + 1, + 0.5 + ], + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "entrances_probs_dur_env_size": 8, + "entrances_probs_dur_env_flatten": 0, + "entrances_probs_dur_env_rslider": [ + 0.515267175572519, + 4.599236641221374 + ], + "entrances_probs_dur_env_rslider_v2": 4.599236641221374, + "entrances_probs_dur_env_rslider_v1": 0.515267175572519, + "entrances_probs_dur_env_mpos": "", + "entrances_probs_dur_env": -1, + "passages_probs_dur_env_vals": [ + 0, + 5, + 0, + 0.5, + 0.23316062176165803, + 0.7094594594594594, + 0.3963730569948187, + 0.8716216216216216, + 0.4948186528497409, + 0.5912162162162162, + 0.5362694300518135, + 0.8614864864864865, + 0.6424870466321243, + 0.5912162162162162, + 0.7901554404145078, + 0.8277027027027027, + 1, + 0.5 + ], + "passages_probs_dur_env_canvas": [ + [ + 0, + 0.5 + ], + [ + 0.23316062176165803, + 0.7094594594594594 + ], + [ + 0.3963730569948187, + 0.8716216216216216 + ], + [ + 0.4948186528497409, + 0.5912162162162162 + ], + [ + 0.5362694300518135, + 0.8614864864864865 + ], + [ + 0.6424870466321243, + 0.5912162162162162 + ], + [ + 0.7901554404145078, + 0.8277027027027027 + ], + [ + 1, + 0.5 + ], + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "passages_probs_dur_env_size": 8, + "passages_probs_dur_env_flatten": 0, + "passages_probs_dur_env_rslider": [ + 0, + 5 + ], + "passages_probs_dur_env_rslider_v2": 5, + "passages_probs_dur_env_rslider_v1": 0, + "passages_probs_dur_env_mpos": "", + "passages_probs_dur_env": -1, + "exits_probs_dur_env_vals": [ + 0, + 5, + 0, + 0.5, + 0.5, + 0.5, + 1, + 0.5 + ], + "exits_probs_dur_env_canvas": [ + [ + 0, + 0.5 + ], + [ + 0.5, + 0.5 + ], + [ + 1, + 0.5 + ], + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "exits_probs_dur_env_size": 3, + "exits_probs_dur_env_flatten": 0, + "exits_probs_dur_env_rslider": [ + 0, + 5 + ], + "exits_probs_dur_env_rslider_v2": 5, + "exits_probs_dur_env_rslider_v1": 0, + "exits_probs_dur_env_mpos": "", + "exits_probs_dur_env": -1, + "mus_seq": [ + [ + [ + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + "Rest" + ], + [ + "Rest" + ] + ], + 0 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + "Rest" + ] + ], + 1.75 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.75 + ], + [ + [ + [ + 0, + 1, + -3, + 0, + 2, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0.75 + ], + [ + [ + [ + 1, + 1, + -2, + -2, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0.625 + ], + [ + [ + [ + 1, + 1, + -3, + -1, + 0, + 0 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0.625 + ], + [ + [ + [ + 1, + 0, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.75 + ] + ], + [ + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.75 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 1, + -2, + 0, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.375 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 2, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0.75 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 1, + -2, + -1, + 2, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.75 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 0, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.875 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1 + ] + ], + [ + [ + [ + [ + 1, + 0, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0 + ], + [ + [ + [ + 1, + 0, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 2, + 0, + -3, + -1, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.625 + ], + [ + [ + [ + 1, + 0, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 1, + -1, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.75 + ], + [ + [ + [ + 1, + 0, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 1, + -1, + -1, + 1, + 0 + ], + [ + "Rest" + ] + ], + 0 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 1, + -1, + -1, + 1, + 0 + ], + [ + "Rest" + ] + ], + 1.875 + ], + [ + [ + [ + "Rest" + ], + [ + "Rest" + ], + [ + 0, + 1, + -1, + -1, + 1, + 0 + ], + [ + "Rest" + ] + ], + 0 + ], + [ + [ + [ + "Rest" + ], + [ + "Rest" + ], + [ + "Rest" + ], + [ + "Rest" + ] + ], + 0.875 + ] + ] + ] + ], + "root": [ + 0.20743639921722112, + 0 + ], + "order_seed": 798574, + "dur_seed": 884869, + "passages_size": [ + 0, + 10 + ], + "dur_seed_lock": 1, + "order_seed_lock": 0, + "seeds_panel": -1, + "motif_panel": [ + 0, + 0 + ], + "ref_uid": "6f1a789f", + "cur_uid": "4c01589b" +} \ No newline at end of file diff --git a/resources/piece_ledger_transcribe_test/4c01589b/4c01589b_mus_model.json b/resources/piece_ledger_transcribe_test/4c01589b/4c01589b_mus_model.json new file mode 100644 index 0000000..436b630 --- /dev/null +++ b/resources/piece_ledger_transcribe_test/4c01589b/4c01589b_mus_model.json @@ -0,0 +1,85 @@ +{ +"music_data": +[ + [ + [ + [ [ [ "Rest" ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ] ], 1.75 ], + [ [ [ "Rest" ], [ -1, 0, 0, 1, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ] ], 0 ], + [ [ [ "Rest" ], [ -1, 0, 0, 1, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 1, 0, 0, 0 ] ], 0 ], + [ [ [ -1, 0, 0, 0, 0, 1 ], [ -1, 0, 0, 1, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 1, 0, 0, 0 ] ], 1.25 ], + [ [ [ -1, 0, 0, 0, 0, 1 ], [ 0, 0, -1, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 1, 0, 0, 0 ] ], 1.75 ], + [ [ [ -1, 0, 0, 0, 0, 1 ], [ -1, 1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 1, 0, 0, 0 ] ], 0 ], + [ [ [ -1, 0, 0, 0, 0, 1 ], [ -1, 1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ] ], 0 ], + [ [ [ -1, 0, 0, 1, 0, 0 ], [ -1, 1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ] ], 0.875 ], + [ [ [ 1, 0, 0, -1, 0, 0 ], [ -1, 1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 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 0, 0 ] ], + [ [ 0, 1, 0, 0, 0, 0 ], [ -1, 1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ] ], + [ [ 0, 1, 0, 0, 0, 0 ], [ 1, -1, 0, -1, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ] ], + [ [ 0, 1, 0, 0, 0, 0 ], [ 1, 0, 0, -1, -1, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ] ] +], +"cur_uid": "4c01589b", +"ref_uid": "nil", +"order_seed": 720097, +"dur_seed": 979064, +"motifs_seed": 718021, +"entrances_probs_vals": [ 0.75, 0.5, 2, 0, 0.5, 0.26424870466321, 0.75675675675676, 0.5, 0.5, 0.58549222797927, 0.72635135135135, 1, 0.5 ], +"passages_probs_vals": [ 0.75, 0.5, 2, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], +"exits_probs_vals": [ 0.75, 0.5, 2, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], +"ranges": [ [ -384, 2400 ], [ -507, 2400 ], [ -282, 2237 ], [ -1200, 2053 ] ], +"passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], +"order": +[ + [ [ 2 ], [ 1, 3, 0, 1, 1, 3, 0, 0, 3, 0, 0, 3 ], [ ] ], + [ [ 1, 0, 3 ], [ 2, 2, 2, 2, 2, 2, 2, 2 ], [ ] ], + [ [ 3, 2, 0 ], [ 1, 1, 1, 1 ], [ ] ], + [ [ 0 ], [ 2 ], [ 3, 1 ] ], + [ [ 0, 2, 3 ], [ 1, 1, 1, 1, 1, 1 ], [ ] ] +], +"sus_weights": [ 0.75, 0.69, 0.75 ], +"order_size": [ 2, 6 ], +"passages_size": [ 0, 10 ] +} \ No newline at end of file diff --git a/resources/5397abab/5397abab_code.scd b/resources/piece_ledger_transcribe_test/5397abab/5397abab_code.scd similarity index 100% rename from resources/5397abab/5397abab_code.scd rename to resources/piece_ledger_transcribe_test/5397abab/5397abab_code.scd diff --git a/resources/5397abab/5397abab_mus_model.json b/resources/piece_ledger_transcribe_test/5397abab/5397abab_mus_model.json similarity index 100% rename from resources/5397abab/5397abab_mus_model.json rename to resources/piece_ledger_transcribe_test/5397abab/5397abab_mus_model.json diff --git a/resources/54479f3d/54479f3d_code.scd b/resources/piece_ledger_transcribe_test/54479f3d/54479f3d_code.scd similarity index 100% rename from resources/54479f3d/54479f3d_code.scd rename to resources/piece_ledger_transcribe_test/54479f3d/54479f3d_code.scd diff --git a/resources/54479f3d/54479f3d_mus_model.json b/resources/piece_ledger_transcribe_test/54479f3d/54479f3d_mus_model.json similarity index 100% rename from resources/54479f3d/54479f3d_mus_model.json rename to resources/piece_ledger_transcribe_test/54479f3d/54479f3d_mus_model.json diff --git a/resources/57fa6a01/57fa6a01_code.scd b/resources/piece_ledger_transcribe_test/57fa6a01/57fa6a01_code.scd similarity index 100% rename from resources/57fa6a01/57fa6a01_code.scd rename to resources/piece_ledger_transcribe_test/57fa6a01/57fa6a01_code.scd diff --git a/resources/57fa6a01/57fa6a01_mus_model.json b/resources/piece_ledger_transcribe_test/57fa6a01/57fa6a01_mus_model.json similarity index 100% rename from resources/57fa6a01/57fa6a01_mus_model.json rename to resources/piece_ledger_transcribe_test/57fa6a01/57fa6a01_mus_model.json diff --git a/resources/5cd72e22/5cd72e22_code.scd b/resources/piece_ledger_transcribe_test/5cd72e22/5cd72e22_code.scd similarity index 100% rename from resources/5cd72e22/5cd72e22_code.scd rename to resources/piece_ledger_transcribe_test/5cd72e22/5cd72e22_code.scd diff --git a/resources/5cd72e22/5cd72e22_mus_model.json b/resources/piece_ledger_transcribe_test/5cd72e22/5cd72e22_mus_model.json similarity index 100% rename from resources/5cd72e22/5cd72e22_mus_model.json rename to resources/piece_ledger_transcribe_test/5cd72e22/5cd72e22_mus_model.json diff --git a/resources/600e3005/600e3005_code.scd b/resources/piece_ledger_transcribe_test/600e3005/600e3005_code.scd similarity index 100% rename from resources/600e3005/600e3005_code.scd rename to resources/piece_ledger_transcribe_test/600e3005/600e3005_code.scd diff --git a/resources/600e3005/600e3005_mus_model.json b/resources/piece_ledger_transcribe_test/600e3005/600e3005_mus_model.json similarity index 100% rename from resources/600e3005/600e3005_mus_model.json rename to resources/piece_ledger_transcribe_test/600e3005/600e3005_mus_model.json diff --git a/resources/piece_ledger_transcribe_test/640eeed3/640eeed3_code.scd b/resources/piece_ledger_transcribe_test/640eeed3/640eeed3_code.scd new file mode 100644 index 0000000..af06ede --- /dev/null +++ b/resources/piece_ledger_transcribe_test/640eeed3/640eeed3_code.scd @@ -0,0 +1,716 @@ +( +// helper funcs +var hsArrayToCents, pDist, hdSum, hsChordalDistance, hsArrayToFreq; + +// score funcs +var isInRange, spacingScore, rangeScore, intervalScore, inclusionScore; + +// subroutines +var genTuples, initVoices, genOrders, genSubMotif, updateVoices, genDurFunc; + +// primary routines +var genMotif, genSecondarySeq; + +// audition funcs +var genPatterns, genMidiPatterns; + +// resource management funcs +var seedFunc, genUID, writeResources, stringifyToDepth, setSeeds, sanityCheck, +msgInterpret, loadLedgerFile, loadLedgerJSON, loadModelFile, loadModelJSON; + +// model vars +//(model and global vars mostly set by OSC funcs +var curUID, refUID, orderSeed, durSeed, motifSeed, +entrancesProbVals, passagesProbVals, exitsProbVals, +ranges, orders, susWeights, passagesWeights, passagesSize, orderSize; + +// model aux vars +var entrancesDurFunc, passagesDurFunc, exitsDurFunc; + +// other global vars +var lastXChanges, popSize, exPath, dir, primes, dims, tuples, +seq, group, player, ledgerPath, ledger, currentlyPlayingUID; + + +// install JSON quark +if(Quarks.isInstalled("JSONlib").not, { + Quarks.install("https://github.com/musikinformatik/JSONlib.git"); + thisProcess.recompile; + //HelpBrowser.openHelpFor("Classes/JSONlib"); +}); + + +//------helper funcs + +hsArrayToCents = { + arg hsArray; + hsArray.collect({arg dist, p; dist * 1200 * log2(primes[p][0]/primes[p][1])}).sum +}; + +pDist = { + arg array1, array2, signed = false; + var pDistance; + pDistance = hsArrayToCents.value(array1) - hsArrayToCents.value(array2); + if(signed, {pDistance}, {abs(pDistance)}) +}; + +hdSum = { + arg hsArrays; + var size, distances, mean; + size = hsArrays.size; + distances = (size - 1).collect({arg i; + ((i + 1)..(size - 1)).collect({arg j; + abs(hsArrays[i] - hsArrays[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum + }); + }).flat; + mean = distances.sum / distances.size; + distances.sum + //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) +}; + +hsChordalDistance = { + arg hsArrays1, hsArrays2; + var size, distances, mean; + size = hsArrays1.size; + distances = hsArrays1.size.collect({arg i; + hsArrays2.size.collect({arg j; + abs(hsArrays1[i] - hsArrays2[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum + }); + }).flat; + mean = distances.sum / distances.size; + distances.sum + //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) +}; + +hsArrayToFreq = { + arg array; + array.collect({arg dim, d; pow(primes[d][0]/primes[d][1], dim)}).product +}; + +//------score funcs + +/* +isInRange = { + arg hsArray, min, max; + var cents; + cents = hsArrayToCents.value(hsArray); + (cents >= min) && (cents <= max) +}; +*/ + +spacingScore = { + arg hsArrays, min; + var centsArray; + centsArray = hsArrays.collect({arg hsArray; hsArrayToCents.value(hsArray)}).sort({arg a, b; a < b}); + centsArray.differentiate.drop(1).collect({arg pDistance; if(pDistance >= min, {1}, {0.01})}).sum; +}; + +rangeScore = { + arg hsArray1, hsArray2, min, max, low, signed = false; + var pDistance; + pDistance = pDist.value(hsArray1, hsArray2, signed); + if((pDistance >= min) && (pDistance <= max), {1}, {low}); +}; + +intervalScore = { + arg hsArray1, hsArray2, mean, sd, signed = false; + var pDistance; + pDistance = pDist.value(hsArray1, hsArray2, signed); + pDistance.gaussCurve(1, mean, sd) +}; + +inclusionScore = { + arg array, test, min = 0.01; + if(array.collect({arg v; v.hash}).includes(test.hash), {min}, {1}); +}; + + +//------subroutines + +genTuples = { + var tuples; + tuples = dims.collect({[-1, 0, 1]}).allTuples.select({arg tuple; (abs(tuple.drop(1)).sum <= 1) && (tuple[0] == 0)}); + tuples = tuples ++ tuples.collect({arg tuple; [-3, -2, -1, 1, 2, 3].collect({arg octTrans; tuple.deepCopy.put(0, octTrans)})}).flatten; +}; + +initVoices = { + var init, voicesInit; + voicesInit = popSize.collect({dims.collect({0})}); + /* + voicesInit = [dims.collect({0})]; + (popSize - 1).do({ + arg rep, new; + rep = dims.rand; + new = voicesInit.last.deepCopy; + new[rep] = new[rep] + [-1, 1].choose(); + voicesInit = voicesInit.add(new); + }); + */ + voicesInit.deepCopy; +}; + +genDurFunc = {arg chordProb, min, max, envData; + var env, pTable, durFunc; + env = Env.pairs([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).asSignal(256).asList.asArray; + pTable = env.asRandomTable; + durFunc = {arg allowChord; + var res; + res = if(allowChord.not, { + pTable.tableRand * (max - min) + min + }, { + if(1.0.rand < chordProb, {0}, {pTable.tableRand * (max - min) + min}); + }).round(0.125); + if(res.asInteger == res, {res = res.asInteger}); + res + }; + seedFunc.value(durFunc, durSeed); +}; + +genOrders = {arg minMotifLength = 1, maxMotifLength = 5, minProgLength = 0, maxProgLength = 5; + ((maxMotifLength - minMotifLength).rand + minMotifLength).collect({ + var noProgIns, noSusIns, noSilentIns, prog, sus, silent, order; + noSusIns = [1, 2, 3].wchoose(susWeights.normalizeSum); + noProgIns = (popSize - noSusIns).rand + 1; + noSilentIns = popSize - noSusIns - noProgIns; + + # prog, sus, silent = (0..(popSize-1)).scramble.clumps([noProgIns, noSusIns, noSilentIns]); + + prog = (prog.scramble ++ ((maxProgLength - minProgLength).rand + minProgLength).collect({prog.choose}).scramble); + if(silent == nil, {silent = []}); + [sus.scramble, prog, silent.scramble] + }); +}; + +updateVoices = {arg ins, sus; + var voices, candidates, nWeights, nProbs, sel; + + voices = lastXChanges.deepCopy.last; + + candidates = sus.collect({arg v; tuples.collect({arg t; voices[v] + t})}).flatten; + candidates = difference(candidates.asSet, voices.asSet).asList; + nProbs = candidates.collect({arg candidate; + var stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore; + + //stepScore = intervalScore.value(voices[ins], candidate, 30, 400, 0.1); + stepScore = intervalScore.value(voices[ins], candidate, 100, 100); + recentlySoundedScore = inclusionScore.value(lastXChanges.flop[ins], candidate, 0); + isInRangeScore = rangeScore.value(candidate, candidate.collect({0}), ranges[ins][0], ranges[ins][1], 0, true); + regScore = spacingScore.value(voices.deepCopy.put(ins, candidate), 300); + hdScore = 1/pow(hdSum.value(voices.deepCopy.put(ins, candidate)), 2); + //maybe what you want here is a vector to another root and then favoring movement towards it. + //distScore = pow(hsChordalDistance.value(voices, voices.put(ins, candidate)), 2); + + [stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore] + }); + + nWeights = passagesWeights; + + //this handles nWeights of 0; mainly for testing + nProbs = nProbs.flop.select({arg scores, s; nWeights[s] != 0}).flop; + nWeights = nWeights.select({arg weight; weight != 0}); + nProbs = nProbs.flop.collect({arg scores, s; + if(scores.sum == 0, {scores}, {scores.normalizeSum * nWeights[s]}) + }); + nProbs = nProbs.flop.collect({arg scores, s; scores.product}).normalizeSum; + + sel = candidates.wchoose(nProbs); + + voices[ins] = sel; + lastXChanges = lastXChanges.add(voices).keep(-5); +}; + +genSubMotif = {arg order, lastState, repeatLast = false, startFromLast = false, isLastOrder = false; + var sus, prog, silent, flatOrder, res, isInChord, allowChord, lastXChangesHold, voices, adder; + # sus, prog, silent = order; + flatOrder = silent ++ sus ++ prog; + lastXChangesHold = lastXChanges.deepCopy; + voices = lastState.deepCopy; + isInChord = popSize.collect({false}); + allowChord = false; + res = []; + "------generating motif".postln; + //need to figure out here if voices move between motifs + flatOrder.do({arg ins, i; + + if(prog.includes(ins) && repeatLast.not, {updateVoices.value(ins, sus)}); + adder = if(silent.includes(ins), {["Rest"]}, {lastXChanges.last.deepCopy[ins]}); + + if(voices[ins] != adder, { + var dur; + allowChord = if((sus ++ silent).includes(ins), { + (sus ++ silent).includes(ins) && (ins != sus.last); + }, { + if(i < (flatOrder.size - 1), {(isInChord[flatOrder[i + 1]] || (ins == flatOrder[i + 1])).not}, {false}); + }); + dur = passagesDurFunc.value(allowChord); + if(dur == 0, {isInChord[ins] = true}, {isInChord = popSize.collect({false})}); + + voices[ins] = adder; + res = res.add([voices.deepCopy.postln, dur]); + }); + }); + + // pad ending + if(isLastOrder, { + (0..(popSize-1)).scramble.do({arg ins; + if(res.last.first[ins] != ["Rest"], { + var dur; + voices[ins] = ["Rest"]; + allowChord = (voices != popSize.collect({["Rest"]})); + dur = passagesDurFunc.value(allowChord); + res = res.add([voices.deepCopy.postln, dur]); + }); + }); + }); + + //format and return + if(startFromLast, {lastXChanges = lastXChangesHold}); + res; +}; + + +//------primary routines + +genMotif = { + var repeats, fSeq; + + repeats = 1; + fSeq = []; + + repeats.do({arg index; + var motif; + + motif = []; + + orders.do({arg order, o; + var lastState, subMotif; + lastState = if(o == 0, {popSize.collect({["Rest"]})}, {motif.last.last.first}); + subMotif = genSubMotif.value(order, lastState, isLastOrder: o == (orders.size - 1)); + motif = motif.add(subMotif); + + }); + + sanityCheck.value(motif, index); + + fSeq = fSeq.add(motif); + }); + fSeq +}; + +genSecondarySeq = {arg seq; + var curdles, fSeq; + curdles = []; + while({curdles.sum < seq.size}, {curdles = curdles ++ [3.rand + 1]}); + + fSeq = seq.clumps(curdles).collect({arg clump, m; + var repeats, paddedSeq; + + //add rest + paddedSeq = clump.add([[[popSize.collect({["Rest"]}), 0.5.rand]]]); + + //implement repeats + repeats = [0.rand + 1, 1].wchoose([1, 0].normalizeSum); + repeats.collect({paddedSeq}); + }); + fSeq +}; + + +//------audition funcs + +Event.addEventType(\osc, { + if (~addr.postln.notNil) { + ~addr.sendMsg(~indexPath, ~indexMsg); + ~addr.sendMsg(~seqPath, stringifyToDepth.value(~seqMsg, 3)); + //~addr.sendMsg("/STATE/OPEN", (dir.replace("supercollider", "resources") +/+ ~idMsg +/+ ~idMsg ++ "_gui_state" ++ ".state").standardizePath.postln); + }; +}); + +genPatterns = {arg inSeq, addr; + var voices, durs, patterns, res, indices, sectionDurs, ids, seq; + seq = inSeq.collect({arg mSeq; mSeq[0]}); + # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; + indices = inSeq.collect({arg mSeq, m; mSeq[1]}); + ids = inSeq.collect({arg mSeq, m; mSeq[2]}); + sectionDurs = seq.collect({arg mSeq; mSeq.flatten2(mSeq.maxDepth - 5).flop[1].sum}); + res = Ppar( + voices.flop.collect({arg voice; + var clumps, hdScores, freqs, fDurs; + clumps = voice.separate({arg a, b; a != b }); + freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); + fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); + + Pbind( + \instrument, \test, + \group, group, + \freq, Pseq(freqs, 1), + \dur, Pseq(fDurs, 1), + \sustain, Pseq(fDurs, 1) + ) + }) ++ + [ + Pbind( + \type, \osc, + \addr, addr, + \indexPath, "/cur_play_index", + \indexMsg, Pseq(indices.postln, 1), + \seqPath, "/mus_seq", + \seqMsg, Pseq(seq, 1), + \dur, Pseq(sectionDurs, 1) + ); + ] + ); + res +}; + +/* +genMidiPatterns = {arg seq; + var voices, durs, patterns, res, mOut, pbRange; + pbRange = 1; //semitones - change this as needed for your situation + mOut = MIDIOut.newByName("TiMidity", "TiMidity port 0").latency_(Server.default.latency); + # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; + res = Ppar( + voices.flop.collect({arg voice, v; + var clumps, hdScores, freqs, fDurs; + + mOut.program(v, 70); + + clumps = voice.separate({arg a, b; a != b }); + freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); + fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); + + Pbind( + \type, \midi, + \chan, v, + \noteval, Pseq(freqs.cpsmidi - 24, 1), + \note, Pfunc({ | event | event[\noteval].floor }), + \dur, Pseq(fDurs, 1), + \midiout, mOut, + \amp, 1, + \bend, Pfunc({ + | event | + if (event[\note].isRest.not) { + var pitchbendvalue = event[\noteval].frac.linlin(0, pbRange, 8192, 8192*2).asInteger; + m.bend(v, pitchbendvalue); + }; + 0; // return something other than nil to avoid stopping the pattern + }), + ); + }); + ); + res +}; +*/ + + +//------resource management funcs + +genUID = {Date.seed.asHexString.toLower}; + +seedFunc = {arg func, seed; + var funcArgs, next; + next = Routine({loop{func.valueArray(funcArgs).yield }}); + next.randSeed_(seed); + {arg ...args; funcArgs = args; next.value} +}; + +stringifyToDepth = {arg data, maxDepth = 1; + var prettyString = "", rCount = 0, writeArray, indent; + + if(maxDepth == 0, { + data.asCompileString + }, { + indent = {arg size; size.collect({" "}).join("")}; + writeArray = {arg array; + prettyString = prettyString ++ indent.value(rCount) ++ "[\n"; + rCount = rCount + 1; + if(rCount < maxDepth, { + array.do({arg subArray; writeArray.value(subArray)}); + }, { + prettyString = prettyString ++ array.collect({arg subArray; + indent.value(rCount + 1) ++ subArray.asCompileString + }).join(",\n"); + }); + rCount = rCount - 1; + prettyString = prettyString ++ "\n" ++ indent.value(rCount) ++ "],\n"; + }; + + writeArray.value(data); + prettyString.replace(",\n\n", "\n").drop(-2); + }) +}; + +sanityCheck = {arg motif, index; + //print functions = very helpful + ("----------" + index + "------------").postln; + + motif.flatten.do({arg val, v; + if(v > 0, { + if(motif.flatten[v-1][0].hammingDistance(val[0]) > 1, {"problem 1".postln}); + if(motif.flatten[v-1][0].hammingDistance(val[0]) == 0, {"problem 2".postln}); + }); + val.postln + }); + "***********".postln; +}; + +msgInterpret = {arg in, escapeDoubleQuotes = true, escapeSingleQuotes = true; + var res; + + res = in; + if(res.isNil.not, { + if((res.isArray && res.isString.not), { + res = res.asCompileString; + res = res.replace(" ", "").replace("\n", "").replace("\t", ""); + if(escapeSingleQuotes, {res = res.replace("\'", "")}); + if(escapeDoubleQuotes, {res = res.replace("\"", "")}); + res = res.replace("Rest", "\"Rest\""); + res = res.interpret; + }, { + //res.postln; + if(res.every({arg char; char.isDecDigit}), {res = res.asInteger}); + }); + }); + res +}; + +writeResources = {arg path; + var file, nameSpaces, modelItems, resString; + file = File(path,"w"); + + nameSpaces = [ + "music_data", "last_changes", + "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", + "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", + "ranges", "passages_weights", "order", "sus_weights", "order_size", "passages_size" + ]; + + modelItems = [ + seq, lastXChanges, + curUID, refUID, orderSeed, durSeed, motifSeed, + entrancesProbVals, passagesProbVals, exitsProbVals, + ranges, passagesWeights, orders, susWeights, orderSize, passagesSize + ]; + + resString = [nameSpaces, modelItems].flop.collect({arg item; + var nameSpace, modelItem, depth = 0, insert = " "; + # nameSpace, modelItem = item; + if(nameSpace == "music_data", {depth = 3; insert = "\n"}); + if(nameSpace == "last_changes", {depth = 1; insert = "\n"}); + if(nameSpace == "order", {depth = 1; insert = "\n"}); + "\"" ++ nameSpace ++ "\":" ++ insert ++ stringifyToDepth.value(modelItem.postln, depth).postln + }).join(",\n"); + + resString = "{\n" ++ resString ++ "\n}"; + + file.write(resString); + file.close; + resString +}; + +loadModelFile = {arg path; loadModelJSON.value(File(path, "r").readAllString.parseJSON)}; + +loadModelJSON = {arg jsonObject; + var nameSpaces, data; + + //model = File(path, "r").readAllString.parseJSON; + + nameSpaces = [ + "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", + "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", + "ranges", "passages_weights", "order", "sus_weights", "order_size", "passages_size" + ]; + + data = nameSpaces.collect({arg nS; msgInterpret.value(jsonObject[nS]).postln}); + + data.postln; + + # curUID, refUID, orderSeed, durSeed, motifSeed, + entrancesProbVals, passagesProbVals, exitsProbVals, + ranges, passagesWeights, orders, susWeights, orderSize, passagesSize = data; + + popSize = ranges.size; +}; + +loadLedgerFile = {arg path; + ledgerPath = path; + loadLedgerJSON.value(File(ledgerPath, "r").readAllString.parseJSON) +}; + +loadLedgerJSON = {arg jsonObject; ledger = jsonObject["ledger"]}; + +//------global vars + +primes = [[2, 1], [3, 2], [5, 4], [7, 4], [11, 8], [13, 8]]; +//ranges = [[-2400, 0], [-1200, 1200], [0, 2400], [0, 2400]]; +exPath = thisProcess.nowExecutingPath; +dir = exPath.dirname; +//popSize = 4; +dims = primes.size; +tuples = genTuples.value(); +//refUID = nil; +group = Group.new; +loadLedgerFile.value(dir +/+ ".." +/+ "resources" +/+ "piece_ledger.json"); +//passagesWeights = [1, 1, 1, 1, 1]; +//susWeights = [1, 1, 1]; + + +//------OSC funcs + +OSCdef(\load_ledger, {arg msg, time, addr, port; + loadLedgerFile.value(msg[1].asString); +}, \load_ledger); + +OSCdef(\load_model, {arg msg, time, addr, port; + loadModelFile.value(msg[1].asString); +}, \load_model); + + +OSCdef(\generate, {arg msg, time, addr, port; + var path, dFormat, condition, musPath, modelString; + msg.postln; + + path = msg[1].asString; + + loadModelFile.value(path); + + refUID.postln; + + loadLedgerFile.value(ledgerPath); + if(ledger == nil, {ledger = ["tmp"]}); + if(ledger.last != "tmp", {ledger = ledger.add("tmp")}); + + lastXChanges = if(refUID == nil, { + [initVoices.value().deepCopy]; + }, { + var file; + refUID.postln; + file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); + msgInterpret.value(file.readAllString.parseJSON["last_changes"]); + }); + + entrancesDurFunc = genDurFunc.valueArray(entrancesProbVals[..2] ++ [entrancesProbVals[3..]]); + passagesDurFunc = genDurFunc.valueArray(passagesProbVals[..2] ++ [passagesProbVals[3..]]); + exitsDurFunc = genDurFunc.valueArray(exitsProbVals[..2] ++ [exitsProbVals[3..]]); + + if(orders == nil, { + orders = seedFunc.value(genOrders, orderSeed).valueArray(orderSize ++ passagesSize); + //addr.sendMsg("/order", stringifyToDepth.value(orders, 1)); + }); + seq = seedFunc.value(genMotif, motifSeed).value; + + modelString = writeResources.value(path); + + //addr.sendMsg("/generated", musPath, stringifyToDepth.value(seq, 3)); + addr.sendMsg("/generated", path, modelString); +}, \generate); + + +OSCdef(\commit, {arg msg, time, addr, port; + var newLedger, modelPath, musString, musFile, test1, test2; + msg.postln; + + /* + test1 = msg[1].asString.parseJSON; + test2 = (dir +/+ ".." +/+ "resources/tmp/tmp_music" ++ ".json").standardizePath.parseJSONFile; + msgInterpret.value(test1["music"])[0][0][0][1].class.postln; + msgInterpret.value(test2["music_data"])[0][0][0][1].class.postln; + (test1["music"] == test2["music_data"]).postln; + */ + + curUID = genUID.value; + File.mkdir((dir +/+ ".." +/+ "resources" +/+ curUID).standardizePath); + File.copy(exPath, (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_code" ++ ".scd").standardizePath); + + modelPath = (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_mus_model" ++ ".json").standardizePath; + writeResources.value(modelPath); + + File.delete(ledgerPath.postln ++ "_bak"); + File.copy(ledgerPath, ledgerPath ++ "_bak"); + File.delete(ledgerPath); + newLedger = File(ledgerPath.postln, "w"); + ledger = ledger.postln.drop(-1).add(curUID); + newLedger.write("{\n\"ledger\":\n" ++ stringifyToDepth.value(ledger, 1) ++ "\n}"); + newLedger.close; + + addr.sendMsg("/committed", curUID, ledgerPath); + //refUID = curUID; +}, \commit); + +OSCdef(\transport, {arg msg, time, addr, port; + msg.postln; + if(msg[1] == 0, { + player.stop; + group.set(\gate, 0); + }, { + // the cued sequence can now be read from file, so this can be cleaned up + var cSize, patterns, pSeq, cuedSeek, indexStart, indexEnd, tmpLedger; + pSeq = []; + cuedSeek = (seq != nil); + indexStart = msg[2].asInteger; + indexEnd = ledger.size - if(cuedSeek, {2}, {1}); + ledger.postln; + if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { + ledger[indexStart..indexEnd].do({arg uid, index; + var file; + (indexStart + index).postln; + file = File((dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath, "r"); + pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), indexStart + index, uid]); + file.close; + }); + }); + if(cuedSeek, {pSeq = pSeq.add([seq, ledger.size - 1])}); + patterns = genPatterns.value(pSeq, addr); + player = Pfset(pattern: patterns, cleanupFunc: { + addr.sendMsg("/transport", 0); + }); + player = player.play + }); +}, \transport); + +) + +( +SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; + var trig, exc, sig1, sig2, noHarms; + noHarms = 30; + exc = Saw.ar(freq, TRand.ar(0.5, 1, Impulse.ar(freq))) * 0.001 + Dust.ar(10000, 0.01); + sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), + Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), + Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.5).softclip; + sig1 = HPF.ar(sig1, 300); + Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); +}).add; +) + +( +SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; + var trig, exc, sig1, sig2, noHarms, freqFinal, start, end; + noHarms = 30; + freq = WhiteNoise.ar * 3 + freq; + freqFinal = Duty.ar((1/freq), 0, freq); + trig = Changed.ar(freqFinal); + start = Demand.ar(trig, 0, Dwhite(-1, -0.75)); + end = Demand.ar(trig, 0, Dwhite(0.75, 1)); + exc = Phasor.ar(trig, (end - start) * freqFinal / SampleRate.ir, start, end, 0) * 0.001 + Dust.ar(10000, 0.01); + + sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), + Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), + Array.fill(noHarms, {rrand(2, 3)}) ], exc) * 0.5).softclip; + sig1 = HPF.ar(sig1, 300); + Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); +}).add; +) + + + +"{\"a\": 1}".parseYAML["a"].asInteger; +"{\"a\": 1}".parseJSON["a"].isNumber; + +1223423434123.asHexString.toLower + +Date.getDate.rawSeconds +Date.seed.asHexString.toLower + +n = NetAddr("localhost", 8080); +n.sendMsg("/GET/#", (NetAddr.localAddr.hostname ++ ":" ++ NetAddr.localAddr.port), "/passage_probs_vals"); \ No newline at end of file diff --git a/resources/piece_ledger_transcribe_test/640eeed3/640eeed3_mus_model.json b/resources/piece_ledger_transcribe_test/640eeed3/640eeed3_mus_model.json new file mode 100644 index 0000000..79d175f --- /dev/null +++ b/resources/piece_ledger_transcribe_test/640eeed3/640eeed3_mus_model.json @@ -0,0 +1,38 @@ +{ +"music_data": +[ + [ + [ + [ [ [ "Rest" ], [ 1, 0, 0, -1, -1, 0 ], [ "Rest" ], [ "Rest" ] ], 3.125 ], + [ [ [ "Rest" ], [ 1, 0, 0, -1, -1, 0 ], [ "Rest" ], [ 2, 0, 0, -2, -1, 0 ] ], 2.25 ], + [ [ [ "Rest" ], [ 1, 0, 0, -1, -1, 0 ], [ "Rest" ], [ "Rest" ] ], 2.625 ], + [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 2 ] + ] + ] +], +"last_changes": +[ + [ [ 0, 1, 0, 0, 0, 0 ], [ 0, 0, -1, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ] ], + [ [ 0, 1, 0, 0, 0, 0 ], [ -1, 1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ] ], + [ [ 0, 1, 0, 0, 0, 0 ], [ 1, -1, 0, -1, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ] ], + [ [ 0, 1, 0, 0, 0, 0 ], [ 1, 0, 0, -1, -1, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ] ], + [ [ 0, 1, 0, 0, 0, 0 ], [ 1, 0, 0, -1, -1, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 2, 0, 0, -2, -1, 0 ] ] +], +"cur_uid": "640eeed3", +"ref_uid": "4c01589b", +"order_seed": 155513, +"dur_seed": 460216, +"motifs_seed": 397643, +"entrances_probs_vals": [ 0.75, 0.5, 2, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], +"passages_probs_vals": [ 0, 1.87, 3.7996946564886, 0, 0.5, 0.5, 0.5, 1, 0.5 ], +"exits_probs_vals": [ 0.75, 0.5, 2, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], +"ranges": [ [ -384, 2400 ], [ -507, 2400 ], [ -282, 2237 ], [ -1200, 2053 ] ], +"passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], +"order": +[ + [ [ 1 ], [ 3 ], [ 0, 2 ] ] +], +"sus_weights": [ 1, 0, 0 ], +"order_size": [ 1, 3 ], +"passages_size": [ 0, 2 ] +} \ No newline at end of file diff --git a/resources/674b56e3/674b56e3_code.scd b/resources/piece_ledger_transcribe_test/674b56e3/674b56e3_code.scd similarity index 100% rename from resources/674b56e3/674b56e3_code.scd rename to resources/piece_ledger_transcribe_test/674b56e3/674b56e3_code.scd diff --git a/resources/674b56e3/674b56e3_mus_model.json b/resources/piece_ledger_transcribe_test/674b56e3/674b56e3_mus_model.json similarity index 100% rename from resources/674b56e3/674b56e3_mus_model.json rename to resources/piece_ledger_transcribe_test/674b56e3/674b56e3_mus_model.json diff --git a/resources/688ee3e1/688ee3e1_code.scd b/resources/piece_ledger_transcribe_test/688ee3e1/688ee3e1_code.scd similarity index 100% rename from resources/688ee3e1/688ee3e1_code.scd rename to resources/piece_ledger_transcribe_test/688ee3e1/688ee3e1_code.scd diff --git a/resources/688ee3e1/688ee3e1_mus_model.json b/resources/piece_ledger_transcribe_test/688ee3e1/688ee3e1_mus_model.json similarity index 100% rename from resources/688ee3e1/688ee3e1_mus_model.json rename to resources/piece_ledger_transcribe_test/688ee3e1/688ee3e1_mus_model.json diff --git a/resources/75638b4d/75638b4d_code.scd b/resources/piece_ledger_transcribe_test/75638b4d/75638b4d_code.scd similarity index 100% rename from resources/75638b4d/75638b4d_code.scd rename to resources/piece_ledger_transcribe_test/75638b4d/75638b4d_code.scd diff --git a/resources/75638b4d/75638b4d_mus_model.json b/resources/piece_ledger_transcribe_test/75638b4d/75638b4d_mus_model.json similarity index 100% rename from resources/75638b4d/75638b4d_mus_model.json rename to resources/piece_ledger_transcribe_test/75638b4d/75638b4d_mus_model.json diff --git a/resources/piece_ledger_transcribe_test/7ac10d34/7ac10d34_code.scd b/resources/piece_ledger_transcribe_test/7ac10d34/7ac10d34_code.scd new file mode 100644 index 0000000..65c17df --- /dev/null +++ b/resources/piece_ledger_transcribe_test/7ac10d34/7ac10d34_code.scd @@ -0,0 +1,719 @@ +( +// helper funcs +var hsArrayToCents, pDist, hdSum, hsChordalDistance, hsArrayToFreq; + +// score funcs +var isInRange, spacingScore, rangeScore, intervalScore, inclusionScore; + +// subroutines +var genTuples, initVoices, genOrders, genSubMotif, updateVoices, genDurFunc; + +// primary routines +var genMotif, genSecondarySeq; + +// audition funcs +var genPatterns, genMidiPatterns; + +// resource management funcs +var seedFunc, genUID, writeResources, stringifyToDepth, setSeeds, sanityCheck, +msgInterpret, loadLedgerFile, loadLedgerJSON, loadModelFile, loadModelJSON; + +// model vars +//(model and global vars mostly set by OSC funcs +var curUID, refUID, orderSeed, durSeed, motifSeed, +entrancesProbVals, passagesProbVals, exitsProbVals, +ranges, orders, susWeights, passagesWeights, passagesSize, orderSize; + +// model aux vars +var entrancesDurFunc, passagesDurFunc, exitsDurFunc; + +// other global vars +var lastXChanges, popSize, exPath, dir, primes, dims, tuples, +seq, group, player, ledgerPath, ledger, currentlyPlayingUID; + + +// install JSON quark +if(Quarks.isInstalled("JSONlib").not, { + Quarks.install("https://github.com/musikinformatik/JSONlib.git"); + thisProcess.recompile; + //HelpBrowser.openHelpFor("Classes/JSONlib"); +}); + + +//------helper funcs + +hsArrayToCents = { + arg hsArray; + hsArray.collect({arg dist, p; dist * 1200 * log2(primes[p][0]/primes[p][1])}).sum +}; + +pDist = { + arg array1, array2, signed = false; + var pDistance; + pDistance = hsArrayToCents.value(array1) - hsArrayToCents.value(array2); + if(signed, {pDistance}, {abs(pDistance)}) +}; + +hdSum = { + arg hsArrays; + var size, distances, mean; + size = hsArrays.size; + distances = (size - 1).collect({arg i; + ((i + 1)..(size - 1)).collect({arg j; + abs(hsArrays[i] - hsArrays[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum + }); + }).flat; + mean = distances.sum / distances.size; + distances.sum + //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) +}; + +hsChordalDistance = { + arg hsArrays1, hsArrays2; + var size, distances, mean; + size = hsArrays1.size; + distances = hsArrays1.size.collect({arg i; + hsArrays2.size.collect({arg j; + abs(hsArrays1[i] - hsArrays2[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum + }); + }).flat; + mean = distances.sum / distances.size; + distances.sum + //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) +}; + +hsArrayToFreq = { + arg array; + array.collect({arg dim, d; pow(primes[d][0]/primes[d][1], dim)}).product +}; + +//------score funcs + +/* +isInRange = { + arg hsArray, min, max; + var cents; + cents = hsArrayToCents.value(hsArray); + (cents >= min) && (cents <= max) +}; +*/ + +spacingScore = { + arg hsArrays, min; + var centsArray; + centsArray = hsArrays.collect({arg hsArray; hsArrayToCents.value(hsArray)}).sort({arg a, b; a < b}); + centsArray.differentiate.drop(1).collect({arg pDistance; if(pDistance >= min, {1}, {0.01})}).sum; +}; + +rangeScore = { + arg hsArray1, hsArray2, min, max, low, signed = false; + var pDistance; + pDistance = pDist.value(hsArray1, hsArray2, signed); + if((pDistance >= min) && (pDistance <= max), {1}, {low}); +}; + +intervalScore = { + arg hsArray1, hsArray2, mean, sd, signed = false; + var pDistance; + pDistance = pDist.value(hsArray1, hsArray2, signed); + pDistance.gaussCurve(1, mean, sd) +}; + +inclusionScore = { + arg array, test, min = 0.01; + if(array.collect({arg v; v.hash}).includes(test.hash), {min}, {1}); +}; + + +//------subroutines + +genTuples = { + var tuples; + tuples = dims.collect({[-1, 0, 1]}).allTuples.select({arg tuple; (abs(tuple.drop(1)).sum <= 1) && (tuple[0] == 0)}); + tuples = tuples ++ tuples.collect({arg tuple; [-3, -2, -1, 1, 2, 3].collect({arg octTrans; tuple.deepCopy.put(0, octTrans)})}).flatten; +}; + +initVoices = { + var init, voicesInit; + voicesInit = popSize.collect({dims.collect({0})}); + /* + voicesInit = [dims.collect({0})]; + (popSize - 1).do({ + arg rep, new; + rep = dims.rand; + new = voicesInit.last.deepCopy; + new[rep] = new[rep] + [-1, 1].choose(); + voicesInit = voicesInit.add(new); + }); + */ + voicesInit.deepCopy; +}; + +genDurFunc = {arg chordProb, min, max, envData; + var env, pTable, durFunc; + env = Env.pairs([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).asSignal(256).asList.asArray; + pTable = env.asRandomTable; + durFunc = {arg allowChord; + var res; + res = if(allowChord.not, { + pTable.tableRand * (max - min) + min + }, { + if(1.0.rand < chordProb, {0}, {pTable.tableRand * (max - min) + min}); + }).round(0.125); + if(res.asInteger == res, {res = res.asInteger}); + res + }; + seedFunc.value(durFunc, durSeed); +}; + +genOrders = {arg minMotifLength = 1, maxMotifLength = 5, minProgLength = 0, maxProgLength = 5; + ((maxMotifLength - minMotifLength).rand + minMotifLength).collect({ + var noProgIns, noSusIns, noSilentIns, prog, sus, silent, order; + noSusIns = [1, 2, 3].wchoose(susWeights.normalizeSum); + noProgIns = (popSize - noSusIns).rand + 1; + noSilentIns = popSize - noSusIns - noProgIns; + + # prog, sus, silent = (0..(popSize-1)).scramble.clumps([noProgIns, noSusIns, noSilentIns]); + + prog = (prog.scramble ++ ((maxProgLength - minProgLength).rand + minProgLength).collect({prog.choose}).scramble); + if(silent == nil, {silent = []}); + [sus.scramble, prog, silent.scramble] + }); +}; + +updateVoices = {arg ins, sus; + var voices, candidates, nWeights, nProbs, sel; + + voices = lastXChanges.deepCopy.last; + + candidates = sus.collect({arg v; tuples.collect({arg t; voices[v] + t})}).flatten; + candidates = difference(candidates.asSet, voices.asSet).asList; + nProbs = candidates.collect({arg candidate; + var stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore; + + //stepScore = intervalScore.value(voices[ins], candidate, 30, 400, 0.1); + stepScore = intervalScore.value(voices[ins], candidate, 100, 100); + recentlySoundedScore = inclusionScore.value(lastXChanges.flop[ins], candidate, 0); + isInRangeScore = rangeScore.value(candidate, candidate.collect({0}), ranges[ins][0], ranges[ins][1], 0, true); + regScore = spacingScore.value(voices.deepCopy.put(ins, candidate), 300); + hdScore = 1/pow(hdSum.value(voices.deepCopy.put(ins, candidate)), 2); + //maybe what you want here is a vector to another root and then favoring movement towards it. + //distScore = pow(hsChordalDistance.value(voices, voices.put(ins, candidate)), 2); + + [stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore] + }); + + nWeights = passagesWeights; + + //this handles nWeights of 0; mainly for testing + nProbs = nProbs.flop.select({arg scores, s; nWeights[s] != 0}).flop; + nWeights = nWeights.select({arg weight; weight != 0}); + nProbs = nProbs.flop.collect({arg scores, s; + if(scores.sum == 0, {scores}, {scores.normalizeSum * nWeights[s]}) + }); + nProbs = nProbs.flop.collect({arg scores, s; scores.product}).normalizeSum; + + sel = candidates.wchoose(nProbs); + + voices[ins] = sel; + lastXChanges = lastXChanges.add(voices).keep(-5); +}; + +genSubMotif = {arg order, lastState, repeatLast = false, startFromLast = false, isLastOrder = false; + var sus, prog, silent, flatOrder, res, isInChord, allowChord, lastXChangesHold, voices, adder; + # sus, prog, silent = order; + flatOrder = silent ++ sus ++ prog; + lastXChangesHold = lastXChanges.deepCopy; + voices = lastState.deepCopy; + isInChord = popSize.collect({false}); + allowChord = false; + res = []; + "------generating motif".postln; + //need to figure out here if voices move between motifs + flatOrder.do({arg ins, i; + + if(prog.includes(ins) && repeatLast.not, {updateVoices.value(ins, sus)}); + adder = if(silent.includes(ins), {["Rest"]}, {lastXChanges.last.deepCopy[ins]}); + + if(voices[ins] != adder, { + var dur; + allowChord = if((sus ++ silent).includes(ins), { + (sus ++ silent).includes(ins) && (ins != sus.last); + }, { + if(i < (flatOrder.size - 1), {(isInChord[flatOrder[i + 1]] || (ins == flatOrder[i + 1])).not}, {false}); + }); + dur = passagesDurFunc.value(allowChord); + if(dur == 0, {isInChord[ins] = true}, {isInChord = popSize.collect({false})}); + + voices[ins] = adder; + res = res.add([voices.deepCopy.postln, dur]); + }); + }); + + // pad ending + if(isLastOrder, { + (0..(popSize-1)).scramble.do({arg ins; + if(res.last.first[ins] != ["Rest"], { + var dur; + voices[ins] = ["Rest"]; + allowChord = (voices != popSize.collect({["Rest"]})); + dur = passagesDurFunc.value(allowChord); + res = res.add([voices.deepCopy.postln, dur]); + }); + }); + }); + + //format and return + if(startFromLast, {lastXChanges = lastXChangesHold}); + res; +}; + + +//------primary routines + +genMotif = { + var repeats, fSeq; + + repeats = 1; + fSeq = []; + + repeats.do({arg index; + var motif; + + motif = []; + + orders.do({arg order, o; + var lastState, subMotif; + lastState = if(o == 0, {popSize.collect({["Rest"]})}, {motif.last.last.first}); + subMotif = genSubMotif.value(order, lastState, isLastOrder: o == (orders.size - 1)); + motif = motif.add(subMotif); + + }); + + sanityCheck.value(motif, index); + + fSeq = fSeq.add(motif); + }); + fSeq +}; + +genSecondarySeq = {arg seq; + var curdles, fSeq; + curdles = []; + while({curdles.sum < seq.size}, {curdles = curdles ++ [3.rand + 1]}); + + fSeq = seq.clumps(curdles).collect({arg clump, m; + var repeats, paddedSeq; + + //add rest + paddedSeq = clump.add([[[popSize.collect({["Rest"]}), 0.5.rand]]]); + + //implement repeats + repeats = [0.rand + 1, 1].wchoose([1, 0].normalizeSum); + repeats.collect({paddedSeq}); + }); + fSeq +}; + + +//------audition funcs + +Event.addEventType(\osc, { + if (~addr.postln.notNil) { + ~addr.sendMsg(~indexPath, ~indexMsg); + ~addr.sendMsg(~seqPath, stringifyToDepth.value(~seqMsg, 3)); + //~addr.sendMsg("/STATE/OPEN", (dir.replace("supercollider", "resources") +/+ ~idMsg +/+ ~idMsg ++ "_gui_state" ++ ".state").standardizePath.postln); + }; +}); + +genPatterns = {arg inSeq, addr; + var voices, durs, patterns, res, indices, sectionDurs, ids, seq; + seq = inSeq.collect({arg mSeq; mSeq[0]}); + # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; + indices = inSeq.collect({arg mSeq, m; mSeq[1]}); + ids = inSeq.collect({arg mSeq, m; mSeq[2]}); + sectionDurs = seq.collect({arg mSeq; mSeq.flatten2(mSeq.maxDepth - 5).flop[1].sum}); + res = Ppar( + voices.flop.collect({arg voice; + var clumps, hdScores, freqs, fDurs; + clumps = voice.separate({arg a, b; a != b }); + freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); + fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); + + Pbind( + \instrument, \test, + \group, group, + \freq, Pseq(freqs, 1), + \dur, Pseq(fDurs, 1), + \sustain, Pseq(fDurs, 1) + ) + }) ++ + [ + Pbind( + \type, \osc, + \addr, addr, + \indexPath, "/cur_play_index", + \indexMsg, Pseq(indices.postln, 1), + \seqPath, "/mus_seq", + \seqMsg, Pseq(seq, 1), + \dur, Pseq(sectionDurs, 1) + ); + ] + ); + res +}; + +/* +genMidiPatterns = {arg seq; + var voices, durs, patterns, res, mOut, pbRange; + pbRange = 1; //semitones - change this as needed for your situation + mOut = MIDIOut.newByName("TiMidity", "TiMidity port 0").latency_(Server.default.latency); + # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; + res = Ppar( + voices.flop.collect({arg voice, v; + var clumps, hdScores, freqs, fDurs; + + mOut.program(v, 70); + + clumps = voice.separate({arg a, b; a != b }); + freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); + fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); + + Pbind( + \type, \midi, + \chan, v, + \noteval, Pseq(freqs.cpsmidi - 24, 1), + \note, Pfunc({ | event | event[\noteval].floor }), + \dur, Pseq(fDurs, 1), + \midiout, mOut, + \amp, 1, + \bend, Pfunc({ + | event | + if (event[\note].isRest.not) { + var pitchbendvalue = event[\noteval].frac.linlin(0, pbRange, 8192, 8192*2).asInteger; + m.bend(v, pitchbendvalue); + }; + 0; // return something other than nil to avoid stopping the pattern + }), + ); + }); + ); + res +}; +*/ + + +//------resource management funcs + +genUID = {Date.seed.asHexString.toLower}; + +seedFunc = {arg func, seed; + var funcArgs, next; + next = Routine({loop{func.valueArray(funcArgs).yield }}); + next.randSeed_(seed); + {arg ...args; funcArgs = args; next.value} +}; + +stringifyToDepth = {arg data, maxDepth = 1; + var prettyString = "", rCount = 0, writeArray, indent; + + if(maxDepth == 0, { + data.asCompileString + }, { + indent = {arg size; size.collect({" "}).join("")}; + writeArray = {arg array; + prettyString = prettyString ++ indent.value(rCount) ++ "[\n"; + rCount = rCount + 1; + if(rCount < (maxDepth - 0), { + array.do({arg subArray; writeArray.value(subArray)}); + }, { + prettyString = prettyString ++ array.collect({arg subArray; + indent.value(rCount + 1) ++ subArray.asCompileString + }).join(",\n"); + }); + rCount = rCount - 1; + prettyString = prettyString ++ "\n" ++ indent.value(rCount) ++ "],\n"; + }; + + writeArray.value(data); + prettyString.replace(",\n\n", "\n").drop(-2); + }) +}; + +sanityCheck = {arg motif, index; + //print functions = very helpful + ("----------" + index + "------------").postln; + + motif.flatten.do({arg val, v; + if(v > 0, { + if(motif.flatten[v-1][0].hammingDistance(val[0]) > 1, {"problem 1".postln}); + if(motif.flatten[v-1][0].hammingDistance(val[0]) == 0, {"problem 2".postln}); + }); + val.postln + }); + "***********".postln; +}; + +msgInterpret = {arg in, escapeDoubleQuotes = true, escapeSingleQuotes = true; + var res; + + res = in; + if(res.isNil.not, { + if((res.isArray && res.isString.not), { + res = res.asCompileString; + res = res.replace(" ", "").replace("\n", "").replace("\t", ""); + if(escapeSingleQuotes, {res = res.replace("\'", "")}); + if(escapeDoubleQuotes, {res = res.replace("\"", "")}); + res = res.replace("Rest", "\"Rest\""); + res = res.interpret; + }, { + //res.postln; + if(res.every({arg char; char.isDecDigit}), {res = res.asInteger}); + }); + }); + res +}; + +writeResources = {arg path; + var file, nameSpaces, modelItems, resString; + file = File(path,"w"); + + nameSpaces = [ + "music_data", "last_changes", + "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", + "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", + "ranges", "passages_weights", "order", "sus_weights", "order_size", "passages_size" + ]; + + modelItems = [ + seq, lastXChanges, + curUID, refUID, orderSeed, durSeed, motifSeed, + entrancesProbVals, passagesProbVals, exitsProbVals, + ranges, passagesWeights, orders, susWeights, orderSize, passagesSize + ]; + + resString = [nameSpaces, modelItems].flop.collect({arg item; + var nameSpace, modelItem, depth = 0, insert = " "; + # nameSpace, modelItem = item; + if(nameSpace == "music_data", {depth = 3; insert = "\n"}); + if(nameSpace == "last_changes", {depth = 1; insert = "\n"}); + if(nameSpace == "order", {depth = 1; insert = "\n"}); + "\"" ++ nameSpace ++ "\":" ++ insert ++ stringifyToDepth.value(modelItem.postln, depth).postln + }).join(",\n"); + + resString = "{\n" ++ resString ++ "\n}"; + + file.write(resString); + file.close; +}; + +loadModelFile = {arg path; loadModelJSON.value(File(path, "r").readAllString.parseJSON)}; + +loadModelJSON = {arg model; + var nameSpaces, data; + + //model = File(path, "r").readAllString.parseJSON; + + nameSpaces = [ + "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", + "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", + "ranges", "passages_weights", "order", "sus_weights", "order_size", "passages_size" + ]; + + data = nameSpaces.collect({arg nS; msgInterpret.value(model[nS]).postln}); + + data.postln; + + # curUID, refUID, orderSeed, durSeed, motifSeed, + entrancesProbVals, passagesProbVals, exitsProbVals, + ranges, passagesWeights, orders, susWeights, orderSize, passagesSize = data; + + popSize = ranges.size; +}; + +loadLedgerFile = {arg path; + ledgerPath = path; + loadLedgerJSON.value(File(ledgerPath, "r").readAllString.parseJSON) +}; + +loadLedgerJSON = {arg ledger; ledger = ledger["ledger"]}; + +//------global vars + +primes = [[2, 1], [3, 2], [5, 4], [7, 4], [11, 8], [13, 8]]; +//ranges = [[-2400, 0], [-1200, 1200], [0, 2400], [0, 2400]]; +exPath = thisProcess.nowExecutingPath; +dir = exPath.dirname; +//popSize = 4; +dims = primes.size; +tuples = genTuples.value(); +//refUID = nil; +group = Group.new; +loadLedgerFile.value(dir +/+ ".." +/+ "resources" +/+ "piece_ledger.json"); +//passagesWeights = [1, 1, 1, 1, 1]; +//susWeights = [1, 1, 1]; + + +//------OSC funcs + +OSCdef(\load_ledger, {arg msg, time, addr, port; + loadLedgerFile.value(msg[1].asString); +}, \load_ledger); + +OSCdef(\load_model, {arg msg, time, addr, port; + loadModelFile.value(msg[1].asString); +}, \load_model); + + +OSCdef(\generate, {arg msg, time, addr, port; + var path, dFormat, condition, musPath; + msg.postln; + + path = msg[1].asString; + + loadModelFile.value(path); + + refUID.postln; + + loadLedgerFile.value(ledgerPath); + if(ledger == nil, {ledger = ["tmp"]}); + if(ledger.last != "tmp", {ledger = ledger.add("tmp")}); + + lastXChanges = if(refUID == nil, { + [initVoices.value().deepCopy]; + }, { + var file; + refUID.postln; + file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); + msgInterpret.value(file.readAllString.parseJSON["last_changes"]); + }); + + entrancesDurFunc = genDurFunc.valueArray(entrancesProbVals[..2] ++ [entrancesProbVals[3..]]); + passagesDurFunc = genDurFunc.valueArray(passagesProbVals[..2] ++ [passagesProbVals[3..]]); + exitsDurFunc = genDurFunc.valueArray(exitsProbVals[..2] ++ [exitsProbVals[3..]]); + + if(orders == nil, { + orders = seedFunc.value(genOrders, orderSeed).valueArray(orderSize ++ passagesSize); + addr.sendMsg("/order", stringifyToDepth.value(orders, 1)); + }); + seq = seedFunc.value(genMotif, motifSeed).value; + + //musPath = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; + writeResources.value(path); + + //orders = nil; + //addr.sendMsg("/current_uid", curUID); + //addr.sendMsg("/ledger", prettifyArray.value(ledger, 1).replace("\"", "")); + //addr.sendMsg("/ledger_size", ledger.size); + //addr.sendMsg("/mus_seq", prettifyArray.value(seq, 3)); + addr.sendMsg("/generated", musPath, stringifyToDepth.value(seq, 3)); +}, \generate); + + +OSCdef(\commit, {arg msg, time, addr, port; + var newLedger, modelPath, musString, musFile, test1, test2; + msg.postln; + + /* + test1 = msg[1].asString.parseJSON; + test2 = (dir +/+ ".." +/+ "resources/tmp/tmp_music" ++ ".json").standardizePath.parseJSONFile; + msgInterpret.value(test1["music"])[0][0][0][1].class.postln; + msgInterpret.value(test2["music_data"])[0][0][0][1].class.postln; + (test1["music"] == test2["music_data"]).postln; + */ + + curUID = genUID.value; + File.mkdir((dir +/+ ".." +/+ "resources" +/+ curUID).standardizePath); + File.copy(exPath, (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_code" ++ ".scd").standardizePath); + + modelPath = (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_mus_model" ++ ".json").standardizePath; + writeResources.value(modelPath); + + File.delete(ledgerPath.postln ++ "_bak"); + File.copy(ledgerPath, ledgerPath ++ "_bak"); + File.delete(ledgerPath); + newLedger = File(ledgerPath.postln, "w"); + ledger = ledger.postln.drop(-1).add(curUID); + newLedger.write("{\n\"ledger\":\n" ++ stringifyToDepth.value(ledger, 1) ++ "\n}"); + newLedger.close; + + addr.sendMsg("/committed", curUID, ledgerPath); + //refUID = curUID; +}, \commit); + +OSCdef(\transport, {arg msg, time, addr, port; + msg.postln; + if(msg[1] == 0, { + player.stop; + group.set(\gate, 0); + }, { + // the cued sequence can now be read from file, so this can be cleaned up + var cSize, patterns, pSeq, cuedSeek, indexStart, indexEnd, tmpLedger; + pSeq = []; + cuedSeek = (seq != nil); + indexStart = msg[2].asInteger; + indexEnd = ledger.size - if(cuedSeek, {2}, {1}); + if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { + ledger[indexStart..indexEnd].do({arg uid, index; + var file; + (indexStart + index).postln; + file = File((dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_music" ++ ".json").standardizePath, "r"); + pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), indexStart + index, uid]); + file.close; + }); + }); + if(cuedSeek, {pSeq = pSeq.add([seq, ledger.size - 1])}); + patterns = genPatterns.value(pSeq, addr); + player = Pfset(pattern: patterns, cleanupFunc: { + addr.sendMsg("/transport", 0); + }); + player = player.play + }); +}, \transport); + +) + +( +SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; + var trig, exc, sig1, sig2, noHarms; + noHarms = 30; + exc = Saw.ar(freq, TRand.ar(0.5, 1, Impulse.ar(freq))) * 0.001 + Dust.ar(10000, 0.01); + sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), + Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), + Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.5).softclip; + sig1 = HPF.ar(sig1, 300); + Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); +}).add; +) + +( +SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; + var trig, exc, sig1, sig2, noHarms, freqFinal, start, end; + noHarms = 30; + freq = WhiteNoise.ar * 3 + freq; + freqFinal = Duty.ar((1/freq), 0, freq); + trig = Changed.ar(freqFinal); + start = Demand.ar(trig, 0, Dwhite(-1, -0.75)); + end = Demand.ar(trig, 0, Dwhite(0.75, 1)); + exc = Phasor.ar(trig, (end - start) * freqFinal / SampleRate.ir, start, end, 0) * 0.001 + Dust.ar(10000, 0.01); + + sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), + Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), + Array.fill(noHarms, {rrand(2, 3)}) ], exc) * 0.5).softclip; + sig1 = HPF.ar(sig1, 300); + Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); +}).add; +) + + + +"{\"a\": 1}".parseYAML["a"].asInteger; +"{\"a\": 1}".parseJSON["a"].isNumber; + +1223423434123.asHexString.toLower + +Date.getDate.rawSeconds +Date.seed.asHexString.toLower + +n = NetAddr("localhost", 8080); +n.sendMsg("/GET/#", (NetAddr.localAddr.hostname ++ ":" ++ NetAddr.localAddr.port), "/passage_probs_vals"); \ No newline at end of file diff --git a/resources/piece_ledger_transcribe_test/7ac10d34/7ac10d34_gui_state.json b/resources/piece_ledger_transcribe_test/7ac10d34/7ac10d34_gui_state.json new file mode 100644 index 0000000..84e6edd --- /dev/null +++ b/resources/piece_ledger_transcribe_test/7ac10d34/7ac10d34_gui_state.json @@ -0,0 +1,1359 @@ +{ + "motif_label": "motif", + "seeds_label": "seeds", + "order": "[\n [ [ 3, 1, 0 ], [ 2 ], [ ] ],\n [ [ 1, 2 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 3 ] ],\n [ [ 3, 2 ], [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ], [ 0 ] ],\n [ [ 2, 3 ], [ 0, 1, 0 ], [ ] ]\n]", + "order_lock": 1, + "order_size": [ + 3, + 8 + ], + "order_size_v2": 8, + "order_size_v1": 3, + "order_size_panel": -1, + "passage_size_v2": 8, + "passage_size_v1": 2, + "passage_size_panel": -1, + "sus_weights": [ + null, + null, + null + ], + "range_matrix": [ + null, + null, + null, + null + ], + "instrumentation": [ + 0, + 0 + ], + "entrances_probs_sync": "passages", + "entrances": -1, + "passages_probs_sync": "passages", + "passages": -1, + "exits_probs_sync": "passages", + "exits": -1, + "dur_panel": 0, + "durations": -1, + "passages_weights": [ + null, + null, + null, + null, + null + ], + "weights": -1, + "seeds_tab_panel": 0, + "weights_seed_lock": 0, + "weights_seed": 534103, + "sus_weights/0_slider_val": 0.21, + "sus_weights/0_slider_slider": 0.21, + "sus_weights/0_slider_input": 0.21, + "sus_weights/0_slider_label": 1, + "sus_weights/0_slider": -1, + "sus_weights/1_slider_val": 0.35, + "sus_weights/1_slider_slider": 0.35, + "sus_weights/1_slider_input": 0.35, + "sus_weights/1_slider_label": 2, + "sus_weights/1_slider": -1, + "sus_weights/2_slider_val": 0.21, + "sus_weights/2_slider_slider": 0.21, + "sus_weights/2_slider_input": 0.21, + "sus_weights/2_slider_label": 3, + "sus_weights/2_slider": -1, + "passages_weights/0_slider_val": 0.49, + "passages_weights/0_slider_slider": 0.49, + "passages_weights/0_slider_input": 0.49, + "passages_weights/0_slider_label": "step", + "passages_weights/0_slider": -1, + "passages_weights/1_slider_val": 0.53, + "passages_weights/1_slider_slider": 0.53, + "passages_weights/1_slider_input": 0.53, + "passages_weights/1_slider_label": "dc", + "passages_weights/1_slider": -1, + "passages_weights/2_slider_val": 0.35, + "passages_weights/2_slider_slider": 0.35, + "passages_weights/2_slider_input": 0.35, + "passages_weights/2_slider_label": "range", + "passages_weights/2_slider": -1, + "passages_weights/3_slider_val": 0.59, + "passages_weights/3_slider_slider": 0.59, + "passages_weights/3_slider_input": 0.59, + "passages_weights/3_slider_label": "registration", + "passages_weights/3_slider": -1, + "passages_weights/4_slider_val": 0.39, + "passages_weights/4_slider_slider": 0.39, + "passages_weights/4_slider_input": 0.39, + "passages_weights/4_slider_label": "hd", + "passages_weights/4_slider": -1, + "range_matrix/0_val_input_min": -853.2067988668555, + "range_matrix/0_val_rslider": [ + -853.2067988668555, + 401 + ], + "range_matrix/0_val_input_max": 401, + "range_matrix/0_val": -1, + "range_matrix/1_val_input_min": -659, + "range_matrix/1_val_rslider": [ + -659, + 880 + ], + "range_matrix/1_val_input_max": 880, + "range_matrix/1_val": -1, + "range_matrix/2_val_input_min": -241, + "range_matrix/2_val_rslider": [ + -241, + 1869 + ], + "range_matrix/2_val_input_max": 1869, + "range_matrix/2_val": -1, + "range_matrix/3_val_input_min": -27, + "range_matrix/3_val_rslider": [ + -27, + 2063 + ], + "range_matrix/3_val_input_max": 2063, + "range_matrix/3_val": -1, + "entrances_probs_chord_slider_val": 0.66, + "entrances_probs_chord_slider_slider": 0.66, + "entrances_probs_chord_slider_input": 0.66, + "entrances_probs_chord_slider_label": "chord prob", + "entrances_probs_chord_slider": -1, + "entrances_probs_vals": [ + 0.63, + 0, + 5, + 0, + 0.5, + 0.23316062176165803, + 0.7094594594594594, + 0.3963730569948187, + 0.8716216216216216, + 0.4948186528497409, + 0.5912162162162162, + 0.5362694300518135, + 0.8614864864864865, + 0.6424870466321243, + 0.5912162162162162, + 0.7901554404145078, + 0.8277027027027027, + 1, + 0.5 + ], + "entrances_probs": -1, + "passages_probs_chord_slider_val": 0.63, + "passages_probs_chord_slider_slider": 0.63, + "passages_probs_chord_slider_input": 0.63, + "passages_probs_chord_slider_label": "chord prob", + "passages_probs_chord_slider": -1, + "passages_probs_vals": [ + 0.63, + 0, + 5, + 0, + 0.5, + 0.23316062176165803, + 0.7094594594594594, + 0.3963730569948187, + 0.8716216216216216, + 0.4948186528497409, + 0.5912162162162162, + 0.5362694300518135, + 0.8614864864864865, + 0.6424870466321243, + 0.5912162162162162, + 0.7901554404145078, + 0.8277027027027027, + 1, + 0.5 + ], + "passages_probs": -1, + "exits_probs_chord_slider_val": 0, + "exits_probs_chord_slider_slider": 0, + "exits_probs_chord_slider_input": 0, + "exits_probs_chord_slider_label": "chord prob", + "exits_probs_chord_slider": -1, + "exits_probs_vals": [ + 0, + 0, + 5, + 0, + 0.5, + 0.23316062176165803, + 0.7094594594594594, + 0.4948186528497409, + 0.5912162162162162, + 0.7901554404145078, + 0.8277027027027027, + 1, + 0.5 + ], + "exits_probs": -1, + "step_env_env_vals": [ + 0, + 5, + 0, + 0, + 0, + 0, + 0.14609053497942387, + 0.7613636363636364, + 0.20164609053497942, + 0.26136363636363635, + 0.24279835390946503, + 0.7215909090909092, + 0.39094650205761317, + 0.875, + 0.4567901234567901, + 0.44318181818181823, + 0.5432098765432098, + 0.34659090909090906, + 0.6481481481481481, + 0.8011363636363636, + 0.6810699588477366, + 0.5170454545454546, + 0.8868312757201646, + 0.49431818181818177, + 0.8868312757201646, + 0.49431818181818177 + ], + "step_env_env_canvas": [ + [ + 0, + 0 + ], + [ + 0, + 0 + ], + [ + 0.14609053497942387, + 0.7613636363636364 + ], + [ + 0.20164609053497942, + 0.26136363636363635 + ], + [ + 0.24279835390946503, + 0.7215909090909092 + ], + [ + 0.39094650205761317, + 0.875 + ], + [ + 0.4567901234567901, + 0.44318181818181823 + ], + [ + 0.5432098765432098, + 0.34659090909090906 + ], + [ + 0.6481481481481481, + 0.8011363636363636 + ], + [ + 0.6810699588477366, + 0.5170454545454546 + ], + [ + 0.8868312757201646, + 0.49431818181818177 + ], + [ + 0.8868312757201646, + 0.49431818181818177 + ], + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "step_env_env_size": 12, + "step_env_env_flatten": 0, + "step_env_env_rslider": [ + 0, + 5 + ], + "step_env_env_rslider_v2": 5, + "step_env_env_rslider_v1": 0, + "step_env_env_mpos": "", + "step_env_env": -1, + "entrances_probs_dur_env_vals": [ + 0.515267175572519, + 4.599236641221374, + 0, + 0.5, + 0.2772020725388601, + 0.7972972972972973, + 0.45077720207253885, + 0.8783783783783784, + 0.5, + 0.5, + 0.727979274611399, + 0.45270270270270274, + 0.7357512953367875, + 0.6486486486486487, + 0.8911917098445595, + 0.7905405405405406, + 1, + 0.5 + ], + "entrances_probs_dur_env_canvas": [ + [ + 0, + 0.5 + ], + [ + 0.2772020725388601, + 0.7972972972972973 + ], + [ + 0.45077720207253885, + 0.8783783783783784 + ], + [ + 0.5, + 0.5 + ], + [ + 0.727979274611399, + 0.45270270270270274 + ], + [ + 0.7357512953367875, + 0.6486486486486487 + ], + [ + 0.8911917098445595, + 0.7905405405405406 + ], + [ + 1, + 0.5 + ], + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "entrances_probs_dur_env_size": 8, + "entrances_probs_dur_env_flatten": 0, + "entrances_probs_dur_env_rslider": [ + 0.515267175572519, + 4.599236641221374 + ], + "entrances_probs_dur_env_rslider_v2": 4.599236641221374, + "entrances_probs_dur_env_rslider_v1": 0.515267175572519, + "entrances_probs_dur_env_mpos": "", + "entrances_probs_dur_env": -1, + "passages_probs_dur_env_vals": [ + 0, + 5, + 0, + 0.5, + 0.23316062176165803, + 0.7094594594594594, + 0.3963730569948187, + 0.8716216216216216, + 0.4948186528497409, + 0.5912162162162162, + 0.5362694300518135, + 0.8614864864864865, + 0.6424870466321243, + 0.5912162162162162, + 0.7901554404145078, + 0.8277027027027027, + 1, + 0.5 + ], + "passages_probs_dur_env_canvas": [ + [ + 0, + 0.5 + ], + [ + 0.23316062176165803, + 0.7094594594594594 + ], + [ + 0.3963730569948187, + 0.8716216216216216 + ], + [ + 0.4948186528497409, + 0.5912162162162162 + ], + [ + 0.5362694300518135, + 0.8614864864864865 + ], + [ + 0.6424870466321243, + 0.5912162162162162 + ], + [ + 0.7901554404145078, + 0.8277027027027027 + ], + [ + 1, + 0.5 + ], + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "passages_probs_dur_env_size": 8, + "passages_probs_dur_env_flatten": 0, + "passages_probs_dur_env_rslider": [ + 0, + 5 + ], + "passages_probs_dur_env_rslider_v2": 5, + "passages_probs_dur_env_rslider_v1": 0, + "passages_probs_dur_env_mpos": "", + "passages_probs_dur_env": -1, + "exits_probs_dur_env_vals": [ + 0, + 5, + 0, + 0.5, + 0.5, + 0.5, + 1, + 0.5 + ], + "exits_probs_dur_env_canvas": [ + [ + 0, + 0.5 + ], + [ + 0.5, + 0.5 + ], + [ + 1, + 0.5 + ], + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "exits_probs_dur_env_size": 3, + "exits_probs_dur_env_flatten": 0, + "exits_probs_dur_env_rslider": [ + 0, + 5 + ], + "exits_probs_dur_env_rslider_v2": 5, + "exits_probs_dur_env_rslider_v1": 0, + "exits_probs_dur_env_mpos": "", + "exits_probs_dur_env": -1, + "mus_seq": [ + [ + [ + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + "Rest" + ], + [ + "Rest" + ] + ], + 0 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + "Rest" + ] + ], + 1.75 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.75 + ], + [ + [ + [ + 0, + 1, + -3, + 0, + 2, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0.75 + ], + [ + [ + [ + 1, + 1, + -2, + -2, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0.625 + ], + [ + [ + [ + 1, + 1, + -3, + -1, + 0, + 0 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0.625 + ], + [ + [ + [ + 1, + 0, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.75 + ] + ], + [ + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.75 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 1, + -2, + 0, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.375 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 2, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0.75 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 1, + -2, + -1, + 2, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.75 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 0, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.875 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1 + ] + ], + [ + [ + [ + [ + 1, + 0, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0 + ], + [ + [ + [ + 1, + 0, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 2, + 0, + -3, + -1, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.625 + ], + [ + [ + [ + 1, + 0, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 1, + -1, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.75 + ], + [ + [ + [ + 1, + 0, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 1, + -1, + -1, + 1, + 0 + ], + [ + "Rest" + ] + ], + 0 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 1, + -1, + -1, + 1, + 0 + ], + [ + "Rest" + ] + ], + 1.875 + ], + [ + [ + [ + "Rest" + ], + [ + "Rest" + ], + [ + 0, + 1, + -1, + -1, + 1, + 0 + ], + [ + "Rest" + ] + ], + 0 + ], + [ + [ + [ + "Rest" + ], + [ + "Rest" + ], + [ + "Rest" + ], + [ + "Rest" + ] + ], + 0.875 + ] + ] + ] + ], + "root": [ + 0.20743639921722112, + 0 + ], + "order_seed": 798574, + "dur_seed": 884869, + "passages_size": [ + 0, + 10 + ], + "dur_seed_lock": 1, + "order_seed_lock": 0, + "seeds_panel": -1, + "motif_panel": [ + 0, + 0 + ], + "ref_uid": "6f1a789f", + "cur_uid": "7ac10d34" +} \ No newline at end of file diff --git a/resources/piece_ledger_transcribe_test/7ac10d34/7ac10d34_mus_model.json b/resources/piece_ledger_transcribe_test/7ac10d34/7ac10d34_mus_model.json new file mode 100644 index 0000000..73f197b --- /dev/null +++ b/resources/piece_ledger_transcribe_test/7ac10d34/7ac10d34_mus_model.json @@ -0,0 +1,59 @@ +{ +"music_data": +[ + [ + [ + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 1.375 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 0, 0, 0, 0, 0, 1 ], [ "Rest" ] ], 0.875 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 0, 1, 0, 0, 0, 0 ], [ "Rest" ] ], 0.875 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 0, 0, 0, 0, 1, 0 ], [ "Rest" ] ], 0.75 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 1, 0, 0, 0, -1, 0 ], [ "Rest" ] ], 1.5 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 1, -1, 0, 0, 0, 0 ], [ "Rest" ] ], 1.125 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 0, 0, 1, 0, 0, 0 ], [ "Rest" ] ], 1.625 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 1, 0, 0, -1, 0, 0 ], [ "Rest" ] ], 1.625 ] + ], + [ + [ [ [ 0, 0, 0, 0, 0, 0 ], [ 2, -1, 0, -1, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ "Rest" ] ], 0 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ 2, -1, 0, -1, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ] ], 1.25 ], + [ [ [ 1, -1, 1, -1, 0, 0 ], [ 2, -1, 0, -1, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ] ], 1.125 ], + [ [ [ 2, -2, 0, -1, 0, 0 ], [ 2, -1, 0, -1, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ] ], 1 ], + [ [ [ 0, 1, 0, -1, 0, 0 ], [ 2, -1, 0, -1, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ] ], 0.5 ], + [ [ [ 1, 0, -1, -1, 0, 0 ], [ 2, -1, 0, -1, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ] ], 1.625 ], + [ [ [ 2, -1, 0, -1, 0, -1 ], [ 2, -1, 0, -1, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ] ], 2 ], + [ [ [ 2, -1, 0, -2, 0, 0 ], [ 2, -1, 0, -1, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ] ], 1.75 ], + [ [ [ 1, -1, 1, -1, 0, 0 ], [ 2, -1, 0, -1, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ] ], 1.5 ], + [ [ [ 2, -2, 0, -1, 0, 0 ], [ 2, -1, 0, -1, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ] ], 1.25 ], + [ [ [ 2, -2, 0, -1, 0, 0 ], [ 2, -1, 0, -1, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ "Rest" ] ], 0.875 ], + [ [ [ 2, -2, 0, -1, 0, 0 ], [ 2, -1, 0, -1, 0, 0 ], [ "Rest" ], [ "Rest" ] ], 0 ], + [ [ [ 2, -2, 0, -1, 0, 0 ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 0 ], + [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 1.375 ] + ] + ] +], +"last_changes": +[ + [ [ 1, 0, -1, -1, 0, 0 ], [ 2, -1, 0, -1, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ] ], + [ [ 2, -1, 0, -1, 0, -1 ], [ 2, -1, 0, -1, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ] ], + [ [ 2, -1, 0, -2, 0, 0 ], [ 2, -1, 0, -1, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ] ], + [ [ 1, -1, 1, -1, 0, 0 ], [ 2, -1, 0, -1, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ] ], + [ [ 2, -2, 0, -1, 0, 0 ], [ 2, -1, 0, -1, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ] ] +], +"cur_uid": "7ac10d34", +"ref_uid": "46b6952a", +"order_seed": 638872, +"dur_seed": 225879, +"motifs_seed": 992393, +"entrances_probs_vals": [ 0.75, 0.5, 2, 0, 0.5, 0.26424870466321, 0.75675675675676, 0.5, 0.5, 0.58549222797927, 0.72635135135135, 1, 0.5 ], +"passages_probs_vals": [ 0.75, 0.5, 2, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], +"exits_probs_vals": [ 0.75, 0.5, 2, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], +"ranges": [ [ -384, 2400 ], [ -507, 2400 ], [ -282, 2237 ], [ -1200, 2053 ] ], +"passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], +"order": +[ + [ [ 0 ], [ 2, 2, 2, 2, 2, 2, 2 ], [ 3, 1 ] ], + [ [ 1, 2, 3 ], [ 0, 0, 0, 0, 0, 0, 0, 0 ], [ ] ] +], +"sus_weights": [ 0.75, 0.69, 0.75 ], +"order_size": [ 2, 6 ], +"passages_size": [ 0, 10 ] +} \ No newline at end of file diff --git a/resources/7bfea52f/7bfea52f_code.scd b/resources/piece_ledger_transcribe_test/7bfea52f/7bfea52f_code.scd similarity index 100% rename from resources/7bfea52f/7bfea52f_code.scd rename to resources/piece_ledger_transcribe_test/7bfea52f/7bfea52f_code.scd diff --git a/resources/7bfea52f/7bfea52f_mus_model.json b/resources/piece_ledger_transcribe_test/7bfea52f/7bfea52f_mus_model.json similarity index 100% rename from resources/7bfea52f/7bfea52f_mus_model.json rename to resources/piece_ledger_transcribe_test/7bfea52f/7bfea52f_mus_model.json diff --git a/resources/piece_ledger_transcribe_test/7e170ef8/7e170ef8_code.scd b/resources/piece_ledger_transcribe_test/7e170ef8/7e170ef8_code.scd new file mode 100644 index 0000000..b11446a --- /dev/null +++ b/resources/piece_ledger_transcribe_test/7e170ef8/7e170ef8_code.scd @@ -0,0 +1,718 @@ +( +// helper funcs +var hsArrayToCents, pDist, hdSum, hsChordalDistance, hsArrayToFreq; + +// score funcs +var isInRange, spacingScore, rangeScore, intervalScore, inclusionScore; + +// subroutines +var genTuples, initVoices, genOrders, genSubMotif, updateVoices, genDurFunc; + +// primary routines +var genMotif, genSecondarySeq; + +// audition funcs +var genPatterns, genMidiPatterns; + +// resource management funcs +var seedFunc, genUID, writeResources, stringifyToDepth, setSeeds, sanityCheck, +msgInterpret, loadLedgerFile, loadLedgerJSON, loadModelFile, loadModelJSON; + +// model vars +//(model and global vars mostly set by OSC funcs +var curUID, refUID, orderSeed, durSeed, motifSeed, +entrancesProbVals, passagesProbVals, exitsProbVals, +ranges, orders, susWeights, passagesWeights, passagesSize, orderSize; + +// model aux vars +var entrancesDurFunc, passagesDurFunc, exitsDurFunc; + +// other global vars +var lastXChanges, popSize, exPath, dir, primes, dims, tuples, +seq, group, player, ledgerPath, ledger, currentlyPlayingUID; + + +// install JSON quark +if(Quarks.isInstalled("JSONlib").not, { + Quarks.install("https://github.com/musikinformatik/JSONlib.git"); + thisProcess.recompile; + //HelpBrowser.openHelpFor("Classes/JSONlib"); +}); + + +//------helper funcs + +hsArrayToCents = { + arg hsArray; + hsArray.collect({arg dist, p; dist * 1200 * log2(primes[p][0]/primes[p][1])}).sum +}; + +pDist = { + arg array1, array2, signed = false; + var pDistance; + pDistance = hsArrayToCents.value(array1) - hsArrayToCents.value(array2); + if(signed, {pDistance}, {abs(pDistance)}) +}; + +hdSum = { + arg hsArrays; + var size, distances, mean; + size = hsArrays.size; + distances = (size - 1).collect({arg i; + ((i + 1)..(size - 1)).collect({arg j; + abs(hsArrays[i] - hsArrays[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum + }); + }).flat; + mean = distances.sum / distances.size; + distances.sum + //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) +}; + +hsChordalDistance = { + arg hsArrays1, hsArrays2; + var size, distances, mean; + size = hsArrays1.size; + distances = hsArrays1.size.collect({arg i; + hsArrays2.size.collect({arg j; + abs(hsArrays1[i] - hsArrays2[j]).collect({arg dist, p; dist * log2(primes[p].product)}).sum + }); + }).flat; + mean = distances.sum / distances.size; + distances.sum + //mean + ((1 / sqrt((pow(distances - mean, 2)).sum / distances.size)) * mean) +}; + +hsArrayToFreq = { + arg array; + array.collect({arg dim, d; pow(primes[d][0]/primes[d][1], dim)}).product +}; + +//------score funcs + +/* +isInRange = { + arg hsArray, min, max; + var cents; + cents = hsArrayToCents.value(hsArray); + (cents >= min) && (cents <= max) +}; +*/ + +spacingScore = { + arg hsArrays, min; + var centsArray; + centsArray = hsArrays.collect({arg hsArray; hsArrayToCents.value(hsArray)}).sort({arg a, b; a < b}); + centsArray.differentiate.drop(1).collect({arg pDistance; if(pDistance >= min, {1}, {0.01})}).sum; +}; + +rangeScore = { + arg hsArray1, hsArray2, min, max, low, signed = false; + var pDistance; + pDistance = pDist.value(hsArray1, hsArray2, signed); + if((pDistance >= min) && (pDistance <= max), {1}, {low}); +}; + +intervalScore = { + arg hsArray1, hsArray2, mean, sd, signed = false; + var pDistance; + pDistance = pDist.value(hsArray1, hsArray2, signed); + pDistance.gaussCurve(1, mean, sd) +}; + +inclusionScore = { + arg array, test, min = 0.01; + if(array.collect({arg v; v.hash}).includes(test.hash), {min}, {1}); +}; + + +//------subroutines + +genTuples = { + var tuples; + tuples = dims.collect({[-1, 0, 1]}).allTuples.select({arg tuple; (abs(tuple.drop(1)).sum <= 1) && (tuple[0] == 0)}); + tuples = tuples ++ tuples.collect({arg tuple; [-3, -2, -1, 1, 2, 3].collect({arg octTrans; tuple.deepCopy.put(0, octTrans)})}).flatten; +}; + +initVoices = { + var init, voicesInit; + voicesInit = popSize.collect({dims.collect({0})}); + /* + voicesInit = [dims.collect({0})]; + (popSize - 1).do({ + arg rep, new; + rep = dims.rand; + new = voicesInit.last.deepCopy; + new[rep] = new[rep] + [-1, 1].choose(); + voicesInit = voicesInit.add(new); + }); + */ + voicesInit.deepCopy; +}; + +genDurFunc = {arg chordProb, min, max, envData; + var env, pTable, durFunc; + env = Env.pairs([[0, 0]] ++ envData.clump(2) ++ [[1, 0]]).asSignal(256).asList.asArray; + pTable = env.asRandomTable; + durFunc = {arg allowChord; + var res; + res = if(allowChord.not, { + pTable.tableRand * (max - min) + min + }, { + if(1.0.rand < chordProb, {0}, {pTable.tableRand * (max - min) + min}); + }).round(0.125); + if(res.asInteger == res, {res = res.asInteger}); + res + }; + seedFunc.value(durFunc, durSeed); +}; + +genOrders = {arg minMotifLength = 1, maxMotifLength = 5, minProgLength = 0, maxProgLength = 5; + ((maxMotifLength - minMotifLength).rand + minMotifLength).collect({ + var noProgIns, noSusIns, noSilentIns, prog, sus, silent, order; + noSusIns = [1, 2, 3].wchoose(susWeights.normalizeSum); + noProgIns = (popSize - noSusIns).rand + 1; + noSilentIns = popSize - noSusIns - noProgIns; + + # prog, sus, silent = (0..(popSize-1)).scramble.clumps([noProgIns, noSusIns, noSilentIns]); + + prog = (prog.scramble ++ ((maxProgLength - minProgLength).rand + minProgLength).collect({prog.choose}).scramble); + if(silent == nil, {silent = []}); + [sus.scramble, prog, silent.scramble] + }); +}; + +updateVoices = {arg ins, sus; + var voices, candidates, nWeights, nProbs, sel; + + voices = lastXChanges.deepCopy.last; + + candidates = sus.collect({arg v; tuples.collect({arg t; voices[v] + t})}).flatten; + candidates = difference(candidates.asSet, voices.asSet).asList; + nProbs = candidates.collect({arg candidate; + var stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore; + + //stepScore = intervalScore.value(voices[ins], candidate, 30, 400, 0.1); + stepScore = intervalScore.value(voices[ins], candidate, 100, 100); + recentlySoundedScore = inclusionScore.value(lastXChanges.flop[ins], candidate, 0); + isInRangeScore = rangeScore.value(candidate, candidate.collect({0}), ranges[ins][0], ranges[ins][1], 0, true); + regScore = spacingScore.value(voices.deepCopy.put(ins, candidate), 300); + hdScore = 1/pow(hdSum.value(voices.deepCopy.put(ins, candidate)), 2); + //maybe what you want here is a vector to another root and then favoring movement towards it. + //distScore = pow(hsChordalDistance.value(voices, voices.put(ins, candidate)), 2); + + [stepScore, recentlySoundedScore, isInRangeScore, regScore, hdScore] + }); + + nWeights = passagesWeights; + + //this handles nWeights of 0; mainly for testing + nProbs = nProbs.flop.select({arg scores, s; nWeights[s] != 0}).flop; + nWeights = nWeights.select({arg weight; weight != 0}); + nProbs = nProbs.flop.collect({arg scores, s; + if(scores.sum == 0, {scores}, {scores.normalizeSum * nWeights[s]}) + }); + nProbs = nProbs.flop.collect({arg scores, s; scores.product}).normalizeSum; + + sel = candidates.wchoose(nProbs); + + voices[ins] = sel; + lastXChanges = lastXChanges.add(voices).keep(-5); +}; + +genSubMotif = {arg order, lastState, repeatLast = false, startFromLast = false, isLastOrder = false; + var sus, prog, silent, flatOrder, res, isInChord, allowChord, lastXChangesHold, voices, adder; + # sus, prog, silent = order; + flatOrder = silent ++ sus ++ prog; + lastXChangesHold = lastXChanges.deepCopy; + voices = lastState.deepCopy; + isInChord = popSize.collect({false}); + allowChord = false; + res = []; + "------generating motif".postln; + //need to figure out here if voices move between motifs + flatOrder.do({arg ins, i; + + if(prog.includes(ins) && repeatLast.not, {updateVoices.value(ins, sus)}); + adder = if(silent.includes(ins), {["Rest"]}, {lastXChanges.last.deepCopy[ins]}); + + if(voices[ins] != adder, { + var dur; + allowChord = if((sus ++ silent).includes(ins), { + (sus ++ silent).includes(ins) && (ins != sus.last); + }, { + if(i < (flatOrder.size - 1), {(isInChord[flatOrder[i + 1]] || (ins == flatOrder[i + 1])).not}, {false}); + }); + dur = passagesDurFunc.value(allowChord); + if(dur == 0, {isInChord[ins] = true}, {isInChord = popSize.collect({false})}); + + voices[ins] = adder; + res = res.add([voices.deepCopy.postln, dur]); + }); + }); + + // pad ending + if(isLastOrder, { + (0..(popSize-1)).scramble.do({arg ins; + if(res.last.first[ins] != ["Rest"], { + var dur; + voices[ins] = ["Rest"]; + allowChord = (voices != popSize.collect({["Rest"]})); + dur = passagesDurFunc.value(allowChord); + res = res.add([voices.deepCopy.postln, dur]); + }); + }); + }); + + //format and return + if(startFromLast, {lastXChanges = lastXChangesHold}); + res; +}; + + +//------primary routines + +genMotif = { + var repeats, fSeq; + + repeats = 1; + fSeq = []; + + repeats.do({arg index; + var motif; + + motif = []; + + orders.do({arg order, o; + var lastState, subMotif; + lastState = if(o == 0, {popSize.collect({["Rest"]})}, {motif.last.last.first}); + subMotif = genSubMotif.value(order, lastState, isLastOrder: o == (orders.size - 1)); + motif = motif.add(subMotif); + + }); + + sanityCheck.value(motif, index); + + fSeq = fSeq.add(motif); + }); + fSeq +}; + +genSecondarySeq = {arg seq; + var curdles, fSeq; + curdles = []; + while({curdles.sum < seq.size}, {curdles = curdles ++ [3.rand + 1]}); + + fSeq = seq.clumps(curdles).collect({arg clump, m; + var repeats, paddedSeq; + + //add rest + paddedSeq = clump.add([[[popSize.collect({["Rest"]}), 0.5.rand]]]); + + //implement repeats + repeats = [0.rand + 1, 1].wchoose([1, 0].normalizeSum); + repeats.collect({paddedSeq}); + }); + fSeq +}; + + +//------audition funcs + +Event.addEventType(\osc, { + if (~addr.postln.notNil) { + ~addr.sendMsg(~indexPath, ~indexMsg); + ~addr.sendMsg(~seqPath, stringifyToDepth.value(~seqMsg, 3)); + //~addr.sendMsg("/STATE/OPEN", (dir.replace("supercollider", "resources") +/+ ~idMsg +/+ ~idMsg ++ "_gui_state" ++ ".state").standardizePath.postln); + }; +}); + +genPatterns = {arg inSeq, addr; + var voices, durs, patterns, res, indices, sectionDurs, ids, seq; + seq = inSeq.collect({arg mSeq; mSeq[0]}); + # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; + indices = inSeq.collect({arg mSeq, m; mSeq[1]}); + ids = inSeq.collect({arg mSeq, m; mSeq[2]}); + sectionDurs = seq.collect({arg mSeq; mSeq.flatten2(mSeq.maxDepth - 5).flop[1].sum}); + res = Ppar( + voices.flop.collect({arg voice; + var clumps, hdScores, freqs, fDurs; + clumps = voice.separate({arg a, b; a != b }); + freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); + fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); + + Pbind( + \instrument, \test, + \group, group, + \freq, Pseq(freqs, 1), + \dur, Pseq(fDurs, 1), + \sustain, Pseq(fDurs, 1) + ) + }) ++ + [ + Pbind( + \type, \osc, + \addr, addr, + \indexPath, "/cur_play_index", + \indexMsg, Pseq(indices.postln, 1), + \seqPath, "/mus_seq", + \seqMsg, Pseq(seq, 1), + \dur, Pseq(sectionDurs, 1) + ); + ] + ); + res +}; + +/* +genMidiPatterns = {arg seq; + var voices, durs, patterns, res, mOut, pbRange; + pbRange = 1; //semitones - change this as needed for your situation + mOut = MIDIOut.newByName("TiMidity", "TiMidity port 0").latency_(Server.default.latency); + # voices, durs = seq.flatten2(seq.maxDepth - 5).flop; + res = Ppar( + voices.flop.collect({arg voice, v; + var clumps, hdScores, freqs, fDurs; + + mOut.program(v, 70); + + clumps = voice.separate({arg a, b; a != b }); + freqs = clumps.collect({arg clump; if(clump[0] != ["Rest"], {(60.midicps * hsArrayToFreq.value(clump[0]))}, {Rest(0)})}); + fDurs = durs.clumps(clumps.collect({arg clump; clump.size})).collect({arg clump; clump.sum}); + + Pbind( + \type, \midi, + \chan, v, + \noteval, Pseq(freqs.cpsmidi - 24, 1), + \note, Pfunc({ | event | event[\noteval].floor }), + \dur, Pseq(fDurs, 1), + \midiout, mOut, + \amp, 1, + \bend, Pfunc({ + | event | + if (event[\note].isRest.not) { + var pitchbendvalue = event[\noteval].frac.linlin(0, pbRange, 8192, 8192*2).asInteger; + m.bend(v, pitchbendvalue); + }; + 0; // return something other than nil to avoid stopping the pattern + }), + ); + }); + ); + res +}; +*/ + + +//------resource management funcs + +genUID = {Date.seed.asHexString.toLower}; + +seedFunc = {arg func, seed; + var funcArgs, next; + next = Routine({loop{func.valueArray(funcArgs).yield }}); + next.randSeed_(seed); + {arg ...args; funcArgs = args; next.value} +}; + +stringifyToDepth = {arg data, maxDepth = 1; + var prettyString = "", rCount = 0, writeArray, indent; + + if(maxDepth == 0, { + data.asCompileString + }, { + indent = {arg size; size.collect({" "}).join("")}; + writeArray = {arg array; + prettyString = prettyString ++ indent.value(rCount) ++ "[\n"; + rCount = rCount + 1; + if(rCount < (maxDepth - 0), { + array.do({arg subArray; writeArray.value(subArray)}); + }, { + prettyString = prettyString ++ array.collect({arg subArray; + indent.value(rCount + 1) ++ subArray.asCompileString + }).join(",\n"); + }); + rCount = rCount - 1; + prettyString = prettyString ++ "\n" ++ indent.value(rCount) ++ "],\n"; + }; + + writeArray.value(data); + prettyString.replace(",\n\n", "\n").drop(-2); + }) +}; + +sanityCheck = {arg motif, index; + //print functions = very helpful + ("----------" + index + "------------").postln; + + motif.flatten.do({arg val, v; + if(v > 0, { + if(motif.flatten[v-1][0].hammingDistance(val[0]) > 1, {"problem 1".postln}); + if(motif.flatten[v-1][0].hammingDistance(val[0]) == 0, {"problem 2".postln}); + }); + val.postln + }); + "***********".postln; +}; + +msgInterpret = {arg in, escapeDoubleQuotes = true, escapeSingleQuotes = true; + var res; + + res = in; + if(res.isNil.not, { + if((res.isArray && res.isString.not), { + res = res.asCompileString; + res = res.replace(" ", "").replace("\n", "").replace("\t", ""); + if(escapeSingleQuotes, {res = res.replace("\'", "")}); + if(escapeDoubleQuotes, {res = res.replace("\"", "")}); + res = res.replace("Rest", "\"Rest\""); + res = res.interpret; + }, { + //res.postln; + if(res.every({arg char; char.isDecDigit}), {res = res.asInteger}); + }); + }); + res +}; + +writeResources = {arg path; + var file, nameSpaces, modelItems, resString; + file = File(path,"w"); + + nameSpaces = [ + "music_data", "last_changes", + "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", + "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", + "ranges", "passages_weights", "order", "sus_weights", "order_size", "passages_size" + ]; + + modelItems = [ + seq, lastXChanges, + curUID, refUID, orderSeed, durSeed, motifSeed, + entrancesProbVals, passagesProbVals, exitsProbVals, + ranges, passagesWeights, orders, susWeights, orderSize, passagesSize + ]; + + resString = [nameSpaces, modelItems].flop.collect({arg item; + var nameSpace, modelItem, depth = 0, insert = " "; + # nameSpace, modelItem = item; + if(nameSpace == "music_data", {depth = 3; insert = "\n"}); + if(nameSpace == "last_changes", {depth = 1; insert = "\n"}); + if(nameSpace == "order", {depth = 1; insert = "\n"}); + "\"" ++ nameSpace ++ "\":" ++ insert ++ stringifyToDepth.value(modelItem.postln, depth).postln + }).join(",\n"); + + resString = "{\n" ++ resString ++ "\n}"; + + file.write(resString); + file.close; +}; + +loadModelFile = {arg path; loadModelJSON.value(File(path, "r").readAllString.parseJSON)}; + +loadModelJSON = {arg model; + var nameSpaces, data; + + //model = File(path, "r").readAllString.parseJSON; + + nameSpaces = [ + "cur_uid", "ref_uid", "order_seed", "dur_seed", "motifs_seed", + "entrances_probs_vals","passages_probs_vals", "exits_probs_vals", + "ranges", "passages_weights", "order", "sus_weights", "order_size", "passages_size" + ]; + + data = nameSpaces.collect({arg nS; msgInterpret.value(model[nS]).postln}); + + data.postln; + + # curUID, refUID, orderSeed, durSeed, motifSeed, + entrancesProbVals, passagesProbVals, exitsProbVals, + ranges, passagesWeights, orders, susWeights, orderSize, passagesSize = data; + + popSize = ranges.size; +}; + +loadLedgerFile = {arg path; + ledgerPath = path; + loadLedgerJSON.value(File(ledgerPath, "r").readAllString.parseJSON) +}; + +loadLedgerJSON = {arg ledger; ledger = ledger["ledger"]}; + +//------global vars + +primes = [[2, 1], [3, 2], [5, 4], [7, 4], [11, 8], [13, 8]]; +//ranges = [[-2400, 0], [-1200, 1200], [0, 2400], [0, 2400]]; +exPath = thisProcess.nowExecutingPath; +dir = exPath.dirname; +//popSize = 4; +dims = primes.size; +tuples = genTuples.value(); +//refUID = nil; +group = Group.new; +loadLedgerFile.value(dir +/+ ".." +/+ "resources" +/+ "piece_ledger.json"); +//passagesWeights = [1, 1, 1, 1, 1]; +//susWeights = [1, 1, 1]; + + +//------OSC funcs + +OSCdef(\load_ledger, {arg msg, time, addr, port; + loadLedgerFile.value(msg[1].asString); +}, \load_ledger); + +OSCdef(\load_model, {arg msg, time, addr, port; + loadModelFile.value(msg[1].asString); +}, \load_model); + + +OSCdef(\generate, {arg msg, time, addr, port; + var path, dFormat, condition, musPath; + msg.postln; + + path = msg[1].asString; + + loadModelFile.value(path); + + refUID.postln; + + loadLedgerFile.value(ledgerPath); + if(ledger.last != "tmp", {ledger = ledger.add("tmp")}); + + lastXChanges = if(refUID == nil, { + [initVoices.value().deepCopy]; + }, { + var file; + refUID.postln; + file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); + msgInterpret.value(file.readAllString.parseJSON["last_changes"]); + }); + + entrancesDurFunc = genDurFunc.valueArray(entrancesProbVals[..2] ++ [entrancesProbVals[3..]]); + passagesDurFunc = genDurFunc.valueArray(passagesProbVals[..2] ++ [passagesProbVals[3..]]); + exitsDurFunc = genDurFunc.valueArray(exitsProbVals[..2] ++ [exitsProbVals[3..]]); + + if(orders == nil, { + orders = seedFunc.value(genOrders, orderSeed).valueArray(orderSize ++ passagesSize); + addr.sendMsg("/order", stringifyToDepth.value(orders, 1)); + }); + seq = seedFunc.value(genMotif, motifSeed).value; + + //musPath = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; + writeResources.value(path); + + //orders = nil; + //addr.sendMsg("/current_uid", curUID); + //addr.sendMsg("/ledger", prettifyArray.value(ledger, 1).replace("\"", "")); + //addr.sendMsg("/ledger_size", ledger.size); + //addr.sendMsg("/mus_seq", prettifyArray.value(seq, 3)); + addr.sendMsg("/generated", musPath, stringifyToDepth.value(seq, 3)); +}, \generate); + + +OSCdef(\commit, {arg msg, time, addr, port; + var newLedger, modelPath, musString, musFile, test1, test2; + msg.postln; + + /* + test1 = msg[1].asString.parseJSON; + test2 = (dir +/+ ".." +/+ "resources/tmp/tmp_music" ++ ".json").standardizePath.parseJSONFile; + msgInterpret.value(test1["music"])[0][0][0][1].class.postln; + msgInterpret.value(test2["music_data"])[0][0][0][1].class.postln; + (test1["music"] == test2["music_data"]).postln; + */ + + curUID = genUID.value; + File.mkdir((dir +/+ ".." +/+ "resources" +/+ curUID).standardizePath); + File.copy(exPath, (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_code" ++ ".scd").standardizePath); + + modelPath = (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_mus_model" ++ ".json").standardizePath; + writeResources.value(modelPath); + + File.delete(ledgerPath.postln ++ "_bak"); + File.copy(ledgerPath, ledgerPath ++ "_bak"); + File.delete(ledgerPath); + newLedger = File(ledgerPath.postln, "w"); + ledger = ledger.postln.drop(-1).add(curUID); + newLedger.write("{\n\"ledger\":\n" ++ stringifyToDepth.value(ledger, 1) ++ "\n}"); + newLedger.close; + + addr.sendMsg("/committed", curUID, ledgerPath); + //refUID = curUID; +}, \commit); + +OSCdef(\transport, {arg msg, time, addr, port; + msg.postln; + if(msg[1] == 0, { + player.stop; + group.set(\gate, 0); + }, { + // the cued sequence can now be read from file, so this can be cleaned up + var cSize, patterns, pSeq, cuedSeek, indexStart, indexEnd, tmpLedger; + pSeq = []; + cuedSeek = (seq != nil); + indexStart = msg[2].asInteger; + indexEnd = ledger.size - if(cuedSeek, {2}, {1}); + if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { + ledger[indexStart..indexEnd].do({arg uid, index; + var file; + (indexStart + index).postln; + file = File((dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_music" ++ ".json").standardizePath, "r"); + pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), indexStart + index, uid]); + file.close; + }); + }); + if(cuedSeek, {pSeq = pSeq.add([seq, ledger.size - 1])}); + patterns = genPatterns.value(pSeq, addr); + player = Pfset(pattern: patterns, cleanupFunc: { + addr.sendMsg("/transport", 0); + }); + player = player.play + }); +}, \transport); + +) + +( +SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; + var trig, exc, sig1, sig2, noHarms; + noHarms = 30; + exc = Saw.ar(freq, TRand.ar(0.5, 1, Impulse.ar(freq))) * 0.001 + Dust.ar(10000, 0.01); + sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), + Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), + Array.fill(noHarms, {rrand(1, 2)}) ], exc) * 0.5).softclip; + sig1 = HPF.ar(sig1, 300); + Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); +}).add; +) + +( +SynthDef(\test, {arg freq, gate = 1, sustain, amp, dur; + var trig, exc, sig1, sig2, noHarms, freqFinal, start, end; + noHarms = 30; + freq = WhiteNoise.ar * 3 + freq; + freqFinal = Duty.ar((1/freq), 0, freq); + trig = Changed.ar(freqFinal); + start = Demand.ar(trig, 0, Dwhite(-1, -0.75)); + end = Demand.ar(trig, 0, Dwhite(0.75, 1)); + exc = Phasor.ar(trig, (end - start) * freqFinal / SampleRate.ir, start, end, 0) * 0.001 + Dust.ar(10000, 0.01); + + sig1 = (Klank.ar(`[ Array.series(noHarms, freq, freq), + Array.geom(noHarms, 1, 0.2) + Array.fill(noHarms, {rrand(0.01, 0.03)}), + Array.fill(noHarms, {rrand(2, 3)}) ], exc) * 0.5).softclip; + sig1 = HPF.ar(sig1, 300); + Out.ar([0, 1], sig1 * EnvGen.kr(Env.adsr(0.3, 0.3, 0.9, 0.5, 0.9), gate, doneAction: 2)); +}).add; +) + + + +"{\"a\": 1}".parseYAML["a"].asInteger; +"{\"a\": 1}".parseJSON["a"].isNumber; + +1223423434123.asHexString.toLower + +Date.getDate.rawSeconds +Date.seed.asHexString.toLower + +n = NetAddr("localhost", 8080); +n.sendMsg("/GET/#", (NetAddr.localAddr.hostname ++ ":" ++ NetAddr.localAddr.port), "/passage_probs_vals"); \ No newline at end of file diff --git a/resources/piece_ledger_transcribe_test/7e170ef8/7e170ef8_gui_state.json b/resources/piece_ledger_transcribe_test/7e170ef8/7e170ef8_gui_state.json new file mode 100644 index 0000000..704cf3a --- /dev/null +++ b/resources/piece_ledger_transcribe_test/7e170ef8/7e170ef8_gui_state.json @@ -0,0 +1,1359 @@ +{ + "motif_label": "motif", + "seeds_label": "seeds", + "order": "[\n [ [ 3, 1, 0 ], [ 2 ], [ ] ],\n [ [ 1, 2 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 3 ] ],\n [ [ 3, 2 ], [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ], [ 0 ] ],\n [ [ 2, 3 ], [ 0, 1, 0 ], [ ] ]\n]", + "order_lock": 1, + "order_size": [ + 3, + 8 + ], + "order_size_v2": 8, + "order_size_v1": 3, + "order_size_panel": -1, + "passage_size_v2": 8, + "passage_size_v1": 2, + "passage_size_panel": -1, + "sus_weights": [ + null, + null, + null + ], + "range_matrix": [ + null, + null, + null, + null + ], + "instrumentation": [ + 0, + 0 + ], + "entrances_probs_sync": "passages", + "entrances": -1, + "passages_probs_sync": "passages", + "passages": -1, + "exits_probs_sync": "passages", + "exits": -1, + "dur_panel": 0, + "durations": -1, + "passages_weights": [ + null, + null, + null, + null, + null + ], + "weights": -1, + "seeds_tab_panel": 0, + "weights_seed_lock": 0, + "weights_seed": 534103, + "sus_weights/0_slider_val": 0.21, + "sus_weights/0_slider_slider": 0.21, + "sus_weights/0_slider_input": 0.21, + "sus_weights/0_slider_label": 1, + "sus_weights/0_slider": -1, + "sus_weights/1_slider_val": 0.35, + "sus_weights/1_slider_slider": 0.35, + "sus_weights/1_slider_input": 0.35, + "sus_weights/1_slider_label": 2, + "sus_weights/1_slider": -1, + "sus_weights/2_slider_val": 0.21, + "sus_weights/2_slider_slider": 0.21, + "sus_weights/2_slider_input": 0.21, + "sus_weights/2_slider_label": 3, + "sus_weights/2_slider": -1, + "passages_weights/0_slider_val": 0.49, + "passages_weights/0_slider_slider": 0.49, + "passages_weights/0_slider_input": 0.49, + "passages_weights/0_slider_label": "step", + "passages_weights/0_slider": -1, + "passages_weights/1_slider_val": 0.53, + "passages_weights/1_slider_slider": 0.53, + "passages_weights/1_slider_input": 0.53, + "passages_weights/1_slider_label": "dc", + "passages_weights/1_slider": -1, + "passages_weights/2_slider_val": 0.35, + "passages_weights/2_slider_slider": 0.35, + "passages_weights/2_slider_input": 0.35, + "passages_weights/2_slider_label": "range", + "passages_weights/2_slider": -1, + "passages_weights/3_slider_val": 0.59, + "passages_weights/3_slider_slider": 0.59, + "passages_weights/3_slider_input": 0.59, + "passages_weights/3_slider_label": "registration", + "passages_weights/3_slider": -1, + "passages_weights/4_slider_val": 0.39, + "passages_weights/4_slider_slider": 0.39, + "passages_weights/4_slider_input": 0.39, + "passages_weights/4_slider_label": "hd", + "passages_weights/4_slider": -1, + "range_matrix/0_val_input_min": -853.2067988668555, + "range_matrix/0_val_rslider": [ + -853.2067988668555, + 401 + ], + "range_matrix/0_val_input_max": 401, + "range_matrix/0_val": -1, + "range_matrix/1_val_input_min": -659, + "range_matrix/1_val_rslider": [ + -659, + 880 + ], + "range_matrix/1_val_input_max": 880, + "range_matrix/1_val": -1, + "range_matrix/2_val_input_min": -241, + "range_matrix/2_val_rslider": [ + -241, + 1869 + ], + "range_matrix/2_val_input_max": 1869, + "range_matrix/2_val": -1, + "range_matrix/3_val_input_min": -27, + "range_matrix/3_val_rslider": [ + -27, + 2063 + ], + "range_matrix/3_val_input_max": 2063, + "range_matrix/3_val": -1, + "entrances_probs_chord_slider_val": 0.66, + "entrances_probs_chord_slider_slider": 0.66, + "entrances_probs_chord_slider_input": 0.66, + "entrances_probs_chord_slider_label": "chord prob", + "entrances_probs_chord_slider": -1, + "entrances_probs_vals": [ + 0.63, + 0, + 5, + 0, + 0.5, + 0.23316062176165803, + 0.7094594594594594, + 0.3963730569948187, + 0.8716216216216216, + 0.4948186528497409, + 0.5912162162162162, + 0.5362694300518135, + 0.8614864864864865, + 0.6424870466321243, + 0.5912162162162162, + 0.7901554404145078, + 0.8277027027027027, + 1, + 0.5 + ], + "entrances_probs": -1, + "passages_probs_chord_slider_val": 0.63, + "passages_probs_chord_slider_slider": 0.63, + "passages_probs_chord_slider_input": 0.63, + "passages_probs_chord_slider_label": "chord prob", + "passages_probs_chord_slider": -1, + "passages_probs_vals": [ + 0.63, + 0, + 5, + 0, + 0.5, + 0.23316062176165803, + 0.7094594594594594, + 0.3963730569948187, + 0.8716216216216216, + 0.4948186528497409, + 0.5912162162162162, + 0.5362694300518135, + 0.8614864864864865, + 0.6424870466321243, + 0.5912162162162162, + 0.7901554404145078, + 0.8277027027027027, + 1, + 0.5 + ], + "passages_probs": -1, + "exits_probs_chord_slider_val": 0, + "exits_probs_chord_slider_slider": 0, + "exits_probs_chord_slider_input": 0, + "exits_probs_chord_slider_label": "chord prob", + "exits_probs_chord_slider": -1, + "exits_probs_vals": [ + 0, + 0, + 5, + 0, + 0.5, + 0.23316062176165803, + 0.7094594594594594, + 0.4948186528497409, + 0.5912162162162162, + 0.7901554404145078, + 0.8277027027027027, + 1, + 0.5 + ], + "exits_probs": -1, + "step_env_env_vals": [ + 0, + 5, + 0, + 0, + 0, + 0, + 0.14609053497942387, + 0.7613636363636364, + 0.20164609053497942, + 0.26136363636363635, + 0.24279835390946503, + 0.7215909090909092, + 0.39094650205761317, + 0.875, + 0.4567901234567901, + 0.44318181818181823, + 0.5432098765432098, + 0.34659090909090906, + 0.6481481481481481, + 0.8011363636363636, + 0.6810699588477366, + 0.5170454545454546, + 0.8868312757201646, + 0.49431818181818177, + 0.8868312757201646, + 0.49431818181818177 + ], + "step_env_env_canvas": [ + [ + 0, + 0 + ], + [ + 0, + 0 + ], + [ + 0.14609053497942387, + 0.7613636363636364 + ], + [ + 0.20164609053497942, + 0.26136363636363635 + ], + [ + 0.24279835390946503, + 0.7215909090909092 + ], + [ + 0.39094650205761317, + 0.875 + ], + [ + 0.4567901234567901, + 0.44318181818181823 + ], + [ + 0.5432098765432098, + 0.34659090909090906 + ], + [ + 0.6481481481481481, + 0.8011363636363636 + ], + [ + 0.6810699588477366, + 0.5170454545454546 + ], + [ + 0.8868312757201646, + 0.49431818181818177 + ], + [ + 0.8868312757201646, + 0.49431818181818177 + ], + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "step_env_env_size": 12, + "step_env_env_flatten": 0, + "step_env_env_rslider": [ + 0, + 5 + ], + "step_env_env_rslider_v2": 5, + "step_env_env_rslider_v1": 0, + "step_env_env_mpos": "", + "step_env_env": -1, + "entrances_probs_dur_env_vals": [ + 0.515267175572519, + 4.599236641221374, + 0, + 0.5, + 0.2772020725388601, + 0.7972972972972973, + 0.45077720207253885, + 0.8783783783783784, + 0.5, + 0.5, + 0.727979274611399, + 0.45270270270270274, + 0.7357512953367875, + 0.6486486486486487, + 0.8911917098445595, + 0.7905405405405406, + 1, + 0.5 + ], + "entrances_probs_dur_env_canvas": [ + [ + 0, + 0.5 + ], + [ + 0.2772020725388601, + 0.7972972972972973 + ], + [ + 0.45077720207253885, + 0.8783783783783784 + ], + [ + 0.5, + 0.5 + ], + [ + 0.727979274611399, + 0.45270270270270274 + ], + [ + 0.7357512953367875, + 0.6486486486486487 + ], + [ + 0.8911917098445595, + 0.7905405405405406 + ], + [ + 1, + 0.5 + ], + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "entrances_probs_dur_env_size": 8, + "entrances_probs_dur_env_flatten": 0, + "entrances_probs_dur_env_rslider": [ + 0.515267175572519, + 4.599236641221374 + ], + "entrances_probs_dur_env_rslider_v2": 4.599236641221374, + "entrances_probs_dur_env_rslider_v1": 0.515267175572519, + "entrances_probs_dur_env_mpos": "", + "entrances_probs_dur_env": -1, + "passages_probs_dur_env_vals": [ + 0, + 5, + 0, + 0.5, + 0.23316062176165803, + 0.7094594594594594, + 0.3963730569948187, + 0.8716216216216216, + 0.4948186528497409, + 0.5912162162162162, + 0.5362694300518135, + 0.8614864864864865, + 0.6424870466321243, + 0.5912162162162162, + 0.7901554404145078, + 0.8277027027027027, + 1, + 0.5 + ], + "passages_probs_dur_env_canvas": [ + [ + 0, + 0.5 + ], + [ + 0.23316062176165803, + 0.7094594594594594 + ], + [ + 0.3963730569948187, + 0.8716216216216216 + ], + [ + 0.4948186528497409, + 0.5912162162162162 + ], + [ + 0.5362694300518135, + 0.8614864864864865 + ], + [ + 0.6424870466321243, + 0.5912162162162162 + ], + [ + 0.7901554404145078, + 0.8277027027027027 + ], + [ + 1, + 0.5 + ], + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "passages_probs_dur_env_size": 8, + "passages_probs_dur_env_flatten": 0, + "passages_probs_dur_env_rslider": [ + 0, + 5 + ], + "passages_probs_dur_env_rslider_v2": 5, + "passages_probs_dur_env_rslider_v1": 0, + "passages_probs_dur_env_mpos": "", + "passages_probs_dur_env": -1, + "exits_probs_dur_env_vals": [ + 0, + 5, + 0, + 0.5, + 0.5, + 0.5, + 1, + 0.5 + ], + "exits_probs_dur_env_canvas": [ + [ + 0, + 0.5 + ], + [ + 0.5, + 0.5 + ], + [ + 1, + 0.5 + ], + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "exits_probs_dur_env_size": 3, + "exits_probs_dur_env_flatten": 0, + "exits_probs_dur_env_rslider": [ + 0, + 5 + ], + "exits_probs_dur_env_rslider_v2": 5, + "exits_probs_dur_env_rslider_v1": 0, + "exits_probs_dur_env_mpos": "", + "exits_probs_dur_env": -1, + "mus_seq": [ + [ + [ + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + "Rest" + ], + [ + "Rest" + ] + ], + 0 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + "Rest" + ] + ], + 1.75 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.75 + ], + [ + [ + [ + 0, + 1, + -3, + 0, + 2, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0.75 + ], + [ + [ + [ + 1, + 1, + -2, + -2, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0.625 + ], + [ + [ + [ + 1, + 1, + -3, + -1, + 0, + 0 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0.625 + ], + [ + [ + [ + 1, + 0, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.75 + ] + ], + [ + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -3, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.75 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 1, + -2, + 0, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.375 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 2, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0.75 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 1, + -2, + -1, + 2, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.75 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 0, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.875 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1 + ] + ], + [ + [ + [ + [ + 1, + 0, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 0 + ], + [ + [ + [ + 1, + 0, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 2, + 0, + -3, + -1, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.625 + ], + [ + [ + [ + 1, + 0, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 1, + -1, + -1, + 1, + 0 + ], + [ + 1, + 1, + -2, + -1, + 0, + 0 + ] + ], + 1.75 + ], + [ + [ + [ + 1, + 0, + -3, + 0, + 1, + -1 + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 1, + -1, + -1, + 1, + 0 + ], + [ + "Rest" + ] + ], + 0 + ], + [ + [ + [ + "Rest" + ], + [ + 1, + 1, + -2, + -1, + 1, + 0 + ], + [ + 0, + 1, + -1, + -1, + 1, + 0 + ], + [ + "Rest" + ] + ], + 1.875 + ], + [ + [ + [ + "Rest" + ], + [ + "Rest" + ], + [ + 0, + 1, + -1, + -1, + 1, + 0 + ], + [ + "Rest" + ] + ], + 0 + ], + [ + [ + [ + "Rest" + ], + [ + "Rest" + ], + [ + "Rest" + ], + [ + "Rest" + ] + ], + 0.875 + ] + ] + ] + ], + "root": [ + 0.20743639921722112, + 0 + ], + "order_seed": 798574, + "dur_seed": 884869, + "passages_size": [ + 0, + 10 + ], + "dur_seed_lock": 1, + "order_seed_lock": 0, + "seeds_panel": -1, + "motif_panel": [ + 0, + 0 + ], + "ref_uid": "6f1a789f", + "cur_uid": "7e170ef8" +} \ No newline at end of file diff --git a/resources/piece_ledger_transcribe_test/7e170ef8/7e170ef8_mus_model.json b/resources/piece_ledger_transcribe_test/7e170ef8/7e170ef8_mus_model.json new file mode 100644 index 0000000..c9b8807 --- /dev/null +++ b/resources/piece_ledger_transcribe_test/7e170ef8/7e170ef8_mus_model.json @@ -0,0 +1,79 @@ +{ +"music_data": +[ + [ + [ + [ [ [ "Rest" ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ] ], 1.75 ], + [ [ [ "Rest" ], [ "Rest" ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 1, 0, 0, 0 ] ], 0 ], + [ [ [ "Rest" ], [ -1, 0, 0, 1, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 1, 0, 0, 0 ] ], 0.625 ], + [ [ [ "Rest" ], [ -1, 0, 0, 1, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ] ], 0.875 ], + [ [ [ "Rest" ], [ -1, 0, 0, 1, 0, 0 ], [ 0, 0, 0, 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, 0 ], [ 0, 0, 0, 1, 0, 0 ] ], + [ [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 1, 0, 0, 0, 0, 0 ] ], + [ [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 1, -1, 0, 0, 0, 1 ] ], + [ [ 0, 0, 0, 0, 0, 0 ], [ 1, -1, 0, 0, 0, 0 ], [ 1, 0, 0, -1, 0, 0 ], [ 2, 0, 0, -1, 0, 0 ] ] +], +"cur_uid": "7e170ef8", +"ref_uid": "nil", +"order_seed": 142640, +"dur_seed": 629022, +"motifs_seed": 973728, +"entrances_probs_vals": [ 0.75, 0.5, 2, 0, 0.5, 0.26424870466321, 0.75675675675676, 0.5, 0.5, 0.58549222797927, 0.72635135135135, 1, 0.5 ], +"passages_probs_vals": [ 0.75, 0.5, 2, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], +"exits_probs_vals": [ 0.75, 0.5, 2, 0, 0.5, 0.20725388601036, 0.68581081081081, 0.24093264248705, 0.34121621621622, 0.5, 0.5, 0.67616580310881, 0.81081081081081, 1, 0.5 ], +"ranges": [ [ -384, 2400 ], [ -507, 2400 ], [ -282, 2237 ], [ -1200, 2053 ] ], +"passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], +"order": +[ + [ [ 2 ], [ 3, 1, 3, 3, 3, 1, 1, 3, 3, 1 ], [ 0 ] ], + [ [ 0 ], [ 1, 2, 3, 3, 1, 3, 1, 3 ], [ ] ], + [ [ 0, 3 ], [ 1, 1, 1, 1, 1, 1 ], [ 2 ] ], + [ [ 1, 2, 0 ], [ 3, 3, 3, 3 ], [ ] ] +], +"sus_weights": [ 0.75, 0.69, 0.75 ], +"order_size": [ 2, 6 ], +"passages_size": [ 0, 10 ] +} \ No newline at end of file diff --git a/resources/7e2c2e91/7e2c2e91_code.scd b/resources/piece_ledger_transcribe_test/7e2c2e91/7e2c2e91_code.scd similarity index 100% rename from resources/7e2c2e91/7e2c2e91_code.scd rename to resources/piece_ledger_transcribe_test/7e2c2e91/7e2c2e91_code.scd diff --git a/resources/7e2c2e91/7e2c2e91_mus_model.json b/resources/piece_ledger_transcribe_test/7e2c2e91/7e2c2e91_mus_model.json similarity index 100% rename from resources/7e2c2e91/7e2c2e91_mus_model.json rename to resources/piece_ledger_transcribe_test/7e2c2e91/7e2c2e91_mus_model.json diff --git a/resources/tmp/tmp_gui_state.json.json b/resources/tmp/tmp_gui_state.json.json deleted file mode 100644 index b388a1d..0000000 --- a/resources/tmp/tmp_gui_state.json.json +++ /dev/null @@ -1,603 +0,0 @@ -{ - "mus_seq": "[\n [\n [\n [ [ [ \"Rest\" ], [ \"Rest\" ], [ \"Rest\" ], [ 0, 0, 0, 0, 0, 0 ] ], 0 ], \n [ [ [ \"Rest\" ], [ \"Rest\" ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], 1.75 ], \n [ [ [ 0, 0, 1, 0, 0, 0 ], [ \"Rest\" ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], 1.5 ], \n [ [ [ 0, 0, 1, 0, 0, 0 ], [ -1, 0, 0, 1, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], 1.75 ], \n [ [ [ 0, 0, 1, 0, 0, 0 ], [ -1, 0, 0, 0, 0, 1 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], 0.5 ], \n [ [ [ 0, 0, 1, 0, 0, 0 ], [ -1, 1, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0 ] ], 1.875 ], \n [ [ [ 0, 0, 1, 0, 0, 0 ], [ 0, 0, -1, 0,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, 1, 0, 1, 0 ], [ \"Rest\" ] ], 0 ], \n [ [ [ \"Rest\" ], [ \"Rest\" ], [ -1, 0, 1, 0, 1, 0 ], [ \"Rest\" ] ], 0 ], \n [ [ [ \"Rest\" ], [ \"Rest\" ], [ \"Rest\" ], [ \"Rest\" ] ], 1.375 ]\n ]\n ]\n]", - "motif_label": "motif", - "motif_panel": -1, - "seeds_label": "seeds", - "order": "[\n [ [ 3, 2 ], [ 0, 1, 1, 1, 1, 1, 0 ], [ ] ], \n [ [ 1, 0, 3 ], [ 2, 2, 2, 2, 2, 2 ], [ ] ]\n]", - "order_lock": 0, - "order_size_rslider": [ - 2, - 6 - ], - "order_size_input_max": 6, - "order_size_input_min": 2, - "order_size": -1, - "passages_size_rslider": [ - 0, - 10 - ], - "passages_size_input_max": 10, - "passages_size_input_min": 0, - "passages_size": -1, - "sus_weights": [ - null, - null, - null - ], - "range_matrix": [ - null, - null, - null, - null - ], - "instrumentation": -1, - "entrances_probs_sync": "entrances", - "entrances": -1, - "passages_probs_sync": "passages", - "passages": -1, - "exits_probs_sync": "exits", - "exits": -1, - "dur_panel": 0, - "durations": -1, - "passages_weights": [ - null, - null, - null, - null, - null - ], - "weights": -1, - "seeds_tab_panel": 1, - "order_seed_lock": 0, - "order_seed": 684642, - "dur_seed_lock": 0, - "dur_seed": 712392, - "weights_seed_lock": 0, - "weights_seed": 330807, - "seeds_panel": -1, - "root": -1, - "sus_weights/0_val_slider": 0.75, - "sus_weights/0_val_input": 0.75, - "sus_weights/0_val_label": 1, - "sus_weights/0_val": -1, - "sus_weights/1_val_slider": 0.69, - "sus_weights/1_val_input": 0.69, - "sus_weights/1_val_label": 2, - "sus_weights/1_val": -1, - "sus_weights/2_val_slider": 0.75, - "sus_weights/2_val_input": 0.75, - "sus_weights/2_val_label": 3, - "sus_weights/2_val": -1, - "passages_weights/0_val_slider": 0.75, - "passages_weights/0_val_input": 0.75, - "passages_weights/0_val_label": "step", - "passages_weights/0_val": -1, - "passages_weights/1_val_slider": 0.75, - "passages_weights/1_val_input": 0.75, - "passages_weights/1_val_label": "dc", - "passages_weights/1_val": -1, - "passages_weights/2_val_slider": 0.75, - "passages_weights/2_val_input": 0.75, - "passages_weights/2_val_label": "range", - "passages_weights/2_val": -1, - "passages_weights/3_val_slider": 0.75, - "passages_weights/3_val_input": 0.75, - "passages_weights/3_val_label": "registration", - "passages_weights/3_val": -1, - "passages_weights/4_val_slider": 0.75, - "passages_weights/4_val_input": 0.75, - "passages_weights/4_val_label": "hd", - "passages_weights/4_val": -1, - "range_matrix/0_val_input_min": -384, - "range_matrix/0_val_rslider": [ - -384, - 2400 - ], - "range_matrix/0_val_input_max": 2400, - "range_matrix/0_val": -1, - "range_matrix/1_val_input_min": -507, - "range_matrix/1_val_rslider": [ - -507, - 2400 - ], - "range_matrix/1_val_input_max": 2400, - "range_matrix/1_val": -1, - "range_matrix/2_val_input_min": -282, - "range_matrix/2_val_rslider": [ - -282, - 2237 - ], - "range_matrix/2_val_input_max": 2237, - "range_matrix/2_val": -1, - "range_matrix/3_val_input_min": -1200, - "range_matrix/3_val_rslider": [ - -1200, - 2053 - ], - "range_matrix/3_val_input_max": 2053, - "range_matrix/3_val": -1, - "entrances_probs_chord_val_slider": 0.75, - "entrances_probs_chord_val_input": 0.75, - "entrances_probs_chord_val_label": "chord prob", - "entrances_probs_chord_val": -1, - "entrances_probs_vals": [ - 0.75, - 0.5, - 2, - 0, - 0.5, - 0.26424870466321, - 0.75675675675676, - 0.5, - 0.5, - 0.58549222797927, - 0.72635135135135, - 1, - 0.5 - ], - "entrances_probs": -1, - "passages_probs_chord_val_slider": 0.75, - "passages_probs_chord_val_input": 0.75, - "passages_probs_chord_val_label": "chord prob", - "passages_probs_chord_val": -1, - "passages_probs_vals": [ - 0.75, - 0.5, - 2, - 0, - 0.5, - 0.20725388601036, - 0.68581081081081, - 0.24093264248705, - 0.34121621621622, - 0.5, - 0.5, - 0.67616580310881, - 0.81081081081081, - 1, - 0.5 - ], - "passages_probs": -1, - "exits_probs_chord_val_slider": 0.75, - "exits_probs_chord_val_input": 0.75, - "exits_probs_chord_val_label": "chord prob", - "exits_probs_chord_val": -1, - "exits_probs_vals": [ - 0.75, - 0.5, - 2, - 0, - 0.5, - 0.20725388601036, - 0.68581081081081, - 0.24093264248705, - 0.34121621621622, - 0.5, - 0.5, - 0.67616580310881, - 0.81081081081081, - 1, - 0.5 - ], - "exits_probs": -1, - "step_env_env_vals": [ - 0.5, - 2, - 0, - 0.5, - 0.5, - 0.5, - 1, - 0.5 - ], - "step_env_env_canvas": [ - [ - 0, - 0.5 - ], - [ - 0.5, - 0.5 - ], - [ - 1, - 0.5 - ], - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - ], - "step_env_env_size": 3, - "step_env_env_flatten": 0, - "step_env_env_rslider": [ - 0.5, - 2 - ], - "step_env_env_input_max": 2, - "step_env_env_input_min": 0.5, - "step_env_env_mpos": "", - "step_env_env": -1, - "entrances_probs_dur_env_vals": [ - 0.5, - 2, - 0, - 0.5, - 0.26424870466321, - 0.75675675675676, - 0.5, - 0.5, - 0.58549222797927, - 0.72635135135135, - 1, - 0.5 - ], - "entrances_probs_dur_env_canvas": [ - [ - 0, - 0.5 - ], - [ - 0.26424870466321, - 0.75675675675676 - ], - [ - 0.5, - 0.5 - ], - [ - 0.58549222797927, - 0.72635135135135 - ], - [ - 1, - 0.5 - ], - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - ], - "entrances_probs_dur_env_size": 5, - "entrances_probs_dur_env_flatten": 0, - "entrances_probs_dur_env_rslider": [ - 0.5, - 2 - ], - "entrances_probs_dur_env_input_max": 2, - "entrances_probs_dur_env_input_min": 0.5, - "entrances_probs_dur_env_mpos": "", - "entrances_probs_dur_env": -1, - "passages_probs_dur_env_vals": [ - 0.5, - 2, - 0, - 0.5, - 0.20725388601036, - 0.68581081081081, - 0.24093264248705, - 0.34121621621622, - 0.5, - 0.5, - 0.67616580310881, - 0.81081081081081, - 1, - 0.5 - ], - "passages_probs_dur_env_canvas": [ - [ - 0, - 0.5 - ], - [ - 0.20725388601036, - 0.68581081081081 - ], - [ - 0.24093264248705, - 0.34121621621622 - ], - [ - 0.5, - 0.5 - ], - [ - 0.67616580310881, - 0.81081081081081 - ], - [ - 1, - 0.5 - ], - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - ], - "passages_probs_dur_env_size": 6, - "passages_probs_dur_env_flatten": 0, - "passages_probs_dur_env_rslider": [ - 0.5, - 2 - ], - "passages_probs_dur_env_input_max": 2, - "passages_probs_dur_env_input_min": 0.5, - "passages_probs_dur_env_mpos": "", - "passages_probs_dur_env": -1, - "exits_probs_dur_env_vals": [ - 0.5, - 2, - 0, - 0.5, - 0.20725388601036, - 0.68581081081081, - 0.24093264248705, - 0.34121621621622, - 0.5, - 0.5, - 0.67616580310881, - 0.81081081081081, - 1, - 0.5 - ], - "exits_probs_dur_env_canvas": [ - [ - 0, - 0.5 - ], - [ - 0.20725388601036, - 0.68581081081081 - ], - [ - 0.24093264248705, - 0.34121621621622 - ], - [ - 0.5, - 0.5 - ], - [ - 0.67616580310881, - 0.81081081081081 - ], - [ - 1, - 0.5 - ], - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - ], - "exits_probs_dur_env_size": 6, - "exits_probs_dur_env_flatten": 0, - "exits_probs_dur_env_rslider": [ - 0.5, - 2 - ], - "exits_probs_dur_env_input_max": 2, - "exits_probs_dur_env_input_min": 0.5, - "exits_probs_dur_env_mpos": "", - "exits_probs_dur_env": -1 -} \ No newline at end of file diff --git a/resources/tmp/tmp_mus_model.json b/resources/tmp/tmp_mus_model.json deleted file mode 100644 index 88d2ead..0000000 --- a/resources/tmp/tmp_mus_model.json +++ /dev/null @@ -1,70 +0,0 @@ -{ -"music_data": -[ - [ - [ - [ [ [ "Rest" ], [ "Rest" ], [ 1, -1, 0, -1, 1, -1 ], [ "Rest" ] ], 0 ], - [ [ [ "Rest" ], [ 2, -2, 0, -1, 1, 0 ], [ 1, -1, 0, -1, 1, -1 ], [ "Rest" ] ], 0.625 ], - [ [ [ 1, -1, 0, -1, 1, 0 ], [ 2, -2, 0, -1, 1, 0 ], [ 1, -1, 0, -1, 1, -1 ], [ "Rest" ] ], 2.5 ], - [ [ [ 1, -1, 0, -1, 1, 0 ], [ 2, -2, 0, -1, 1, 0 ], [ 1, -1, 0, -1, 1, -1 ], [ 2, -1, -1, -1, 1, 0 ] ], 1 ], - [ [ [ 1, -1, 0, -1, 1, 0 ], [ 2, -2, 0, -1, 1, 0 ], [ 1, -1, 0, -1, 1, -1 ], [ 2, -1, 1, -1, 1, -1 ] ], 3.875 ] - ], - [ - [ [ [ 1, -1, 0, -1, 1, 0 ], [ 2, -2, 0, -1, 1, 0 ], [ "Rest" ], [ 2, -1, 1, -1, 1, -1 ] ], 2 ], - [ [ [ 1, -1, 0, -1, 1, 0 ], [ 2, -1, 0, -1, 1, -1 ], [ "Rest" ], [ 2, -1, 1, -1, 1, -1 ] ], 6.5 ] - ], - [ - [ [ [ "Rest" ], [ 2, -1, 0, -1, 1, -1 ], [ "Rest" ], [ 2, -1, 1, -1, 1, -1 ] ], 0 ], - [ [ [ "Rest" ], [ 2, -1, 0, -1, 1, -1 ], [ "Rest" ], [ "Rest" ] ], 0.75 ], - [ [ [ "Rest" ], [ 2, -1, 0, -1, 1, -1 ], [ 2, -1, 0, 0, 1, -1 ], [ "Rest" ] ], 1.125 ], - [ [ [ "Rest" ], [ 2, -1, 0, -1, 1, -1 ], [ 2, -1, 0, -1, 1, 0 ], [ "Rest" ] ], 4.5 ] - ], - [ - [ [ [ "Rest" ], [ 2, -1, 0, -1, 1, -1 ], [ 2, -1, 0, -1, 1, 0 ], [ 2, -1, 1, -1, 1, -1 ] ], 0.875 ], - [ [ [ "Rest" ], [ 2, -1, 0, -2, 1, 0 ], [ 2, -1, 0, -1, 1, 0 ], [ 2, -1, 1, -1, 1, -1 ] ], 1.25 ], - [ [ [ "Rest" ], [ 1, 0, 1, -1, 1, -1 ], [ 2, -1, 0, -1, 1, 0 ], [ 2, -1, 1, -1, 1, -1 ] ], 3.75 ] - ], - [ - [ [ [ "Rest" ], [ 1, -1, 1, -1, 1, 0 ], [ 2, -1, 0, -1, 1, 0 ], [ 2, -1, 1, -1, 1, -1 ] ], 1 ], - [ [ [ "Rest" ], [ 2, -2, 0, -1, 1, 0 ], [ 2, -1, 0, -1, 1, 0 ], [ 2, -1, 1, -1, 1, -1 ] ], 3.75 ], - [ [ [ "Rest" ], [ 2, -2, 0, -1, 1, 0 ], [ 2, -1, 0, -1, 1, 0 ], [ "Rest" ] ], 2 ], - [ [ [ "Rest" ], [ "Rest" ], [ 2, -1, 0, -1, 1, 0 ], [ "Rest" ] ], 0 ], - [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 4.5 ] - ] - ] -], -"last_changes": -[ - [ [ 1, -1, 0, -1, 1, 0 ], [ 2, -1, 0, -1, 1, -1 ], [ 2, -1, 0, -1, 1, 0 ], [ 2, -1, 1, -1, 1, -1 ] ], - [ [ 1, -1, 0, -1, 1, 0 ], [ 2, -1, 0, -2, 1, 0 ], [ 2, -1, 0, -1, 1, 0 ], [ 2, -1, 1, -1, 1, -1 ] ], - [ [ 1, -1, 0, -1, 1, 0 ], [ 1, 0, 1, -1, 1, -1 ], [ 2, -1, 0, -1, 1, 0 ], [ 2, -1, 1, -1, 1, -1 ] ], - [ [ 1, -1, 0, -1, 1, 0 ], [ 1, -1, 1, -1, 1, 0 ], [ 2, -1, 0, -1, 1, 0 ], [ 2, -1, 1, -1, 1, -1 ] ], - [ [ 1, -1, 0, -1, 1, 0 ], [ 2, -2, 0, -1, 1, 0 ], [ 2, -1, 0, -1, 1, 0 ], [ 2, -1, 1, -1, 1, -1 ] ] -], -"cur_uid": "tmp", -"ref_uid": "6fb60ab6", -"order_seed": 499586, -"dur_seed": 134526, -"motifs_seed": 636998, -"entrances_probs_vals": [ 0.34, 0.99, 3.1746031746032, 0.5, 2, 0, 0.5, 0.5, 0.5, 1, 0.5 ], -"passages_probs_vals": [ 0.34, 1.5873015873016, 4.7222222222222, 0.5, 2.1153846153846, 0, 0.5, 0.5, 0.5, 1, 0.5 ], -"exits_probs_vals": [ 0.34, 0.32, 1.9444444444444, 0.5, 2.12, 0, 0.5, 0.5, 0.5, 1, 0.5 ], -"ranges": [ [ -3600, -312.07430340557 ], [ -1872, 1378.3281733746 ], [ -144.89164086687, 1582.6625386997 ], [ -182.04334365325, 1527 ] ], -"step_probs_vals": [ 0, 1200, 0, 0, 0.082304526748971, 0.99431818181818, 0.14197530864198, 0, 1, 0 ], -"passages_weights": [ 0.75, 0.75, 0.75, 0.75, 0.75 ], -"hd_exp": 2, -"hd_invert": 0, -"order": -[ - [ [ 2, 1, 0 ], [ 3, 3 ], [ ] ], - [ [ 3, 0 ], [ 1 ], [ 2 ] ], - [ [ 1 ], [ 2, 2 ], [ 0, 3 ] ], - [ [ 3, 2 ], [ 1, 1 ], [ 0 ] ], - [ [ 3, 2 ], [ 1, 1 ], [ 0 ] ] -], -"sus_weights": [ 0.75, 0.25, 0.25 ], -"order_size": [ 3, 6 ], -"passages_size": [ 0, 3 ], -"motif_edited": "false", -"order_edited": "false" -} \ No newline at end of file diff --git a/supercollider/seeds_and_ledgers_backend.scd b/supercollider/seeds_and_ledgers_backend.scd index bf1611a..8e9fe42 100644 --- a/supercollider/seeds_and_ledgers_backend.scd +++ b/supercollider/seeds_and_ledgers_backend.scd @@ -33,7 +33,7 @@ var entrancesDurFunc, passagesDurFunc, exitsDurFunc, stepFunc; // other global vars var popSize, exPath, dir, primes, dims, tuples, -group, player, ledgerPath, ledger, currentlyPlayingUID, +group, player, resourceDir, ledgerPath, ledger, currentlyPlayingUID, nameSpaces; // install JSON quark (not used) @@ -617,14 +617,21 @@ globalVarsToDict = { loadLedgerFile = {arg path; ledgerPath = path; + resourceDir = path.splitext(".").drop(-1).join; loadLedgerJSON.value(File(ledgerPath, "r").readAllString.parseJSON) }; loadLedgerJSON = {arg jsonObject; ledger = jsonObject["ledger"]}; saveLedger = {arg ledger, path; - var file; + var file, curResourceDir; file = File(path, "w"); + curResourceDir = resourceDir; + resourceDir = path.splitext(".").drop(-1).join; + File.mkdir(resourceDir); + ledger.do({arg id; + File.copy(curResourceDir +/+ id, resourceDir +/+ id); + }); file.write("{\n\"ledger\":\n" ++ stringifyToDepth.value(ledger, 1) ++ "\n}"); file.close; }; @@ -642,6 +649,7 @@ tuples = genTuples.value(); group = Group.new; ~group = group; loadLedgerFile.value(dir +/+ ".." +/+ "resources" +/+ "piece_ledger.json"); +resourceDir = (dir +/+ ".." +/+ "resources" +/+ "piece_ledger"); //passagesWeights = [1, 1, 1, 1, 1]; //susWeights = [1, 1, 1]; // order really matters!!!! @@ -694,7 +702,7 @@ OSCdef(\generate, {arg msg, time, addr, port; if(refUID == nil, {lastXChanges = [initVoices.value().deepCopy]}); if((refUID != nil) && (refUID != "tmp"), { var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); + file = File((resourceDir +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); lastXChanges = msgInterpret.value(file.readAllString.parseJSON["last_changes"]); }); @@ -746,10 +754,10 @@ OSCdef(\commit, {arg msg, time, addr, port; lastCurUID = curUID.deepCopy; curUID = genUID.value; - File.mkdir((dir +/+ ".." +/+ "resources" +/+ curUID).standardizePath); - File.copy(exPath, (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_code" ++ ".scd").standardizePath); + File.mkdir((resourceDir +/+ curUID).standardizePath); + File.copy(exPath, (resourceDir +/+ curUID +/+ curUID ++ "_code" ++ ".scd").standardizePath); - modelPath = (dir +/+ ".." +/+ "resources" +/+ curUID +/+ curUID ++ "_mus_model" ++ ".json").standardizePath; + modelPath = (resourceDir +/+ curUID +/+ curUID ++ "_mus_model" ++ ".json").standardizePath; dict = globalVarsToDict.value; if(musicChanged, { seq = musicData; @@ -812,7 +820,7 @@ OSCdef(\transport, {arg msg, time, addr, port; if(((indexStart == (ledger.size - 1)) && cuedSeek).not, { ledger[indexStart..indexEnd].do({arg uid, index; var path, file; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; + path = (resourceDir +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; file = File(path, "r"); pSeq = pSeq.add([msgInterpret.value(file.readAllString.postln.parseJSON["music_data"]), path, indexStart + index, uid]); file.close; @@ -820,7 +828,7 @@ OSCdef(\transport, {arg msg, time, addr, port; }); if(cuedSeek, { var path, file; - path = (dir +/+ ".." +/+ "resources/tmp/tmp_mus_model" ++ ".json").standardizePath; + path = (resourceDir +/+ "tmp/tmp_mus_model" ++ ".json").standardizePath; file = File(path, "r"); pSeq = pSeq.add([msgInterpret.value(file.readAllString.parseJSON["music_data"]), path, ledger.size - 1, "tmp"]); file.close; @@ -849,7 +857,7 @@ OSCdef(\transcribe_motif, {arg msg, time, addr, port; if((refUID != "nil") && (refUID != "tmp"), { var file; - file = File((dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); + file = File((resourceDir +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath, "r"); refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; file.close; }, { @@ -880,7 +888,7 @@ OSCdef(\transcribe_all, {arg msg, time, addr, port; ledger[indexStart..indexEnd].do({arg uid, index; var path, file, fileString, tSeq, refUID, refChord; - path = (dir +/+ ".." +/+ "resources" +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; + path = (resourceDir +/+ uid +/+ uid ++ "_mus_model" ++ ".json").standardizePath; file = File(path, "r"); fileString = file.readAllString; tSeq = msgInterpret.value(fileString.parseJSON["music_data"]); @@ -893,20 +901,20 @@ OSCdef(\transcribe_all, {arg msg, time, addr, port; refChord = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; if(refUID != "nil", { - path = (dir +/+ ".." +/+ "resources" +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath; + path = (resourceDir +/+ refUID +/+ refUID ++ "_mus_model" ++ ".json").standardizePath; file = File(path, "r"); refChord = msgInterpret.value(file.readAllString.parseJSON["last_changes"]).last; file.close; }); if(index != indexEnd, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath); + ~transcribe.value(tSeq, refChord, (resourceDir +/+ uid +/+ "lilypond").standardizePath); }, { - ~transcribe.value(tSeq, refChord, (dir +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond").standardizePath, addr, "/transcribe_all"); + ~transcribe.value(tSeq, refChord, (resourceDir +/+ uid +/+ "lilypond").standardizePath, addr, "/transcribe_all"); }); lilyPartLedgerFiles.do({arg f, p; - f.write("\\include \".." +/+ ".." +/+ "resources" +/+ uid +/+ "lilypond" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly\"\n"); + f.write("\\include \"" ++ resourceDir +/+ uid +/+ "lilypond" +/+ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly\"\n"); }); }); diff --git a/supercollider/seeds_and_ledgers_transcriber.scd b/supercollider/seeds_and_ledgers_transcriber.scd index 19e394c..cfe72b1 100644 --- a/supercollider/seeds_and_ledgers_transcriber.scd +++ b/supercollider/seeds_and_ledgers_transcriber.scd @@ -286,7 +286,7 @@ consolidateNotes = {arg lyStr, part; tmpSectionData, pcRoot, partLookup, quality; //create file - lyFile = File((basePath +/+ /*"includes" +/+ */ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly").standardizePath,"w"); + lyFile = File((basePath.postln +/+ /*"includes" +/+ */ "part_" ++ ["IV", "III", "II", "I"][p] ++ ".ly").standardizePath,"w"); //start lypond directives lyStr = ""; diff --git a/supercollider/seeds_and_ledgers_utilities.scd b/supercollider/seeds_and_ledgers_utilities.scd new file mode 100644 index 0000000..b3a2fd2 --- /dev/null +++ b/supercollider/seeds_and_ledgers_utilities.scd @@ -0,0 +1,129 @@ +//transposing and swapping parts +( + +var stringifyToDepth, transpose, swap; + +stringifyToDepth = {arg data, maxDepth = 1; + var prettyString = "", rCount = 0, writeArray, indent; + + if(maxDepth == 0, { + data.asCompileString + }, { + indent = {arg size; size.collect({" "}).join("")}; + writeArray = {arg array; + prettyString = prettyString ++ indent.value(rCount) ++ "[\n"; + rCount = rCount + 1; + if(rCount < maxDepth, { + array.do({arg subArray; writeArray.value(subArray)}); + }, { + prettyString = prettyString ++ array.collect({arg subArray; + indent.value(rCount + 1) ++ subArray.asCompileString + }).join(",\n"); + }); + rCount = rCount - 1; + prettyString = prettyString ++ "\n" ++ indent.value(rCount) ++ "],\n"; + }; + + writeArray.value(data); + prettyString.replace(",\n\n", "\n").drop(-2); + }) +}; + +transpose = {arg data, trans; + var res; + res = data.collect({arg x; + x.collect({arg y; + y.collect({arg z; + [z[0].collect({arg item; if(item == ["Rest"], {item}, {item + trans })}), z[1]]})})}); +}; + +swap = {arg data, swaplist; + var res; + res = data.collect({arg x; + x.collect({arg y; + y.collect({arg z; + var cur; + cur = z[0]; + [ + swaplist.do({arg curSwap; curSwap.postln; cur = cur.postln.swap(curSwap[0], curSwap[1])}); cur, + z[1] + ] + }) + }) + }); +}; + +c = [ + [ + [ + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 0.625 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ], [ 0, 1, 0, 0, 0, 0 ] ], 0 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 1, 0, 0, 0, 0, -1 ], [ 0, 1, 0, 0, 0, 0 ] ], 1.75 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 1, 0, 0, 0, 0, -1 ], [ 1, 0, 0, 0, -1, 0 ] ], 1.875 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 1, 0, 0, 0, 0, -1 ], [ 0, 0, 0, 0, 1, 0 ] ], 1.5 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ 1, 0, 0, 0, 0, -1 ], [ 0, 0, 1, 0, 0, 0 ] ], 0.75 ], + [ [ [ 0, 0, 0, 0, 0, 0 ], [ "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 0, 0, 0, 0, 0, 0 ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 0 ], + [ [ [ "Rest" ], [ "Rest" ], [ "Rest" ], [ "Rest" ] ], 1.25 ] + ] + ] +]; + +c = transpose.value(c, [ 1, -1, 0, -1, 1, 0 ]); + +f = File("tweak.txt", "w"); + +f.write(stringifyToDepth.value(c, 3)); +f.close; +) + +//reorganize existing file structure so each ledger has its own resource folder for easier pruning +( +var ledgerName, ledger, path; + +ledger = [ + "314s49e1", + "4c01589b", + "7e170ef8", + "7ac10d34", + "640eeed3", + "5e947063", + "5cf1e9ab", + "7aa8c429", + "7ead41c3", + "62b894e8", + "628d5c8b", + "55930f4d", + "4cf4476d", + "6abf27d4", + "46a0e6a8", + "6be1486c", + "7000ae3e", + "69a72421", + "6506161e", + "65c4abeb", + "661a850b", + "46f2010f" +]; + +ledgerName = "piece_ledger"; +path = "/home/mwinter/Sketches/seeds_and_ledgers/source/resources"; + +File.mkdir(path +/+ ledgerName); + +ledger.do({arg id; id.postln; File.copy(path +/+ id, path +/+ ledgerName +/+ id)}); + +) +