Compare commits

..

70 Commits

Author SHA1 Message Date
yaxu c150752372 revert 85e6d436ef
revert motors workshop page
(committed to main by mistake!)
2026-06-21 20:47:04 +02:00
Alex McLean e248bf85f3 Merge pull request 'Creates a pattern of numbers in base x from a number or pattern of numbers @stretchyboy' (#2075) from stretchyboy-base-function into main
Reviewed-on: https://codeberg.org/uzu/strudel/pulls/2075
2026-06-21 20:45:28 +02:00
Alex McLean 6c51c0261a Merge branch 'main' into stretchyboy-base-function 2026-06-21 20:45:05 +02:00
Felix Roos deefde7b50 hotfix: codeformat 2026-06-21 15:41:50 +02:00
froos d4f63e8de3 Merge pull request 'fix: cache bunny cdn urls #2057' (#2076) from cache-bunny into main
Reviewed-on: https://codeberg.org/uzu/strudel/pulls/2076
2026-06-21 15:29:56 +02:00
alex 19cb3dedc2 snapshot 2026-06-21 14:02:34 +01:00
alex a7c3407da7 codeformat 2026-06-21 13:54:38 +01:00
Martyn Eggleton 6870b04fb2 Pretty code now 2026-06-21 13:49:11 +01:00
Alex McLean 2b2646a768 Merge branch 'main' into base-function 2026-06-21 14:34:18 +02:00
alex 97ef5bc335 Merge branch 'main' of ssh://codeberg.org/uzu/strudel 2026-06-19 21:30:17 +01:00
alex 85e6d436ef motors workshop page 2026-06-19 21:29:58 +01:00
alex d3e2b7c7b4 motors workshop page 2026-06-19 21:29:49 +01:00
alex def1738259 shortcuts for workshop 2026-06-19 21:29:25 +01:00
Alex McLean 0feeb1e701 Merge pull request 'Add growlist' (#2073) from growlist into main
Reviewed-on: https://codeberg.org/uzu/strudel/pulls/2073
2026-06-18 13:25:38 +02:00
alex 813cc6c190 format 2026-06-18 12:04:03 +01:00
alex 62d4f84e69 add growlist 2026-06-18 10:55:34 +01:00
stretchyboy 49a1e11cd8 Merge branch 'main' into base-function 2026-06-17 13:58:30 +02:00
Felix Roos 941c97da0d fix: cache bunny cdn urls #2057 2026-06-15 09:15:06 +02:00
Alex McLean 95a9d301a1 Merge pull request 'midikeys-with-channel' (#2063) from eefano/strudel:midikeys-with-channel into main
Reviewed-on: https://codeberg.org/uzu/strudel/pulls/2063
2026-06-10 13:38:02 +02:00
Martyn Eggleton 475f17ddfd base now accepts Arrays which improve compatibility with rockstar-strudel 2026-06-03 21:56:26 +01:00
Martyn Eggleton bd68c6a0a7 Documentation tweak 2026-06-03 12:36:41 +01:00
eefano 2635716c87 added midikeys third test 2026-06-02 14:56:55 +02:00
eefano 58f956b57e prettier fix 2026-06-02 14:29:28 +02:00
eefano 0ae2c120b3 updated documentation for midikeys 2026-06-02 13:28:23 +02:00
eefano 05a43ef687 included midichan value in midikeys haps 2026-06-02 13:14:30 +02:00
Martyn Eggleton f21aeb55bd The base param can be a pattern. We also add a max number of digits to produce for each n 2026-06-01 14:02:20 +01:00
Martyn Eggleton d83139980b Creates a pattern of numbers in base x from a number or pattern of numbers 2026-05-27 21:23:55 +01:00
Alex McLean 0c61cd7670 Merge pull request 'Don't force SSL for mqtt websocket connections' (#2058) from mqtt-ws into main
Reviewed-on: https://codeberg.org/uzu/strudel/pulls/2058
2026-05-27 13:35:28 +02:00
alex 13b11efa15 don't force SSL for mqtt websocket connections - fall back on url instead (wss: for SSL, ws: for unencrypted) 2026-05-26 16:11:33 +01:00
froos f73b395648 Merge pull request 'Add error for when name arg in register is a pattern' (#2020) from tyow/localstrudel:registerErrorFix into main
Reviewed-on: https://codeberg.org/uzu/strudel/pulls/2020
2026-05-07 11:46:59 +02:00
froos 9c47efd3cf Merge pull request 'docs: note that all/each require labeled patterns' (#2015) from bwagner/strudel:fix/all-unlabeled-pattern-docs into main
Reviewed-on: https://codeberg.org/uzu/strudel/pulls/2015
2026-05-07 11:28:31 +02:00
froos f4066089f4 Merge pull request 'Add flux function' (#1528) from TodePond/strudel:lu/flux into main
Reviewed-on: https://codeberg.org/uzu/strudel/pulls/1528
2026-05-07 10:51:57 +02:00
Felix Roos 0e81987c4e Merge remote-tracking branch 'origin/main' into lu/flux 2026-05-07 10:36:11 +02:00
Felix Roos 23dbe53013 add snapshots 2026-05-07 10:32:58 +02:00
froos 0e4d0484a3 Merge pull request 'Fix the documentation of stretch' (#1670) from vvolhejn/strudel:vv/fix-stretch-docs into main
Reviewed-on: https://codeberg.org/uzu/strudel/pulls/1670
2026-05-07 09:32:37 +02:00
froos 37bf2e4dc7 Merge pull request 'Added .dockerignore' (#2005) from KuboOrk/strudel:docker/add-dockerignore into main
Reviewed-on: https://codeberg.org/uzu/strudel/pulls/2005
2026-05-07 00:45:30 +02:00
froos e69761397e Merge pull request 'fix midi numbers as notes for osc backend' (#2001) from jagen31/strudel:jagen-midinote-osc into main
Reviewed-on: https://codeberg.org/uzu/strudel/pulls/2001
2026-05-07 00:20:41 +02:00
froos 10c33f24f5 Merge pull request 'LFO documentation' (#2000) from scrappy_fiddler/strudel:lfo_docs into main
Reviewed-on: https://codeberg.org/uzu/strudel/pulls/2000
2026-05-07 00:11:54 +02:00
Felix Roos ea0ec7edb9 fix format 2026-05-06 22:14:11 +02:00
froos f900642359 cross-reference signals page 2026-05-06 22:01:58 +02:00
froos 4cc63b8b01 Merge pull request 'fixed bug where withBase would silence a pattern if freq was unset' (#1994) from tyow/localstrudel:withbase-fix into main
Reviewed-on: https://codeberg.org/uzu/strudel/pulls/1994
2026-05-06 21:29:34 +02:00
Alex McLean 26832c0fe7 Merge pull request 'send manual deploy to cold.strudel.cc, and autodeploy to strudel.cc' (#2037) from move-domains into main
Reviewed-on: https://codeberg.org/uzu/strudel/pulls/2037
2026-04-05 12:42:49 +02:00
alex 01abc8ae79 send manual deploy to cold.strudel.cc, and autodeploy to strudel.cc 2026-04-05 11:37:40 +01:00
Alex McLean 84df683794 Merge pull request 'colorless version display implementation' (#2029) from tyow/localstrudel:versionIndicator into main
Reviewed-on: https://codeberg.org/uzu/strudel/pulls/2029
2026-04-05 12:12:57 +02:00
Alex McLean ca1aca0c00 Merge branch 'main' into versionIndicator 2026-04-05 12:12:20 +02:00
tyow e8668a1552 improved unofficial detection 2026-03-30 14:51:22 -04:00
tyow 86d65c72f0 colorless version display implementation 2026-03-30 14:39:14 -04:00
Aria 9f19e4616a Merge pull request 'Feature: Add replace and insert code helpers to codemirror' (#2021) from glossing/insert-code-helper into main
Reviewed-on: https://codeberg.org/uzu/strudel/pulls/2021
2026-03-15 19:25:56 +01:00
tyow ae32743f12 format 2026-03-13 14:11:38 -04:00
tyow 7294cd5443 Add error for when name arg in register is a pattern 2026-03-13 14:11:19 -04:00
Bernhard Wagner cdae661b24 docs: note that all/each require labeled patterns 2026-03-09 11:15:14 +01:00
TodePond 63f42faca8 Update packages/core/pattern.mjs 2026-03-03 11:27:05 +01:00
Václav Volhejn 2624b97500 Merge branch 'main' of ssh://codeberg.org/vvolhejn/strudel into vv/fix-stretch-docs 2026-03-01 11:15:28 +01:00
Václav Volhejn 633b7287c0 Merge branch 'main' of ssh://codeberg.org/vvolhejn/strudel into vv/fix-stretch-docs 2026-03-01 11:13:14 +01:00
KuboOrk 3805ba8f76 Added .dockerignore 2026-02-28 13:39:07 +03:00
jagen31 82e88d4a28 fix midi numbers as notes for osc backend
note -> midinote
2026-02-23 01:24:53 +01:00
scrappy_fiddler 5cd45d5ea1 typo in lfo docs 2026-02-23 00:22:30 +01:00
scrappy_fiddler d930057000 lfo documentation 2026-02-23 00:18:42 +01:00
scrappy_fiddler daf27ed971 added lfo documentation 2026-02-23 00:11:17 +01:00
tyow 8520044f3e fixed bug where withBase would silence a pattern if freq was unset 2026-02-20 13:10:16 -05:00
Václav Volhejn 7c22b29493 Merge branch 'main' of ssh://codeberg.org/vvolhejn/strudel into vv/fix-stretch-docs 2026-01-10 06:34:34 -08:00
Lu[ke] Wilson c77675c492 add another synonym 2025-11-29 18:01:27 +00:00
Lu[ke] Wilson 5197af1aa4 Merge remote-tracking branch 'origin/main' into lu/flux 2025-11-29 17:58:41 +00:00
froos 85f6472894 Merge branch 'main' into lu/flux 2025-10-28 23:53:44 +01:00
Václav Volhejn 54fd877be1 Update snapshot 2025-10-18 13:19:18 +02:00
Václav Volhejn 7d948fd1a7 Fix example snapshot 2025-10-18 12:25:15 +02:00
Václav Volhejn 3373fa39a6 Fix the documentation of stretch 2025-10-18 12:14:39 +02:00
froos 1de8123437 Merge branch 'main' into lu/flux 2025-09-14 01:12:28 +02:00
Lu[ke] Wilson 781c477078 rename to juxFlip 2025-08-29 17:20:18 +01:00
Lu[ke] Wilson e2cdce5ac9 add flux function 2025-08-29 15:35:41 +01:00
16 changed files with 871 additions and 24 deletions
+11
View File
@@ -0,0 +1,11 @@
**/node_modules
**/.angular
**/dist
.astro/
.forgejo/
.idea/
.vscode/
test/
.gitignore
Dockerfile
.dockerignore
+2 -2
View File
@@ -1,4 +1,4 @@
name: Build and Deploy to beta (warm.strudel.cc)
name: Build and Deploy to warm (strudel.cc)
on:
push:
@@ -37,4 +37,4 @@ jobs:
apt update && apt install -y rsync
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/warm.strudel.cc
rsync -atv --delete --delete-after --progress ./website/dist/ strudel@matrix.toplap.org:/home/strudel/deploy/strudel.cc
+2 -2
View File
@@ -1,4 +1,4 @@
name: Build and Deploy to live (strudel.cc)
name: Build and Deploy to cold (cold.strudel.cc)
on: [workflow_dispatch]
@@ -34,4 +34,4 @@ jobs:
apt update && apt install -y rsync
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/strudel.cc
rsync -atv --delete --delete-after --progress ./website/dist/ strudel@matrix.toplap.org:/home/strudel/deploy/cold.strudel.cc
+7 -3
View File
@@ -2582,13 +2582,17 @@ export const { compressorRelease } = registerControl('compressorRelease');
export const { speed } = registerControl('speed');
/**
* Changes the speed of sample playback, i.e. a cheap way of changing pitch.
* Changes the pitch of the sample without changing its speed.
* The frequencies are multiplied by (factor + 1) for positive numbers
* and by max(factor / 4 + 1, 0) for negative numbers.
* So tuning up by octaves can be done with 1, 3, 7, ...
* and tuning down by octaves with -2, -3, -3.5...
*
* @name stretch
* @tags pitch, samples
* @param {number | Pattern} factor -inf to inf, negative numbers play the sample backwards.
* @param {number | Pattern} factor between `-4` and `inf`. Positive increases pitch, 0 does nothing, negative decreases the pitch.
* @example
* s("gm_flute").stretch("1 2 .5")
* s("gm_flute").stretch("<2 1 0 -2>")
*
*/
export const { stretch } = registerControl('stretch');
+96
View File
@@ -1741,6 +1741,12 @@ export const func = curry((a, b) => reify(b).func(a));
*
*/
export function register(name, func, patternify = true, preserveSteps = false, join = (x) => x.innerJoin()) {
if (isPattern(name)) {
throw new Error(
'Name argument for register is a pattern, try using single quotes (\'name\') instead of double quotes ("name")',
);
}
if (Array.isArray(name)) {
const result = {};
for (const name_item of name) {
@@ -2546,6 +2552,20 @@ export const { juxBy, juxby } = register(['juxBy', 'juxby'], function (by, func,
return stack(left, right).setSteps(__steps ? lcm(left._steps, right._steps) : undefined);
});
/**
* Like juxBy, except it flips the ears each cycle.
* @name juxFlipBy
* @synonyms juxflipby, fluxBy, fluxby
* @example
* s("bd lt [~ ht] mt cp ~ bd hh").juxFlipBy(".8", rev)
*/
export const { juxFlipBy, juxflipby, fluxBy, fluxby } = register(
['juxFlipBy', 'juxflipby', 'fluxBy', 'fluxby'],
function (by, func, pat) {
return pat.juxBy(slowcat(by, -by), func);
},
);
/**
* The jux function creates strange stereo effects, by applying a function to a pattern, but only in the right-hand channel.
* @tags temporal, superdough
@@ -2560,6 +2580,21 @@ export const jux = register('jux', function (func, pat) {
return pat._juxBy(1, func, pat);
});
/**
* Like jux, but flips the ears each cycle.
* @name juxFlip
* @synonyms juxflip, flux
* @example
* s("bd lt [~ ht] mt cp ~ bd hh").juxFlip(rev)
* @example
* s("bd lt [~ ht] mt cp ~ bd hh").juxFlip(press)
* @example
* s("bd lt [~ ht] mt cp ~ bd hh").juxFlip(iter(4))
*/
export const { juxFlip, flux } = register(['juxFlip', 'juxflip', 'flux'], function (func, pat) {
return pat._juxFlipBy(1, func, pat);
});
/**
* Superimpose and offset multiple times, applying the given function each time.
* @tags temporal, functional
@@ -3324,6 +3359,11 @@ Pattern.prototype.shrinklist = function (amount) {
export const shrinklist = (amount, pat) => pat.shrinklist(amount);
Pattern.prototype.growlist = function (amount) {
return this.shrinklist(amount).reverse();
};
export const growlist = (amount, pat) => pat.growlist(amount);
/**
* *Experimental*
*
@@ -4092,3 +4132,59 @@ Pattern.prototype.worklet = function (src, ...inputs) {
};
export const worklet = (...args) => pure({}).worklet(...args);
/**
* Creates a pattern of numbers in base b from a number or pattern of numbers
* limited to d digits long from the right
*
* @name base
* @tags generators
* @param {number} n - number to convert (can be a pattern or array)
* @param {number} b - base to convert to (defaults to 10) (can be a pattern)
* @param {number} d - max number of digits to produce for each n (defaults to 0 for all) (can be a pattern)
* @example
* $: note(base("7175 543", 10, 3)).scale("c:major").s("saw")
* // $: note("1 7 5 5 4 3").scale("c:major").s("saw")
*/
export const base = (n, b = 10, d = 0) => {
if (Array.isArray(n)) {
n = sequence(n);
}
n = reify(n);
b = reify(b);
d = reify(d);
return d
.withValue((e) => {
return b
.withValue((c) => {
return n
.withValue((v) => {
let digits = [];
let value = v;
while (value > 0) {
digits.unshift(value % c);
value = Math.floor(value / c);
}
if (e) {
const l = digits.length;
if (l > e) {
digits = digits.slice(-1 * e);
}
/*
if (l < e){
for (let i = l; i < e; i++) {
digits.unshift("~");//0); //Would like to be padding this but ~- doesn't work
}
console.log("digits", digits);
}
*/
}
return sequence(digits);
})
.squeezeJoin();
})
.squeezeJoin();
})
.squeezeJoin();
};
+8 -1
View File
@@ -307,8 +307,12 @@ export function repl({
let allTransforms = [];
/**
* Applies a function to all the running patterns. Note that the patterns are groups together into a single `stack` before the function is applied. This is probably what you want, but see `each` for
* Applies a function to all the running patterns. Note that the patterns are grouped together into a single `stack` before the function is applied. This is probably what you want, but see `each` for
* a version that applies the function to each pattern separately.
*
* **Note:** Patterns must be labeled (e.g. with `$:`) to be picked up by `all`. An unlabeled
* pattern such as `note("c4")` is not registered and will produce no audio when `all` is present.
* Use `$: note("c4")` instead.
* ```
* $: sound("bd - cp sd")
* $: sound("hh*8")
@@ -328,6 +332,9 @@ export function repl({
};
/** Applies a function to each of the running patterns separately. This is intended for future use with upcoming 'stepwise' features. See `all` for a version that applies the function to all the patterns stacked together into a single pattern.
*
* **Note:** Patterns must be labeled (e.g. with `$:`) to be picked up by `each`. An unlabeled
* pattern such as `note("c4")` is not registered and will produce no audio when `each` is present.
* Use `$: note("c4")` instead.
* ```
* $: sound("bd - cp sd")
* $: sound("hh*8")
+8 -1
View File
@@ -537,6 +537,9 @@ export async function midin(input) {
* The note length is fixed as Superdough is not currently set up for undetermined
* note durations
*
* The 'midichan' control value contains the number of the channel the note is coming from
* so it could be filtered or manipulated further in the chain.
*
* @name midikeys
* @tags external_io, midi
* @param {string | number} input MIDI device name or index defaulting to 0
@@ -552,6 +555,10 @@ export async function midin(input) {
* .s("saw")
* .add(note(rand.mul(0.3)))
* .lpf(1000).lpe(2).room(0.5)
* @example
* // discard all notes not coming out from midi channel 2
* const kb = await midikeys('Arturia KeyStep 32')
* kb().filterValues(v=>v.midichan==2).s("tri")
*/
const kHaps = {};
const kListeners = {};
@@ -633,7 +640,7 @@ export async function midikeys(input) {
*/
return;
} else {
value = { ...value, note: Math.round(note), velocity: velocity / 127 };
value = { ...value, note: Math.round(note), velocity: velocity / 127, midichan: message.channel };
}
kHaps[input].push(new Hap(span, span, value, {}));
if (!noteoff && triggerAvailable) {
+10 -2
View File
@@ -4,7 +4,7 @@ Copyright (C) 2022 Strudel contributors - see <https://codeberg.org/uzu/strudel/
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { Pattern, isPattern } from '@strudel/core';
import { Pattern, isPattern, createParams } from '@strudel/core';
import Paho from 'paho-mqtt';
const connections = {};
@@ -61,7 +61,6 @@ Pattern.prototype.mqtt = function (
const props = {
onSuccess: onConnect,
onFailure: onFailure,
useSSL: true,
};
if (username) {
@@ -119,3 +118,12 @@ Pattern.prototype.mqtt = function (
return hap.setContext({ ...hap.context, onTrigger, dominantTrigger: true });
});
};
// This adds the 'move' and 'motor' commands to strudel
export const { move, motor } = createParams('move', 'motor');
window.move = move;
window.motor = motor;
// This adds the 'robot' command
Pattern.prototype.robot = function (robot_id, address = 'ws://192.168.8.248:9001/mqtt') {
return this.mqtt(undefined, undefined, '/move/' + robot_id, address);
};
+1 -1
View File
@@ -42,7 +42,7 @@ export function parseControlsFromHap(hap, cps) {
if (isNote(controls.note)) {
controls.midinote = noteToMidi(controls.note, controls.octave || 3);
} else {
controls.note = parseNumeral(controls.note);
controls.midinote = parseNumeral(controls.note);
}
}
controls.bank && (controls.s = controls.bank + controls.s);
+1
View File
@@ -149,6 +149,7 @@ export const withBase = register('withBase', (b, pat) => {
let hVal = hap.value;
const isObject = typeof hVal === 'object';
let freq = isObject ? hVal.freq : hVal;
if (!freq) return hap;
freq = (freq * base) / originalBase;
hap.value = isObject ? { ...hap.value, freq } : { freq };
return hap;
+279 -12
View File
@@ -1242,6 +1242,35 @@ exports[`runs examples > example "bank" example index 0 1`] = `
]
`;
exports[`runs examples > example "base" example index 0 1`] = `
[
"[ 0/1 → 1/6 | note:D3 s:saw ]",
"[ 1/6 → 1/3 | note:C4 s:saw ]",
"[ 1/3 → 1/2 | note:A3 s:saw ]",
"[ 1/2 → 2/3 | note:A3 s:saw ]",
"[ 2/3 → 5/6 | note:G3 s:saw ]",
"[ 5/6 → 1/1 | note:F3 s:saw ]",
"[ 1/1 → 7/6 | note:D3 s:saw ]",
"[ 7/6 → 4/3 | note:C4 s:saw ]",
"[ 4/3 → 3/2 | note:A3 s:saw ]",
"[ 3/2 → 5/3 | note:A3 s:saw ]",
"[ 5/3 → 11/6 | note:G3 s:saw ]",
"[ 11/6 → 2/1 | note:F3 s:saw ]",
"[ 2/1 → 13/6 | note:D3 s:saw ]",
"[ 13/6 → 7/3 | note:C4 s:saw ]",
"[ 7/3 → 5/2 | note:A3 s:saw ]",
"[ 5/2 → 8/3 | note:A3 s:saw ]",
"[ 8/3 → 17/6 | note:G3 s:saw ]",
"[ 17/6 → 3/1 | note:F3 s:saw ]",
"[ 3/1 → 19/6 | note:D3 s:saw ]",
"[ 19/6 → 10/3 | note:C4 s:saw ]",
"[ 10/3 → 7/2 | note:A3 s:saw ]",
"[ 7/2 → 11/3 | note:A3 s:saw ]",
"[ 11/3 → 23/6 | note:G3 s:saw ]",
"[ 23/6 → 4/1 | note:F3 s:saw ]",
]
`;
exports[`runs examples > example "beat" example index 0 1`] = `
[
"[ 0/1 → 1/16 | s:bd ]",
@@ -6527,6 +6556,250 @@ exports[`runs examples > example "juxBy" example index 0 1`] = `
]
`;
exports[`runs examples > example "juxFlip" example index 0 1`] = `
[
"[ 0/1 → 1/8 | s:bd pan:0 ]",
"[ 0/1 → 1/8 | s:hh pan:1 ]",
"[ 1/8 → 1/4 | s:lt pan:0 ]",
"[ 1/8 → 1/4 | s:bd pan:1 ]",
"[ 5/16 → 3/8 | s:ht pan:0 ]",
"[ 3/8 → 1/2 | s:mt pan:0 ]",
"[ 3/8 → 1/2 | s:cp pan:1 ]",
"[ 1/2 → 5/8 | s:cp pan:0 ]",
"[ 1/2 → 5/8 | s:mt pan:1 ]",
"[ 5/8 → 11/16 | s:ht pan:1 ]",
"[ 3/4 → 7/8 | s:bd pan:0 ]",
"[ 3/4 → 7/8 | s:lt pan:1 ]",
"[ 7/8 → 1/1 | s:hh pan:0 ]",
"[ 7/8 → 1/1 | s:bd pan:1 ]",
"[ 1/1 → 9/8 | s:bd pan:1 ]",
"[ 1/1 → 9/8 | s:hh pan:0 ]",
"[ 9/8 → 5/4 | s:lt pan:1 ]",
"[ 9/8 → 5/4 | s:bd pan:0 ]",
"[ 21/16 → 11/8 | s:ht pan:1 ]",
"[ 11/8 → 3/2 | s:mt pan:1 ]",
"[ 11/8 → 3/2 | s:cp pan:0 ]",
"[ 3/2 → 13/8 | s:cp pan:1 ]",
"[ 3/2 → 13/8 | s:mt pan:0 ]",
"[ 13/8 → 27/16 | s:ht pan:0 ]",
"[ 7/4 → 15/8 | s:bd pan:1 ]",
"[ 7/4 → 15/8 | s:lt pan:0 ]",
"[ 15/8 → 2/1 | s:hh pan:1 ]",
"[ 15/8 → 2/1 | s:bd pan:0 ]",
"[ 2/1 → 17/8 | s:bd pan:0 ]",
"[ 2/1 → 17/8 | s:hh pan:1 ]",
"[ 17/8 → 9/4 | s:lt pan:0 ]",
"[ 17/8 → 9/4 | s:bd pan:1 ]",
"[ 37/16 → 19/8 | s:ht pan:0 ]",
"[ 19/8 → 5/2 | s:mt pan:0 ]",
"[ 19/8 → 5/2 | s:cp pan:1 ]",
"[ 5/2 → 21/8 | s:cp pan:0 ]",
"[ 5/2 → 21/8 | s:mt pan:1 ]",
"[ 21/8 → 43/16 | s:ht pan:1 ]",
"[ 11/4 → 23/8 | s:bd pan:0 ]",
"[ 11/4 → 23/8 | s:lt pan:1 ]",
"[ 23/8 → 3/1 | s:hh pan:0 ]",
"[ 23/8 → 3/1 | s:bd pan:1 ]",
"[ 3/1 → 25/8 | s:bd pan:1 ]",
"[ 3/1 → 25/8 | s:hh pan:0 ]",
"[ 25/8 → 13/4 | s:lt pan:1 ]",
"[ 25/8 → 13/4 | s:bd pan:0 ]",
"[ 53/16 → 27/8 | s:ht pan:1 ]",
"[ 27/8 → 7/2 | s:mt pan:1 ]",
"[ 27/8 → 7/2 | s:cp pan:0 ]",
"[ 7/2 → 29/8 | s:cp pan:1 ]",
"[ 7/2 → 29/8 | s:mt pan:0 ]",
"[ 29/8 → 59/16 | s:ht pan:0 ]",
"[ 15/4 → 31/8 | s:bd pan:1 ]",
"[ 15/4 → 31/8 | s:lt pan:0 ]",
"[ 31/8 → 4/1 | s:hh pan:1 ]",
"[ 31/8 → 4/1 | s:bd pan:0 ]",
]
`;
exports[`runs examples > example "juxFlip" example index 1 1`] = `
[
"[ 0/1 → 1/8 | s:bd pan:0 ]",
"[ 1/16 → 1/8 | s:bd pan:1 ]",
"[ 1/8 → 1/4 | s:lt pan:0 ]",
"[ 3/16 → 1/4 | s:lt pan:1 ]",
"[ 5/16 → 3/8 | s:ht pan:0 ]",
"[ 11/32 → 3/8 | s:ht pan:1 ]",
"[ 3/8 → 1/2 | s:mt pan:0 ]",
"[ 7/16 → 1/2 | s:mt pan:1 ]",
"[ 1/2 → 5/8 | s:cp pan:0 ]",
"[ 9/16 → 5/8 | s:cp pan:1 ]",
"[ 3/4 → 7/8 | s:bd pan:0 ]",
"[ 13/16 → 7/8 | s:bd pan:1 ]",
"[ 7/8 → 1/1 | s:hh pan:0 ]",
"[ 15/16 → 1/1 | s:hh pan:1 ]",
"[ 1/1 → 9/8 | s:bd pan:1 ]",
"[ 17/16 → 9/8 | s:bd pan:0 ]",
"[ 9/8 → 5/4 | s:lt pan:1 ]",
"[ 19/16 → 5/4 | s:lt pan:0 ]",
"[ 21/16 → 11/8 | s:ht pan:1 ]",
"[ 43/32 → 11/8 | s:ht pan:0 ]",
"[ 11/8 → 3/2 | s:mt pan:1 ]",
"[ 23/16 → 3/2 | s:mt pan:0 ]",
"[ 3/2 → 13/8 | s:cp pan:1 ]",
"[ 25/16 → 13/8 | s:cp pan:0 ]",
"[ 7/4 → 15/8 | s:bd pan:1 ]",
"[ 29/16 → 15/8 | s:bd pan:0 ]",
"[ 15/8 → 2/1 | s:hh pan:1 ]",
"[ 31/16 → 2/1 | s:hh pan:0 ]",
"[ 2/1 → 17/8 | s:bd pan:0 ]",
"[ 33/16 → 17/8 | s:bd pan:1 ]",
"[ 17/8 → 9/4 | s:lt pan:0 ]",
"[ 35/16 → 9/4 | s:lt pan:1 ]",
"[ 37/16 → 19/8 | s:ht pan:0 ]",
"[ 75/32 → 19/8 | s:ht pan:1 ]",
"[ 19/8 → 5/2 | s:mt pan:0 ]",
"[ 39/16 → 5/2 | s:mt pan:1 ]",
"[ 5/2 → 21/8 | s:cp pan:0 ]",
"[ 41/16 → 21/8 | s:cp pan:1 ]",
"[ 11/4 → 23/8 | s:bd pan:0 ]",
"[ 45/16 → 23/8 | s:bd pan:1 ]",
"[ 23/8 → 3/1 | s:hh pan:0 ]",
"[ 47/16 → 3/1 | s:hh pan:1 ]",
"[ 3/1 → 25/8 | s:bd pan:1 ]",
"[ 49/16 → 25/8 | s:bd pan:0 ]",
"[ 25/8 → 13/4 | s:lt pan:1 ]",
"[ 51/16 → 13/4 | s:lt pan:0 ]",
"[ 53/16 → 27/8 | s:ht pan:1 ]",
"[ 107/32 → 27/8 | s:ht pan:0 ]",
"[ 27/8 → 7/2 | s:mt pan:1 ]",
"[ 55/16 → 7/2 | s:mt pan:0 ]",
"[ 7/2 → 29/8 | s:cp pan:1 ]",
"[ 57/16 → 29/8 | s:cp pan:0 ]",
"[ 15/4 → 31/8 | s:bd pan:1 ]",
"[ 61/16 → 31/8 | s:bd pan:0 ]",
"[ 31/8 → 4/1 | s:hh pan:1 ]",
"[ 63/16 → 4/1 | s:hh pan:0 ]",
]
`;
exports[`runs examples > example "juxFlip" example index 2 1`] = `
[
"[ 0/1 → 1/8 | s:bd pan:0 ]",
"[ 0/1 → 1/8 | s:bd pan:1 ]",
"[ 1/8 → 1/4 | s:lt pan:0 ]",
"[ 1/8 → 1/4 | s:lt pan:1 ]",
"[ 5/16 → 3/8 | s:ht pan:0 ]",
"[ 5/16 → 3/8 | s:ht pan:1 ]",
"[ 3/8 → 1/2 | s:mt pan:0 ]",
"[ 3/8 → 1/2 | s:mt pan:1 ]",
"[ 1/2 → 5/8 | s:cp pan:0 ]",
"[ 1/2 → 5/8 | s:cp pan:1 ]",
"[ 3/4 → 7/8 | s:bd pan:0 ]",
"[ 3/4 → 7/8 | s:bd pan:1 ]",
"[ 7/8 → 1/1 | s:hh pan:0 ]",
"[ 7/8 → 1/1 | s:hh pan:1 ]",
"[ 1/1 → 9/8 | s:bd pan:1 ]",
"[ 17/16 → 9/8 | s:ht pan:0 ]",
"[ 9/8 → 5/4 | s:lt pan:1 ]",
"[ 9/8 → 5/4 | s:mt pan:0 ]",
"[ 5/4 → 11/8 | s:cp pan:0 ]",
"[ 21/16 → 11/8 | s:ht pan:1 ]",
"[ 11/8 → 3/2 | s:mt pan:1 ]",
"[ 3/2 → 13/8 | s:cp pan:1 ]",
"[ 3/2 → 13/8 | s:bd pan:0 ]",
"[ 13/8 → 7/4 | s:hh pan:0 ]",
"[ 7/4 → 15/8 | s:bd pan:1 ]",
"[ 7/4 → 15/8 | s:bd pan:0 ]",
"[ 15/8 → 2/1 | s:hh pan:1 ]",
"[ 15/8 → 2/1 | s:lt pan:0 ]",
"[ 2/1 → 17/8 | s:bd pan:0 ]",
"[ 2/1 → 17/8 | s:cp pan:1 ]",
"[ 17/8 → 9/4 | s:lt pan:0 ]",
"[ 9/4 → 19/8 | s:bd pan:1 ]",
"[ 37/16 → 19/8 | s:ht pan:0 ]",
"[ 19/8 → 5/2 | s:mt pan:0 ]",
"[ 19/8 → 5/2 | s:hh pan:1 ]",
"[ 5/2 → 21/8 | s:cp pan:0 ]",
"[ 5/2 → 21/8 | s:bd pan:1 ]",
"[ 21/8 → 11/4 | s:lt pan:1 ]",
"[ 11/4 → 23/8 | s:bd pan:0 ]",
"[ 45/16 → 23/8 | s:ht pan:1 ]",
"[ 23/8 → 3/1 | s:hh pan:0 ]",
"[ 23/8 → 3/1 | s:mt pan:1 ]",
"[ 3/1 → 25/8 | s:bd pan:1 ]",
"[ 3/1 → 25/8 | s:bd pan:0 ]",
"[ 25/8 → 13/4 | s:lt pan:1 ]",
"[ 25/8 → 13/4 | s:hh pan:0 ]",
"[ 13/4 → 27/8 | s:bd pan:0 ]",
"[ 53/16 → 27/8 | s:ht pan:1 ]",
"[ 27/8 → 7/2 | s:mt pan:1 ]",
"[ 27/8 → 7/2 | s:lt pan:0 ]",
"[ 7/2 → 29/8 | s:cp pan:1 ]",
"[ 57/16 → 29/8 | s:ht pan:0 ]",
"[ 29/8 → 15/4 | s:mt pan:0 ]",
"[ 15/4 → 31/8 | s:bd pan:1 ]",
"[ 15/4 → 31/8 | s:cp pan:0 ]",
"[ 31/8 → 4/1 | s:hh pan:1 ]",
]
`;
exports[`runs examples > example "juxFlipBy" example index 0 1`] = `
[
"[ 0/1 → 1/8 | s:bd pan:0.09999999999999998 ]",
"[ 0/1 → 1/8 | s:hh pan:0.9 ]",
"[ 1/8 → 1/4 | s:lt pan:0.09999999999999998 ]",
"[ 1/8 → 1/4 | s:bd pan:0.9 ]",
"[ 5/16 → 3/8 | s:ht pan:0.09999999999999998 ]",
"[ 3/8 → 1/2 | s:mt pan:0.09999999999999998 ]",
"[ 3/8 → 1/2 | s:cp pan:0.9 ]",
"[ 1/2 → 5/8 | s:cp pan:0.09999999999999998 ]",
"[ 1/2 → 5/8 | s:mt pan:0.9 ]",
"[ 5/8 → 11/16 | s:ht pan:0.9 ]",
"[ 3/4 → 7/8 | s:bd pan:0.09999999999999998 ]",
"[ 3/4 → 7/8 | s:lt pan:0.9 ]",
"[ 7/8 → 1/1 | s:hh pan:0.09999999999999998 ]",
"[ 7/8 → 1/1 | s:bd pan:0.9 ]",
"[ 1/1 → 9/8 | s:bd pan:0.9 ]",
"[ 1/1 → 9/8 | s:hh pan:0.09999999999999998 ]",
"[ 9/8 → 5/4 | s:lt pan:0.9 ]",
"[ 9/8 → 5/4 | s:bd pan:0.09999999999999998 ]",
"[ 21/16 → 11/8 | s:ht pan:0.9 ]",
"[ 11/8 → 3/2 | s:mt pan:0.9 ]",
"[ 11/8 → 3/2 | s:cp pan:0.09999999999999998 ]",
"[ 3/2 → 13/8 | s:cp pan:0.9 ]",
"[ 3/2 → 13/8 | s:mt pan:0.09999999999999998 ]",
"[ 13/8 → 27/16 | s:ht pan:0.09999999999999998 ]",
"[ 7/4 → 15/8 | s:bd pan:0.9 ]",
"[ 7/4 → 15/8 | s:lt pan:0.09999999999999998 ]",
"[ 15/8 → 2/1 | s:hh pan:0.9 ]",
"[ 15/8 → 2/1 | s:bd pan:0.09999999999999998 ]",
"[ 2/1 → 17/8 | s:bd pan:0.09999999999999998 ]",
"[ 2/1 → 17/8 | s:hh pan:0.9 ]",
"[ 17/8 → 9/4 | s:lt pan:0.09999999999999998 ]",
"[ 17/8 → 9/4 | s:bd pan:0.9 ]",
"[ 37/16 → 19/8 | s:ht pan:0.09999999999999998 ]",
"[ 19/8 → 5/2 | s:mt pan:0.09999999999999998 ]",
"[ 19/8 → 5/2 | s:cp pan:0.9 ]",
"[ 5/2 → 21/8 | s:cp pan:0.09999999999999998 ]",
"[ 5/2 → 21/8 | s:mt pan:0.9 ]",
"[ 21/8 → 43/16 | s:ht pan:0.9 ]",
"[ 11/4 → 23/8 | s:bd pan:0.09999999999999998 ]",
"[ 11/4 → 23/8 | s:lt pan:0.9 ]",
"[ 23/8 → 3/1 | s:hh pan:0.09999999999999998 ]",
"[ 23/8 → 3/1 | s:bd pan:0.9 ]",
"[ 3/1 → 25/8 | s:bd pan:0.9 ]",
"[ 3/1 → 25/8 | s:hh pan:0.09999999999999998 ]",
"[ 25/8 → 13/4 | s:lt pan:0.9 ]",
"[ 25/8 → 13/4 | s:bd pan:0.09999999999999998 ]",
"[ 53/16 → 27/8 | s:ht pan:0.9 ]",
"[ 27/8 → 7/2 | s:mt pan:0.9 ]",
"[ 27/8 → 7/2 | s:cp pan:0.09999999999999998 ]",
"[ 7/2 → 29/8 | s:cp pan:0.9 ]",
"[ 7/2 → 29/8 | s:mt pan:0.09999999999999998 ]",
"[ 29/8 → 59/16 | s:ht pan:0.09999999999999998 ]",
"[ 15/4 → 31/8 | s:bd pan:0.9 ]",
"[ 15/4 → 31/8 | s:lt pan:0.09999999999999998 ]",
"[ 31/8 → 4/1 | s:hh pan:0.9 ]",
"[ 31/8 → 4/1 | s:bd pan:0.09999999999999998 ]",
]
`;
exports[`runs examples > example "keep" example index 0 1`] = `
[
"[ 0/1 → 1/4 | note:c s:piano ]",
@@ -7683,6 +7956,8 @@ exports[`runs examples > example "midikeys" example index 0 1`] = `[]`;
exports[`runs examples > example "midikeys" example index 1 1`] = `[]`;
exports[`runs examples > example "midikeys" example index 2 1`] = `[]`;
exports[`runs examples > example "midin" example index 0 1`] = `
[
"[ 0/1 → 1/4 | note:c cutoff:0 resonance:0 s:sawtooth ]",
@@ -12404,18 +12679,10 @@ exports[`runs examples > example "stepcat" example index 1 1`] = `
exports[`runs examples > example "stretch" example index 0 1`] = `
[
"[ (0/1 → 1/3) ⇝ 1/1 | s:gm_flute stretch:1 ]",
"[ 0/1 ⇜ (1/3 → 2/3) ⇝ 1/1 | s:gm_flute stretch:2 ]",
"[ 0/1 ⇜ (2/31/1) | s:gm_flute stretch:0.5 ]",
"[ (1/1 → 4/3) ⇝ 2/1 | s:gm_flute stretch:1 ]",
"[ 1/1 ⇜ (4/3 → 5/3) ⇝ 2/1 | s:gm_flute stretch:2 ]",
"[ 1/1 ⇜ (5/3 → 2/1) | s:gm_flute stretch:0.5 ]",
"[ (2/1 → 7/3) ⇝ 3/1 | s:gm_flute stretch:1 ]",
"[ 2/1 ⇜ (7/3 → 8/3) ⇝ 3/1 | s:gm_flute stretch:2 ]",
"[ 2/1 ⇜ (8/3 → 3/1) | s:gm_flute stretch:0.5 ]",
"[ (3/1 → 10/3) ⇝ 4/1 | s:gm_flute stretch:1 ]",
"[ 3/1 ⇜ (10/3 → 11/3) ⇝ 4/1 | s:gm_flute stretch:2 ]",
"[ 3/1 ⇜ (11/3 → 4/1) | s:gm_flute stretch:0.5 ]",
"[ 0/1 → 1/1 | s:gm_flute stretch:2 ]",
"[ 1/1 → 2/1 | s:gm_flute stretch:1 ]",
"[ 2/13/1 | s:gm_flute stretch:0 ]",
"[ 3/1 → 4/1 | s:gm_flute stretch:-2 ]",
]
`;
+1
View File
@@ -78,6 +78,7 @@ export default defineConfig({
urlPattern: ({ url }) =>
[
/^https:\/\/raw\.githubusercontent\.com\/.*/i,
/^https:\/\/strudel\.b-cdn\.net\/.*/i,
/^https:\/\/freesound\.org\/.*/i,
/^https:\/\/cdn\.freesound\.org\/.*/i,
/^https:\/\/shabda\.ndre\.gr\/.*/i,
+1
View File
@@ -98,6 +98,7 @@ export const SIDEBAR: Sidebar = {
{ text: 'Random Modifiers', link: 'learn/random-modifiers' },
{ text: 'Conditional Modifiers', link: 'learn/conditional-modifiers' },
{ text: 'Accumulation', link: 'learn/accumulation' },
{ text: 'LFOs', link: 'learn/lfo' },
{ text: 'Tonal Functions', link: 'learn/tonal' },
{ text: 'Stepwise Functions', link: 'learn/stepwise' },
],
+301
View File
@@ -0,0 +1,301 @@
---
title: Low-frequency oscillators (LFO)
layout: ../../layouts/MainLayout.astro
---
import { MiniRepl } from '../../docs/MiniRepl';
import { JsDoc } from '../../docs/JsDoc';
# Low frequency oscillators (LFO)
A low frequency oscillator (or short LFO) is a common way on synthesizers to continuously modulate various signals.
This documentation is an interactive version of glossing's tutorial https://www.youtube.com/watch?v=11frBA9L638
## Signals vs LFOs
In Strudel, there are two ways to modulate:
1. [signals](/learn/signals/) for pattern-level modulation
2. `lfo` (this page) for audio-level modulation
## Applying an LFO
Here, the LFO will change the frequency of the `saw`. Put a comment like this `//.lfo()` to see and hear how it changes, and remove the comment again.
<MiniRepl
client:idle
tune={`
s("saw").lfo()
.lpf(800)
._spectrum({height: 300, width: 800})`}
/>
By default, the LFO will modulate the control parameter which is right before `.lfo()`:
<MiniRepl
client:idle
tune={`
s("saw")
.lpf(800).lfo()
._spectrum({height: 300, width: 800})`}
/>
Here, the LFO will modulate the low pass filter `.lpf`.
## Moving away from the default
The following sections explain how pass parameters to `.lfo`. Similar to `._spectrum` above, almost all the configuration of `lfo` lives inside a json object, starting with `{` and ending with `}`.
All the parameters (except `id`) are written as `key: value` inside and separated by `,`.
The reference refers to them as `config.key`, i.e. for the following one as `config.control` but you use them like below.
## Control
`control` determines which parameter will be modulated. This allows you to place your `lfo` at different places,
not necessarily immediately after the controlled parameter.
Here, we place `lfo` after the `s`, but it modulates the low pass filter.
<MiniRepl
client:idle
tune={`
s("saw")
.lfo({control:'lpf'})
.lpf(800)
._spectrum({height: 300, width: 800})`}
/>
You can even influence parameters which are always present, even if you haven't explicitly written them, like `gain`.
<MiniRepl
client:idle
tune={`
s("saw")
.lfo({control:'gain'})
.lpf(800)
._spectrum({height: 300, width: 800})`}
/>
`control` has an alias `c`.
## Rate
`rate` determines how often the `lfo` oscillates per second:
<MiniRepl
client:idle
tune={`
s("saw")
.lfo({c:'gain', rate:"<2 4>"})
.lpf(800)
._spectrum({height: 300, width: 800})`}
/>
The alias of `rate` is `r`.{' '}
## Sync
Instead of controlling the frequency with `rate` by setting a frequency in Hz, you can use `sync`
to snychronize your lfo with your other patterns.
`sync` expresses this frequency as "times per cycle"
Try removing the `sync: "<2 4 8 0.5 >"` from the pattern and notice that there is something not in sync.
<MiniRepl
client:idle
tune={`
$: s("bd*4").bank("TR909").postgain(0.5)
$: s("saw")
.lpf(800)
.lfo({sync: "<2 4 8 0.5 >"})
._spectrum({height: 300, width: 800})`}
/>
You can put patterns into the parameters of `lfo` if you want them to change over time, as seen above.
## Relative Depth
`.depth` is relative depth, a value of 1 (the default) means that
the value goes above and below by half of the value which is being modulated
E.g. for depth `1`, it modulates the frequency to oscillate between 32 = (64/2) and 96 (= 64 + 64/2).
<MiniRepl
client:idle
tune={`
s("saw").freq(64)
.lfo({r: 2, depth: "<1 2 3>"})
.lpf(800)
._spectrum({height: 300, width: 800})`}
/>
The `freq` is not needed here, as this is the default frequency, it's just for instructive purposes.
The aliases of `depth` are `dr` and `dep`.
## Absolute Depth
`depthabs` controls the absolute modulation depth. For example you can modulate
the low pass filter by exactly 250 Hz up and below:
<MiniRepl
client:idle
tune={`
s("saw")
.lpf(800)
.lfo({r: 2, depthabs: "250"})`}
/>
The alias of `depthabs` is `da`.
## DC offset
If you don't want to go up or down by the same amount with your modulation, then you can shift the center of the modulation with `dcoffset`.
The default value is -0.5, which is the middle point between:
"dcoffset = 0: All modulations increase the control parameter (or keep it constant)"
"dcoffset = -1: All modulations decrease the control parameter (or keep it constant)"
Other values will work as well.
<MiniRepl
client:idle
tune={`
s("saw")
.lpf(600)
.lfo({r: 2, da: "200", dcoffset: "<-0.5 -1 -0.5 0>"})`}
/>
The marvellous alias of `dcoffset` is `dc`.
## Shape
You can change the shape of the modulation with `shape`. The default is `triangle`, but other shapes are available too:
<MiniRepl
client:idle
tune={`
s("saw")
.lpf(800)
.lfo({r: 2, shape: "<triangle sine ramp saw square>"}) `}
/>
You can add `._spectrum()` to see the shape of the modulations in the spectrum.
You can also get these shapes by using numbers:
| Shape | number |
| -------- | ------ |
| triangle | 0 |
| sine | 1 |
| ramp | 2 |
| saw | 3 |
| square | 4 |
this way, you can use a function like `irand` to generate numbers:
<MiniRepl
client:idle
tune={`
s("saw")
.lpf(800)
.lfo({r: 2, shape: irand(4)}) `}
/>
The alias of `shape` is `sh`.
## Skewing some shapes
You can influence some of the shapes (`triangle` and `square`) in more detail.
The default skew is 0.5, it does different things for these two.
For `triangle`, it skews the top of the triangle to the left or right,
where 0 makes it look like `saw` and 1 makes it look like `ramp`.
For `square`, the skew influences the pulse width (see reference for `pulse` and `.pw`):
<MiniRepl
client:idle
tune={`
s("saw")
.lpf(800)
.lfo({r: 2, sh: "<triangle square>/5",
skew: "<0 0.25 0.5 0.75 1>"}) `}
/>
The alias of `skew` is `sk`.{' '}
## Curve
You can change the curves of your lfo and can make it more intense.
The default value is 1. Writing numbers greater than one can make it more intense,
numbers between 0 and 1 will make it less intense.
This will raise the lfo to the power of curve, so larger numbers (such as 10) can have very unexpected results.
<MiniRepl
client:idle
tune={`
s("saw")
.lpf(800)
.lfo({r: 2, sh: "<triangle>", curve: "<1.3 1 0.75 1>"}) `}
/>
## Referencing your lfos with id
All the lfos are numbered from the first starting with 0, the second having an `id` of 1 and so on.
You can refer to this in a later call if you want to modify a specific `lfo`.
The `id` is outside of the config json (which is different from the other parameters of `lfo()`
Try out how the sound changes when you replace the 0 with a 1.
<MiniRepl
client:idle
tune={`
s("saw").lfo().lpf(800)
.lfo({s: "<4 8 0.5>"})
.sometimes(x => x.lfo({dr: "4"},0))`}
/>
You can also name your lfos and refer to them by name, using the `id` parameter
<MiniRepl
client:idle
tune={`
s("saw").lfo({}, "lfo_freq_saw").lpf(800)
.lfo({s: "<4 8 0.5>"}, "lfo_lpf")
.sometimes(x => x.lfo({dr: "4"},"<lfo_lpf lfo_freq_saw>"))`}
/>
## FX index
If you are using `FX()` to reorder your effects, you dont need to write your lfos inside the `FX`,
but instead can refer to them by their FX index (starting with 0)
<MiniRepl
client:idle
tune={`
s("saw").FX(
distort(3),
gain(0.3), // this has the fx index 1
lpf(400)
).lfo({s: 16, dr:2, c:"gain", fxi: 1})`}
/>
## Modulating other LFOs with Sub-control
LFOs can modulate other lfos and will modulate their frequency (given by `r` or `s`):
<MiniRepl
client:idle
tune={`
s("saw").lpf(400).gain(0.8)
.lfo({s: 16, dr:2, c:"gain"})
.lfo({s: 0.3, dc:-1, dr: 0.8})`}
/>
To modulate other parameters of the first lfo (like `skew`, `depth` and so on), we can specify this with `subControl`or
its alias `sc`
<MiniRepl
client:idle
tune={`
s("saw").lpf(400).gain(0.8)
.lfo({s: 4, dr:2, c:"gain"})
.lfo({s: 0.3, sc: "skew"})`}
/>
+117
View File
@@ -0,0 +1,117 @@
---
title: Movement with Strudel
layout: ../../layouts/MainLayout.astro
---
import { MiniRepl } from '@src/docs/MiniRepl';
import Box from '@components/Box.astro';
import QA from '@components/QA';
# Controlling motors with Strudel
Strudel is mainly made for making music, but it's possible to pattern other things with it, including motors.
We're going to use a microcontroller for this, called an "[Inventor 2040W](https://shop.pimoroni.com/products/inventor-2040-w)", which is
a [Pico W](https://shop.pimoroni.com/products/inventor-2040-w?variant=40053063155795) with extra ports added including some for controlling motors.
![image](https://shop.pimoroni.com/cdn/shop/products/Inventor2040_1of3_1500x1500_crop_center.jpg?v=1656927927)
## Technical details
Feel free to gloss over these!
- The Inventor 2040W connects to the internet wirelessly, and it can power from a battery or USB. Hopefully the batteries last!
- It's running [some code](https://github.com/patternclub/alpacalab/blob/main/course/main.py) that listens for messages using an "Internet of Things" network protocol (called MQTT). When it receives a message, it moves a motor.
- It connects to a small server (running software called 'mosquitto') on Alex's laptop.
- Strudel can send these messages instead of triggering sounds - that's how we use it to pattern movement.
## First movement
Let's get a motor running!
1. Note the letter drawn on a label on the back of the microcontroller.
2. Plug a battery into your microcontroller.
3. Plug a motor into 'servo' (not motor) plug numbered 1, with the yellow (lightest) cable closest to the '1', and the brown (darkest) cable outward
4. Run the below to set up some values, changing the `x` in 'robot('x')` to the letter on your microcontroller.
<MiniRepl
client:visible
tune={`
$: move("-60 80").motor("0").robot('x');
`}
/>
<Box>
If you refresh the page, you'll need to change the letter to match your robot again.
If your motor starts moving unexpectedly, someone else might have put your letter in by mistake!
Note that in the above, we start counting motors from '0', so motor 1 on the board is motor 0 in the code.
</Box>
## Patterning movement
Many strudel features for playing with sound patterns will work when
playing with motor patterns. Try playing with the mininotation in the
`move` command:
<MiniRepl
client:visible
tune={`
$: move("-10 0 10 [20 30]*2").motor("0").slow(2).robot('x')
`}
/>
The move instructions are in the range from -90 to 90.
<box>
If your motors stop working at some point, and your code looks right, try pressing the 'reset' button on the
microcontroller.
</box>
It's possible to make smooth movements based on different 'waveforms', for example a smooth sinewave:
<MiniRepl
client:visible
tune={`
$: move(sine.range(-30, 30).segment(16)).motor("0").slow(2).robot('x');
`}
/>
The movement is still quite jerky, because the 'segment' command is
only taking 16 positions from the sinewave. Try increasing it to 32 or 64. It's best not too much higher than that, as the microcontroller
might get overwhelmed with a backlog of instructions!
<box>
Try replacing `sine` with other waveforms: `saw` (sawtooth wave), `tri` (triangular wave) are good, and there is also
`rand` (random wave) and `perlin` (a kind of smoothed-out randomness).
</box>
## Patterning more than one motor
You can pattern the `motor` command separately from the `move` one:
<MiniRepl
client:visible
tune={`
$: move("-10 0 10 [20 30]*2").motor("0 1").slow(2).robot('x');
`}
/>
Alternatively, you can pattern two motors in separate patterns. The below sends the same pattern for the first two motors, but with the second one running slower:
<MiniRepl
client:visible
tune={`
$: move("-10 0 10 [20 30]\*2").motor("0").slow(2).robot('x');
$: move("-10 0 10 [20 30]\*2").motor("1").slow(3).robot('x');
`}
/>
@@ -44,6 +44,25 @@ export function LogoButton({ context, isEmbedded }) {
export function MainPanel({ context, isEmbedded = false, className }) {
const { isZen, isButtonRowHidden, fontFamily } = useSettings();
let loc = window.location;
let ver = 'unofficial';
let hot = false;
let b = loc.hostname.match(/^(.+)\.(strudel)/);
if (/(strudel.cc$)/.test(loc.hostname)) {
// if there's no text before 'strudel', it's warm, otherwise use the text before strudel
ver = b ? b[1] : 'warm';
} else {
// match both versions of localhost
if (/(localhost)|(127.0.0.1)/.test(loc.hostname)) ver = 'dev';
}
let pr = ver.match(/pr-([0-9]+)/);
if (pr) {
pr = pr[1];
ver = `hot: ${pr}`;
hot = true;
pr = `https://codeberg.org/uzu/strudel/pulls/${pr}`;
}
return (
<nav
id="header"
@@ -72,6 +91,13 @@ export function MainPanel({ context, isEmbedded = false, className }) {
<div className="space-x-2 flex items-baseline">
<span className="hidden sm:block">strudel</span>
<span className="text-sm font-medium hidden sm:block">REPL</span>
{!hot ? (
<span className="text-sm font-medium hidden sm:block">({ver})</span>
) : (
<a className="hover:opacity-50" href={pr} target="_blank">
<span className="text-sm font-medium hidden sm:block">({ver})</span>
</a>
)}
</div>
)}
</h1>