From 6129f9afe8448340e2d7ded9ff595b308a852cb3 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Fri, 4 Nov 2022 20:13:25 +0100 Subject: [PATCH 1/9] fix: mini repl test tune --- packages/react/src/App.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react/src/App.jsx b/packages/react/src/App.jsx index 61e81f2d..7cec6382 100644 --- a/packages/react/src/App.jsx +++ b/packages/react/src/App.jsx @@ -16,7 +16,7 @@ evalScope( function App() { return (
- +
); } From 89434fc3bdea5d34f79bcf7ac0fc0156b120d652 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Fri, 4 Nov 2022 20:14:47 +0100 Subject: [PATCH 2/9] replace old snippet --- packages/embed/README.md | 25 ++++++++++++++++--------- packages/embed/example.html | 25 ++++++++++++++++--------- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/packages/embed/README.md b/packages/embed/README.md index b0ccf52b..f293c931 100644 --- a/packages/embed/README.md +++ b/packages/embed/README.md @@ -10,15 +10,22 @@ Either install with `npm i @strudel.cycles/embed` or just use a cdn to import th ``` diff --git a/packages/embed/example.html b/packages/embed/example.html index 9e6fca15..4470210b 100644 --- a/packages/embed/example.html +++ b/packages/embed/example.html @@ -2,14 +2,21 @@ From 4fc7ef698a808b5904ab8d12ef7260a22095ba68 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Fri, 4 Nov 2022 20:14:57 +0100 Subject: [PATCH 3/9] code format --- packages/core/controls.mjs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/core/controls.mjs b/packages/core/controls.mjs index ca9bec08..fec6c39a 100644 --- a/packages/core/controls.mjs +++ b/packages/core/controls.mjs @@ -97,7 +97,7 @@ const generic_params = [ ], /** - * Select the sound bank to use. To be used together with `s`. The bank name (+ "_") will be prepended to the value of `s`. + * Select the sound bank to use. To be used together with `s`. The bank name (+ "_") will be prepended to the value of `s`. * * @name bank * @param {string | Pattern} bank the name of the bank @@ -105,11 +105,7 @@ const generic_params = [ * s("bd sd").bank('RolandTR909') // = s("RolandTR909_bd RolandTR909_sd") * */ - [ - 'f', - 'bank', - 'selects sound bank to use', - ], + ['f', 'bank', 'selects sound bank to use'], // TODO: find out how this works? /* From 67ee493e563d370dc9bba80ccda6a95a7a9e0a13 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Fri, 4 Nov 2022 20:15:11 +0100 Subject: [PATCH 4/9] remove cross import + code format --- packages/mini/mini.mjs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/mini/mini.mjs b/packages/mini/mini.mjs index 416203e2..82ed4b86 100644 --- a/packages/mini/mini.mjs +++ b/packages/mini/mini.mjs @@ -6,7 +6,7 @@ This program is free software: you can redistribute it and/or modify it under th import * as krill from './krill-parser.js'; import * as strudel from '@strudel.cycles/core'; -import { addMiniLocations } from '@strudel.cycles/eval/shapeshifter.mjs'; +// import { addMiniLocations } from '@strudel.cycles/eval/shapeshifter.mjs'; const { pure, Pattern, Fraction, stack, slowcat, sequence, timeCat, silence, reify } = strudel; @@ -29,7 +29,10 @@ const applyOptions = (parent) => (pat, i) => { case 'bjorklund': return pat.euclid(operator.arguments_.pulse, operator.arguments_.step, operator.arguments_.rotation); case 'degradeBy': - return reify(pat)._degradeByWith(strudel.rand.early(randOffset * _nextSeed()).segment(1), operator.arguments_.amount); + return reify(pat)._degradeByWith( + strudel.rand.early(randOffset * _nextSeed()).segment(1), + operator.arguments_.amount, + ); // TODO: case 'fixed-step': "%" } console.warn(`operator "${operator.type_}" not implemented`); @@ -112,9 +115,9 @@ export function patternifyAST(ast) { return silence; } if (typeof ast.source_ !== 'object') { - if (!addMiniLocations) { + /* if (!addMiniLocations) { return ast.source_; - } + } */ if (!ast.location_) { console.warn('no location for', ast); return ast.source_; From 698f560d56437e72de73b561846ba7030487713b Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Fri, 4 Nov 2022 20:15:36 +0100 Subject: [PATCH 5/9] export controls from core root --- packages/core/index.mjs | 4 ++-- repl/src/App.jsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/core/index.mjs b/packages/core/index.mjs index 49b7de19..bb45275b 100644 --- a/packages/core/index.mjs +++ b/packages/core/index.mjs @@ -4,10 +4,10 @@ Copyright (C) 2022 Strudel contributors - see . */ -export * from './controls.mjs'; +import controls from './controls.mjs'; export * from './euclid.mjs'; import Fraction from './fraction.mjs'; -export { Fraction }; +export { Fraction, controls }; export * from './hap.mjs'; export * from './pattern.mjs'; export * from './signal.mjs'; diff --git a/repl/src/App.jsx b/repl/src/App.jsx index a89c7a8f..54510857 100644 --- a/repl/src/App.jsx +++ b/repl/src/App.jsx @@ -4,7 +4,6 @@ Copyright (C) 2022 Strudel contributors - see . */ -import controls from '@strudel.cycles/core/controls.mjs'; import { evalScope, evaluate } from '@strudel.cycles/eval'; import { CodeMirror, cx, flash, useHighlighting, useRepl, useWebMidi } from '@strudel.cycles/react'; import { cleanupDraw, cleanupUi, Tone } from '@strudel.cycles/tone'; @@ -15,6 +14,7 @@ import * as tunes from './tunes.mjs'; import { prebake } from './prebake.mjs'; import * as WebDirt from 'WebDirt'; import { resetLoadedSamples, getAudioContext } from '@strudel.cycles/webaudio'; +import { controls } from '@strudel.cycles/core'; import { createClient } from '@supabase/supabase-js'; import { nanoid } from 'nanoid'; @@ -26,7 +26,7 @@ const supabase = createClient( evalScope( Tone, - controls, + controls, // sadly, this cannot be exported from core direclty { WebDirt }, import('@strudel.cycles/core'), import('@strudel.cycles/tone'), From 96c49689ec71999c3ef7f4435e60549ae7944fe9 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Fri, 4 Nov 2022 20:15:46 +0100 Subject: [PATCH 6/9] improve readmes --- packages/mini/README.md | 9 ++++++++ packages/osc/README.md | 4 +++- packages/react/README.md | 44 ++++++++++++++++++++++++++++++++++++++-- 3 files changed, 54 insertions(+), 3 deletions(-) diff --git a/packages/mini/README.md b/packages/mini/README.md index f5e6f4b5..755ba5df 100644 --- a/packages/mini/README.md +++ b/packages/mini/README.md @@ -33,3 +33,12 @@ yields: ## Mini Notation API See "Mini Notation" in the [Strudel Tutorial](https://strudel.tidalcycles.org/tutorial/) + +## Building the Parser + +The parser [krill-parser.js] is generated from [krill.pegjs](./krill.pegjs) using [peggy](https://peggyjs.org/). +To generate the parser, run + +```js +npm run build:parser +``` diff --git a/packages/osc/README.md b/packages/osc/README.md index cb48090d..2c52e2dc 100644 --- a/packages/osc/README.md +++ b/packages/osc/README.md @@ -31,7 +31,9 @@ Now open Supercollider (with the super dirt startup file) Now open the REPL and type: ```js -s(" hh").osc() +s(' hh').osc(); ``` or just [click here](http://localhost:3000/#cygiPGJkIHNkPiBoaCIpLm9zYygp)... + +You can read more about [how to use Superdirt with Strudel the Tutorial](https://strudel.tidalcycles.org/tutorial/#superdirt-api) diff --git a/packages/react/README.md b/packages/react/README.md index 4fc64a8e..ce2e5247 100644 --- a/packages/react/README.md +++ b/packages/react/README.md @@ -1,4 +1,44 @@ # @strudel.cycles/react -This package contains react hooks and components for strudel. -Example coming soon +This package contains react hooks and components for strudel. It is used internally by the Strudel REPL. + +## Install + +```js +npm i @strudel.cycles/react +``` + +## Usage + +Here is a minimal example of how to set up a MiniRepl: + +```jsx +import { evalScope } from '@strudel.cycles/eval'; +import { MiniRepl } from '@strudel.cycles/react'; +import controls from '@strudel.cycles/core/controls.mjs'; +import { prebake } from '../repl/src/prebake.mjs'; + +evalScope( + controls, + import('@strudel.cycles/core'), + import('@strudel.cycles/tonal'), + import('@strudel.cycles/mini'), + import('@strudel.cycles/webaudio'), + /* probably import other strudel packages */ +); + +prebake(); + +export function Repl({ tune }) { + return ; +} +``` + +## Development + +If you change something in here and want to see the changes in the repl, make sure to run `npm run build` inside this folder! + +```js +npm run dev # dev server +npm run build # build package +``` From 230e8e9d4da1226cf295a08ca31d4a5259ba0dbe Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Fri, 4 Nov 2022 20:21:08 +0100 Subject: [PATCH 7/9] revert auto formatted snippet --- packages/osc/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/osc/README.md b/packages/osc/README.md index 2c52e2dc..61a125b5 100644 --- a/packages/osc/README.md +++ b/packages/osc/README.md @@ -31,7 +31,7 @@ Now open Supercollider (with the super dirt startup file) Now open the REPL and type: ```js -s(' hh').osc(); +s(" hh").osc() ``` or just [click here](http://localhost:3000/#cygiPGJkIHNkPiBoaCIpLm9zYygp)... From bdc321df4dfcbda0afecd64182cc4b323ef2661f Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Fri, 4 Nov 2022 20:24:42 +0100 Subject: [PATCH 8/9] update browserslist --- package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index d7a08feb..6a0ee9c3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3314,9 +3314,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001341", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001341.tgz", - "integrity": "sha512-2SodVrFFtvGENGCv0ChVJIDQ0KPaS1cg7/qtfMaICgeMolDdo/Z2OD32F0Aq9yl6F4YFwGPBS5AaPqNYiW4PoA==", + "version": "1.0.30001430", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001430.tgz", + "integrity": "sha512-IB1BXTZKPDVPM7cnV4iaKaHxckvdr/3xtctB3f7Hmenx3qYBhGtTZ//7EllK66aKXW98Lx0+7Yr0kxBtIt3tzg==", "funding": [ { "type": "opencollective", @@ -15537,9 +15537,9 @@ } }, "caniuse-lite": { - "version": "1.0.30001341", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001341.tgz", - "integrity": "sha512-2SodVrFFtvGENGCv0ChVJIDQ0KPaS1cg7/qtfMaICgeMolDdo/Z2OD32F0Aq9yl6F4YFwGPBS5AaPqNYiW4PoA==" + "version": "1.0.30001430", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001430.tgz", + "integrity": "sha512-IB1BXTZKPDVPM7cnV4iaKaHxckvdr/3xtctB3f7Hmenx3qYBhGtTZ//7EllK66aKXW98Lx0+7Yr0kxBtIt3tzg==" }, "caseless": { "version": "0.12.0", From 854692f975be33d1ec2c3bd045e7f2f6ad94202f Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Fri, 4 Nov 2022 20:25:31 +0100 Subject: [PATCH 9/9] use only node 18 to save some energy --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b26f4cb4..7813cf60 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node-version: [16, 17] + node-version: [18] steps: - uses: actions/checkout@v2