mirror of
https://codeberg.org/uzu/strudel
synced 2026-12-04 21:11:12 -05:00
Compare commits
102 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ef38980b12 | |||
| 6274001515 | |||
| 3dde9f49e4 | |||
| 5c4064c3ad | |||
| fff2610a19 | |||
| 4613c1d4a8 | |||
| 8315a8269c | |||
| 8248ee411c | |||
| 9605a9478a | |||
| c4cec8dd18 | |||
| 4033919a8a | |||
| 217fac5e11 | |||
| 207c9d5470 | |||
| 7a1075b746 | |||
| 34b7a81c8b | |||
| b30e3ad88f | |||
| 70b44f6694 | |||
| fdc5db6b9b | |||
| b49981aea6 | |||
| 0c38bfaf99 | |||
| d6ce044ccb | |||
| 255314f7fa | |||
| acf4628a16 | |||
| 2a35745f73 | |||
| 787f44bb38 | |||
| db62b8b6aa | |||
| dc1fe808c0 | |||
| a61418c54c | |||
| 2feba92516 | |||
| 2b001170de | |||
| fe06a1e59e | |||
| a4b83a364b | |||
| 1d8d0dae8c | |||
| d3a6cef369 | |||
| d0de54a880 | |||
| d1a4c3c60e | |||
| 118de38551 | |||
| 8bde1314c5 | |||
| f13dbe00e1 | |||
| 68598a674b | |||
| db2835c5cb | |||
| f92d6a0a03 | |||
| 31730842a7 | |||
| 9e92aba3de | |||
| 789376d151 | |||
| 0fc0996d5c | |||
| e000020a9f | |||
| 926cd6b772 | |||
| b1b026b56c | |||
| 49926243f6 | |||
| b298ac7b53 | |||
| cd7c88e768 | |||
| 4694c59d74 | |||
| 9e00181020 | |||
| ad98f1050d | |||
| e1e156296a | |||
| 4db94e163c | |||
| 438eb553bd | |||
| 379c075d56 | |||
| a261d47b4e | |||
| 8b1d68e494 | |||
| 6e550f5a6c | |||
| 2271593c06 | |||
| 7dd9cacc37 | |||
| 446f8468c4 | |||
| 28a6c304cd | |||
| 2668f4be2c | |||
| 4ddd09cf64 | |||
| 96f8c545ae | |||
| 1686ff877c | |||
| 83b1c89d25 | |||
| 1743f65e61 | |||
| bb4b8bb27e | |||
| bdac0eccbd | |||
| 6333fa1ddf | |||
| 41e6084823 | |||
| fe9a75c9b6 | |||
| cd7c1dbd97 | |||
| 25b9fd991a | |||
| 375b25afd7 | |||
| d3d311e105 | |||
| afc7f1aab1 | |||
| 4b3c6f90a5 | |||
| 5e82110522 | |||
| 4616b374f3 | |||
| 08e9e3893e | |||
| 98b71bcb4d | |||
| cf7dae5d7f | |||
| b3d9eab3b6 | |||
| 067f002d93 | |||
| c799a686c0 | |||
| 9e5e172931 | |||
| 1f5b8d6bcc | |||
| 11e64428dd | |||
| 551e8aed5e | |||
| 5f88fab5d0 | |||
| 207fa00eac | |||
| 3c32b3b0aa | |||
| c492e21e1d | |||
| 88b7d14487 | |||
| 3ac25f7960 | |||
| 8b3ae4c514 |
@@ -0,0 +1,41 @@
|
||||
name: Build and Deploy labeled serve-hot PRs
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [labeled]
|
||||
|
||||
# Allow one concurrent deployment
|
||||
concurrency:
|
||||
group: "warm-pages"
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
build:
|
||||
if: ${{ github.event.label.name == 'serve-hot' }}
|
||||
runs-on: docker
|
||||
container: node:22-bookworm
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
allow-unsafe-pr-checkout: true
|
||||
- uses: pnpm/action-setup@v4
|
||||
|
||||
- name: Install Dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Build
|
||||
run: pnpm build
|
||||
|
||||
- name: Deploy
|
||||
env:
|
||||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
run: |
|
||||
eval $(ssh-agent -s)
|
||||
echo "$SSH_PRIVATE_KEY" | ssh-add -
|
||||
apt update && apt install -y rsync
|
||||
mkdir -p ~/.ssh
|
||||
ssh-keyscan matrix.toplap.org > ~/.ssh/known_hosts
|
||||
rsync -atv --delete --delete-after --progress \
|
||||
./website/dist/ \
|
||||
strudel@matrix.toplap.org:/home/strudel/deploy/pr-${{ github.event.pull_request.number }}.hot.strudel.cc
|
||||
@@ -1,23 +1,23 @@
|
||||
name: Build and Deploy hot PRs
|
||||
name: Build and Deploy to hot.strudel.cc on merge
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [labeled]
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
# Allow one concurrent deployment
|
||||
concurrency:
|
||||
group: "warm-pages"
|
||||
cancel-in-progress: false
|
||||
group: "pages"
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
if: ${{ github.event.label.name == 'serve-hot' }}
|
||||
runs-on: docker
|
||||
container: node:22-bookworm
|
||||
env:
|
||||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
- uses: pnpm/action-setup@v4
|
||||
|
||||
- name: Install Dependencies
|
||||
@@ -27,14 +27,10 @@ jobs:
|
||||
run: pnpm build
|
||||
|
||||
- name: Deploy
|
||||
env:
|
||||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
run: |
|
||||
eval $(ssh-agent -s)
|
||||
echo "$SSH_PRIVATE_KEY" | ssh-add -
|
||||
apt update && apt install -y rsync
|
||||
mkdir -p ~/.ssh
|
||||
ssh-keyscan matrix.toplap.org > ~/.ssh/known_hosts
|
||||
rsync -atv --delete --delete-after --progress \
|
||||
./website/dist/ \
|
||||
strudel@matrix.toplap.org:/home/strudel/deploy/pr-${{ github.event.pull_request.number }}.hot.strudel.cc
|
||||
mkdir ~/.ssh
|
||||
ssh-keyscan matrix.toplap.org > ~/.ssh/known_hosts
|
||||
rsync -atv --delete --delete-after --progress ./website/dist/ strudel@matrix.toplap.org:/home/strudel/deploy/hot.strudel.cc
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
name: Build and Deploy to warm (strudel.cc)
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
on: [workflow_dispatch]
|
||||
|
||||
# Allow one concurrent deployment
|
||||
concurrency:
|
||||
@@ -18,6 +18,11 @@ Strudel has purposefully moved away from github.com, as a closed
|
||||
source platform with ethical issues. Please do not fork strudel back
|
||||
to that platform, or similar corporate platforms.
|
||||
|
||||
Strudel's git repo is hosted by codeberg, which attempts to block bots
|
||||
including LLMs from accessing it, to avoid being overloaded. Agents
|
||||
should not try to circumvent this, instead encouraging developers
|
||||
to engage with the strudel community directly.
|
||||
|
||||
Projects using strudel must not use "strudel" in their name, unless
|
||||
they are 'official' projects, or have the blessing of the strudel
|
||||
community.
|
||||
|
||||
@@ -136,6 +136,15 @@ There are also eslint extensions / plugins for most editors.
|
||||
|
||||
When opening a PR, the CI runner will (once approved by a human) check the code style and eslint, as well as run all tests. You can run the same check with `pnpm check`.
|
||||
|
||||
## Publishing a change live on *.strudel.cc
|
||||
|
||||
There are a few steps to a contribution to strudel making it to https://strudel.cc/
|
||||
|
||||
1. If a maintainer adds a 'serve-hot' label to a pull request on codeberg, it is built and exposed as http://pr-1000.hot.strudel.cc (where 1000 is the pr number). This allows changes to be tried out live, without building locally. However, because it's plain http, some webaudio things etc won't work. A maintainer with server access can assign a certificate for https via a manual process if needed.
|
||||
2. When a pull request is merged into the main branch by a maintainer, it is automatically built and served under https://hot.strudel.cc/
|
||||
3. Then a maintainer can trigger an action on codeberg to rebuild https://strudel.cc/ (also known as https://warm.strudel.cc/) from the main branch. This [currently makes strudel refresh for all users](https://codeberg.org/uzu/strudel/pulls/2130), and is intended to happen around once a week, early in the week (when fewer people will be performing with it!), or more often for urgent fixes.
|
||||
4. There is also https://cold.strudel.cc/, which is intended to reflect the last package release to npm.
|
||||
|
||||
## Package Workflow
|
||||
|
||||
The project is split into multiple [packages](https://codeberg.org/uzu/strudel/src/branch/main/packages) with independent versioning.
|
||||
|
||||
+15
-3
@@ -95,11 +95,12 @@ export default [
|
||||
},
|
||||
},
|
||||
jsdoc({
|
||||
files: ['packages/**/*.{js,mjs}'],
|
||||
config: 'flat/recommended-error',
|
||||
rules: {
|
||||
'jsdoc/no-undefined-types': [
|
||||
'error',
|
||||
{ definedTypes: ['Pattern', 'Pattern.prototype', 'Hap', 'KabelsalatExpression'] },
|
||||
{ definedTypes: ['Pattern', 'Pattern.prototype', 'Hap', 'KabelsalatExpression', 'TimeSpan', 'State'] },
|
||||
],
|
||||
'jsdoc/check-tag-names': ['error', { definedTags: ['tags', 'synonyms', 'noAutocomplete', 'superdirtOnly'] }],
|
||||
'jsdoc/no-restricted-syntax': [
|
||||
@@ -111,13 +112,18 @@ export default [
|
||||
comment:
|
||||
'JsdocBlock:has(JsdocTag[tag="memberof"]:not([name=/\\.prototype(?:\\s|$)/]):not([description=/\\.prototype(?:\\s|$)/]))',
|
||||
context: 'any',
|
||||
message: "Use '@memberof <Name>.prototype'. Without, it's considered a static function.",
|
||||
message: "Use '@memberof <Name>.prototype' instead.",
|
||||
},
|
||||
{
|
||||
context: 'FunctionDeclaration',
|
||||
comment: 'JsdocBlock:not(:has(JsdocTag[tag=/^(global|memberof)$/]))',
|
||||
message: 'JSDoc block should be explicitly labeled as @global or @memberof.',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
'jsdoc/require-description': 'error',
|
||||
'jsdoc/no-defaults': 0, //removes defaults with not alternative
|
||||
'jsdoc/no-defaults': 0, //removes defaults with no alternative
|
||||
'jsdoc/require-jsdoc': 0,
|
||||
'jsdoc/tag-lines': 0,
|
||||
'jsdoc/require-returns-description': 0,
|
||||
@@ -129,4 +135,10 @@ export default [
|
||||
'jsdoc/reject-function-type': 0,
|
||||
},
|
||||
}),
|
||||
jsdoc({
|
||||
files: ['packages/core/**/*.{js,mjs}', 'packages/pattern/**/*.{js,mjs}'],
|
||||
rules: {
|
||||
'jsdoc/require-jsdoc': ['warn', { publicOnly: {}, enableFixer: false }],
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
+17
-9
@@ -1,16 +1,19 @@
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { dirname, resolve } from 'path';
|
||||
import { dirname, resolve, win32, posix } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { parse } from 'acorn';
|
||||
import dependencyTree from 'dependency-tree';
|
||||
import { platform } from 'node:process';
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
const packageRoot = resolve(__dirname, '..');
|
||||
|
||||
function getExports(code) {
|
||||
// parse it with acorn
|
||||
let ast;
|
||||
try {
|
||||
ast = parse(code, {
|
||||
ecmaVersion: 11,
|
||||
ecmaVersion: 'latest',
|
||||
sourceType: 'module',
|
||||
});
|
||||
} catch (err) {
|
||||
@@ -64,21 +67,26 @@ async function getUndocumented(path, docs) {
|
||||
}
|
||||
}
|
||||
|
||||
function getPackageRelativePosixPath(path) {
|
||||
path = path.replace(packageRoot, '');
|
||||
if (platform === 'win32') {
|
||||
path = path.replaceAll(win32.sep, posix.sep);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
// read doc.json file
|
||||
const { docs } = JSON.parse(await readFile(resolve(__dirname, '..', 'doc.json'), 'utf8'));
|
||||
const excludedFileTypes = /\.json$/;
|
||||
|
||||
const paths = dependencyTree.toList({
|
||||
filename: 'index.mjs',
|
||||
// filename: 'packages/core/index.mjs',
|
||||
directory: resolve(__dirname),
|
||||
filter: (path) => !path.includes('node_modules'),
|
||||
directory: packageRoot,
|
||||
filter: (path) => !path.includes('node_modules') && !excludedFileTypes.test(path),
|
||||
});
|
||||
// const paths = ['../packages/core/pattern.mjs', '../packages/core/hap.mjs'].map((rel) => resolve(__dirname, rel));
|
||||
|
||||
const undocumented = Object.fromEntries(
|
||||
await Promise.all(
|
||||
paths.map(async (path) => [path.replace(resolve(__dirname, '..'), ''), await getUndocumented(path, docs)]),
|
||||
),
|
||||
await Promise.all(paths.map(async (path) => [getPackageRelativePosixPath(path), await getUndocumented(path, docs)])),
|
||||
);
|
||||
|
||||
console.log(JSON.stringify(undocumented, null, 2));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { closeBrackets } from '@codemirror/autocomplete';
|
||||
import { indentWithTab } from '@codemirror/commands';
|
||||
import { indentWithTab, toggleLineComment, redo } from '@codemirror/commands';
|
||||
import { javascript, javascriptLanguage } from '@codemirror/lang-javascript';
|
||||
import { bracketMatching, defaultHighlightStyle, syntaxHighlighting } from '@codemirror/language';
|
||||
import { Compartment, EditorState, Prec } from '@codemirror/state';
|
||||
@@ -112,6 +112,10 @@ export function initEditor({ initialCode = '', onChange, onEvaluate, onStop, roo
|
||||
key: 'Alt-Enter',
|
||||
run: () => onEvaluate?.(),
|
||||
},
|
||||
{
|
||||
key: 'Ctrl-Shift-z',
|
||||
run: redo,
|
||||
},
|
||||
{
|
||||
key: 'Ctrl-.',
|
||||
run: () => onStop?.(),
|
||||
@@ -202,10 +206,10 @@ export class StrudelMirror {
|
||||
cleanupDraw(true, id);
|
||||
}
|
||||
},
|
||||
beforeEval: async () => {
|
||||
beforeEval: async (bag) => {
|
||||
cleanupDraw(true, id);
|
||||
await this.prebaked;
|
||||
await replOptions?.beforeEval?.();
|
||||
await replOptions?.beforeEval?.(bag);
|
||||
},
|
||||
afterEval: (options) => {
|
||||
// remember for when highlighting is toggled on
|
||||
@@ -400,6 +404,7 @@ function s4() {
|
||||
* Overrides the css of highlighted events. Make sure to use single quotes!
|
||||
* @name markcss
|
||||
* @tags visualization
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* note("c a f e")
|
||||
* .markcss('text-decoration:underline')
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/codemirror",
|
||||
"version": "1.3.0",
|
||||
"version": "1.4.0",
|
||||
"description": "Codemirror Extensions for Strudel",
|
||||
"main": "index.mjs",
|
||||
"publishConfig": {
|
||||
|
||||
+421
-19
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/core",
|
||||
"version": "1.2.6",
|
||||
"version": "1.3.0",
|
||||
"description": "Port of Tidal Cycles to JavaScript",
|
||||
"main": "index.mjs",
|
||||
"type": "module",
|
||||
@@ -31,8 +31,8 @@
|
||||
},
|
||||
"homepage": "https://strudel.cc",
|
||||
"dependencies": {
|
||||
"fraction.js": "^5.2.1",
|
||||
"@strudel/pattern": "workspace:*"
|
||||
"@strudel/pattern": "workspace:*",
|
||||
"fraction.js": "^5.2.1"
|
||||
},
|
||||
"gitHead": "0e26d4e741500f5bae35b023608f062a794905c2",
|
||||
"devDependencies": {
|
||||
|
||||
@@ -13,6 +13,28 @@ import {
|
||||
setClockTime,
|
||||
} from './schedulerState.mjs';
|
||||
|
||||
/**
|
||||
* Creates a new Repl
|
||||
* @global
|
||||
* @param {object} options
|
||||
* @param {*} options.onSchedule
|
||||
* @param {*} options.defaultOutput
|
||||
* @param {*} options.onEvalError
|
||||
* @param {*} options.beforeEval
|
||||
* @param {*} options.beforeStart
|
||||
* @param {*} options.afterEval
|
||||
* @param {*} options.getTime
|
||||
* @param {*} options.transpiler
|
||||
* @param {*} options.onToggle
|
||||
* @param {*} options.editPattern
|
||||
* @param {*} options.onUpdateState
|
||||
* @param {*} options.sync = false
|
||||
* @param {*} options.setInterval
|
||||
* @param {*} options.clearInterval
|
||||
* @param {*} options.id
|
||||
* @param {*} options.mondo = false
|
||||
* @returns {object}
|
||||
*/
|
||||
export function repl({
|
||||
onSchedule,
|
||||
defaultOutput,
|
||||
|
||||
@@ -12,6 +12,7 @@ let isStarted;
|
||||
|
||||
/**
|
||||
* Get the current cycle time as a number
|
||||
* @global
|
||||
* @name getTime
|
||||
* @tags internals
|
||||
* @returns {number}
|
||||
@@ -23,6 +24,12 @@ export function getTime() {
|
||||
return time();
|
||||
}
|
||||
|
||||
/**
|
||||
* define how the cycle time should be computed
|
||||
* @global
|
||||
* @param {function():number} func
|
||||
* @tags internals
|
||||
*/
|
||||
export function setTime(func) {
|
||||
time = func;
|
||||
}
|
||||
@@ -30,6 +37,7 @@ export function setTime(func) {
|
||||
let clockTime;
|
||||
/**
|
||||
* Get the current clock time in seconds (onSchedule time)
|
||||
* @global
|
||||
* @name getClockTime
|
||||
* @tags internals
|
||||
* @returns {number}
|
||||
@@ -41,16 +49,28 @@ export function getClockTime() {
|
||||
return clockTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* define how the clock time should be computed
|
||||
* @global
|
||||
* @param {function():number} func
|
||||
*/
|
||||
export function setClockTime(func) {
|
||||
clockTime = func;
|
||||
}
|
||||
|
||||
/**
|
||||
* define how Cycles per seconds are computed
|
||||
* @global
|
||||
* @tags internals
|
||||
* @param {function():number} func
|
||||
*/
|
||||
export function setCpsFunc(func) {
|
||||
cpsFunc = func;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current cycles per second
|
||||
* @global
|
||||
* @name getCps
|
||||
* @tags internals
|
||||
* @returns {number}
|
||||
@@ -59,26 +79,51 @@ export function getCps() {
|
||||
return cpsFunc?.();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the currently running pattern
|
||||
* @param {Pattern} pat
|
||||
*/
|
||||
export function setPattern(pat) {
|
||||
pattern = pat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the currently running pattern
|
||||
* @returns {Pattern}
|
||||
*/
|
||||
export function getPattern() {
|
||||
return pattern;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the function that applies a function for a given time and cps
|
||||
* @param {function(Pattern,number,number)} func
|
||||
*/
|
||||
export function setScheduleFunc(func) {
|
||||
scheduleFunc = func;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the function that applies a function for a given time and cps
|
||||
* @returns {function(Pattern,number,number)} taking a Pattern, the current time and cps as inputs
|
||||
*/
|
||||
export function getScheduleFunc() {
|
||||
return scheduleFunc;
|
||||
}
|
||||
|
||||
/**
|
||||
* start/stop the scheduler
|
||||
* @param {boolean | undefined} val
|
||||
*/
|
||||
export function setIsStarted(val) {
|
||||
isStarted = !!val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Has the scheduler started?
|
||||
In the repl, this returns true only after the full pattern code has successfully executed without errors, including any prebake files, or if the scheduler was already running from a previous pattern update.
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function getIsStarted() {
|
||||
return isStarted;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,19 @@
|
||||
// will move to https://github.com/felixroos/zyklus
|
||||
// TODO: started flag
|
||||
|
||||
/**
|
||||
* Creates a Web Audio Clock
|
||||
* @global
|
||||
* @param {Function} getTime
|
||||
* @param {Function} callback
|
||||
* @param {number} [duration]
|
||||
* @param {number} [interval]
|
||||
* @param {number} [overlap]
|
||||
* @param {Function} [setInterval]
|
||||
* @param {Function} [clearInterval]
|
||||
* @param {boolean} round
|
||||
* @returns {object}
|
||||
*/
|
||||
function createClock(
|
||||
getTime,
|
||||
callback, // called slightly before each cycle
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/csound",
|
||||
"version": "1.3.0",
|
||||
"version": "1.4.0",
|
||||
"description": "csound bindings for strudel",
|
||||
"main": "index.mjs",
|
||||
"type": "module",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/dough",
|
||||
"version": "1.3.2",
|
||||
"version": "1.4.0",
|
||||
"description": "dough synth integration for strudel",
|
||||
"main": "dough.mjs",
|
||||
"type": "module",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/draw",
|
||||
"version": "1.2.6",
|
||||
"version": "1.3.0",
|
||||
"description": "Helpers for drawing with Strudel",
|
||||
"main": "index.mjs",
|
||||
"type": "module",
|
||||
|
||||
@@ -308,6 +308,7 @@ Pattern.prototype.punchcard = function (options) {
|
||||
* @name wordfall
|
||||
* @tags visualization
|
||||
* @returns {Pattern}
|
||||
* @memberof Pattern.prototype
|
||||
*/
|
||||
Pattern.prototype.wordfall = function (options) {
|
||||
return this.punchcard({ vertical: 1, labels: 1, stroke: 0, fillActive: 1, active: 'white', ...options });
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/edo",
|
||||
"version": "0.1.0",
|
||||
"version": "0.2.0",
|
||||
"description": "Equal division of the octave (EDO) scale functions for strudel",
|
||||
"main": "index.mjs",
|
||||
"publishConfig": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/gamepad",
|
||||
"version": "1.2.6",
|
||||
"version": "1.3.0",
|
||||
"description": "Gamepad Inputs for strudel",
|
||||
"main": "index.mjs",
|
||||
"type": "module",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/hydra",
|
||||
"version": "1.2.6",
|
||||
"version": "1.3.0",
|
||||
"description": "Hydra integration for strudel",
|
||||
"main": "hydra.mjs",
|
||||
"type": "module",
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import { registerChainEffect, getFrequencyFromValue, getWorklet, logger, registerWorklet } from 'superdough';
|
||||
import workletUrl from './worklet.mjs?audioworklet';
|
||||
|
||||
let kabel;
|
||||
async function initKabelsalat() {
|
||||
const { SalatRepl } = await import('@kabelsalat/web');
|
||||
logger('[kabelsalat] ready');
|
||||
kabel = new SalatRepl({ localScope: true });
|
||||
return kabel;
|
||||
}
|
||||
|
||||
initKabelsalat().catch((err) => {
|
||||
logger(`kabelsalat init failed: ${err}`);
|
||||
});
|
||||
|
||||
const compileKabel = (code) => {
|
||||
if (!kabel) {
|
||||
throw new Error('kabelsalat still loading');
|
||||
}
|
||||
const node = kabel.evaluate(code);
|
||||
return node.compile({ log: false });
|
||||
};
|
||||
|
||||
registerWorklet(workletUrl);
|
||||
|
||||
registerChainEffect('workletSrc', ({ audioContext, fx, value, chainID, start, gateEnd, releaseEnd }) => {
|
||||
const workletSrc = fx.workletSrc
|
||||
.replace(/\bpat\[(\d+)\]/g, (_, i) => fx.workletInputs[i])
|
||||
.replaceAll('sFreq', getFrequencyFromValue(value))
|
||||
.replaceAll('sGate', `cc('strudel-gate-${chainID}')`);
|
||||
const { src, ugens, registers } = compileKabel(workletSrc);
|
||||
const workletNode = getWorklet(audioContext, 'generic-processor', {}, { outputChannelCount: [2] });
|
||||
workletNode.port.postMessage({
|
||||
src,
|
||||
schema: { ugens, registers },
|
||||
start,
|
||||
gateEnd,
|
||||
end: releaseEnd,
|
||||
});
|
||||
return workletNode;
|
||||
});
|
||||
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"name": "@strudel/kabelsalat",
|
||||
"version": "1.3.0",
|
||||
"description": "kabelsalat integration for superdough",
|
||||
"main": "kabelsalat.mjs",
|
||||
"type": "module",
|
||||
"publishConfig": {
|
||||
"main": "dist/kabelsalat.mjs"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "vite build",
|
||||
"prepublishOnly": "npm run build"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://codeberg.org/uzu/strudel.git"
|
||||
},
|
||||
"keywords": [
|
||||
"titdalcycles",
|
||||
"strudel",
|
||||
"pattern",
|
||||
"livecoding",
|
||||
"algorave"
|
||||
],
|
||||
"author": "Felix Roos <flix91@gmail.com>",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"bugs": {
|
||||
"url": "https://codeberg.org/uzu/strudel/issues"
|
||||
},
|
||||
"homepage": "https://codeberg.org/uzu/strudel#readme",
|
||||
"dependencies": {
|
||||
"@kabelsalat/lib": "^0.4.1",
|
||||
"@kabelsalat/web": "^0.4.1",
|
||||
"superdough": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"vite": "^6.0.11",
|
||||
"vite-plugin-bundle-audioworklet": "workspace:*"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import { resolve } from 'path';
|
||||
import bundleAudioWorkletPlugin from 'vite-plugin-bundle-audioworklet';
|
||||
import { dependencies } from './package.json';
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [bundleAudioWorkletPlugin()],
|
||||
build: {
|
||||
lib: {
|
||||
entry: resolve(__dirname, 'kabelsalat.mjs'),
|
||||
formats: ['es'],
|
||||
fileName: (ext) => ({ es: 'kabelsalat.mjs' })[ext],
|
||||
},
|
||||
rollupOptions: {
|
||||
external: [...Object.keys(dependencies)],
|
||||
},
|
||||
target: 'esnext',
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,83 @@
|
||||
import * as ugens from '@kabelsalat/lib/src/ugens.js';
|
||||
|
||||
const blockSize = 128;
|
||||
|
||||
const UGENS = new Map(Object.entries(ugens));
|
||||
|
||||
class GenericProcessor extends AudioWorkletProcessor {
|
||||
constructor() {
|
||||
super();
|
||||
this.playPos = 0;
|
||||
const channels = 16;
|
||||
this.outputs = new Array(channels).fill(0);
|
||||
this.sources = new Array(channels).fill(0);
|
||||
this.gateEnded = false;
|
||||
this.started = false;
|
||||
this.port.onmessage = (event) => {
|
||||
let {
|
||||
src,
|
||||
schema: { ugens, registers },
|
||||
start,
|
||||
gateEnd,
|
||||
end,
|
||||
} = event.data;
|
||||
this.start = start;
|
||||
this.gateEnd = gateEnd;
|
||||
this.end = end;
|
||||
this.registers = new Array(registers).fill(0);
|
||||
this.src = `o.fill(0); // reset outputs\n${src}`;
|
||||
this.nodes = [];
|
||||
for (let i = 0; i < ugens.length; i++) {
|
||||
const ugen = ugens[i];
|
||||
const nodeClass = UGENS.get(ugen.type);
|
||||
const node = new nodeClass(i, ugen, sampleRate);
|
||||
if (node.type === 'cc' && ugen.inputs?.[0]?.includes('strudel-gate')) {
|
||||
node.setValue(1);
|
||||
this.gateNode = node;
|
||||
}
|
||||
this.nodes[i] = node;
|
||||
}
|
||||
this.genSample = new Function(
|
||||
'time',
|
||||
'nodes',
|
||||
'input',
|
||||
'r', // registers
|
||||
'o', // outputs
|
||||
's', // sources
|
||||
this.src,
|
||||
);
|
||||
};
|
||||
}
|
||||
process(inputs, outputs) {
|
||||
const input = inputs[0]?.[0];
|
||||
if (currentTime >= this.end) {
|
||||
return false;
|
||||
} else if (this.genSample === undefined || currentTime < this.start) {
|
||||
// pending
|
||||
return true;
|
||||
}
|
||||
this.started = true;
|
||||
if (!this.gateEnded && currentTime > this.gateEnd) {
|
||||
this.gateNode?.setValue(0);
|
||||
this.gateEnded = true;
|
||||
}
|
||||
const output = outputs[0];
|
||||
const outL = output[0];
|
||||
const outR = output[1];
|
||||
for (let n = 0; n < blockSize; n++) {
|
||||
this.genSample(this.playPos, this.nodes, input ? input[n] : 0, this.registers, this.outputs, this.sources);
|
||||
const left = this.outputs[0];
|
||||
const right = this.outputs[1];
|
||||
// Spread to stereo if possible; else mixdown to mono
|
||||
if (outR) {
|
||||
outL[n] = left;
|
||||
outR[n] = right;
|
||||
} else {
|
||||
outL[n] = 0.5 * (left + right);
|
||||
}
|
||||
this.playPos += 1 / sampleRate;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
registerProcessor('generic-processor', GenericProcessor);
|
||||
@@ -113,6 +113,7 @@ function githubPath(base, subpath = '') {
|
||||
|
||||
/**
|
||||
* configures the default midimap, which is used when no "midimap" port is set
|
||||
* @global
|
||||
* @param {*} mapping
|
||||
* @tags external_io, midi
|
||||
* @example
|
||||
@@ -128,6 +129,7 @@ let loadCache = {};
|
||||
|
||||
/**
|
||||
* Adds midimaps to the registry. Inside each midimap, control names (e.g. lpf) are mapped to cc numbers.
|
||||
* @global
|
||||
* @param {string | object} map
|
||||
* @tags external_io, midi
|
||||
* @example
|
||||
@@ -484,6 +486,7 @@ Pattern.prototype.midi = function (midiport, options = {}) {
|
||||
|
||||
/**
|
||||
* Initialize a midi input device
|
||||
* @global
|
||||
* @param {string} input
|
||||
* @returns {MidiInput}
|
||||
*/
|
||||
@@ -526,9 +529,10 @@ const midiInputs = {};
|
||||
* The output is a function that accepts a midi cc value to query as well as (optionally) a midi channel
|
||||
*
|
||||
* @name midin
|
||||
* @global
|
||||
* @tags external_io, midi
|
||||
* @param {string | number} input MIDI device name or index defaulting to 0
|
||||
* @returns {function(number, number=): Pattern} A function from (cc, channel?) to a pattern.
|
||||
* @returns {Promise<function(number, number=): Pattern>} A function from (cc, channel?) to a pattern.
|
||||
* When queried, the pattern will produces the most recently received midi value (normalized to 0 to 1)
|
||||
* that came through that cc number (and channel, if provided)
|
||||
* @example
|
||||
@@ -558,7 +562,7 @@ export async function midin(input) {
|
||||
* @name midikeys
|
||||
* @tags external_io, midi
|
||||
* @param {string | number} input MIDI device name or index defaulting to 0
|
||||
* @returns {function((number | Pattern)=): Pattern} A function that produces a pattern.
|
||||
* @returns {Promise<function((number | Pattern)=): Pattern>} A function that produces a pattern.
|
||||
* When queried, the pattern will produces the most recently played midi notes and velocities,
|
||||
* lasting for the specified duration
|
||||
* @example
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/midi",
|
||||
"version": "1.3.0",
|
||||
"version": "1.4.0",
|
||||
"description": "Midi API for strudel",
|
||||
"main": "index.mjs",
|
||||
"type": "module",
|
||||
|
||||
@@ -8,6 +8,7 @@ import { Input, Output } from 'webmidi';
|
||||
|
||||
/**
|
||||
* Get a string listing device names for error messages.
|
||||
* @global
|
||||
* @param {Input[] | Output[]} devices
|
||||
* @returns {string}
|
||||
*/
|
||||
@@ -18,6 +19,7 @@ export function getMidiDeviceNamesString(devices) {
|
||||
/**
|
||||
* Look up a device by index or name. Otherwise return a default device, or fail if none are connected.
|
||||
*
|
||||
* @global
|
||||
* @param {string | number} indexOrName
|
||||
* @param {Input[] | Output[]} devices
|
||||
* @returns {Input | Output | undefined}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/mini",
|
||||
"version": "1.2.6",
|
||||
"version": "1.3.0",
|
||||
"description": "Mini notation for strudel",
|
||||
"main": "index.mjs",
|
||||
"type": "module",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/mondo",
|
||||
"version": "1.1.6",
|
||||
"version": "1.2.0",
|
||||
"description": "mondo notation for strudel",
|
||||
"main": "mondough.mjs",
|
||||
"type": "module",
|
||||
@@ -37,7 +37,6 @@
|
||||
"mondolang": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mondo": "*",
|
||||
"vite": "^6.0.11",
|
||||
"vitest": "^3.0.4"
|
||||
},
|
||||
|
||||
+15
-15
@@ -5,7 +5,7 @@ import { signal } from '@strudel/core';
|
||||
/**
|
||||
* The accelerometer's x-axis value ranges from 0 to 1.
|
||||
* @name accelerationX
|
||||
* @returns {Pattern}
|
||||
* @type {Pattern}
|
||||
* @synonyms accX
|
||||
* @tags external_io
|
||||
* @example
|
||||
@@ -16,7 +16,7 @@ import { signal } from '@strudel/core';
|
||||
/**
|
||||
* The accelerometer's y-axis value ranges from 0 to 1.
|
||||
* @name accelerationY
|
||||
* @returns {Pattern}
|
||||
* @type {Pattern}
|
||||
* @synonyms accY
|
||||
* @tags external_io
|
||||
* @example
|
||||
@@ -27,7 +27,7 @@ import { signal } from '@strudel/core';
|
||||
/**
|
||||
* The accelerometer's z-axis value ranges from 0 to 1.
|
||||
* @name accelerationZ
|
||||
* @returns {Pattern}
|
||||
* @type {Pattern}
|
||||
* @synonyms accZ
|
||||
* @tags external_io
|
||||
* @example
|
||||
@@ -38,7 +38,7 @@ import { signal } from '@strudel/core';
|
||||
/**
|
||||
* The device's gravity x-axis value ranges from 0 to 1.
|
||||
* @name gravityX
|
||||
* @returns {Pattern}
|
||||
* @type {Pattern}
|
||||
* @synonyms gravX
|
||||
* @tags external_io
|
||||
* @example
|
||||
@@ -49,7 +49,7 @@ import { signal } from '@strudel/core';
|
||||
/**
|
||||
* The device's gravity y-axis value ranges from 0 to 1.
|
||||
* @name gravityY
|
||||
* @returns {Pattern}
|
||||
* @type {Pattern}
|
||||
* @synonyms gravY
|
||||
* @tags external_io
|
||||
* @example
|
||||
@@ -60,7 +60,7 @@ import { signal } from '@strudel/core';
|
||||
/**
|
||||
* The device's gravity z-axis value ranges from 0 to 1.
|
||||
* @name gravityZ
|
||||
* @returns {Pattern}
|
||||
* @type {Pattern}
|
||||
* @synonyms gravZ
|
||||
* @tags external_io
|
||||
* @example
|
||||
@@ -71,7 +71,7 @@ import { signal } from '@strudel/core';
|
||||
/**
|
||||
* The device's rotation around the alpha-axis value ranges from 0 to 1.
|
||||
* @name rotationAlpha
|
||||
* @returns {Pattern}
|
||||
* @type {Pattern}
|
||||
* @synonyms rotA, rotZ, rotationZ
|
||||
* @tags external_io
|
||||
* @example
|
||||
@@ -82,7 +82,7 @@ import { signal } from '@strudel/core';
|
||||
/**
|
||||
* The device's rotation around the beta-axis value ranges from 0 to 1.
|
||||
* @name rotationBeta
|
||||
* @returns {Pattern}
|
||||
* @type {Pattern}
|
||||
* @synonyms rotB, rotX, rotationX
|
||||
* @tags external_io
|
||||
* @example
|
||||
@@ -93,7 +93,7 @@ import { signal } from '@strudel/core';
|
||||
/**
|
||||
* The device's rotation around the gamma-axis value ranges from 0 to 1.
|
||||
* @name rotationGamma
|
||||
* @returns {Pattern}
|
||||
* @type {Pattern}
|
||||
* @synonyms rotG, rotY, rotationY
|
||||
* @tags external_io
|
||||
* @example
|
||||
@@ -104,7 +104,7 @@ import { signal } from '@strudel/core';
|
||||
/**
|
||||
* The device's orientation alpha value ranges from 0 to 1.
|
||||
* @name orientationAlpha
|
||||
* @returns {Pattern}
|
||||
* @type {Pattern}
|
||||
* @synonyms oriA, oriZ, orientationZ
|
||||
* @tags external_io
|
||||
* @example
|
||||
@@ -115,7 +115,7 @@ import { signal } from '@strudel/core';
|
||||
/**
|
||||
* The device's orientation beta value ranges from 0 to 1.
|
||||
* @name orientationBeta
|
||||
* @returns {Pattern}
|
||||
* @type {Pattern}
|
||||
* @synonyms oriB, oriX, orientationX
|
||||
* @tags external_io
|
||||
* @example
|
||||
@@ -126,7 +126,7 @@ import { signal } from '@strudel/core';
|
||||
/**
|
||||
* The device's orientation gamma value ranges from 0 to 1.
|
||||
* @name orientationGamma
|
||||
* @returns {Pattern}
|
||||
* @type {Pattern}
|
||||
* @synonyms oriG, oriY, orientationY
|
||||
* @tags external_io
|
||||
* @example
|
||||
@@ -137,7 +137,7 @@ import { signal } from '@strudel/core';
|
||||
/**
|
||||
* The device's absolute orientation alpha value ranges from 0 to 1.
|
||||
* @name absoluteOrientationAlpha
|
||||
* @returns {Pattern}
|
||||
* @type {Pattern}
|
||||
* @synonyms absOriA, absOriZ, absoluteOrientationZ
|
||||
* @tags external_io
|
||||
* @example
|
||||
@@ -148,7 +148,7 @@ import { signal } from '@strudel/core';
|
||||
/**
|
||||
* The device's absolute orientation beta value ranges from 0 to 1.
|
||||
* @name absoluteOrientationBeta
|
||||
* @returns {Pattern}
|
||||
* @type {Pattern}
|
||||
* @synonyms absOriB, absOriX, absoluteOrientationX
|
||||
* @tags external_io
|
||||
* @example
|
||||
@@ -159,7 +159,7 @@ import { signal } from '@strudel/core';
|
||||
/**
|
||||
* The device's absolute orientation gamma value ranges from 0 to 1.
|
||||
* @name absoluteOrientationGamma
|
||||
* @returns {Pattern}
|
||||
* @type {Pattern}
|
||||
* @synonyms absOriG, absOriY, absoluteOrientationY
|
||||
* @tags external_io
|
||||
* @example
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/motion",
|
||||
"version": "1.2.6",
|
||||
"version": "1.3.0",
|
||||
"description": "DeviceMotion API for strudel",
|
||||
"main": "index.mjs",
|
||||
"type": "module",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/mqtt",
|
||||
"version": "1.2.6",
|
||||
"version": "1.3.0",
|
||||
"description": "MQTT API for strudel",
|
||||
"main": "mqtt.mjs",
|
||||
"type": "module",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/osc",
|
||||
"version": "1.3.2",
|
||||
"version": "1.4.0",
|
||||
"description": "OSC messaging for strudel",
|
||||
"main": "osc.mjs",
|
||||
"bin": "./server.js",
|
||||
|
||||
@@ -15,10 +15,11 @@ import Fraction, { gcd } from './fraction.mjs';
|
||||
* - "-" hold previous value
|
||||
* - "." silence
|
||||
*
|
||||
* @tags visualization
|
||||
* @tags internal, visualization
|
||||
* @param {Pattern} pat the pattern to use
|
||||
* @param {number} chars max number of characters (approximately)
|
||||
* @returns {string}
|
||||
* @global
|
||||
* @example
|
||||
* const line = drawLine("0 [1 2 3]", 10); // |0--123|0--123
|
||||
* console.log(line);
|
||||
|
||||
+33
-15
@@ -6,22 +6,40 @@ This program is free software: you can redistribute it and/or modify it under th
|
||||
import Fraction from './fraction.mjs';
|
||||
import { stringifyValues } from './util.mjs';
|
||||
|
||||
/**
|
||||
* @tags internal
|
||||
* @class Event class, representing a discrete or samples event (or "happening").
|
||||
* 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 word "Event" is more or less a reserved word in javascript, hence this
|
||||
* class is named called `Hap`.
|
||||
*/
|
||||
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 metadata, including 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'.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create a hap. Create a hap. Haps and patterns are considered immutable, but you can create a new pattern with modified haps with functions like {@link Pattern#withHaps} and {@link Pattern#withValue}.
|
||||
*
|
||||
* @param {TimeSpan | undefined} whole timespan. 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 the start of the `part` timespan.
|
||||
* @param {TimeSpan} part of the timespan. May never extend outside of the `whole`.
|
||||
* @param {function(State):* | *} value active during the timespan `part`. Must be a function if `stateful` is set to `true`.
|
||||
* @param {object} [context={}] - The context is to store metadata. When two patterns are combined, their context objects are merged.
|
||||
* @param {Array<{ start: number, end: number }>} [context.locations] - list of source code locations causing the event
|
||||
* @param {string[]} [context.tags] Metadata about the Hap
|
||||
* @param {boolean} [stateful=false] - (experimental) if true the value depends on the state.
|
||||
*
|
||||
* @example
|
||||
* // Keep only haps whose full `whole` timespan is at least half a cycle long
|
||||
* s("bd, sd*2, hh*4")
|
||||
* .filterHaps((hap) => hap.whole !== undefined && hap.whole.duration >= 0.5);
|
||||
*
|
||||
* @example
|
||||
* // Keep only haps that begin within the first half of a cycle
|
||||
* note("c3 d3 e3 f3")
|
||||
* .filterHaps((hap) => hap.part.begin < 0.5);
|
||||
*/
|
||||
constructor(whole, part, value, context = {}, stateful = false) {
|
||||
this.whole = whole;
|
||||
this.part = part;
|
||||
|
||||
@@ -4,6 +4,12 @@ let debounce = 1000,
|
||||
lastMessage,
|
||||
lastTime;
|
||||
|
||||
/**
|
||||
* Logs an error to the system and/or Strudel REPL console.
|
||||
* @global
|
||||
* @param {*} e
|
||||
* @param {string} origin
|
||||
*/
|
||||
export function errorLogger(e, origin = 'cyclist') {
|
||||
if (typeof process !== 'undefined' && process.env.NODE_ENV === 'development') {
|
||||
console.error(e);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/pattern",
|
||||
"version": "1.2.6",
|
||||
"version": "1.3.0",
|
||||
"description": "Port of Tidal Cycles to JavaScript. This package contains only the pattern representation.",
|
||||
"main": "index.mjs",
|
||||
"type": "module",
|
||||
|
||||
+153
-57
@@ -91,7 +91,7 @@ export class Pattern {
|
||||
|
||||
/**
|
||||
* Returns a new pattern, with the function applied to the value of
|
||||
* each hap. It has the alias `fmap`.
|
||||
* each {@link Hap}. It has the alias `fmap`.
|
||||
* @tags functional
|
||||
* @synonyms fmap
|
||||
* @param {Function} func to to apply to the value
|
||||
@@ -407,7 +407,7 @@ export class Pattern {
|
||||
// Utility methods mainly for internal use
|
||||
|
||||
/**
|
||||
* Query haps inside the given time span.
|
||||
* Query {@link Hap}s inside the given time span.
|
||||
*
|
||||
* @tags internals
|
||||
* @param {Fraction | number} begin from time
|
||||
@@ -422,11 +422,17 @@ export class Pattern {
|
||||
* @noAutocomplete
|
||||
*/
|
||||
queryArc(begin, end, controls = {}) {
|
||||
try {
|
||||
if (controls.propagateExceptions) {
|
||||
// In tests, we want exceptions to propagate to actually catch problems
|
||||
// and to see the proper stack trace in the test result.
|
||||
return this.query(new State(new TimeSpan(begin, end), controls));
|
||||
} catch (err) {
|
||||
errorLogger(err, 'query');
|
||||
return [];
|
||||
} else {
|
||||
try {
|
||||
return this.query(new State(new TimeSpan(begin, end), controls));
|
||||
} catch (err) {
|
||||
errorLogger(err, 'query');
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -450,7 +456,7 @@ export class Pattern {
|
||||
* Returns a new pattern, where the given function is applied to the query
|
||||
* timespan before passing it to the original pattern.
|
||||
* @tags internals
|
||||
* @param {Function} func the function to apply
|
||||
* @param {function(TimeSpan):TimeSpan} func the function to apply
|
||||
* @returns {Pattern}
|
||||
* @noAutocomplete
|
||||
*/
|
||||
@@ -482,11 +488,11 @@ export class Pattern {
|
||||
}
|
||||
|
||||
/**
|
||||
* Similar to `withQuerySpan`, but the function is applied to the timespans
|
||||
* of all haps returned by pattern queries (both `part` timespans, and where
|
||||
* Similar to {@link Pattern#withQuerySpan}, but the function is applied to the timespans
|
||||
* of all {@link Hap}s returned by pattern queries (both `part` timespans, and where
|
||||
* present, `whole` timespans).
|
||||
* @tags internals
|
||||
* @param {Function} func
|
||||
* @param {function(TimeSpan):TimeSpan} func
|
||||
* @returns {Pattern}
|
||||
* @noAutocomplete
|
||||
*/
|
||||
@@ -495,10 +501,10 @@ export class Pattern {
|
||||
}
|
||||
|
||||
/**
|
||||
* As with `withHapSpan`, but the function is applied to both the
|
||||
* begin and end time of the hap timespans.
|
||||
* As with {@link Pattern#withHapSpan}, but the function is applied to both the
|
||||
* begin and end time of the {@link Hap} timespans.
|
||||
* @tags internals
|
||||
* @param {Function} func the function to apply
|
||||
* @param {function(TimeSpan):TimeSpan} func the function to apply
|
||||
* @returns {Pattern}
|
||||
* @noAutocomplete
|
||||
*/
|
||||
@@ -507,9 +513,9 @@ export class Pattern {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new pattern with the given function applied to the list of haps returned by every query.
|
||||
* Returns a new pattern with the given function applied to the list of {@link Hap}s returned by every query.
|
||||
*
|
||||
* As an end user, you will most likely not need to use this; look at `withContext`, `withHapSpan`, etc. instead.
|
||||
* As an end user, you will most likely not need to use this; look at {@link Pattern#withContext}, {@link Pattern#withHapSpan}, etc. instead.
|
||||
* @tags internals
|
||||
* @param {Function} func
|
||||
* @returns {Pattern}
|
||||
@@ -535,9 +541,9 @@ export class Pattern {
|
||||
}
|
||||
|
||||
/**
|
||||
* As with `withHaps`, but applies the function to every hap, rather than every list of haps.
|
||||
* As with {@link Pattern#withHaps}, but applies the function to every {@link Hap}, rather than every list of haps.
|
||||
*
|
||||
* As an end user, you will most likely not need to use this; look at `withContext`, `withHapSpan`, etc. instead.
|
||||
* As an end user, you will most likely not need to use this; look at {@link Pattern#withContext}, {@link Pattern#withHapSpan}, etc. instead.
|
||||
* @tags internals
|
||||
* @param {Function} func
|
||||
* @returns {Pattern}
|
||||
@@ -559,7 +565,7 @@ export class Pattern {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new pattern with the context field set to every hap set to the given value.
|
||||
* Returns a new pattern with the context field set to every {@link Hap} set to the given value.
|
||||
* @tags internals
|
||||
* @param {*} context
|
||||
* @returns {Pattern}
|
||||
@@ -570,7 +576,7 @@ export class Pattern {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new pattern with the given function applied to the context field of every hap.
|
||||
* Returns a new pattern with the given function applied to the context field of every {@link Hap}.
|
||||
* @tags internals
|
||||
* @param {Function} func
|
||||
* @returns {Pattern}
|
||||
@@ -586,7 +592,7 @@ export class Pattern {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new pattern with the context field of every hap set to an empty object.
|
||||
* Returns a new pattern with the `context` field of every {@link Hap} set to an empty object.
|
||||
* @tags internals
|
||||
* @returns {Pattern}
|
||||
* @noAutocomplete
|
||||
@@ -597,7 +603,7 @@ export class Pattern {
|
||||
|
||||
/**
|
||||
* Returns a new pattern with the given location information added to the
|
||||
* context of every hap.
|
||||
* context of every {@link Hap}.
|
||||
* @tags internals
|
||||
* @param {number} start start offset
|
||||
* @param {number} end end offset
|
||||
@@ -621,9 +627,9 @@ export class Pattern {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new Pattern, which only returns haps that meet the given test.
|
||||
* Returns a new Pattern, which only returns {@link Hap}s that meet the given test.
|
||||
* @tags internals
|
||||
* @param {Function} hap_test - a function which returns false for haps to be removed from the pattern
|
||||
* @param {function(Hap):boolean} hap_test - a function which returns false for {@link Hap}s to be removed from the pattern
|
||||
* @returns {Pattern}
|
||||
* @example
|
||||
* s("bd*8").velocity(rand).filterHaps((h) => (h.whole.begin % 1) < h.value.velocity)
|
||||
@@ -633,7 +639,7 @@ export class Pattern {
|
||||
}
|
||||
|
||||
/**
|
||||
* As with `filterHaps`, but the function is applied to values
|
||||
* As with {@link Pattern#filterHaps}, but the function is applied to values
|
||||
* inside haps.
|
||||
* @tags internals
|
||||
* @param {Function} value_test
|
||||
@@ -660,22 +666,20 @@ export class Pattern {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new pattern, with all haps without onsets filtered out. A hap
|
||||
* with an onset is one with a `whole` timespan that begins at the same time
|
||||
* Returns a new pattern, with all {@link Hap}s without onsets filtered out.
|
||||
*
|
||||
* A hap with an onset is one with a `whole` timespan that begins at the same time
|
||||
* as its `part` timespan.
|
||||
* @tags internals
|
||||
* @returns {Pattern}
|
||||
* @noAutocomplete
|
||||
*/
|
||||
onsetsOnly() {
|
||||
// Returns a new pattern that will only return haps where the start
|
||||
// of the 'whole' timespan matches the start of the 'part'
|
||||
// timespan, i.e. the haps that include their 'onset'.
|
||||
return this.filterHaps((hap) => hap.hasOnset());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new pattern, with 'continuous' haps (those without 'whole'
|
||||
* Returns a new pattern, with 'continuous' {@link Hap}s (those without 'whole'
|
||||
* timespans) removed from query results.
|
||||
* @tags internals
|
||||
* @returns {Pattern}
|
||||
@@ -687,7 +691,7 @@ export class Pattern {
|
||||
}
|
||||
|
||||
/**
|
||||
* Combines adjacent haps with the same value and whole. Only
|
||||
* Combines adjacent {@link Hap}s with the same value and whole. Only
|
||||
* intended for use in tests.
|
||||
* @tags internals
|
||||
* @noAutocomplete
|
||||
@@ -741,7 +745,7 @@ export class Pattern {
|
||||
}
|
||||
|
||||
/**
|
||||
* Queries the pattern for the first cycle, returning Haps. Mainly of use when
|
||||
* Queries the pattern for the first cycle, returning {@link Hap}s. Mainly of use when
|
||||
* debugging a pattern.
|
||||
* @tags internals
|
||||
* @param {boolean} with_context - set to true, otherwise the context field
|
||||
@@ -780,7 +784,7 @@ export class Pattern {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new pattern, which returns haps sorted in temporal order. Mainly
|
||||
* Returns a new pattern, which returns {@link Hap}s sorted in temporal order. Mainly
|
||||
* of use when comparing two patterns for equality, in tests.
|
||||
* @tags internals
|
||||
* @returns {Pattern}
|
||||
@@ -1059,6 +1063,8 @@ Pattern.prototype.collect = function () {
|
||||
/**
|
||||
* Selects indices in in stacked notes.
|
||||
* @tags temporal
|
||||
* @name arpWith
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* note("<[c,eb,g]!2 [c,f,ab] [d,f,ab]>")
|
||||
* .arpWith(haps => haps[2])
|
||||
@@ -1074,6 +1080,8 @@ export const arpWith = register('arpWith', (func, pat) => {
|
||||
/**
|
||||
* Selects indices in in stacked notes.
|
||||
* @tags temporal
|
||||
* @name arp
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* note("<[c,eb,g]!2 [c,f,ab] [d,f,ab]>")
|
||||
* .arp("0 [0,2] 1 [0,2]")
|
||||
@@ -1485,7 +1493,6 @@ const ALIGNMENT_KEYS = ALIGNMENTS.map((how) => how.toLowerCase());
|
||||
*
|
||||
* @param {...any} args
|
||||
* @tags temporal
|
||||
* @memberof Pattern.prototype
|
||||
* @returns {Pattern}
|
||||
* @example
|
||||
* note("c [eb,g] d [eb,g]").mask("<1 [0 1]>")
|
||||
@@ -1501,7 +1508,6 @@ const ALIGNMENT_KEYS = ALIGNMENTS.map((how) => how.toLowerCase());
|
||||
*
|
||||
* @param {...any} args
|
||||
* @tags temporal
|
||||
* @memberof Pattern.prototype
|
||||
* @returns {Pattern}
|
||||
* @example
|
||||
* s("[<bd lt> sd]*2, hh*8").reset("<x@3 x(5,8)>")
|
||||
@@ -1518,7 +1524,6 @@ const ALIGNMENT_KEYS = ALIGNMENTS.map((how) => how.toLowerCase());
|
||||
*
|
||||
* @param {...any} args
|
||||
* @tags temporal
|
||||
* @memberof Pattern.prototype
|
||||
* @returns {Pattern}
|
||||
* @example
|
||||
* s("[<bd lt> sd]*2, hh*8").restart("<x@3 x(5,8)>")
|
||||
@@ -1605,6 +1610,7 @@ export const nothing = gap(0);
|
||||
/**
|
||||
* A discrete value that repeats once per cycle.
|
||||
*
|
||||
* @global
|
||||
* @param {number} value
|
||||
* @tags generators
|
||||
* @returns {Pattern}
|
||||
@@ -1621,6 +1627,11 @@ export function pure(value) {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* checks if the given thing is an pattern
|
||||
* @param {*} thing
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function isPattern(thing) {
|
||||
// thing?.constructor?.name !== 'Pattern' // <- this will fail when code is mangled
|
||||
const is = thing instanceof Pattern || thing?._Pattern;
|
||||
@@ -1637,6 +1648,11 @@ export function isPattern(thing) {
|
||||
return is;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns something into a pattern via pure(), unless it's already a pattern. If a string parser is set via {@link setStringParser}, that is used to reify strings.
|
||||
* @param {*} thing
|
||||
* @returns {Pattern}
|
||||
*/
|
||||
export function reify(thing) {
|
||||
// Turns something into a pattern, unless it's already a pattern
|
||||
if (isPattern(thing)) {
|
||||
@@ -1650,6 +1666,7 @@ export function reify(thing) {
|
||||
|
||||
/**
|
||||
* Takes a list of patterns, and returns a pattern of lists.
|
||||
* @global
|
||||
* @param {Pattern[]} pats
|
||||
* @returns {Pattern}
|
||||
* @tags temporal
|
||||
@@ -1668,6 +1685,8 @@ export function sequenceP(pats) {
|
||||
* @param {...any} pats
|
||||
* @tags temporal
|
||||
* @returns {Pattern}
|
||||
* @name stack
|
||||
* @memberof Pattern.prototype
|
||||
* @synonyms polyrhythm, pr
|
||||
* @example
|
||||
* stack("g3", "b3", ["e4", "d4"]).note()
|
||||
@@ -1685,13 +1704,19 @@ export function stack(...pats) {
|
||||
const query = (state) =>
|
||||
flatten(
|
||||
pats.map((pat) => {
|
||||
try {
|
||||
// An error occurring in one part of the stack should not break
|
||||
// playback of the other parts of the stack.
|
||||
if (state.controls.propagateExceptions) {
|
||||
// In tests, we want exceptions to propagate to actually catch problems
|
||||
// and to see the proper stack trace in the test result.
|
||||
return pat.query(state);
|
||||
} catch (e) {
|
||||
errorLogger(e);
|
||||
return [];
|
||||
} else {
|
||||
try {
|
||||
// An error occurring in one part of the stack should not break
|
||||
// playback of the other parts of the stack.
|
||||
return pat.query(state);
|
||||
} catch (e) {
|
||||
errorLogger(e);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}),
|
||||
);
|
||||
@@ -1722,6 +1747,7 @@ function _stackWith(func, pats) {
|
||||
* @name stackLeft
|
||||
* @tags temporal, stepwise, combiners
|
||||
* @returns {Pattern}
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* stackLeft("0 1 2 3", "3 4", "[4 5 6] 7 8 9 10").scale("c:minor").note()
|
||||
* @example
|
||||
@@ -1742,6 +1768,7 @@ export function stackLeft(...pats) {
|
||||
* @name stackRight
|
||||
* @tags temporal, stepwise, combiners
|
||||
* @returns {Pattern}
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* stackRight("0 1 2 3", "3 4", "[4 5 6] 7 8 9 10").scale("c:minor").note()
|
||||
* @example
|
||||
@@ -1762,6 +1789,7 @@ export function stackRight(...pats) {
|
||||
* @tags temporal, stepwise, combiners
|
||||
* @synonyms stackCentre
|
||||
* @returns {Pattern}
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* stackCenter("0 1 2 3", "3 4", "[4 5 6] 7 8 9 10").scale("c:minor").note()
|
||||
* @example
|
||||
@@ -1792,6 +1820,7 @@ export function stackCentre(...pats) {
|
||||
* @name stackRepeat
|
||||
* @tags temporal, stepwise, combiners
|
||||
* @returns {Pattern}
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* stackRepeat("0 1 2 3", "3 4", "[4 5 6] 7 8 9 10").scale("c:minor").note()
|
||||
* @example
|
||||
@@ -1855,6 +1884,7 @@ export function slowcat(...pats) {
|
||||
}
|
||||
|
||||
/** Concatenation: combines a list of patterns, switching between them successively, one per cycle. Unlike slowcat, this version will skip cycles.
|
||||
* @global
|
||||
* @tags combiners
|
||||
* @param {...any} pats The items to concatenate
|
||||
* @returns {Pattern}
|
||||
@@ -1896,6 +1926,7 @@ export function cat(...pats) {
|
||||
* Allows to arrange multiple patterns together over multiple cycles.
|
||||
* Takes a variable number of arrays with two elements specifying the number of cycles and the pattern to use.
|
||||
*
|
||||
* @global
|
||||
* @param {...any} sections
|
||||
* @tags combiners
|
||||
* @returns {Pattern}
|
||||
@@ -2198,6 +2229,7 @@ export const ceil = register('ceil', function (pat) {
|
||||
* @tags math
|
||||
* @returns {Pattern}
|
||||
* @noAutocomplete
|
||||
* @memberof Pattern.prototype
|
||||
*/
|
||||
export const toBipolar = register('toBipolar', function (pat) {
|
||||
return pat.fmap((x) => x * 2 - 1);
|
||||
@@ -2209,6 +2241,7 @@ export const toBipolar = register('toBipolar', function (pat) {
|
||||
* @tags math
|
||||
* @returns {Pattern}
|
||||
* @noAutocomplete
|
||||
* @memberof Pattern.prototype
|
||||
*/
|
||||
export const fromBipolar = register('fromBipolar', function (pat) {
|
||||
return pat.fmap((x) => (x + 1) / 2);
|
||||
@@ -2286,6 +2319,8 @@ export const ratio = register('ratio', (pat) =>
|
||||
|
||||
/** Compress each cycle into the given timespan, leaving a gap
|
||||
* @tags temporal
|
||||
* @name compress
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* cat(
|
||||
* s("bd sd").compress(.25,.75),
|
||||
@@ -2310,6 +2345,7 @@ export const { compressSpan, compressspan } = register(['compressSpan', 'compres
|
||||
* @tags temporal
|
||||
* @name fastGap
|
||||
* @synonyms fastgap
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* s("bd sd").fastGap(2)
|
||||
*/
|
||||
@@ -2346,6 +2382,7 @@ export const { fastGap, fastgap } = register(['fastGap', 'fastgap'], function (f
|
||||
/**
|
||||
* Similar to `compress`, but doesn't leave gaps, and the 'focus' can be bigger than a cycle
|
||||
* @tags temporal
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* s("bd hh sd hh").focus(1/4, 3/4)
|
||||
*/
|
||||
@@ -2364,6 +2401,8 @@ export const { focusSpan, focusspan } = register(['focusSpan', 'focusspan'], fun
|
||||
|
||||
/** The ply function repeats each event the given number of times.
|
||||
* @tags temporal
|
||||
* @name ply
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* s("bd ~ sd cp").ply("<1 2 3>")
|
||||
*/
|
||||
@@ -2423,6 +2462,8 @@ export const { slow, sparsity } = register(['slow', 'sparsity'], function (facto
|
||||
/**
|
||||
* Carries out an operation 'inside' a cycle.
|
||||
* @tags temporal
|
||||
* @name inside
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* "0 1 2 3 4 3 2 1".inside(4, rev).scale('C major').note()
|
||||
* // "0 1 2 3 4 3 2 1".slow(4).rev().fast(4).scale('C major').note()
|
||||
@@ -2434,6 +2475,8 @@ export const inside = register('inside', function (factor, f, pat) {
|
||||
/**
|
||||
* Carries out an operation 'outside' a cycle.
|
||||
* @tags temporal
|
||||
* @name outside
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* "<[0 1] 2 [3 4] 5>".outside(4, rev).scale('C major').note()
|
||||
* // "<[0 1] 2 [3 4] 5>".fast(4).rev().slow(4).scale('C major').note()
|
||||
@@ -2492,6 +2535,7 @@ export const { firstOf, every } = register(['firstOf', 'every'], function (n, fu
|
||||
* Applies the given function to the pattern. Like layer, but with a single function:
|
||||
* @tags combiners
|
||||
* @name apply
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* "<c3 eb3 g3>".scale('C minor').apply(scaleTranspose("0,2,4")).note()
|
||||
*/
|
||||
@@ -2503,6 +2547,8 @@ export const apply = register('apply', function (func, pat) {
|
||||
* Plays the pattern at the given cycles per minute.
|
||||
* @tags temporal
|
||||
* @deprecated
|
||||
* @name cpm
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* s("<bd sd>,hh*2").cpm(90) // = 90 bpm
|
||||
*/
|
||||
@@ -2557,6 +2603,8 @@ export const late = register(
|
||||
* Plays a portion of a pattern, specified by the beginning and end of a time span. The new resulting pattern is played over the time period of the original pattern:
|
||||
*
|
||||
* @tags temporal
|
||||
* @name zoom
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* s("bd*2 hh*3 [sd bd]*2 perc").zoom(0.25, 0.75)
|
||||
* // s("hh*3 [sd bd]*2") // equivalent
|
||||
@@ -2586,6 +2634,7 @@ export const { zoomArc, zoomarc } = register(['zoomArc', 'zoomarc'], function (a
|
||||
* @tags temporal
|
||||
* @param {number} number of slices
|
||||
* @param {number} slices to play
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* note("0 1 2 3 4 5 6 7".scale('c:mixolydian'))
|
||||
* .bite(4, "3 2 1 0")
|
||||
@@ -2681,6 +2730,8 @@ export const { isobite, cyclestruct, cycleStruct } = register(
|
||||
* Selects the given fraction of the pattern and repeats that part to fill the remainder of the cycle.
|
||||
* @tags temporal
|
||||
* @param {number} fraction fraction to select
|
||||
* @name linger
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* s("lt ht mt cp, [hh oh]*2").linger("<1 .5 .25 .125>")
|
||||
*/
|
||||
@@ -2704,6 +2755,7 @@ export const linger = register(
|
||||
* @name segment
|
||||
* @synonyms seg
|
||||
* @param {number} segments number of segments per cycle
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* note(saw.range(40,52).segment(24))
|
||||
*/
|
||||
@@ -2716,15 +2768,21 @@ export const { segment, seg } = register(['segment', 'seg'], function (rate, pat
|
||||
* @tags temporal
|
||||
* @param {number} subdivision
|
||||
* @param {number} offset
|
||||
* @name swingBy
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* s("hh*8").swingBy(1/3, 4)
|
||||
*/
|
||||
export const swingBy = register('swingBy', (swing, n, pat) => pat.inside(n, late(seq(0, swing / 2))));
|
||||
export const swingBy = register('swingBy', (swing, n, pat) =>
|
||||
pat.inside(n, late(stack(seq(0, silence), seq(silence, swing / 2).late(swing / 2)))),
|
||||
);
|
||||
|
||||
/**
|
||||
* Shorthand for swingBy with 1/3:
|
||||
* @tags temporal
|
||||
* @param {number} subdivision
|
||||
* @name swing
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* s("hh*8").swing(4)
|
||||
* // s("hh*8").swingBy(1/3, 4)
|
||||
@@ -2736,6 +2794,7 @@ export const swing = register('swing', (n, pat) => pat.swingBy(1 / 3, n));
|
||||
* @tags temporal
|
||||
* @name invert
|
||||
* @synonyms inv
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* s("bd").struct("1 0 0 1 0 0 1 0".lastOf(4, invert))
|
||||
*/
|
||||
@@ -2850,6 +2909,7 @@ export const revv = register('revv', function (pat) {
|
||||
* event is shifted. pressBy(0.5) is the same as press, while
|
||||
* pressBy(1/3) shifts each event by a third of its timespan.
|
||||
* @tags temporal
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* stack(s("hh*4"),
|
||||
* s("bd mt sd ht").pressBy("<0 0.5 0.25>")
|
||||
@@ -2862,6 +2922,7 @@ export const pressBy = register('pressBy', function (r, pat) {
|
||||
/**
|
||||
* Syncopates a rhythm, by shifting each event halfway into its timespan.
|
||||
* @tags temporal
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* stack(s("hh*4"),
|
||||
* s("bd mt sd ht").every(4, press)
|
||||
@@ -2874,7 +2935,6 @@ export const press = register('press', function (pat) {
|
||||
/**
|
||||
* Silences a pattern.
|
||||
* @tags temporal
|
||||
* @memberof Pattern.prototype
|
||||
* @returns {Pattern}
|
||||
* @example
|
||||
* stack(
|
||||
@@ -2889,6 +2949,8 @@ Pattern.prototype.hush = function () {
|
||||
/**
|
||||
* Applies `rev` to a pattern every other cycle, so that the pattern alternates between forwards and backwards.
|
||||
* @tags temporal
|
||||
* @name palindrome
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* note("c d e g").palindrome()
|
||||
*/
|
||||
@@ -2909,6 +2971,7 @@ export const palindrome = register(
|
||||
* @param {number} times how many times to repeat
|
||||
* @param {number} time cycle offset between iterations
|
||||
* @param {Function} func function to apply, given the pattern and the iteration index
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* "<0 [2 4]>"
|
||||
* .echoWith(4, 1/8, (p,n) => p.add(n*2))
|
||||
@@ -2936,6 +2999,7 @@ export const applyN = register('applyN', function (n, func, p) {
|
||||
* @synonyms plywith
|
||||
* @param {number} factor how many times to repeat
|
||||
* @param {Function} func function to apply, given the pattern
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* "<0 [2 4]>"
|
||||
* .plyWith(4, (p) => p.add(2))
|
||||
@@ -2959,6 +3023,7 @@ export const plyWith = register(['plyWith', 'plywith'], function (factor, func,
|
||||
* @synonyms plyforeach
|
||||
* @param {number} factor how many times to repeat
|
||||
* @param {Function} func function to apply, given the pattern and the iteration index
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* "<0 [2 4]>"
|
||||
* .plyForEach(4, (p,n) => p.add(n*2))
|
||||
@@ -3176,6 +3241,7 @@ export const bypass = register(
|
||||
* @synonyms rib
|
||||
* @param {number} offset start point of loop in cycles
|
||||
* @param {number} cycles loop length in cycles
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* note("<c d e f>").ribbon(1, 2)
|
||||
* @example
|
||||
@@ -3212,6 +3278,7 @@ Pattern.prototype.tag = function (tag) {
|
||||
* @name filter
|
||||
* @tags temporal, functional
|
||||
* @param {Function} test function to test Hap
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* s("hh!7 oh").filter(hap => hap.value.s === 'hh')
|
||||
*/
|
||||
@@ -3222,6 +3289,7 @@ export const filter = register('filter', (test, pat) => pat.withHaps((haps) => h
|
||||
* @name filterWhen
|
||||
* @tags temporal, functional
|
||||
* @param {Function} test function to test Hap.whole.begin
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* oneCycle: s("bd*4").filterWhen((t) => t < 1)
|
||||
*/
|
||||
@@ -3234,6 +3302,7 @@ export const filterWhen = register('filterWhen', (test, pat) => pat.filter((h) =
|
||||
* @param {number} start start within cycle (0 - 1)
|
||||
* @param {number} end end within cycle (0 - 1). Must be > start
|
||||
* @param {Function} func function to be applied to the sub-pattern
|
||||
* @memberof Pattern.prototype
|
||||
*/
|
||||
export const within = register('within', (a, b, fn, pat) =>
|
||||
stack(
|
||||
@@ -3306,6 +3375,8 @@ export function _match(span, hap_p) {
|
||||
*
|
||||
* Speeds a pattern up or down, to fit to the given number of steps per cycle.
|
||||
* @tags stepwise
|
||||
* @name pace
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* sound("bd sd cp").pace(4)
|
||||
* // The same as sound("{bd sd cp}%4") or sound("<bd sd cp>*4")
|
||||
@@ -3381,6 +3452,7 @@ export function polymeter(...args) {
|
||||
/** 'Concatenates' patterns like `fastcat`, but proportional to a number of steps per cycle.
|
||||
* The steps can either be inferred from the pattern, or provided as a [length, pattern] pair.
|
||||
* Has the alias `timecat`.
|
||||
* @global
|
||||
* @param {...any} timepats
|
||||
* @name stepcat
|
||||
* @tags stepwise
|
||||
@@ -3441,6 +3513,7 @@ export function stepcat(...timepats) {
|
||||
* Concatenates patterns stepwise, according to an inferred 'steps per cycle'.
|
||||
* Similar to `stepcat`, but if an argument is a list, the whole pattern will alternate between the elements in the list.
|
||||
*
|
||||
* @global
|
||||
* @param {...any} groups
|
||||
* @tags stepwise
|
||||
* @returns {Pattern}
|
||||
@@ -3470,6 +3543,8 @@ export function stepalt(...groups) {
|
||||
* Takes the given number of steps from a pattern (dropping the rest).
|
||||
* A positive number will take steps from the start of a pattern, and a negative number from the end.
|
||||
* @tags stepwise
|
||||
* @name take
|
||||
* @memberof Pattern.prototype
|
||||
* @returns {Pattern}
|
||||
* @example
|
||||
* "bd cp ht mt".take("2").sound()
|
||||
@@ -3514,8 +3589,10 @@ export const take = stepRegister('take', function (i, pat) {
|
||||
*
|
||||
* Drops the given number of steps from a pattern.
|
||||
* A positive number will drop steps from the start of a pattern, and a negative number from the end.
|
||||
* @name drop
|
||||
* @tags stepwise
|
||||
* @returns {Pattern}
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* "tha dhi thom nam".drop("1").sound().bank("mridangam")
|
||||
* @example
|
||||
@@ -3543,7 +3620,9 @@ export const drop = stepRegister('drop', function (i, pat) {
|
||||
* `extend` is similar to `fast` in that it increases its density, but it also increases the step count
|
||||
* accordingly. So `stepcat("a b".extend(2), "c d")` would be the same as `"a b a b c d"`, whereas
|
||||
* `stepcat("a b".fast(2), "c d")` would be the same as `"[a b] [a b] c d"`.
|
||||
* @name extend
|
||||
* @tags stepwise
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* stepcat(
|
||||
* sound("bd bd - <cp hh>").extend(2),
|
||||
@@ -3560,6 +3639,7 @@ export const extend = stepRegister('extend', function (factor, pat) {
|
||||
* `replicate` is similar to `extend`, except that `replicate` will "replicate" the thing being extended. This will only differ from `extend` when the input pattern differs from cycle to cycle.
|
||||
*
|
||||
* @tags stepwise
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* stepcat(
|
||||
* sound("bd bd - <cp hh>").replicate(2),
|
||||
@@ -3574,7 +3654,9 @@ export const replicate = stepRegister('replicate', function (factor, pat) {
|
||||
* *Experimental*
|
||||
*
|
||||
* Expands the step size of the pattern by the given factor.
|
||||
* @name expand
|
||||
* @tags stepwise
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* sound("tha dhi thom nam").bank("mridangam").expand("3 2 1 1 2 3").pace(8)
|
||||
*/
|
||||
@@ -3587,6 +3669,8 @@ export const expand = stepRegister('expand', function (factor, pat) {
|
||||
*
|
||||
* Contracts the step size of the pattern by the given factor. See also `expand`.
|
||||
* @tags stepwise
|
||||
* @name contract
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* sound("tha dhi thom nam").bank("mridangam").contract("3 2 1 1 2 3").pace(8)
|
||||
*/
|
||||
@@ -3648,6 +3732,8 @@ export const growlist = (amount, pat) => pat.growlist(amount);
|
||||
* A positive number will progressively drop steps from the start of a pattern, and a negative number from the end.
|
||||
* @tags stepwise
|
||||
* @returns {Pattern}
|
||||
* @name shrink
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* "tha dhi thom nam".shrink("1").sound()
|
||||
* .bank("mridangam")
|
||||
@@ -3688,6 +3774,8 @@ export const shrink = register(
|
||||
* A positive number will progressively grow steps from the start of a pattern, and a negative number from the end.
|
||||
* @tags stepwise
|
||||
* @returns {Pattern}
|
||||
* @name grow
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* "tha dhi thom nam".grow("1").sound()
|
||||
* .bank("mridangam")
|
||||
@@ -3731,6 +3819,8 @@ export const grow = register(
|
||||
* @param {...any} many
|
||||
* @tags stepwise
|
||||
* @returns {Pattern}
|
||||
* @name tour
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* "[c g]".tour("e f", "e f g", "g f e c").note()
|
||||
* .sound("folkharp")
|
||||
@@ -3757,6 +3847,7 @@ Pattern.prototype.tour = function (...many) {
|
||||
* Using `pace` to set the number of steps per cycle is therefore usually recommended.
|
||||
*
|
||||
* @param {...any} pats
|
||||
* @global
|
||||
* @tags stepwise
|
||||
* @returns {Pattern}
|
||||
* @example
|
||||
@@ -3771,7 +3862,7 @@ export const zip = function (...pats) {
|
||||
return zipped._fast(steps).setSteps(steps);
|
||||
};
|
||||
|
||||
/** Aliases for `stepcat` */
|
||||
// Aliases for `stepcat`
|
||||
export const timecat = stepcat;
|
||||
export const timeCat = stepcat;
|
||||
|
||||
@@ -3815,18 +3906,6 @@ export const ref = (accessor) =>
|
||||
.withValue(() => reify(accessor()))
|
||||
.innerJoin();
|
||||
|
||||
/**
|
||||
* creates a structure pattern from divisions of a cycle
|
||||
* especially useful for creating rhythms
|
||||
* @param {Function} join
|
||||
* @name beat
|
||||
* @tags temporal
|
||||
* @returns {Pattern}
|
||||
* @example
|
||||
* s("bd").beat("0,7,10", 16)
|
||||
* @example
|
||||
* s("sd").beat("4,12", 16)
|
||||
*/
|
||||
const __beat = (join) => (t, div, pat) => {
|
||||
t = Fraction(t).mod(div);
|
||||
div = Fraction(div);
|
||||
@@ -3835,6 +3914,23 @@ const __beat = (join) => (t, div, pat) => {
|
||||
return join(pat.fmap((x) => pure(x)._compress(b, e)));
|
||||
};
|
||||
|
||||
/**
|
||||
* Changes the structure of a pattern by dividing the cycle into equal segments (total number of beats) and allowing to specify at which segment (beat) the pattern is played.
|
||||
* @param {number[] | Pattern} beat - sections of the beat that should play the sound. Multiple beats can be stacked in a pattern
|
||||
* @param {number} number of total beats to divide the cycle into
|
||||
* @name beat
|
||||
* @tags temporal
|
||||
* @returns {Pattern}
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* s("bd").beat("0,7,10", 16)
|
||||
* @example
|
||||
* s("sd").beat("4,12", 16)
|
||||
* @example
|
||||
* s("sd").beat("0,3,6", 8)
|
||||
* //same as
|
||||
* s("sd - - sd - - sd -")
|
||||
*/
|
||||
export const { beat } = register(
|
||||
['beat'],
|
||||
__beat((x) => x.innerJoin()),
|
||||
|
||||
+42
-24
@@ -26,12 +26,22 @@ const _pick = function (lookup, pat, modulo = true) {
|
||||
});
|
||||
};
|
||||
|
||||
export const pick = function (lookup, pat) {
|
||||
// backward compatibility - the args used to be flipped
|
||||
if (Array.isArray(pat)) {
|
||||
[pat, lookup] = [lookup, pat];
|
||||
}
|
||||
return __pick(lookup, pat);
|
||||
};
|
||||
|
||||
/** * Picks patterns (or plain values) either from a list (by index) or a lookup table (by name).
|
||||
* Similar to `inhabit`, but maintains the structure of the original patterns.
|
||||
* The lookup can also be a pattern of objects, such as a pattern of controls, in which case each of its events is used as the lookup table.
|
||||
* @tags combiners
|
||||
* @param {Pattern} pat
|
||||
* @param {*} xs
|
||||
* @name pick
|
||||
* @memberof Pattern.prototype
|
||||
* @returns {Pattern}
|
||||
* @example
|
||||
* note("<0 1 2!2 3>".pick(["g a", "e f", "f g f g" , "g c d"]))
|
||||
@@ -46,15 +56,6 @@ const _pick = function (lookup, pat, modulo = true) {
|
||||
* const pat = sound("bd cp").speed("<2 3>")
|
||||
* pat.fast("speed".pick(pat))
|
||||
*/
|
||||
|
||||
export const pick = function (lookup, pat) {
|
||||
// backward compatibility - the args used to be flipped
|
||||
if (Array.isArray(pat)) {
|
||||
[pat, lookup] = [lookup, pat];
|
||||
}
|
||||
return __pick(lookup, pat);
|
||||
};
|
||||
|
||||
const __pick = register('pick', function (lookup, pat) {
|
||||
return _pick(lookup, pat, false).innerJoin();
|
||||
});
|
||||
@@ -66,9 +67,10 @@ const __pick = register('pick', function (lookup, pat) {
|
||||
* @tags combiners
|
||||
* @param {Pattern} pat
|
||||
* @param {*} xs
|
||||
* @name pickmod
|
||||
* @memberof Pattern.prototype
|
||||
* @returns {Pattern}
|
||||
*/
|
||||
|
||||
export const pickmod = register('pickmod', function (lookup, pat) {
|
||||
return _pick(lookup, pat, true).innerJoin();
|
||||
});
|
||||
@@ -78,6 +80,8 @@ export const pickmod = register('pickmod', function (lookup, pat) {
|
||||
* @param {Pattern} pat
|
||||
* @param {Pattern} lookup a pattern of indices or names
|
||||
* @param {Function[] | object} lookup the array or lookup object of functions from which to pull
|
||||
* @name pickF
|
||||
* @memberof Pattern.prototype
|
||||
* @returns {Pattern}
|
||||
* @example
|
||||
* s("bd [rim hh]").pickF("<0 1 2>", [rev,jux(rev),fast(2)])
|
||||
@@ -98,6 +102,8 @@ export const pickF = register('pickF', function (pickPattern, lookup, pat) {
|
||||
* @param {Pattern} pat
|
||||
* @param {Pattern} lookup a pattern of indices or names
|
||||
* @param {Function[] | object} lookup the array or lookup object of functions from which to pull
|
||||
* @name pickmodF
|
||||
* @memberof Pattern.prototype
|
||||
* @returns {Pattern}
|
||||
*/
|
||||
export const pickmodF = register('pickmodF', function (pickPattern, lookup, pat) {
|
||||
@@ -108,6 +114,7 @@ export const pickmodF = register('pickmodF', function (pickPattern, lookup, pat)
|
||||
* @tags combiners
|
||||
* @param {Pattern} pat
|
||||
* @param {*} xs
|
||||
* @memberof Pattern.prototype
|
||||
* @returns {Pattern}
|
||||
* @example
|
||||
* note("<0*4 1 2*2 3*3>".pickOut(["g a", "e f", "f g f g" , "g c d"]))
|
||||
@@ -121,6 +128,7 @@ export const pickOut = register('pickOut', function (lookup, pat) {
|
||||
* @tags combiners
|
||||
* @param {Pattern} pat
|
||||
* @param {*} xs
|
||||
* @memberof Pattern.prototype
|
||||
* @returns {Pattern}
|
||||
*/
|
||||
export const pickmodOut = register('pickmodOut', function (lookup, pat) {
|
||||
@@ -131,26 +139,30 @@ export const pickmodOut = register('pickmodOut', function (lookup, pat) {
|
||||
* @tags combiners
|
||||
* @param {Pattern} pat
|
||||
* @param {*} xs
|
||||
* @name pickRestart
|
||||
* @memberof Pattern.prototype
|
||||
* @returns {Pattern}
|
||||
*/
|
||||
export const pickRestart = register('pickRestart', function (lookup, pat) {
|
||||
return _pick(lookup, pat, false).restartJoin();
|
||||
});
|
||||
|
||||
/** * The same as `pickRestart`, but if you pick a number greater than the size of the list,
|
||||
* it wraps around, rather than sticking at the maximum value.
|
||||
* @tags combiners
|
||||
* @param {Pattern} pat
|
||||
* @param {*} xs
|
||||
* @returns {Pattern}
|
||||
* @example
|
||||
* "<a@2 b@2 c@2 d@2>".pickRestart({
|
||||
a: n("0 1 2 0"),
|
||||
b: n("2 3 4 ~"),
|
||||
c: n("[4 5] [4 3] 2 0"),
|
||||
d: n("0 -3 0 ~")
|
||||
}).scale("C:major").s("piano")
|
||||
*/
|
||||
/** The same as `pickRestart`, but if you pick a number greater than the size of the list,
|
||||
* it wraps around, rather than sticking at the maximum value.
|
||||
* @tags combiners
|
||||
* @param {Pattern} pat
|
||||
* @param {*} xs
|
||||
* @name pickmodRestart
|
||||
* @memberof Pattern.prototype
|
||||
* @returns {Pattern}
|
||||
* @example
|
||||
* "<a@2 b@2 c@2 d@2>".pickRestart({
|
||||
a: n("0 1 2 0"),
|
||||
b: n("2 3 4 ~"),
|
||||
c: n("[4 5] [4 3] 2 0"),
|
||||
d: n("0 -3 0 ~")
|
||||
}).scale("C:major").s("piano")
|
||||
*/
|
||||
export const pickmodRestart = register('pickmodRestart', function (lookup, pat) {
|
||||
return _pick(lookup, pat, true).restartJoin();
|
||||
});
|
||||
@@ -159,6 +171,8 @@ export const pickmodRestart = register('pickmodRestart', function (lookup, pat)
|
||||
* @tags combiners
|
||||
* @param {Pattern} pat
|
||||
* @param {*} xs
|
||||
* @name pickReset
|
||||
* @memberof Pattern.prototype
|
||||
* @returns {Pattern}
|
||||
*/
|
||||
export const pickReset = register('pickReset', function (lookup, pat) {
|
||||
@@ -170,6 +184,8 @@ export const pickReset = register('pickReset', function (lookup, pat) {
|
||||
* @tags combiners
|
||||
* @param {Pattern} pat
|
||||
* @param {*} xs
|
||||
* @name pickmodReset
|
||||
* @memberof Pattern.prototype
|
||||
* @returns {Pattern}
|
||||
*/
|
||||
export const pickmodReset = register('pickmodReset', function (lookup, pat) {
|
||||
@@ -183,6 +199,7 @@ export const pickmodReset = register('pickmodReset', function (lookup, pat) {
|
||||
* @synonyms pickSqueeze
|
||||
* @param {Pattern} pat
|
||||
* @param {*} xs
|
||||
* @memberof Pattern.prototype
|
||||
* @returns {Pattern}
|
||||
* @example
|
||||
* let a = s("bd(3,8)")
|
||||
@@ -206,6 +223,7 @@ export const { inhabit, pickSqueeze } = register(['inhabit', 'pickSqueeze'], fun
|
||||
* @tags combiners
|
||||
* @param {Pattern} pat
|
||||
* @param {*} xs
|
||||
* @memberof Pattern.prototype
|
||||
* @returns {Pattern}
|
||||
*/
|
||||
|
||||
|
||||
+162
-32
@@ -6,18 +6,26 @@ This program is free software: you can redistribute it and/or modify it under th
|
||||
|
||||
import { Hap } from './hap.mjs';
|
||||
import { Pattern, fastcat, pure, register, reify, silence, stack, sequenceP, isPattern } from './pattern.mjs';
|
||||
import { _mod } from './util.mjs';
|
||||
import { _mod, noteToMidi } from './util.mjs';
|
||||
import Fraction from './fraction.mjs';
|
||||
|
||||
import { id, keyAlias, getCurrentKeyboardState } from './util.mjs';
|
||||
import TimeSpan from './timespan.mjs';
|
||||
|
||||
/**
|
||||
* A `signal` consisting of a constant value. Similar to `pure`, except that function
|
||||
* creates a pattern with one event per cycle, whereas 'steady' patterns don't have
|
||||
* an discrete structure.
|
||||
*
|
||||
* @param {*} value The constant value of the resulting pattern
|
||||
* @returns {Pattern}
|
||||
*/
|
||||
export function steady(value) {
|
||||
// A continuous value
|
||||
return new Pattern((state) => [new Hap(undefined, state.span, value)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a signal given by the input function
|
||||
* Creates a "signal", an unstructured pattern consisting of a single value that changes over time.
|
||||
*
|
||||
* @name signal
|
||||
* @param {*} func
|
||||
@@ -204,27 +212,6 @@ export const itri2 = fastcat(isaw2, saw2);
|
||||
*/
|
||||
export const time = signal(id);
|
||||
|
||||
/**
|
||||
* The mouse's x position value ranges from 0 to 1.
|
||||
* @name mousex
|
||||
* @synonyms mouseX
|
||||
* @returns {Pattern}
|
||||
* @tags external_io
|
||||
* @example
|
||||
* n(mousex.segment(4).range(0,7)).scale("C:minor")
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* The mouse's y position value ranges from 0 to 1.
|
||||
* @name mousey
|
||||
* @synonyms mouseY
|
||||
* @returns {Pattern}
|
||||
* @tags external_io
|
||||
* @example
|
||||
* n(mousey.segment(4).range(0,7)).scale("C:minor")
|
||||
*
|
||||
*/
|
||||
let _mouseY = 0,
|
||||
_mouseX = 0;
|
||||
if (typeof window !== 'undefined') {
|
||||
@@ -235,8 +222,29 @@ if (typeof window !== 'undefined') {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* The mouse's y position value ranges from 0 to 1.
|
||||
* @name mousey
|
||||
* @synonyms mouseY
|
||||
* @type {Pattern}
|
||||
* @tags external_io
|
||||
* @example
|
||||
* n(mousey.segment(4).range(0,7)).scale("C:minor")
|
||||
*
|
||||
*/
|
||||
export const mousey = signal(() => _mouseY);
|
||||
export const mouseY = signal(() => _mouseY);
|
||||
|
||||
/**
|
||||
* The mouse's x position value ranges from 0 to 1.
|
||||
* @name mousex
|
||||
* @synonyms mouseX
|
||||
* @type {Pattern}
|
||||
* @tags external_io
|
||||
* @example
|
||||
* n(mousex.segment(4).range(0,7)).scale("C:minor")
|
||||
*
|
||||
*/
|
||||
export const mousex = signal(() => _mouseX);
|
||||
export const mouseX = signal(() => _mouseX);
|
||||
|
||||
@@ -505,6 +513,7 @@ export const withSeed = (func, pat) => {
|
||||
* @name seed
|
||||
* @tags math
|
||||
* @param {number} n A new seed. Can be any number.
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* $: s("hh*4").degrade();
|
||||
* $: s("bd*4").degrade().seed(1); // Will degrade different events from the hi-hat
|
||||
@@ -627,12 +636,19 @@ export const chooseInWith = (pat, xs) => {
|
||||
*/
|
||||
export const choose = (...xs) => chooseWith(rand, xs);
|
||||
|
||||
/**
|
||||
* As with {choose}, but the structure comes from the chosen values, rather
|
||||
* than the pattern you're using to choose with.
|
||||
* @param {...any} xs
|
||||
* @returns {Pattern} - a continuous pattern.
|
||||
*/
|
||||
export const chooseIn = (...xs) => chooseInWith(rand, xs);
|
||||
|
||||
/**
|
||||
* Chooses from the given list of values (or patterns of values), according
|
||||
* to the pattern that the method is called on. The pattern should be in
|
||||
* the range 0 .. 1.
|
||||
* @name choose
|
||||
* @tags temporal
|
||||
* @param {...any} xs
|
||||
* @memberof Pattern.prototype
|
||||
@@ -645,6 +661,7 @@ Pattern.prototype.choose = function (...xs) {
|
||||
/**
|
||||
* As with choose, but the pattern that this method is called on should be
|
||||
* in the range -1 .. 1
|
||||
* @name choose2
|
||||
* @tags temporal
|
||||
* @param {...any} xs
|
||||
* @memberof Pattern.prototype
|
||||
@@ -778,12 +795,10 @@ export const perlin = signal((t, controls) => _perlin(t, controls.randSeed));
|
||||
export const berlin = signal((t, controls) => _berlin(t, controls.randSeed));
|
||||
|
||||
/**
|
||||
* `degradeByWith` is like `degradeBy`, but with control over the random or other signal used to filter out the events.
|
||||
*
|
||||
* `degradeByWith` is like `degradeBy`, but with control over the signal used to degrade the pattern.
|
||||
* It removes events from a pattern given a signal of numbers and a cutoff value for interpreting that pattern as true or false.
|
||||
* `degradeBy(x)` is essentially `degradeByWith(rand, x)`
|
||||
*
|
||||
* This allows you to do things other than with `rand`, see examples below
|
||||
*
|
||||
* @name degradeByWith
|
||||
* @param {Pattern|number} test
|
||||
* @param {Pattern|number} testAgainst
|
||||
@@ -1047,7 +1062,6 @@ export const never = register('never', function (_, pat) {
|
||||
});
|
||||
|
||||
/**
|
||||
*
|
||||
* Shorthand for `.sometimesBy(1, fn)` (always calls fn)
|
||||
*
|
||||
* @tags temporal
|
||||
@@ -1061,8 +1075,11 @@ export const always = register('always', function (func, pat) {
|
||||
return func(pat);
|
||||
});
|
||||
|
||||
//keyname: string | Array<string>
|
||||
//keyname reference: https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values
|
||||
/**
|
||||
* checks if a key is down
|
||||
* @param {string | Array<string>} keyname reference: https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function _keyDown(keyname) {
|
||||
if (Array.isArray(keyname) === false) {
|
||||
keyname = [keyname];
|
||||
@@ -1103,7 +1120,6 @@ export const whenKey = register('whenKey', function (input, func, pat) {
|
||||
* @example
|
||||
* keyDown("Control:j").pick([s("bd(5,8)"), s("cp(3,8)")])
|
||||
*/
|
||||
|
||||
export const keyDown = register('keyDown', function (pat) {
|
||||
return pat.fmap(_keyDown);
|
||||
});
|
||||
@@ -1116,6 +1132,7 @@ export const keyDown = register('keyDown', function (pat) {
|
||||
* See also its reciprocal, `per`, also known as `perCycle`.
|
||||
*
|
||||
* @tags temporal
|
||||
* @type {Pattern}
|
||||
* @example
|
||||
* // Shorter events are lower in pitch
|
||||
* sound("saw saw [saw saw] saw")
|
||||
@@ -1128,14 +1145,34 @@ export const cyclesPer = new Pattern(function (state) {
|
||||
return [new Hap(undefined, state.span, state.span.duration)];
|
||||
});
|
||||
|
||||
/**
|
||||
* A pattern measuring the duration of events, in seconds per event.
|
||||
* `secondsPer` doesn't have structure itself, but takes structue, and therefore
|
||||
* event durations, from the pattern that it is combined with.
|
||||
* For example `secondsPer.struct("1 1 [1 1] 1")` with `cps = 1` would give the same as `"0.25 0.25 [0.125 0.125] 0.25"`.
|
||||
*
|
||||
* @tags temporal
|
||||
* @synonyms sper
|
||||
* @example
|
||||
* note("f a [c d] e")
|
||||
* .dec(secondsPer.mul(1))
|
||||
*/
|
||||
export const secondsPer = new Pattern(function (state) {
|
||||
return [new Hap(undefined, state.span, state.span.duration.div(state.controls?._cps ?? 0.5))];
|
||||
});
|
||||
|
||||
export const sper = secondsPer;
|
||||
|
||||
/**
|
||||
* A pattern measuring the 'shortness' of events, or in other words, the duration of pattern events,
|
||||
* in events per cycle. `per` doesn't have structure itself, but takes structure, and therefore
|
||||
* event durations, from the pattern that it is combined with.
|
||||
* For example `per.struct("1 1 [1 1] 1")` would give the same as `"4 4 [8 8] 4"`.
|
||||
* See also its reciprocal, `cyclesPer`.
|
||||
* @global
|
||||
* @tags temporal
|
||||
* @synonyms perCycle
|
||||
* @type {Pattern}
|
||||
* @example
|
||||
* // Shorter events are more distorted
|
||||
* n("0 0*2 0 0*2 0 [0 0 0]@2").sound("bd")
|
||||
@@ -1153,6 +1190,7 @@ export const perCycle = per;
|
||||
* returned value increases by one. `perx.struct("1 1 [1 [1 1]] 1")` would therefore be
|
||||
* the same as `"3 3 [4 [5 5]] 3"`.
|
||||
* @tags temporal
|
||||
* @type {Pattern}
|
||||
*/
|
||||
export const perx = new Pattern(function (state) {
|
||||
const n = Fraction(1).div(state.span.duration);
|
||||
@@ -1164,6 +1202,7 @@ export const perx = new Pattern(function (state) {
|
||||
* Mainly useful in combination with other functions that reset the cycle. See also
|
||||
* `close`.
|
||||
* @tags temporal
|
||||
* @type {Pattern}
|
||||
* @example
|
||||
* sound("bd sd [- bd] sd".fast(2))
|
||||
* .lpf(open.slow(4).range(300,3000)) // close envelope over 4 cycles
|
||||
@@ -1175,9 +1214,100 @@ export const open = signal((t) => t.min(1));
|
||||
* The same as `open`, but goes from `1` to `0` over one cycle, and then
|
||||
* stays on `0` forever.
|
||||
* @tags temporal
|
||||
* @type {Pattern}
|
||||
* @example
|
||||
* sound("bd sd [- bd] sd".fast(2))
|
||||
* .lpf(close.slow(4).range(300,3000)) // close envelope over 4 cycles
|
||||
* .restart("x/4") // restart every 4 cycles
|
||||
*/
|
||||
export const close = signal((t) => Fraction(1).sub(t).max(0));
|
||||
|
||||
/**
|
||||
* Turns a pattern of numbers into a continuous signal.
|
||||
* Each number in the pattern specifies the value at its onset, and over the
|
||||
* duration of the hap, it will linearly transition to the value of the next hap.
|
||||
*
|
||||
* Alternatively, the end value of a hap can be specified explicitly using
|
||||
* array notation, in which case there will be a hard jump from the end value
|
||||
* of the hap, and the begin value of the next hap.
|
||||
*
|
||||
* Similar to other signals like `saw` or `perlin`, this signal should be sampled
|
||||
* at regular intervals to actually get the desired result.
|
||||
*
|
||||
* @name smooth
|
||||
* @tags generators
|
||||
* @example
|
||||
* n(smooth("0 8").seg(16))
|
||||
* .scale('C major')
|
||||
* @example
|
||||
* n(smooth("0:8").seg(8))
|
||||
* .scale('C major')
|
||||
* @example
|
||||
* n("<0 0 0 3 0 4 0 7>*16").scale("e2:phrygian")
|
||||
* .s("saw").lpf(100).lpq(7)
|
||||
* .lpenv(smooth("<0 1@3 2 3 5 [8 [3 5] 2]*4@4 2:8 2:8 2:8 8>"))
|
||||
*
|
||||
*/
|
||||
export const smooth = register('smooth', (pat) => {
|
||||
return new Pattern((state) => {
|
||||
const haps = pat.query(state);
|
||||
if (!haps.length) {
|
||||
return haps;
|
||||
}
|
||||
// Find the last hap in the query
|
||||
const lastHap = haps.reduce((max, hap) => (hap.whole.end.gt(max.whole.end) ? hap : max));
|
||||
|
||||
let onsetHaps = [
|
||||
...haps,
|
||||
// Because the last hap in our query also needs to transition to the next value,
|
||||
// we query to find the next hap after the current last hap.
|
||||
// If that hap is outside of the smooth margin, we simply assume that there is no next hap (e.g. a rest).
|
||||
...pat.query(state.withSpan((span) => new TimeSpan(lastHap.whole.end, lastHap.whole.end))),
|
||||
]
|
||||
// sort by onsets
|
||||
.sort((a, b) => a.whole.begin.compare(b.whole.begin))
|
||||
// Make onsets unique
|
||||
.filter((x, i, arr) => i === arr.length - 1 || x.whole.begin.ne(arr[i + 1].whole.begin));
|
||||
|
||||
const newHaps = [];
|
||||
|
||||
for (const hap of haps) {
|
||||
// Find the next onset
|
||||
const next = onsetHaps.find((onsetHap) => onsetHap.whole.begin.eq(hap.whole.end));
|
||||
|
||||
newHaps.push(__smoothHap(state.span.begin, hap, next));
|
||||
}
|
||||
return newHaps;
|
||||
});
|
||||
});
|
||||
|
||||
function __smoothHap(time, hapA, hapB) {
|
||||
let a, b, context;
|
||||
if (Array.isArray(hapA.value)) {
|
||||
// Hap with array notation determines both start and end values.
|
||||
a = hapA.value[0];
|
||||
b = hapA.value[1];
|
||||
context = hapA.context;
|
||||
} else {
|
||||
a = hapA.value;
|
||||
if (hapB === undefined) {
|
||||
// With no hapB given, we simply copy the value of hapA so the value
|
||||
// remains the same throughout the hap.
|
||||
// E.g. smooth("0 1 -") will transition from 0 to 1 and then stay at 1 until the rest.
|
||||
b = hapA.value;
|
||||
context = hapA.context;
|
||||
} else {
|
||||
// Otherwise, transition to the value at the start of hapB.
|
||||
b = Array.isArray(hapB.value) ? hapB.value[0] : hapB.value;
|
||||
context = hapA.combineContext(hapB);
|
||||
}
|
||||
}
|
||||
if (typeof a === 'string') {
|
||||
a = noteToMidi(a);
|
||||
}
|
||||
if (typeof b === 'string') {
|
||||
b = noteToMidi(b);
|
||||
}
|
||||
const progress = time.sub(hapA.whole.begin).div(hapA.whole.end.sub(hapA.whole.begin));
|
||||
return new Hap(hapA.whole, hapA.part, a + (b - a) * (progress.lt(0) ? 0 : progress), context);
|
||||
}
|
||||
|
||||
@@ -24,8 +24,9 @@ import {
|
||||
per,
|
||||
perx,
|
||||
cyclesPer,
|
||||
smooth,
|
||||
} from '../signal.mjs';
|
||||
import { fastcat, sequence, State, TimeSpan, Hap, seq } from '../index.mjs';
|
||||
import { fastcat, sequence, State, TimeSpan, Hap, seq, pure, silence } from '../index.mjs';
|
||||
|
||||
const st = (begin, end) => new State(ts(begin, end));
|
||||
const ts = (begin, end) => new TimeSpan(Fraction(begin), Fraction(end));
|
||||
@@ -125,3 +126,18 @@ describe('shuffle', () => {
|
||||
expect(seq(1, 2, 3, 4).shuffle(1).firstCycle()).toEqual(seq(1, 2, 3, 4).firstCycle());
|
||||
});
|
||||
});
|
||||
|
||||
describe('smooth', () => {
|
||||
it('"0 1" equals a tri wave', () => {
|
||||
sameFirst(smooth(fastcat(0, 1)).seg(64), tri.seg(64));
|
||||
});
|
||||
it('"0:1" equals a saw wave', () => {
|
||||
sameFirst(smooth(pure([0, 1])).seg(64), saw.seg(64));
|
||||
});
|
||||
it('supports rests', () => {
|
||||
sameFirst(smooth(fastcat(0, 1, silence)).seg(64), fastcat(saw, 1, silence).seg(64));
|
||||
});
|
||||
it('supports notes', () => {
|
||||
sameFirst(smooth(fastcat('c2', 'c3')).seg(64), fastcat(tri.range(36, 48)).seg(64));
|
||||
});
|
||||
});
|
||||
|
||||
+85
-16
@@ -212,6 +212,11 @@ export function curry(func, overload, arity = func.length) {
|
||||
return fn;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses a number. supports midi notes as strings
|
||||
* @param {number | string} numOrString
|
||||
* @returns {number}
|
||||
*/
|
||||
export function parseNumeral(numOrString) {
|
||||
const asNumber = Number(numOrString);
|
||||
if (!isNaN(asNumber)) {
|
||||
@@ -223,10 +228,20 @@ export function parseNumeral(numOrString) {
|
||||
throw new Error(`cannot parse as numeral: "${numOrString}"`);
|
||||
}
|
||||
|
||||
/**
|
||||
* map over the arguments of a function
|
||||
* @param {Function} fn
|
||||
* @param {Function} mapFn
|
||||
* @returns {Function}
|
||||
*/
|
||||
export function mapArgs(fn, mapFn) {
|
||||
return (...args) => fn(...args.map(mapFn));
|
||||
}
|
||||
|
||||
/** converts the arguments of a function into numbers
|
||||
* @param {Function} fn
|
||||
* @returns {Function}
|
||||
*/
|
||||
export function numeralArgs(fn) {
|
||||
return mapArgs(fn, parseNumeral);
|
||||
}
|
||||
@@ -328,7 +343,12 @@ export const sol2note = (n, notation = 'letters') => {
|
||||
return note + oct;
|
||||
};
|
||||
|
||||
// Remove duplicates from list
|
||||
/**
|
||||
* Remove duplicates from list
|
||||
* @template T
|
||||
* @param {T[]} a
|
||||
* @returns {T[]}
|
||||
*/
|
||||
export function uniq(a) {
|
||||
var seen = {};
|
||||
return a.filter(function (item) {
|
||||
@@ -336,14 +356,26 @@ export function uniq(a) {
|
||||
});
|
||||
}
|
||||
|
||||
// Remove duplicates from list, sorting in the process. Mutates argument!
|
||||
/**
|
||||
* Remove duplicate primitives from list, sorting in the process. Mutates argument!
|
||||
* Use {@link uniqsortr} for objects instead.
|
||||
* @template T
|
||||
* @param {T[]} a (only primitives)
|
||||
* @returns {T[]}
|
||||
*/
|
||||
export function uniqsort(a) {
|
||||
return a.sort().filter(function (item, pos, ary) {
|
||||
return !pos || item != ary[pos - 1];
|
||||
});
|
||||
}
|
||||
|
||||
// rational version
|
||||
/**
|
||||
* Remove duplicate objects from list, sorting in the process. Mutates argument!
|
||||
* Use {@link uniqsort} for primitives instead.
|
||||
* @template T
|
||||
* @param {T[]} a (only objects)
|
||||
* @returns {T[]}
|
||||
*/
|
||||
export function uniqsortr(a) {
|
||||
return a
|
||||
.sort((x, y) => x.compare(y))
|
||||
@@ -375,22 +407,47 @@ export function base64ToUnicode(base64String) {
|
||||
return decodedText;
|
||||
}
|
||||
|
||||
/**
|
||||
* converts unicode text into a URL hash
|
||||
* @ignore
|
||||
* @param {string} code
|
||||
* @returns {string}
|
||||
*/
|
||||
export function code2hash(code) {
|
||||
return encodeURIComponent(unicodeToBase64(code));
|
||||
//return '#' + encodeURIComponent(btoa(code));
|
||||
}
|
||||
|
||||
/**
|
||||
* converts the URL hash into unicode text
|
||||
* @ignore
|
||||
* @param {string} hash
|
||||
* @returns {string}
|
||||
*/
|
||||
export function hash2code(hash) {
|
||||
return base64ToUnicode(decodeURIComponent(hash));
|
||||
//return atob(decodeURIComponent(codeParam || ''));
|
||||
}
|
||||
|
||||
/**
|
||||
* maps over the entries of an object
|
||||
* @param {object} obj
|
||||
* @param {Function} fn
|
||||
* @returns {object}
|
||||
*/
|
||||
export function objectMap(obj, fn) {
|
||||
if (Array.isArray(obj)) {
|
||||
return obj.map(fn);
|
||||
}
|
||||
return Object.fromEntries(Object.entries(obj).map(([k, v], i) => [k, fn(v, k, i)]));
|
||||
}
|
||||
|
||||
/**
|
||||
* converts the cycle into seconds
|
||||
* @param {number} cycle
|
||||
* @param {number} cps
|
||||
* @returns {number} `cycle / cps`
|
||||
*/
|
||||
export function cycleToSeconds(cycle, cps) {
|
||||
return cycle / cps;
|
||||
}
|
||||
@@ -454,6 +511,10 @@ export class ClockCollator {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The total time that strudel has been running
|
||||
* @returns {number}
|
||||
*/
|
||||
export function getPerformanceTimeSeconds() {
|
||||
return performance.now() * 0.001;
|
||||
}
|
||||
@@ -474,21 +535,24 @@ export const keyAlias = new Map([
|
||||
]);
|
||||
let keyState;
|
||||
|
||||
/**
|
||||
* returns the all the keys currently being pressed or released
|
||||
* @returns {object | void}
|
||||
*/
|
||||
export function getCurrentKeyboardState() {
|
||||
if (keyState == null) {
|
||||
if (typeof window === 'undefined') {
|
||||
return;
|
||||
}
|
||||
keyState = {};
|
||||
// Listen for the keydown event to mark the key as pressed
|
||||
window.addEventListener('keydown', (event) => {
|
||||
keyState[event.key] = true; // Mark the key as pressed
|
||||
});
|
||||
if (typeof window !== 'undefined') {
|
||||
// Listen for the keydown event to mark the key as pressed
|
||||
window.addEventListener('keydown', (event) => {
|
||||
keyState[event.key] = true; // Mark the key as pressed
|
||||
});
|
||||
|
||||
// Listen for the keyup event to mark the key as released
|
||||
window.addEventListener('keyup', (event) => {
|
||||
keyState[event.key] = false; // Mark the key as released
|
||||
});
|
||||
// Listen for the keyup event to mark the key as released
|
||||
window.addEventListener('keyup', (event) => {
|
||||
keyState[event.key] = false; // Mark the key as released
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return { ...keyState }; // Return a shallow copy of the key state object
|
||||
@@ -514,8 +578,13 @@ export function getCurrentKeyboardState() {
|
||||
// return lcm((x * y) / gcd(x, y), ...z);
|
||||
// };
|
||||
|
||||
// Takes values -- typically derived from events, i.e. `hap`s -- and renders them
|
||||
// into a readable format
|
||||
/**
|
||||
* Takes values -- typically derived from events, i.e. `hap`s -- and renders them
|
||||
* into a readable format
|
||||
* @param {*} value
|
||||
* @param {boolean} [compact=false] creates a compacter version
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function stringifyValues(value, compact = false) {
|
||||
return typeof value === 'object'
|
||||
? compact
|
||||
|
||||
@@ -7,6 +7,12 @@ This program is free software: you can redistribute it and/or modify it under th
|
||||
import { curry } from './util.mjs';
|
||||
import { logger } from './logger.mjs';
|
||||
|
||||
/** combine two objects into one
|
||||
* @param {object} a
|
||||
* @param {object} b
|
||||
* @param {Function} func
|
||||
* @returns {object}
|
||||
*/
|
||||
export function unionWithObj(a, b, func) {
|
||||
if (b?.value !== undefined && Object.keys(b).length === 1) {
|
||||
// https://codeberg.org/uzu/strudel/issues/1026
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/repl",
|
||||
"version": "1.3.0",
|
||||
"version": "1.4.0",
|
||||
"description": "Strudel REPL as a Web Component",
|
||||
"module": "index.mjs",
|
||||
"publishConfig": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/sampler",
|
||||
"version": "0.2.4",
|
||||
"version": "0.3.0",
|
||||
"description": "",
|
||||
"keywords": [
|
||||
"tidalcycles",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/serial",
|
||||
"version": "1.2.6",
|
||||
"version": "1.3.0",
|
||||
"description": "Webserial API for strudel",
|
||||
"main": "serial.mjs",
|
||||
"type": "module",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/soundfonts",
|
||||
"version": "1.3.0",
|
||||
"version": "1.4.0",
|
||||
"description": "Soundsfont support for strudel",
|
||||
"main": "index.mjs",
|
||||
"publishConfig": {
|
||||
|
||||
@@ -442,7 +442,8 @@ export function applyFM(param, value, begin) {
|
||||
} else {
|
||||
control = `fmi${i}${j}`;
|
||||
}
|
||||
const amt = value[control];
|
||||
// If we can't find fm3/fm2/fm1/etc, fall back to fm32/fm21/fm10/etc
|
||||
const amt = value[control] ?? (i === j + 1 ? value[`fmi${i}${j}`] : undefined);
|
||||
if (!amt) continue;
|
||||
let io = [];
|
||||
for (let [isMod, idx] of [
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "superdough",
|
||||
"version": "1.3.0",
|
||||
"version": "1.4.0",
|
||||
"description": "simple web audio synth and sampler intended for live coding. inspired by superdirt and webdirt.",
|
||||
"main": "index.mjs",
|
||||
"type": "module",
|
||||
@@ -36,8 +36,6 @@
|
||||
"vite-plugin-bundle-audioworklet": "workspace:*"
|
||||
},
|
||||
"dependencies": {
|
||||
"@kabelsalat/lib": "^0.4.1",
|
||||
"@kabelsalat/web": "^0.4.1",
|
||||
"nanostores": "^0.11.3"
|
||||
},
|
||||
"engines": {
|
||||
|
||||
@@ -35,7 +35,7 @@ function humanFileSize(bytes, si) {
|
||||
* Has optional param `n` (for instance, the `2` in `s("casio:2")`)
|
||||
*
|
||||
* Note: `must` be called with await, otherwise you'll get a pending Promise object.
|
||||
*
|
||||
* @global
|
||||
* @name getDuration
|
||||
* @synonyms getDur
|
||||
* @tags samples
|
||||
@@ -260,6 +260,7 @@ export async function fetchSampleMap(url) {
|
||||
/**
|
||||
* Loads a collection of samples to use with `s`
|
||||
* @tags samples
|
||||
* @global
|
||||
* @example
|
||||
* samples('github:tidalcycles/dirt-samples');
|
||||
* s("[bd ~]*2, [~ hh]*2, ~ sd")
|
||||
@@ -288,12 +289,14 @@ export const samples = async (sampleMap, baseUrl = sampleMap._base || '', option
|
||||
};
|
||||
|
||||
const cutGroups = [];
|
||||
const scutGroups = [];
|
||||
|
||||
export async function onTriggerSample(t, value, onended, bank, resolveUrl) {
|
||||
let {
|
||||
s,
|
||||
nudge = 0, // TODO: is this in seconds?
|
||||
cut,
|
||||
scut,
|
||||
loop,
|
||||
clip = undefined, // if set, samples will be cut off when the hap ends
|
||||
n = 0,
|
||||
@@ -372,6 +375,23 @@ export async function onTriggerSample(t, value, onended, bank, resolveUrl) {
|
||||
cutGroups[cut] = handle;
|
||||
}
|
||||
|
||||
// scut groups
|
||||
if (scut !== undefined) {
|
||||
if (scutGroups[scut] === undefined) {
|
||||
scutGroups[scut] = { t, handles: [] };
|
||||
}
|
||||
const prevGroup = scutGroups[scut];
|
||||
if (prevGroup.t !== t) {
|
||||
for (const prev of prevGroup.handles) {
|
||||
prev.node.gain.setValueAtTime(1, time);
|
||||
prev.node.gain.linearRampToValueAtTime(0, time + 0.01);
|
||||
}
|
||||
|
||||
scutGroups[scut] = { t, handles: [] };
|
||||
}
|
||||
scutGroups[scut].handles.push(handle);
|
||||
}
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ import {
|
||||
gainNode,
|
||||
getCompressor,
|
||||
getDistortion,
|
||||
getFrequencyFromValue,
|
||||
getLfo,
|
||||
getWorklet,
|
||||
releaseAudioNode,
|
||||
@@ -40,6 +39,7 @@ export let maxPolyphony = DEFAULT_MAX_POLYPHONY;
|
||||
* start to die out in first-in-first-out order once the max polyphony has been hit
|
||||
*
|
||||
* @name setMaxPolyphony
|
||||
* @global
|
||||
* @tags superdough
|
||||
* @param {number} polyphony Max polyphony. Defaults to 128
|
||||
* @example
|
||||
@@ -63,6 +63,11 @@ export function registerSound(key, onTrigger, data = {}) {
|
||||
soundMap.setKey(key, { onTrigger, data });
|
||||
}
|
||||
|
||||
const chainEffects = {};
|
||||
export function registerChainEffect(name, effect) {
|
||||
chainEffects[name] = effect;
|
||||
}
|
||||
|
||||
let gainCurveFunc = (val) => val;
|
||||
|
||||
export function applyGainCurve(val) {
|
||||
@@ -72,7 +77,7 @@ export function applyGainCurve(val) {
|
||||
/**
|
||||
* Apply a function to all gains provided in patterns. Can be used to rescale gain to be
|
||||
* quadratic, exponential, etc. rather than linear
|
||||
*
|
||||
* @global
|
||||
* @name setGainCurve
|
||||
* @tags amplitude, superdough
|
||||
* @param {Function} newGainCurveFunc function to apply to all gain values
|
||||
@@ -126,9 +131,10 @@ async function aliasBankPath(path) {
|
||||
|
||||
/**
|
||||
* Register an alias for a bank of sounds.
|
||||
* @global
|
||||
* @param {...any} args either one or two arguments. first argument is bank to alias. Second argument is alias to use for the bank.
|
||||
* Optionally accepts a single argument map of bank aliases.
|
||||
* Optionally accepts a single argument string of a path to a JSON file containing bank aliases.
|
||||
* @param {...any} args either one or two arguments. first argument is bank to alias. Second argument is alias to use for the bank.
|
||||
* @returns {void}
|
||||
* @tags samples
|
||||
*/
|
||||
@@ -149,6 +155,7 @@ export async function aliasBank(...args) {
|
||||
|
||||
/**
|
||||
* Register an alias for a sound.
|
||||
* @global
|
||||
* @tags samples
|
||||
* @param {string} original - The original sound name
|
||||
* @param {string} alias - The alias to use for the sound
|
||||
@@ -259,14 +266,6 @@ export function loadWorklets() {
|
||||
return workletsLoading;
|
||||
}
|
||||
|
||||
let kabel;
|
||||
async function initKabelsalat() {
|
||||
const { SalatRepl } = await import('@kabelsalat/web');
|
||||
logger('[kabelsalat] ready');
|
||||
kabel = new SalatRepl({ localScope: true });
|
||||
return kabel;
|
||||
}
|
||||
|
||||
// this function should be called on first user interaction (to avoid console warning)
|
||||
export async function initAudio(options = {}) {
|
||||
const {
|
||||
@@ -313,7 +312,6 @@ export async function initAudio(options = {}) {
|
||||
} catch (err) {
|
||||
console.warn('could not load AudioWorklet effects', err);
|
||||
}
|
||||
await initKabelsalat();
|
||||
logger('[superdough] ready');
|
||||
}
|
||||
let audioReady;
|
||||
@@ -449,14 +447,6 @@ class Chain {
|
||||
}
|
||||
}
|
||||
|
||||
const compileKabel = (code) => {
|
||||
if (!kabel) {
|
||||
throw new Error('kabelsalat not loaded');
|
||||
}
|
||||
const node = kabel.evaluate(code);
|
||||
return node.compile({ log: false });
|
||||
};
|
||||
|
||||
export const superdough = async (value, t, hapDuration, cps = 0.5, cycle = 0.5) => {
|
||||
// mapping from main FX and numbered FX chains to nodes
|
||||
const nodes = { main: {} };
|
||||
@@ -632,17 +622,21 @@ export const superdough = async (value, t, hapDuration, cps = 0.5, cycle = 0.5)
|
||||
gain *= velocity; // velocity currently only multiplies with gain. it might do other things in the future
|
||||
delaytime = delaytime ?? cycleToSeconds(delaysync, cps);
|
||||
|
||||
// Kabelsalat
|
||||
if (fx.workletSrc !== undefined) {
|
||||
const workletNode = getWorklet(ac, 'generic-processor', {}, { outputChannelCount: [2] });
|
||||
chain.connect(workletNode);
|
||||
const workletSrc = fx.workletSrc
|
||||
.replace(/\bpat\[(\d+)\]/g, (_, i) => fx.workletInputs[i])
|
||||
.replaceAll('sFreq', getFrequencyFromValue(value))
|
||||
.replaceAll('sGate', `cc('strudel-gate-${chainID}')`);
|
||||
/* global compileKabel */
|
||||
const { src, ugens, registers } = compileKabel(workletSrc);
|
||||
workletNode.port.postMessage({ src, schema: { ugens, registers }, start: t, gateEnd: end, end: endWithRelease });
|
||||
// custom chain effect sink (used for kabelsalat)
|
||||
for (let key in chainEffects) {
|
||||
const effect = chainEffects[key];
|
||||
if (fx[key] !== undefined) {
|
||||
const node = effect({
|
||||
audioContext: ac,
|
||||
fx,
|
||||
chainID,
|
||||
value,
|
||||
start: t,
|
||||
gateEnd: end,
|
||||
releaseEnd: endWithRelease,
|
||||
});
|
||||
node && chain.connect(node);
|
||||
}
|
||||
}
|
||||
|
||||
if (fx.stretch !== undefined) {
|
||||
|
||||
@@ -404,6 +404,89 @@ export function registerSynthSounds() {
|
||||
{ prebake: true, type: 'input' },
|
||||
);
|
||||
|
||||
registerSound(
|
||||
'goabd',
|
||||
(t, value, onended) => {
|
||||
const {
|
||||
duration,
|
||||
attack = 0,
|
||||
hold = 0.2,
|
||||
decay = 0.25,
|
||||
sustain = 0,
|
||||
release = 0,
|
||||
pdecay = 1,
|
||||
penv = 84,
|
||||
pcurve = 0.85,
|
||||
clip,
|
||||
} = value;
|
||||
const ctx = getAudioContext();
|
||||
const soundGain = 0.5;
|
||||
const mixGain = 1;
|
||||
|
||||
const freq = getFrequencyFromValue(value, 24);
|
||||
const f = getWorklet(ctx, 'goabd-freq-env-processor', {
|
||||
begin: t,
|
||||
end: t + pdecay,
|
||||
freq0: freq * Math.pow(2, penv / 12),
|
||||
freq1: freq,
|
||||
pcurve: pcurve,
|
||||
});
|
||||
const o = ctx.createOscillator();
|
||||
o.type = 'sine';
|
||||
o.frequency.value = 0;
|
||||
f.connect(o.frequency);
|
||||
const g = gainNode(soundGain);
|
||||
let soundDuration = attack + hold + decay;
|
||||
if (sustain > 0) {
|
||||
soundDuration = Math.max(soundDuration, duration) + release;
|
||||
}
|
||||
if (attack > 0) {
|
||||
g.gain.setValueAtTime(0.0001, t);
|
||||
g.gain.exponentialRampToValueAtTime(soundGain, t + attack);
|
||||
} else {
|
||||
g.gain.setValueAtTime(soundGain, t);
|
||||
}
|
||||
if (hold > 0) {
|
||||
g.gain.setValueAtTime(soundGain, t + attack + hold);
|
||||
}
|
||||
g.gain.exponentialRampToValueAtTime(Math.max(0.0001, sustain), t + soundDuration - release);
|
||||
g.gain.exponentialRampToValueAtTime(0.0001, t + soundDuration);
|
||||
o.start(t);
|
||||
|
||||
const mix = gainNode(mixGain);
|
||||
|
||||
onceEnded(o, () => {
|
||||
releaseAudioNode(f);
|
||||
releaseAudioNode(o);
|
||||
releaseAudioNode(g);
|
||||
releaseAudioNode(mix);
|
||||
onended();
|
||||
});
|
||||
|
||||
const node = o.connect(g).connect(mix);
|
||||
|
||||
// prevent clicking
|
||||
let mixDuration = soundDuration;
|
||||
if (clip != null) {
|
||||
mixDuration = Math.min(clip * duration, mixDuration);
|
||||
}
|
||||
const mixEnd = t + mixDuration;
|
||||
mix.gain.setValueAtTime(mixGain, mixEnd - 0.01);
|
||||
mix.gain.linearRampToValueAtTime(0, mixEnd);
|
||||
|
||||
o.stop(mixEnd);
|
||||
|
||||
return {
|
||||
node,
|
||||
nodes: { source: [o] },
|
||||
stop: (endTime) => {
|
||||
o.stop(endTime);
|
||||
},
|
||||
};
|
||||
},
|
||||
{ type: 'synth', prebake: true },
|
||||
);
|
||||
|
||||
[...noises].forEach((s) => {
|
||||
registerSound(
|
||||
s,
|
||||
|
||||
@@ -111,6 +111,7 @@ export function getCommonSampleInfo(hapValue, bank) {
|
||||
}
|
||||
|
||||
/** Selects entries from `source` and renames them via `map`
|
||||
* @global
|
||||
* @tags internals
|
||||
* @param {object} source
|
||||
* @param {*} map
|
||||
|
||||
@@ -184,7 +184,7 @@ export function registerWaveTable(key, tables, params) {
|
||||
|
||||
/**
|
||||
* Loads a collection of wavetables to use with `s`
|
||||
*
|
||||
* @global
|
||||
* @param {string} url
|
||||
* @param {*} frameLen
|
||||
* @param {string} json
|
||||
|
||||
@@ -5,9 +5,6 @@
|
||||
import OLAProcessor from './ola-processor';
|
||||
import FFT from './fft.js';
|
||||
import { getDistortionAlgorithm } from './helpers.mjs';
|
||||
import * as ugens from '@kabelsalat/lib/src/ugens.js';
|
||||
|
||||
const UGENS = new Map(Object.entries(ugens));
|
||||
|
||||
const blockSize = 128;
|
||||
const PI = Math.PI;
|
||||
@@ -853,6 +850,8 @@ registerProcessor('pulse-oscillator', PulseOscillatorProcessor);
|
||||
|
||||
/** BYTE BEATS
|
||||
* @tags internals
|
||||
* @global
|
||||
* @typedef Chyx
|
||||
*/
|
||||
const chyx = {
|
||||
/*bit*/ bitC: function (x, y, z) {
|
||||
@@ -986,6 +985,49 @@ class ByteBeatProcessor extends AudioWorkletProcessor {
|
||||
|
||||
registerProcessor('byte-beat-processor', ByteBeatProcessor);
|
||||
|
||||
class GoaBdFreqEnvProcessor extends AudioWorkletProcessor {
|
||||
static get parameterDescriptors() {
|
||||
return [
|
||||
{ name: 'begin', defaultValue: 0 },
|
||||
{ name: 'end', defaultValue: 0 },
|
||||
{ name: 'freq0', defaultValue: 55 * 64 },
|
||||
{ name: 'freq1', defaultValue: 55 },
|
||||
{ name: 'pcurve', defaultValue: 0.5 },
|
||||
];
|
||||
}
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.p0 = 0.006699687;
|
||||
this.p1 = 0.00001884606;
|
||||
this.time = 0;
|
||||
}
|
||||
|
||||
process(_inputs, outputs, params) {
|
||||
const begin = params['begin'][0];
|
||||
const end = params['end'][0];
|
||||
if (currentTime >= end) {
|
||||
return false;
|
||||
}
|
||||
if (currentTime <= begin) {
|
||||
return true;
|
||||
}
|
||||
const out = outputs[0][0];
|
||||
const freq0 = params['freq0'][0];
|
||||
const freq1 = params['freq1'][0];
|
||||
const pcurve = params['pcurve'][0];
|
||||
const p = (1 - pcurve) * this.p0 + pcurve * this.p1;
|
||||
const dt = (INVSR * 1) / (end - begin);
|
||||
for (let i = 0; i < out.length; i++) {
|
||||
out[i] = freq1 + (freq0 - freq1) / (1 + this.time / p);
|
||||
this.time += dt;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
registerProcessor('goabd-freq-env-processor', GoaBdFreqEnvProcessor);
|
||||
|
||||
class EnvelopeProcessor extends AudioWorkletProcessor {
|
||||
static get parameterDescriptors() {
|
||||
return [
|
||||
@@ -1494,81 +1536,3 @@ class TransientProcessor extends AudioWorkletProcessor {
|
||||
}
|
||||
|
||||
registerProcessor('transient-processor', TransientProcessor);
|
||||
|
||||
class GenericProcessor extends AudioWorkletProcessor {
|
||||
constructor() {
|
||||
super();
|
||||
this.playPos = 0;
|
||||
const channels = 16;
|
||||
this.outputs = new Array(channels).fill(0);
|
||||
this.sources = new Array(channels).fill(0);
|
||||
this.gateEnded = false;
|
||||
this.started = false;
|
||||
this.port.onmessage = (event) => {
|
||||
let {
|
||||
src,
|
||||
schema: { ugens, registers },
|
||||
start,
|
||||
gateEnd,
|
||||
end,
|
||||
} = event.data;
|
||||
this.start = start;
|
||||
this.gateEnd = gateEnd;
|
||||
this.end = end;
|
||||
this.registers = new Array(registers).fill(0);
|
||||
this.src = `o.fill(0); // reset outputs\n${src}`;
|
||||
this.nodes = [];
|
||||
for (let i = 0; i < ugens.length; i++) {
|
||||
const ugen = ugens[i];
|
||||
const nodeClass = UGENS.get(ugen.type);
|
||||
const node = new nodeClass(i, ugen, sampleRate);
|
||||
if (node.type === 'cc' && ugen.inputs?.[0]?.includes('strudel-gate')) {
|
||||
node.setValue(1);
|
||||
this.gateNode = node;
|
||||
}
|
||||
this.nodes[i] = node;
|
||||
}
|
||||
this.genSample = new Function(
|
||||
'time',
|
||||
'nodes',
|
||||
'input',
|
||||
'r', // registers
|
||||
'o', // outputs
|
||||
's', // sources
|
||||
this.src,
|
||||
);
|
||||
};
|
||||
}
|
||||
process(inputs, outputs) {
|
||||
const input = inputs[0]?.[0];
|
||||
if (currentTime >= this.end) {
|
||||
return false;
|
||||
} else if (this.genSample === undefined || currentTime < this.start) {
|
||||
// pending
|
||||
return true;
|
||||
}
|
||||
this.started = true;
|
||||
if (!this.gateEnded && currentTime > this.gateEnd) {
|
||||
this.gateNode?.setValue(0);
|
||||
this.gateEnded = true;
|
||||
}
|
||||
const output = outputs[0];
|
||||
const outL = output[0];
|
||||
const outR = output[1];
|
||||
for (let n = 0; n < blockSize; n++) {
|
||||
this.genSample(this.playPos, this.nodes, input ? input[n] : 0, this.registers, this.outputs, this.sources);
|
||||
const left = this.outputs[0];
|
||||
const right = this.outputs[1];
|
||||
// Spread to stereo if possible; else mixdown to mono
|
||||
if (outR) {
|
||||
outL[n] = left;
|
||||
outR[n] = right;
|
||||
} else {
|
||||
outL[n] = 0.5 * (left + right);
|
||||
}
|
||||
this.playPos += 1 / sampleRate;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
registerProcessor('generic-processor', GenericProcessor);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/tonal",
|
||||
"version": "1.2.6",
|
||||
"version": "1.3.0",
|
||||
"description": "Tonal functions for strudel",
|
||||
"main": "index.mjs",
|
||||
"publishConfig": {
|
||||
|
||||
@@ -196,6 +196,7 @@ export const rootNotes = register('rootNotes', function (octave, pat) {
|
||||
* @name voicing
|
||||
* @tags tonal
|
||||
* @returns {Pattern}
|
||||
* @memberof Pattern.prototype
|
||||
* @example
|
||||
* n("0 1 2 3").chord("<C Am F G>").voicing()
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/transpiler",
|
||||
"version": "1.2.6",
|
||||
"version": "1.3.0",
|
||||
"description": "Transpiler for strudel user code. Converts syntactically correct but semantically meaningless JS into evaluatable strudel code.",
|
||||
"main": "index.mjs",
|
||||
"type": "module",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/web",
|
||||
"version": "1.3.0",
|
||||
"version": "1.4.0",
|
||||
"description": "Easy to setup, opiniated bundle of Strudel for the browser.",
|
||||
"module": "web.mjs",
|
||||
"publishConfig": {
|
||||
|
||||
+37
-3
@@ -12,7 +12,10 @@ import { initAudioOnFirstClick, registerSynthSounds, webaudioRepl } from '@strud
|
||||
import { evaluate as _evaluate, transpiler } from '@strudel/transpiler';
|
||||
import { miniAllStrings } from '@strudel/mini';
|
||||
|
||||
// init logic
|
||||
/**
|
||||
* init logic
|
||||
* @global
|
||||
*/
|
||||
export async function defaultPrebake() {
|
||||
const loadModules = evalScope(
|
||||
evalScope,
|
||||
@@ -30,6 +33,28 @@ export async function defaultPrebake() {
|
||||
let initDone;
|
||||
|
||||
let repl;
|
||||
/** initiates strudel
|
||||
* @global
|
||||
* @param {object} options
|
||||
* @param {*} options.onSchedule
|
||||
* @param {*} options.defaultOutput
|
||||
* @param {*} options.onEvalError
|
||||
* @param {*} options.beforeEval
|
||||
* @param {*} options.beforeStart
|
||||
* @param {*} options.afterEval
|
||||
* @param {*} options.getTime
|
||||
* @param {*} options.transpiler
|
||||
* @param {*} options.onToggle
|
||||
* @param {*} options.editPattern
|
||||
* @param {*} options.onUpdateState
|
||||
* @param {*} options.sync = false
|
||||
* @param {*} options.setInterval
|
||||
* @param {*} options.clearInterval
|
||||
* @param {*} options.id
|
||||
* @param {*} options.mondo = false
|
||||
* @param {*} options.prebake
|
||||
* @returns {object}
|
||||
*/
|
||||
export function initStrudel(options = {}) {
|
||||
initAudioOnFirstClick();
|
||||
options.miniAllStrings !== false && miniAllStrings();
|
||||
@@ -58,12 +83,21 @@ Pattern.prototype.play = function () {
|
||||
return this;
|
||||
};
|
||||
|
||||
// stop playback
|
||||
/**
|
||||
* stop playback
|
||||
* @global
|
||||
*/
|
||||
export function hush() {
|
||||
repl.stop();
|
||||
}
|
||||
|
||||
// evaluate and play the given code using the transpiler
|
||||
/**
|
||||
* evaluate and play the given code using the transpiler
|
||||
* @global
|
||||
* @param {*} code
|
||||
* @param {*} autoplay
|
||||
* @returns {*}
|
||||
*/
|
||||
export async function evaluate(code, autoplay = true) {
|
||||
return repl.evaluate(code, autoplay);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/webaudio",
|
||||
"version": "1.3.0",
|
||||
"version": "1.4.0",
|
||||
"description": "Web Audio helpers for Strudel",
|
||||
"main": "index.mjs",
|
||||
"type": "module",
|
||||
@@ -35,10 +35,12 @@
|
||||
"dependencies": {
|
||||
"@strudel/core": "workspace:*",
|
||||
"@strudel/draw": "workspace:*",
|
||||
"@strudel/pattern": "workspace:*",
|
||||
"superdough": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"vite": "^6.0.11"
|
||||
"vite": "^6.0.11",
|
||||
"vitest": "^3.0.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
|
||||
@@ -99,6 +99,7 @@ function clearScreen(smear = 0, smearRGB = `0,0,0`, ctx = getDrawContext()) {
|
||||
* Renders an oscilloscope for the frequency domain of the audio signal.
|
||||
* @name fscope
|
||||
* @tags visualization
|
||||
* @memberof Pattern.prototype
|
||||
* @param {object} config object that may have the following arguments
|
||||
* @param {string} config.color line color as hex or color name. defaults to white.
|
||||
* @param {number} config.scale scales the y-axis. Defaults to 0.25
|
||||
@@ -124,6 +125,7 @@ Pattern.prototype.fscope = function (config = {}) {
|
||||
/**
|
||||
* Renders an oscilloscope for the time domain of the audio signal.
|
||||
* @name scope
|
||||
* @memberof Pattern.prototype
|
||||
* @synonyms tscope
|
||||
* @tags visualization
|
||||
* @param {object} config optional config with options:
|
||||
|
||||
@@ -5,6 +5,7 @@ import { analysers, getAnalyzerData } from 'superdough';
|
||||
/**
|
||||
* Renders a spectrum analyzer for the incoming audio signal.
|
||||
* @name spectrum
|
||||
* @memberof Pattern.prototype
|
||||
* @tags visualization
|
||||
* @param {object} config optional config with options:
|
||||
* @param {number} [thickness=3] line thickness in px (default 3)
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
import { calculateContextLength, getExportCheckpoints } from '../util.mjs';
|
||||
import { cps } from '@strudel/core';
|
||||
import { slowcat, silence, fastcat } from '@strudel/pattern';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
describe('getCheckpoints()', () => {
|
||||
it('Should return the start and end checkpoints for an empty pattern', () => {
|
||||
expect(getExportCheckpoints(silence, 0.5, 1, 10)).toStrictEqual([
|
||||
{ cycle: 1, cps: 0.5 },
|
||||
{ cycle: 10, cps: 0.5 },
|
||||
]);
|
||||
});
|
||||
it('Should break up checkpoints for an empty pattern into chunks when a max duration is specified', () => {
|
||||
expect(getExportCheckpoints(silence, 0.5, 1, 10, 2)).toStrictEqual([
|
||||
{ cycle: 1, cps: 0.5 },
|
||||
{ cycle: 3, cps: 0.5 },
|
||||
{ cycle: 5, cps: 0.5 },
|
||||
{ cycle: 7, cps: 0.5 },
|
||||
{ cycle: 9, cps: 0.5 },
|
||||
{ cycle: 10, cps: 0.5 },
|
||||
]);
|
||||
});
|
||||
it('Should create checkpoints for cps changes', () => {
|
||||
expect(getExportCheckpoints(cps(fastcat(1, 2, 3, 4)), 0.5, 0, 2)).toStrictEqual([
|
||||
{ cycle: 0, cps: 1 },
|
||||
{ cycle: 0.25, cps: 2 },
|
||||
{ cycle: 0.5, cps: 3 },
|
||||
{ cycle: 0.75, cps: 4 },
|
||||
{ cycle: 1, cps: 1 },
|
||||
{ cycle: 1.25, cps: 2 },
|
||||
{ cycle: 1.5, cps: 3 },
|
||||
{ cycle: 1.75, cps: 4 },
|
||||
{ cycle: 2, cps: 0.5 },
|
||||
]);
|
||||
});
|
||||
it('Should create checkpoints for cps changes and split into chunks when a max duration is specified', () => {
|
||||
expect(getExportCheckpoints(cps(slowcat(1, 2, 3, 4)), 0.5, 1, 5, 0.75)).toStrictEqual([
|
||||
{ cycle: 1, cps: 2 },
|
||||
{ cycle: 1.75, cps: 2 },
|
||||
{ cycle: 2, cps: 3 },
|
||||
{ cycle: 2.75, cps: 3 },
|
||||
{ cycle: 3, cps: 4 },
|
||||
{ cycle: 3.75, cps: 4 },
|
||||
{ cycle: 4, cps: 1 },
|
||||
{ cycle: 4.75, cps: 1 },
|
||||
{ cycle: 5, cps: 0.5 },
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('calculateContextLength()', () => {
|
||||
it('Should work when there are only the start and end checkpoints', () => {
|
||||
expect(
|
||||
calculateContextLength(
|
||||
[
|
||||
{ cycle: 1, cps: 0.5 },
|
||||
{ cycle: 10, cps: 0.5 },
|
||||
],
|
||||
1000,
|
||||
),
|
||||
).toBe(18000);
|
||||
});
|
||||
it('Should calculate the context length correctly', () => {
|
||||
expect(
|
||||
calculateContextLength(
|
||||
[
|
||||
{ cycle: 1, cps: 1 },
|
||||
{ cycle: 2, cps: 0.5 },
|
||||
{ cycle: 3, cps: 2 },
|
||||
{ cycle: 5, cps: 1 },
|
||||
{ cycle: 6, cps: 0.5 },
|
||||
],
|
||||
1000,
|
||||
),
|
||||
).toBe(5000);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,107 @@
|
||||
/**
|
||||
* @typedef {object} ExportCheckpoint
|
||||
* @property {number} cycle The point in time that the cps changes happens
|
||||
* @property {number} cps The new target cps (cycles per second)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Queries the pattern from `begin` to `end` and returns a list of checkpoints
|
||||
* that signify the places in the pattern where the `cps` changes.
|
||||
* If `maxCheckpointDuration` is specified, additional checkpoints will be
|
||||
* inserted if the time difference between two checkpoints is longer than the
|
||||
* specified value.
|
||||
*
|
||||
* The returned list of checkpoints will always have at least 2 checkpoints,
|
||||
* signifying the start and end of the query.
|
||||
*
|
||||
* @param {Pattern} pattern The pattern to query
|
||||
* @param {number} cps The starting cps
|
||||
* @param {number} begin The start of the query
|
||||
* @param {number} end The end of the query
|
||||
* @param {number} maxCheckpointDuration The maximum time difference between checkpoints
|
||||
* @returns {ExportCheckpoint[]} A list of at least 2 checkpoints
|
||||
*/
|
||||
export function getExportCheckpoints(pattern, cps, begin, end, maxCheckpointDuration = Number.MAX_VALUE) {
|
||||
const cpsHaps = pattern
|
||||
.queryArc(0, end, { _cps: cps })
|
||||
.filter((hap) => hap.value.cps !== undefined)
|
||||
.sort((a, b) => {
|
||||
const aBegin = a.whole.begin.valueOf();
|
||||
const bBegin = b.whole.begin.valueOf();
|
||||
if (aBegin === bBegin) {
|
||||
// With multiple simultaneous haps that set the cps,
|
||||
// there must be an order for determinism.
|
||||
return a.value.cps - b.value.cps;
|
||||
}
|
||||
return aBegin - bBegin;
|
||||
})
|
||||
.map((hap) => {
|
||||
return {
|
||||
cycle: hap.whole.begin.valueOf(),
|
||||
cps: hap.value.cps,
|
||||
};
|
||||
});
|
||||
|
||||
// Insert starting checkpoint with the default cps
|
||||
cpsHaps.splice(0, 0, { cycle: 0, cps: cps });
|
||||
// Insert an ending checkpoint after the target end-time with the default cps
|
||||
cpsHaps.push({ cycle: end + 1, cps: cps });
|
||||
|
||||
const checkpoints = [];
|
||||
|
||||
for (var i = 0; i < cpsHaps.length - 1; i++) {
|
||||
const checkpointA = cpsHaps[i];
|
||||
const checkpointB = cpsHaps[i + 1];
|
||||
if (checkpointA.cycle === checkpointB.cycle) {
|
||||
// With multiple checkpoints at the same cycle, we only use the last one.
|
||||
continue;
|
||||
}
|
||||
if (checkpointB.cycle < begin) {
|
||||
// Not at the start yet
|
||||
continue;
|
||||
}
|
||||
var newCheckpoint;
|
||||
if (checkpointA.cycle <= begin && begin < checkpointB.cycle) {
|
||||
// Found the first checkpoint
|
||||
newCheckpoint = { cycle: begin, cps: checkpointA.cps };
|
||||
checkpoints.push(newCheckpoint);
|
||||
} else if (begin <= checkpointA.cycle) {
|
||||
newCheckpoint = { cycle: checkpointA.cycle, cps: checkpointA.cps };
|
||||
checkpoints.push(newCheckpoint);
|
||||
}
|
||||
if (newCheckpoint !== undefined) {
|
||||
while (maxCheckpointDuration < Math.min(checkpointB.cycle, end) - newCheckpoint.cycle) {
|
||||
newCheckpoint = { cycle: newCheckpoint.cycle + maxCheckpointDuration, cps: newCheckpoint.cps };
|
||||
checkpoints.push(newCheckpoint);
|
||||
}
|
||||
}
|
||||
if (end <= checkpointB.cycle) {
|
||||
checkpoints.push({ cycle: end, cps: checkpointB.cps });
|
||||
}
|
||||
}
|
||||
|
||||
return checkpoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the context length in number of samples based on a list of
|
||||
* checkpoints and the samplerate per second.
|
||||
*
|
||||
* @param {ExportCheckpoint[]} checkpoints
|
||||
* @param {number} sampleRate
|
||||
* @returns {number}
|
||||
*/
|
||||
export function calculateContextLength(checkpoints, sampleRate) {
|
||||
console.assert(checkpoints.length >= 2, 'checkpoints must contain at least two entries');
|
||||
|
||||
var total = 0;
|
||||
|
||||
for (let i = 0; i < checkpoints.length - 1; i++) {
|
||||
const changeA = checkpoints[i];
|
||||
const changeB = checkpoints[i + 1];
|
||||
const duration = changeB.cycle - changeA.cycle;
|
||||
total += duration / changeA.cps;
|
||||
}
|
||||
|
||||
return total * sampleRate;
|
||||
}
|
||||
+104
-47
@@ -10,7 +10,6 @@ import {
|
||||
getAudioContext,
|
||||
setLogger,
|
||||
rawdspOutput,
|
||||
registerWorklet,
|
||||
setAudioContext,
|
||||
initAudio,
|
||||
setSuperdoughAudioController,
|
||||
@@ -18,9 +17,14 @@ import {
|
||||
errorLogger,
|
||||
} from 'superdough';
|
||||
import { SuperdoughAudioController } from 'superdough/superdoughoutput.mjs';
|
||||
import { getExportCheckpoints, calculateContextLength } from './util.mjs';
|
||||
|
||||
const { Pattern, logger, repl } = strudel;
|
||||
|
||||
/**
|
||||
* @import { ExportCheckpoint } from '@strudel/core'
|
||||
*/
|
||||
|
||||
setLogger(logger);
|
||||
|
||||
const hap2value = (hap) => {
|
||||
@@ -46,7 +50,13 @@ export async function renderPatternAudio(
|
||||
) {
|
||||
let audioContext = getAudioContext();
|
||||
await audioContext.close();
|
||||
audioContext = new OfflineAudioContext(2, ((end - begin) / cps) * sampleRate, sampleRate);
|
||||
|
||||
const chunkSize = 1;
|
||||
|
||||
const checkpoints = getExportCheckpoints(pattern, cps, begin, end, chunkSize);
|
||||
const contextLength = calculateContextLength(checkpoints, sampleRate);
|
||||
|
||||
audioContext = new OfflineAudioContext(2, contextLength, sampleRate);
|
||||
setAudioContext(audioContext);
|
||||
setSuperdoughAudioController(new SuperdoughAudioController(audioContext));
|
||||
await initAudio({
|
||||
@@ -58,8 +68,8 @@ export async function renderPatternAudio(
|
||||
// so no chunked rendering. Bad performance, but at least it works.
|
||||
return (
|
||||
audioContext.suspend === undefined
|
||||
? renderPatternAudioWhole(audioContext, pattern, cps, begin, end)
|
||||
: renderPatternAudioInChunks(audioContext, pattern, cps, begin, end, 1)
|
||||
? renderPatternAudioWhole(audioContext, pattern, checkpoints)
|
||||
: renderPatternAudioInChunks(audioContext, pattern, checkpoints)
|
||||
)
|
||||
.then((renderedBuffer) => {
|
||||
const wavBuffer = audioBufferToWav(renderedBuffer);
|
||||
@@ -81,52 +91,89 @@ export async function renderPatternAudio(
|
||||
});
|
||||
}
|
||||
|
||||
async function renderPatternAudioWhole(audioContext, pattern, cps, begin, end) {
|
||||
/**
|
||||
* Renders a whole pattern to an OfflineAudioContext in one go.
|
||||
* @global
|
||||
* @param {OfflineAudioContext} audioContext The OfflineAudioContext to render to
|
||||
* @param {Pattern} pattern The pattern to render
|
||||
* @param {ExportCheckpoint[]} checkpoints A list of checkpoints indicating the cps changes throughout the song
|
||||
* @returns {Promise<AudioBuffer>}
|
||||
*/
|
||||
async function renderPatternAudioWhole(audioContext, pattern, checkpoints) {
|
||||
logger(`[webaudio] preloading`);
|
||||
|
||||
await scheduleHapsChunk(pattern, cps, begin, begin, end);
|
||||
var seconds = 0;
|
||||
|
||||
for (var i = 0; i < checkpoints.length - 1; i++) {
|
||||
const checkpointA = checkpoints[i];
|
||||
const checkpointB = checkpoints[i + 1];
|
||||
|
||||
seconds += await scheduleHapsChunk(pattern, seconds, checkpointA, checkpointB);
|
||||
}
|
||||
|
||||
logger('[webaudio] start rendering');
|
||||
|
||||
return audioContext.startRendering();
|
||||
}
|
||||
|
||||
async function renderPatternAudioInChunks(audioContext, pattern, cps, begin, end, chunkSizeInCycles) {
|
||||
let currentCycle = begin;
|
||||
let renderPromise = null;
|
||||
/**
|
||||
* Renders a whole pattern to an OfflineAudioContext in small chunks.
|
||||
* Rendering in chunks provides better rendering performance by keeping the
|
||||
* overall audio graph smaller.
|
||||
*
|
||||
* Not suppoerted on Firefox
|
||||
* @global
|
||||
* @param {OfflineAudioContext} audioContext
|
||||
* @param {Pattern} pattern
|
||||
* @param {ExportCheckpoint[]} checkpoints
|
||||
* @returns {Promise<AudioBuffer>}
|
||||
*/
|
||||
async function renderPatternAudioInChunks(audioContext, pattern, checkpoints) {
|
||||
let renderPromise;
|
||||
|
||||
// The grace period is used to suspend rendering before the next haps are scheduled.
|
||||
const gracePeriod = 1;
|
||||
|
||||
logger('[webaudio] start rendering');
|
||||
|
||||
while (currentCycle <= end) {
|
||||
const chunkStart = currentCycle;
|
||||
const chunkEnd = Math.min(currentCycle + chunkSizeInCycles, end);
|
||||
var lastSuspend = 0;
|
||||
var seconds = 0;
|
||||
|
||||
logger(`[webaudio] preloading cycles ${chunkStart} - ${chunkEnd}`);
|
||||
for (var i = 0; i < checkpoints.length - 1; i++) {
|
||||
const checkpointA = checkpoints[i];
|
||||
const checkpointB = checkpoints[i + 1];
|
||||
|
||||
await scheduleHapsChunk(pattern, cps, begin, chunkStart, chunkEnd);
|
||||
logger(`[webaudio] preloading cycles ${checkpointA.cycle} - ${checkpointB.cycle}`);
|
||||
|
||||
logger(`[webaudio] rendering cycles ${chunkStart} - ${chunkEnd}`);
|
||||
seconds += await scheduleHapsChunk(pattern, seconds, checkpointA, checkpointB);
|
||||
|
||||
currentCycle += chunkSizeInCycles;
|
||||
const lastCycle = i === checkpoints.length - 2;
|
||||
|
||||
// According to the MDN docs, suspends should be scheduled while
|
||||
// the audioContext is not currently running for better precision.
|
||||
// So we schedule the suspend first, and await after resuming.
|
||||
var suspendPromise;
|
||||
if (currentCycle < end) {
|
||||
// Make sure to suspend one cycle before the next currentCycle
|
||||
// so the next haps can be scheduled on time.
|
||||
suspendPromise = audioContext.suspend((currentCycle - begin - 1) / cps);
|
||||
}
|
||||
if (lastSuspend < seconds - gracePeriod || lastCycle) {
|
||||
if (lastCycle) {
|
||||
logger(`[webaudio] rendering seconds ${lastSuspend} - ${seconds}`);
|
||||
} else {
|
||||
logger(`[webaudio] rendering seconds ${lastSuspend} - ${seconds - gracePeriod}`);
|
||||
}
|
||||
|
||||
if (renderPromise === null) {
|
||||
renderPromise = audioContext.startRendering();
|
||||
} else {
|
||||
await audioContext.resume();
|
||||
}
|
||||
// According to the MDN docs, suspends should be scheduled while
|
||||
// the audioContext is not currently running for better precision.
|
||||
// So we schedule the suspend first, and await after resuming.
|
||||
var suspendPromise;
|
||||
if (!lastCycle) {
|
||||
suspendPromise = audioContext.suspend(seconds - gracePeriod);
|
||||
lastSuspend = seconds - gracePeriod;
|
||||
}
|
||||
|
||||
if (currentCycle < end) {
|
||||
await suspendPromise;
|
||||
if (renderPromise === undefined) {
|
||||
renderPromise = audioContext.startRendering();
|
||||
} else {
|
||||
await audioContext.resume();
|
||||
}
|
||||
|
||||
if (suspendPromise !== undefined) {
|
||||
await suspendPromise;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,28 +182,38 @@ async function renderPatternAudioInChunks(audioContext, pattern, cps, begin, end
|
||||
return renderPromise;
|
||||
}
|
||||
|
||||
async function scheduleHapsChunk(pattern, cps, begin, chunkStart, chunkEnd) {
|
||||
/**
|
||||
* Schedule all haps between 2 checkpoints
|
||||
* @global
|
||||
* @param {Pattern} pattern The pattern to render
|
||||
* @param {number} chunkStartTime The time in seconds where the chunk starts
|
||||
* @param {ExportCheckpoint} checkpointA The starting checkpoint of the chunk
|
||||
* @param {ExportCheckpoint} checkpointB The ending checkpoint of the chunk
|
||||
* @returns {number} The length of the scheduled chunk in seconds.
|
||||
*/
|
||||
async function scheduleHapsChunk(pattern, chunkStartTime, checkpointA, checkpointB) {
|
||||
// Calling superdough(...) in ascending onset time order is important
|
||||
// for controls that depend on the audio graph state like `cut`
|
||||
let haps = pattern
|
||||
.queryArc(chunkStart, chunkEnd, { _cps: cps })
|
||||
const haps = pattern
|
||||
.queryArc(checkpointA.cycle, checkpointB.cycle, { _cps: checkpointA.cps })
|
||||
.filter((hap) => hap.hasOnset())
|
||||
.sort((a, b) => a.whole.begin.valueOf() - b.whole.begin.valueOf());
|
||||
|
||||
for (const hap of haps) {
|
||||
if (hap.hasOnset()) {
|
||||
try {
|
||||
await superdough(
|
||||
hap2value(hap),
|
||||
(hap.whole.begin.valueOf() - begin) / cps,
|
||||
hap.duration / cps,
|
||||
cps,
|
||||
(hap.whole?.begin.valueOf() - begin) / cps,
|
||||
);
|
||||
} catch (err) {
|
||||
errorLogger(err, 'webaudio');
|
||||
}
|
||||
try {
|
||||
await superdough(
|
||||
hap2value(hap),
|
||||
(hap.whole.begin.valueOf() - checkpointA.cycle) / checkpointA.cps + chunkStartTime,
|
||||
hap.duration / checkpointA.cps,
|
||||
checkpointA.cps,
|
||||
(hap.whole?.begin.valueOf() - checkpointA.cycle) / checkpointA.cps + chunkStartTime,
|
||||
);
|
||||
} catch (err) {
|
||||
errorLogger(err, 'webaudio');
|
||||
}
|
||||
}
|
||||
|
||||
return (checkpointB.cycle - checkpointA.cycle) / checkpointA.cps;
|
||||
}
|
||||
|
||||
export function webaudioRepl(options = {}) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/websocket",
|
||||
"version": "1.0.0",
|
||||
"version": "1.1.0",
|
||||
"description": "Websocket input for strudel",
|
||||
"main": "index.mjs",
|
||||
"type": "module",
|
||||
|
||||
@@ -20,7 +20,6 @@ function connect(addr) {
|
||||
});
|
||||
ws.addEventListener('message', (event) => {
|
||||
try {
|
||||
console.log(event.data);
|
||||
values[addr] = JSON.parse(event.data);
|
||||
} catch {
|
||||
logger(`[websocket] received invalid json on ${addr}`);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/xen",
|
||||
"version": "1.2.6",
|
||||
"version": "1.3.0",
|
||||
"description": "Xenharmonic API for strudel",
|
||||
"main": "index.mjs",
|
||||
"type": "module",
|
||||
|
||||
@@ -7,7 +7,12 @@ This program is free software: you can redistribute it and/or modify it under th
|
||||
import { register, _mod, parseNumeral, removeUndefineds, Pattern, parray, State } from '@strudel/core';
|
||||
import Tune from './tunejs.js';
|
||||
|
||||
// returns a list of frequency ratios for given edo scale
|
||||
/**
|
||||
* returns a list of frequency ratios for given edo scale
|
||||
* @param {string} name
|
||||
* @returns {number[]}
|
||||
* @global
|
||||
*/
|
||||
export function edo(name) {
|
||||
if (!/^[1-9]+[0-9]*edo$/.test(name)) {
|
||||
throw new Error('not an edo scale: "' + name + '"');
|
||||
|
||||
Generated
+28
-93
@@ -395,6 +395,25 @@ importers:
|
||||
specifier: ^6.0.11
|
||||
version: 6.0.11(@types/node@22.10.10)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(yaml@2.7.0)
|
||||
|
||||
packages/kabelsalat:
|
||||
dependencies:
|
||||
'@kabelsalat/lib':
|
||||
specifier: ^0.4.1
|
||||
version: 0.4.1
|
||||
'@kabelsalat/web':
|
||||
specifier: ^0.4.1
|
||||
version: 0.4.1
|
||||
superdough:
|
||||
specifier: workspace:*
|
||||
version: link:../superdough
|
||||
devDependencies:
|
||||
vite:
|
||||
specifier: ^6.0.11
|
||||
version: 6.0.11(@types/node@22.10.10)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(yaml@2.7.0)
|
||||
vite-plugin-bundle-audioworklet:
|
||||
specifier: workspace:*
|
||||
version: link:../vite-plugin-bundle-audioworklet
|
||||
|
||||
packages/midi:
|
||||
dependencies:
|
||||
'@strudel/core':
|
||||
@@ -448,9 +467,6 @@ importers:
|
||||
specifier: workspace:*
|
||||
version: link:../mondo
|
||||
devDependencies:
|
||||
mondo:
|
||||
specifier: '*'
|
||||
version: 0.4.4
|
||||
vite:
|
||||
specifier: ^6.0.11
|
||||
version: 6.0.11(@types/node@22.10.10)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(yaml@2.7.0)
|
||||
@@ -611,12 +627,6 @@ importers:
|
||||
|
||||
packages/superdough:
|
||||
dependencies:
|
||||
'@kabelsalat/lib':
|
||||
specifier: ^0.4.1
|
||||
version: 0.4.1
|
||||
'@kabelsalat/web':
|
||||
specifier: ^0.4.1
|
||||
version: 0.4.1
|
||||
nanostores:
|
||||
specifier: ^0.11.3
|
||||
version: 0.11.3
|
||||
@@ -736,6 +746,9 @@ importers:
|
||||
'@strudel/draw':
|
||||
specifier: workspace:*
|
||||
version: link:../draw
|
||||
'@strudel/pattern':
|
||||
specifier: workspace:*
|
||||
version: link:../pattern
|
||||
superdough:
|
||||
specifier: workspace:*
|
||||
version: link:../superdough
|
||||
@@ -743,6 +756,9 @@ importers:
|
||||
vite:
|
||||
specifier: ^6.0.11
|
||||
version: 6.0.11(@types/node@22.10.10)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(yaml@2.7.0)
|
||||
vitest:
|
||||
specifier: ^3.0.4
|
||||
version: 3.0.4(@types/debug@4.1.12)(@types/node@22.10.10)(@vitest/ui@3.0.4)(jiti@2.4.2)(lightningcss@1.29.1)(terser@5.37.0)(yaml@2.7.0)
|
||||
|
||||
packages/websocket:
|
||||
dependencies:
|
||||
@@ -853,6 +869,9 @@ importers:
|
||||
'@strudel/hydra':
|
||||
specifier: workspace:*
|
||||
version: link:../packages/hydra
|
||||
'@strudel/kabelsalat':
|
||||
specifier: workspace:*
|
||||
version: link:../packages/kabelsalat
|
||||
'@strudel/midi':
|
||||
specifier: workspace:*
|
||||
version: link:../packages/midi
|
||||
@@ -3315,10 +3334,6 @@ packages:
|
||||
resolution: {integrity: sha512-groO71Fvi5SWpxjI9Ia+chy0QBwT61mg6yxJV27f5YFf+Mw+STT75K6SHySpP8Co5LsCrtsbCH5dJZSRtkSKaQ==}
|
||||
engines: {node: '>= 14.0.0'}
|
||||
|
||||
amdefine@1.0.1:
|
||||
resolution: {integrity: sha512-S2Hw0TtNkMJhIabBwIojKL9YHO5T0n5eNqWJ7Lrlel/zDbftQpxpapi8tZs3X1HWa+u+QeydGmzzNU0m09+Rcg==}
|
||||
engines: {node: '>=0.4.2'}
|
||||
|
||||
ansi-align@3.0.1:
|
||||
resolution: {integrity: sha512-IOfwwBF5iczOjp/WeY4YxyjqAFMQoZufdQWDd19SEExbVLNXqvpzSJ/M7Za4/sCPmQ0+GRquoA7bGcINcxew6w==}
|
||||
|
||||
@@ -3451,9 +3466,6 @@ packages:
|
||||
resolution: {integrity: sha512-hsU18Ae8CDTR6Kgu9DYf0EbCr/a5iGL0rytQDobUcdpYOKokk8LEjVphnXkDkgpi0wYVsqrXuP0bZxJaTqdgoA==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
async@0.2.10:
|
||||
resolution: {integrity: sha512-eAkdoKxU6/LkKDBzLpT+t6Ff5EtfSF4wx1WfJiPEEV7WNLnDaRXk0oVysiEPm262roaachGexwUv94WhSgN5TQ==}
|
||||
|
||||
async@3.2.6:
|
||||
resolution: {integrity: sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==}
|
||||
|
||||
@@ -3696,9 +3708,6 @@ packages:
|
||||
claviature@0.1.0:
|
||||
resolution: {integrity: sha512-Ai12axNwQ7x/F9QAj64RYKsgvi5Y33+X3GUSKAC/9s/adEws8TSSc0efeiqhKNGKBo6rT/c+CSCwSXzXxwxZzQ==}
|
||||
|
||||
cldr-plurals@1.0.0:
|
||||
resolution: {integrity: sha512-xGkehDsjj/ng1LtYiAzdiqDgqTQ/qmWafDlB6R8CfXbpXe4Ge2Tl4l7gxiA+yaD1WCTP3EVfwerdmVwfco7vxw==}
|
||||
|
||||
clean-stack@2.2.0:
|
||||
resolution: {integrity: sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==}
|
||||
engines: {node: '>=6'}
|
||||
@@ -4804,9 +4813,6 @@ packages:
|
||||
engines: {node: '>=16 || 14 >=14.17'}
|
||||
deprecated: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me
|
||||
|
||||
globalize@0.1.1:
|
||||
resolution: {integrity: sha512-5e01v8eLGfuQSOvx2MsDMOWS0GFtCx1wPzQSmcHw4hkxFzrQDBO3Xwg/m8Hr/7qXMrHeOIE29qWVzyv06u1TZA==}
|
||||
|
||||
globals@11.12.0:
|
||||
resolution: {integrity: sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==}
|
||||
engines: {node: '>=4'}
|
||||
@@ -4868,11 +4874,6 @@ packages:
|
||||
h3@1.14.0:
|
||||
resolution: {integrity: sha512-ao22eiONdgelqcnknw0iD645qW0s9NnrJHr5OBz4WOMdBdycfSas1EQf1wXRsm+PcB2Yoj43pjBPwqIpJQTeWg==}
|
||||
|
||||
handlebars@1.1.2:
|
||||
resolution: {integrity: sha512-6lekK3aSHE7XnEqEs+JWQJRSRdCqJYHEVjEfWWZv9pjLUYZNeP26EtlgOrpDCSX+k5N1m74urTbztgBOCko1Kg==}
|
||||
engines: {node: '>=0.4.7'}
|
||||
hasBin: true
|
||||
|
||||
handlebars@4.7.8:
|
||||
resolution: {integrity: sha512-vafaFqs8MZkRrSX7sFVUdo3ap/eNiLnb4IakshzvP56X5Nr1iGKAIqdX6tMlm6HcNRIkr6AxO5jFEoJzzpT8aQ==}
|
||||
engines: {node: '>=0.4.7'}
|
||||
@@ -6031,10 +6032,6 @@ packages:
|
||||
engines: {node: '>=18'}
|
||||
hasBin: true
|
||||
|
||||
mondo@0.4.4:
|
||||
resolution: {integrity: sha512-3ot6iKwC9KZvwmyZ9dgPCnlt0O1GuBnK8QZyhnoJdtkIiRL9X/cmQuu88CbFSznQx6bq19xQdwJHpv8hggH62Q==}
|
||||
deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
|
||||
|
||||
mrmime@2.0.0:
|
||||
resolution: {integrity: sha512-eu38+hdgojoyq63s+yTpN4XMBdt5l8HhMhc4VKLO9KM5caLIBvUm4thi7fFaxyTmCKeNnXZ5pAlBwCUnhA09uw==}
|
||||
engines: {node: '>=10'}
|
||||
@@ -6290,9 +6287,6 @@ packages:
|
||||
resolution: {integrity: sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
optimist@0.3.7:
|
||||
resolution: {integrity: sha512-TCx0dXQzVtSCg2OgY/bO9hjM9cV4XYx09TVK+s3+FhkjT6LovsLe+pPMzpWf+6yXK/hUizs2gUoTw3jHM0VaTQ==}
|
||||
|
||||
optionator@0.9.4:
|
||||
resolution: {integrity: sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==}
|
||||
engines: {node: '>= 0.8.0'}
|
||||
@@ -7218,10 +7212,6 @@ packages:
|
||||
source-map-support@0.5.21:
|
||||
resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==}
|
||||
|
||||
source-map@0.1.43:
|
||||
resolution: {integrity: sha512-VtCvB9SIQhk3aF6h+N85EaqIaBFIAfZ9Cu+NJHHVvc8BbEcnvDcFw6sqQ2dQrT6SlOrZq3tIvyD9+EGq/lJryQ==}
|
||||
engines: {node: '>=0.8.0'}
|
||||
|
||||
source-map@0.5.7:
|
||||
resolution: {integrity: sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
@@ -7668,11 +7658,6 @@ packages:
|
||||
ufo@1.5.4:
|
||||
resolution: {integrity: sha512-UsUk3byDzKd04EyoZ7U4DOlxQaD14JUKQl6/P7wiX4FNvUfm3XL246n9W5AmqwW5RSFJ27NAuM0iLscAOYUiGQ==}
|
||||
|
||||
uglify-js@2.3.6:
|
||||
resolution: {integrity: sha512-T2LWWydxf5+Btpb0S/Gg/yKFmYjnX9jtQ4mdN9YRq73BhN21EhU0Dvw3wYDLqd3TooGUJlCKf3Gfyjjy/RTcWA==}
|
||||
engines: {node: '>=0.4.0'}
|
||||
hasBin: true
|
||||
|
||||
uglify-js@3.19.3:
|
||||
resolution: {integrity: sha512-v3Xu+yuwBXisp6QYTcH4UbH+xYJXqnq2m/LtQVWKWzYc1iehYnLixoQDN9FH6/j9/oybfd6W9Ghwkl8+UMKTKQ==}
|
||||
engines: {node: '>=0.8.0'}
|
||||
@@ -7691,9 +7676,6 @@ packages:
|
||||
underscore@1.13.7:
|
||||
resolution: {integrity: sha512-GMXzWtsc57XAtguZgaQViUOzs0KTkk8ojr3/xAxXLITqf/3EMwxC0inyETfDFjH/Krbhuep0HNbbjI9i/q3F3g==}
|
||||
|
||||
underscore@1.5.2:
|
||||
resolution: {integrity: sha512-yejOFsRnTJs0N9CK5Apzf6maDO2djxGoLLrlZlvGs2o9ZQuhIhDL18rtFyy4FBIbOkzA6+4hDgXbgz5EvDQCXQ==}
|
||||
|
||||
undici-types@6.20.0:
|
||||
resolution: {integrity: sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==}
|
||||
|
||||
@@ -8074,10 +8056,6 @@ packages:
|
||||
resolution: {integrity: sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
wordwrap@0.0.3:
|
||||
resolution: {integrity: sha512-1tMA907+V4QmxV7dbRvb4/8MaRALK6q9Abid3ndMYnbyo8piisCmeONVqVSXqQA3KaP4SLt5b7ud6E2sqP8TFw==}
|
||||
engines: {node: '>=0.4.0'}
|
||||
|
||||
wordwrap@1.0.0:
|
||||
resolution: {integrity: sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==}
|
||||
|
||||
@@ -11163,9 +11141,6 @@ snapshots:
|
||||
'@algolia/requester-fetch': 5.20.0
|
||||
'@algolia/requester-node-http': 5.20.0
|
||||
|
||||
amdefine@1.0.1:
|
||||
optional: true
|
||||
|
||||
ansi-align@3.0.1:
|
||||
dependencies:
|
||||
string-width: 4.2.3
|
||||
@@ -11377,9 +11352,6 @@ snapshots:
|
||||
|
||||
async-function@1.0.0: {}
|
||||
|
||||
async@0.2.10:
|
||||
optional: true
|
||||
|
||||
async@3.2.6: {}
|
||||
|
||||
asynckit@0.4.0: {}
|
||||
@@ -11643,8 +11615,6 @@ snapshots:
|
||||
|
||||
claviature@0.1.0: {}
|
||||
|
||||
cldr-plurals@1.0.0: {}
|
||||
|
||||
clean-stack@2.2.0: {}
|
||||
|
||||
cli-boxes@3.0.0: {}
|
||||
@@ -12846,8 +12816,6 @@ snapshots:
|
||||
minipass: 4.2.8
|
||||
path-scurry: 1.11.1
|
||||
|
||||
globalize@0.1.1: {}
|
||||
|
||||
globals@11.12.0: {}
|
||||
|
||||
globals@14.0.0: {}
|
||||
@@ -12914,12 +12882,6 @@ snapshots:
|
||||
uncrypto: 0.1.3
|
||||
unenv: 1.10.0
|
||||
|
||||
handlebars@1.1.2:
|
||||
dependencies:
|
||||
optimist: 0.3.7
|
||||
optionalDependencies:
|
||||
uglify-js: 2.3.6
|
||||
|
||||
handlebars@4.7.8:
|
||||
dependencies:
|
||||
minimist: 1.2.8
|
||||
@@ -14514,13 +14476,6 @@ snapshots:
|
||||
requirejs: 2.3.7
|
||||
requirejs-config-file: 4.0.0
|
||||
|
||||
mondo@0.4.4:
|
||||
dependencies:
|
||||
cldr-plurals: 1.0.0
|
||||
globalize: 0.1.1
|
||||
handlebars: 1.1.2
|
||||
underscore: 1.5.2
|
||||
|
||||
mrmime@2.0.0: {}
|
||||
|
||||
ms@2.0.0: {}
|
||||
@@ -14824,10 +14779,6 @@ snapshots:
|
||||
is-docker: 2.2.1
|
||||
is-wsl: 2.2.0
|
||||
|
||||
optimist@0.3.7:
|
||||
dependencies:
|
||||
wordwrap: 0.0.3
|
||||
|
||||
optionator@0.9.4:
|
||||
dependencies:
|
||||
deep-is: 0.1.4
|
||||
@@ -15975,11 +15926,6 @@ snapshots:
|
||||
buffer-from: 1.1.2
|
||||
source-map: 0.6.1
|
||||
|
||||
source-map@0.1.43:
|
||||
dependencies:
|
||||
amdefine: 1.0.1
|
||||
optional: true
|
||||
|
||||
source-map@0.5.7: {}
|
||||
|
||||
source-map@0.6.1: {}
|
||||
@@ -16460,13 +16406,6 @@ snapshots:
|
||||
|
||||
ufo@1.5.4: {}
|
||||
|
||||
uglify-js@2.3.6:
|
||||
dependencies:
|
||||
async: 0.2.10
|
||||
optimist: 0.3.7
|
||||
source-map: 0.1.43
|
||||
optional: true
|
||||
|
||||
uglify-js@3.19.3:
|
||||
optional: true
|
||||
|
||||
@@ -16483,8 +16422,6 @@ snapshots:
|
||||
|
||||
underscore@1.13.7: {}
|
||||
|
||||
underscore@1.5.2: {}
|
||||
|
||||
undici-types@6.20.0: {}
|
||||
|
||||
unenv@1.10.0:
|
||||
@@ -16859,8 +16796,6 @@ snapshots:
|
||||
|
||||
word-wrap@1.2.5: {}
|
||||
|
||||
wordwrap@0.0.3: {}
|
||||
|
||||
wordwrap@1.0.0: {}
|
||||
|
||||
workbox-background-sync@7.0.0:
|
||||
|
||||
@@ -1,5 +1,98 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`runs examples > example "__pick" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/2 | note:g ]",
|
||||
"[ 1/2 → 1/1 | note:a ]",
|
||||
"[ 1/1 → 3/2 | note:e ]",
|
||||
"[ 3/2 → 2/1 | note:f ]",
|
||||
"[ 2/1 → 9/4 | note:f ]",
|
||||
"[ 9/4 → 5/2 | note:g ]",
|
||||
"[ 5/2 → 11/4 | note:f ]",
|
||||
"[ 11/4 → 3/1 | note:g ]",
|
||||
"[ 3/1 → 13/4 | note:f ]",
|
||||
"[ 13/4 → 7/2 | note:g ]",
|
||||
"[ 7/2 → 15/4 | note:f ]",
|
||||
"[ 15/4 → 4/1 | note:g ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "__pick" example index 1 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/2 | s:bd ]",
|
||||
"[ 1/2 → 1/1 | s:sd ]",
|
||||
"[ 1/1 → 3/2 | s:cp ]",
|
||||
"[ 3/2 → 2/1 | s:cp ]",
|
||||
"[ 2/1 → 5/2 | s:hh ]",
|
||||
"[ 2/1 → 5/2 | s:bd ]",
|
||||
"[ 5/2 → 3/1 | s:hh ]",
|
||||
"[ 5/2 → 3/1 | s:sd ]",
|
||||
"[ 3/1 → 7/2 | s:bd ]",
|
||||
"[ 7/2 → 4/1 | s:sd ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "__pick" example index 2 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/8 | s:bd ]",
|
||||
"[ 3/8 → 1/2 | s:bd ]",
|
||||
"[ 3/4 → 7/8 | s:bd ]",
|
||||
"[ 1/1 → 9/8 | s:bd ]",
|
||||
"[ 11/8 → 3/2 | s:bd ]",
|
||||
"[ 7/4 → 15/8 | s:bd ]",
|
||||
"[ 2/1 → 17/8 | s:bd ]",
|
||||
"[ 2/1 → 5/2 | s:sd ]",
|
||||
"[ 19/8 → 5/2 | s:bd ]",
|
||||
"[ 5/2 → 3/1 | s:sd ]",
|
||||
"[ 11/4 → 23/8 | s:bd ]",
|
||||
"[ 3/1 → 7/2 | s:sd ]",
|
||||
"[ 7/2 → 4/1 | s:sd ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "__pick" example index 3 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/8 | s:bd ]",
|
||||
"[ 3/8 → 1/2 | s:bd ]",
|
||||
"[ 3/4 → 7/8 | s:bd ]",
|
||||
"[ 1/1 → 9/8 | s:bd ]",
|
||||
"[ 11/8 → 3/2 | s:bd ]",
|
||||
"[ 7/4 → 15/8 | s:bd ]",
|
||||
"[ 2/1 → 17/8 | s:bd ]",
|
||||
"[ 2/1 → 5/2 | s:sd ]",
|
||||
"[ 19/8 → 5/2 | s:bd ]",
|
||||
"[ 5/2 → 3/1 | s:sd ]",
|
||||
"[ 11/4 → 23/8 | s:bd ]",
|
||||
"[ 3/1 → 7/2 | s:sd ]",
|
||||
"[ 7/2 → 4/1 | s:sd ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "__pick" example index 4 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/4 | s:bd speed:2 ]",
|
||||
"[ 1/4 → 1/2 | s:cp speed:2 ]",
|
||||
"[ 1/2 → 3/4 | s:bd speed:3 ]",
|
||||
"[ 3/4 → 1/1 | s:cp speed:3 ]",
|
||||
"[ 1/1 → 7/6 | s:bd speed:3 ]",
|
||||
"[ 7/6 → 4/3 | s:cp speed:3 ]",
|
||||
"[ 4/3 → 3/2 | s:bd speed:2 ]",
|
||||
"[ 3/2 → 5/3 | s:cp speed:2 ]",
|
||||
"[ 5/3 → 11/6 | s:bd speed:3 ]",
|
||||
"[ 11/6 → 2/1 | s:cp speed:3 ]",
|
||||
"[ 2/1 → 9/4 | s:bd speed:2 ]",
|
||||
"[ 9/4 → 5/2 | s:cp speed:2 ]",
|
||||
"[ 5/2 → 11/4 | s:bd speed:3 ]",
|
||||
"[ 11/4 → 3/1 | s:cp speed:3 ]",
|
||||
"[ 3/1 → 19/6 | s:bd speed:3 ]",
|
||||
"[ 19/6 → 10/3 | s:cp speed:3 ]",
|
||||
"[ 10/3 → 7/2 | s:bd speed:2 ]",
|
||||
"[ 7/2 → 11/3 | s:cp speed:2 ]",
|
||||
"[ 11/3 → 23/6 | s:bd speed:3 ]",
|
||||
"[ 23/6 → 4/1 | s:cp speed:3 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "_euclidRot" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/5 | note:c3 ]",
|
||||
@@ -611,6 +704,30 @@ exports[`runs examples > example "FX" example index 1 1`] = `
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "Hap" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/2 | s:sd ]",
|
||||
"[ 0/1 → 1/1 | s:bd ]",
|
||||
"[ 1/2 → 1/1 | s:sd ]",
|
||||
"[ 1/1 → 3/2 | s:sd ]",
|
||||
"[ 1/1 → 2/1 | s:bd ]",
|
||||
"[ 3/2 → 2/1 | s:sd ]",
|
||||
"[ 2/1 → 5/2 | s:sd ]",
|
||||
"[ 2/1 → 3/1 | s:bd ]",
|
||||
"[ 5/2 → 3/1 | s:sd ]",
|
||||
"[ 3/1 → 7/2 | s:sd ]",
|
||||
"[ 3/1 → 4/1 | s:bd ]",
|
||||
"[ 7/2 → 4/1 | s:sd ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "Hap" example index 1 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/4 | note:c3 ]",
|
||||
"[ 1/4 → 1/2 | note:d3 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "K" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/12 | note:Bb4 s:saw workletSrc:saw(saw(sFreq / pat[0]).mul(8).add(sFreq).lag(pat[1])).mul(0.3).mul(sGate.adsr(0 0.15 0.5 pat[2])).lpf(sGate.adsr(0 0.2 0.3 0.2).mul(1).add(0)).add(x => x.delay(pat[3]).mul(0.7)).add(x => x.delay(pat[4]).mul(0.77)).mul(0.7).add(x => x.delay(0.13).mul(0.7)).out() workletInputs:[2 0 0.1 0.3 0.03] ]",
|
||||
@@ -1301,6 +1418,23 @@ exports[`runs examples > example "beat" example index 1 1`] = `
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "beat" example index 2 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/8 | s:sd ]",
|
||||
"[ 3/8 → 1/2 | s:sd ]",
|
||||
"[ 3/4 → 7/8 | s:sd ]",
|
||||
"[ 1/1 → 9/8 | s:sd ]",
|
||||
"[ 11/8 → 3/2 | s:sd ]",
|
||||
"[ 7/4 → 15/8 | s:sd ]",
|
||||
"[ 2/1 → 17/8 | s:sd ]",
|
||||
"[ 19/8 → 5/2 | s:sd ]",
|
||||
"[ 11/4 → 23/8 | s:sd ]",
|
||||
"[ 3/1 → 25/8 | s:sd ]",
|
||||
"[ 27/8 → 7/2 | s:sd ]",
|
||||
"[ 15/4 → 31/8 | s:sd ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "begin" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/2 | s:rave begin:0 ]",
|
||||
@@ -7107,7 +7241,30 @@ exports[`runs examples > example "keep" example index 0 1`] = `
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "keyDown" example index 0 1`] = `[]`;
|
||||
exports[`runs examples > example "keyDown" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/8 | s:bd ]",
|
||||
"[ 1/4 → 3/8 | s:bd ]",
|
||||
"[ 3/8 → 1/2 | s:bd ]",
|
||||
"[ 5/8 → 3/4 | s:bd ]",
|
||||
"[ 3/4 → 7/8 | s:bd ]",
|
||||
"[ 1/1 → 9/8 | s:bd ]",
|
||||
"[ 5/4 → 11/8 | s:bd ]",
|
||||
"[ 11/8 → 3/2 | s:bd ]",
|
||||
"[ 13/8 → 7/4 | s:bd ]",
|
||||
"[ 7/4 → 15/8 | s:bd ]",
|
||||
"[ 2/1 → 17/8 | s:bd ]",
|
||||
"[ 9/4 → 19/8 | s:bd ]",
|
||||
"[ 19/8 → 5/2 | s:bd ]",
|
||||
"[ 21/8 → 11/4 | s:bd ]",
|
||||
"[ 11/4 → 23/8 | s:bd ]",
|
||||
"[ 3/1 → 25/8 | s:bd ]",
|
||||
"[ 13/4 → 27/8 | s:bd ]",
|
||||
"[ 27/8 → 7/2 | s:bd ]",
|
||||
"[ 29/8 → 15/4 | s:bd ]",
|
||||
"[ 15/4 → 31/8 | s:bd ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "lastOf" example index 0 1`] = `
|
||||
[
|
||||
@@ -11751,6 +11908,72 @@ exports[`runs examples > example "scrub" example index 1 1`] = `
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "scut" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/2 | note:E3 s:piano scut:1 ]",
|
||||
"[ 0/1 → 1/2 | note:C4 s:piano scut:1 ]",
|
||||
"[ 0/1 → 1/2 | note:E4 s:piano scut:1 ]",
|
||||
"[ 0/1 → 1/2 | note:G4 s:piano scut:1 ]",
|
||||
"[ 0/1 → 1/2 | note:C5 s:piano scut:1 ]",
|
||||
"[ 1/2 → 1/1 | note:G3 s:piano scut:1 ]",
|
||||
"[ 1/2 → 1/1 | note:D4 s:piano scut:1 ]",
|
||||
"[ 1/2 → 1/1 | note:G4 s:piano scut:1 ]",
|
||||
"[ 1/2 → 1/1 | note:B4 s:piano scut:1 ]",
|
||||
"[ 1/1 → 3/2 | note:E3 s:piano scut:1 ]",
|
||||
"[ 1/1 → 3/2 | note:C4 s:piano scut:1 ]",
|
||||
"[ 1/1 → 3/2 | note:E4 s:piano scut:1 ]",
|
||||
"[ 1/1 → 3/2 | note:G4 s:piano scut:1 ]",
|
||||
"[ 1/1 → 3/2 | note:C5 s:piano scut:1 ]",
|
||||
"[ 3/2 → 2/1 | note:G3 s:piano scut:1 ]",
|
||||
"[ 3/2 → 2/1 | note:D4 s:piano scut:1 ]",
|
||||
"[ 3/2 → 2/1 | note:G4 s:piano scut:1 ]",
|
||||
"[ 3/2 → 2/1 | note:B4 s:piano scut:1 ]",
|
||||
"[ 2/1 → 5/2 | note:E3 s:piano scut:1 ]",
|
||||
"[ 2/1 → 5/2 | note:C4 s:piano scut:1 ]",
|
||||
"[ 2/1 → 5/2 | note:E4 s:piano scut:1 ]",
|
||||
"[ 2/1 → 5/2 | note:G4 s:piano scut:1 ]",
|
||||
"[ 2/1 → 5/2 | note:C5 s:piano scut:1 ]",
|
||||
"[ 5/2 → 3/1 | note:G3 s:piano scut:1 ]",
|
||||
"[ 5/2 → 3/1 | note:D4 s:piano scut:1 ]",
|
||||
"[ 5/2 → 3/1 | note:G4 s:piano scut:1 ]",
|
||||
"[ 5/2 → 3/1 | note:B4 s:piano scut:1 ]",
|
||||
"[ 3/1 → 7/2 | note:E3 s:piano scut:1 ]",
|
||||
"[ 3/1 → 7/2 | note:C4 s:piano scut:1 ]",
|
||||
"[ 3/1 → 7/2 | note:E4 s:piano scut:1 ]",
|
||||
"[ 3/1 → 7/2 | note:G4 s:piano scut:1 ]",
|
||||
"[ 3/1 → 7/2 | note:C5 s:piano scut:1 ]",
|
||||
"[ 7/2 → 4/1 | note:G3 s:piano scut:1 ]",
|
||||
"[ 7/2 → 4/1 | note:D4 s:piano scut:1 ]",
|
||||
"[ 7/2 → 4/1 | note:G4 s:piano scut:1 ]",
|
||||
"[ 7/2 → 4/1 | note:B4 s:piano scut:1 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "secondsPer" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/4 | note:f decay:0.5 ]",
|
||||
"[ 1/4 → 1/2 | note:a decay:0.5 ]",
|
||||
"[ 1/2 → 5/8 | note:c decay:0.25 ]",
|
||||
"[ 5/8 → 3/4 | note:d decay:0.25 ]",
|
||||
"[ 3/4 → 1/1 | note:e decay:0.5 ]",
|
||||
"[ 1/1 → 5/4 | note:f decay:0.5 ]",
|
||||
"[ 5/4 → 3/2 | note:a decay:0.5 ]",
|
||||
"[ 3/2 → 13/8 | note:c decay:0.25 ]",
|
||||
"[ 13/8 → 7/4 | note:d decay:0.25 ]",
|
||||
"[ 7/4 → 2/1 | note:e decay:0.5 ]",
|
||||
"[ 2/1 → 9/4 | note:f decay:0.5 ]",
|
||||
"[ 9/4 → 5/2 | note:a decay:0.5 ]",
|
||||
"[ 5/2 → 21/8 | note:c decay:0.25 ]",
|
||||
"[ 21/8 → 11/4 | note:d decay:0.25 ]",
|
||||
"[ 11/4 → 3/1 | note:e decay:0.5 ]",
|
||||
"[ 3/1 → 13/4 | note:f decay:0.5 ]",
|
||||
"[ 13/4 → 7/2 | note:a decay:0.5 ]",
|
||||
"[ 7/2 → 29/8 | note:c decay:0.25 ]",
|
||||
"[ 29/8 → 15/4 | note:d decay:0.25 ]",
|
||||
"[ 15/4 → 4/1 | note:e decay:0.5 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "seed" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/4 | s:bd ]",
|
||||
@@ -12831,6 +13054,181 @@ exports[`runs examples > example "slowcat" example index 0 1`] = `
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "smooth" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/16 | note:C3 ]",
|
||||
"[ 1/16 → 1/8 | note:D3 ]",
|
||||
"[ 1/8 → 3/16 | note:E3 ]",
|
||||
"[ 3/16 → 1/4 | note:F3 ]",
|
||||
"[ 1/4 → 5/16 | note:G3 ]",
|
||||
"[ 5/16 → 3/8 | note:A3 ]",
|
||||
"[ 3/8 → 7/16 | note:B3 ]",
|
||||
"[ 7/16 → 1/2 | note:C4 ]",
|
||||
"[ 1/2 → 9/16 | note:D4 ]",
|
||||
"[ 9/16 → 5/8 | note:C4 ]",
|
||||
"[ 5/8 → 11/16 | note:B3 ]",
|
||||
"[ 11/16 → 3/4 | note:A3 ]",
|
||||
"[ 3/4 → 13/16 | note:G3 ]",
|
||||
"[ 13/16 → 7/8 | note:F3 ]",
|
||||
"[ 7/8 → 15/16 | note:E3 ]",
|
||||
"[ 15/16 → 1/1 | note:D3 ]",
|
||||
"[ 1/1 → 17/16 | note:C3 ]",
|
||||
"[ 17/16 → 9/8 | note:D3 ]",
|
||||
"[ 9/8 → 19/16 | note:E3 ]",
|
||||
"[ 19/16 → 5/4 | note:F3 ]",
|
||||
"[ 5/4 → 21/16 | note:G3 ]",
|
||||
"[ 21/16 → 11/8 | note:A3 ]",
|
||||
"[ 11/8 → 23/16 | note:B3 ]",
|
||||
"[ 23/16 → 3/2 | note:C4 ]",
|
||||
"[ 3/2 → 25/16 | note:D4 ]",
|
||||
"[ 25/16 → 13/8 | note:C4 ]",
|
||||
"[ 13/8 → 27/16 | note:B3 ]",
|
||||
"[ 27/16 → 7/4 | note:A3 ]",
|
||||
"[ 7/4 → 29/16 | note:G3 ]",
|
||||
"[ 29/16 → 15/8 | note:F3 ]",
|
||||
"[ 15/8 → 31/16 | note:E3 ]",
|
||||
"[ 31/16 → 2/1 | note:D3 ]",
|
||||
"[ 2/1 → 33/16 | note:C3 ]",
|
||||
"[ 33/16 → 17/8 | note:D3 ]",
|
||||
"[ 17/8 → 35/16 | note:E3 ]",
|
||||
"[ 35/16 → 9/4 | note:F3 ]",
|
||||
"[ 9/4 → 37/16 | note:G3 ]",
|
||||
"[ 37/16 → 19/8 | note:A3 ]",
|
||||
"[ 19/8 → 39/16 | note:B3 ]",
|
||||
"[ 39/16 → 5/2 | note:C4 ]",
|
||||
"[ 5/2 → 41/16 | note:D4 ]",
|
||||
"[ 41/16 → 21/8 | note:C4 ]",
|
||||
"[ 21/8 → 43/16 | note:B3 ]",
|
||||
"[ 43/16 → 11/4 | note:A3 ]",
|
||||
"[ 11/4 → 45/16 | note:G3 ]",
|
||||
"[ 45/16 → 23/8 | note:F3 ]",
|
||||
"[ 23/8 → 47/16 | note:E3 ]",
|
||||
"[ 47/16 → 3/1 | note:D3 ]",
|
||||
"[ 3/1 → 49/16 | note:C3 ]",
|
||||
"[ 49/16 → 25/8 | note:D3 ]",
|
||||
"[ 25/8 → 51/16 | note:E3 ]",
|
||||
"[ 51/16 → 13/4 | note:F3 ]",
|
||||
"[ 13/4 → 53/16 | note:G3 ]",
|
||||
"[ 53/16 → 27/8 | note:A3 ]",
|
||||
"[ 27/8 → 55/16 | note:B3 ]",
|
||||
"[ 55/16 → 7/2 | note:C4 ]",
|
||||
"[ 7/2 → 57/16 | note:D4 ]",
|
||||
"[ 57/16 → 29/8 | note:C4 ]",
|
||||
"[ 29/8 → 59/16 | note:B3 ]",
|
||||
"[ 59/16 → 15/4 | note:A3 ]",
|
||||
"[ 15/4 → 61/16 | note:G3 ]",
|
||||
"[ 61/16 → 31/8 | note:F3 ]",
|
||||
"[ 31/8 → 63/16 | note:E3 ]",
|
||||
"[ 63/16 → 4/1 | note:D3 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "smooth" example index 1 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/8 | note:C3 ]",
|
||||
"[ 1/8 → 1/4 | note:D3 ]",
|
||||
"[ 1/4 → 3/8 | note:E3 ]",
|
||||
"[ 3/8 → 1/2 | note:F3 ]",
|
||||
"[ 1/2 → 5/8 | note:G3 ]",
|
||||
"[ 5/8 → 3/4 | note:A3 ]",
|
||||
"[ 3/4 → 7/8 | note:B3 ]",
|
||||
"[ 7/8 → 1/1 | note:C4 ]",
|
||||
"[ 1/1 → 9/8 | note:C3 ]",
|
||||
"[ 9/8 → 5/4 | note:D3 ]",
|
||||
"[ 5/4 → 11/8 | note:E3 ]",
|
||||
"[ 11/8 → 3/2 | note:F3 ]",
|
||||
"[ 3/2 → 13/8 | note:G3 ]",
|
||||
"[ 13/8 → 7/4 | note:A3 ]",
|
||||
"[ 7/4 → 15/8 | note:B3 ]",
|
||||
"[ 15/8 → 2/1 | note:C4 ]",
|
||||
"[ 2/1 → 17/8 | note:C3 ]",
|
||||
"[ 17/8 → 9/4 | note:D3 ]",
|
||||
"[ 9/4 → 19/8 | note:E3 ]",
|
||||
"[ 19/8 → 5/2 | note:F3 ]",
|
||||
"[ 5/2 → 21/8 | note:G3 ]",
|
||||
"[ 21/8 → 11/4 | note:A3 ]",
|
||||
"[ 11/4 → 23/8 | note:B3 ]",
|
||||
"[ 23/8 → 3/1 | note:C4 ]",
|
||||
"[ 3/1 → 25/8 | note:C3 ]",
|
||||
"[ 25/8 → 13/4 | note:D3 ]",
|
||||
"[ 13/4 → 27/8 | note:E3 ]",
|
||||
"[ 27/8 → 7/2 | note:F3 ]",
|
||||
"[ 7/2 → 29/8 | note:G3 ]",
|
||||
"[ 29/8 → 15/4 | note:A3 ]",
|
||||
"[ 15/4 → 31/8 | note:B3 ]",
|
||||
"[ 31/8 → 4/1 | note:C4 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "smooth" example index 2 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:0 ]",
|
||||
"[ 1/16 → 1/8 | note:E2 s:saw cutoff:100 resonance:7 lpenv:0.0625 ]",
|
||||
"[ 1/8 → 3/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:0.125 ]",
|
||||
"[ 3/16 → 1/4 | note:A2 s:saw cutoff:100 resonance:7 lpenv:0.1875 ]",
|
||||
"[ 1/4 → 5/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:0.25 ]",
|
||||
"[ 5/16 → 3/8 | note:B2 s:saw cutoff:100 resonance:7 lpenv:0.3125 ]",
|
||||
"[ 3/8 → 7/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:0.375 ]",
|
||||
"[ 7/16 → 1/2 | note:E3 s:saw cutoff:100 resonance:7 lpenv:0.4375 ]",
|
||||
"[ 1/2 → 9/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:0.5 ]",
|
||||
"[ 9/16 → 5/8 | note:E2 s:saw cutoff:100 resonance:7 lpenv:0.5625 ]",
|
||||
"[ 5/8 → 11/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:0.625 ]",
|
||||
"[ 11/16 → 3/4 | note:A2 s:saw cutoff:100 resonance:7 lpenv:0.6875 ]",
|
||||
"[ 3/4 → 13/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:0.75 ]",
|
||||
"[ 13/16 → 7/8 | note:B2 s:saw cutoff:100 resonance:7 lpenv:0.8125 ]",
|
||||
"[ 7/8 → 15/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:0.875 ]",
|
||||
"[ 15/16 → 1/1 | note:E3 s:saw cutoff:100 resonance:7 lpenv:0.9375 ]",
|
||||
"[ 1/1 → 17/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1 ]",
|
||||
"[ 17/16 → 9/8 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.0208333333333333 ]",
|
||||
"[ 9/8 → 19/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.0416666666666667 ]",
|
||||
"[ 19/16 → 5/4 | note:A2 s:saw cutoff:100 resonance:7 lpenv:1.0625 ]",
|
||||
"[ 5/4 → 21/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.0833333333333333 ]",
|
||||
"[ 21/16 → 11/8 | note:B2 s:saw cutoff:100 resonance:7 lpenv:1.1041666666666667 ]",
|
||||
"[ 11/8 → 23/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.125 ]",
|
||||
"[ 23/16 → 3/2 | note:E3 s:saw cutoff:100 resonance:7 lpenv:1.1458333333333333 ]",
|
||||
"[ 3/2 → 25/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.1666666666666667 ]",
|
||||
"[ 25/16 → 13/8 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.1875 ]",
|
||||
"[ 13/8 → 27/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.2083333333333333 ]",
|
||||
"[ 27/16 → 7/4 | note:A2 s:saw cutoff:100 resonance:7 lpenv:1.2291666666666667 ]",
|
||||
"[ 7/4 → 29/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.25 ]",
|
||||
"[ 29/16 → 15/8 | note:B2 s:saw cutoff:100 resonance:7 lpenv:1.2708333333333333 ]",
|
||||
"[ 15/8 → 31/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.2916666666666667 ]",
|
||||
"[ 31/16 → 2/1 | note:E3 s:saw cutoff:100 resonance:7 lpenv:1.3125 ]",
|
||||
"[ 2/1 → 33/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.3333333333333333 ]",
|
||||
"[ 33/16 → 17/8 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.3541666666666667 ]",
|
||||
"[ 17/8 → 35/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.375 ]",
|
||||
"[ 35/16 → 9/4 | note:A2 s:saw cutoff:100 resonance:7 lpenv:1.3958333333333333 ]",
|
||||
"[ 9/4 → 37/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.4166666666666667 ]",
|
||||
"[ 37/16 → 19/8 | note:B2 s:saw cutoff:100 resonance:7 lpenv:1.4375 ]",
|
||||
"[ 19/8 → 39/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.4583333333333333 ]",
|
||||
"[ 39/16 → 5/2 | note:E3 s:saw cutoff:100 resonance:7 lpenv:1.4791666666666667 ]",
|
||||
"[ 5/2 → 41/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.5 ]",
|
||||
"[ 41/16 → 21/8 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.5208333333333335 ]",
|
||||
"[ 21/8 → 43/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.5416666666666665 ]",
|
||||
"[ 43/16 → 11/4 | note:A2 s:saw cutoff:100 resonance:7 lpenv:1.5625 ]",
|
||||
"[ 11/4 → 45/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.5833333333333335 ]",
|
||||
"[ 45/16 → 23/8 | note:B2 s:saw cutoff:100 resonance:7 lpenv:1.6041666666666665 ]",
|
||||
"[ 23/8 → 47/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.625 ]",
|
||||
"[ 47/16 → 3/1 | note:E3 s:saw cutoff:100 resonance:7 lpenv:1.6458333333333335 ]",
|
||||
"[ 3/1 → 49/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.6666666666666665 ]",
|
||||
"[ 49/16 → 25/8 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.6875 ]",
|
||||
"[ 25/8 → 51/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.7083333333333335 ]",
|
||||
"[ 51/16 → 13/4 | note:A2 s:saw cutoff:100 resonance:7 lpenv:1.7291666666666665 ]",
|
||||
"[ 13/4 → 53/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.75 ]",
|
||||
"[ 53/16 → 27/8 | note:B2 s:saw cutoff:100 resonance:7 lpenv:1.7708333333333335 ]",
|
||||
"[ 27/8 → 55/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.7916666666666665 ]",
|
||||
"[ 55/16 → 7/2 | note:E3 s:saw cutoff:100 resonance:7 lpenv:1.8125 ]",
|
||||
"[ 7/2 → 57/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.8333333333333335 ]",
|
||||
"[ 57/16 → 29/8 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.8541666666666665 ]",
|
||||
"[ 29/8 → 59/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.875 ]",
|
||||
"[ 59/16 → 15/4 | note:A2 s:saw cutoff:100 resonance:7 lpenv:1.8958333333333335 ]",
|
||||
"[ 15/4 → 61/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.9166666666666665 ]",
|
||||
"[ 61/16 → 31/8 | note:B2 s:saw cutoff:100 resonance:7 lpenv:1.9375 ]",
|
||||
"[ 31/8 → 63/16 | note:E2 s:saw cutoff:100 resonance:7 lpenv:1.9583333333333335 ]",
|
||||
"[ 63/16 → 4/1 | note:E3 s:saw cutoff:100 resonance:7 lpenv:1.9791666666666665 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "someCycles" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/8 | s:hh speed:0.5 ]",
|
||||
@@ -14108,106 +14506,76 @@ exports[`runs examples > example "sustain" example index 0 1`] = `
|
||||
|
||||
exports[`runs examples > example "swing" example index 0 1`] = `
|
||||
[
|
||||
"[ -1/12 ⇜ (0/1 → 1/24) | s:hh ]",
|
||||
"[ 0/1 → 1/8 | s:hh ]",
|
||||
"[ 1/24 ⇜ (1/8 → 1/6) | s:hh ]",
|
||||
"[ (1/6 → 1/4) ⇝ 7/24 | s:hh ]",
|
||||
"[ 1/6 → 7/24 | s:hh ]",
|
||||
"[ 1/4 → 3/8 | s:hh ]",
|
||||
"[ 7/24 ⇜ (3/8 → 5/12) | s:hh ]",
|
||||
"[ (5/12 → 1/2) ⇝ 13/24 | s:hh ]",
|
||||
"[ 5/12 → 13/24 | s:hh ]",
|
||||
"[ 1/2 → 5/8 | s:hh ]",
|
||||
"[ 13/24 ⇜ (5/8 → 2/3) | s:hh ]",
|
||||
"[ (2/3 → 3/4) ⇝ 19/24 | s:hh ]",
|
||||
"[ 2/3 → 19/24 | s:hh ]",
|
||||
"[ 3/4 → 7/8 | s:hh ]",
|
||||
"[ 19/24 ⇜ (7/8 → 11/12) | s:hh ]",
|
||||
"[ (11/12 → 1/1) ⇝ 25/24 | s:hh ]",
|
||||
"[ 11/12 → 25/24 | s:hh ]",
|
||||
"[ 1/1 → 9/8 | s:hh ]",
|
||||
"[ 25/24 ⇜ (9/8 → 7/6) | s:hh ]",
|
||||
"[ (7/6 → 5/4) ⇝ 31/24 | s:hh ]",
|
||||
"[ 7/6 → 31/24 | s:hh ]",
|
||||
"[ 5/4 → 11/8 | s:hh ]",
|
||||
"[ 31/24 ⇜ (11/8 → 17/12) | s:hh ]",
|
||||
"[ (17/12 → 3/2) ⇝ 37/24 | s:hh ]",
|
||||
"[ 17/12 → 37/24 | s:hh ]",
|
||||
"[ 3/2 → 13/8 | s:hh ]",
|
||||
"[ 37/24 ⇜ (13/8 → 5/3) | s:hh ]",
|
||||
"[ (5/3 → 7/4) ⇝ 43/24 | s:hh ]",
|
||||
"[ 5/3 → 43/24 | s:hh ]",
|
||||
"[ 7/4 → 15/8 | s:hh ]",
|
||||
"[ 43/24 ⇜ (15/8 → 23/12) | s:hh ]",
|
||||
"[ (23/12 → 2/1) ⇝ 49/24 | s:hh ]",
|
||||
"[ 23/12 → 49/24 | s:hh ]",
|
||||
"[ 2/1 → 17/8 | s:hh ]",
|
||||
"[ 49/24 ⇜ (17/8 → 13/6) | s:hh ]",
|
||||
"[ (13/6 → 9/4) ⇝ 55/24 | s:hh ]",
|
||||
"[ 13/6 → 55/24 | s:hh ]",
|
||||
"[ 9/4 → 19/8 | s:hh ]",
|
||||
"[ 55/24 ⇜ (19/8 → 29/12) | s:hh ]",
|
||||
"[ (29/12 → 5/2) ⇝ 61/24 | s:hh ]",
|
||||
"[ 29/12 → 61/24 | s:hh ]",
|
||||
"[ 5/2 → 21/8 | s:hh ]",
|
||||
"[ 61/24 ⇜ (21/8 → 8/3) | s:hh ]",
|
||||
"[ (8/3 → 11/4) ⇝ 67/24 | s:hh ]",
|
||||
"[ 8/3 → 67/24 | s:hh ]",
|
||||
"[ 11/4 → 23/8 | s:hh ]",
|
||||
"[ 67/24 ⇜ (23/8 → 35/12) | s:hh ]",
|
||||
"[ (35/12 → 3/1) ⇝ 73/24 | s:hh ]",
|
||||
"[ 35/12 → 73/24 | s:hh ]",
|
||||
"[ 3/1 → 25/8 | s:hh ]",
|
||||
"[ 73/24 ⇜ (25/8 → 19/6) | s:hh ]",
|
||||
"[ (19/6 → 13/4) ⇝ 79/24 | s:hh ]",
|
||||
"[ 19/6 → 79/24 | s:hh ]",
|
||||
"[ 13/4 → 27/8 | s:hh ]",
|
||||
"[ 79/24 ⇜ (27/8 → 41/12) | s:hh ]",
|
||||
"[ (41/12 → 7/2) ⇝ 85/24 | s:hh ]",
|
||||
"[ 41/12 → 85/24 | s:hh ]",
|
||||
"[ 7/2 → 29/8 | s:hh ]",
|
||||
"[ 85/24 ⇜ (29/8 → 11/3) | s:hh ]",
|
||||
"[ (11/3 → 15/4) ⇝ 91/24 | s:hh ]",
|
||||
"[ 11/3 → 91/24 | s:hh ]",
|
||||
"[ 15/4 → 31/8 | s:hh ]",
|
||||
"[ 91/24 ⇜ (31/8 → 47/12) | s:hh ]",
|
||||
"[ (47/12 → 4/1) ⇝ 97/24 | s:hh ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "swingBy" example index 0 1`] = `
|
||||
[
|
||||
"[ -1/12 ⇜ (0/1 → 1/24) | s:hh ]",
|
||||
"[ 0/1 → 1/8 | s:hh ]",
|
||||
"[ 1/24 ⇜ (1/8 → 1/6) | s:hh ]",
|
||||
"[ (1/6 → 1/4) ⇝ 7/24 | s:hh ]",
|
||||
"[ 1/6 → 7/24 | s:hh ]",
|
||||
"[ 1/4 → 3/8 | s:hh ]",
|
||||
"[ 7/24 ⇜ (3/8 → 5/12) | s:hh ]",
|
||||
"[ (5/12 → 1/2) ⇝ 13/24 | s:hh ]",
|
||||
"[ 5/12 → 13/24 | s:hh ]",
|
||||
"[ 1/2 → 5/8 | s:hh ]",
|
||||
"[ 13/24 ⇜ (5/8 → 2/3) | s:hh ]",
|
||||
"[ (2/3 → 3/4) ⇝ 19/24 | s:hh ]",
|
||||
"[ 2/3 → 19/24 | s:hh ]",
|
||||
"[ 3/4 → 7/8 | s:hh ]",
|
||||
"[ 19/24 ⇜ (7/8 → 11/12) | s:hh ]",
|
||||
"[ (11/12 → 1/1) ⇝ 25/24 | s:hh ]",
|
||||
"[ 11/12 → 25/24 | s:hh ]",
|
||||
"[ 1/1 → 9/8 | s:hh ]",
|
||||
"[ 25/24 ⇜ (9/8 → 7/6) | s:hh ]",
|
||||
"[ (7/6 → 5/4) ⇝ 31/24 | s:hh ]",
|
||||
"[ 7/6 → 31/24 | s:hh ]",
|
||||
"[ 5/4 → 11/8 | s:hh ]",
|
||||
"[ 31/24 ⇜ (11/8 → 17/12) | s:hh ]",
|
||||
"[ (17/12 → 3/2) ⇝ 37/24 | s:hh ]",
|
||||
"[ 17/12 → 37/24 | s:hh ]",
|
||||
"[ 3/2 → 13/8 | s:hh ]",
|
||||
"[ 37/24 ⇜ (13/8 → 5/3) | s:hh ]",
|
||||
"[ (5/3 → 7/4) ⇝ 43/24 | s:hh ]",
|
||||
"[ 5/3 → 43/24 | s:hh ]",
|
||||
"[ 7/4 → 15/8 | s:hh ]",
|
||||
"[ 43/24 ⇜ (15/8 → 23/12) | s:hh ]",
|
||||
"[ (23/12 → 2/1) ⇝ 49/24 | s:hh ]",
|
||||
"[ 23/12 → 49/24 | s:hh ]",
|
||||
"[ 2/1 → 17/8 | s:hh ]",
|
||||
"[ 49/24 ⇜ (17/8 → 13/6) | s:hh ]",
|
||||
"[ (13/6 → 9/4) ⇝ 55/24 | s:hh ]",
|
||||
"[ 13/6 → 55/24 | s:hh ]",
|
||||
"[ 9/4 → 19/8 | s:hh ]",
|
||||
"[ 55/24 ⇜ (19/8 → 29/12) | s:hh ]",
|
||||
"[ (29/12 → 5/2) ⇝ 61/24 | s:hh ]",
|
||||
"[ 29/12 → 61/24 | s:hh ]",
|
||||
"[ 5/2 → 21/8 | s:hh ]",
|
||||
"[ 61/24 ⇜ (21/8 → 8/3) | s:hh ]",
|
||||
"[ (8/3 → 11/4) ⇝ 67/24 | s:hh ]",
|
||||
"[ 8/3 → 67/24 | s:hh ]",
|
||||
"[ 11/4 → 23/8 | s:hh ]",
|
||||
"[ 67/24 ⇜ (23/8 → 35/12) | s:hh ]",
|
||||
"[ (35/12 → 3/1) ⇝ 73/24 | s:hh ]",
|
||||
"[ 35/12 → 73/24 | s:hh ]",
|
||||
"[ 3/1 → 25/8 | s:hh ]",
|
||||
"[ 73/24 ⇜ (25/8 → 19/6) | s:hh ]",
|
||||
"[ (19/6 → 13/4) ⇝ 79/24 | s:hh ]",
|
||||
"[ 19/6 → 79/24 | s:hh ]",
|
||||
"[ 13/4 → 27/8 | s:hh ]",
|
||||
"[ 79/24 ⇜ (27/8 → 41/12) | s:hh ]",
|
||||
"[ (41/12 → 7/2) ⇝ 85/24 | s:hh ]",
|
||||
"[ 41/12 → 85/24 | s:hh ]",
|
||||
"[ 7/2 → 29/8 | s:hh ]",
|
||||
"[ 85/24 ⇜ (29/8 → 11/3) | s:hh ]",
|
||||
"[ (11/3 → 15/4) ⇝ 91/24 | s:hh ]",
|
||||
"[ 11/3 → 91/24 | s:hh ]",
|
||||
"[ 15/4 → 31/8 | s:hh ]",
|
||||
"[ 91/24 ⇜ (31/8 → 47/12) | s:hh ]",
|
||||
"[ (47/12 → 4/1) ⇝ 97/24 | s:hh ]",
|
||||
]
|
||||
`;
|
||||
@@ -15853,7 +16221,30 @@ exports[`runs examples > example "when" example index 0 1`] = `
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "whenKey" example index 0 1`] = `[]`;
|
||||
exports[`runs examples > example "whenKey" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/8 | s:bd ]",
|
||||
"[ 1/4 → 3/8 | s:bd ]",
|
||||
"[ 3/8 → 1/2 | s:bd ]",
|
||||
"[ 5/8 → 3/4 | s:bd ]",
|
||||
"[ 3/4 → 7/8 | s:bd ]",
|
||||
"[ 1/1 → 9/8 | s:bd ]",
|
||||
"[ 5/4 → 11/8 | s:bd ]",
|
||||
"[ 11/8 → 3/2 | s:bd ]",
|
||||
"[ 13/8 → 7/4 | s:bd ]",
|
||||
"[ 7/4 → 15/8 | s:bd ]",
|
||||
"[ 2/1 → 17/8 | s:bd ]",
|
||||
"[ 9/4 → 19/8 | s:bd ]",
|
||||
"[ 19/8 → 5/2 | s:bd ]",
|
||||
"[ 21/8 → 11/4 | s:bd ]",
|
||||
"[ 11/4 → 23/8 | s:bd ]",
|
||||
"[ 3/1 → 25/8 | s:bd ]",
|
||||
"[ 13/4 → 27/8 | s:bd ]",
|
||||
"[ 27/8 → 7/2 | s:bd ]",
|
||||
"[ 29/8 → 15/4 | s:bd ]",
|
||||
"[ 15/4 → 31/8 | s:bd ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "withBase" example index 0 1`] = `
|
||||
[
|
||||
|
||||
@@ -31,7 +31,7 @@ describe('runs examples', () => {
|
||||
}
|
||||
doc.examples?.forEach((example, i) => {
|
||||
it(`example "${doc.name}" example index ${i}`, async ({ expect }) => {
|
||||
const haps = await queryCode(example, 4);
|
||||
const haps = await queryCode(example, 4, true);
|
||||
expect(haps).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
+2
-2
@@ -182,9 +182,9 @@ evalScope(
|
||||
);
|
||||
|
||||
// TBD: use transpiler to support labeled statements
|
||||
export const queryCode = async (code, cycles = 1) => {
|
||||
export const queryCode = async (code, cycles = 1, propagateExceptions = false) => {
|
||||
const { pattern } = await evaluate(code);
|
||||
const haps = pattern.sortHapsByPart().queryArc(0, cycles);
|
||||
const haps = pattern.sortHapsByPart().queryArc(0, cycles, { propagateExceptions });
|
||||
return haps.map((h) => h.show(true));
|
||||
};
|
||||
|
||||
|
||||
+561
-176
File diff suppressed because it is too large
Load Diff
@@ -65,7 +65,7 @@ export default defineConfig({
|
||||
tailwind(),
|
||||
AstroPWA({
|
||||
experimental: { directoryAndTrailingSlashHandler: true },
|
||||
registerType: 'autoUpdate',
|
||||
registerType: 'prompt', // see pwa.ts
|
||||
injectRegister: 'auto',
|
||||
workbox: {
|
||||
maximumFileSizeToCacheInBytes: 4194304, // 4MB
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
"@strudel/websocket": "workspace:*",
|
||||
"@strudel/mondo": "workspace:*",
|
||||
"@strudel/xen": "workspace:*",
|
||||
"@strudel/kabelsalat": "workspace:*",
|
||||
"@supabase/supabase-js": "^2.48.1",
|
||||
"@tailwindcss/forms": "^0.5.10",
|
||||
"@tailwindcss/postcss": "^4.0.0",
|
||||
|
||||
+63
-17
@@ -2,20 +2,23 @@ import jsdoc from '../../../doc.json'; // doc.json is built with `npm run jsdoc-
|
||||
const docs = jsdoc.docs.reduce((acc, obj) => Object.assign(acc, { [obj.longname]: obj }), {});
|
||||
import { MiniRepl } from './MiniRepl';
|
||||
|
||||
export function JsDoc({ name, h = 3, hideDescription, punchcard, canvasHeight }) {
|
||||
/**
|
||||
*
|
||||
* @param {Object} arguments
|
||||
* @param {number} [arguments.h] Adds a heading (like 3 for h3). Deprecated, add the heading in MDX instead.
|
||||
* @returns
|
||||
*/
|
||||
export function JsDoc({ name, h = undefined, hideDescription, punchcard, canvasHeight, hideMiniRepl }) {
|
||||
const item = docs[name];
|
||||
if (!item) {
|
||||
console.warn('Not found: ' + name);
|
||||
return <div />;
|
||||
console.warn(`JsDoc for ${name} not found`);
|
||||
return <div>Could not load docs for ${name}</div>;
|
||||
}
|
||||
const CustomHeading = `h${h}`;
|
||||
const description =
|
||||
item.description?.replaceAll(/\{@link ([a-zA-Z\.]+)?#?([a-zA-Z]*)\}/g, (_, a, b) => {
|
||||
return `<a href="#${a.replaceAll('.', '').toLowerCase()}${b ? `-${b}` : ''}">${a}${b ? `#${b}` : ''}</a>`;
|
||||
}) || '';
|
||||
const CustomHeading = h ? `h${h}` : undefined;
|
||||
const description = parseAndReplaceLink(item.description ?? '');
|
||||
return (
|
||||
<>
|
||||
{!!h && <CustomHeading>{item.longname}</CustomHeading>}
|
||||
{!!h && <CustomHeading id={name}>{item.longname}</CustomHeading>}
|
||||
{!hideDescription && (
|
||||
<>
|
||||
{!!item.synonyms_text && (
|
||||
@@ -26,19 +29,43 @@ export function JsDoc({ name, h = 3, hideDescription, punchcard, canvasHeight })
|
||||
<div dangerouslySetInnerHTML={{ __html: description }} />
|
||||
</>
|
||||
)}
|
||||
{item.params && item.params.length > 0 && <p className="font-bold">Arguments</p>}
|
||||
<ul>
|
||||
{item.params?.map((param, i) => (
|
||||
<li key={i}>
|
||||
{param.name} ({param.type?.names?.join('|')}): {param.description?.replace(/(<([^>]+)>)/gi, '')}
|
||||
</li>
|
||||
))}
|
||||
{item.params?.map(({ name, type, description }, i) => {
|
||||
// Check if the param is actually the parameter of an object
|
||||
const objParamSeperator = name.indexOf('.');
|
||||
const isObjectParam = objParamSeperator !== -1;
|
||||
|
||||
return (
|
||||
<li key={i} className={isObjectParam ? 'list-none' : ''}>
|
||||
{isObjectParam ? name.substring(objParamSeperator + 1) : name} : {type?.names?.join(' | ')}{' '}
|
||||
{description ? <> - {removeHtmlTags(description)}</> : ''}
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
{item.returns && (
|
||||
<p>
|
||||
<span className="font-bold">Returns</span>{' '}
|
||||
{item.returns
|
||||
.map((returnValue) => {
|
||||
const description = returnValue.description ? `- ${removeHtmlTags(returnValue.description)}` : '';
|
||||
return `${returnValue.type?.names?.join(' | ')} ${description}`;
|
||||
})
|
||||
.join(' or ')}
|
||||
</p>
|
||||
)}
|
||||
|
||||
{item.examples?.length ? (
|
||||
<div className="space-y-2">
|
||||
{item.examples?.map((example, k) => (
|
||||
<MiniRepl tune={example} key={k} {...{ punchcard, canvasHeight }} />
|
||||
))}
|
||||
{item.examples?.map((example, k) => {
|
||||
const key = `${item.longname}_example_${k}`;
|
||||
return hideMiniRepl ? (
|
||||
<pre key={key}>{example}</pre>
|
||||
) : (
|
||||
<MiniRepl tune={example} key={key} {...{ punchcard, canvasHeight }} />
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
) : (
|
||||
<div />
|
||||
@@ -46,3 +73,22 @@ export function JsDoc({ name, h = 3, hideDescription, punchcard, canvasHeight })
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the jsDocs link with something else.
|
||||
* @param {string} string
|
||||
* @param {(name:string,longname: string) => string} [replaceWith]
|
||||
*/
|
||||
export const parseAndReplaceLink = (string, replaceWith) => {
|
||||
const jsDocsLinkRegex = /\{@link ([a-zA-Z\.#]+)\}/g;
|
||||
const fun = replaceWith ?? ((name, longname) => `<a target="_blank" href="/reference#${longname}">${name}</a>`);
|
||||
|
||||
return string
|
||||
.replaceAll(/<a href="https:\/\//g, `<a target="_blank" href="https://`)
|
||||
.replaceAll(jsDocsLinkRegex, (_, longname) => {
|
||||
const name = [...longname.matchAll(/[a-zA-Z]+[\.#]([a-zA-Z]+)/g)].at(0)?.at(1); //take the string after . or #
|
||||
return fun(name ?? longname, longname);
|
||||
});
|
||||
};
|
||||
|
||||
const removeHtmlTags = (string) => string.replace(/(<([^>]+)>)/gi, '');
|
||||
|
||||
@@ -10,11 +10,15 @@ import { loadModules, setVersionDefaultsFrom } from '../repl/util.mjs';
|
||||
import Claviature from '@components/Claviature';
|
||||
import useClient from '@src/useClient.mjs';
|
||||
|
||||
let prebaked, modulesLoading, audioReady;
|
||||
if (typeof window !== 'undefined') {
|
||||
prebaked = prebake();
|
||||
modulesLoading = loadModules();
|
||||
audioReady = initAudioOnFirstClick();
|
||||
let prebaked, modulesLoading, audioReady, initicated;
|
||||
|
||||
export function initMiniRepl() {
|
||||
if (typeof window !== 'undefined' && !initicated) {
|
||||
prebaked = prebake();
|
||||
modulesLoading = loadModules();
|
||||
audioReady = initAudioOnFirstClick();
|
||||
initicated = true;
|
||||
}
|
||||
}
|
||||
|
||||
export function MiniRepl({
|
||||
@@ -44,6 +48,7 @@ export function MiniRepl({
|
||||
const [activeNotes, setActiveNotes] = useState([]);
|
||||
|
||||
const init = useCallback(({ code, autodraw }) => {
|
||||
initMiniRepl();
|
||||
const drawContext = canvasId ? document.querySelector('#' + canvasId)?.getContext('2d') : getDrawContext();
|
||||
|
||||
const editor = new StrudelMirror({
|
||||
@@ -85,7 +90,7 @@ export function MiniRepl({
|
||||
}
|
||||
},
|
||||
beforeStart: () => audioReady,
|
||||
afterEval: ({ code }) => setVersionDefaultsFrom(code),
|
||||
beforeEval: ({ code }) => setVersionDefaultsFrom(code),
|
||||
mondo,
|
||||
});
|
||||
// init settings
|
||||
|
||||
+66
-66
@@ -1,67 +1,68 @@
|
||||
export const examples = [
|
||||
`// "coastline" @by eddyflux
|
||||
// @version 1.0
|
||||
samples('github:eddyflux/crate')
|
||||
setcps(.75)
|
||||
let chords = chord("<Bbm9 Fm9>/4").dict('ireal')
|
||||
stack(
|
||||
stack( // DRUMS
|
||||
s("bd").struct("<[x*<1 2> [~@3 x]] x>"),
|
||||
s("~ [rim, sd:<2 3>]").room("<0 .2>"),
|
||||
n("[0 <1 3>]*<2!3 4>").s("hh"),
|
||||
s("rd:<1!3 2>*2").mask("<0 0 1 1>/16").gain(.5)
|
||||
).bank('crate')
|
||||
.mask("<[0 1] 1 1 1>/16".early(.5))
|
||||
, // CHORDS
|
||||
chords.offset(-1).voicing().s("gm_epiano1:1")
|
||||
.phaser(4).room(.5)
|
||||
, // MELODY
|
||||
n("<0!3 1*2>").set(chords).mode("root:g2")
|
||||
.voicing().s("gm_acoustic_bass"),
|
||||
chords.n("[0 <4 3 <2 5>>*2](<3 5>,8)")
|
||||
.anchor("D5").voicing()
|
||||
.segment(4).clip(rand.range(.4,.8))
|
||||
.room(.75).shape(.3).delay(.25)
|
||||
.fm(sine.range(3,8).slow(8))
|
||||
.lpf(sine.range(500,1000).slow(8)).lpq(5)
|
||||
.rarely(ply("2")).chunk(4, fast(2))
|
||||
.gain(perlin.range(.6, .9))
|
||||
.mask("<0 1 1 0>/16")
|
||||
)
|
||||
.late("[0 .01]*4").late("[0 .01]*2").size(4)`,
|
||||
// @version 1.0
|
||||
samples('github:eddyflux/crate')
|
||||
setcps(.75)
|
||||
let chords = chord("<Bbm9 Fm9>/4").dict('ireal')
|
||||
|
||||
// DRUMS
|
||||
$: stack(
|
||||
s("bd").struct("<[x*<1 2> [~@3 x]] x>"),
|
||||
s("~ [rim, sd:<2 3>]").room("<0 .2>"),
|
||||
n("[0 <1 3>]*<2!3 4>").s("hh"),
|
||||
s("rd:<1!3 2>*2").mask("<0 0 1 1>/16").gain(.5)
|
||||
).bank('crate')
|
||||
.mask("<[0 1] 1 1 1>/16".early(.5))
|
||||
// CHORDS
|
||||
$: chords.offset(-1).voicing().s("gm_epiano1:1")
|
||||
.phaser(4).room(.5)
|
||||
// BASS
|
||||
$: n("<0!3 1*2>").set(chords).mode("root:g1")
|
||||
.voicing().s("gm_acoustic_bass")
|
||||
// MELODY
|
||||
$: chords.n("[0 <4 3 <2 5>>*2](<3 5>,8)")
|
||||
.anchor("D5").voicing()
|
||||
.segment(4).clip(rand.range(.4,.8))
|
||||
.room(.75).shape(.3).delay(.25)
|
||||
.fm(sine.range(3,8).slow(8))
|
||||
.lpf(sine.range(500,1000).slow(8)).lpq(5)
|
||||
.rarely(ply("2")).chunk(4, fast(2))
|
||||
.gain(perlin.range(.6, .9))
|
||||
.mask("<0 1 1 0>/16")
|
||||
// swing everything
|
||||
all(x=>x.late("[0 .01]*4").late("[0 .01]*2").size(4))`,
|
||||
`// "broken cut 1" @by froos
|
||||
// @version 1.0
|
||||
|
||||
samples('github:tidalcycles/dirt-samples')
|
||||
samples({
|
||||
'slap': 'https://cdn.freesound.org/previews/495/495416_10350281-lq.mp3',
|
||||
'whirl': 'https://cdn.freesound.org/previews/495/495313_10350281-lq.mp3',
|
||||
'attack': 'https://cdn.freesound.org/previews/494/494947_10350281-lq.mp3'
|
||||
})
|
||||
|
||||
setcps(1.25)
|
||||
|
||||
note("[c2 ~](3,8)*2,eb,g,bb,d").s("sawtooth")
|
||||
.noise(0.3)
|
||||
.lpf(perlin.range(800,2000).mul(0.6))
|
||||
.lpenv(perlin.range(1,5)).lpa(.25).lpd(.1).lps(0)
|
||||
.add.mix(note("<0!3 [1 <4!3 12>]>")).late(.5)
|
||||
.vib("4:.2")
|
||||
.room(1).roomsize(4).slow(4)
|
||||
.stack(
|
||||
s("bd").late("<0.01 .251>"),
|
||||
s("breaks165:1/2").fit()
|
||||
.chop(4).sometimesBy(.4, ply("2"))
|
||||
.sometimesBy(.1, ply("4")).release(.01)
|
||||
.gain(1.5).sometimes(mul(speed("1.05"))).cut(1)
|
||||
,
|
||||
s("<whirl attack>?").delay(".8:.1:.8").room(2).slow(8).cut(2),
|
||||
).reset("<x@30 [x*[8 [8 [16 32]]]]@2>".late(2))`,
|
||||
// @version 1.0
|
||||
|
||||
samples('github:tidalcycles/dirt-samples')
|
||||
samples({
|
||||
'slap': 'https://cdn.freesound.org/previews/495/495416_10350281-lq.mp3',
|
||||
'whirl': 'https://cdn.freesound.org/previews/495/495313_10350281-lq.mp3',
|
||||
'attack': 'https://cdn.freesound.org/previews/494/494947_10350281-lq.mp3'
|
||||
})
|
||||
|
||||
setcps(1.25)
|
||||
|
||||
$: note("[c2 ~](3,8)*2,eb,g,bb,d").s("sawtooth")
|
||||
.noise(0.3)
|
||||
.lpf(perlin.range(300,800).mul(0.6)).lpq(10)
|
||||
.lpenv(perlin.range(1,5)).lpa(.25).lpd(.1).lps(0)
|
||||
.add.mix(note("<0!3 [1 <4!3 12>]>")).late(.5)
|
||||
.vib("4:.2")
|
||||
.room(1).roomsize(4).slow(4)
|
||||
$: s("bd").late("<0.01 .251>")
|
||||
$: s("breaks165:1/2").fit()
|
||||
.chop(4).sometimesBy(.4, ply("2"))
|
||||
.sometimesBy(.1, ply("4")).release(.01)
|
||||
.gain(1.5).sometimes(mul(speed("1.05"))).cut(1)
|
||||
|
||||
$: s("<whirl attack>?").delay(".8:.1:.8").room(2).slow(8).cut(2)
|
||||
all(x=>x.reset("<x@30 [x*[8 [8 [16 32]]]]@2>".late(2)))`,
|
||||
`// "acidic tooth" @by eddyflux
|
||||
// @version 1.0
|
||||
// @version 1.0
|
||||
setcps(1)
|
||||
stack(
|
||||
note("[<g1 f1>/8](<3 5>,8)")
|
||||
|
||||
$: note("[<g1 f1>/8](<3 5>,8)")
|
||||
.clip(perlin.range(.15,1.5))
|
||||
.release(.1)
|
||||
.s("sawtooth")
|
||||
@@ -74,11 +75,10 @@ note("[c2 ~](3,8)*2,eb,g,bb,d").s("sawtooth")
|
||||
.room(.2).shape(.3).postgain(.5)
|
||||
.superimpose(x=>x.add(note(12)).delay(.5).bpf(1000))
|
||||
.gain("[.2 1@3]*2") // fake sidechain
|
||||
,
|
||||
stack(
|
||||
s("bd*2").mask("<0@4 1@16>"),
|
||||
s("hh*8").gain(saw.mul(saw.fast(2))).clip(sine)
|
||||
.mask("<0@8 1@16>")
|
||||
).bank('RolandTR909')
|
||||
)`,
|
||||
|
||||
$: stack(
|
||||
s("bd*2").mask("<0@4 1@16>"),
|
||||
s("hh*8").gain(saw.mul(saw.fast(2))).clip(sine)
|
||||
.mask("<0@8 1@16>")
|
||||
).bank('RolandTR909')`,
|
||||
];
|
||||
|
||||
@@ -134,7 +134,7 @@ This group of functions allows to modify the value of events.
|
||||
|
||||
## as
|
||||
|
||||
<JsDoc client:idle name="as" h={0} />
|
||||
<JsDoc client:idle name="Pattern#as" h={0} />
|
||||
|
||||
# Custom Parameters
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import { JsDoc } from '../../docs/JsDoc';
|
||||
|
||||
## echoWith
|
||||
|
||||
<JsDoc client:idle name="echoWith" h={0} />
|
||||
<JsDoc client:idle name="Pattern#echoWith" h={0} />
|
||||
|
||||
## stut
|
||||
|
||||
|
||||
@@ -34,11 +34,11 @@ import { JsDoc } from '../../docs/JsDoc';
|
||||
|
||||
## arp
|
||||
|
||||
<JsDoc client:idle name="arp" h={0} />
|
||||
<JsDoc client:idle name="Pattern#arp" h={0} />
|
||||
|
||||
## arpWith 🧪
|
||||
|
||||
<JsDoc client:idle name="arpWith" h={0} />
|
||||
<JsDoc client:idle name="Pattern#arpWith" h={0} />
|
||||
|
||||
## struct
|
||||
|
||||
@@ -62,47 +62,47 @@ import { JsDoc } from '../../docs/JsDoc';
|
||||
|
||||
## invert
|
||||
|
||||
<JsDoc client:idle name="invert" h={0} />
|
||||
<JsDoc client:idle name="Pattern#invert" h={0} />
|
||||
|
||||
## pick
|
||||
|
||||
<JsDoc client:idle name="pick" h={0} />
|
||||
<JsDoc client:idle name="Pattern#pick" h={0} />
|
||||
|
||||
## pickmod
|
||||
|
||||
<JsDoc client:idle name="pickmod" h={0} />
|
||||
<JsDoc client:idle name="Pattern#pickmod" h={0} />
|
||||
|
||||
## pickF
|
||||
|
||||
<JsDoc client:idle name="pickF" h={0} />
|
||||
<JsDoc client:idle name="Pattern#pickF" h={0} />
|
||||
|
||||
## pickmodF
|
||||
|
||||
<JsDoc client:idle name="pickmodF" h={0} />
|
||||
<JsDoc client:idle name="Pattern#pickmodF" h={0} />
|
||||
|
||||
## pickRestart
|
||||
|
||||
<JsDoc client:idle name="pickRestart" h={0} />
|
||||
<JsDoc client:idle name="Pattern#pickRestart" h={0} />
|
||||
|
||||
## pickmodRestart
|
||||
|
||||
<JsDoc client:idle name="pickmodRestart" h={0} />
|
||||
<JsDoc client:idle name="Pattern#pickmodRestart" h={0} />
|
||||
|
||||
## pickReset
|
||||
|
||||
<JsDoc client:idle name="pickReset" h={0} />
|
||||
<JsDoc client:idle name="Pattern#pickReset" h={0} />
|
||||
|
||||
## pickmodReset
|
||||
|
||||
<JsDoc client:idle name="pickmodReset" h={0} />
|
||||
<JsDoc client:idle name="Pattern#pickmodReset" h={0} />
|
||||
|
||||
## inhabit
|
||||
|
||||
<JsDoc client:idle name="inhabit" h={0} />
|
||||
<JsDoc client:idle name="Pattern#inhabit" h={0} />
|
||||
|
||||
## inhabitmod
|
||||
|
||||
<JsDoc client:idle name="inhabitmod" h={0} />
|
||||
<JsDoc client:idle name="Pattern#inhabitmod" h={0} />
|
||||
|
||||
## squeeze
|
||||
|
||||
|
||||
@@ -150,35 +150,35 @@ Each filter has 2 parameters:
|
||||
|
||||
## lpf
|
||||
|
||||
<JsDoc client:idle name="lpf" h={0} />
|
||||
<JsDoc client:idle name="Pattern#lpf" h={0} />
|
||||
|
||||
## lpq
|
||||
|
||||
<JsDoc client:idle name="lpq" h={0} />
|
||||
<JsDoc client:idle name="Pattern#lpq" h={0} />
|
||||
|
||||
## hpf
|
||||
|
||||
<JsDoc client:idle name="hpf" h={0} />
|
||||
<JsDoc client:idle name="Pattern#hpf" h={0} />
|
||||
|
||||
## hpq
|
||||
|
||||
<JsDoc client:idle name="hpq" h={0} />
|
||||
<JsDoc client:idle name="Pattern#hpq" h={0} />
|
||||
|
||||
## bpf
|
||||
|
||||
<JsDoc client:idle name="bpf" h={0} />
|
||||
<JsDoc client:idle name="Pattern#bpf" h={0} />
|
||||
|
||||
## bpq
|
||||
|
||||
<JsDoc client:idle name="bpq" h={0} />
|
||||
<JsDoc client:idle name="Pattern#bpq" h={0} />
|
||||
|
||||
## ftype
|
||||
|
||||
<JsDoc client:idle name="ftype" h={0} />
|
||||
<JsDoc client:idle name="Pattern#ftype" h={0} />
|
||||
|
||||
## vowel
|
||||
|
||||
<JsDoc client:idle name="vowel" h={0} />
|
||||
<JsDoc client:idle name="Pattern#vowel" h={0} />
|
||||
|
||||
# Amplitude Modulation
|
||||
|
||||
@@ -186,27 +186,27 @@ Amplitude modulation changes the amplitude (gain) periodically over time.
|
||||
|
||||
## tremolo
|
||||
|
||||
<JsDoc client:idle name="tremolo" h={0} />
|
||||
<JsDoc client:idle name="Pattern#tremolo" h={0} />
|
||||
|
||||
## tremolosync
|
||||
|
||||
<JsDoc client:idle name="tremolosync" h={0} />
|
||||
<JsDoc client:idle name="Pattern#tremolosync" h={0} />
|
||||
|
||||
## tremolodepth
|
||||
|
||||
<JsDoc client:idle name="tremolodepth" h={0} />
|
||||
<JsDoc client:idle name="Pattern#tremolodepth" h={0} />
|
||||
|
||||
## tremoloskew
|
||||
|
||||
<JsDoc client:idle name="tremoloskew" h={0} />
|
||||
<JsDoc client:idle name="Pattern#tremoloskew" h={0} />
|
||||
|
||||
## tremolophase
|
||||
|
||||
<JsDoc client:idle name="tremolophase" h={0} />
|
||||
<JsDoc client:idle name="Pattern#tremolophase" h={0} />
|
||||
|
||||
## tremoloshape
|
||||
|
||||
<JsDoc client:idle name="tremoloshape" h={0} />
|
||||
<JsDoc client:idle name="Pattern#tremoloshape" h={0} />
|
||||
|
||||
# Amplitude Envelope
|
||||
|
||||
@@ -219,23 +219,23 @@ Strudel uses ADSR envelopes, which are probably the most common way to describe
|
||||
|
||||
## attack
|
||||
|
||||
<JsDoc client:idle name="attack" h={0} />
|
||||
<JsDoc client:idle name="Pattern#attack" h={0} />
|
||||
|
||||
## decay
|
||||
|
||||
<JsDoc client:idle name="decay" h={0} />
|
||||
<JsDoc client:idle name="Pattern#decay" h={0} />
|
||||
|
||||
## sustain
|
||||
|
||||
<JsDoc client:idle name="sustain" h={0} />
|
||||
<JsDoc client:idle name="Pattern#sustain" h={0} />
|
||||
|
||||
## release
|
||||
|
||||
<JsDoc client:idle name="release" h={0} />
|
||||
<JsDoc client:idle name="Pattern#release" h={0} />
|
||||
|
||||
## adsr
|
||||
|
||||
<JsDoc client:idle name="adsr" h={0} />
|
||||
<JsDoc client:idle name="Pattern#adsr" h={0} />
|
||||
|
||||
# Filter Envelope
|
||||
|
||||
@@ -271,23 +271,23 @@ There is one filter envelope for each filter type and thus one set of envelope f
|
||||
|
||||
## lpattack
|
||||
|
||||
<JsDoc client:idle name="lpattack" h={0} />
|
||||
<JsDoc client:idle name="Pattern#lpattack" h={0} />
|
||||
|
||||
## lpdecay
|
||||
|
||||
<JsDoc client:idle name="lpdecay" h={0} />
|
||||
<JsDoc client:idle name="Pattern#lpdecay" h={0} />
|
||||
|
||||
## lpsustain
|
||||
|
||||
<JsDoc client:idle name="lpsustain" h={0} />
|
||||
<JsDoc client:idle name="Pattern#lpsustain" h={0} />
|
||||
|
||||
## lprelease
|
||||
|
||||
<JsDoc client:idle name="lprelease" h={0} />
|
||||
<JsDoc client:idle name="Pattern#lprelease" h={0} />
|
||||
|
||||
## lpenv
|
||||
|
||||
<JsDoc client:idle name="lpenv" h={0} />
|
||||
<JsDoc client:idle name="Pattern#lpenv" h={0} />
|
||||
|
||||
# Pitch Envelope
|
||||
|
||||
@@ -321,45 +321,45 @@ Let's break down all pitch envelope controls:
|
||||
|
||||
## pattack
|
||||
|
||||
<JsDoc client:idle name="pattack" h={0} />
|
||||
<JsDoc client:idle name="Pattern#pattack" h={0} />
|
||||
|
||||
## pdecay
|
||||
|
||||
<JsDoc client:idle name="pdecay" h={0} />
|
||||
<JsDoc client:idle name="Pattern#pdecay" h={0} />
|
||||
|
||||
## prelease
|
||||
|
||||
<JsDoc client:idle name="prelease" h={0} />
|
||||
<JsDoc client:idle name="Pattern#prelease" h={0} />
|
||||
|
||||
## penv
|
||||
|
||||
<JsDoc client:idle name="penv" h={0} />
|
||||
<JsDoc client:idle name="Pattern#penv" h={0} />
|
||||
|
||||
## pcurve
|
||||
|
||||
<JsDoc client:idle name="pcurve" h={0} />
|
||||
<JsDoc client:idle name="Pattern#pcurve" h={0} />
|
||||
|
||||
## panchor
|
||||
|
||||
<JsDoc client:idle name="panchor" h={0} />
|
||||
<JsDoc client:idle name="Pattern#panchor" h={0} />
|
||||
|
||||
# Dynamics
|
||||
|
||||
## gain
|
||||
|
||||
<JsDoc client:idle name="gain" h={0} />
|
||||
<JsDoc client:idle name="Pattern#gain" h={0} />
|
||||
|
||||
## velocity
|
||||
|
||||
<JsDoc client:idle name="velocity" h={0} />
|
||||
<JsDoc client:idle name="Pattern#velocity" h={0} />
|
||||
|
||||
## compressor
|
||||
|
||||
<JsDoc client:idle name="compressor" h={0} />
|
||||
<JsDoc client:idle name="Pattern#compressor" h={0} />
|
||||
|
||||
## postgain
|
||||
|
||||
<JsDoc client:idle name="postgain" h={0} />
|
||||
<JsDoc client:idle name="Pattern#postgain" h={0} />
|
||||
|
||||
## xfade
|
||||
|
||||
@@ -377,21 +377,21 @@ Let's break down all pitch envelope controls:
|
||||
|
||||
## pan
|
||||
|
||||
<JsDoc client:idle name="pan" h={0} />
|
||||
<JsDoc client:idle name="Pattern#pan" h={0} />
|
||||
|
||||
# Waveshaping
|
||||
|
||||
## coarse
|
||||
|
||||
<JsDoc client:idle name="coarse" h={0} />
|
||||
<JsDoc client:idle name="Pattern#coarse" h={0} />
|
||||
|
||||
## crush
|
||||
|
||||
<JsDoc client:idle name="crush" h={0} />
|
||||
<JsDoc client:idle name="Pattern#crush" h={0} />
|
||||
|
||||
## distort
|
||||
|
||||
<JsDoc client:idle name="distort" h={0} />
|
||||
<JsDoc client:idle name="Pattern#distort" h={0} />
|
||||
|
||||
# Global Effects
|
||||
|
||||
@@ -402,78 +402,78 @@ global effects use the same chain for all events of the same orbit:
|
||||
|
||||
## orbit
|
||||
|
||||
<JsDoc client:idle name="orbit" h={0} />
|
||||
<JsDoc client:idle name="Pattern#orbit" h={0} />
|
||||
|
||||
## Delay
|
||||
|
||||
### delay
|
||||
|
||||
<JsDoc client:idle name="delay" h={0} />
|
||||
<JsDoc client:idle name="Pattern#delay" h={0} />
|
||||
|
||||
### delaytime
|
||||
|
||||
<JsDoc client:idle name="delaytime" h={0} />
|
||||
<JsDoc client:idle name="Pattern#delaytime" h={0} />
|
||||
|
||||
### delayfeedback
|
||||
|
||||
<JsDoc client:idle name="delayfeedback" h={0} />
|
||||
<JsDoc client:idle name="Pattern#delayfeedback" h={0} />
|
||||
|
||||
## Reverb
|
||||
|
||||
### room
|
||||
|
||||
<JsDoc client:idle name="room" h={0} />
|
||||
<JsDoc client:idle name="Pattern#room" h={0} />
|
||||
|
||||
### roomsize
|
||||
|
||||
<JsDoc client:idle name="roomsize" h={0} />
|
||||
<JsDoc client:idle name="Pattern#roomsize" h={0} />
|
||||
|
||||
### roomfade
|
||||
|
||||
<JsDoc client:idle name="roomfade" h={0} />
|
||||
<JsDoc client:idle name="Pattern#roomfade" h={0} />
|
||||
|
||||
### roomlp
|
||||
|
||||
<JsDoc client:idle name="roomlp" h={0} />
|
||||
<JsDoc client:idle name="Pattern#roomlp" h={0} />
|
||||
|
||||
### roomdim
|
||||
|
||||
<JsDoc client:idle name="roomdim" h={0} />
|
||||
<JsDoc client:idle name="Pattern#roomdim" h={0} />
|
||||
|
||||
### iresponse
|
||||
|
||||
<JsDoc client:idle name="iresponse" h={0} />
|
||||
<JsDoc client:idle name="Pattern#iresponse" h={0} />
|
||||
|
||||
## Phaser
|
||||
|
||||
### phaser
|
||||
|
||||
<JsDoc client:idle name="phaser" h={0} />
|
||||
<JsDoc client:idle name="Pattern#phaser" h={0} />
|
||||
|
||||
### phaserdepth
|
||||
|
||||
<JsDoc client:idle name="phaserdepth" h={0} />
|
||||
<JsDoc client:idle name="Pattern#phaserdepth" h={0} />
|
||||
|
||||
### phasercenter
|
||||
|
||||
<JsDoc client:idle name="phasercenter" h={0} />
|
||||
<JsDoc client:idle name="Pattern#phasercenter" h={0} />
|
||||
|
||||
### phasersweep
|
||||
|
||||
<JsDoc client:idle name="phasersweep" h={0} />
|
||||
<JsDoc client:idle name="Pattern#phasersweep" h={0} />
|
||||
|
||||
## Duck
|
||||
|
||||
### duckorbit
|
||||
|
||||
<JsDoc client:idle name="duckorbit" h={0} />
|
||||
<JsDoc client:idle name="Pattern#duckorbit" h={0} />
|
||||
|
||||
### duckattack
|
||||
|
||||
<JsDoc client:idle name="duckattack" h={0} />
|
||||
<JsDoc client:idle name="Pattern#duckattack" h={0} />
|
||||
|
||||
### duckdepth
|
||||
|
||||
<JsDoc client:idle name="duckdepth" h={0} />
|
||||
<JsDoc client:idle name="Pattern#duckdepth" h={0} />
|
||||
|
||||
Next, we'll look at input / output via [MIDI, OSC and other methods](/learn/input-output).
|
||||
|
||||
@@ -30,7 +30,7 @@ These are the equivalents used by the Mini Notation:
|
||||
|
||||
## stack
|
||||
|
||||
<JsDoc client:idle name="stack" h={0} />
|
||||
<JsDoc client:idle name="Pattern#stack" h={0} />
|
||||
|
||||
## stepcat
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ $: midiport('IAC Driver');
|
||||
$: note('c a f e').midiport('<0 1 2 3>').midi();
|
||||
```
|
||||
|
||||
<JsDoc client:idle name="midiport" h={0} />
|
||||
<JsDoc client:idle name="Pattern#midiport" h={0} />
|
||||
|
||||
## midichan(number)
|
||||
|
||||
|
||||
@@ -329,7 +329,7 @@ Sampler effects are functions that can be used to change the behaviour of sample
|
||||
|
||||
### begin
|
||||
|
||||
<JsDoc client:idle name="begin" h={0} />
|
||||
<JsDoc client:idle name="Pattern#begin" h={0} />
|
||||
|
||||
### end
|
||||
|
||||
@@ -337,23 +337,23 @@ Sampler effects are functions that can be used to change the behaviour of sample
|
||||
|
||||
### loop
|
||||
|
||||
<JsDoc client:idle name="loop" h={0} />
|
||||
<JsDoc client:idle name="Pattern#loop" h={0} />
|
||||
|
||||
### loopBegin
|
||||
|
||||
<JsDoc client:idle name="loopBegin" h={0} />
|
||||
<JsDoc client:idle name="Pattern#loopBegin" h={0} />
|
||||
|
||||
### loopEnd
|
||||
|
||||
<JsDoc client:idle name="loopEnd" h={0} />
|
||||
<JsDoc client:idle name="Pattern#loopEnd" h={0} />
|
||||
|
||||
### cut
|
||||
|
||||
<JsDoc client:idle name="cut" h={0} />
|
||||
<JsDoc client:idle name="Pattern#cut" h={0} />
|
||||
|
||||
### clip
|
||||
|
||||
<JsDoc client:idle name="clip" h={0} />
|
||||
<JsDoc client:idle name="Pattern#clip" h={0} />
|
||||
|
||||
### loopAt
|
||||
|
||||
@@ -385,6 +385,6 @@ Sampler effects are functions that can be used to change the behaviour of sample
|
||||
|
||||
### speed
|
||||
|
||||
<JsDoc client:idle name="speed" h={0} />
|
||||
<JsDoc client:idle name="Pattern#speed" h={0} />
|
||||
|
||||
After samples, let's see what [Synths](/learn/synths) afford us.
|
||||
|
||||
@@ -82,7 +82,7 @@ Earlier versions of many of these functions had `s_` prefixes, and the `pace` fu
|
||||
|
||||
### pace
|
||||
|
||||
<JsDoc client:idle name="pace" h={0} />
|
||||
<JsDoc client:idle name="Pattern#pace" h={0} />
|
||||
|
||||
### stepcat
|
||||
|
||||
@@ -94,23 +94,23 @@ Earlier versions of many of these functions had `s_` prefixes, and the `pace` fu
|
||||
|
||||
### expand
|
||||
|
||||
<JsDoc client:idle name="expand" h={0} />
|
||||
<JsDoc client:idle name="Pattern#expand" h={0} />
|
||||
|
||||
### contract
|
||||
|
||||
<JsDoc client:idle name="contract" h={0} />
|
||||
<JsDoc client:idle name="Pattern#contract" h={0} />
|
||||
|
||||
### extend
|
||||
|
||||
<JsDoc client:idle name="extend" h={0} />
|
||||
<JsDoc client:idle name="Pattern#extend" h={0} />
|
||||
|
||||
### take
|
||||
|
||||
<JsDoc client:idle name="take" h={0} />
|
||||
<JsDoc client:idle name="Pattern#take" h={0} />
|
||||
|
||||
### drop
|
||||
|
||||
<JsDoc client:idle name="drop" h={0} />
|
||||
<JsDoc client:idle name="Pattern#drop" h={0} />
|
||||
|
||||
### polymeter
|
||||
|
||||
@@ -118,15 +118,15 @@ Earlier versions of many of these functions had `s_` prefixes, and the `pace` fu
|
||||
|
||||
### shrink
|
||||
|
||||
<JsDoc client:idle name="shrink" h={0} />
|
||||
<JsDoc client:idle name="Pattern#shrink" h={0} />
|
||||
|
||||
### grow
|
||||
|
||||
<JsDoc client:idle name="grow" h={0} />
|
||||
<JsDoc client:idle name="Pattern#grow" h={0} />
|
||||
|
||||
### tour
|
||||
|
||||
<JsDoc client:idle name="tour" h={0} />
|
||||
<JsDoc client:idle name="Pattern#tour" h={0} />
|
||||
|
||||
### zip
|
||||
|
||||
|
||||
@@ -141,11 +141,11 @@ These phases too can be declared in Strudel and can give your sounds interesting
|
||||
|
||||
### vib
|
||||
|
||||
<JsDoc client:idle name="vib" h={0} />
|
||||
<JsDoc client:idle name="Pattern#vib" h={0} />
|
||||
|
||||
### vibmod
|
||||
|
||||
<JsDoc client:idle name="vibmod" h={0} />
|
||||
<JsDoc client:idle name="Pattern#vibmod" h={0} />
|
||||
|
||||
## FM Synthesis
|
||||
|
||||
@@ -155,27 +155,27 @@ You can use fm with any of the above waveforms, although the below examples all
|
||||
|
||||
### fm
|
||||
|
||||
<JsDoc client:idle name="fm" h={0} />
|
||||
<JsDoc client:idle name="Pattern#fm" h={0} />
|
||||
|
||||
### fmh
|
||||
|
||||
<JsDoc client:idle name="fmh" h={0} />
|
||||
<JsDoc client:idle name="Pattern#fmh" h={0} />
|
||||
|
||||
### fmattack
|
||||
|
||||
<JsDoc client:idle name="fmattack" h={0} />
|
||||
<JsDoc client:idle name="Pattern#fmattack" h={0} />
|
||||
|
||||
### fmdecay
|
||||
|
||||
<JsDoc client:idle name="fmdecay" h={0} />
|
||||
<JsDoc client:idle name="Pattern#fmdecay" h={0} />
|
||||
|
||||
### fmsustain
|
||||
|
||||
<JsDoc client:idle name="fmsustain" h={0} />
|
||||
<JsDoc client:idle name="Pattern#fmsustain" h={0} />
|
||||
|
||||
### fmenv
|
||||
|
||||
<JsDoc client:idle name="fmenv" h={0} />
|
||||
<JsDoc client:idle name="Pattern#fmenv" h={0} />
|
||||
|
||||
## Wavetable Synthesis
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ Some of these have equivalent operators in the Mini Notation:
|
||||
|
||||
## clip / legato
|
||||
|
||||
<JsDoc client:idle name="clip" h={0} />
|
||||
<JsDoc client:idle name="Pattern#clip" h={0} />
|
||||
|
||||
## euclid
|
||||
|
||||
@@ -56,7 +56,7 @@ Some of these have equivalent operators in the Mini Notation:
|
||||
|
||||
## palindrome
|
||||
|
||||
<JsDoc client:idle name="palindrome" h={0} />
|
||||
<JsDoc client:idle name="Pattern#palindrome" h={0} />
|
||||
|
||||
## iter
|
||||
|
||||
@@ -68,50 +68,50 @@ Some of these have equivalent operators in the Mini Notation:
|
||||
|
||||
## ply
|
||||
|
||||
<JsDoc client:idle name="ply" h={0} />
|
||||
<JsDoc client:idle name="Pattern#ply" h={0} />
|
||||
|
||||
## segment
|
||||
|
||||
<JsDoc client:idle name="segment" h={0} />
|
||||
<JsDoc client:idle name="Pattern#segment" h={0} />
|
||||
|
||||
## compress
|
||||
|
||||
<JsDoc client:idle name="compress" h={0} />
|
||||
<JsDoc client:idle name="Pattern#compress" h={0} />
|
||||
|
||||
## zoom
|
||||
|
||||
<JsDoc client:idle name="zoom" h={0} />
|
||||
<JsDoc client:idle name="Pattern#zoom" h={0} />
|
||||
|
||||
## linger
|
||||
|
||||
<JsDoc client:idle name="linger" h={0} />
|
||||
<JsDoc client:idle name="Pattern#linger" h={0} />
|
||||
|
||||
## fastGap
|
||||
|
||||
<JsDoc client:idle name="fastGap" h={0} />
|
||||
<JsDoc client:idle name="Pattern#fastGap" h={0} />
|
||||
|
||||
## inside
|
||||
|
||||
<JsDoc client:idle name="inside" h={0} />
|
||||
<JsDoc client:idle name="Pattern#inside" h={0} />
|
||||
|
||||
## outside
|
||||
|
||||
<JsDoc client:idle name="outside" h={0} />
|
||||
<JsDoc client:idle name="Pattern#outside" h={0} />
|
||||
|
||||
## cpm
|
||||
|
||||
<JsDoc client:idle name="cpm" h={0} />
|
||||
<JsDoc client:idle name="Pattern#cpm" h={0} />
|
||||
|
||||
## ribbon
|
||||
|
||||
<JsDoc client:idle name="ribbon" h={0} />
|
||||
<JsDoc client:idle name="Pattern#ribbon" h={0} />
|
||||
|
||||
## swingBy
|
||||
|
||||
<JsDoc client:idle name="swingBy" h={0} />
|
||||
<JsDoc client:idle name="Pattern#swingBy" h={0} />
|
||||
|
||||
## swing
|
||||
|
||||
<JsDoc client:idle name="swing" h={0} />
|
||||
<JsDoc client:idle name="Pattern#swing" h={0} />
|
||||
|
||||
Apart from modifying time, there are ways to [Control Parameters](/functions/value-modifiers/).
|
||||
|
||||
@@ -12,7 +12,7 @@ These functions use [tonaljs](https://github.com/tonaljs/tonal) to provide helpe
|
||||
|
||||
### voicing()
|
||||
|
||||
<JsDoc client:idle name="voicing" h={0} />
|
||||
<JsDoc client:idle name="Pattern#voicing" h={0} />
|
||||
|
||||
Here's an example of how you can play chords and a bassline:
|
||||
|
||||
@@ -29,7 +29,7 @@ Here's an example of how you can play chords and a bassline:
|
||||
|
||||
### scale(name)
|
||||
|
||||
<JsDoc client:idle name="scale" h={0} />
|
||||
<JsDoc client:idle name="Pattern#scale" h={0} />
|
||||
|
||||
### transpose(semitones)
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ What follows is the API doc of all the options you can pass:
|
||||
|
||||
## Scope
|
||||
|
||||
<JsDoc client:idle name="scope" h={0} />
|
||||
<JsDoc client:idle name="Pattern#scope" h={0} />
|
||||
|
||||
## Pitchwheel
|
||||
|
||||
@@ -101,7 +101,7 @@ What follows is the API doc of all the options you can pass:
|
||||
|
||||
## Spectrum
|
||||
|
||||
<JsDoc client:idle name="spectrum" h={0} />
|
||||
<JsDoc client:idle name="Pattern#spectrum" h={0} />
|
||||
|
||||
## Print
|
||||
|
||||
@@ -109,4 +109,4 @@ What follows is the API doc of all the options you can pass:
|
||||
|
||||
## markcss
|
||||
|
||||
<JsDoc client:idle name="markcss" h={0} />
|
||||
<JsDoc client:idle name="Pattern#markcss" h={0} />
|
||||
|
||||
+27
-2
@@ -1,12 +1,37 @@
|
||||
// @ts-ignore
|
||||
import { registerSW } from 'virtual:pwa-register';
|
||||
|
||||
registerSW({
|
||||
immediate: true,
|
||||
function h(html: string): HTMLElement {
|
||||
const template = document.createElement('template');
|
||||
template.innerHTML = html;
|
||||
return template.content.firstElementChild as HTMLElement;
|
||||
}
|
||||
|
||||
function showUpdateModal() {
|
||||
const hint = h(`
|
||||
<div style="position:fixed;bottom:8px;right:8px;z-index:99999;padding:10px;background:var(--background);color:var(--foreground);border:2px solid var(--gutterForeground)">
|
||||
<p style="margin-bottom:10px">A new strudel version is available. Update now?</p>
|
||||
<button style="border:1px solid var(--gutterForeground);padding:4px" id="updateButton">update</button>
|
||||
<button style="border:1px solid var(--gutterForeground);padding:4px" id="cancelButton">cancel</button>
|
||||
</div>`);
|
||||
document.body.appendChild(hint);
|
||||
hint.querySelector<HTMLButtonElement>('#updateButton')!.onclick = () => {
|
||||
updateSW();
|
||||
hint.remove();
|
||||
};
|
||||
hint.querySelector<HTMLButtonElement>('#cancelButton')!.onclick = () => {
|
||||
hint.remove();
|
||||
};
|
||||
}
|
||||
// https://vite-pwa-org.netlify.app/frameworks/#prompt-for-update
|
||||
const updateSW = registerSW({
|
||||
onRegisteredSW(swScriptUrl) {
|
||||
// console.log('SW registered: ', swScriptUrl)
|
||||
},
|
||||
onOfflineReady() {
|
||||
// console.log('PWA application ready to work offline')
|
||||
},
|
||||
onNeedRefresh() {
|
||||
showUpdateModal();
|
||||
},
|
||||
});
|
||||
|
||||
@@ -3,6 +3,7 @@ import { memo, useEffect, useMemo, useState, Fragment } from 'react';
|
||||
import jsdocJson from '../../../../../doc.json';
|
||||
import { Textbox } from '@src/repl/components/panel/SettingsTab';
|
||||
import { settingsMap, useSettings } from '@src/settings.mjs';
|
||||
import { JsDoc } from '@src/docs/JsDoc';
|
||||
import { computeAvailableFunctions } from '@src/jsDocsUtils.mjs';
|
||||
|
||||
const availableFunctions = computeAvailableFunctions(jsdocJson);
|
||||
@@ -178,48 +179,7 @@ export const Reference = memo(function Reference() {
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
{!!entry.synonyms_text && (
|
||||
<p>
|
||||
Synonyms: <code>{entry.synonyms_text}</code>
|
||||
</p>
|
||||
)}
|
||||
|
||||
<p
|
||||
dangerouslySetInnerHTML={{
|
||||
// If we have an external url make sure it opens in another tab to not interrupt the player
|
||||
__html: entry.description.replaceAll(/<a href="https:\/\//g, `<a target="_blank" href="https://`),
|
||||
}}
|
||||
></p>
|
||||
{entry.params && entry.params.length > 0 && <p className="font-bold">Arguments</p>}
|
||||
<ul>
|
||||
{entry.params?.map(({ name, type, description }, i) => {
|
||||
// Check if the param is actually the parameter of an object
|
||||
const objParamSeperator = name.indexOf('.');
|
||||
const isObjectParam = objParamSeperator !== -1;
|
||||
|
||||
return (
|
||||
<li key={i} className={isObjectParam ? 'list-none' : ''}>
|
||||
{isObjectParam ? name.substring(objParamSeperator + 1) : name} : {type?.names?.join(' | ')}{' '}
|
||||
{description ? <> - {getInnerText(description)}</> : ''}
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
{entry.returns && (
|
||||
<p>
|
||||
<span className="font-bold">Returns</span>{' '}
|
||||
{entry.returns.map(({ type, description }) => (
|
||||
<>
|
||||
{type?.names?.join(' | ')} {description ? <> - {getInnerText(description)}</> : ''}
|
||||
</>
|
||||
))}
|
||||
</p>
|
||||
)}
|
||||
{entry.examples?.map((example, j) => (
|
||||
<pre className="bg-background border border-muted" key={j}>
|
||||
{example}
|
||||
</pre>
|
||||
))}
|
||||
<JsDoc name={entry.longname} hideMiniRepl></JsDoc>
|
||||
</section>
|
||||
)) || <p className="font-sans">Search or select a tag to get started.</p>}
|
||||
{detailVisibleFunctions.length > 0 && <div className="h-screen" />}
|
||||
|
||||
@@ -37,8 +37,11 @@ export function WelcomeTab({ context }) {
|
||||
tidalcycles
|
||||
</a>
|
||||
, which is a popular live coding language for music, written in Haskell. Strudel is free/open source software,
|
||||
with copyright owned by its [contributors](https://codeberg.org/uzu/strudel/activity/contributors). You can
|
||||
redistribute and/or modify it under the terms of the{' '}
|
||||
with copyright owned by its{' '}
|
||||
<a href="https://codeberg.org/uzu/strudel/activity/contributors" target="_blank">
|
||||
contributors
|
||||
</a>
|
||||
. You can redistribute and/or modify it under the terms of the{' '}
|
||||
<a href="https://codeberg.org/uzu/strudel/src/branch/main/LICENSE" target="_blank">
|
||||
GNU Affero General Public License
|
||||
</a>
|
||||
|
||||
@@ -101,7 +101,10 @@ export function useReplContext() {
|
||||
clearHydra();
|
||||
}
|
||||
},
|
||||
beforeEval: () => audioReady,
|
||||
beforeEval: ({ code }) => {
|
||||
setVersionDefaultsFrom(code);
|
||||
return audioReady;
|
||||
},
|
||||
afterEval: (all) => {
|
||||
const { code } = all;
|
||||
//post to iframe parent (like Udels) if it exists...
|
||||
@@ -115,7 +118,6 @@ export function useReplContext() {
|
||||
}
|
||||
setDocumentTitle(code);
|
||||
const viewingPatternData = getViewingPatternData();
|
||||
setVersionDefaultsFrom(code);
|
||||
const data = { ...viewingPatternData, code };
|
||||
let id = data.id;
|
||||
const isExamplePattern = viewingPatternData.collection !== userPattern.collection;
|
||||
|
||||
@@ -15,6 +15,14 @@ const { code2hash, errorLogger, evalScope, hash2code, logger } = strudelCore;
|
||||
export const supabase = createClient(
|
||||
'https://pidxdsxphlhzjnzmifth.supabase.co',
|
||||
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InBpZHhkc3hwaGxoempuem1pZnRoIiwicm9sZSI6ImFub24iLCJpYXQiOjE2NTYyMzA1NTYsImV4cCI6MTk3MTgwNjU1Nn0.bqlw7802fsWRnqU5BLYtmXk_k-D1VFmbkHMywWc15NM',
|
||||
{
|
||||
// avoid "Uncaught (in promise) Error: Acquiring an exclusive Navigator LockManager lock ... immediately failed"
|
||||
auth: {
|
||||
persistSession: false,
|
||||
autoRefreshToken: false,
|
||||
detectSessionInUrl: false,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
let dbLoaded;
|
||||
@@ -89,6 +97,7 @@ export function loadModules() {
|
||||
import('@strudel/mqtt'),
|
||||
import('@strudel/mondo'),
|
||||
import('@strudel/dough'),
|
||||
import('@strudel/kabelsalat'),
|
||||
];
|
||||
if (isTauri()) {
|
||||
modules = modules.concat([
|
||||
|
||||
Reference in New Issue
Block a user