From a750490eeada9c269df3cc59739c6f5fe1ce01d9 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Fri, 8 Dec 2023 08:49:03 +0100 Subject: [PATCH 01/15] begin pattern import button --- website/src/repl/panel/PatternsTab.jsx | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/website/src/repl/panel/PatternsTab.jsx b/website/src/repl/panel/PatternsTab.jsx index 1b19c8e0..fba6fbc9 100644 --- a/website/src/repl/panel/PatternsTab.jsx +++ b/website/src/repl/panel/PatternsTab.jsx @@ -44,6 +44,20 @@ export function PatternsTab({ context }) { + {Object.entries(userPatterns).map(([key, up]) => ( ); } - -/* -selectable examples -if example selected - type character -> create new user pattern with exampleName_n - even if -clicking (+) opens the "new" example with same behavior as above -*/ From b03bf9ec3def256b2f643153fcafc56a3fa43919 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Fri, 8 Dec 2023 09:17:43 +0100 Subject: [PATCH 02/15] remove log --- website/src/settings.mjs | 1 - 1 file changed, 1 deletion(-) diff --git a/website/src/settings.mjs b/website/src/settings.mjs index 67d386cf..eaed555b 100644 --- a/website/src/settings.mjs +++ b/website/src/settings.mjs @@ -187,6 +187,5 @@ export function duplicateActivePattern() { } export function setActivePattern(key) { - console.log('set', key); settingsMap.setKey('activePattern', key); } From cec8553fb5e1eb03518bbddd8aea671d7cc39a41 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Fri, 8 Dec 2023 09:18:33 +0100 Subject: [PATCH 03/15] clear sounds + cps on pattern change + similar to shuffle --- website/src/repl/Repl.jsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/website/src/repl/Repl.jsx b/website/src/repl/Repl.jsx index 3d3117ae..7813ae98 100644 --- a/website/src/repl/Repl.jsx +++ b/website/src/repl/Repl.jsx @@ -247,9 +247,15 @@ export function Repl({ embedded = false }) { stop(); } }; - const handleUpdate = (newCode) => { + const handleUpdate = async (newCode, reset = false) => { + if (reset) { + clearCanvas(); + resetLoadedSounds(); + scheduler.setCps(1); + await prebake(); // declare default samples + } (newCode || isDirty) && activateCode(newCode); - logger('[repl] code updated! tip: you can also update the code by pressing ctrl+enter', 'highlight'); + logger('[repl] code updated!'); }; const handleShuffle = async () => { From 10d86ff83522d3eef3df06247f52a0685dfd1ed3 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Fri, 8 Dec 2023 09:18:55 +0100 Subject: [PATCH 04/15] more style + set reset flag --- website/src/repl/panel/PatternsTab.jsx | 91 +++++++++++++++----------- 1 file changed, 52 insertions(+), 39 deletions(-) diff --git a/website/src/repl/panel/PatternsTab.jsx b/website/src/repl/panel/PatternsTab.jsx index fba6fbc9..5cbfc3b3 100644 --- a/website/src/repl/panel/PatternsTab.jsx +++ b/website/src/repl/panel/PatternsTab.jsx @@ -9,7 +9,9 @@ import { duplicateActivePattern, getUserPattern, renameActivePattern, + addUserPattern, } from '../../settings.mjs'; +import { logger } from '@strudel.cycles/core'; function classNames(...classes) { return classes.filter(Boolean).join(' '); @@ -18,16 +20,16 @@ function classNames(...classes) { export function PatternsTab({ context }) { const { userPatterns, activePattern } = useSettings(); return ( -
+

Pattern Collection

-
+
- {Object.entries(userPatterns).map(([key, up]) => ( -
{ - const { code } = up; - setActivePattern(key); - context.handleUpdate(code); - }} - > - {key} - - ))} +

Examples

- {Object.entries(tunes).map(([key, tune]) => ( - { - setActivePattern(key); - context.handleUpdate(tune); - }} - > - {key} - - ))} +
+ {Object.entries(tunes).map(([key, tune]) => ( + { + setActivePattern(key); + context.handleUpdate(tune, true); + }} + > + {key} + + ))} +
); From 8dd0e9600d51030dba058ae6947cb0cd67e65f7e Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Fri, 8 Dec 2023 09:20:42 +0100 Subject: [PATCH 05/15] add some padding --- website/src/repl/panel/PatternsTab.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/src/repl/panel/PatternsTab.jsx b/website/src/repl/panel/PatternsTab.jsx index 5cbfc3b3..880134ce 100644 --- a/website/src/repl/panel/PatternsTab.jsx +++ b/website/src/repl/panel/PatternsTab.jsx @@ -20,7 +20,7 @@ function classNames(...classes) { export function PatternsTab({ context }) { const { userPatterns, activePattern } = useSettings(); return ( -
+

Pattern Collection

From 31cd626820ea8b9b87ddba31082a490b06756f9d Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Fri, 8 Dec 2023 09:30:06 +0100 Subject: [PATCH 06/15] style sounds and patterns tab more consistently --- website/src/repl/panel/PatternsTab.jsx | 3 +-- website/src/repl/panel/SoundsTab.jsx | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/website/src/repl/panel/PatternsTab.jsx b/website/src/repl/panel/PatternsTab.jsx index 880134ce..37cac6f7 100644 --- a/website/src/repl/panel/PatternsTab.jsx +++ b/website/src/repl/panel/PatternsTab.jsx @@ -22,8 +22,7 @@ export function PatternsTab({ context }) { return (
-

Pattern Collection

-
+
+ {!isExample && ( + + )} + {!isExample && ( + + )} +
+
+ )} + +
- - - @@ -66,24 +98,14 @@ export function PatternsTab({ context }) { /> import -
-
- {Object.entries(userPatterns).map(([key, up]) => ( - { - const { code } = up; - setActivePattern(key); - context.handleUpdate(code, true); - }} - > - {key} - - ))} +
From a6f969614e9e080e28f6f2a6a8ae77149763e151 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Fri, 8 Dec 2023 22:24:49 +0100 Subject: [PATCH 10/15] fix: rename cancel --- website/src/settings.mjs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/website/src/settings.mjs b/website/src/settings.mjs index d660b396..620fb890 100644 --- a/website/src/settings.mjs +++ b/website/src/settings.mjs @@ -123,6 +123,10 @@ export function renameActivePattern() { return; } const newName = prompt('Enter new name', activePattern); + if (newName === null) { + // canceled + return; + } if (userPatterns[newName]) { alert('Name already taken!'); return; From 5116bf74ad267a244383ddf9474f7539820f8d96 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Fri, 8 Dec 2023 22:25:05 +0100 Subject: [PATCH 11/15] reorder pattern action buttons --- website/src/repl/panel/PatternsTab.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/website/src/repl/panel/PatternsTab.jsx b/website/src/repl/panel/PatternsTab.jsx index 124ba400..def6cef1 100644 --- a/website/src/repl/panel/PatternsTab.jsx +++ b/website/src/repl/panel/PatternsTab.jsx @@ -28,15 +28,15 @@ export function PatternsTab({ context }) {

{activePattern}

- {!isExample && ( )} + {!isExample && ( )} - {!isExample && ( - )} From 6969800192ae2e34974f44ff616375991e866aef Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Sat, 9 Dec 2023 17:23:24 +0100 Subject: [PATCH 14/15] fix: update button bug --- website/src/repl/Header.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/src/repl/Header.jsx b/website/src/repl/Header.jsx index 5e991f8a..b6f13060 100644 --- a/website/src/repl/Header.jsx +++ b/website/src/repl/Header.jsx @@ -87,7 +87,7 @@ export function Header({ context }) { )}