Compare commits

..

413 Commits

Author SHA1 Message Date
Felix Roos 2d2c671e6f Publish
- @strudel.cycles/eval@0.1.1
 - @strudel.cycles/midi@0.1.1
 - @strudel.cycles/mini@0.1.1
 - @strudel.cycles/react@0.1.2
 - @strudel.cycles/tonal@0.1.1
 - @strudel.cycles/tone@0.1.1
 - @strudel.cycles/webaudio@0.1.1
 - @strudel.cycles/xen@0.1.1
2022-05-20 11:45:07 +02:00
Felix Roos d2f47262de bump core deps 2022-05-20 11:43:39 +02:00
Felix Roos cb13eb7f3b remove now redundant style 2022-05-20 00:15:10 +02:00
Felix Roos 96825f9fcc Publish
- @strudel.cycles/react@0.1.1
2022-05-20 00:09:30 +02:00
Felix Roos 7eeae4292c add missing styles + fix demo 2022-05-20 00:08:50 +02:00
Felix Roos a29c5f1bd8 Publish
- @strudel.cycles/eval@0.1.0
 - @strudel.cycles/midi@0.1.0
 - @strudel.cycles/mini@0.1.0
 - @strudel.cycles/react@0.1.0
 - @strudel.cycles/tonal@0.1.0
 - @strudel.cycles/tone@0.1.0
 - @strudel.cycles/webaudio@0.1.0
 - @strudel.cycles/xen@0.1.0
2022-05-19 19:42:22 +02:00
Felix Roos b7a2386874 messed up everything 2022-05-19 19:40:47 +02:00
Felix Roos 43a0c7e604 fix cp error 2022-05-19 19:36:00 +02:00
Felix Roos 73d8afd61b revert unpublished versions 2022-05-19 19:34:02 +02:00
Felix Roos 87162a9f31 Publish
- @strudel.cycles/core@0.1.0
 - @strudel.cycles/embed@0.1.0
 - @strudel.cycles/eval@0.1.0
 - @strudel.cycles/midi@0.1.0
 - @strudel.cycles/mini@0.1.0
 - @strudel.cycles/osc@0.1.0
 - @strudel.cycles/react@0.1.0
 - @strudel.cycles/serial@0.1.0
 - @strudel.cycles/tonal@0.1.0
 - @strudel.cycles/tone@0.1.0
 - @strudel.cycles/webaudio@0.1.0
 - @strudel.cycles/xen@0.1.0
2022-05-19 19:13:46 +02:00
Felix Roos c643f10530 tutorial toc 2022-05-19 17:16:28 +02:00
Felix Roos ae81f6d573 MiniRepl: hideOutsideView flag 2022-05-19 08:39:51 +02:00
Felix Roos 44ba1f85c3 clear out before build 2022-05-18 20:40:24 +02:00
Felix Roos f34301b427 fix deploy out 2022-05-18 20:10:41 +02:00
Felix Roos 666cbf6568 add todos 2022-05-18 00:28:24 +02:00
Felix Roos f31a5a4bbb remove old todo 2022-05-18 00:25:51 +02:00
Felix Roos bbf0565007 delete react logo 2022-05-18 00:23:49 +02:00
Felix Roos c41ac9a413 add basic readme 2022-05-18 00:22:26 +02:00
Felix Roos ab1dd27875 hide todo 2022-05-18 00:21:11 +02:00
Felix Roos 788a4c9143 fix tests 2022-05-18 00:18:12 +02:00
Felix Roos 43c2f46196 small fixes 2022-05-18 00:07:37 +02:00
Felix Roos fdb60a3fc1 migrate public files + add deploy script 2022-05-17 22:55:12 +02:00
Felix Roos 6c6ea3ab9f fix favicon 2022-05-17 22:47:35 +02:00
Felix Roos 806c8925c9 new build script + fix draw 2022-05-17 22:45:23 +02:00
Felix Roos ed35f967b0 migrate repl + move imports out of minirepl 2022-05-17 22:27:22 +02:00
Felix Roos 0bcc01ed0e add missing deps 2022-05-17 21:55:37 +02:00
Felix Roos b7fac65a87 add description 2022-05-17 21:45:22 +02:00
Felix Roos 605cb98b8e package meta 2022-05-17 21:43:28 +02:00
Felix Roos b8a0559012 react packaging 2022-05-17 21:40:17 +02:00
Felix Roos fb2f63ee26 unify barrel exports 2022-05-17 21:38:47 +02:00
Felix Roos b59f36f40b basic react package build config 2022-05-17 00:32:57 +02:00
Felix Roos 2a618b42b7 add evalScope + deprecate extend 2022-05-17 00:31:20 +02:00
Felix Roos aa3db09f22 tone barrel export 2022-05-17 00:23:13 +02:00
Felix Roos 9fa01aa6ff add barrel exports 2022-05-17 00:22:50 +02:00
Felix Roos 999251e137 Merge remote-tracking branch 'origin/main' into repl-package 2022-05-15 22:55:31 +02:00
Felix Roos 55d5cc9308 fix asNumber 2022-05-15 22:55:12 +02:00
Alex McLean 58301c380b Merge pull request #113 from tidalcycles/osc-timing
Osc timing improvements
2022-05-15 21:29:25 +01:00
Alex McLean ee45337d89 Merge pull request #114 from tidalcycles/more-functions
loopAt
2022-05-15 21:28:24 +01:00
alex f2e1ee1aac Fix osc timing, and send cps, cycle and delta 2022-05-15 18:49:32 +01:00
alex ee5bc0f3a6 loopAt 2022-05-15 18:38:26 +01:00
Felix Roos 273cb81da0 use Function instead of eval
- fixes scope issues (e.g. seq duplication)
- should be much safer and much faster
2022-05-15 00:35:17 +02:00
Felix Roos 1cbf4c8c7e fix name collision 2022-05-14 23:39:31 +02:00
Felix Roos 446ddc2c11 pull out tutorial 2022-05-14 22:11:29 +02:00
Felix Roos 42d3510c74 migrate tutorial 2022-05-14 21:28:10 +02:00
Felix Roos 92c17d6376 migrate missing files + fix tests 2022-05-14 20:51:00 +02:00
Felix Roos 645ea30b53 use vite for repl 2022-05-14 20:33:55 +02:00
Felix Roos 0d63ec9146 basic react package 2022-05-14 20:27:05 +02:00
Alex McLean 9588272639 Merge pull request #112 from tidalcycles/more-functions
`.brak()`, `.inside()` and `.outside()`
2022-05-09 20:09:46 +02:00
alex aca3bea56b Implement inside/outside 2022-05-09 18:43:02 +01:00
alex a8d676641b brak() fix 2022-05-09 17:24:49 +02:00
alex 4fd843f8cf Implement brak() 2022-05-09 16:56:08 +02:00
alex 73b0a3a0ef build 2022-05-06 15:29:05 +02:00
alex 6dedeae6e1 fix run-license call 2022-05-06 15:28:40 +02:00
Alex McLean 14487ed5cf Merge pull request #105 from tidalcycles/in-source-doc
In source doc
2022-05-06 15:18:41 +02:00
alex 5419b0896c more docs 2022-05-05 18:45:31 +02:00
alex f8f744dd87 standardise on hap rather than event, especially in function names 2022-05-05 17:20:36 +01:00
alex b0dfb44e96 add license to those extracted during javascript minification (temporary hack) 2022-05-05 16:45:32 +01:00
Felix Roos cdc068bb47 build 2022-05-04 23:02:05 +02:00
Felix Roos 09c5c07bfb Merge pull request #109 from tidalcycles/embed-style
Embed style
2022-05-04 22:59:30 +02:00
Felix Roos 56962196ea configure jsdoc to parse all package files 2022-05-04 22:47:13 +02:00
Felix Roos 8b4af5ce9d local testing comments 2022-05-04 22:03:09 +02:00
Felix Roos 8034eb14b6 embedded styles 2022-05-04 22:03:00 +02:00
Felix Roos 2739c89475 Merge remote-tracking branch 'origin/main' into in-source-doc 2022-05-03 08:10:19 +02:00
Alex McLean cf79083edb Merge pull request #88 from tidalcycles/reset
Reset, Restart and other composers
2022-05-03 00:40:22 +01:00
Alex McLean cbe9c9248d Merge branch 'main' into reset 2022-05-03 00:39:25 +01:00
Felix Roos e0c77a5fa8 try out jsdoc-json 2022-05-02 23:17:50 +02:00
Felix Roos 339e91b026 Merge remote-tracking branch 'origin/HEAD' into in-source-doc 2022-05-02 23:08:15 +02:00
Felix Roos 25bfdd80e3 Update README.md
add more link for all packages
2022-05-02 22:48:50 +02:00
Felix Roos 68c6d340ce Merge pull request #106 from tidalcycles/embed
/embed package: web component for repl
2022-05-02 22:47:20 +02:00
Felix Roos 91261b8b3f bump 2022-05-02 22:40:58 +02:00
Felix Roos 6e8bd1ff33 fix example 2022-05-02 22:40:40 +02:00
Felix Roos b01865f0f5 add basic embed package 2022-05-02 22:33:31 +02:00
alex 4319b6d2d1 Merge branch 'main' of github.com:tidalcycles/strudel 2022-05-02 21:27:15 +01:00
alex 53d82e5126 Prettify 2022-05-02 21:27:02 +01:00
Alex McLean 90b74a72ad Add link to packages/serial 2022-05-02 21:22:30 +01:00
alex c23f9b8629 reflect licence change to AGPL 2022-05-02 21:15:25 +01:00
Felix Roos d752d0eb5e Merge remote-tracking branch 'origin/main' into embed 2022-05-02 22:06:02 +02:00
Felix Roos 65fbdba047 Merge pull request #104 from tidalcycles/tune-tests
Tune tests
2022-05-02 22:05:33 +02:00
alex 6273b34254 Support string concatenation for add() and variants 2022-05-02 09:40:06 +01:00
alex 4779dd13c0 _asNumber: support old 'silent' parameter, renamed
as 'dropfails'
2022-05-02 09:22:00 +01:00
alex 469db7d5bd Add ption for asNumber to return original event
on fail.
Make numerical composers use asNumber.
2022-05-01 23:17:21 +01:00
alex 42269cf72b add bossa snapshot 2022-05-01 23:15:22 +01:00
Felix Roos 38bb0ca041 add cycles for all tunes 2022-05-01 23:22:54 +02:00
alex 1949071259 Merge branch 'tune-tests' into reset 2022-05-01 22:19:40 +01:00
Felix Roos a119b83b65 more readable tune test + longer snaps 2022-05-01 23:13:54 +02:00
Felix Roos c939a8a0c1 fix shoot 2022-05-01 22:47:58 +02:00
Felix Roos 5f26773c61 add repl test to root package 2022-05-01 22:35:35 +02:00
Felix Roos 6cac8ba108 basic snapshot test for tunes 2022-05-01 22:34:11 +02:00
Felix Roos 3eebccd566 add showWhole 2022-05-01 22:22:07 +02:00
alex f81190bf35 try adding some pattern docs 2022-05-01 20:46:30 +01:00
alex 065f4191f0 Rename TrigZero -> Trigzero, + more composer tests 2022-05-01 17:34:47 +01:00
alex b2d58ce0bd Use this.duration for things 2022-05-01 17:06:26 +01:00
alex 41b7939dac More composer tests 2022-05-01 17:02:40 +01:00
alex 68c63cca7e Merge branch 'main' into reset 2022-05-01 16:08:42 +01:00
Felix Roos 2348d056cb test jsdoc 2022-05-01 15:40:54 +02:00
Felix Roos f469e48970 build 2022-05-01 14:36:30 +02:00
Felix Roos 7e52fdd5ca Merge pull request #97 from tidalcycles/codemirror-6
Codemirror 6
2022-05-01 14:33:10 +02:00
Felix Roos 29fceff9b3 handle edge case 2022-05-01 14:13:20 +02:00
Felix Roos bdb5dabba5 patch holes in highlighting query span
+ make sure disable-highlighting works again
2022-05-01 11:33:25 +02:00
alex 3fe705427f binary composer fixes 2022-04-30 19:21:37 +01:00
alex 21a1fe5056 Merge branch 'codemirror-6' into reset 2022-04-30 19:13:41 +01:00
alex e40bdad6c3 Add binary composers 2022-04-30 19:12:24 +01:00
alex dcbe24d45c Merge branch 'main' into reset 2022-04-30 19:02:48 +01:00
Felix Roos d4607c68f7 highlight only events with onsets 2022-04-30 11:14:16 +02:00
alex 026ae3c8e1 reset -> trig, restart -> trigZero, then alias reset -> keepTrig, restart -> keepTrigZero 2022-04-30 09:23:42 +01:00
Felix Roos f6d128842a filter out inactive events 2022-04-29 21:56:15 +02:00
Felix Roos a6dac6ded3 Merge remote-tracking branch 'origin/HEAD' into codemirror-6 2022-04-29 21:33:15 +02:00
Felix Roos 4fcec82917 support custom dynamic highlight color 2022-04-29 21:27:12 +02:00
Felix Roos 9e46b3cd00 fix: dont highlight out of range 2022-04-29 21:14:37 +02:00
Felix Roos d56f151edb Merge branch 'main' of https://github.com/tidalcycles/strudel 2022-04-29 20:39:32 +02:00
Felix Roos 4b49c95e73 fix: .wave 2022-04-29 20:39:28 +02:00
Felix Roos cf922b036e remove old codemirror packages + styles 2022-04-29 20:38:49 +02:00
alex f7dedd6244 Try without the special case for reset/restart 2022-04-29 17:08:00 +01:00
alex 7af3c33814 Tidy and add 'keepif' 2022-04-29 17:03:38 +01:00
alex 8cd3be6f67 Merge branch 'main' into reset 2022-04-29 16:50:50 +01:00
alex 86e8ed2ac0 Trying a different naming scheme for composers 2022-04-29 16:46:17 +01:00
Felix Roos 0d1e7f5c17 fix: .wave 2022-04-29 16:27:43 +02:00
Felix Roos fc9a9e33d2 use cm6 in tutorial
+ move highlighting to hook
+ optimize tutorial loading time
2022-04-29 16:27:23 +02:00
Felix Roos f00e28ced3 Merge pull request #102 from mindofmatthew/codemirror-6-highlights
Work on Codemirror 6 highlighting
2022-04-28 23:45:53 +02:00
Alex McLean 4c29677d5b Merge pull request #101 from tidalcycles/agpl-license
Change to Affero GPL
2022-04-28 14:46:06 +01:00
alex 07b8dc3f76 Merge branch 'agpl-license' of github.com:tidalcycles/strudel into agpl-license 2022-04-28 14:43:13 +01:00
alex ee514ee8ba redo headers 2022-04-28 14:38:41 +01:00
alex 97a0fb3e18 add AGPL headers 2022-04-28 11:06:39 +01:00
Matthew ef42ca692a Work on Codemirror 6 highlighting 2022-04-27 20:57:08 -04:00
alex 9ca49c587c Change to Affero GPL 2022-04-27 09:34:47 +01:00
Alex McLean 3b38d936a8 Merge pull request #98 from tidalcycles/paper
Paper
2022-04-25 23:13:07 +01:00
Felix Roos 7f8cdfa361 revert sound function 2022-04-25 22:49:31 +02:00
Felix Roos 8da4217d69 remove old patched osc-js 2022-04-25 22:48:59 +02:00
Felix Roos d3a04071eb remove duplicate range 2022-04-25 22:47:30 +02:00
Felix Roos 0c5903d822 Merge remote-tracking branch 'origin/HEAD' into paper 2022-04-25 22:43:41 +02:00
Felix Roos f97f8be5a4 Merge remote-tracking branch 'origin/main' into codemirror-6 2022-04-25 22:32:49 +02:00
Alex McLean d2ec9768f1 Merge pull request #90 from tidalcycles/more-functions
Fiddles with cat/stack
2022-04-25 21:10:21 +01:00
Felix Roos 37218e8764 match font size of old editor 2022-04-25 22:04:51 +02:00
Felix Roos 069fff673a fix some bugs 2022-04-25 22:00:18 +02:00
Felix Roos 5aed046b34 fix z-index 2022-04-25 21:32:25 +02:00
Felix Roos 5dea15ade9 remove background color from cm6 theme 2022-04-25 21:25:13 +02:00
Felix Roos 10487683d3 tiny bit of style 2022-04-25 20:46:12 +02:00
Felix Roos 12967f2819 use codemirror 6 2022-04-25 20:34:09 +02:00
alex 07b22a2c28 Tweaks, more inspirations, and figure 2022-04-25 10:41:16 +01:00
alex fe13a7fe34 build 2022-04-24 22:35:00 +01:00
alex 602cac5a35 tweak copyright 2022-04-24 22:34:46 +01:00
alex 11f697fa9c Tweak copyright 2022-04-24 22:34:29 +01:00
alex d5957035fa fix citations, build 2022-04-24 22:16:23 +01:00
alex b80d7d226b Merge branch 'paper' of github.com:tidalcycles/strudel into paper 2022-04-24 21:54:17 +01:00
alex 8564dafbfb Merge branch 'main' into paper 2022-04-24 21:54:11 +01:00
Felix Roos dc66dab237 future outlook + links 2022-04-24 21:36:03 +02:00
Felix Roos a32d77b24d Merge commit '47717e872b87f497990d7c1d6c3d54bfb96f2003' into paper 2022-04-24 21:00:54 +02:00
Felix Roos 23836e2345 fix reset / restart default method 2022-04-24 21:00:11 +02:00
alex 1a5c95d084 Merge branch 'more-functions' of github.com:tidalcycles/strudel into more-functions 2022-04-24 17:51:41 +01:00
alex 6a6464b0f7 Remove append, fixes #89 2022-04-24 17:51:31 +01:00
alex 60027e664f Try 'keep' instead of 'const' 2022-04-24 14:38:33 +01:00
alex 27ff329981 Prettify 2022-04-24 11:30:13 +01:00
alex df5ffb4736 Tidy up composers, supporting function patterns 2022-04-24 11:27:52 +01:00
alex a194b908e7 Export unionWithObj 2022-04-24 11:26:33 +01:00
alex 79f5faa544 Merge branch 'reset' of github.com:tidalcycles/strudel into reset 2022-04-24 01:04:14 +01:00
alex 5c3f095ef2 Experimental rejig of the pattern composers.
Now `restart` is `setRestart`, use `constRestart` for the old behavior.
Same for `reset`.
2022-04-24 01:02:32 +01:00
Felix Roos 283e5fde69 fix drawLine polyrhythm 2022-04-24 01:40:26 +02:00
Felix Roos f96ca562a2 fix restart overlap 2022-04-24 01:27:44 +02:00
Felix Roos 58a936cf33 test silence 2022-04-24 00:59:38 +02:00
Felix Roos a0d6fc47e0 improve drawLine 2022-04-24 00:56:16 +02:00
Felix Roos dd03ad6c14 support stack in drawLine 2022-04-24 00:34:04 +02:00
Felix Roos 2bbd306b94 drawLine test 2022-04-23 23:47:52 +02:00
Felix Roos 766cccf335 refactor event.duration references 2022-04-23 23:36:26 +02:00
Felix Roos 9e2e5ce581 log + drawLine 2022-04-23 23:28:43 +02:00
Felix Roos e747c0b060 remove featurelist as it's now kept up to date in #31 2022-04-23 21:08:58 +02:00
Felix Roos 67bef933be migrate tutorial cat -> seq 2022-04-23 20:38:51 +02:00
Felix Roos f1c0d8c8f8 refactor cat -> seq 2022-04-23 20:27:40 +02:00
Felix Roos dd2552eda8 add seq to factories for highlighting 2022-04-23 20:27:16 +02:00
Felix Roos ab9871640a add todo 2022-04-23 17:38:29 +02:00
alex 615f71b099 Fix evaluate test with new cat behaviour ref #87 2022-04-23 11:11:45 +01:00
alex ff418c9f0c seq -> sequence shorthand ref #87 2022-04-23 11:10:05 +01:00
alex 4c43d3d850 Make sequence a fastcat alias and change cat to be a slowcat ref #87 2022-04-23 11:01:12 +01:00
alex a4cacc079e Support subpattern sequences in stack like slowcat in ref #87 2022-04-23 09:47:12 +01:00
alex 9df20fcbc5 support catting subpatterns, fixes #87 2022-04-23 09:38:05 +01:00
alex f4dd549a41 Merge branch 'main' into more-functions 2022-04-23 09:21:47 +01:00
alex cc445e89a3 cat/append/fastcat/slowcat as pattern methods 2022-04-23 09:21:40 +01:00
Felix Roos 08f8a7a17c restart example 2022-04-22 23:47:05 +02:00
Felix Roos ab14d70c6c rename to restart 2022-04-22 23:01:37 +02:00
Felix Roos ecfc6fd31e simplify 2022-04-22 22:52:11 +02:00
Felix Roos 0fae8b2b10 first take at reset 2022-04-22 22:21:43 +02:00
Felix Roos c38e4f7206 helper functions 2022-04-22 22:21:36 +02:00
alex 47717e872b test for negative time, ref #85 2022-04-22 17:06:15 +01:00
alex 903c065e26 Use mathematical mod in slowcat, fixes #85 2022-04-22 17:02:21 +01:00
alex 3742bf384c Remove recursion from mod 2022-04-22 17:01:28 +01:00
alex 1029f8674c fix the fix for echo 2022-04-22 12:35:43 +01:00
alex c801660b2a use rational multiplication in echo 2022-04-22 12:30:16 +01:00
alex 48d4541ed7 build 2022-04-22 12:12:11 +01:00
Alex McLean 8007ea6a7e Merge pull request #83 from tidalcycles/pattern-composers
Add pattern composers, implements #82
2022-04-22 12:08:11 +01:00
alex 8e441ecb19 fix striate: union -> set 2022-04-22 12:07:23 +01:00
alex c305e82f5c Merge branch 'main' into pattern-composers 2022-04-22 11:52:36 +01:00
alex 87cfa30508 Extra test for ply (and prettify) 2022-04-22 11:51:41 +01:00
alex 2c224d5092 Make comparisons rational in _compress 2022-04-22 11:46:34 +01:00
Felix Roos 72eeaf446e fix: cycleArg imprecise fraction operation 2022-04-22 12:40:23 +02:00
Felix Roos 51a806b0ba Merge branch 'main' of https://github.com/tidalcycles/strudel 2022-04-22 11:49:42 +02:00
Felix Roos 52840f9141 add tune + fix another 2022-04-22 11:48:57 +02:00
alex 974503160d squeezeflip, tests for add including failing one.. 2022-04-22 09:51:44 +01:00
alex d9e3ff3256 Tests for set, setFlip and setSqueeze 2022-04-22 09:27:23 +01:00
alex b510ab0371 Make set work for primative patterns, allow ops accept sequence 2022-04-22 09:26:39 +01:00
Felix Roos 5eba78d795 Merge pull request #84 from mindofmatthew/tidying
Tidy up a couple of old files
2022-04-21 20:57:45 +02:00
Matthew Kaney 884c13a22d Remove old files 2022-04-21 13:14:37 -04:00
Alex McLean 90c5605409 Merge pull request #76 from tidalcycles/more-functions
add `striate()`
2022-04-21 14:21:29 +01:00
alex 3ae6443c59 Tidy test and console logs 2022-04-21 14:17:28 +01:00
alex b370c405da Add pattern composers, implements #82 2022-04-21 14:13:26 +01:00
Felix Roos 36d1a68b9a build 2022-04-20 20:22:50 +02:00
Felix Roos 58bbbecb2d package-lock 2022-04-20 20:19:56 +02:00
Felix Roos 1cdff32b5c Merge pull request #77 from tidalcycles/webaudio-compat
Webaudio in REPL
2022-04-20 20:17:26 +02:00
Felix Roos 7dbdb005b0 fix adsr + add example tune 2022-04-20 20:15:36 +02:00
Felix Roos e6c15dc3c5 add waa example 2022-04-19 21:46:44 +02:00
Felix Roos 1778d19bde Merge remote-tracking branch 'origin/main' into webaudio-compat 2022-04-19 21:35:08 +02:00
alex 56c3c0462c build 2022-04-19 18:16:00 +01:00
Alex McLean 80102353d6 Merge pull request #80 from tidalcycles/webserial
Basic webserial support
2022-04-19 14:31:34 +01:00
alex d7dc158861 Tidy up 2022-04-19 14:28:16 +01:00
alex b52c42c31d First go at serial output 2022-04-19 13:40:01 +01:00
Felix Roos f8739e341b respect midi numbers 2022-04-18 18:57:28 +02:00
Felix Roos 1ead12a2a3 patternify filter 2022-04-18 18:57:02 +02:00
Felix Roos c2feb6e214 remove logs 2022-04-18 18:45:18 +02:00
Felix Roos 3d74b8a2fa Merge commit '83a46c68dc6583ad36b256bc0d03e0913ecbc1f0' into webaudio-compat 2022-04-18 18:33:47 +02:00
Felix Roos 83a46c68dc webaudio@0.0.6 2022-04-18 15:03:11 +02:00
Felix Roos bcefce9df7 package-lock 2022-04-18 14:54:19 +02:00
Felix Roos dcb5af3339 fix: core imports in scheduler 2022-04-18 14:51:47 +02:00
alex 1d56d79757 add striate() 2022-04-17 23:18:01 +01:00
alex 0b370bd40d Make intersection_e actually raise an exception 2022-04-17 18:38:34 +01:00
alex 07a5ae83b5 build 2022-04-17 18:31:20 +01:00
Alex McLean cc60addbaa Merge pull request #75 from tidalcycles/more-tests
Try to fix appLeft / appRight
2022-04-17 18:29:48 +01:00
alex 30b7429169 Fix appLeft/appRight to discard nonmatching events 2022-04-17 18:28:55 +01:00
alex 28ebf6559e Fix steady() 2022-04-17 18:25:38 +01:00
alex 1c6e3dd9a6 A couple of tests for continuous haps/patterns 2022-04-17 18:23:34 +01:00
Felix Roos 6bba661e24 experiment with passing time to withAudioNode 2022-04-17 12:01:13 +02:00
alex eccb20c3b7 Fix choose and add weighted wchoose 2022-04-16 23:23:15 +01:00
Felix Roos f210c4425b make webaudio compatible with repl
+ rename osc to wave
+ migrate repl.html
2022-04-16 21:39:14 +02:00
Felix Roos e0e3ab941e remove experimental tone tutorial 2022-04-16 21:38:23 +02:00
Felix Roos 9cc568fe3e remove tonejs experimental features 2022-04-16 21:36:10 +02:00
Felix Roos a638f9505f test fromMidi + getFrequency 2022-04-16 21:34:19 +02:00
Felix Roos 1b35dd0c55 add preliminary getFrequency 2022-04-16 21:34:05 +02:00
alex d394b4939f build 2022-04-16 18:34:11 +01:00
alex c751d4eb79 Make sure random numbers are positive 2022-04-16 18:32:17 +01:00
alex bb147abb7f Merge branch 'main' of github.com:tidalcycles/strudel 2022-04-16 15:06:02 +01:00
alex 1c3793e2ef Add someCycles and someCyclesBy 2022-04-16 15:05:56 +01:00
alex 1274641f89 Tweak applicative 2022-04-16 15:05:37 +01:00
Felix Roos 803b50535f add repl link 2022-04-16 15:49:40 +02:00
Felix Roos 028af735c9 remove mini for now 2022-04-16 15:46:48 +02:00
Felix Roos d42cd6efaf Publish
- @strudel.cycles/mini@0.0.7
 - @strudel.cycles/webaudio@0.0.5
2022-04-16 15:37:05 +02:00
Felix Roos 2cf129408b use skypack in example 2022-04-16 15:36:49 +02:00
Felix Roos 0ed1c75c38 fix core dependency 2022-04-16 15:35:01 +02:00
Felix Roos 5588b62b40 Publish
- @strudel.cycles/webaudio@0.0.4
2022-04-16 15:24:40 +02:00
Felix Roos 03cb80b75b add core dependeny 2022-04-16 15:24:24 +02:00
Felix Roos 86a3fd6e22 Publish
- @strudel.cycles/webaudio@0.0.3
2022-04-16 15:17:30 +02:00
Felix Roos 27ebe7ba73 stub change 2022-04-16 15:17:02 +02:00
Felix Roos 0ce2dcacef Publish
- @strudel.cycles/core@0.0.5
 - @strudel.cycles/eval@0.0.5
 - @strudel.cycles/midi@0.0.6
 - @strudel.cycles/mini@0.0.6
 - @strudel.cycles/tonal@0.0.5
 - @strudel.cycles/tone@0.0.6
 - @strudel.cycles/xen@0.0.5
2022-04-16 15:14:29 +02:00
Felix Roos 6c8fc6bb21 core publish 2022-04-16 15:12:06 +02:00
Felix Roos 0e26d4e741 Publish
- @strudel.cycles/core@0.0.4
 - @strudel.cycles/eval@0.0.4
 - @strudel.cycles/midi@0.0.5
 - @strudel.cycles/mini@0.0.5
 - @strudel.cycles/osc@0.0.2
 - @strudel.cycles/tonal@0.0.4
 - @strudel.cycles/tone@0.0.5
 - @strudel.cycles/webaudio@0.0.2
 - @strudel.cycles/xen@0.0.4
2022-04-16 15:10:49 +02:00
alex 3d6f01c872 build 2022-04-16 12:39:02 +01:00
alex 4894588284 fix degrade/undegrade 2022-04-16 12:37:47 +01:00
alex 7adea0ac65 build 2022-04-16 12:29:05 +01:00
Alex McLean 138c84cd5f Merge pull request #74 from tidalcycles/more-functions
More random functions
2022-04-16 12:26:57 +01:00
alex d283791f77 Merge branch 'more-functions' of github.com:tidalcycles/strudel into more-functions 2022-04-16 12:24:27 +01:00
alex 911d9d17d6 undegrade, sometimes, sometimesBy, sometimesByPre, often, rarely, almostNever, almostAlways, never, always 2022-04-16 12:19:42 +01:00
alex 8abbaf2e56 undegrade, sometimes, sometimesBy, sometimesByPre, often, rarely, almostNever, almostAlways, never, always 2022-04-16 12:18:44 +01:00
alex dca8b46abf add degrade/degradeBy 2022-04-16 11:40:47 +01:00
Alex McLean 2b968c4387 Merge pull request #73 from tidalcycles/more-functions
Port `perlin` noise, `rangex`, and `palindrome`
2022-04-16 10:13:25 +01:00
alex c88508ace3 tidy 2022-04-16 10:12:01 +01:00
alex b4adbcd6cb Merge branch 'main' into more-functions 2022-04-16 10:10:00 +01:00
alex 031b93f062 fix palindrome 2022-04-16 10:09:47 +01:00
alex f1ac9c4443 perlin noise 2022-04-16 10:03:00 +01:00
alex 544e32e0f8 add 'constant' 2022-04-16 10:02:35 +01:00
Felix Roos f8f806e8eb Merge pull request #26 from tidalcycles/webaudio
webaudio package
2022-04-16 10:26:06 +02:00
Felix Roos 2aed40d99b add example info 2022-04-16 10:24:09 +02:00
Felix Roos d0443a7f41 Merge remote-tracking branch 'origin/HEAD' into webaudio 2022-04-16 10:21:41 +02:00
Felix Roos 1d83ad5282 add randomBells 2022-04-16 00:13:18 +02:00
alex 8fda84c15a palindrome 2022-04-15 22:42:03 +01:00
alex 939bc643be rangex 2022-04-15 22:41:39 +01:00
alex c163039c6e build 2022-04-15 22:06:02 +01:00
Felix Roos 9c6652b19d remove old imports 2022-04-15 21:45:55 +02:00
Felix Roos 2510399017 Merge remote-tracking branch 'origin/HEAD' into webaudio 2022-04-15 20:54:33 +02:00
Felix Roos 9d2cbbaa2c fix notes example 2022-04-15 20:40:58 +02:00
Alex McLean f47d4d0c9d Merge pull request #70 from tidalcycles/more-functions
More randomness, fix `rand`, and add `brand`, `irand` and `choose`
2022-04-15 19:18:06 +01:00
alex f41d89515c Merge branch 'main' into more-functions 2022-04-15 19:15:32 +01:00
alex ea16d6b050 Add choose, fix rand to be unipolar. 2022-04-15 16:05:48 +01:00
alex 19f7dc1657 add brand (boolean rand) and brandBy 2022-04-15 15:05:30 +01:00
alex b674014377 Ignore continuous haps (those without a whole) 2022-04-15 15:04:16 +01:00
Alex McLean 802ed9d481 Merge pull request #69 from tidalcycles/more-functions
First effort at rand()
2022-04-15 10:29:51 +01:00
alex 1f1b20041c Merge branch 'main' of github.com:tidalcycles/strudel into more-functions 2022-04-15 10:15:12 +01:00
alex 3ae0762f62 First effort at rand() 2022-04-15 10:14:51 +01:00
alex 89934886f7 initial demo submission 2022-04-15 08:55:53 +01:00
Felix Roos 233cc4bdc4 update task instructions 2022-04-15 09:33:46 +02:00
alex f278c85f2a more citations 2022-04-14 20:55:07 +01:00
Felix Roos 8dde34565a add speakerman 2022-04-14 19:06:33 +02:00
Felix Roos 14774ae687 build 2022-04-14 18:26:53 +02:00
Felix Roos ed4156530b add build script 2022-04-14 18:18:53 +02:00
Felix Roos 45e8cd104b package-lock 2022-04-14 17:42:51 +02:00
Felix Roos fc195eae1e Merge pull request #68 from tidalcycles/osc-fixed
use new fixed version of osc-js package
2022-04-14 17:41:18 +02:00
Felix Roos 18d8049f37 use new fixed version of osc-js package 2022-04-14 17:37:44 +02:00
alex 21e328569b A bit more blah blah 2022-04-14 09:12:56 +01:00
Felix Roos ff32485f67 fix header 2022-04-14 00:35:15 +02:00
Felix Roos d718eb0be2 add readme 2022-04-14 00:32:45 +02:00
Felix Roos 325eec2c6f refactor scheduler constructor + add onEvent 2022-04-14 00:32:41 +02:00
Felix Roos 5629c0ee72 npm i 2022-04-14 00:32:09 +02:00
alex 369604aa42 Merge branch 'main' of github.com:tidalcycles/strudel into paper 2022-04-13 23:16:07 +01:00
Felix Roos db20ff93c7 fix lockfile 2022-04-14 00:15:27 +02:00
Felix Roos 192eb28ac7 Merge remote-tracking branch 'origin/main' into webaudio 2022-04-14 00:12:47 +02:00
alex 023da097a1 A bit of background 2022-04-13 23:09:53 +01:00
Felix Roos 02738a0694 Merge pull request #67 from tidalcycles/speak
Speech output
2022-04-14 00:09:17 +02:00
Felix Roos 61892bdf3d fix minirepl import 2022-04-13 23:58:51 +02:00
Felix Roos 02ece1183e export patternify 2022-04-13 23:58:44 +02:00
Felix Roos 38fe310a7c fix import 2022-04-13 23:58:34 +02:00
Felix Roos 70fbbd65e9 Merge remote-tracking branch 'origin/main' into speak 2022-04-13 23:58:24 +02:00
Alex McLean 2973223fb1 Merge pull request #62 from tidalcycles/tidy-modules
Separate out strudel.mjs, make index.mjs aggregate module
2022-04-13 22:55:32 +01:00
Felix Roos 1dd19c0831 add speak output 2022-04-13 23:25:55 +02:00
Felix Roos 16e2c97e0c export patternify helpers 2022-04-13 23:25:18 +02:00
alex 050296d0c2 make separate signal module 2022-04-13 17:41:48 +01:00
alex f75da0e2e3 separate out strudel.mjs, make index.mjs aggregate module 2022-04-13 17:25:02 +01:00
Alex McLean 0396c3f475 Merge pull request #61 from tidalcycles/more-functions
More functions
2022-04-13 16:26:45 +01:00
alex 97044fee16 build 2022-04-13 16:25:58 +01:00
alex ca4bffe5a1 compress 2022-04-13 16:20:34 +01:00
alex 0df67fa920 patternify zoom 2022-04-13 16:04:57 +01:00
alex ec3371c4ff Allow linger to accept non-fractions 2022-04-13 15:59:36 +01:00
alex dcc5f66691 Merge branch 'main' of github.com:tidalcycles/strudel into more-functions 2022-04-13 15:51:36 +01:00
alex ec10f349bd Add _zoom and linger 2022-04-13 15:51:23 +01:00
Alex McLean 3b9e854042 Merge pull request #56 from tidalcycles/more-functions
More functions
2022-04-13 09:04:29 +01:00
alex 9eba883978 move some utilities to utils.mjs 2022-04-13 09:03:31 +01:00
alex fb826bed70 sort classes to top of export list 2022-04-13 08:44:38 +01:00
alex 2797856f50 sort exports 2022-04-13 08:40:04 +01:00
alex ad69fa19b6 Prettify 2022-04-13 08:38:08 +01:00
alex 0ad80c1af9 fix citations 2022-04-12 23:49:21 +01:00
Felix Roos 2060e86875 add queryArc + update readme 2022-04-13 00:25:53 +02:00
Felix Roos 87605ca25e Merge branch 'main' of https://github.com/tidalcycles/strudel 2022-04-13 00:15:39 +02:00
Felix Roos 3cd10bf4b3 package-lock 2022-04-13 00:15:36 +02:00
Felix Roos 6bdb0fee55 fix server import 2022-04-13 00:15:09 +02:00
alex 7182894eb6 reference links 2022-04-12 23:14:06 +01:00
Felix Roos 42e2531e8d readme additions 2022-04-13 00:09:04 +02:00
Felix Roos 171f845069 add setup script 2022-04-12 23:54:56 +02:00
Felix Roos f9b043dc7e remove osc-js folder + remove umd stuff 2022-04-12 23:54:13 +02:00
Felix Roos e069e66952 patch osc for client 2022-04-12 23:42:46 +02:00
Felix Roos c9d7a2f313 osc instructions 2022-04-12 22:58:13 +02:00
alex c69af72060 Merge branch 'main' of github.com:tidalcycles/strudel 2022-04-12 21:49:32 +01:00
alex 4111a12cbf hard temporary fork of osc-js 2022-04-12 21:48:48 +01:00
alex 57c1c4e016 more info 2022-04-12 21:48:29 +01:00
alex 324dcd7ef8 use local osc.js 2022-04-12 21:48:11 +01:00
Felix Roos c604f920a0 add root scripts 2022-04-12 20:14:48 +02:00
Felix Roos f8cbd67557 fix: disable highlighting 2022-04-12 20:14:08 +02:00
alex 3c31891774 Add range2 2022-04-12 17:53:40 +01:00
alex 0e5dc4f368 add range 2022-04-12 17:48:09 +01:00
alex e75d8048fe rename range > listRange and remove from exports 2022-04-12 16:54:27 +01:00
alex 7c10d171f6 patternify jux, add juxBy 2022-04-12 16:49:27 +01:00
Alex McLean 5aa01ce91c Merge pull request #27 from tidalcycles/osc
OSC and SuperDirt support
2022-04-12 16:04:04 +01:00
Alex McLean 86bb92d3be Merge pull request #50 from tidalcycles/chop
Implement `chop()`
2022-04-12 12:24:14 +01:00
alex e199564415 Patternify chop() 2022-04-12 12:22:04 +01:00
alex 51db0eaf40 Test and fix chop / squeezebind 2022-04-12 12:16:02 +01:00
alex 83c9200e7d Prettify 2022-04-12 12:01:19 +01:00
alex 529d448383 squeezeBind itself + tidying 2022-04-12 12:00:39 +01:00
alex 8ea59067ce rename inner <> outer bind and join 2022-04-12 11:55:56 +01:00
Alex McLean ac5c844f0b Merge pull request #48 from tidalcycles/squeezejoin
First run at squeezeBind, ref #32
2022-04-12 11:37:32 +01:00
alex b10e0c3a15 Add ply() 2022-04-12 11:31:20 +01:00
alex c2cc6b6dc8 Working squeezeBind 2022-04-12 11:22:53 +01:00
alex 357b0ee467 First run at squeezeBind, ref #32 2022-04-12 10:53:22 +01:00
Alex McLean ac409965d5 Merge pull request #44 from tidalcycles/fix-polymeter
Fix polymeter
2022-04-11 23:03:37 +01:00
alex c596fe33a9 Fix polymeter 2022-04-11 23:01:26 +01:00
Felix Roos 914bc117a1 some loose references 2022-04-11 23:26:17 +02:00
Felix Roos 4dbe366978 just a little plumber tune 2022-04-11 23:25:13 +02:00
Felix Roos 7ca8c8d298 fix "every" example 2022-04-11 23:07:53 +02:00
Felix Roos cf7b2b2acf Merge pull request #40 from tidalcycles/compose
Compose
2022-04-11 22:39:43 +02:00
Felix Roos 81598aefce remove ramda dep + update lockfiles 2022-04-11 22:37:28 +02:00
Felix Roos 9effc166bb use own compose 2022-04-11 22:32:53 +02:00
Felix Roos de3c453763 add pipe + compose 2022-04-11 22:31:02 +02:00
Alex McLean 9da114d965 Merge branch 'main' into osc 2022-04-11 21:10:37 +01:00
Felix Roos 3f603eb84f Merge pull request #38 from bwagner/patch-2
Update tutorial.mdx
2022-04-11 21:49:34 +02:00
Bernhard Wagner 3f1df8faa6 Update tutorial.mdx 2022-04-11 18:08:23 +02:00
Felix Roos 2a3af80deb Merge pull request #37 from bwagner/patch-1
Update tutorial.mdx
2022-04-11 08:43:44 +02:00
Bernhard Wagner abfff8bcf1 Update tutorial.mdx
seperating -> separating
2022-04-11 08:34:11 +02:00
Felix Roos c6d7dabada Create CONTRIBUTING.md 2022-04-10 01:01:02 +02:00
Felix Roos 0c61bb0063 Update featurelist.md
tick some boxes
2022-04-09 22:10:27 +02:00
Felix Roos 0f003abf52 Merge remote-tracking branch 'origin/HEAD' into paper 2022-04-09 18:35:44 +02:00
Felix Roos 80393bf765 Publish
- @strudel.cycles/core@0.0.3
 - @strudel.cycles/eval@0.0.3
 - @strudel.cycles/midi@0.0.4
 - @strudel.cycles/mini@0.0.4
 - @strudel.cycles/tonal@0.0.3
 - @strudel.cycles/tone@0.0.4
 - @strudel.cycles/xen@0.0.3
2022-04-05 23:44:40 +02:00
Felix Roos f43ecf1a85 fix readme instructions 2022-04-05 23:41:10 +02:00
Felix Roos a242c0654b dont create defaultSynth on start 2022-04-05 23:40:21 +02:00
Felix Roos fb1976a6bc add .range 2022-04-05 23:37:27 +02:00
Felix Roos 0e7b345010 some more sprinkles of text 2022-04-05 23:37:14 +02:00
Felix Roos fd28cfc4f8 dont create defaultSynth on start 2022-04-05 23:36:37 +02:00
Felix Roos b20467d6e3 add more shapeshifter flags 2022-04-03 00:45:51 +02:00
Felix Roos 068b95eacb add shapeshifter snippets 2022-04-03 00:44:30 +02:00
Felix Roos 95e4239fd5 pattern comparison snippets 2022-04-03 00:04:00 +02:00
Felix Roos 05c900d291 patch osc-js browser version 2022-04-03 00:03:18 +02:00
Felix Roos f698078f94 add sound synonm 2022-04-03 00:03:05 +02:00
Felix Roos a54b6f0359 Merge remote-tracking branch 'origin/osc' into paper 2022-04-03 00:02:21 +02:00
Felix Roos c8e9fe519f osc timing now hopefully works everywhere 2022-04-02 22:41:04 +02:00
Felix Roos 0c726d835d fix keybindings on safari 2022-04-02 22:40:35 +02:00
Felix Roos 86b1e992a1 fix absolute time 2022-04-02 21:46:56 +02:00
alex c3b15fffa4 remove duplication 2022-04-02 18:48:30 +01:00
alex 7bbac0ed23 newline 2022-04-02 18:40:27 +01:00
alex 1fb1d15d4c add all the superdirt controls 2022-04-02 18:38:20 +01:00
alex 64ea9b7c8b controls (renamed from packages/osc/superdirt.mjs 2022-04-02 17:32:36 +01:00
Felix Roos 5a03386ad5 package-lock 2022-04-02 18:14:10 +02:00
alex acca363a4e move osc/superdirt to core/controls 2022-04-02 16:06:42 +01:00
alex e28a411408 Make param args a sequence, remove some redundancy 2022-04-02 16:03:50 +01:00
alex 89a7bd4e7d superdirt parameters 2022-04-01 23:17:52 +01:00
alex 46b2e82b43 formatting 2022-04-01 23:15:54 +01:00
alex 723b239fda formatting 2022-04-01 23:15:39 +01:00
Felix Roos bfb757b3b1 remove logs 2022-04-01 21:02:11 +02:00
Felix Roos 7fb9c3bf1e move core repl + add package 2022-04-01 20:54:54 +02:00
alex bf7c8cebc4 tidy 2022-04-01 15:38:06 +01:00
alex ac01a621be workaround for osc-js timestamp bug, reduce latency 2022-04-01 15:37:50 +01:00
Felix Roos 47a046ca1d begin webaudio package 2022-04-01 15:44:17 +02:00
Felix Roos 4ef70d2a15 Merge branch 'osc' of https://github.com/tidalcycles/strudel into osc 2022-03-29 22:17:46 +02:00
Felix Roos ee0d835cd8 add core examples 2022-03-29 22:16:36 +02:00
alex 330263028e it seems the custom handler wasn't being used 2022-03-29 17:04:00 +01:00
alex d0d19778a4 try sending osc in timestamped bundle with added latency 2022-03-29 17:03:30 +01:00
alex 0bfbd87bbf try to send osc as timestamped bundle 2022-03-29 16:39:52 +01:00
alex ba095d8e7f Stop failing on no tests 2022-03-29 15:36:56 +01:00
alex 0b8919de61 send actual osc parameters 2022-03-29 08:12:34 +01:00
alex 7fca7e6bd9 attempt to send an OSC message 2022-03-28 22:10:20 +01:00
alex 69884c61b4 first (broken) attempt 2022-03-28 21:41:49 +01:00
Felix Roos ed6cf2ecf1 enlarge button 2022-03-28 21:24:44 +02:00
Felix Roos 0be0347f8b basic communication with superdirt 2022-03-28 21:22:24 +02:00
196 changed files with 34175 additions and 38649 deletions
+5 -1
View File
@@ -1,4 +1,5 @@
dist
out
!docs/dist
dist-*
cabal-dev
@@ -26,4 +27,7 @@ node_modules/
.DS_Store
repl-parcel
mytunes.ts
doc
doc
out
.parcel-cache
repl_old
+111
View File
@@ -0,0 +1,111 @@
# 🌀 Contributing to Strudel 🌀
Thanks for wanting to contribute!!! There are many ways you can add value to this project
## Communication Channels
To get in touch with the contributors, either
- open a [github discussion](https://github.com/tidalcycles/strudel/discussions) or
- [join the Tidal Discord Channel](https://discord.gg/remJ6gQA) and go to the #strudel channel
- Find related discussions on the [tidal club forum](https://club.tidalcycles.org/)
## Ask a Question
If you have any questions about strudel, make sure you've read the
[tutorial](https://strudel.tidalcycles.org/tutorial/) to find out if it answers your question.
If not, use one of the Communication Channels above!
Don't be afraid to ask! Your question might be of great value for other people too.
## Give Feedback
No matter if you've used the Strudel REPL or if you are using the strudel packages, we are happy to hear some feedback.
Use one of the Communication Channels listed above and drop us a line or two!
## Share Music
If you made some music with strudel, you can give back some love and share what you've done!
Your creation could also be part of the random selection in the REPL if you want.
Use one of the Communication Channels listed above.
## Improve the Tutorial
If you find some weak spots in the [tutorial](https://strudel.tidalcycles.org/),
you are welcome to improve them by editing [this file](https://github.com/tidalcycles/strudel/blob/main/repl/src/tutorial/tutorial.mdx).
This will even work without setting up a development environment, only a github account is required.
## Propose a Feature
If you want a specific feature that is not part of strudel yet, feel free to use one of the communication channels above.
Maybe you even want to help with the implementation of that feature!
## Report a Bug
If you've found a bug, or some behaviour that does not seem right, you are welcome to file an [issue](https://github.com/tidalcycles/strudel/issues).
Please check that it has not been reported before.
## Fix a Bug
To fix a bug that has been reported,
1. check that nobody else is already fixing it and respond to the issue to let people know you're on it
3. fork the repository
4. make sure you've setup the project (see below)
5. hopefully fix the bug
6. make sure the tests pass
7. send a pull request
## Write Tests
There are still many tests that have not been written yet! Reading and writing tests is a great opportunity to get familiar with the codebase.
You can find the tests in each package in the `test` folder. To run all tests, run `npm test` from the root folder.
## Project Setup
To get the project up and running for development, make sure you have installed:
- git
- node, preferably v16
then, do the following:
```sh
git clone https://github.com/tidalcycles/strudel.git && cd strudel
npm i # install at root to symlink packages
npx lerna bootstrap # install all dependencies in packages
cd repl && npm i # install repl dependencies
npm run start # start repl
```
Those commands might look slightly different for your OS.
Please report any problems you've had with the setup instructions!
## Code Style
To make sure the code changes only where it should, we are using prettier to unify the code style.
If you use VSCode, you can
1. install [the prettier extension](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)
2. open command palette and run "Format Document With..."
3. Choose "Configure Default Formatter..."
4. Select prettier
## Package Workflow
The project is split into multiple [packages](https://github.com/tidalcycles/strudel/tree/main/packages) with independent versioning.
When you run `npm i` on the root folder, [npm workspaces](https://docs.npmjs.com/cli/v7/using-npm/workspaces) will symlink all packages
in the `node_modules` folder. This will allow any js file to import `@strudel.cycles/<package-name>` to get the local version,
which allows developing multiple packages at the same time
## Package Publishing
To publish all packages that have been changed since the last release, run:
```sh
npx lerna publish
```
## Have Fun
Remember to have fun, and that this project is driven by the passion of volunteers!
+64 -77
View File
@@ -1,5 +1,5 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
@@ -7,17 +7,15 @@
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
software for all its users.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
@@ -26,44 +24,34 @@ them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate. Many developers of free software are heartened and
encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
The precise terms and conditions for copying, distribution and
modification follow.
@@ -72,7 +60,7 @@ modification follow.
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
@@ -549,35 +537,45 @@ to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
@@ -635,40 +633,29 @@ the "copyright" line and a pointer to where the full notice is found.
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
GNU Affero General Public License for more details.
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
For more information on this, and how to apply and follow the GNU AGPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
+25 -21
View File
@@ -4,40 +4,44 @@
An experiment in making a [Tidal](https://github.com/tidalcycles/tidal/) using web technologies. This is unstable software, please tread carefully.
Try it here: https://strudel.tidalcycles.org/
- Try it here: <https://strudel.tidalcycles.org/>
- Tutorial: <https://strudel.tidalcycles.org/tutorial/>
- Technical Blog Post: <https://loophole-letters.vercel.app/strudel>
Tutorial: https://strudel.tidalcycles.org/tutorial/
## Running Locally
## Local development
Run the REPL locally:
After cloning the project, you can run the REPL locally:
```bash
npm install
npx lerna bootstrap
cd repl
npm install
npm run start
npm run setup
npm run repl
```
## Publish Packages
## Using Strudel In Your Project
To publish, just run:
There are multiple npm packages you can use to use strudel, or only parts of it, in your project:
```sh
npx lerna version
```
- [`core`](./packages/core/): tidal pattern engine
- [`mini`](./packages/mini): mini notation parser + core binding
- [`eval`](./packages/eval): user code evaluator. syntax sugar + highlighting
- [`tone`](./packages/tone): bindings for Tone.js instruments and effects
- [`osc`](./packages/osc): bindings to communicate via OSC
- [`midi`](./packages/midi): webmidi bindings
- [`serial`](./packages/serial): webserial bindings
- [`tonal`](./packages/tonal): tonal functions
- [`xen`](./packages/xen): microtonal / xenharmonic functions
- ... [and there are more](./packages/)
This will publish all packages that changed since the last version.
Click on the package names to find out more about each one.
## Style
## Contributing
For now, please try to copy the style of surrounding code. VS Code users can install the 'prettier' add-on which will use the .prettierrc configuration file for automatic formatting.
There are many ways to contribute to this project! See [contribution guide](./CONTRIBUTING.md).
## Community
There is a #strudel channel on the TidalCycles discord: https://discord.com/invite/HGEdXmRkzT
There is a #strudel channel on the TidalCycles discord: <https://discord.com/invite/HGEdXmRkzT>
You can also ask questions and find related discussions on the tidal club forum: https://club.tidalcycles.org/
You can also ask questions and find related discussions on the tidal club forum: <https://club.tidalcycles.org/>
The discord and forum is shared with the haskell (tidal) and python (vortex) siblings of this project.
The discord and forum is shared with the haskell (tidal) and python (vortex) siblings of this project.
+1037
View File
File diff suppressed because it is too large Load Diff
+8 -8
View File
@@ -1,16 +1,16 @@
{
"files": {
"main.css": "/static/css/main.0d689283.css",
"main.js": "/static/js/main.77e38ada.js",
"static/js/787.8f7ec9e0.chunk.js": "/static/js/787.8f7ec9e0.chunk.js",
"main.css": "/static/css/main.35f2ca4c.css",
"main.js": "/static/js/main.f848d51e.js",
"static/js/787.1c52cb78.chunk.js": "/static/js/787.1c52cb78.chunk.js",
"static/media/logo.svg": "/static/media/logo.ac95051720b3dccfe511e0e02d8e1029.svg",
"index.html": "/index.html",
"main.0d689283.css.map": "/static/css/main.0d689283.css.map",
"main.77e38ada.js.map": "/static/js/main.77e38ada.js.map",
"787.8f7ec9e0.chunk.js.map": "/static/js/787.8f7ec9e0.chunk.js.map"
"main.35f2ca4c.css.map": "/static/css/main.35f2ca4c.css.map",
"main.f848d51e.js.map": "/static/js/main.f848d51e.js.map",
"787.1c52cb78.chunk.js.map": "/static/js/787.1c52cb78.chunk.js.map"
},
"entrypoints": [
"static/css/main.0d689283.css",
"static/js/main.77e38ada.js"
"static/css/main.35f2ca4c.css",
"static/js/main.f848d51e.js"
]
}
+1 -1
View File
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Strudel REPL"/><title>Strudel REPL</title><script defer="defer" src="/static/js/main.77e38ada.js"></script><link href="/static/css/main.0d689283.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Strudel REPL"/><title>Strudel REPL</title><script defer="defer" src="/static/js/main.f848d51e.js"></script><link href="/static/css/main.35f2ca4c.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+2
View File
@@ -0,0 +1,2 @@
"use strict";(self.webpackChunk_strudel_cycles_repl=self.webpackChunk_strudel_cycles_repl||[]).push([[787],{787:function(e,t,n){n.r(t),n.d(t,{getCLS:function(){return y},getFCP:function(){return g},getFID:function(){return C},getLCP:function(){return P},getTTFB:function(){return D}});var i,r,a,o,u=function(e,t){return{name:e,value:void 0===t?-1:t,delta:0,entries:[],id:"v2-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12)}},c=function(e,t){try{if(PerformanceObserver.supportedEntryTypes.includes(e)){if("first-input"===e&&!("PerformanceEventTiming"in self))return;var n=new PerformanceObserver((function(e){return e.getEntries().map(t)}));return n.observe({type:e,buffered:!0}),n}}catch(e){}},f=function(e,t){var n=function n(i){"pagehide"!==i.type&&"hidden"!==document.visibilityState||(e(i),t&&(removeEventListener("visibilitychange",n,!0),removeEventListener("pagehide",n,!0)))};addEventListener("visibilitychange",n,!0),addEventListener("pagehide",n,!0)},s=function(e){addEventListener("pageshow",(function(t){t.persisted&&e(t)}),!0)},m=function(e,t,n){var i;return function(r){t.value>=0&&(r||n)&&(t.delta=t.value-(i||0),(t.delta||void 0===i)&&(i=t.value,e(t)))}},v=-1,p=function(){return"hidden"===document.visibilityState?0:1/0},d=function(){f((function(e){var t=e.timeStamp;v=t}),!0)},l=function(){return v<0&&(v=p(),d(),s((function(){setTimeout((function(){v=p(),d()}),0)}))),{get firstHiddenTime(){return v}}},g=function(e,t){var n,i=l(),r=u("FCP"),a=function(e){"first-contentful-paint"===e.name&&(f&&f.disconnect(),e.startTime<i.firstHiddenTime&&(r.value=e.startTime,r.entries.push(e),n(!0)))},o=window.performance&&performance.getEntriesByName&&performance.getEntriesByName("first-contentful-paint")[0],f=o?null:c("paint",a);(o||f)&&(n=m(e,r,t),o&&a(o),s((function(i){r=u("FCP"),n=m(e,r,t),requestAnimationFrame((function(){requestAnimationFrame((function(){r.value=performance.now()-i.timeStamp,n(!0)}))}))})))},h=!1,T=-1,y=function(e,t){h||(g((function(e){T=e.value})),h=!0);var n,i=function(t){T>-1&&e(t)},r=u("CLS",0),a=0,o=[],v=function(e){if(!e.hadRecentInput){var t=o[0],i=o[o.length-1];a&&e.startTime-i.startTime<1e3&&e.startTime-t.startTime<5e3?(a+=e.value,o.push(e)):(a=e.value,o=[e]),a>r.value&&(r.value=a,r.entries=o,n())}},p=c("layout-shift",v);p&&(n=m(i,r,t),f((function(){p.takeRecords().map(v),n(!0)})),s((function(){a=0,T=-1,r=u("CLS",0),n=m(i,r,t)})))},E={passive:!0,capture:!0},w=new Date,L=function(e,t){i||(i=t,r=e,a=new Date,F(removeEventListener),S())},S=function(){if(r>=0&&r<a-w){var e={entryType:"first-input",name:i.type,target:i.target,cancelable:i.cancelable,startTime:i.timeStamp,processingStart:i.timeStamp+r};o.forEach((function(t){t(e)})),o=[]}},b=function(e){if(e.cancelable){var t=(e.timeStamp>1e12?new Date:performance.now())-e.timeStamp;"pointerdown"==e.type?function(e,t){var n=function(){L(e,t),r()},i=function(){r()},r=function(){removeEventListener("pointerup",n,E),removeEventListener("pointercancel",i,E)};addEventListener("pointerup",n,E),addEventListener("pointercancel",i,E)}(t,e):L(t,e)}},F=function(e){["mousedown","keydown","touchstart","pointerdown"].forEach((function(t){return e(t,b,E)}))},C=function(e,t){var n,a=l(),v=u("FID"),p=function(e){e.startTime<a.firstHiddenTime&&(v.value=e.processingStart-e.startTime,v.entries.push(e),n(!0))},d=c("first-input",p);n=m(e,v,t),d&&f((function(){d.takeRecords().map(p),d.disconnect()}),!0),d&&s((function(){var a;v=u("FID"),n=m(e,v,t),o=[],r=-1,i=null,F(addEventListener),a=p,o.push(a),S()}))},k={},P=function(e,t){var n,i=l(),r=u("LCP"),a=function(e){var t=e.startTime;t<i.firstHiddenTime&&(r.value=t,r.entries.push(e),n())},o=c("largest-contentful-paint",a);if(o){n=m(e,r,t);var v=function(){k[r.id]||(o.takeRecords().map(a),o.disconnect(),k[r.id]=!0,n(!0))};["keydown","click"].forEach((function(e){addEventListener(e,v,{once:!0,capture:!0})})),f(v,!0),s((function(i){r=u("LCP"),n=m(e,r,t),requestAnimationFrame((function(){requestAnimationFrame((function(){r.value=performance.now()-i.timeStamp,k[r.id]=!0,n(!0)}))}))}))}},D=function(e){var t,n=u("TTFB");t=function(){try{var t=performance.getEntriesByType("navigation")[0]||function(){var e=performance.timing,t={entryType:"navigation",startTime:0};for(var n in e)"navigationStart"!==n&&"toJSON"!==n&&(t[n]=Math.max(e[n]-e.navigationStart,0));return t}();if(n.value=n.delta=t.responseStart,n.value<0||n.value>performance.now())return;n.entries=[t],e(n)}catch(e){}},"complete"===document.readyState?setTimeout(t,0):addEventListener("load",(function(){return setTimeout(t,0)}))}}}]);
//# sourceMappingURL=787.1c52cb78.chunk.js.map
File diff suppressed because one or more lines are too long
-2
View File
@@ -1,2 +0,0 @@
"use strict";(self.webpackChunk_strudel_repl=self.webpackChunk_strudel_repl||[]).push([[787],{787:function(e,t,n){n.r(t),n.d(t,{getCLS:function(){return y},getFCP:function(){return g},getFID:function(){return C},getLCP:function(){return P},getTTFB:function(){return D}});var i,r,a,o,u=function(e,t){return{name:e,value:void 0===t?-1:t,delta:0,entries:[],id:"v2-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12)}},c=function(e,t){try{if(PerformanceObserver.supportedEntryTypes.includes(e)){if("first-input"===e&&!("PerformanceEventTiming"in self))return;var n=new PerformanceObserver((function(e){return e.getEntries().map(t)}));return n.observe({type:e,buffered:!0}),n}}catch(e){}},f=function(e,t){var n=function n(i){"pagehide"!==i.type&&"hidden"!==document.visibilityState||(e(i),t&&(removeEventListener("visibilitychange",n,!0),removeEventListener("pagehide",n,!0)))};addEventListener("visibilitychange",n,!0),addEventListener("pagehide",n,!0)},s=function(e){addEventListener("pageshow",(function(t){t.persisted&&e(t)}),!0)},m=function(e,t,n){var i;return function(r){t.value>=0&&(r||n)&&(t.delta=t.value-(i||0),(t.delta||void 0===i)&&(i=t.value,e(t)))}},v=-1,p=function(){return"hidden"===document.visibilityState?0:1/0},d=function(){f((function(e){var t=e.timeStamp;v=t}),!0)},l=function(){return v<0&&(v=p(),d(),s((function(){setTimeout((function(){v=p(),d()}),0)}))),{get firstHiddenTime(){return v}}},g=function(e,t){var n,i=l(),r=u("FCP"),a=function(e){"first-contentful-paint"===e.name&&(f&&f.disconnect(),e.startTime<i.firstHiddenTime&&(r.value=e.startTime,r.entries.push(e),n(!0)))},o=window.performance&&performance.getEntriesByName&&performance.getEntriesByName("first-contentful-paint")[0],f=o?null:c("paint",a);(o||f)&&(n=m(e,r,t),o&&a(o),s((function(i){r=u("FCP"),n=m(e,r,t),requestAnimationFrame((function(){requestAnimationFrame((function(){r.value=performance.now()-i.timeStamp,n(!0)}))}))})))},h=!1,T=-1,y=function(e,t){h||(g((function(e){T=e.value})),h=!0);var n,i=function(t){T>-1&&e(t)},r=u("CLS",0),a=0,o=[],v=function(e){if(!e.hadRecentInput){var t=o[0],i=o[o.length-1];a&&e.startTime-i.startTime<1e3&&e.startTime-t.startTime<5e3?(a+=e.value,o.push(e)):(a=e.value,o=[e]),a>r.value&&(r.value=a,r.entries=o,n())}},p=c("layout-shift",v);p&&(n=m(i,r,t),f((function(){p.takeRecords().map(v),n(!0)})),s((function(){a=0,T=-1,r=u("CLS",0),n=m(i,r,t)})))},E={passive:!0,capture:!0},w=new Date,L=function(e,t){i||(i=t,r=e,a=new Date,F(removeEventListener),S())},S=function(){if(r>=0&&r<a-w){var e={entryType:"first-input",name:i.type,target:i.target,cancelable:i.cancelable,startTime:i.timeStamp,processingStart:i.timeStamp+r};o.forEach((function(t){t(e)})),o=[]}},b=function(e){if(e.cancelable){var t=(e.timeStamp>1e12?new Date:performance.now())-e.timeStamp;"pointerdown"==e.type?function(e,t){var n=function(){L(e,t),r()},i=function(){r()},r=function(){removeEventListener("pointerup",n,E),removeEventListener("pointercancel",i,E)};addEventListener("pointerup",n,E),addEventListener("pointercancel",i,E)}(t,e):L(t,e)}},F=function(e){["mousedown","keydown","touchstart","pointerdown"].forEach((function(t){return e(t,b,E)}))},C=function(e,t){var n,a=l(),v=u("FID"),p=function(e){e.startTime<a.firstHiddenTime&&(v.value=e.processingStart-e.startTime,v.entries.push(e),n(!0))},d=c("first-input",p);n=m(e,v,t),d&&f((function(){d.takeRecords().map(p),d.disconnect()}),!0),d&&s((function(){var a;v=u("FID"),n=m(e,v,t),o=[],r=-1,i=null,F(addEventListener),a=p,o.push(a),S()}))},k={},P=function(e,t){var n,i=l(),r=u("LCP"),a=function(e){var t=e.startTime;t<i.firstHiddenTime&&(r.value=t,r.entries.push(e),n())},o=c("largest-contentful-paint",a);if(o){n=m(e,r,t);var v=function(){k[r.id]||(o.takeRecords().map(a),o.disconnect(),k[r.id]=!0,n(!0))};["keydown","click"].forEach((function(e){addEventListener(e,v,{once:!0,capture:!0})})),f(v,!0),s((function(i){r=u("LCP"),n=m(e,r,t),requestAnimationFrame((function(){requestAnimationFrame((function(){r.value=performance.now()-i.timeStamp,k[r.id]=!0,n(!0)}))}))}))}},D=function(e){var t,n=u("TTFB");t=function(){try{var t=performance.getEntriesByType("navigation")[0]||function(){var e=performance.timing,t={entryType:"navigation",startTime:0};for(var n in e)"navigationStart"!==n&&"toJSON"!==n&&(t[n]=Math.max(e[n]-e.navigationStart,0));return t}();if(n.value=n.delta=t.responseStart,n.value<0||n.value>performance.now())return;n.entries=[t],e(n)}catch(e){}},"complete"===document.readyState?setTimeout(t,0):addEventListener("load",(function(){return setTimeout(t,0)}))}}}]);
//# sourceMappingURL=787.8f7ec9e0.chunk.js.map
File diff suppressed because one or more lines are too long
-56
View File
@@ -1,56 +0,0 @@
/*
object-assign
(c) Sindre Sorhus
@license MIT
*/
/**
* @license Fraction.js v4.2.0 05/03/2022
* https://www.xarg.org/2014/03/rational-numbers-in-javascript/
*
* Copyright (c) 2021, Robert Eisele (robert@xarg.org)
* Dual licensed under the MIT or GPL Version 2 licenses.
**/
/**
* Tone.js
* @author Yotam Mann
* @license http://opensource.org/licenses/MIT MIT License
* @copyright 2014-2019 Yotam Mann
*/
/** @license React v0.20.2
* scheduler.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/** @license React v17.0.2
* react-dom.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/** @license React v17.0.2
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/** @license React v17.0.2
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
File diff suppressed because one or more lines are too long
+96
View File
@@ -0,0 +1,96 @@
/*
Strudel - javascript-based environment for live coding algorithmic (musical) patterns
https://strudel.tidalcycles.org / https://github.com/tidalcycles/strudel/
Copyright (C) Strudel contributors
https://github.com/tidalcycles/strudel/graphs/contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/*
object-assign
(c) Sindre Sorhus
@license MIT
*/
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/*! @license ReactCodeMirror - MIT License - Tom Golden (8162045+tbjgolden@users.noreply.github.com) */
/**
* @license Fraction.js v4.2.0 05/03/2022
* https://www.xarg.org/2014/03/rational-numbers-in-javascript/
*
* Copyright (c) 2021, Robert Eisele (robert@xarg.org)
* Dual licensed under the MIT or GPL Version 2 licenses.
**/
/**
* Tone.js
* @author Yotam Mann
* @license http://opensource.org/licenses/MIT MIT License
* @copyright 2014-2019 Yotam Mann
*/
/** @license React v0.20.2
* scheduler.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/** @license React v17.0.2
* react-dom.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/** @license React v17.0.2
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/** @license React v17.0.2
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><link rel="icon" href="/tutorial/favicon.e3ab9dd9.ico"><link rel="stylesheet" type="text/css" href="/tutorial/index.999678aa.css"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="description" content="Strudel REPL"><title>Strudel Tutorial</title></head><body> <div id="root"></div> <noscript>You need to enable JavaScript to run this app.</noscript> <script src="/tutorial/index.097d520a.js" defer></script> </body></html>
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><link rel="icon" href="/tutorial/favicon.e3ab9dd9.ico"><link rel="stylesheet" type="text/css" href="/tutorial/index.a3acddda.css"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="description" content="Strudel REPL"><title>Strudel Tutorial</title></head><body> <div id="root"></div> <noscript>You need to enable JavaScript to run this app.</noscript> <script src="/tutorial/index.55306425.js" defer></script> </body></html>
-128
View File
@@ -1,128 +0,0 @@
# Tidal Features in Strudel
## Basics
- [ ] drawLine
- [ ] setcps
- [ ] naming patterns? block based evaluation?
- [ ] once
- [ ] silence
- [x] hush
- [ ] panic
## Concatenation
https://tidalcycles.org/docs/patternlib/tour/concatenation
- [x] cat: is synonym to fastcat in strudel, while [in tidal, cat is slowcat](https://tidalcycles.org/docs/patternlib/tour/concatenation#cat)
- [x] fastcat
- [x] timeCat: why is this camel case?
- [ ] randcat
- [x] append: but is like fastAppend in tidal
- [ ] fastAppend
- [ ] slowAppend
- [ ] wedge
- [ ] brak
- [ ] flatpat
## Accumulation
- [ ] overlay => like stack? "The overlay function is similar to cat" => wrong?
- [ ] `<>` operator (=== overlay)
- [x] stack
- [x] superimpose => strudel supports multiple args => is this layer?
- [ ] layer => is this like superimpose but with multiple args?
- [ ] steps ?
- [ ] iter, iter'
## Alteration
- [ ] range, rangex
- [ ] quantise
- [ ] ply
- [ ] stutter
- [ ] stripe, slowstripe
- [ ] palindrome = every(2, rev)
- [ ] trunc
- [ ] linger
- [ ] chunk, chunk'
- [ ] shuffle
- [ ] scramble
- [ ] rot
- [ ] step / step'
- [ ] lindenmeyer
- [ ] spread / spreadf / fastspread
- [ ] spreadChoose / spreadr
## conditions
- [x] every
- [ ] every'
- [ ] whenmod
- [ ] sometimes, sometimesBy, someCycles, someCyclesBy
- [ ] choose, chooseby, wchoose, wchooseby
- [x] struct
- [x] mask
- [ ] sew
- [ ] stitch
- [ ] select, selectF
- [ ] pickF
- [ ] squeeze
- [ ] euclid, euclidInv, euclidFull
- [ ] ifp
## Time
- [x] fast
- [x] fastGap
- [x] slow
- [ ] hurry
- [ ] compress: is this compressSpan?
- [ ] zoom
- [ ] within
- [x] off
- [ ] rotL / rotR
- [x] rev
- [ ] jux / juxBy
- [ ] swingBy / swing
- [ ] ghost
- [ ] inside / outside
## Harmony & Melody
- [x] scale
- [ ] scaleList
- [ ] getScale
- [ ] toScale
- [ ] chordList
- [ ] arpeggiate
- [ ] arp
## Transitions
- [ ] anticipate / anticipateIn
- [ ] clutch / clutchIn
- [ ] histpan
- [ ] interpolate / interpolateIn
- [ ] jump / jumpIn / jumpIn' / jumpMod
- [ ] wait / waitT
- [ ] wash / washIn
- [ ] xfade / xfadeIn
## Sampling
- [ ] chop
- [ ] striate / striateBy
- [ ] loopAt
- [ ] segment
- [ ] discretise
## Randomness
- [ ] rand / irand
- [ ] perlin / perlinWith / perlin2 / perlin2With
## Composition
- [ ] ur
- [ ] seqP / seqPLoop
-14
View File
@@ -1,14 +0,0 @@
<!DOCTYPE html>
<script>import("./strudel.js").then(m => strudel = m)
</script>
<html>
<head>
<title>Bingo</title>
</head>
<body>
<button onclick="foo()">hello</button>
<button onclick="bar()">hello</button>
<script type="module" src="./strudel.js"></script>
</body>
</html>
+11
View File
@@ -0,0 +1,11 @@
{
"source": {
"includePattern": ".+\\.(js(doc|x)?|mjs)$",
"excludePattern": "node_modules|shift-parser|shift-reducer|shift-traverser"
},
"plugins": ["plugins/markdown"],
"opts": {
"destination": "./out/",
"recurse": true
}
}
+5539 -180
View File
File diff suppressed because it is too large Load Diff
+15 -4
View File
@@ -3,10 +3,17 @@
"version": "0.0.1",
"private": true,
"description": "Port of tidalcycles to javascript",
"main": "strudel.mjs",
"scripts": {
"test": "npm run test --workspaces --if-present",
"bootstrap": "lerna bootstrap"
"test": "npm run test --workspaces --if-present && cd repl && npm run test",
"bootstrap": "lerna bootstrap",
"setup": "npm i && npm run bootstrap && cd repl && npm i",
"repl": "cd repl && npm run dev",
"osc": "cd packages/osc && npm run server",
"build": "rm -rf out && cd repl && npm run build && cd ../tutorial && npm run build",
"preview": "npx serve ./out",
"deploy": "gh-pages -d out",
"jsdoc": "jsdoc packages/ -c jsdoc.config.json",
"jsdoc-json": "jsdoc packages/ --template ./node_modules/jsdoc-json --destination doc.json -c jsdoc.config.json"
},
"workspaces": [
"packages/*"
@@ -23,13 +30,17 @@
"algorave"
],
"author": "Alex McLean <alex@slab.org> (https://slab.org)",
"license": "GPL-3.0-or-later",
"license": "AGPL-3.0-or-later",
"bugs": {
"url": "https://github.com/tidalcycles/strudel/issues"
},
"homepage": "https://strudel.tidalcycles.org",
"devDependencies": {
"events": "^3.3.0",
"gh-pages": "^4.0.0",
"jsdoc": "^3.6.10",
"jsdoc-json": "^2.0.2",
"jsdoc-to-markdown": "^7.1.1",
"lerna": "^4.0.0",
"mocha": "^9.1.4"
}
+6 -4
View File
@@ -11,18 +11,18 @@ npm i @strudel.cycles/core --save
## Example
```js
import { sequence, State, TimeSpan } from '@strudel.cycles/core';
import { sequence } from '@strudel.cycles/core';
const pattern = sequence('a', ['b', 'c']);
const events = pattern.query(new State(new TimeSpan(0, 2)));
const events = pattern.queryArc(0, 1);
const spans = events.map(
(event) => `${event.value}: ${event.whole.begin.toFraction()} - ${event.whole.end.toFraction()} `,
);
```
spans:
yields:
```log
a: 0 - 1/2
@@ -33,4 +33,6 @@ b: 3/2 - 7/4
c: 7/4 - 2
```
[play with @strudel.cycles/core on codesandbox](https://codesandbox.io/s/strudel-core-test-qmz6qr?file=/src/index.js).
- [play with @strudel.cycles/core on codesandbox](https://codesandbox.io/s/strudel-core-test-qmz6qr?file=/src/index.js).
- [open color pattern example](https://raw.githack.com/tidalcycles/strudel/package-examples/packages/core/examples/canvas.html)
- [open minimal repl example](https://raw.githack.com/tidalcycles/strudel/package-examples/packages/core/examples/metro.html)
+294
View File
@@ -0,0 +1,294 @@
/*
controls.mjs - <short description TODO>
Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/strudel/blob/main/packages/core/controls.mjs>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { Pattern, sequence } from './pattern.mjs';
const controls = {};
const generic_params = [
['s', 's', 'sound'],
//['s', 'toArg', 'for internal sound routing'],
// ["f", "from", "for internal sound routing"),
//['f', 'to', 'for internal sound routing'],
['f', 'accelerate', 'a pattern of numbers that speed up (or slow down) samples while they play.'],
['f', 'amp', 'like @gain@, but linear.'],
[
'f',
'attack',
'a pattern of numbers to specify the attack time (in seconds) of an envelope applied to each sample.',
],
['f', 'bandf', 'a pattern of numbers from 0 to 1. Sets the center frequency of the band-pass filter.'],
['f', 'bandq', 'a pattern of anumbers from 0 to 1. Sets the q-factor of the band-pass filter.'],
[
'f',
'begin',
'a pattern of numbers from 0 to 1. Skips the beginning of each sample, e.g. `0.25` to cut off the first quarter from each sample.',
],
['f', 'legato', 'controls the amount of overlap between two adjacent sounds'],
// ['f', 'clhatdecay', ''],
[
'f',
'crush',
'bit crushing, a pattern of numbers from 1 (for drastic reduction in bit-depth) to 16 (for barely no reduction).',
],
[
'f',
'coarse',
'fake-resampling, a pattern of numbers for lowering the sample rate, i.e. 1 for original 2 for half, 3 for a third and so on.',
],
['i', 'channel', 'choose the channel the pattern is sent to in superdirt'],
[
'i',
'cut',
'In the style of classic drum-machines, `cut` will stop a playing sample as soon as another samples with in same cutgroup is to be played. An example would be an open hi-hat followed by a closed one, essentially muting the open.',
],
['f', 'cutoff', 'a pattern of numbers from 0 to 1. Applies the cutoff frequency of the low-pass filter.'],
// ['f', 'cutoffegint', ''],
['f', 'decay', ''],
['f', 'delay', 'a pattern of numbers from 0 to 1. Sets the level of the delay signal.'],
['f', 'delayfeedback', 'a pattern of numbers from 0 to 1. Sets the amount of delay feedback.'],
['f', 'delaytime', 'a pattern of numbers from 0 to 1. Sets the length of the delay.'],
['f', 'detune', ''],
['f', 'djf', 'DJ filter, below 0.5 is low pass filter, above is high pass filter.'],
[
'f',
'dry',
'when set to `1` will disable all reverb for this pattern. See `room` and `size` for more information about reverb.',
],
[
'f',
'end',
'the same as `begin`, but cuts the end off samples, shortening them; e.g. `0.75` to cut off the last quarter of each sample.',
],
[
'f',
'fadeTime',
"Used when using begin/end or chop/striate and friends, to change the fade out time of the 'grain' envelope.",
],
[
'f',
'fadeInTime',
'As with fadeTime, but controls the fade in time of the grain envelope. Not used if the grain begins at position 0 in the sample.',
],
['f', 'freq', ''],
[
'f',
'gain',
'a pattern of numbers that specify volume. Values less than 1 make the sound quieter. Values greater than 1 make the sound louder. For the linear equivalent, see @amp@.',
],
['f', 'gate', ''],
// ['f', 'hatgrain', ''],
[
'f',
'hcutoff',
'a pattern of numbers from 0 to 1. Applies the cutoff frequency of the high-pass filter. Also has alias @hpf@',
],
[
'f',
'hold',
'a pattern of numbers to specify the hold time (in seconds) of an envelope applied to each sample. Only takes effect if `attack` and `release` are also specified.',
],
[
'f',
'hresonance',
'a pattern of numbers from 0 to 1. Applies the resonance of the high-pass filter. Has alias @hpq@',
],
// ['f', 'lagogo', ''],
// ['f', 'lclap', ''],
// ['f', 'lclaves', ''],
// ['f', 'lclhat', ''],
// ['f', 'lcrash', ''],
['f', 'leslie', ''],
['f', 'lrate', ''],
['f', 'lsize', ''],
// ['f', 'lfo', ''],
// ['f', 'lfocutoffint', ''],
// ['f', 'lfodelay', ''],
// ['f', 'lfoint', ''],
// ['f', 'lfopitchint', ''],
// ['f', 'lfoshape', ''],
// ['f', 'lfosync', ''],
// ['f', 'lhitom', ''],
// ['f', 'lkick', ''],
// ['f', 'llotom', ''],
[
'f',
'lock',
'A pattern of numbers. Specifies whether delaytime is calculated relative to cps. When set to 1, delaytime is a direct multiple of a cycle.',
],
['f', 'loop', 'loops the sample (from `begin` to `end`) the specified number of times.'],
// ['f', 'lophat', ''],
// ['f', 'lsnare', ''],
['f', 'n', 'The note or sample number to choose for a synth or sampleset'],
['f', 'note', 'The note or pitch to play a sound or synth with'],
['f', 'degree', ''],
['f', 'mtranspose', ''],
['f', 'ctranspose', ''],
['f', 'harmonic', ''],
['f', 'stepsPerOctave', ''],
['f', 'octaveR', ''],
[
'f',
'nudge',
'Nudges events into the future by the specified number of seconds. Negative numbers work up to a point as well (due to internal latency)',
],
['i', 'octave', ''],
['f', 'offset', ''],
// ['f', 'ophatdecay', ''],
[
'i',
'orbit',
'a pattern of numbers. An `orbit` is a global parameter context for patterns. Patterns with the same orbit will share hardware output bus offset and global effects, e.g. reverb and delay. The maximum number of orbits is specified in the superdirt startup, numbers higher than maximum will wrap around.',
],
['f', 'overgain', ''],
['f', 'overshape', ''],
[
'f',
'pan',
'a pattern of numbers between 0 and 1, from left to right (assuming stereo), once round a circle (assuming multichannel)',
],
[
'f',
'panspan',
'a pattern of numbers between -inf and inf, which controls how much multichannel output is fanned out (negative is backwards ordering)',
],
[
'f',
'pansplay',
'a pattern of numbers between 0.0 and 1.0, which controls the multichannel spread range (multichannel only)',
],
[
'f',
'panwidth',
'a pattern of numbers between 0.0 and inf, which controls how much each channel is distributed over neighbours (multichannel only)',
],
[
'f',
'panorient',
'a pattern of numbers between -1.0 and 1.0, which controls the relative position of the centre pan in a pair of adjacent speakers (multichannel only)',
],
// ['f', 'pitch1', ''],
// ['f', 'pitch2', ''],
// ['f', 'pitch3', ''],
// ['f', 'portamento', ''],
['f', 'rate', "used in SuperDirt softsynths as a control rate or 'speed'"],
[
'f',
'release',
'a pattern of numbers to specify the release time (in seconds) of an envelope applied to each sample.',
],
['f', 'resonance', 'a pattern of numbers from 0 to 1. Specifies the resonance of the low-pass filter.'],
['f', 'room', 'a pattern of numbers from 0 to 1. Sets the level of reverb.'],
// ['f', 'sagogo', ''],
// ['f', 'sclap', ''],
// ['f', 'sclaves', ''],
// ['f', 'scrash', ''],
['f', 'semitone', ''],
[
'f',
'shape',
'wave shaping distortion, a pattern of numbers from 0 for no distortion up to 1 for loads of distortion.',
],
[
'f',
'size',
'a pattern of numbers from 0 to 1. Sets the perceptual size (reverb time) of the `room` to be used in reverb.',
],
['f', 'slide', ''],
[
'f',
'speed',
'a pattern of numbers which changes the speed of sample playback, i.e. a cheap way of changing pitch. Negative values will play the sample backwards!',
],
['f', 'squiz', ''],
['f', 'stutterdepth', ''],
['f', 'stuttertime', ''],
['f', 'sustain', ''],
['f', 'timescale', ''],
['f', 'timescalewin', ''],
// ['f', 'tomdecay', ''],
[
's',
'unit',
'used in conjunction with `speed`, accepts values of "r" (rate, default behavior), "c" (cycles), or "s" (seconds). Using `unit "c"` means `speed` will be interpreted in units of cycles, e.g. `speed "1"` means samples will be stretched to fill a cycle. Using `unit "s"` means the playback speed will be adjusted so that the duration is the number of seconds specified by `speed`.',
],
['f', 'velocity', ''],
// ['f', 'vcfegint', ''],
// ['f', 'vcoegint', ''],
['f', 'voice', ''],
[
's',
'vowel',
'formant filter to make things sound like vowels, a pattern of either `a`, `e`, `i`, `o` or `u`. Use a rest (`~`) for no effect.',
],
['f', 'waveloss', ''],
['f', 'dur', ''],
// ['f', 'modwheel', ''],
['f', 'expression', ''],
['f', 'sustainpedal', ''],
['f', 'tremolodepth', "Tremolo Audio DSP effect | params are 'tremolorate' and 'tremolodepth'"],
['f', 'tremolorate', "Tremolo Audio DSP effect | params are 'tremolorate' and 'tremolodepth'"],
['f', 'phaserdepth', "Phaser Audio DSP effect | params are 'phaserrate' and 'phaserdepth'"],
['f', 'phaserrate', "Phaser Audio DSP effect | params are 'phaserrate' and 'phaserdepth'"],
['f', 'fshift', 'frequency shifter'],
['f', 'fshiftnote', 'frequency shifter'],
['f', 'fshiftphase', 'frequency shifter'],
['f', 'triode', 'tube distortion'],
['f', 'krush', 'shape/bass enhancer'],
['f', 'kcutoff', ''],
['f', 'octer', 'octaver effect'],
['f', 'octersub', 'octaver effect'],
['f', 'octersubsub', 'octaver effect'],
['f', 'ring', 'ring modulation'],
['f', 'ringf', 'ring modulation'],
['f', 'ringdf', 'ring modulation'],
['f', 'distort', 'noisy fuzzy distortion'],
['f', 'freeze', 'Spectral freeze'],
['f', 'xsdelay', ''],
['f', 'tsdelay', ''],
['f', 'real', 'Spectral conform'],
['f', 'imag', ''],
['f', 'enhance', 'Spectral enhance'],
['f', 'partials', ''],
['f', 'comb', 'Spectral comb'],
['f', 'smear', 'Spectral smear'],
['f', 'scram', 'Spectral scramble'],
['f', 'binshift', 'Spectral binshift'],
['f', 'hbrick', 'High pass sort of spectral filter'],
['f', 'lbrick', 'Low pass sort of spectral filter'],
['f', 'midichan', ''],
['f', 'control', ''],
['f', 'ccn', ''],
['f', 'ccv', ''],
['f', 'polyTouch', ''],
['f', 'midibend', ''],
['f', 'miditouch', ''],
['f', 'ctlNum', ''],
['f', 'frameRate', ''],
['f', 'frames', ''],
['f', 'hours', ''],
['s', 'midicmd', ''],
['f', 'minutes', ''],
['f', 'progNum', ''],
['f', 'seconds', ''],
['f', 'songPtr', ''],
['f', 'uid', ''],
['f', 'val', ''],
['f', 'cps', ''],
];
const _name = (name, ...pats) => sequence(...pats).withValue((x) => ({ [name]: x }));
const _setter = (func) =>
function (...pats) {
return this.set(func(...pats));
};
generic_params.forEach(([type, name, description]) => {
controls[name] = (...pats) => _name(name, ...pats);
Pattern.prototype[name] = _setter(controls[name]);
});
export default controls;
+45
View File
@@ -0,0 +1,45 @@
/*
drawLine.mjs - <short description TODO>
Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/strudel/blob/main/packages/core/drawLine.mjs>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import Fraction, { gcd } from './fraction.mjs';
function drawLine(pat, chars = 60) {
let cycle = 0;
let pos = Fraction(0);
let lines = [''];
let emptyLine = ''; // this will be the "reference" empty line, which will be copied into extra lines
while (lines[0].length < chars) {
const haps = pat.queryArc(cycle, cycle + 1);
const durations = haps.filter((hap) => hap.hasOnset()).map((hap) => hap.duration);
const charFraction = gcd(...durations);
const totalSlots = charFraction.inverse(); // number of character slots for the current cycle
lines = lines.map((line) => line + '|'); // add pipe character before each cycle
emptyLine += '|';
for (let i = 0; i < totalSlots; i++) {
const [begin, end] = [pos, pos.add(charFraction)];
const matches = haps.filter((hap) => hap.whole.begin.lte(begin) && hap.whole.end.gte(end));
const missingLines = matches.length - lines.length;
if (missingLines > 0) {
lines = lines.concat(Array(missingLines).fill(emptyLine));
}
lines = lines.map((line, i) => {
const hap = matches[i];
if (hap) {
const isOnset = hap.whole.begin.eq(begin);
const char = isOnset ? '' + hap.value : '-';
return line + char;
}
return line + '.';
});
emptyLine += '.';
pos = pos.add(charFraction);
}
cycle++;
}
return lines.join('\n');
}
export default drawLine;
+7 -1
View File
@@ -1,4 +1,10 @@
import { Pattern, timeCat } from './strudel.mjs';
/*
euclid.mjs - <short description TODO>
Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/strudel/blob/main/packages/core/euclid.mjs>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { Pattern, timeCat } from './pattern.mjs';
import bjork from 'bjork';
import { rotate } from './util.mjs';
import Fraction from './fraction.mjs';
+3 -4
View File
@@ -2,8 +2,8 @@
<input
type="text"
id="text"
value="cat('lime', slowcat('steelblue','darkblue'),'yellow','salmon','black').every(2,rev).fast(16)"
style="width: 100%; font-size: 1.5em; background: black; color: white; outline: none; position: absolute; top: 0"
value="cat('orange', 'indigo')"
style="width: 100%; font-size: 2em; background: black; color: white; outline: none; position: absolute; top: 0"
spellcheck="false"
/>
<canvas id="canvas"></canvas>
@@ -25,10 +25,9 @@
function paint(code) {
const pattern = eval(code); // run code
const events = pattern.firstCycle(); // query first cycle
ctx.clearRect(0, 0, canvas.width, canvas.height); // clear canvas
events.forEach((event) => {
ctx.fillStyle = event.value;
ctx.fillRect(event.whole.begin * canvas.width, 0, event.duration * canvas.width, canvas.height);
ctx.fillRect(event.whole.begin * canvas.width, 0, event.duration.valueOf() * canvas.width, canvas.height);
});
}
</script>
-237
View File
@@ -1,237 +0,0 @@
<div style="position: absolute; top: 0; right: 0; padding: 4px">
<button id="start" style="margin-bottom: 4px; font-size: 2em">start</button><br />
<button id="stop" style="font-size: 2em">stop</button>
</div>
<textarea
style="font-size: 2em; background: #e8d565; color: #323230; height: 100%; width: 100%; outline: none; border: 0"
id="text"
spellcheck="false"
>
Loading...</textarea
>
<script type="module">
document.body.style = 'margin: 0';
import * as strudel from 'https://cdn.skypack.dev/@strudel.cycles/core@0.0.2';
import 'https://cdn.skypack.dev/@strudel.cycles/core@0.0.2/euclid.mjs';
const { cat, State, TimeSpan } = strudel;
let pattern;
Object.assign(window, strudel); // add strudel to eval scope
const input = document.getElementById('text');
let initialCode = `sequence(880, [440, 660], 440, 660)
.div(slowcat(3,2).slow(2))
.off(1/8,mul(2))
.off(1/4,mul(3))
.legato(2)
.slow(2)`;
try {
initialCode = atob(decodeURIComponent(window.location.href.split('#')[1]));
} catch (err) {
console.warn('failed to decode', err);
}
input.value = initialCode;
const evaluate = () => {
try {
pattern = eval(input.value);
window.location.hash = '#' + encodeURIComponent(btoa(input.value)); // update url hash
} catch (err) {
console.warn(err);
}
};
input.addEventListener('input', () => evaluate());
// helpers to create a worker dynamically without needing a server / extra file
const stringifyFunction = (func) => '(' + func + ')();';
const urlifyFunction = (func) =>
URL.createObjectURL(new Blob([stringifyFunction(func)], { type: 'text/javascript' }));
const createWorker = (func) => new Worker(urlifyFunction(func));
const interval = 0.1;
const lookahead = 0.5;
// this class is basically the tale of two clocks
class Metro {
worker;
audioContext;
interval = 0.2; // query span
lastEnd = 0;
constructor(audioContext, callback, interval = this.interval) {
this.audioContext = audioContext;
this.interval = interval;
this.worker = createWorker(() => {
// we cannot use closures here!
let interval;
let timerID = null; // this is clock #1 (the sloppy js clock)
const clear = () => {
if (timerID) {
clearInterval(timerID);
timerID = null;
}
};
const start = () => {
clear();
if (!interval) {
throw new Error('no interval set! call worker.postMessage({interval}) before starting.');
}
timerID = setInterval(() => postMessage('tick'), interval * 1000);
};
self.onmessage = function (e) {
if (e.data == 'start') {
start();
} else if (e.data.interval) {
interval = e.data.interval;
if (timerID) {
start();
}
} else if (e.data == 'stop') {
clear();
}
};
});
this.worker.postMessage({ interval });
const round = (n, d) => Math.round(n * d) / d;
const precision = 100;
this.worker.onmessage = (e) => {
if (e.data === 'tick') {
const begin = this.lastEnd || this.audioContext.currentTime;
const end = this.audioContext.currentTime + this.interval; // DONT reference begin here!
this.lastEnd = end;
// callback with query span, using clock #2 (the audio clock)
callback(begin, end);
}
};
}
start() {
console.log('start...');
this.audioContext.resume();
this.worker.postMessage('start');
}
stop() {
console.log('stop...');
this.worker.postMessage('stop');
}
}
const audioContext = new AudioContext();
const metro = new Metro(
audioContext,
(begin, end) => {
pattern.query(new State(new TimeSpan(begin, end))).forEach((e) => {
if (!e.part.begin.equals(e.whole.begin)) {
return;
}
if (e.context.createAudioNode) {
e.context.createAudioNode(e);
} else {
// fallback sine wave
const attack = 0.01;
const decay = 0.05;
const sustain = 0.5;
const release = 0.01;
const velocity = (e.context?.velocity || 1) * 0.1;
const osc = audioContext.createOscillator();
osc.type = 'sine';
osc.frequency.value = e.value;
osc.start(e.whole.begin);
const envelope = adsr(attack, decay, sustain, release, velocity, e.whole.begin, e.whole.end);
osc.stop(e.whole.end + release);
osc.connect(envelope);
envelope.connect(audioContext.destination);
}
});
},
interval,
lookahead,
);
const adsr = (attack, decay, sustain, release, velocity, begin, end) => {
const gainNode = audioContext.createGain();
gainNode.gain.setValueAtTime(0, begin);
gainNode.gain.linearRampToValueAtTime(velocity, begin + attack); // attack
gainNode.gain.linearRampToValueAtTime(sustain * velocity, begin + attack + decay); // sustain start
gainNode.gain.setValueAtTime(sustain * velocity, end); // sustain end
gainNode.gain.linearRampToValueAtTime(0, end + release); // release
// for some reason, using exponential ramping creates little cracklings
return gainNode;
};
strudel.Pattern.prototype.withAudioNode = function (createAudioNode) {
return this._withEvent((event) => {
return event.setContext({
...event.context,
createAudioNode: (e) => createAudioNode(e, event.context.createAudioNode?.(event)),
});
});
};
strudel.Pattern.prototype._osc = function (type) {
return this.withAudioNode((e) => {
const osc = audioContext.createOscillator();
osc.type = type;
osc.frequency.value = e.value; // expects frequency..
osc.start(e.whole.begin.valueOf() + lookahead);
osc.stop(e.whole.end.valueOf() + lookahead); // release?
// osc.connect(audioContext.destination);
return osc;
});
};
strudel.Pattern.prototype.define('osc', (type, pat) => pat.osc(type), { patternified: true });
strudel.Pattern.prototype.adsr = function (a = 0.01, d = 0.05, s = 1, r = 0.01) {
return this.withAudioNode((e, node) => {
const velocity = e.context?.velocity || 1;
const envelope = adsr(
a,
d,
s,
r,
velocity,
e.whole.begin.valueOf() + lookahead,
e.whole.end.valueOf() + lookahead,
);
node?.connect(envelope);
return envelope;
});
};
strudel.Pattern.prototype.filter = function (type = 'lowshelf', frequency = 1000, gain = 25) {
return this.withAudioNode((e, node) => {
const filter = audioContext.createBiquadFilter();
filter.type = type;
filter.frequency.value = frequency;
filter.gain.value = gain;
node?.connect(filter);
return filter;
});
};
strudel.Pattern.prototype.out = function () {
const master = audioContext.createGain();
master.gain.value = 0.1;
master.connect(audioContext.destination);
return this.withAudioNode((e, node) => {
if (!node) {
console.warn('out: no source! call .osc() first');
}
node?.connect(master);
});
};
document.getElementById('start').addEventListener('click', () => metro.start());
document.getElementById('stop').addEventListener('click', () => metro.stop());
evaluate(); // evaluate initial code
/*
sequence(1,3/2,1,2).stack(
stack(5,3,4).velocity(.8).slow(2).legato(.2)
//.echo(3, 1/4, .5)
).mul(110) // frequencies
.div(slowcat(slowcat(2,5/4, 3/2),slowcat(3,4/3)).slow(2))
.echoWith(
16, // n of partials / cutoff
tri2.slow(128).div(2), // time between partials
(x,n)=>x // n = partial index 0..n
.mul((n+1)*3/2)
.legato(2)
.velocity(1/((n+1)**1.6)) // amplitude falloff
).legato(2) // note length
*/
</script>
+18 -1
View File
@@ -1,5 +1,11 @@
/*
fraction.mjs - <short description TODO>
Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/strudel/blob/main/packages/core/fraction.mjs>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import Fraction from 'fraction.js';
import { TimeSpan } from './strudel.mjs';
import { TimeSpan } from './timespan.mjs';
// Returns the start of the cycle.
Fraction.prototype.sam = function () {
@@ -16,6 +22,11 @@ Fraction.prototype.wholeCycle = function () {
return new TimeSpan(this.sam(), this.nextSam());
};
// The position of a time value relative to the start of its cycle.
Fraction.prototype.cyclePos = function () {
return this.sub(this.sam());
};
Fraction.prototype.lt = function (other) {
return this.compare(other) < 0;
};
@@ -67,6 +78,12 @@ const fraction = (n) => {
return Fraction(n);
};
export const gcd = (...fractions) => {
return fractions.reduce((gcd, fraction) => gcd.gcd(fraction), fraction(1));
};
fraction._original = Fraction;
export default fraction;
// "If you concern performance, cache Fraction.js objects and pass arrays/objects.“
+6
View File
@@ -1,3 +1,9 @@
/*
gist.js - <short description TODO>
Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/strudel/blob/main/packages/core/gist.js>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
// this is a shortcut to eval code from a gist
// why? to be able to shorten strudel code + e.g. be able to change instruments after links have been generated
export default (route) =>
+106
View File
@@ -0,0 +1,106 @@
/*
hap.mjs - <short description TODO>
Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/strudel/blob/main/packages/core/hap.mjs>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
export class Hap {
/*
Event class, representing a value active during the timespan
'part'. This might be a fragment of an event, in which case the
timespan will be smaller than the 'whole' timespan, otherwise the
two timespans will be the same. The 'part' must never extend outside of the
'whole'. If the event represents a continuously changing value
then the whole will be returned as None, in which case the given
value will have been sampled from the point halfway between the
start and end of the 'part' timespan.
The context is to store a list of source code locations causing the event.
The word 'Event' is more or less a reserved word in javascript, hence this
class is named called 'Hap'.
*/
constructor(whole, part, value, context = {}, stateful = false) {
this.whole = whole;
this.part = part;
this.value = value;
this.context = context;
this.stateful = stateful;
if (stateful) {
console.assert(typeof this.value === 'function', 'Stateful values must be functions');
}
}
get duration() {
return this.whole.end.sub(this.whole.begin);
}
wholeOrPart() {
return this.whole ? this.whole : this.part;
}
withSpan(func) {
// Returns a new hap with the function f applies to the hap timespan.
const whole = this.whole ? func(this.whole) : undefined;
return new Hap(whole, func(this.part), this.value, this.context);
}
withValue(func) {
// Returns a new hap with the function f applies to the hap value.
return new Hap(this.whole, this.part, func(this.value), this.context);
}
hasOnset() {
// Test whether the hap contains the onset, i.e that
// the beginning of the part is the same as that of the whole timespan."""
return this.whole != undefined && this.whole.begin.equals(this.part.begin);
}
resolveState(state) {
if (this.stateful && this.hasOnset()) {
console.log('stateful');
const func = this.value;
const [newState, newValue] = func(state);
return [newState, new Hap(this.whole, this.part, newValue, this.context, false)];
}
return [state, this];
}
spanEquals(other) {
return (this.whole == undefined && other.whole == undefined) || this.whole.equals(other.whole);
}
equals(other) {
return (
this.spanEquals(other) &&
this.part.equals(other.part) &&
// TODO would == be better ??
this.value === other.value
);
}
show() {
return (
'(' + (this.whole == undefined ? '~' : this.whole.show()) + ', ' + this.part.show() + ', ' + this.value + ')'
);
}
showWhole() {
return `${this.whole == undefined ? '~' : this.whole.show()}: ${this.value}`;
}
showWhole() {
return `${this.whole == undefined ? '~' : this.whole.show()}: ${this.value}`;
}
combineContext(b) {
const a = this;
return { ...a.context, ...b.context, locations: (a.context.locations || []).concat(b.context.locations || []) };
}
setContext(context) {
return new Hap(this.whole, this.part, this.value, context);
}
}
export default Hap;
+19
View File
@@ -0,0 +1,19 @@
/*
index.mjs - <short description TODO>
Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/strudel/blob/main/packages/core/index.mjs>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
export * from './controls.mjs';
export * from './euclid.mjs';
import Fraction from './fraction.mjs';
export { Fraction };
export * from './hap.mjs';
export * from './pattern.mjs';
export * from './signal.mjs';
export * from './state.mjs';
export * from './timespan.mjs';
export * from './util.mjs';
export * from './speak.mjs';
export * as gist from './gist.js';
// export * from './value.mjs';
+3 -18
View File
@@ -1,17 +1,16 @@
{
"name": "@strudel.cycles/core",
"version": "0.0.2",
"version": "0.1.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@strudel.cycles/core",
"version": "0.0.1",
"version": "0.0.3",
"license": "GPL-3.0-or-later",
"dependencies": {
"bjork": "^0.0.1",
"fraction.js": "^4.2.0",
"ramda": "^0.28.0"
"fraction.js": "^4.2.0"
},
"devDependencies": {
"mocha": "^9.2.2"
@@ -733,15 +732,6 @@
"url": "https://github.com/sponsors/jonschlinkert"
}
},
"node_modules/ramda": {
"version": "0.28.0",
"resolved": "https://registry.npmjs.org/ramda/-/ramda-0.28.0.tgz",
"integrity": "sha512-9QnLuG/kPVgWvMQ4aODhsBUFKOUmnbUnsSXACv+NCQZcHbeb+v8Lodp8OVxtRULN1/xOyYLLaL6npE6dMq5QTA==",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/ramda"
}
},
"node_modules/randombytes": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz",
@@ -1485,11 +1475,6 @@
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
"dev": true
},
"ramda": {
"version": "0.28.0",
"resolved": "https://registry.npmjs.org/ramda/-/ramda-0.28.0.tgz",
"integrity": "sha512-9QnLuG/kPVgWvMQ4aODhsBUFKOUmnbUnsSXACv+NCQZcHbeb+v8Lodp8OVxtRULN1/xOyYLLaL6npE6dMq5QTA=="
},
"randombytes": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz",
+6 -6
View File
@@ -1,8 +1,8 @@
{
"name": "@strudel.cycles/core",
"version": "0.0.2",
"version": "0.1.0",
"description": "Port of Tidal Cycles to JavaScript",
"main": "strudel.mjs",
"main": "index.mjs",
"type": "module",
"scripts": {
"test": "mocha --colors"
@@ -19,17 +19,17 @@
"algorave"
],
"author": "Alex McLean <alex@slab.org> (https://slab.org)",
"license": "GPL-3.0-or-later",
"license": "AGPL-3.0-or-later",
"bugs": {
"url": "https://github.com/tidalcycles/strudel/issues"
},
"homepage": "https://strudel.tidalcycles.org",
"dependencies": {
"bjork": "^0.0.1",
"fraction.js": "^4.2.0",
"ramda": "^0.28.0"
"fraction.js": "^4.2.0"
},
"devDependencies": {
"mocha": "^9.2.2"
}
},
"gitHead": "0e26d4e741500f5bae35b023608f062a794905c2"
}
File diff suppressed because it is too large Load Diff
+218
View File
@@ -0,0 +1,218 @@
/*
signal.mjs - <short description TODO>
Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/strudel/blob/main/packages/core/signal.mjs>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { Hap } from './hap.mjs';
import { Pattern, fastcat, reify, silence, stack } from './pattern.mjs';
import Fraction from './fraction.mjs';
import { id } from './util.mjs';
export function steady(value) {
// A continuous value
return new Pattern((state) => [new Hap(undefined, state.span, value)]);
}
export const signal = (func) => {
const query = (state) => [new Hap(undefined, state.span, func(state.span.midpoint()))];
return new Pattern(query);
};
export const isaw = signal((t) => 1 - (t % 1));
export const isaw2 = isaw._toBipolar();
export const saw = signal((t) => t % 1);
export const saw2 = saw._toBipolar();
export const sine2 = signal((t) => Math.sin(Math.PI * 2 * t));
export const sine = sine2._fromBipolar();
export const cosine = sine._early(Fraction(1).div(4));
export const cosine2 = sine2._early(Fraction(1).div(4));
export const square = signal((t) => Math.floor((t * 2) % 2));
export const square2 = square._toBipolar();
export const tri = fastcat(isaw, saw);
export const tri2 = fastcat(isaw2, saw2);
export const time = signal(id);
// random signals
const xorwise = (x) => {
const a = (x << 13) ^ x;
const b = (a >> 17) ^ a;
return (b << 5) ^ b;
};
// stretch 300 cycles over the range of [0,2**29 == 536870912) then apply the xorshift algorithm
const _frac = (x) => x - Math.trunc(x);
const timeToIntSeed = (x) => xorwise(Math.trunc(_frac(x / 300) * 536870912));
const intSeedToRand = (x) => (x % 536870912) / 536870912;
const timeToRand = (x) => Math.abs(intSeedToRand(timeToIntSeed(x)));
const timeToRandsPrime = (seed, n) => {
const result = [];
for (let i = 0; i < n; ++n) {
result.push(intSeedToRand(seed));
seed = xorwise(seed);
}
return result;
};
const timeToRands = (t, n) => timeToRandsPrime(timeToIntSeed(t), n);
export const rand = signal(timeToRand);
export const _brandBy = (p) => rand.fmap((x) => x < p);
export const brandBy = (pPat) => reify(pPat).fmap(_brandBy).innerJoin();
export const brand = _brandBy(0.5);
export const _irand = (i) => rand.fmap((x) => Math.trunc(x * i));
export const irand = (ipat) => reify(ipat).fmap(_irand).innerJoin();
export const chooseWith = (pat, xs) => {
xs = xs.map(reify);
if (xs.length == 0) {
return silence;
}
return pat
.range(0, xs.length)
.fmap((i) => xs[Math.floor(i)])
.outerJoin();
};
export const choose = (...xs) => chooseWith(rand, xs);
const _wchooseWith = function (pat, ...pairs) {
const values = pairs.map((pair) => reify(pair[0]));
const weights = [];
let accum = 0;
for (const pair of pairs) {
accum += pair[1];
weights.push(accum);
}
const total = accum;
const match = function (r) {
const find = r * total;
return values[weights.findIndex((x) => x > find, weights)];
};
return pat.fmap(match);
};
const wchooseWith = (...args) => _wchooseWith(...args).outerJoin();
export const wchoose = (...pairs) => wchooseWith(rand, ...pairs);
export const wchooseCycles = (...pairs) => _wchooseWith(rand, ...pairs).innerJoin();
export const perlinWith = (pat) => {
const pata = pat.fmap(Math.floor);
const patb = pat.fmap((t) => Math.floor(t) + 1);
const smootherStep = (x) => 6.0 * x ** 5 - 15.0 * x ** 4 + 10.0 * x ** 3;
const interp = (x) => (a) => (b) => a + smootherStep(x) * (b - a);
return pat.sub(pata).fmap(interp).appBoth(pata.fmap(timeToRand)).appBoth(patb.fmap(timeToRand));
};
export const perlin = perlinWith(time);
Pattern.prototype._degradeByWith = function (withPat, x) {
return this.fmap((a) => (_) => a).appLeft(withPat._filterValues((v) => v > x));
};
Pattern.prototype._degradeBy = function (x) {
return this._degradeByWith(rand, x);
};
Pattern.prototype.degrade = function () {
return this._degradeBy(0.5);
};
Pattern.prototype._undegradeBy = function (x) {
return this._degradeByWith(
rand.fmap((r) => 1 - r),
x,
);
};
Pattern.prototype.undegrade = function () {
return this._undegradeBy(0.5);
};
Pattern.prototype._sometimesBy = function (x, func) {
return stack(this._degradeBy(x), func(this._undegradeBy(1 - x)));
};
Pattern.prototype.sometimesBy = function (patx, func) {
const pat = this;
return reify(patx)
.fmap((x) => pat._sometimesBy(x, func))
.innerJoin();
};
Pattern.prototype._sometimesByPre = function (x, func) {
return stack(this._degradeBy(x), func(this).undegradeBy(1 - x));
};
Pattern.prototype.sometimesByPre = function (patx, func) {
const pat = this;
return reify(patx)
.fmap((x) => pat._sometimesByPre(x, func))
.innerJoin();
};
Pattern.prototype.sometimes = function (func) {
return this._sometimesBy(0.5, func);
};
Pattern.prototype.sometimesPre = function (func) {
return this._sometimesByPre(0.5, func);
};
Pattern.prototype._someCyclesBy = function (x, func) {
return stack(
this._degradeByWith(rand._segment(1), x),
func(this._degradeByWith(rand.fmap((r) => 1 - r)._segment(1), 1 - x)),
);
};
Pattern.prototype.someCyclesBy = function (patx, func) {
const pat = this;
return reify(patx)
.fmap((x) => pat._someCyclesBy(x, func))
.innerJoin();
};
Pattern.prototype.someCycles = function (func) {
return this._someCyclesBy(0.5, func);
};
Pattern.prototype.often = function (func) {
return this.sometimesBy(0.75, func);
};
Pattern.prototype.rarely = function (func) {
return this.sometimesBy(0.25, func);
};
Pattern.prototype.almostNever = function (func) {
return this.sometimesBy(0.1, func);
};
Pattern.prototype.almostAlways = function (func) {
return this.sometimesBy(0.9, func);
};
Pattern.prototype.never = function (func) {
return this;
};
Pattern.prototype.always = function (func) {
return func(this);
};
Pattern.prototype.patternified.push('degradeBy', 'undegradeBy');
+45
View File
@@ -0,0 +1,45 @@
/*
speak.mjs - <short description TODO>
Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/strudel/blob/main/packages/core/speak.mjs>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { Pattern, patternify2 } from './index.mjs';
let synth;
try {
synth = window?.speechSynthesis;
} catch (err) {
console.warn('cannot use window: not in browser?');
}
let allVoices = synth?.getVoices();
// console.log('voices', allVoices);
function speak(words, lang, voice) {
synth.cancel();
const utterance = new SpeechSynthesisUtterance(words);
utterance.lang = lang;
allVoices = synth.getVoices();
const voices = allVoices.filter((v) => v.lang.includes(lang));
if (typeof voice === 'number') {
utterance.voice = voices[voice % voices.length];
} else if (typeof voice === 'string') {
utterance.voice = voices.find((voice) => voice.name === voice);
}
// console.log(utterance.voice?.name, utterance.voice?.lang);
speechSynthesis.speak(utterance);
}
Pattern.prototype._speak = function (lang, voice) {
return this._withHap((hap) => {
const onTrigger = (time, hap) => {
speak(hap.value, lang, voice);
};
return hap.setContext({ ...hap.context, onTrigger });
});
};
Pattern.prototype.speak = function (lang, voice) {
return patternify2(Pattern.prototype._speak)(reify(lang), reify(voice), this);
};
+28
View File
@@ -0,0 +1,28 @@
/*
state.mjs - <short description TODO>
Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/strudel/blob/main/packages/core/state.mjs>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
export class State {
constructor(span, controls = {}) {
this.span = span;
this.controls = controls;
}
// Returns new State with different span
setSpan(span) {
return new State(span, this.controls);
}
withSpan(func) {
return this.setSpan(func(this.span));
}
// Returns new State with different controls
setControls(controls) {
return new State(this.span, controls);
}
}
export default State;
File diff suppressed because it is too large Load Diff
+56
View File
@@ -0,0 +1,56 @@
/*
drawLine.test.mjs - <short description TODO>
Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/strudel/blob/main/packages/core/test/drawLine.test.mjs>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { fastcat, stack, slowcat, silence, pure } from '../pattern.mjs';
import { strict as assert } from 'assert';
import drawLine from '../drawLine.mjs';
describe('drawLine', () => {
it('supports equal lengths', () => {
assert.equal(drawLine(fastcat(0), 4), '|0|0');
assert.equal(drawLine(fastcat(0, 1), 4), '|01|01');
assert.equal(drawLine(fastcat(0, 1, 2), 6), '|012|012');
});
it('supports unequal lengths', () => {
assert.equal(drawLine(fastcat(0, [1, 2]), 10), '|0-12|0-12');
assert.equal(drawLine(fastcat(0, [1, 2, 3]), 10), '|0--123|0--123');
assert.equal(drawLine(fastcat(0, 1, [2, 3]), 10), '|0-1-23|0-1-23');
});
it('supports unequal silence', () => {
assert.equal(drawLine(fastcat(0, silence, [1, 2]), 10), '|0-..12|0-..12');
});
it('supports polyrhythms', () => {
'0*2 1*3';
assert.equal(drawLine(fastcat(pure(0).fast(2), pure(1).fast(3)), 10), '|0--0--1-1-1-');
});
it('supports multiple lines', () => {
assert.equal(
drawLine(fastcat(0, stack(1, 2)), 10),
`|01|01|01|01
|.2|.2|.2|.2`,
);
assert.equal(
drawLine(fastcat(0, 1, stack(2, 3)), 10),
`|012|012|012
|..3|..3|..3`,
);
assert.equal(
drawLine(fastcat(0, stack(1, 2, 3)), 10),
`|01|01|01|01
|.2|.2|.2|.2
|.3|.3|.3|.3`,
);
assert.equal(
drawLine(fastcat(0, 1, stack(2, 3, 4)), 10),
`|012|012|012
|..3|..3|..3
|..4|..4|..4`,
);
});
it('supports unequal cycle lengths', () => {
assert.equal(drawLine(slowcat(0, [1, 2]), 10), `|0|12|0|12`);
});
});
+15
View File
@@ -0,0 +1,15 @@
/*
fraction.test.mjs - <short description TODO>
Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/strudel/blob/main/packages/core/test/fraction.test.mjs>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import Fraction, { gcd } from '../fraction.mjs';
import { strict as assert } from 'assert';
describe('gcd', () => {
it('should work', () => {
const F = Fraction._original;
assert.equal(gcd(F(1 / 6), F(1 / 4)).toFraction(), '1/12');
});
});
File diff suppressed because it is too large Load Diff
+36 -1
View File
@@ -1,5 +1,12 @@
/*
util.test.mjs - <short description TODO>
Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/strudel/blob/main/packages/core/test/util.test.mjs>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { strict as assert } from 'assert';
import { isNote, tokenizeNote, toMidi, mod } from '../util.mjs';
import { pure } from '../pattern.mjs';
import { isNote, tokenizeNote, toMidi, fromMidi, mod, compose, getFrequency } from '../util.mjs';
describe('isNote', () => {
it('should recognize notes without accidentals', () => {
@@ -64,6 +71,21 @@ describe('toMidi', () => {
assert.equal(toMidi('C##3'), 50);
});
});
describe('fromMidi', () => {
it('should turn midi into frequency', () => {
assert.equal(fromMidi(69), 440);
assert.equal(fromMidi(57), 220);
});
});
describe('getFrequency', () => {
it('should turn midi into frequency', () => {
const happify = (val, context = {}) => pure(val).firstCycle()[0].setContext(context);
assert.equal(getFrequency(happify('a4')), 440);
assert.equal(getFrequency(happify('a3')), 220);
assert.equal(getFrequency(happify(440, { type: 'frequency' })), 440); // TODO: migrate when values are objects..
assert.equal(getFrequency(happify(432, { type: 'frequency' })), 432);
});
});
describe('mod', () => {
it('should work like regular modulo with positive numbers', () => {
@@ -83,3 +105,16 @@ describe('mod', () => {
assert.equal(mod(-3, 2), 1);
});
});
describe('compose', () => {
const add1 = (a) => a + 1;
it('should compose', () => {
assert.equal(compose(add1, add1)(0), 2);
assert.equal(compose(add1)(0), 1);
});
const addS = (s) => (a) => a + s;
it('should compose left to right', () => {
assert.equal(compose(addS('a'), addS('b'))(''), 'ab');
assert.equal(compose(addS('a'), addS('b'))('x'), 'xab');
});
});
+6
View File
@@ -1,3 +1,9 @@
/*
value.test.mjs - <short description TODO>
Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/strudel/blob/main/packages/core/test/value.test.mjs>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { strict as assert } from 'assert';
import { map, valued, mul } from '../value.mjs';
+112
View File
@@ -0,0 +1,112 @@
/*
timespan.mjs - <short description TODO>
Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/strudel/blob/main/packages/core/timespan.mjs>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import Fraction from './fraction.mjs';
export class TimeSpan {
constructor(begin, end) {
this.begin = Fraction(begin);
this.end = Fraction(end);
}
get spanCycles() {
const spans = [];
var begin = this.begin;
const end = this.end;
const end_sam = end.sam();
while (end.gt(begin)) {
// If begin and end are in the same cycle, we're done.
if (begin.sam().equals(end_sam)) {
spans.push(new TimeSpan(begin, this.end));
break;
}
// add a timespan up to the next sam
const next_begin = begin.nextSam();
spans.push(new TimeSpan(begin, next_begin));
// continue with the next cycle
begin = next_begin;
}
return spans;
}
get duration() {
return this.end.sub(this.begin);
}
cycleArc() {
// Shifts a timespan to one of equal duration that starts within cycle zero.
// (Note that the output timespan probably does not start *at* Time 0 --
// that only happens when the input Arc starts at an integral Time.)
const b = this.begin.cyclePos();
const e = b.add(this.duration);
return new TimeSpan(b, e);
}
withTime(func_time) {
// Applies given function to both the begin and end time of the timespan"""
return new TimeSpan(func_time(this.begin), func_time(this.end));
}
withEnd(func_time) {
// Applies given function to the end time of the timespan"""
return new TimeSpan(this.begin, func_time(this.end));
}
withCycle(func_time) {
// Like withTime, but time is relative to relative to the cycle (i.e. the
// sam of the start of the timespan)
const sam = this.begin.sam();
const b = sam.add(func_time(this.begin.sub(sam)));
const e = sam.add(func_time(this.end.sub(sam)));
return new TimeSpan(b, e);
}
intersection(other) {
// Intersection of two timespans, returns None if they don't intersect.
const intersect_begin = this.begin.max(other.begin);
const intersect_end = this.end.min(other.end);
if (intersect_begin.gt(intersect_end)) {
return undefined;
}
if (intersect_begin.equals(intersect_end)) {
// Zero-width (point) intersection - doesn't intersect if it's at the end of a
// non-zero-width timespan.
if (intersect_begin.equals(this.end) && this.begin.lt(this.end)) {
return undefined;
}
if (intersect_begin.equals(other.end) && other.begin.lt(other.end)) {
return undefined;
}
}
return new TimeSpan(intersect_begin, intersect_end);
}
intersection_e(other) {
// Like 'sect', but raises an exception if the timespans don't intersect.
const result = this.intersection(other);
if (result == undefined) {
throw 'TimeSpans do not intersect';
}
return result;
}
midpoint() {
return this.begin.add(this.duration.div(Fraction(2)));
}
equals(other) {
return this.begin.equals(other.begin) && this.end.equals(other.end);
}
show() {
return this.begin.show() + ' -> ' + this.end.show();
}
}
export default TimeSpan;
+68 -4
View File
@@ -1,3 +1,9 @@
/*
util.mjs - <short description TODO>
Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/strudel/blob/main/packages/core/util.mjs>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
// returns true if the given string is a note
export const isNote = (name) => /^[a-gA-G][#b]*[0-9]$/.test(name);
export const tokenizeNote = (note) => {
@@ -27,18 +33,76 @@ export const fromMidi = (n) => {
// modulo that works with negative numbers e.g. mod(-1, 3) = 2
// const mod = (n: number, m: number): number => (n < 0 ? mod(n + m, m) : n % m);
export const mod = (n, m) => (n < 0 ? mod(n + m, m) : n % m);
export const mod = (n, m) => ((n % m) + m) % m;
export const getPlayableNoteValue = (event) => {
let { value: note, context } = event;
export const getPlayableNoteValue = (hap) => {
let { value: note, context } = hap;
// if value is number => interpret as midi number as long as its not marked as frequency
if (typeof note === 'number' && context.type !== 'frequency') {
note = fromMidi(event.value);
note = fromMidi(hap.value);
} else if (typeof note === 'string' && !isNote(note)) {
throw new Error('not a note: ' + note);
}
return note;
};
export const getFrequency = (hap) => {
let { value, context } = hap;
// if value is number => interpret as midi number as long as its not marked as frequency
if (typeof value === 'object' && value.freq) {
return value.freq;
}
if (typeof value === 'number' && context.type !== 'frequency') {
value = fromMidi(hap.value);
} else if (typeof value === 'string' && isNote(value)) {
value = fromMidi(toMidi(hap.value));
} else if (typeof value !== 'number') {
throw new Error('not a note or frequency:' + value);
}
return value;
};
// rotate array by n steps (to the left)
export const rotate = (arr, n) => arr.slice(n).concat(arr.slice(0, n));
export const pipe = (...funcs) => {
return funcs.reduce(
(f, g) =>
(...args) =>
f(g(...args)),
(x) => x,
);
};
export const compose = (...funcs) => pipe(...funcs.reverse());
// Removes 'None' values from given list
export const removeUndefineds = (xs) => xs.filter((x) => x != undefined);
export const flatten = (arr) => [].concat(...arr);
export const id = (a) => a;
export const constant = (a, b) => a;
export const listRange = (min, max) => Array.from({ length: max - min + 1 }, (_, i) => i + min);
export function curry(func, overload) {
const fn = function curried(...args) {
if (args.length >= func.length) {
return func.apply(this, args);
} else {
const partial = function (...args2) {
return curried.apply(this, args.concat(args2));
};
if (overload) {
overload(partial, args);
}
return partial;
}
};
if (overload) {
// overload function without args... needed for chordBass.transpose(2)
overload(fn, []);
}
return fn;
}
+8 -2
View File
@@ -1,6 +1,12 @@
import { curry } from 'ramda';
/*
value.mjs - <short description TODO>
Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/strudel/blob/main/packages/core/value.mjs>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
function unionWithObj(a, b, func) {
import { curry } from './util.mjs';
export function unionWithObj(a, b, func) {
const common = Object.keys(a).filter((k) => Object.keys(b).includes(k));
return Object.assign({}, a, b, Object.fromEntries(common.map((k) => [k, func(a[k], b[k])])));
}
+27
View File
@@ -0,0 +1,27 @@
# @strudel.cycles/embed
This package contains a embeddable web component for the Strudel REPL.
## Usage
Either install with `npm i @strudel.cycles/embed` or just use a cdn to import the script:
```html
<script src="https://unpkg.com/@strudel.cycles/embed@latest"></script>
<strudel-repl>
<!--
"a4 [a3 c3] a3 c3".color('#F9D649')
.sub("<7 12 5 12>".slow(2))
.off(1/4,x=>x.add(7).color("#FFFFFF #0C3AA1 #C63928"))
.off(1/8,x=>x.add(12).color('#215CB6'))
.slow(2)
.legato(sine.range(0.3, 2).slow(28))
.wave("sawtooth square".fast(2))
.filter('lowpass', cosine.range(500,4000).slow(16))
.out()
.pianoroll({minMidi:20,maxMidi:120,background:'#202124'})
-->
</strudel-repl>
```
Note that the Code is placed inside HTML comments to prevent the browser from treating it as HTML.
+18
View File
@@ -0,0 +1,18 @@
class Strudel extends HTMLElement {
constructor() {
super();
}
connectedCallback() {
setTimeout(() => {
const code = (this.innerHTML + '').replace('<!--', '').replace('-->', '').trim();
const iframe = document.createElement('iframe');
const src = `https://strudel.tidalcycles.org/#${encodeURIComponent(btoa(code))}`;
// const src = `http://localhost:3000/#${encodeURIComponent(btoa(code))}`;
iframe.setAttribute('src', src);
iframe.setAttribute('width', '600');
iframe.setAttribute('height', '400');
this.appendChild(iframe);
});
}
}
customElements.define('strudel-repl', Strudel);
+16
View File
@@ -0,0 +1,16 @@
<script src="https://unpkg.com/@strudel.cycles/embed@latest"></script>
<!-- <script src="./embed.js"></script> -->
<strudel-repl>
<!--
"a4 [a3 c3] a3 c3".color('#F9D649')
.sub("<7 12 5 12>".slow(2))
.off(1/4,x=>x.add(7).color("#FFFFFF #0C3AA1 #C63928"))
.off(1/8,x=>x.add(12).color('#215CB6'))
.slow(2)
.legato(sine.range(0.3, 2).slow(28))
.wave("sawtooth square".fast(2))
.filter('lowpass', cosine.range(500,4000).slow(16))
.out()
.pianoroll({minMidi:20,maxMidi:120,background:'#202124'})
-->
</strudel-repl>
+24
View File
@@ -0,0 +1,24 @@
{
"name": "@strudel.cycles/embed",
"version": "0.1.0",
"description": "Embeddable Web Component to load a Strudel REPL into an iframe",
"main": "embed.js",
"type": "module",
"repository": {
"type": "git",
"url": "git+https://github.com/tidalcycles/strudel.git"
},
"keywords": [
"tidalcycles",
"strudel",
"pattern",
"livecoding",
"algorave"
],
"author": "Felix Roos <flix91@gmail.com>",
"license": "AGPL-3.0-or-later",
"bugs": {
"url": "https://github.com/tidalcycles/strudel/issues"
},
"homepage": "https://github.com/tidalcycles/strudel#readme"
}
+2
View File
@@ -11,6 +11,8 @@ npm i @strudel.cycles/eval --save
## Example
<!-- TODO: -extend +evalScope -->
```js
import { evaluate, extend } from '@strudel.cycles/eval';
import * as strudel from '@strudel.cycles/core';
+32 -4
View File
@@ -1,17 +1,45 @@
/*
evaluate.mjs - <short description TODO>
Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/strudel/blob/main/packages/eval/evaluate.mjs>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import shapeshifter from './shapeshifter.mjs';
import * as strudel from '@strudel.cycles/core';
const { isPattern } = strudel;
const { isPattern, Pattern } = strudel;
export const extend = (...args) => {
// TODO: find a way to make args available to eval without adding it to global scope...
// sadly, "with" does not work in strict mode
console.warn('@strudel.cycles/eval extend is deprecated, please use evalScope instead');
Object.assign(globalThis, ...args);
};
let scoped = false;
export const evalScope = async (...args) => {
if (scoped) {
console.warn('@strudel.cycles/eval evalScope was called more than once.');
}
scoped = true;
const results = await Promise.allSettled(args);
const modules = results.filter((result) => result.status === 'fulfilled').map((r) => r.value);
results.forEach((result, i) => {
if (result.status === 'rejected') {
console.warn(`evalScope: module with index ${i} could not be loaded:`, result.reason);
}
});
Object.assign(globalThis, ...modules, Pattern.prototype.bootstrap());
};
function safeEval(str) {
return Function('"use strict";return (' + str + ')')();
}
export const evaluate = async (code) => {
if (!scoped) {
await evalScope(); // at least scope Pattern.prototype.boostrap
}
const shapeshifted = shapeshifter(code); // transform syntactically correct js code to semantically usable code
let evaluated = await eval(shapeshifted);
let evaluated = await safeEval(shapeshifted);
if (!isPattern(evaluated)) {
console.log('evaluated', evaluated);
const message = `got "${typeof evaluated}" instead of pattern`;
+1
View File
@@ -0,0 +1 @@
export * from './evaluate.mjs';
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "@strudel.cycles/eval",
"version": "0.0.2",
"version": "0.1.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@strudel.cycles/eval",
"version": "0.0.1",
"version": "0.0.3",
"license": "GPL-3.0-or-later",
"dependencies": {
"estraverse": "^5.3.0",
+5 -5
View File
@@ -1,8 +1,9 @@
{
"name": "@strudel.cycles/eval",
"version": "0.0.2",
"version": "0.1.1",
"description": "Code evaluator for strudel",
"main": "evaluate.mjs",
"main": "index.mjs",
"type": "module",
"directories": {
"test": "test"
},
@@ -13,7 +14,6 @@
"type": "git",
"url": "git+https://github.com/tidalcycles/strudel.git"
},
"type": "module",
"keywords": [
"tidalcycles",
"strudel",
@@ -22,13 +22,13 @@
"algorave"
],
"author": "Felix Roos <flix91@gmail.com>",
"license": "GPL-3.0-or-later",
"license": "AGPL-3.0-or-later",
"bugs": {
"url": "https://github.com/tidalcycles/strudel/issues"
},
"homepage": "https://github.com/tidalcycles/strudel#readme",
"dependencies": {
"@strudel.cycles/core": "^0.0.2",
"@strudel.cycles/core": "^0.1.0",
"estraverse": "^5.3.0",
"shift-ast": "^6.1.0",
"shift-codegen": "^7.0.3",
+29 -10
View File
@@ -1,3 +1,9 @@
/*
shapeshifter.mjs - <short description TODO>
Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/strudel/blob/main/packages/eval/shapeshifter.mjs>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/* import { parseScriptWithLocation } from './shift-parser/index.js'; // npm module does not work in the browser
import traverser from './shift-traverser/index.js'; // npm module does not work in the browser */
import { parseScriptWithLocation } from 'shift-parser';
@@ -15,7 +21,7 @@ import {
import shiftCodegen from 'shift-codegen';
const codegen = shiftCodegen.default || shiftCodegen; // parcel module resolution fuckup
import * as strudel from '@strudel.cycles/core/strudel.mjs';
import * as strudel from '@strudel.cycles/core';
const { Pattern } = strudel;
@@ -23,6 +29,8 @@ const isNote = (name) => /^[a-gC-G][bs]?[0-9]$/.test(name);
const addLocations = true;
export const addMiniLocations = true;
export const minifyStrings = true;
export const wrappedAsync = true;
export default (_code) => {
const { code, addReturn } = wrapAsync(_code);
@@ -38,18 +46,18 @@ export default (_code) => {
}
// replace template string `xxx` with mini(`xxx`)
if (isBackTickString(node)) {
if (minifyStrings && isBackTickString(node)) {
return minifyWithLocation(node, node, ast.locations, artificialNodes);
}
// allows to use top level strings, which are normally directives... but we don't need directives
if (node.directives?.length === 1 && !node.statements?.length) {
if (minifyStrings && node.directives?.length === 1 && !node.statements?.length) {
const str = new LiteralStringExpression({ value: node.directives[0].rawValue });
const wrapped = minifyWithLocation(str, node.directives[0], ast.locations, artificialNodes);
return { ...node, directives: [], statements: [wrapped] };
}
// replace double quote string "xxx" with mini('xxx')
if (isStringWithDoubleQuotes(node, ast.locations, code)) {
if (minifyStrings && isStringWithDoubleQuotes(node, ast.locations, code)) {
return minifyWithLocation(node, node, ast.locations, artificialNodes);
}
@@ -117,7 +125,9 @@ export default (_code) => {
},
});
// add return to last statement (because it's wrapped in an async function artificially)
addReturn(shifted);
if (wrappedAsync) {
addReturn(shifted);
}
const generated = codegen(shifted);
return generated;
};
@@ -125,9 +135,11 @@ export default (_code) => {
function wrapAsync(code) {
// wrap code in async to make await work on top level => this will create 1 line offset to locations
// this is why line offset is -1 in getLocationObject calls below
code = `(async () => {
if (wrappedAsync) {
code = `(async () => {
${code}
})()`;
}
const addReturn = (ast) => {
const body = ast.statements[0].expression.callee.body; // actual code ast inside async function body
body.statements = body.statements
@@ -204,9 +216,10 @@ function hasModifierCall(parent) {
parent?.type === 'StaticMemberExpression' && Object.keys(Pattern.prototype.composable).includes(parent.property)
);
}
const factories = Object.keys(Pattern.prototype.factories).concat(['mini']);
function isPatternFactory(node) {
return node?.type === 'CallExpression' && Object.keys(Pattern.prototype.factories).includes(node.callee.name);
return node?.type === 'CallExpression' && factories.includes(node.callee.name);
}
function canBeOverloaded(node) {
@@ -233,9 +246,14 @@ function reifyWithLocation(literalNode, node, locations, artificialNodes) {
// with this, the reified pattern can pass its location to the event, to know where to highlight when it's active
function minifyWithLocation(literalNode, node, locations, artificialNodes) {
const args = getLocationArguments(node, locations);
const wrapped = wrapFunction('mini', literalNode);
if (!addMiniLocations) {
artificialNodes.push(wrapped);
return wrapped;
}
const withLocation = new CallExpression({
callee: new StaticMemberExpression({
object: wrapFunction('mini', literalNode),
object: wrapped,
property: 'withMiniLocation',
}),
arguments: args,
@@ -246,17 +264,18 @@ function minifyWithLocation(literalNode, node, locations, artificialNodes) {
function getLocationArguments(node, locations) {
const loc = locations.get(node);
const lineOffset = wrappedAsync ? -1 : 0;
return [
new ArrayExpression({
elements: [
new LiteralNumericExpression({ value: loc.start.line - 1 }), // the minus 1 assumes the code has been wrapped in async iife
new LiteralNumericExpression({ value: loc.start.line + lineOffset }), // the minus 1 assumes the code has been wrapped in async iife
new LiteralNumericExpression({ value: loc.start.column }),
new LiteralNumericExpression({ value: loc.start.offset }),
],
}),
new ArrayExpression({
elements: [
new LiteralNumericExpression({ value: loc.end.line - 1 }), // the minus 1 assumes the code has been wrapped in async iife
new LiteralNumericExpression({ value: loc.end.line + lineOffset }), // the minus 1 assumes the code has been wrapped in async iife
new LiteralNumericExpression({ value: loc.end.column }),
new LiteralNumericExpression({ value: loc.end.offset }),
],
+6
View File
@@ -1,3 +1,9 @@
/*
index.js - <short description TODO>
Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/strudel/blob/main/packages/eval/shift-traverser/index.js>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/*
Copyright (C) 2014 Yusuke Suzuki <utatane.tea@gmail.com>
+10 -3
View File
@@ -1,22 +1,29 @@
/*
evaluate.test.mjs - <short description TODO>
Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/strudel/blob/main/packages/eval/test/evaluate.test.mjs>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { strict as assert } from 'assert';
import { evaluate, extend } from '../evaluate.mjs';
import { mini } from '@strudel.cycles/mini';
import * as strudel from '@strudel.cycles/core';
const { cat } = strudel;
const { fastcat } = strudel;
extend({ mini }, strudel);
// TODO: test evalScope
describe('evaluate', () => {
const ev = async (code) => (await evaluate(code)).pattern._firstCycleValues;
it('Should evaluate strudel functions', async () => {
assert.deepStrictEqual(await ev("pure('c3')"), ['c3']);
assert.deepStrictEqual(await ev('cat(c3)'), ['c3']);
assert.deepStrictEqual(await ev('cat(c3, d3)'), ['c3', 'd3']);
assert.deepStrictEqual(await ev('fastcat(c3, d3)'), ['c3', 'd3']);
assert.deepStrictEqual(await ev('slowcat(c3, d3)'), ['c3']);
});
it('Should be extendable', async () => {
extend({ myFunction: (...x) => cat(...x) });
extend({ myFunction: (...x) => fastcat(...x) });
assert.deepStrictEqual(await ev('myFunction(c3, d3)'), ['c3', 'd3']);
});
it('Should evaluate simple double quoted mini notation', async () => {
+6
View File
@@ -1,3 +1,9 @@
/*
shapeshifter.test.mjs - <short description TODO>
Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/strudel/blob/main/packages/eval/test/shapeshifter.test.mjs>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { strict as assert } from 'assert';
import shapeshifter from '../shapeshifter.mjs';
+3
View File
@@ -0,0 +1,3 @@
import './midi.mjs';
export * from './midi.mjs';
+14 -8
View File
@@ -1,6 +1,12 @@
/*
midi.mjs - <short description TODO>
Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/strudel/blob/main/packages/midi/midi.mjs>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { isNote } from 'tone';
import _WebMidi from 'webmidi';
import { Pattern, isPattern } from '@strudel.cycles/core/strudel.mjs';
import { Pattern, isPattern } from '@strudel.cycles/core';
import { Tone } from '@strudel.cycles/tone';
// if you use WebMidi from outside of this package, make sure to import that instance:
@@ -33,11 +39,11 @@ Pattern.prototype.midi = function (output, channel = 1) {
}')`,
);
}
return this._withEvent((event) => {
// const onTrigger = (time: number, event: any) => {
const onTrigger = (time, event) => {
let note = event.value;
const velocity = event.context?.velocity ?? 0.9;
return this._withHap((hap) => {
// const onTrigger = (time: number, hap: any) => {
const onTrigger = (time, hap) => {
let note = hap.value;
const velocity = hap.context?.velocity ?? 0.9;
if (!isNote(note)) {
throw new Error('not a note: ' + note);
}
@@ -69,10 +75,10 @@ Pattern.prototype.midi = function (output, channel = 1) {
// await enableWebMidi()
device.playNote(note, channel, {
time,
duration: event.duration * 1000 - 5,
duration: hap.duration.valueOf() * 1000 - 5,
velocity,
});
};
return event.setContext({ ...event.context, onTrigger });
return hap.setContext({ ...hap.context, onTrigger });
});
};
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "@strudel.cycles/midi",
"version": "0.0.3",
"version": "0.1.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@strudel.cycles/midi",
"version": "0.0.1",
"version": "0.0.4",
"license": "GPL-3.0-or-later",
"dependencies": {
"tone": "^14.7.77",
+4 -4
View File
@@ -1,8 +1,8 @@
{
"name": "@strudel.cycles/midi",
"version": "0.0.3",
"version": "0.1.1",
"description": "Midi API for strudel",
"main": "midi.mjs",
"main": "index.mjs",
"repository": {
"type": "git",
"url": "git+https://github.com/tidalcycles/strudel.git"
@@ -15,13 +15,13 @@
"algorave"
],
"author": "Felix Roos <flix91@gmail.com>",
"license": "GPL-3.0-or-later",
"license": "AGPL-3.0-or-later",
"bugs": {
"url": "https://github.com/tidalcycles/strudel/issues"
},
"homepage": "https://github.com/tidalcycles/strudel#readme",
"dependencies": {
"@strudel.cycles/tone": "^0.0.3",
"@strudel.cycles/tone": "^0.1.1",
"tone": "^14.7.77",
"webmidi": "^2.5.2"
}
+2
View File
@@ -0,0 +1,2 @@
export * from './mini.mjs';
export * from './krill-parser.js';
+6
View File
@@ -1,3 +1,9 @@
/*
krill-parser.js - <short description TODO>
Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/strudel/blob/main/packages/mini/krill-parser.js>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
// Generated by Peggy 1.2.0.
//
// https://peggyjs.org/
+6
View File
@@ -1,3 +1,9 @@
/*
krill.pegjs - <short description TODO>
Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/strudel/blob/main/packages/mini/krill.pegjs>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
// Some terminology:
// a sequence = a serie of elements placed between quotes
// a stack = a serie of vertically aligned slices sharing the same overall length
+7 -1
View File
@@ -1,5 +1,11 @@
/*
mini.mjs - <short description TODO>
Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/strudel/blob/main/packages/mini/mini.mjs>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import * as krill from './krill-parser.js';
import * as strudel from '@strudel.cycles/core/strudel.mjs';
import * as strudel from '@strudel.cycles/core';
import { addMiniLocations } from '@strudel.cycles/eval/shapeshifter.mjs';
const { pure, Pattern, Fraction, stack, slowcat, sequence, timeCat, silence, reify } = strudel;
+6 -5
View File
@@ -1,8 +1,8 @@
{
"name": "@strudel.cycles/mini",
"version": "0.0.3",
"version": "0.1.1",
"description": "Mini notation for strudel",
"main": "mini.mjs",
"main": "index.mjs",
"type": "module",
"scripts": {
"test": "mocha --colors"
@@ -19,13 +19,14 @@
"algorave"
],
"author": "Felix Roos <flix91@gmail.com>",
"license": "GPL-3.0-or-later",
"license": "AGPL-3.0-or-later",
"bugs": {
"url": "https://github.com/tidalcycles/strudel/issues"
},
"homepage": "https://github.com/tidalcycles/strudel#readme",
"dependencies": {
"@strudel.cycles/eval": "^0.0.2",
"@strudel.cycles/tone": "^0.0.3"
"@strudel.cycles/core": "^0.1.0",
"@strudel.cycles/eval": "^0.1.1",
"@strudel.cycles/tone": "^0.1.1"
}
}
+6
View File
@@ -1,3 +1,9 @@
/*
mini.test.mjs - <short description TODO>
Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/strudel/blob/main/packages/mini/test/mini.test.mjs>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { strict as assert } from 'assert';
import { mini } from '../mini.mjs';
import '@strudel.cycles/core/euclid.mjs';
+37
View File
@@ -0,0 +1,37 @@
# @strudel.cycles/osc
OSC output for strudel patterns! Currently only tested with super collider / super dirt.
## Usage
OSC will only work if you run the REPL locally + the OSC server besides it:
From the project root:
```js
npm run repl
```
and in a seperate shell:
```js
npm run osc
```
This should give you
```log
osc client running on port 57120
osc server running on port 57121
websocket server running on port 8080
```
Now open Supercollider (with the super dirt startup file)
Now open the REPL and type:
```js
s("<bd sd> hh").osc()
```
or just [click here](http://localhost:3000/#cygiPGJkIHNkPiBoaCIpLm9zYygp)...
+22
View File
@@ -0,0 +1,22 @@
<button id="send" style="font-size: 2em">Thank you @ojack</button>
<script type="text/javascript" src="./node_modules/osc-js/lib/osc.min.js"></script>
<script type="text/javascript">
const comm = new OSC();
comm.open(); // connect by default to ws://localhost:8080
document.getElementById('send').addEventListener('click', function () {
// this will send a message via websocket to the node server
// the great question: how do i know which time super collider is at????????
const message = new OSC.Message(
'/dirt/play',
...['_id_', '1', 'cps', 0.5625, 'cycle', 412.3333435058594, 'delta', 0.592592716217041, 'orbit', 0, 's', 'hh'],
);
comm.send(message);
console.log('sent:', message.address, message.args);
});
/*
comm.on('*', (m) => {
console.log('received:', m.address, m.args);
}); */
</script>
+33
View File
@@ -0,0 +1,33 @@
/*
osc.mjs - <short description TODO>
Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/strudel/blob/main/packages/osc/osc.mjs>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import OSC from 'osc-js';
import { Pattern } from '@strudel.cycles/core';
const comm = new OSC();
comm.open();
const latency = 0.1;
let startedAt = -1;
Pattern.prototype.osc = function () {
return this._withHap((hap) => {
const onTrigger = (time, hap, currentTime, cps, cycle, delta) => {
// time should be audio time of onset
// currentTime should be current time of audio context (slightly before time)
if (startedAt < 0) {
startedAt = Date.now() - (currentTime * 1000);
}
const controls = Object.assign({}, { cps: cps, cycle: cycle, delta: delta }, hap.value);
const keyvals = Object.entries(controls).flat();
const ts = Math.floor(startedAt + ((time + latency) * 1000));
const message = new OSC.Message('/dirt/play', ...keyvals);
const bundle = new OSC.Bundle([message], ts);
bundle.timestamp(ts); // workaround for https://github.com/adzialocha/osc-js/issues/60
comm.send(bundle);
};
return hap.setContext({ ...hap.context, onTrigger });
});
};
+60
View File
@@ -0,0 +1,60 @@
{
"name": "@strudel.cycles/osc",
"version": "0.1.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@strudel.cycles/osc",
"version": "0.0.1",
"license": "GPL-3.0-or-later",
"dependencies": {
"osc-js": "^2.3.2"
}
},
"node_modules/osc-js": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/osc-js/-/osc-js-2.3.2.tgz",
"integrity": "sha512-9i7J4u1hH+glooGMh+ki1ni0JGqKmylT8r0nXKugHbRK63rR+kl4O+5tGW6+/EszjbCju3KV+eXQQzFDdGrmhg==",
"dependencies": {
"ws": "^8.5.0"
}
},
"node_modules/ws": {
"version": "8.5.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.5.0.tgz",
"integrity": "sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg==",
"engines": {
"node": ">=10.0.0"
},
"peerDependencies": {
"bufferutil": "^4.0.1",
"utf-8-validate": "^5.0.2"
},
"peerDependenciesMeta": {
"bufferutil": {
"optional": true
},
"utf-8-validate": {
"optional": true
}
}
}
},
"dependencies": {
"osc-js": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/osc-js/-/osc-js-2.3.2.tgz",
"integrity": "sha512-9i7J4u1hH+glooGMh+ki1ni0JGqKmylT8r0nXKugHbRK63rR+kl4O+5tGW6+/EszjbCju3KV+eXQQzFDdGrmhg==",
"requires": {
"ws": "^8.5.0"
}
},
"ws": {
"version": "8.5.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.5.0.tgz",
"integrity": "sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg==",
"requires": {}
}
}
}
+35
View File
@@ -0,0 +1,35 @@
{
"name": "@strudel.cycles/osc",
"version": "0.1.0",
"description": "OSC messaging for strudel",
"main": "osc.mjs",
"scripts": {
"test": "echo \"No tests present.\" && exit 0",
"server": "node server.js",
"tidal-sniffer": "node tidal-sniffer.js",
"client": "npx serve -p 4321"
},
"repository": {
"type": "git",
"url": "git+https://github.com/tidalcycles/strudel.git"
},
"keywords": [
"tidalcycles",
"strudel",
"pattern",
"livecoding",
"algorave"
],
"author": "Felix Roos <flix91@gmail.com>",
"contributors": [
"Alex McLean <alex@slab.org>"
],
"license": "AGPL-3.0-or-later",
"bugs": {
"url": "https://github.com/tidalcycles/strudel/issues"
},
"homepage": "https://github.com/tidalcycles/strudel#readme",
"dependencies": {
"osc-js": "^2.3.2"
}
}
+36
View File
@@ -0,0 +1,36 @@
/*
server.js - <short description TODO>
Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/strudel/blob/main/packages/osc/server.js>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
const OSC = require('osc-js');
const config = {
receiver: 'ws', // @param {string} Where messages sent via 'send' method will be delivered to, 'ws' for Websocket clients, 'udp' for udp client
udpServer: {
host: 'localhost', // @param {string} Hostname of udp server to bind to
port: 57121, // @param {number} Port of udp client for messaging
// enabling the following line will receive tidal messages:
// port: 57120, // @param {number} Port of udp client for messaging
exclusive: false, // @param {boolean} Exclusive flag
},
udpClient: {
host: 'localhost', // @param {string} Hostname of udp client for messaging
port: 57120, // @param {number} Port of udp client for messaging
},
wsServer: {
host: 'localhost', // @param {string} Hostname of WebSocket server
port: 8080, // @param {number} Port of WebSocket server
},
};
const osc = new OSC({ plugin: new OSC.BridgePlugin(config) });
osc.open(); // start a WebSocket server on port 8080
console.log('osc client running on port', config.udpClient.port);
console.log('osc server running on port', config.udpServer.port);
console.log('websocket server running on port', config.wsServer.port);
+131
View File
@@ -0,0 +1,131 @@
/*
tidal-sniffer.js - <short description TODO>
Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/strudel/blob/main/packages/osc/tidal-sniffer.js>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
const OSC = require('osc-js');
const config = {
receiver: 'ws', // @param {string} Where messages sent via 'send' method will be delivered to, 'ws' for Websocket clients, 'udp' for udp client
udpServer: {
host: 'localhost', // @param {string} Hostname of udp server to bind to
port: 57120, // @param {number} Port of udp client for messaging
exclusive: false, // @param {boolean} Exclusive flag
},
udpClient: {
host: 'localhost', // @param {string} Hostname of udp client for messaging
// port: 57120, // @param {number} Port of udp client for messaging
port: 41235, // @param {number} Port of udp client for messaging
},
wsServer: {
host: 'localhost', // @param {string} Hostname of WebSocket server
port: 8080, // @param {number} Port of WebSocket server
},
};
const osc = new OSC({ plugin: new OSC.BridgePlugin(config) });
osc.open(); // start a WebSocket server on port 8080
console.log('osc client running on port', config.udpClient.port);
console.log('osc server running on port', config.udpServer.port);
console.log('websocket server running on port', config.wsServer.port);
// listen for messages from the client
osc.on('*', (m) => {
console.log('received:', m.address, m.args);
});
/*
example tidal messages:
/*
received: /dirt/play [
'_id_',
'1',
'cps',
0.5625,
'cycle',
503.5,
'delta',
0.8888888359069824,
'orbit',
0,
's',
'bd'
]
received: /dirt/play [
'_id_', '1',
'cps', 0.5625,
'cycle', 503.6666564941406,
'delta', 0.592592716217041,
'orbit', 0,
's', 'hh'
]
received: /dirt/play [
'_id_',
'1',
'cps',
0.5625,
'cycle',
504,
'delta',
0.8888888359069824,
'orbit',
0,
's',
'bd'
]
received: /dirt/play [
'_id_',
'1',
'cps',
0.5625,
'cycle',
504,
'delta',
0.592592716217041,
'orbit',
0,
's',
'hh'
]
received: /dirt/play [
'_id_',
'1',
'cps',
0.5625,
'cycle',
504.3333435058594,
'delta',
0.5925922393798828,
'orbit',
0,
's',
'hh'
]
received: /dirt/play [
'_id_',
'1',
'cps',
0.5625,
'cycle',
504.5,
'delta',
0.8888888359069824,
'orbit',
0,
's',
'bd'
]
received: /dirt/play [
'_id_', '1',
'cps', 0.5625,
'cycle', 504.6666564941406,
'delta', 0.592592716217041,
'orbit', 0,
's', 'hh'
]
*/
+25
View File
@@ -0,0 +1,25 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist-ssr
*.local
!dist
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
+4
View File
@@ -0,0 +1,4 @@
# @strudel.cycles/react
This package contains react hooks and components for strudel.
Example coming soon
File diff suppressed because one or more lines are too long
+620
View File
@@ -0,0 +1,620 @@
import React, { useState, useEffect, useCallback, useMemo, useRef } from 'react';
import { CodeMirror as CodeMirror$1 } from 'react-codemirror6';
import { EditorView, Decoration } from '@codemirror/view';
import { StateEffect, StateField } from '@codemirror/state';
import { javascript } from '@codemirror/lang-javascript';
import { HighlightStyle, tags } from '@codemirror/highlight';
import { useInView } from 'react-hook-inview';
import { evaluate } from '@strudel.cycles/eval';
import { getPlayableNoteValue } from '@strudel.cycles/core/util.mjs';
import { Tone } from '@strudel.cycles/tone';
import { TimeSpan, State } from '@strudel.cycles/core';
import { WebMidi, enableWebMidi } from '@strudel.cycles/midi';
/*
Credits for color palette:
Author: Mattia Astorino (http://github.com/equinusocio)
Website: https://material-theme.site/
*/
const ivory = '#abb2bf',
stone = '#7d8799', // Brightened compared to original to increase contrast
invalid = '#ffffff',
darkBackground = '#21252b',
highlightBackground = 'rgba(0, 0, 0, 0.5)',
// background = '#292d3e',
background = 'transparent',
tooltipBackground = '#353a42',
selection = 'rgba(128, 203, 196, 0.2)',
cursor = '#ffcc00';
/// The editor theme styles for Material Palenight.
const materialPalenightTheme = EditorView.theme(
{
// done
'&': {
color: '#ffffff',
backgroundColor: background,
fontSize: '15px',
'z-index': 11,
},
// done
'.cm-content': {
caretColor: cursor,
lineHeight: '22px',
},
'.cm-line': {
background: '#2C323699',
},
// done
'&.cm-focused .cm-cursor': {
borderLeftColor: cursor,
},
'&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection': {
backgroundColor: selection,
},
'.cm-panels': { backgroundColor: darkBackground, color: '#ffffff' },
'.cm-panels.cm-panels-top': { borderBottom: '2px solid black' },
'.cm-panels.cm-panels-bottom': { borderTop: '2px solid black' },
// done, use onedarktheme
'.cm-searchMatch': {
backgroundColor: '#72a1ff59',
outline: '1px solid #457dff',
},
'.cm-searchMatch.cm-searchMatch-selected': {
backgroundColor: '#6199ff2f',
},
'.cm-activeLine': { backgroundColor: highlightBackground },
'.cm-selectionMatch': { backgroundColor: '#aafe661a' },
'&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket': {
backgroundColor: '#bad0f847',
outline: '1px solid #515a6b',
},
// done
'.cm-gutters': {
background: '#2C323699',
color: '#676e95',
border: 'none',
},
'.cm-activeLineGutter': {
backgroundColor: highlightBackground,
},
'.cm-foldPlaceholder': {
backgroundColor: 'transparent',
border: 'none',
color: '#ddd',
},
'.cm-tooltip': {
border: 'none',
backgroundColor: tooltipBackground,
},
'.cm-tooltip .cm-tooltip-arrow:before': {
borderTopColor: 'transparent',
borderBottomColor: 'transparent',
},
'.cm-tooltip .cm-tooltip-arrow:after': {
borderTopColor: tooltipBackground,
borderBottomColor: tooltipBackground,
},
'.cm-tooltip-autocomplete': {
'& > ul > li[aria-selected]': {
backgroundColor: highlightBackground,
color: ivory,
},
},
},
{ dark: true },
);
/// The highlighting style for code in the Material Palenight theme.
const materialPalenightHighlightStyle = HighlightStyle.define([
{ tag: tags.keyword, color: '#c792ea' },
{ tag: tags.operator, color: '#89ddff' },
{ tag: tags.special(tags.variableName), color: '#eeffff' },
{ tag: tags.typeName, color: '#f07178' },
{ tag: tags.atom, color: '#f78c6c' },
{ tag: tags.number, color: '#ff5370' },
{ tag: tags.definition(tags.variableName), color: '#82aaff' },
{ tag: tags.string, color: '#c3e88d' },
{ tag: tags.special(tags.string), color: '#f07178' },
{ tag: tags.comment, color: stone },
{ tag: tags.variableName, color: '#f07178' },
{ tag: tags.tagName, color: '#ff5370' },
{ tag: tags.bracket, color: '#a2a1a4' },
{ tag: tags.meta, color: '#ffcb6b' },
{ tag: tags.attributeName, color: '#c792ea' },
{ tag: tags.propertyName, color: '#c792ea' },
{ tag: tags.className, color: '#decb6b' },
{ tag: tags.invalid, color: invalid },
]);
/// Extension to enable the Material Palenight theme (both the editor theme and
/// the highlight style).
// : Extension
const materialPalenight = [materialPalenightTheme, materialPalenightHighlightStyle];
const setHighlights = StateEffect.define();
const highlightField = StateField.define({
create() {
return Decoration.none;
},
update(highlights, tr) {
try {
for (let e of tr.effects) {
if (e.is(setHighlights)) {
highlights = Decoration.set(e.value.flatMap((hap) => (hap.context.locations || []).map(({ start, end }) => {
const color = hap.context.color || "#FFCA28";
let from = tr.newDoc.line(start.line).from + start.column;
let to = tr.newDoc.line(end.line).from + end.column;
const l = tr.newDoc.length;
if (from > l || to > l) {
return;
}
const mark = Decoration.mark({ attributes: { style: `outline: 1px solid ${color}` } });
return mark.range(from, to);
})).filter(Boolean), true);
}
}
return highlights;
} catch (err) {
return highlights;
}
},
provide: (f) => EditorView.decorations.from(f)
});
function CodeMirror({ value, onChange, onViewChanged, onCursor, options, editorDidMount }) {
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(CodeMirror$1, {
onViewChange: onViewChanged,
style: {
display: "flex",
flexDirection: "column",
flex: "1 0 auto"
},
value,
onChange,
extensions: [
javascript(),
materialPalenight,
highlightField
]
}));
}
/*
useCycle.mjs - <short description TODO>
Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/strudel/blob/main/repl/src/useCycle.mjs>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/* export declare interface UseCycleProps {
onEvent: ToneEventCallback<any>;
onQuery?: (state: State) => Hap[];
onSchedule?: (events: Hap[], cycle: number) => void;
onDraw?: ToneEventCallback<any>;
ready?: boolean; // if false, query will not be called on change props
} */
// function useCycle(props: UseCycleProps) {
function useCycle(props) {
// onX must use useCallback!
const { onEvent, onQuery, onSchedule, ready = true, onDraw } = props;
const [started, setStarted] = useState(false);
const cycleDuration = 1;
const activeCycle = () => Math.floor(Tone.getTransport().seconds / cycleDuration);
// pull events with onQuery + count up to next cycle
const query = (cycle = activeCycle()) => {
const timespan = new TimeSpan(cycle, cycle + 1);
const events = onQuery?.(new State(timespan)) || [];
onSchedule?.(events, cycle);
// cancel events after current query. makes sure no old events are player for rescheduled cycles
// console.log('schedule', cycle);
// query next cycle in the middle of the current
const cancelFrom = timespan.begin.valueOf();
Tone.getTransport().cancel(cancelFrom);
// const queryNextTime = (cycle + 1) * cycleDuration - 0.1;
const queryNextTime = (cycle + 1) * cycleDuration - 0.5;
// if queryNextTime would be before current time, execute directly (+0.1 for safety that it won't miss)
const t = Math.max(Tone.getTransport().seconds, queryNextTime) + 0.1;
Tone.getTransport().schedule(() => {
query(cycle + 1);
}, t);
// schedule events for next cycle
events
?.filter((event) => event.part.begin.equals(event.whole?.begin))
.forEach((event) => {
Tone.getTransport().schedule((time) => {
onEvent(time, event, Tone.getContext().currentTime);
Tone.Draw.schedule(() => {
// do drawing or DOM manipulation here
onDraw?.(time, event);
}, time);
}, event.part.begin.valueOf());
});
};
useEffect(() => {
ready && query();
}, [onEvent, onSchedule, onQuery, onDraw, ready]);
const start = async () => {
setStarted(true);
await Tone.start();
Tone.getTransport().start('+0.1');
};
const stop = () => {
Tone.getTransport().pause();
setStarted(false);
};
const toggle = () => (started ? stop() : start());
return {
start,
stop,
onEvent,
started,
setStarted,
toggle,
query,
activeCycle,
};
}
/*
usePostMessage.mjs - <short description TODO>
Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/strudel/blob/main/repl/src/usePostMessage.mjs>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
function usePostMessage(listener) {
useEffect(() => {
window.addEventListener('message', listener);
return () => window.removeEventListener('message', listener);
}, [listener]);
return useCallback((data) => window.postMessage(data, '*'), []);
}
/*
useRepl.mjs - <short description TODO>
Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/strudel/blob/main/repl/src/useRepl.mjs>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
let s4 = () => {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
};
const generateHash = (code) => encodeURIComponent(btoa(code));
function useRepl({ tune, defaultSynth, autolink = true, onEvent, onDraw: onDrawProp }) {
const id = useMemo(() => s4(), []);
const [code, setCode] = useState(tune);
const [activeCode, setActiveCode] = useState();
const [log, setLog] = useState('');
const [error, setError] = useState();
const [pending, setPending] = useState(false);
const [hash, setHash] = useState('');
const [pattern, setPattern] = useState();
const dirty = useMemo(() => code !== activeCode || error, [code, activeCode, error]);
const pushLog = useCallback((message) => setLog((log) => log + `${log ? '\n\n' : ''}${message}`), []);
// below block allows disabling the highlighting by including "strudel disable-highlighting" in the code (as comment)
const onDraw = useMemo(() => {
if (activeCode && !activeCode.includes('strudel disable-highlighting')) {
return (time, event) => onDrawProp?.(time, event, activeCode);
}
}, [activeCode, onDrawProp]);
// cycle hook to control scheduling
const cycle = useCycle({
onDraw,
onEvent: useCallback(
(time, event, currentTime) => {
try {
onEvent?.(event);
if (event.context.logs?.length) {
event.context.logs.forEach(pushLog);
}
const { onTrigger, velocity } = event.context;
if (!onTrigger) {
if (defaultSynth) {
const note = getPlayableNoteValue(event);
defaultSynth.triggerAttackRelease(note, event.duration.valueOf(), time, velocity);
} else {
throw new Error('no defaultSynth passed to useRepl.');
}
/* console.warn('no instrument chosen', event);
throw new Error(`no instrument chosen for ${JSON.stringify(event)}`); */
} else {
onTrigger(
time,
event,
currentTime,
1 /* cps */,
event.wholeOrPart().begin.valueOf(),
event.duration.valueOf(),
);
}
} catch (err) {
console.warn(err);
err.message = 'unplayable event: ' + err?.message;
pushLog(err.message); // not with setError, because then we would have to setError(undefined) on next playable event
}
},
[onEvent, pushLog, defaultSynth],
),
onQuery: useCallback(
(state) => {
try {
return pattern?.query(state) || [];
} catch (err) {
console.warn(err);
err.message = 'query error: ' + err.message;
setError(err);
return [];
}
},
[pattern],
),
onSchedule: useCallback((_events, cycle) => logCycle(_events, cycle), []),
ready: !!pattern && !!activeCode,
});
const broadcast = usePostMessage(({ data: { from, type } }) => {
if (type === 'start' && from !== id) {
// console.log('message', from, type);
cycle.setStarted(false);
setActiveCode(undefined);
}
});
const activateCode = useCallback(
async (_code = code) => {
if (activeCode && !dirty) {
setError(undefined);
cycle.start();
return;
}
try {
setPending(true);
const parsed = await evaluate(_code);
cycle.start();
broadcast({ type: 'start', from: id });
setPattern(() => parsed.pattern);
if (autolink) {
window.location.hash = '#' + encodeURIComponent(btoa(code));
}
setHash(generateHash(code));
setError(undefined);
setActiveCode(_code);
setPending(false);
} catch (err) {
err.message = 'evaluation error: ' + err.message;
console.warn(err);
setError(err);
}
},
[activeCode, dirty, code, cycle, autolink, id, broadcast],
);
// logs events of cycle
const logCycle = (_events, cycle) => {
if (_events.length) ;
};
const togglePlay = () => {
if (!cycle.started) {
activateCode();
} else {
cycle.stop();
}
};
return {
pending,
code,
setCode,
pattern,
error,
cycle,
setPattern,
dirty,
log,
togglePlay,
setActiveCode,
activateCode,
activeCode,
pushLog,
hash,
};
}
/*
cx.js - <short description TODO>
Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/strudel/blob/main/repl/src/cx.js>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
function cx(...classes) {
// : Array<string | undefined>
return classes.filter(Boolean).join(' ');
}
let highlights = []; // actively highlighted events
let lastEnd;
function useHighlighting({ view, pattern, active }) {
useEffect(() => {
if (view) {
if (pattern && active) {
let frame = requestAnimationFrame(updateHighlights);
function updateHighlights() {
try {
const audioTime = Tone.getTransport().seconds;
const span = [lastEnd || audioTime, audioTime + 1 / 60];
lastEnd = audioTime + 1 / 60;
highlights = highlights.filter((hap) => hap.whole.end > audioTime); // keep only highlights that are still active
const haps = pattern.queryArc(...span).filter((hap) => hap.hasOnset());
highlights = highlights.concat(haps); // add potential new onsets
view.dispatch({ effects: setHighlights.of(highlights) }); // highlight all still active + new active haps
} catch (err) {
// console.log('error in updateHighlights', err);
view.dispatch({ effects: setHighlights.of([]) });
}
frame = requestAnimationFrame(updateHighlights);
}
return () => {
cancelAnimationFrame(frame);
};
} else {
highlights = [];
view.dispatch({ effects: setHighlights.of([]) });
}
}
}, [pattern, active, view]);
}
var tailwind = '';
const container = "_container_10e1g_1";
const header = "_header_10e1g_5";
const buttons = "_buttons_10e1g_9";
const button = "_button_10e1g_9";
const buttonDisabled = "_buttonDisabled_10e1g_17";
const error = "_error_10e1g_21";
const body = "_body_10e1g_25";
var styles = {
container: container,
header: header,
buttons: buttons,
button: button,
buttonDisabled: buttonDisabled,
error: error,
body: body
};
function Icon({ type }) {
return /* @__PURE__ */ React.createElement("svg", {
xmlns: "http://www.w3.org/2000/svg",
className: "sc-h-5 sc-w-5",
viewBox: "0 0 20 20",
fill: "currentColor"
}, {
refresh: /* @__PURE__ */ React.createElement("path", {
fillRule: "evenodd",
d: "M4 2a1 1 0 011 1v2.101a7.002 7.002 0 0111.601 2.566 1 1 0 11-1.885.666A5.002 5.002 0 005.999 7H9a1 1 0 010 2H4a1 1 0 01-1-1V3a1 1 0 011-1zm.008 9.057a1 1 0 011.276.61A5.002 5.002 0 0014.001 13H11a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0v-2.101a7.002 7.002 0 01-11.601-2.566 1 1 0 01.61-1.276z",
clipRule: "evenodd"
}),
play: /* @__PURE__ */ React.createElement("path", {
fillRule: "evenodd",
d: "M10 18a8 8 0 100-16 8 8 0 000 16zM9.555 7.168A1 1 0 008 8v4a1 1 0 001.555.832l3-2a1 1 0 000-1.664l-3-2z",
clipRule: "evenodd"
}),
pause: /* @__PURE__ */ React.createElement("path", {
fillRule: "evenodd",
d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zM7 8a1 1 0 012 0v4a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v4a1 1 0 102 0V8a1 1 0 00-1-1z",
clipRule: "evenodd"
})
}[type]);
}
function MiniRepl({ tune, defaultSynth, hideOutsideView = false }) {
const { code, setCode, pattern, activateCode, error, cycle, dirty, togglePlay } = useRepl({
tune,
defaultSynth,
autolink: false
});
const [view, setView] = useState();
const [ref, isVisible] = useInView({
threshold: 0.01
});
const wasVisible = useRef();
const show = useMemo(() => {
if (isVisible || !hideOutsideView) {
wasVisible.current = true;
}
return isVisible || wasVisible.current;
}, [isVisible, hideOutsideView]);
useHighlighting({ view, pattern, active: cycle.started });
return /* @__PURE__ */ React.createElement("div", {
className: styles.container,
ref
}, /* @__PURE__ */ React.createElement("div", {
className: styles.header
}, /* @__PURE__ */ React.createElement("div", {
className: styles.buttons
}, /* @__PURE__ */ React.createElement("button", {
className: cx(styles.button, cycle.started ? "sc-animate-pulse" : ""),
onClick: () => togglePlay()
}, /* @__PURE__ */ React.createElement(Icon, {
type: cycle.started ? "pause" : "play"
})), /* @__PURE__ */ React.createElement("button", {
className: cx(dirty ? styles.button : styles.buttonDisabled),
onClick: () => activateCode()
}, /* @__PURE__ */ React.createElement(Icon, {
type: "refresh"
}))), error && /* @__PURE__ */ React.createElement("div", {
className: styles.error
}, error.message)), /* @__PURE__ */ React.createElement("div", {
className: styles.body
}, show && /* @__PURE__ */ React.createElement(CodeMirror, {
value: code,
onChange: setCode,
onViewChanged: setView
})));
}
/*
useWebMidi.js - <short description TODO>
Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/strudel/blob/main/repl/src/useWebMidi.js>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
function useWebMidi(props) {
const { ready, connected, disconnected } = props;
const [loading, setLoading] = useState(true);
const [outputs, setOutputs] = useState(WebMidi?.outputs || []);
useEffect(() => {
enableWebMidi()
.then(() => {
// Reacting when a new device becomes available
WebMidi.addListener('connected', (e) => {
setOutputs([...WebMidi.outputs]);
connected?.(WebMidi, e);
});
// Reacting when a device becomes unavailable
WebMidi.addListener('disconnected', (e) => {
setOutputs([...WebMidi.outputs]);
disconnected?.(WebMidi, e);
});
ready?.(WebMidi);
setLoading(false);
})
.catch((err) => {
if (err) {
console.error(err);
//throw new Error("Web Midi could not be enabled...");
console.warn('Web Midi could not be enabled..');
return;
}
});
}, [ready, connected, disconnected, outputs]);
const outputByName = (name) => WebMidi.getOutputByName(name);
return { loading, outputs, outputByName };
}
export { CodeMirror, MiniRepl, cx, useCycle, useHighlighting, usePostMessage, useRepl, useWebMidi };
+1
View File
@@ -0,0 +1 @@
*,:before,:after{--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.sc-h-5{height:1.25rem}.sc-w-5{width:1.25rem}@keyframes sc-pulse{50%{opacity:.5}}.sc-animate-pulse{animation:sc-pulse 2s cubic-bezier(.4,0,.6,1) infinite}._container_10e1g_1{overflow:hidden;border-radius:.375rem;--tw-bg-opacity: 1;background-color:rgb(68 76 87 / var(--tw-bg-opacity))}._header_10e1g_5{display:flex;justify-content:space-between;border-top-width:1px;--tw-border-opacity: 1;border-color:rgb(100 116 139 / var(--tw-border-opacity));--tw-bg-opacity: 1;background-color:rgb(51 65 85 / var(--tw-bg-opacity))}._buttons_10e1g_9{display:flex}._button_10e1g_9{display:flex;width:4rem;cursor:pointer;align-items:center;justify-content:center;border-right-width:1px;--tw-border-opacity: 1;border-color:rgb(100 116 139 / var(--tw-border-opacity));--tw-bg-opacity: 1;background-color:rgb(51 65 85 / var(--tw-bg-opacity));padding:.25rem;--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity))}._button_10e1g_9:hover{--tw-bg-opacity: 1;background-color:rgb(71 85 105 / var(--tw-bg-opacity))}._buttonDisabled_10e1g_17{display:flex;width:4rem;cursor:pointer;cursor:not-allowed;align-items:center;justify-content:center;--tw-bg-opacity: 1;background-color:rgb(71 85 105 / var(--tw-bg-opacity));padding:.25rem;--tw-text-opacity: 1;color:rgb(148 163 184 / var(--tw-text-opacity))}._error_10e1g_21{padding:.25rem;text-align:right;font-size:.875rem;line-height:1.25rem;--tw-text-opacity: 1;color:rgb(254 202 202 / var(--tw-text-opacity))}._body_10e1g_25{position:relative;overflow:auto}
+13
View File
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<!-- <link rel="icon" type="image/svg+xml" href="/src/favicon.svg" /> -->
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Strudel React Components</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>
+62
View File
@@ -0,0 +1,62 @@
{
"name": "@strudel.cycles/react",
"version": "0.1.2",
"description": "React components for strudel",
"main": "dist/index.cjs.js",
"module": "dist/index.es.js",
"exports": {
".": {
"require": "./dist/index.cjs.js",
"import": "./dist/index.es.js"
},
"./dist/style.css": "./dist/style.css"
},
"files": [
"dist"
],
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"repository": {
"type": "git",
"url": "git+https://github.com/tidalcycles/strudel.git"
},
"keywords": [
"tidalcycles",
"strudel",
"pattern",
"livecoding",
"algorave"
],
"author": "Felix Roos <flix91@gmail.com>",
"license": "AGPL-3.0-or-later",
"bugs": {
"url": "https://github.com/tidalcycles/strudel/issues"
},
"homepage": "https://github.com/tidalcycles/strudel#readme",
"dependencies": {
"@codemirror/lang-javascript": "^0.19.0",
"@strudel.cycles/core": "*",
"@strudel.cycles/eval": "^0.1.1",
"@strudel.cycles/tone": "^0.1.1",
"react-codemirror6": "^1.1.0",
"react-hook-inview": "^4.5.0"
},
"peerDependencies": {
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"devDependencies": {
"@types/react": "^17.0.2",
"@types/react-dom": "^17.0.2",
"@vitejs/plugin-react": "^1.3.0",
"autoprefixer": "^10.4.7",
"postcss": "^8.4.13",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"tailwindcss": "^3.0.24",
"vite": "^2.9.9"
}
}
+12
View File
@@ -0,0 +1,12 @@
/*
postcss.config.js - <short description TODO>
Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/strudel/blob/main/repl/postcss.config.js>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
+28
View File
@@ -0,0 +1,28 @@
import React from 'react';
import { MiniRepl } from './components/MiniRepl';
import 'tailwindcss/tailwind.css';
import { Tone, getDefaultSynth } from '@strudel.cycles/tone';
import { evalScope } from '@strudel.cycles/eval';
const defaultSynth = getDefaultSynth();
evalScope(
Tone,
import('@strudel.cycles/core'),
import('@strudel.cycles/tone'),
import('@strudel.cycles/tonal'),
import('@strudel.cycles/mini'),
import('@strudel.cycles/midi'),
import('@strudel.cycles/xen'),
import('@strudel.cycles/webaudio'),
);
function App() {
return (
<div>
<MiniRepl tune={`"c3"`} defaultSynth={defaultSynth} />
</div>
);
}
export default App;
@@ -1,53 +1,73 @@
import React from 'react';
import { Controlled as CodeMirror2 } from 'react-codemirror2';
import 'codemirror/mode/javascript/javascript';
import 'codemirror/mode/pegjs/pegjs';
// import 'codemirror/theme/material.css';
import 'codemirror/lib/codemirror.css';
import 'codemirror/theme/material.css';
import { CodeMirror as _CodeMirror } from 'react-codemirror6';
// import { CodeMirrorLite as _CodeMirror } from 'react-codemirror6/dist/lite';
import { EditorView, Decoration } from '@codemirror/view';
import { StateField, StateEffect } from '@codemirror/state';
import { javascript } from '@codemirror/lang-javascript';
// import { materialPalenight } from 'codemirror6-themes';
import { materialPalenight } from '../themes/material-palenight';
export default function CodeMirror({ value, onChange, onCursor, options, editorDidMount }) {
options = options || {
mode: 'javascript',
theme: 'material',
lineNumbers: true,
styleSelectedText: true,
cursorBlinkRate: 500,
};
export const setHighlights = StateEffect.define();
const highlightField = StateField.define({
create() {
return Decoration.none;
},
update(highlights, tr) {
try {
for (let e of tr.effects) {
if (e.is(setHighlights)) {
highlights = Decoration.set(
e.value
.flatMap((hap) =>
(hap.context.locations || []).map(({ start, end }) => {
const color = hap.context.color || '#FFCA28';
let from = tr.newDoc.line(start.line).from + start.column;
let to = tr.newDoc.line(end.line).from + end.column;
const l = tr.newDoc.length;
if (from > l || to > l) {
return; // dont mark outside of range, as it will throw an error
}
const mark = Decoration.mark({ attributes: { style: `outline: 1px solid ${color}` } });
return mark.range(from, to);
}),
)
.filter(Boolean),
true,
);
}
}
return highlights;
} catch (err) {
// console.warn('highlighting error', err);
return highlights;
}
},
provide: (f) => EditorView.decorations.from(f),
});
export default function CodeMirror({ value, onChange, onViewChanged, onCursor, options, editorDidMount }) {
return (
<CodeMirror2
value={value}
options={options}
onBeforeChange={onChange}
editorDidMount={editorDidMount}
onCursor={(editor, data) => onCursor?.(editor, data)}
/>
<>
<_CodeMirror
onViewChange={onViewChanged}
style={{
display: 'flex',
flexDirection: 'column',
flex: '1 0 auto',
}}
value={value}
onChange={onChange}
extensions={[
javascript(),
materialPalenight,
highlightField,
// theme, language, ...
]}
/>
</>
);
}
export const markEvent = (editor) => (time, event) => {
const locs = event.context.locations;
if (!locs || !editor) {
return;
}
const col = event.context?.color || '#FFCA28';
// mark active event
const marks = locs.map(({ start, end }) =>
editor.getDoc().markText(
{ line: start.line - 1, ch: start.column },
{ line: end.line - 1, ch: end.column },
//{ css: 'background-color: #FFCA28; color: black' } // background-color is now used by parent marking
{ css: 'outline: 1px solid ' + col + '; box-sizing:border-box' },
//{ css: `background-color: ${col};border-radius:5px` },
),
);
//Tone.Transport.schedule(() => { // problem: this can be cleared by scheduler...
setTimeout(() => {
marks.forEach((mark) => mark.clear());
// }, '+' + event.duration * 0.5);
}, event.duration /* * 0.9 */ * 1000);
};
let parenMark;
export const markParens = (editor, data) => {
const v = editor.getDoc().getValue();
@@ -75,6 +95,10 @@ export function offsetToPosition(offset, code) {
// returns absolute character offset from { line, ch }
export function positionToOffset(position, code) {
const lines = code.split('\n');
if (position.line > lines.length) {
// throw new Error('positionToOffset: position.line > lines.length');
return 0;
}
let offset = 0;
for (let i = 0; i < position.line; i++) {
offset += lines[i].length + 1;
@@ -119,3 +143,27 @@ export function getCurrentParenArea(code, caretPosition) {
end = i;
return [begin, end].map((o) => offsetToPosition(o, code));
}
/*
export const markEvent = (editor) => (time, event) => {
const locs = event.context.locations;
if (!locs || !editor) {
return;
}
const col = event.context?.color || '#FFCA28';
// mark active event
const marks = locs.map(({ start, end }) =>
editor.getDoc().markText(
{ line: start.line - 1, ch: start.column },
{ line: end.line - 1, ch: end.column },
//{ css: 'background-color: #FFCA28; color: black' } // background-color is now used by parent marking
{ css: 'outline: 1px solid ' + col + '; box-sizing:border-box' },
//{ css: `background-color: ${col};border-radius:5px` },
),
);
//Tone.Transport.schedule(() => { // problem: this can be cleared by scheduler...
setTimeout(() => {
marks.forEach((mark) => mark.clear());
// }, '+' + event.duration * 0.5);
}, event.duration * 1000);
}; */
+33
View File
@@ -0,0 +1,33 @@
import React from 'react';
export function Icon({ type }) {
return (
<svg xmlns="http://www.w3.org/2000/svg" className="sc-h-5 sc-w-5" viewBox="0 0 20 20" fill="currentColor">
{
{
refresh: (
<path
fillRule="evenodd"
d="M4 2a1 1 0 011 1v2.101a7.002 7.002 0 0111.601 2.566 1 1 0 11-1.885.666A5.002 5.002 0 005.999 7H9a1 1 0 010 2H4a1 1 0 01-1-1V3a1 1 0 011-1zm.008 9.057a1 1 0 011.276.61A5.002 5.002 0 0014.001 13H11a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0v-2.101a7.002 7.002 0 01-11.601-2.566 1 1 0 01.61-1.276z"
clipRule="evenodd"
/>
),
play: (
<path
fillRule="evenodd"
d="M10 18a8 8 0 100-16 8 8 0 000 16zM9.555 7.168A1 1 0 008 8v4a1 1 0 001.555.832l3-2a1 1 0 000-1.664l-3-2z"
clipRule="evenodd"
/>
),
pause: (
<path
fillRule="evenodd"
d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zM7 8a1 1 0 012 0v4a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v4a1 1 0 102 0V8a1 1 0 00-1-1z"
clipRule="evenodd"
/>
),
}[type]
}
</svg>
);
}
@@ -0,0 +1,48 @@
import React, { useState, useMemo, useRef } from 'react';
import { useInView } from 'react-hook-inview';
import useRepl from '../hooks/useRepl.mjs';
import cx from '../cx';
import useHighlighting from '../hooks/useHighlighting.mjs';
import CodeMirror6 from './CodeMirror6';
import 'tailwindcss/tailwind.css';
import './style.css';
import styles from './MiniRepl.module.css';
import { Icon } from './Icon';
export function MiniRepl({ tune, defaultSynth, hideOutsideView = false }) {
const { code, setCode, pattern, activateCode, error, cycle, dirty, togglePlay } = useRepl({
tune,
defaultSynth,
autolink: false,
});
const [view, setView] = useState();
const [ref, isVisible] = useInView({
threshold: 0.01,
});
const wasVisible = useRef();
const show = useMemo(() => {
if (isVisible || !hideOutsideView) {
wasVisible.current = true;
}
return isVisible || wasVisible.current;
}, [isVisible, hideOutsideView]);
useHighlighting({ view, pattern, active: cycle.started });
return (
<div className={styles.container} ref={ref}>
<div className={styles.header}>
<div className={styles.buttons}>
<button className={cx(styles.button, cycle.started ? 'sc-animate-pulse' : '')} onClick={() => togglePlay()}>
<Icon type={cycle.started ? 'pause' : 'play'} />
</button>
<button className={cx(dirty ? styles.button : styles.buttonDisabled)} onClick={() => activateCode()}>
<Icon type="refresh" />
</button>
</div>
{error && <div className={styles.error}>{error.message}</div>}
</div>
<div className={styles.body} >
{show && <CodeMirror6 value={code} onChange={setCode} onViewChanged={setView} />}
</div>
</div>
);
}
@@ -0,0 +1,27 @@
.container {
@apply sc-rounded-md sc-overflow-hidden sc-bg-[#444C57];
}
.header {
@apply sc-flex sc-justify-between sc-bg-slate-700 sc-border-t sc-border-slate-500;
}
.buttons {
@apply sc-flex;
}
.button {
@apply sc-cursor-pointer sc-w-16 sc-flex sc-items-center sc-justify-center sc-p-1 sc-bg-slate-700 sc-border-r sc-border-slate-500 sc-text-white hover:sc-bg-slate-600;
}
.buttonDisabled {
@apply sc-cursor-pointer sc-w-16 sc-flex sc-items-center sc-justify-center sc-p-1 sc-bg-slate-600 sc-text-slate-400 sc-cursor-not-allowed;
}
.error {
@apply sc-text-right sc-p-1 sc-text-sm sc-text-red-200;
}
.body {
@apply sc-overflow-auto sc-relative;
}
+3
View File
@@ -0,0 +1,3 @@
.cm-editor {
background-color: transparent !important;
}

Some files were not shown because too many files have changed in this diff Show More