Compare commits

..

1 Commits

Author SHA1 Message Date
alex 1756713096 draft agents text 2026-11-22 10:48:48 +00:00
37 changed files with 216 additions and 418 deletions
+23
View File
@@ -0,0 +1,23 @@
In line with [our humane policy](POLICY.md), code and documentation
should not be written by LLM agents. To this end, agents should not
edit the codebase or make any commits that are intended to be
contributed upstream. Likewise, LLM output should not be pasted into
issues, comments, pull requests and so on.
A contributor's personal use of LLMs and related technology is their
own business, whether for research, analysis, bug discovery or other
assistive technology, so long as the output is not included in any
contributions to our projects.
Strudel is AGPL licensed, and so any code integrated with it also
comes under that license. This should be carefully considered before
distributing software integrated with strudel, including making it
available over a network.
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.
Projects using strudel must not use "strudel" in their name, unless
they are 'official' projects, or have the blessing of the strudel
community.
+4 -13
View File
@@ -73,15 +73,6 @@ export function registerControl(names, ...aliases) {
return bag;
}
// Constructs a superdirt effect bus control
const sdbus = register('sdbus', function (busid, control_name, busval, pat) {
return pat[control_name]('c' + busid).withValue((val) => {
const newval = { ...val };
newval['^' + control_name] = [busid, busval];
return newval;
});
});
export function registerMultiControl(names, maxControls, ...aliases) {
names = Array.isArray(names) ? names : [names];
let bag = {};
@@ -3018,7 +3009,7 @@ export const as = register('as', (mapping, pat) => {
* @name scrub
* @tags samples
* @memberof Pattern
* @returns {Pattern}
* @returns Pattern
* @example
* samples('github:switchangel/pad')
* s("swpad:0").scrub("{0.1!2 .25@3 0.7!2 <0.8:1.5>}%8")
@@ -3172,7 +3163,7 @@ Pattern.prototype.modulate = function (type, config, idPat) {
* @param {number | Pattern} [config.retrig] If > 0.5, the LFO will retrigger on each event. Aliases: rt
* @param {number | Pattern} [config.fxi] FX index to target
* @param {string | Pattern} id ID to use for this modulator
* @returns {Pattern}
* @returns Pattern
*
* @example
* s("saw").note("F1").lpf(500).lfo()
@@ -3227,7 +3218,7 @@ export const lfo = (config) => pure({}).lfo(config);
* @param {number | Pattern} [config.rcurve] Snappiness of release curve (-1 = relaxed, 1 = snappy). Aliases: rc
* @param {number | Pattern} [config.fxi] FX index to target
* @param {string | Pattern} id ID to use for this modulator
* @returns {Pattern}
* @returns Pattern
*
* @example
* s("saw").note("F1").lpf(500).env({ a: 1 })
@@ -3283,7 +3274,7 @@ export const env = (config) => pure({}).env(config);
* @param {number | Pattern} [config.dc] DC offset prior to application
* @param {number | Pattern} [config.fxi] FX index to target
* @param {string | Pattern} id ID to use for this modulator
* @returns {Pattern}
* @returns Pattern
*
* @example
* modulator: s("one").seg(64).gain(slider(0, 0, 1)).bus(1).dry(0)
+5 -5
View File
@@ -74,12 +74,12 @@ export class Cyclist {
// query the pattern for events
const haps = this.pattern
.queryArc(begin, end, { _cps: this.cps, cyclist: 'cyclist' })
.filter((hap) => hap.hasOnset() || hap.context.processParts)
.filter((hap) => hap.hasOnset())
// Sort the haps based on their onset, so cps changes within the
// tick duration happen in the correct order.
.sort((a, b) => {
const aBegin = a.part.begin;
const bBegin = b.part.begin;
const aBegin = a.whole.begin;
const bBegin = b.whole.begin;
// If haps happen at the same time, trigger the haps that cause
// cps changes first, so the durations of the simultaneous haps
// are adjusted accordingly.
@@ -96,7 +96,7 @@ export class Cyclist {
});
haps.forEach((hap) => {
const targetTime = (hap.part.begin - this.checkpoint.cycles) / this.cps + this.checkpoint.seconds;
const targetTime = (hap.whole.begin - this.checkpoint.cycles) / this.cps + this.checkpoint.seconds;
if (tickEndTime < targetTime) {
// If the targetTime exceeds the tickEndTime, this means
// the cps has slowed down, and the latter haps from the query
@@ -110,7 +110,7 @@ export class Cyclist {
this.cps = hap.value.cps;
this.num_ticks_since_checkpoint = 0;
this.checkpoint = {
cycles: hap.part.begin,
cycles: hap.whole.begin,
seconds: targetTime,
};
}
+1 -1
View File
@@ -18,7 +18,7 @@ import Fraction, { gcd } from './fraction.mjs';
* @tags visualization
* @param {Pattern} pattern the pattern to use
* @param {number} chars max number of characters (approximately)
* @returns {string}
* @returns string
* @example
* const line = drawLine("0 [1 2 3]", 10); // |0--123|0--123
* console.log(line);
+2 -2
View File
@@ -69,7 +69,7 @@ export const bjorklund = function (ons, steps) {
* @tags temporal
* @param {number} pulses the number of onsets/beats
* @param {number} steps the number of steps to fill
* @returns {Pattern}
* @returns Pattern
* @example
* // The Cuban tresillo pattern.
* note("c3").euclid(3,8)
@@ -83,7 +83,7 @@ export const bjorklund = function (ons, steps) {
* @param {number} pulses the number of onsets/beats
* @param {number} steps the number of steps to fill
* @param {number} rotation offset in steps
* @returns {Pattern}
* @returns Pattern
* @example
* // A Samba rhythm necklace from Brazil
* note("c3").euclidRot(3,16,14)
+1 -5
View File
@@ -16,7 +16,7 @@ export class Hap {
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 context is to store a list of source code locations causing the event.
The word 'Event' is more or less a reserved word in javascript, hence this
class is named called 'Hap'.
@@ -161,10 +161,6 @@ export class Hap {
return new Hap(this.whole, this.part, this.value, context);
}
withContext(f) {
return new Hap(this.whole, this.part, this.value, f(this.context));
}
ensureObjectValue() {
/* if (isNote(hap.value)) {
// supports primitive hap values that look like notes
+76 -81
View File
@@ -64,12 +64,7 @@ export class Pattern {
this.__steps = steps === undefined ? undefined : Fraction(steps);
}
_processParts() {
return this.withHap((hap) => hap.withContext((c) => ({ ...c, processParts: true })));
}
setSteps(steps) {
// TODO shouldn't this be pure and return a new pattern?
this._steps = steps;
return this;
}
@@ -94,7 +89,7 @@ export class Pattern {
* @tags functional
* @synonyms fmap
* @param {Function} func to to apply to the value
* @returns {Pattern}
* @returns Pattern
* @example
* "0 1 2".withValue(v => v + 10).log()
*/
@@ -125,7 +120,7 @@ export class Pattern {
* @param {Function} whole_func
* @param {Function} func
* @noAutocomplete
* @returns {Pattern}
* @returns Pattern
*/
appWhole(whole_func, pat_val) {
const pat_func = this;
@@ -162,7 +157,7 @@ export class Pattern {
* @tags functional
* @param {Pattern} pat_val
* @noAutocomplete
* @returns {Pattern}
* @returns Pattern
*/
appBoth(pat_val) {
const pat_func = this;
@@ -190,7 +185,7 @@ export class Pattern {
* @tags functional
* @param {Pattern} pat_val
* @noAutocomplete
* @returns {Pattern}
* @returns Pattern
*/
appLeft(pat_val) {
const pat_func = this;
@@ -224,7 +219,7 @@ export class Pattern {
* @tags functional
* @param {Pattern} pat_val
* @noAutocomplete
* @returns {Pattern}
* @returns Pattern
*/
appRight(pat_val) {
const pat_func = this;
@@ -415,7 +410,7 @@ export class Pattern {
* @tags internals
* @param {Fraction | number} begin from time
* @param {Fraction | number} end to time
* @returns {Hap[]}
* @returns Hap[]
* @example
* const pattern = sequence('a', ['b', 'c'])
* const haps = pattern.queryArc(0, 1)
@@ -437,7 +432,7 @@ export class Pattern {
* some calculations easier to express, as all haps are then constrained to
* happen within a cycle.
* @tags internals
* @returns {Pattern}
* @returns Pattern
* @noAutocomplete
*/
splitQueries() {
@@ -453,7 +448,7 @@ export class Pattern {
* timespan before passing it to the original pattern.
* @tags internals
* @param {Function} func the function to apply
* @returns {Pattern}
* @returns Pattern
* @noAutocomplete
*/
withQuerySpan(func) {
@@ -476,7 +471,7 @@ export class Pattern {
* begin and end time of the query timespan.
* @tags internals
* @param {Function} func the function to apply
* @returns {Pattern}
* @returns Pattern
* @noAutocomplete
*/
withQueryTime(func) {
@@ -489,7 +484,7 @@ export class Pattern {
* present, `whole` timespans).
* @tags internals
* @param {Function} func
* @returns {Pattern}
* @returns Pattern
* @noAutocomplete
*/
withHapSpan(func) {
@@ -501,7 +496,7 @@ export class Pattern {
* begin and end time of the hap timespans.
* @tags internals
* @param {Function} func the function to apply
* @returns {Pattern}
* @returns Pattern
* @noAutocomplete
*/
withHapTime(func) {
@@ -514,7 +509,7 @@ export class Pattern {
* As an end user, you will most likely not need to use this; look at `withContext`, `withHapSpan`, etc. instead.
* @tags internals
* @param {Function} func
* @returns {Pattern}
* @returns Pattern
* @noAutocomplete
* @example
* note("[a b, c d] a b c d").s("gm_piano").withHaps(x=>{
@@ -542,7 +537,7 @@ export class Pattern {
* As an end user, you will most likely not need to use this; look at `withContext`, `withHapSpan`, etc. instead.
* @tags internals
* @param {Function} func
* @returns {Pattern}
* @returns Pattern
* @noAutocomplete
* @example
* note("c a f e").withHap(x=>{
@@ -564,7 +559,7 @@ export class Pattern {
* Returns a new pattern with the context field set to every hap set to the given value.
* @tags internals
* @param {*} context
* @returns {Pattern}
* @returns Pattern
* @noAutocomplete
*/
setContext(context) {
@@ -575,7 +570,7 @@ export class Pattern {
* Returns a new pattern with the given function applied to the context field of every hap.
* @tags internals
* @param {Function} func
* @returns {Pattern}
* @returns Pattern
* @noAutocomplete
*/
withContext(func) {
@@ -590,7 +585,7 @@ export class Pattern {
/**
* Returns a new pattern with the context field of every hap set to an empty object.
* @tags internals
* @returns {Pattern}
* @returns Pattern
* @noAutocomplete
*/
stripContext() {
@@ -603,7 +598,7 @@ export class Pattern {
* @tags internals
* @param {Number} start start offset
* @param {Number} end end offset
* @returns {Pattern}
* @returns Pattern
* @noAutocomplete
*/
withLoc(start, end) {
@@ -626,7 +621,7 @@ export class Pattern {
* Returns a new Pattern, which only returns haps that meet the given test.
* @tags internals
* @param {Function} hap_test - a function which returns false for haps to be removed from the pattern
* @returns {Pattern}
* @returns Pattern
* @example
* s("bd*8").velocity(rand).filterHaps((h) => (h.whole.begin % 1) < h.value.velocity)
*/
@@ -639,7 +634,7 @@ export class Pattern {
* inside haps.
* @tags internals
* @param {Function} value_test
* @returns {Pattern}
* @returns Pattern
* @example
* const drums = s("bd sd bd sd")
* kick: drums.filterValues((v) => v.s === 'bd').duck(2)
@@ -654,7 +649,7 @@ export class Pattern {
* Returns a new pattern, with haps containing undefined values removed from
* query results.
* @tags internals
* @returns {Pattern}
* @returns Pattern
* @noAutocomplete
*/
removeUndefineds() {
@@ -666,7 +661,7 @@ export class Pattern {
* with an onset is one with a `whole` timespan that begins at the same time
* as its `part` timespan.
* @tags internals
* @returns {Pattern}
* @returns Pattern
* @noAutocomplete
*/
onsetsOnly() {
@@ -680,7 +675,7 @@ export class Pattern {
* Returns a new pattern, with 'continuous' haps (those without 'whole'
* timespans) removed from query results.
* @tags internals
* @returns {Pattern}
* @returns Pattern
* @noAutocomplete
*/
discreteOnly() {
@@ -747,7 +742,7 @@ export class Pattern {
* @tags internals
* @param {Boolean} with_context - set to true, otherwise the context field
* will be stripped from the resulting haps.
* @returns {Hap[]}
* @returns [Hap]
* @noAutocomplete
*/
firstCycle(with_context = false) {
@@ -782,7 +777,7 @@ export class Pattern {
* Returns a new pattern, which returns haps sorted in temporal order. Mainly
* of use when comparing two patterns for equality, in tests.
* @tags internals
* @returns {Pattern}
* @returns Pattern
* @noAutocomplete
*/
sortHapsByPart() {
@@ -797,7 +792,7 @@ export class Pattern {
}
/**
* @Returns {Pattern} a new pattern with all values parsed as numerals.
* Returns a new pattern with all values parsed as numerals.
* @tags internals
*/
asNumber() {
@@ -852,7 +847,7 @@ export class Pattern {
* @name layer
* @tags combiners
* @memberof Pattern
* @returns {Pattern}
* @returns Pattern
* @example
* "<0 2 4 6 ~ 4 ~ 2 0!3 ~!5>*8"
* .layer(x=>x.add("0,2"))
@@ -867,7 +862,7 @@ export class Pattern {
* @name superimpose
* @tags combiners
* @memberof Pattern
* @returns {Pattern}
* @returns Pattern
* @example
* "<0 2 4 6 ~ 4 ~ 2 0!3 ~!5>*8"
* .superimpose(x=>x.add(2))
@@ -1293,7 +1288,7 @@ const COMPOSERS = {
* @tags math
* @param {any} a
* @param {any} b
* @returns {Pattern} with boolean value(s)
* @returns Pattern with boolean value(s)
*/
lt: [(a, b) => a < b],
/**
@@ -1303,7 +1298,7 @@ const COMPOSERS = {
* @tags math
* @param {any} a
* @param {any} b
* @returns {Pattern} with boolean value(s)
* @returns Pattern with boolean value(s)
*/
gt: [(a, b) => a > b],
/**
@@ -1313,7 +1308,7 @@ const COMPOSERS = {
* @tags math
* @param {any} a
* @param {any} b
* @returns {Pattern} with boolean value(s)
* @returns Pattern with boolean value(s)
*/
lte: [(a, b) => a <= b],
/**
@@ -1323,7 +1318,7 @@ const COMPOSERS = {
* @tags math
* @param {any} a
* @param {any} b
* @returns {Pattern} with boolean value(s)
* @returns Pattern with boolean value(s)
*/
gte: [(a, b) => a >= b],
/**
@@ -1333,7 +1328,7 @@ const COMPOSERS = {
* @tags math
* @param {any} a
* @param {any} b
* @returns {Pattern} with boolean value(s)
* @returns Pattern with boolean value(s)
*/
eq: [(a, b) => a == b],
/**
@@ -1343,7 +1338,7 @@ const COMPOSERS = {
* @tags math
* @param {any} a
* @param {any} b
* @returns {Pattern} with boolean value(s)
* @returns Pattern with boolean value(s)
*/
eqt: [(a, b) => a === b],
/**
@@ -1353,7 +1348,7 @@ const COMPOSERS = {
* @tags math
* @param {any} a
* @param {any} b
* @returns {Pattern} with boolean value(s)
* @returns Pattern with boolean value(s)
*/
ne: [(a, b) => a != b],
/**
@@ -1363,7 +1358,7 @@ const COMPOSERS = {
* @tags math
* @param {any} a
* @param {any} b
* @returns {Pattern} with boolean value(s)
* @returns Pattern with boolean value(s)
*/
net: [(a, b) => a !== b],
/**
@@ -1373,7 +1368,7 @@ const COMPOSERS = {
* @tags math
* @param {any} a
* @param {any} b
* @returns {Pattern} with boolean value(s)
* @returns Pattern with boolean value(s)
*/
and: [(a, b) => a && b],
/**
@@ -1383,7 +1378,7 @@ const COMPOSERS = {
* @tags math
* @param {any} a
* @param {any} b
* @returns {Pattern} with boolean value(s)
* @returns Pattern with boolean value(s)
*/
or: [(a, b) => a || b],
@@ -1630,7 +1625,7 @@ export function reify(thing) {
/**
* Takes a list of patterns, and returns a pattern of lists.
* @returns {Pattern}
*
* @tags temporal
*/
export function sequenceP(pats) {
@@ -2126,7 +2121,7 @@ function stepRegister(name, func, patternify = true, preserveSteps = false, join
* @name round
* @tags math
* @memberof Pattern
* @returns {Pattern}
* @returns Pattern
* @example
* n("0.5 1.5 2.5".round()).scale("C:major")
*/
@@ -2140,7 +2135,7 @@ export const round = register('round', function (pat) {
* @name floor
* @memberof Pattern
* @tags math
* @returns {Pattern}
* @returns Pattern
* @example
* note("42 42.1 42.5 43".floor())
*/
@@ -2157,7 +2152,7 @@ export const log2 = register('log2', (pat) => pat.asNumber().fmap((v) => Math.lo
* @name ceil
* @memberof Pattern
* @tags math
* @returns {Pattern}
* @returns Pattern
* @example
* note("42 42.1 42.5 43".ceil())
*/
@@ -2168,7 +2163,7 @@ export const ceil = register('ceil', function (pat) {
* Assumes a numerical pattern, containing unipolar values in the range 0 ..
* 1. Returns a new pattern with values scaled to the bipolar range -1 .. 1
* @tags math
* @returns {Pattern}
* @returns Pattern
* @noAutocomplete
*/
export const toBipolar = register('toBipolar', function (pat) {
@@ -2179,7 +2174,7 @@ export const toBipolar = register('toBipolar', function (pat) {
* Assumes a numerical pattern, containing bipolar values in the range -1 .. 1
* Returns a new pattern with values scaled to the unipolar range 0 .. 1
* @tags math
* @returns {Pattern}
* @returns Pattern
* @noAutocomplete
*/
export const fromBipolar = register('fromBipolar', function (pat) {
@@ -2193,7 +2188,7 @@ export const fromBipolar = register('fromBipolar', function (pat) {
* @name range
* @memberof Pattern
* @tags math
* @returns {Pattern}
* @returns Pattern
* @example
* s("[bd sd]*2,hh*8")
* .cutoff(sine.range(500,4000))
@@ -2209,7 +2204,7 @@ export const range = register('range', function (min, max, pat) {
* @name rangex
* @memberof Pattern
* @tags math
* @returns {Pattern}
* @returns Pattern
* @example
* s("[bd sd]*2,hh*8")
* .cutoff(sine.rangex(500,4000))
@@ -2224,7 +2219,7 @@ export const rangex = register('rangex', function (min, max, pat) {
* @name range2
* @memberof Pattern
* @tags math
* @returns {Pattern}
* @returns Pattern
* @example
* s("[bd sd]*2,hh*8")
* .cutoff(sine2.range2(500,4000))
@@ -2239,7 +2234,7 @@ export const range2 = register('range2', function (min, max, pat) {
* @name ratio
* @memberof Pattern
* @tags math
* @returns {Pattern}
* @returns Pattern
* @example
* ratio("1, 5:4, 3:2").mul(110)
* .freq().s("piano")
@@ -2355,7 +2350,7 @@ export const ply = register('ply', function (factor, pat) {
* @synonyms density
* @memberof Pattern
* @param {number | Pattern} factor speed up factor
* @returns {Pattern}
* @returns Pattern
* @example
* s("bd hh sd hh").fast(2) // s("[bd hh sd hh]*2")
*/
@@ -2391,7 +2386,7 @@ export const hurry = register('hurry', function (r, pat) {
* @synonyms sparsity
* @memberof Pattern
* @param {number | Pattern} factor slow down factor
* @returns {Pattern}
* @returns Pattern
* @example
* s("bd hh sd hh").slow(2) // s("[bd hh sd hh]/2")
*/
@@ -2431,7 +2426,7 @@ export const outside = register('outside', function (factor, f, pat) {
* @memberof Pattern
* @param {number} n how many cycles
* @param {function} func function to apply
* @returns {Pattern}
* @returns Pattern
* @example
* note("c3 d3 e3 g3").lastOf(4, x=>x.rev())
*/
@@ -2448,7 +2443,7 @@ export const lastOf = register('lastOf', function (n, func, pat) {
* @memberof Pattern
* @param {number} n how many cycles
* @param {function} func function to apply
* @returns {Pattern}
* @returns Pattern
* @example
* note("c3 d3 e3 g3").firstOf(4, x=>x.rev())
*/
@@ -2460,7 +2455,7 @@ export const lastOf = register('lastOf', function (n, func, pat) {
* @memberof Pattern
* @param {number} n how many cycles
* @param {function} func function to apply
* @returns {Pattern}
* @returns Pattern
* @example
* note("c3 d3 e3 g3").every(4, x=>x.rev())
*/
@@ -2500,7 +2495,7 @@ export const cpm = register('cpm', function (cpm, pat) {
* @name early
* @memberof Pattern
* @param {number | Pattern} cycles number of cycles to nudge left
* @returns {Pattern}
* @returns Pattern
* @example
* "bd ~".stack("hh ~".early(.1)).s()
*/
@@ -2521,7 +2516,7 @@ export const early = register(
* @name late
* @memberof Pattern
* @param {number | Pattern} cycles number of cycles to nudge right
* @returns {Pattern}
* @returns Pattern
* @example
* "bd ~".stack("hh ~".late(.1)).s()
*/
@@ -2738,7 +2733,7 @@ export const { invert, inv } = register(
* @memberof Pattern
* @param {Pattern} binary_pat
* @param {function} func
* @returns {Pattern}
* @returns Pattern
* @example
* "c3 eb3 g3".when("<0 1>/2", x=>x.sub("5")).note()
*/
@@ -2753,7 +2748,7 @@ export const when = register('when', function (on, func, pat) {
* @memberof Pattern
* @param {Pattern | number} time offset time
* @param {function} func function to apply
* @returns {Pattern}
* @returns Pattern
* @example
* "c3 eb3 g3".off(1/8, x=>x.add(7)).note()
*/
@@ -2767,7 +2762,7 @@ export const off = register('off', function (time_pat, func, pat) {
* breakbeat feel.
* @name brak
* @tags temporal
* @returns {Pattern}
* @returns Pattern
* @memberof Pattern
* @example
* s("bd hh!2 rim").brak()
@@ -2782,7 +2777,7 @@ export const brak = register('brak', function (pat) {
* @tags temporal
* @name rev
* @memberof Pattern
* @returns {Pattern}
* @returns Pattern
* @example
* note("c d e g").rev()
*/
@@ -2816,7 +2811,7 @@ export const rev = register(
* @name revv
* @tags temporal
* @memberof Pattern
* @returns {Pattern}
* @returns Pattern
* @example
* // This is the same as `<[g e] [d c]>`. If `rev()` is used, you get
* // the same as `<[d c] [g e]>`, where each cycle reverses, but the order of
@@ -2971,7 +2966,7 @@ export const { echoWith, echowith, stutWith, stutwith } = register(
* @tags temporal
* @name echo
* @memberof Pattern
* @returns {Pattern}
* @returns Pattern
* @param {number} times how many times to repeat
* @param {number} time cycle offset between iterations
* @param {number} feedback velocity multiplicator for each iteration
@@ -3054,7 +3049,7 @@ export const plyForEach = register(['plyForEach', 'plyforeach'], function (facto
* @tags temporal
* @name iter
* @memberof Pattern
* @returns {Pattern}
* @returns Pattern
* @example
* note("0 1 2 3".scale('A minor')).iter(4)
*/
@@ -3083,7 +3078,7 @@ export const iter = register(
* @name iterBack
* @synonyms iterback
* @memberof Pattern
* @returns {Pattern}
* @returns Pattern
* @example
* note("0 1 2 3".scale('A minor')).iterBack(4)
*/
@@ -3101,7 +3096,7 @@ export const { iterBack, iterback } = register(
* @tags temporal
* @name repeatCycles
* @memberof Pattern
* @returns {Pattern}
* @returns Pattern
* @example
* note(irand(12).add(34)).segment(4).repeatCycles(2).s("gm_acoustic_guitar_nylon")
*/
@@ -3126,7 +3121,7 @@ export const { repeatCycles } = register(
* @name chunk
* @synonyms slowChunk, slowchunk
* @memberof Pattern
* @returns {Pattern}
* @returns Pattern
* @example
* "0 1 2 3".chunk(4, x=>x.add(7))
* .scale("A:minor").note()
@@ -3158,7 +3153,7 @@ export const { chunk, slowchunk, slowChunk } = register(
* @name chunkBack
* @synonyms chunkback
* @memberof Pattern
* @returns {Pattern}
* @returns Pattern
* @example
* "0 1 2 3".chunkBack(4, x=>x.add(7))
* .scale("A:minor").note()
@@ -3179,7 +3174,7 @@ export const { chunkBack, chunkback } = register(
* @name fastChunk
* @synonyms fastchunk
* @memberof Pattern
* @returns {Pattern}
* @returns Pattern
* @example
* "<0 8> 1 2 3 4 5 6 7"
* .scale("C2:major").note()
@@ -3899,7 +3894,7 @@ Pattern.prototype.steps = Pattern.prototype.pace;
* @name chop
* @tags samples
* @memberof Pattern
* @returns {Pattern}
* @returns Pattern
* @example
* samples({ rhodes: 'https://cdn.freesound.org/previews/132/132051_316502-lq.mp3' })
* s("rhodes")
@@ -3930,7 +3925,7 @@ export const chop = register('chop', function (n, pat) {
* @name striate
* @tags samples
* @memberof Pattern
* @returns {Pattern}
* @returns Pattern
* @example
* s("numbers:0 numbers:1 numbers:2").striate(6).slow(3)
*/
@@ -3949,7 +3944,7 @@ export const striate = register('striate', function (n, pat) {
* @name loopAt
* @tags samples, pitch
* @memberof Pattern
* @returns {Pattern}
* @returns Pattern
* @example
* samples({ rhodes: 'https://cdn.freesound.org/previews/132/132051_316502-lq.mp3' })
* s("rhodes").loopAt(2)
@@ -3972,7 +3967,7 @@ export const { loopAt, loopat } = register(['loopAt', 'loopat'], function (facto
* @name slice
* @tags samples
* @memberof Pattern
* @returns {Pattern}
* @returns Pattern
* @example
* samples('github:tidalcycles/dirt-samples')
* s("breaks165").slice(8, "0 1 <2 2*2> 3 [4 0] 5 6 7".every(3, rev)).slow(0.75)
@@ -4008,7 +4003,7 @@ export const slice = register(
* @name onTriggerTime
* @tags external_io
* @memberof Pattern
* @returns {Pattern}
* @returns Pattern
* @example
* s("bd!8").onTriggerTime((hap) => {console.log(hap)})
*/
@@ -4084,7 +4079,7 @@ export const fit = register('fit', (pat) =>
* @tags samples, pitch
* @memberof Pattern
* @deprecated
* @returns {Pattern}
* @returns Pattern
* @example
* samples({ rhodes: 'https://cdn.freesound.org/previews/132/132051_316502-lq.mp3' })
* s("rhodes").loopAtCps(4,1.5).cps(1.5)
@@ -4325,7 +4320,7 @@ export const chebyshev = _distortWithAlg('chebyshev');
*
* @name parray
* @tags combiners
* @returns {Pattern}
* @returns Pattern
*/
export const parray = (pats) => {
const pack = (...xs) => xs;
@@ -4393,7 +4388,7 @@ export const phases = (list) => {
* @name FX
* @tags superdough
* @memberof Pattern
* @returns {Pattern}
* @returns Pattern
* @example
* $: s("[sbd <hh [bd | lt | oh]>]*4").dec(.4)
* .FX(
@@ -4445,7 +4440,7 @@ const _asArrayPattern = (pats) => {
* @tags generators, superdough
* @param {KabelsalatExpression | Function} expr Kabelsalat graph definition
* @memberof Pattern
* @returns {Pattern}
* @returns Pattern
*
* @example
* note("A c e".fast(4)).transpose("<0 2 4 6 8>")
@@ -4485,7 +4480,7 @@ const _asArrayPattern = (pats) => {
* @param {string} src Source code of the worklet update function
* @param {...number | ...Pattern} inputs Worklet inputs
* @memberof Pattern
* @returns {Pattern}
* @returns Pattern
* @noAutocomplete
*/
Pattern.prototype.worklet = function (src, ...inputs) {
+17 -17
View File
@@ -477,7 +477,7 @@ export const scramble = register('scramble', (n, pat) => {
* @tags math
* @param {Function} func Function from seed (or undefined) to seed (or undefined)
* @param {Pattern} pat Pattern to update
* @returns {Pattern}
* @returns Pattern
*/
export const withSeed = (func, pat) => {
return new Pattern((state) => {
@@ -796,7 +796,7 @@ export const degradeByWith = register('degradeByWith', (withPat, x, pat) => {
* @name degradeBy
* @memberof Pattern
* @param {number} amount - a number between 0 and 1
* @returns {Pattern}
* @returns Pattern
* @example
* s("hh*8").degradeBy(0.2)
* @example
@@ -821,7 +821,7 @@ export const degradeBy = register(
* @tags temporal
* @name degrade
* @memberof Pattern
* @returns {Pattern}
* @returns Pattern
* @example
* s("hh*8").degrade()
* @example
@@ -839,7 +839,7 @@ export const degrade = register('degrade', (pat) => pat._degradeBy(0.5), true, t
* @name undegradeBy
* @memberof Pattern
* @param {number} amount - a number between 0 and 1
* @returns {Pattern}
* @returns Pattern
* @example
* s("hh*8").undegradeBy(0.2)
* @example
@@ -867,7 +867,7 @@ export const undegradeBy = register(
* @tags temporal
* @name undegrade
* @memberof Pattern
* @returns {Pattern}
* @returns Pattern
* @example
* s("hh*8").undegrade()
* @example
@@ -888,7 +888,7 @@ export const undegrade = register('undegrade', (pat) => pat._undegradeBy(0.5), t
* @memberof Pattern
* @param {number | Pattern} probability - a number between 0 and 1
* @param {function} function - the transformation to apply
* @returns {Pattern}
* @returns Pattern
* @example
* s("hh*8").sometimesBy(.4, x=>x.speed("0.5"))
*/
@@ -907,7 +907,7 @@ export const sometimesBy = register('sometimesBy', function (patx, func, pat) {
* @name sometimes
* @memberof Pattern
* @param {function} function - the transformation to apply
* @returns {Pattern}
* @returns Pattern
* @example
* s("hh*8").sometimes(x=>x.speed("0.5"))
*/
@@ -924,7 +924,7 @@ export const sometimes = register('sometimes', function (func, pat) {
* @memberof Pattern
* @param {number | Pattern} probability - a number between 0 and 1
* @param {function} function - the transformation to apply
* @returns {Pattern}
* @returns Pattern
* @tags temporal
* @example
* s("bd,hh*8").someCyclesBy(.3, x=>x.speed("0.5"))
@@ -947,7 +947,7 @@ export const someCyclesBy = register('someCyclesBy', function (patx, func, pat)
*
* @name someCycles
* @memberof Pattern
* @returns {Pattern}
* @returns Pattern
* @tags temporal
* @example
* s("bd,hh*8").someCycles(x=>x.speed("0.5"))
@@ -962,7 +962,7 @@ export const someCycles = register('someCycles', function (func, pat) {
*
* @name often
* @memberof Pattern
* @returns {Pattern}
* @returns Pattern
* @tags temporal
* @example
* s("hh*8").often(x=>x.speed("0.5"))
@@ -977,7 +977,7 @@ export const often = register('often', function (func, pat) {
*
* @name rarely
* @memberof Pattern
* @returns {Pattern}
* @returns Pattern
* @tags temporal
* @example
* s("hh*8").rarely(x=>x.speed("0.5"))
@@ -993,7 +993,7 @@ export const rarely = register('rarely', function (func, pat) {
* @tags temporal
* @name almostNever
* @memberof Pattern
* @returns {Pattern}
* @returns Pattern
* @example
* s("hh*8").almostNever(x=>x.speed("0.5"))
*/
@@ -1008,7 +1008,7 @@ export const almostNever = register('almostNever', function (func, pat) {
* @tags temporal
* @name almostAlways
* @memberof Pattern
* @returns {Pattern}
* @returns Pattern
* @example
* s("hh*8").almostAlways(x=>x.speed("0.5"))
*/
@@ -1023,7 +1023,7 @@ export const almostAlways = register('almostAlways', function (func, pat) {
* @tags temporal
* @name never
* @memberof Pattern
* @returns {Pattern}
* @returns Pattern
* @example
* s("hh*8").never(x=>x.speed("0.5"))
*/
@@ -1038,7 +1038,7 @@ export const never = register('never', function (_, pat) {
* @tags temporal
* @name always
* @memberof Pattern
* @returns {Pattern}
* @returns Pattern
* @example
* s("hh*8").always(x=>x.speed("0.5"))
*/
@@ -1067,7 +1067,7 @@ export function _keyDown(keyname) {
* @tags external_io
* @name whenKey
* @memberof Pattern
* @returns {Pattern}
* @returns Pattern
* @example
* s("bd(5,8)").whenKey("Control:j", x => x.segment(16).color("red")).whenKey("Control:i", x => x.fast(2).color("blue"))
*/
@@ -1084,7 +1084,7 @@ export const whenKey = register('whenKey', function (input, func, pat) {
* @tags external_io
* @name keyDown
* @memberof Pattern
* @returns {Pattern}
* @returns Pattern
* @example
* keyDown("Control:j").pick([s("bd(5,8)"), s("cp(3,8)")])
*/
+1 -1
View File
@@ -56,7 +56,7 @@ export async function doughOutput(hap, targetTime, cps = 1) {
* @name dough
* @tags external_io
* @memberof Pattern
* @returns {Pattern}
* @returns Pattern
* @example
* $: chord("<Dm9 Dm11 Dm7>").offset("<-1 0 1 0>").voicing()
* .phaser(3).fm(1.4).fmh(1.01)
+1 -1
View File
@@ -16,7 +16,7 @@
"url": "git+https://codeberg.org/uzu/strudel.git"
},
"keywords": [
"tidalcycles",
"titdalcycles",
"strudel",
"pattern",
"livecoding",
+24 -24
View File
@@ -44,30 +44,30 @@ const getValue = (e) => {
* @synonyms punchcard
* @tags visualization
* @param {Object} options Object containing all the optional following parameters as key value pairs:
* @param {integer} options.cycles number of cycles to be displayed at the same time - defaults to 4
* @param {number} options.playhead location of the active notes on the time axis - 0 to 1, defaults to 0.5
* @param {boolean} options.vertical displays the roll vertically - 0 by default
* @param {boolean} options.labels displays labels on individual notes (see the label function) - 0 by default
* @param {boolean} options.flipTime reverse the direction of the roll - 0 by default
* @param {boolean} options.flipValues reverse the relative location of notes on the value axis - 0 by default
* @param {number} options.overscan lookup X cycles outside of the cycles window to display notes in advance - 1 by default
* @param {boolean} options.hideNegative hide notes with negative time (before starting playing the pattern) - 0 by default
* @param {boolean} options.smear notes leave a solid trace - 0 by default
* @param {boolean} options.fold notes takes the full value axis width - 0 by default
* @param {string} options.active hexadecimal or CSS color of the active notes - defaults to #FFCA28
* @param {string} options.inactive hexadecimal or CSS color of the inactive notes - defaults to #7491D2
* @param {string} options.background hexadecimal or CSS color of the background - defaults to transparent
* @param {string} options.playheadColor hexadecimal or CSS color of the line representing the play head - defaults to white
* @param {boolean} options.fill notes are filled with color (otherwise only the label is displayed) - 0 by default
* @param {boolean} options.fillActive active notes are filled with color - 0 by default
* @param {boolean} options.stroke notes are shown with colored borders - 0 by default
* @param {boolean} options.strokeActive active notes are shown with colored borders - 0 by default
* @param {boolean} options.hideInactive only active notes are shown - 0 by default
* @param {boolean} options.colorizeInactive use note color for inactive notes - 1 by default
* @param {string} options.fontFamily define the font used by notes labels - defaults to 'monospace'
* @param {integer} options.minMidi minimum note value to display on the value axis - defaults to 10
* @param {integer} options.maxMidi maximum note value to display on the value axis - defaults to 90
* @param {boolean} options.autorange automatically calculate the minMidi and maxMidi parameters - 0 by default
* @param {integer} cycles number of cycles to be displayed at the same time - defaults to 4
* @param {number} playhead location of the active notes on the time axis - 0 to 1, defaults to 0.5
* @param {boolean} vertical displays the roll vertically - 0 by default
* @param {boolean} labels displays labels on individual notes (see the label function) - 0 by default
* @param {boolean} flipTime reverse the direction of the roll - 0 by default
* @param {boolean} flipValues reverse the relative location of notes on the value axis - 0 by default
* @param {number} overscan lookup X cycles outside of the cycles window to display notes in advance - 1 by default
* @param {boolean} hideNegative hide notes with negative time (before starting playing the pattern) - 0 by default
* @param {boolean} smear notes leave a solid trace - 0 by default
* @param {boolean} fold notes takes the full value axis width - 0 by default
* @param {string} active hexadecimal or CSS color of the active notes - defaults to #FFCA28
* @param {string} inactive hexadecimal or CSS color of the inactive notes - defaults to #7491D2
* @param {string} background hexadecimal or CSS color of the background - defaults to transparent
* @param {string} playheadColor hexadecimal or CSS color of the line representing the play head - defaults to white
* @param {boolean} fill notes are filled with color (otherwise only the label is displayed) - 0 by default
* @param {boolean} fillActive active notes are filled with color - 0 by default
* @param {boolean} stroke notes are shown with colored borders - 0 by default
* @param {boolean} strokeActive active notes are shown with colored borders - 0 by default
* @param {boolean} hideInactive only active notes are shown - 0 by default
* @param {boolean} colorizeInactive use note color for inactive notes - 1 by default
* @param {string} fontFamily define the font used by notes labels - defaults to 'monospace'
* @param {integer} minMidi minimum note value to display on the value axis - defaults to 10
* @param {integer} maxMidi maximum note value to display on the value axis - defaults to 90
* @param {boolean} autorange automatically calculate the minMidi and maxMidi parameters - 0 by default
* @see _pianoroll
* @example
* note("c2 a2 eb2")
+15 -15
View File
@@ -131,21 +131,21 @@ function drawSpiral(options) {
* @name spiral
* @tags visualization
* @param {Object} options Object containing all the optional following parameters as key value pairs:
* @param {number} options.stretch controls the rotations per cycle ratio, where 1 = 1 cycle / 360 degrees
* @param {number} options.size the diameter of the spiral
* @param {number} options.thickness line thickness
* @param {string} options.cap style of line ends: butt (default), round, square
* @param {string} options.inset number of rotations before spiral starts (default 3)
* @param {string} options.playheadColor color of playhead, defaults to white
* @param {number} options.playheadLength length of playhead in rotations, defaults to 0.02
* @param {number} options.playheadThickness thickness of playheadrotations, defaults to thickness
* @param {number} options.padding space around spiral
* @param {number} options.steady steadyness of spiral vs playhead. 1 = spiral doesn't move, playhead does.
* @param {number} options.activeColor color of active segment. defaults to foreground of theme
* @param {number} options.inactiveColor color of inactive segments. defaults to gutterForeground of theme
* @param {boolean} options.colorizeInactive wether or not to colorize inactive segments, defaults to 0
* @param {boolean} options.fade wether or not past and future should fade out. defaults to 1
* @param {boolean} options.logSpiral wether or not the spiral should be logarithmic. defaults to 0
* @param {number} stretch controls the rotations per cycle ratio, where 1 = 1 cycle / 360 degrees
* @param {number} size the diameter of the spiral
* @param {number} thickness line thickness
* @param {string} cap style of line ends: butt (default), round, square
* @param {string} inset number of rotations before spiral starts (default 3)
* @param {string} playheadColor color of playhead, defaults to white
* @param {number} playheadLength length of playhead in rotations, defaults to 0.02
* @param {number} playheadThickness thickness of playheadrotations, defaults to thickness
* @param {number} padding space around spiral
* @param {number} steady steadyness of spiral vs playhead. 1 = spiral doesn't move, playhead does.
* @param {number} activeColor color of active segment. defaults to foreground of theme
* @param {number} inactiveColor color of inactive segments. defaults to gutterForeground of theme
* @param {boolean} colorizeInactive wether or not to colorize inactive segments, defaults to 0
* @param {boolean} fade wether or not past and future should fade out. defaults to 1
* @param {boolean} logSpiral wether or not the spiral should be logarithmic. defaults to 0
* @example
* note("c2 a2 eb2")
* .euclid(5,8)
+1 -1
View File
@@ -38,7 +38,7 @@ const pitchesCache = new Map();
*
* @name edoScale
* @param {string} scale Definition of EDO scale.
* @returns {Pattern}
* @returns Pattern
* @example
* n("0 2 4 6 4 2").edoScale("C:LLsLLLs:2:1")
* @example
+1 -1
View File
@@ -16,7 +16,7 @@
"url": "git+https://codeberg.org/uzu/strudel.git"
},
"keywords": [
"tidalcycles",
"titdalcycles",
"strudel",
"pattern",
"livecoding",
-6
View File
@@ -290,12 +290,6 @@ function sendNote(note, velocity, duration, device, midichan, timeMs) {
* @tags external_io
* @param {string | number} midiport MIDI device name or index defaulting to 0
* @param {object} options Additional MIDI configuration options
* @param {boolean} options.isController sending notes for midi controllers. Default is false
* @param {number} options.noteOffsetMs note-off offset to prevent glitching in ms. Default is 10 or firefox and 1 otherwise
* @param {number} options.midichannel default is 1
* @param {number} options.velocity default is 0.9
* @param {number} options.gain default is 1
* @param {string} options.midimap default is 'default'
* @example
* note("c4").midichan(1).midi('IAC Driver Bus 1')
*/
+1 -1
View File
@@ -16,7 +16,7 @@
"url": "git+https://codeberg.org/uzu/strudel.git"
},
"keywords": [
"tidalcycles",
"titdalcycles",
"strudel",
"pattern",
"livecoding",
+1 -1
View File
@@ -16,7 +16,7 @@
"url": "git+https://codeberg.org/uzu/strudel.git"
},
"keywords": [
"tidalcycles",
"titdalcycles",
"strudel",
"pattern",
"livecoding",
+1 -1
View File
@@ -16,7 +16,7 @@
"url": "git+https://codeberg.org/uzu/strudel.git"
},
"keywords": [
"tidalcycles",
"titdalcycles",
"strudel",
"pattern",
"livecoding",
+6 -65
View File
@@ -52,13 +52,13 @@ export function parseControlsFromHap(hap, cps) {
controls.unit === 'c' && controls.speed != null && (controls.speed = controls.speed / cps);
const channels = controls.channels;
channels != undefined && (controls.channels = JSON.stringify(channels));
return controls;
}
let timeOrigin = performance.timeOrigin;
export async function oscOutput(hap, targetTime, cps = 1) {
const ws = await connect();
function getOscTimestamp(targetTime) {
const timeMs = getClockBridge().getPerformanceTime(targetTime);
if (!timeMs) {
logger('[osc] clockbridge not ready');
@@ -72,76 +72,21 @@ function getOscTimestamp(targetTime) {
// shift time after microsleep
timeOrigin -= deprivation;
}
return timeOrigin + timeMs;
}
export async function oscOutput(hap, targetTime, cps = 1) {
const ws = await connect();
const ts = getOscTimestamp(targetTime);
if (!ts) {
return;
}
const ts = timeOrigin + timeMs;
const controls = parseControlsFromHap(hap, cps);
const keyvals = Object.entries(controls).flat();
const msg = { address: '/dirt/play', args: keyvals, timestamp: ts };
if ('oschost' in hap.value) {
msg.oschost = hap.value.oschost;
msg['host'] = hap.value['oschost'];
}
if ('oscport' in hap.value) {
msg.oscport = hap.value.oscport;
msg['port'] = hap.value['oscport'];
}
ws.send(JSON.stringify(msg));
}
export async function superdirtOutput(hap, targetTime, cps = 1) {
const ws = await connect();
const ts = getOscTimestamp(targetTime);
if (!ts) {
return;
}
const controls = parseControlsFromHap(hap, cps);
const oschost = hap.value.oschost ?? '127.0.0.1';
const oscport = hap.value.oscport ?? 57120;
const bushost = oschost;
const busport = 57110;
// send SuperDirt bus/control messages first
for (const [key, busIdVal] of Object.entries(controls)) {
if (key.startsWith('^')) {
ws.send(
JSON.stringify({
oschost: bushost,
oscport: busport,
address: '/c_set',
args: busIdVal,
timestamp: ts,
}),
);
// so they aren't sent with trigger messages
delete controls[key];
}
}
// only trigger samples on haps that actually begin here
if (hap.hasOnset()) {
const keyvals = Object.entries(controls).flat();
ws.send(
JSON.stringify({
oschost,
oscport,
address: '/dirt/play',
args: keyvals,
timestamp: ts,
}),
);
}
}
/**
*
* Sends each hap as an OSC message, which can be picked up by SuperCollider or any other OSC-enabled software.
@@ -150,13 +95,9 @@ export async function superdirtOutput(hap, targetTime, cps = 1) {
* @name osc
* @tags external_io
* @memberof Pattern
* @returns {Pattern}
* @returns Pattern
*/
export const osc = register('osc', (pat) => {
ensureMinimalOutput();
return pat.onSchedule(oscOutput);
});
export const superdirt = register('superdirt', (pat) => {
ensureMinimalOutput();
return pat._processParts().onSchedule(superdirtOutput);
});
+13 -9
View File
@@ -12,13 +12,18 @@ import { WebSocketServer } from 'ws';
import osc from 'osc';
const WS_PORT = 8080; // WebSocket server port
const OSC_REMOTE_IP = '127.0.0.1';
const OSC_REMOTE_PORT = 57120;
const udpPort = new osc.UDPPort({
localAddress: '0.0.0.0',
localPort: 0,
remoteAddress: OSC_REMOTE_IP,
remotePort: OSC_REMOTE_PORT,
});
udpPort.open();
console.log(`[Sending OSC] ${OSC_REMOTE_IP}:${OSC_REMOTE_PORT}`);
udpPort.on('error', (e) => {
console.log('Error: ', e);
@@ -31,24 +36,23 @@ wss.on('connection', (ws) => {
console.log('New WebSocket connection');
ws.on('message', (message) => {
let oschost = '127.0.0.1';
let oscport = 57120;
let osc_host = '127.0.0.1';
let osc_port = 57120;
try {
const data = JSON.parse(message);
if ('oschost' in data) {
oschost = data['oschost'];
delete data['oschost'];
if ('host' in data) {
osc_host = data['host'];
}
if ('oscport' in data) {
oscport = data['oscport'];
delete data['oscport'];
if ('port' in data) {
osc_port = data['port'];
}
let msg = { address: data['address'], args: data['args'] };
if ('timestamp' in data) {
msg = { timeTag: osc.timeTag(0, data['timestamp']), packets: [msg] };
}
udpPort.send(msg, oschost, oscport);
udpPort.send(msg, osc_host, osc_port);
} catch (err) {
console.error('Error parsing message:', err);
}
+4 -2
View File
@@ -1,5 +1,7 @@
/* import { tauriOscOutput } from '../desktopbridge/oscbridge.mjs';
import { isTauri } from '../desktopbridge/utils.mjs'; */
// const output = /* isTauri() ? tauriOscOutput : */ oscOutput;
import { oscOutput } from './osc.mjs';
export { superdirtOutput } from './osc.mjs';
const output = /* isTauri() ? tauriOscOutput : */ oscOutput;
export const superdirtOutput = (hap, targetTime, cps) => output(hap, targetTime, cps);
+1 -2
View File
@@ -43,8 +43,7 @@
"@strudel/soundfonts": "workspace:*",
"@strudel/tonal": "workspace:*",
"@strudel/transpiler": "workspace:*",
"@strudel/webaudio": "workspace:*",
"@strudel/websocket": "workspace:*"
"@strudel/webaudio": "workspace:*"
},
"devDependencies": {
"@rollup/plugin-replace": "^6.0.2",
-1
View File
@@ -15,7 +15,6 @@ export async function prebake() {
import('@strudel/hydra'),
import('@strudel/soundfonts'),
import('@strudel/midi'),
import('@strudel/websocket'),
// import('@strudel/xen'),
// import('@strudel/serial'),
// import('@strudel/csound'),
+1 -1
View File
@@ -16,7 +16,7 @@
"url": "git+https://codeberg.org/uzu/strudel.git"
},
"keywords": [
"tidalcycles",
"titdalcycles",
"strudel",
"pattern",
"livecoding",
+3 -3
View File
@@ -102,7 +102,7 @@ function scaleOffset(scale, offset, note) {
*
* @tags tonal
* @param {string | number} amount Either number of semitones or interval string.
* @returns {Pattern}
* @returns Pattern
* @memberof Pattern
* @name transpose
* @synonyms trans
@@ -164,7 +164,7 @@ export const { transpose, trans } = register(['transpose', 'trans'], function tr
* @name scaleTranspose
* @tags tonal
* @param {offset} offset number of steps inside the scale
* @returns {Pattern}
* @returns Pattern
* @synonyms scaleTrans, strans
* @example
* "-8 [2,4,6]"
@@ -255,7 +255,7 @@ function _getNearestScaleNote(scaleName, note, preferHigher = true) {
* @name scale
* @tags tonal
* @param {string} scale Name of scale
* @returns {Pattern}
* @returns Pattern
* @example
* n("0 2 4 6 4 2").scale("C:major")
* @example
+4 -4
View File
@@ -95,7 +95,7 @@ export const setVoicingRange = (name, range) => addVoicings(name, voicingRegistr
* @param {string} name identifier for the voicing dictionary
* @param {Object} dictionary maps chord symbol to possible voicings
* @param {Array} range min, max note
* @returns {Pattern}
* @returns Pattern
* @example
* addVoicings('cookie', {
* 7: ['3M 7m 9M 12P 15P', '7m 10M 13M 16M 19P'],
@@ -137,7 +137,7 @@ const getVoicing = (chord, dictionaryName, lastVoicing) => {
* @tags tonal
* @memberof Pattern
* @param {string} dictionary which voicing dictionary to use.
* @returns {Pattern}
* @returns Pattern
* @example
* stack("<C^7 A7 Dm7 G7>".voicings('lefthand'), "<C3 A2 D3 G2>").note()
*/
@@ -162,7 +162,7 @@ export const voicings = register('voicings', function (dictionary, pat) {
* @tags tonal
* @memberof Pattern
* @param {octave} octave octave to use
* @returns {Pattern}
* @returns Pattern
* @example
* "<C^7 A7 Dm7 G7>".rootNotes(2).note()
*/
@@ -196,7 +196,7 @@ export const rootNotes = register('rootNotes', function (octave, pat) {
*
* @name voicing
* @tags tonal
* @returns {Pattern}
* @returns Pattern
* @example
* n("0 1 2 3").chord("<C Am F G>").voicing()
*/
-6
View File
@@ -1,6 +0,0 @@
# @strudel/websocket
This package adds websocket input to strudel Patterns.
It connects to a websocket server and exposes the latest received value (parsed as JSON) as a pattern.
-3
View File
@@ -1,3 +0,0 @@
import './websocket.mjs';
export * from './websocket.mjs';
-40
View File
@@ -1,40 +0,0 @@
{
"name": "@strudel/websocket",
"version": "1.0.0",
"description": "Websocket input for strudel",
"main": "index.mjs",
"type": "module",
"publishConfig": {
"main": "dist/index.mjs"
},
"scripts": {
"build": "vite build",
"prepublishOnly": "npm run build"
},
"repository": {
"type": "git",
"url": "git+https://codeberg.org/uzu/strudel.git"
},
"keywords": [
"tidalcycles",
"strudel",
"pattern",
"livecoding",
"algorave"
],
"author": "Alex McLean <alex@slab.org>",
"license": "AGPL-3.0-or-later",
"bugs": {
"url": "https://codeberg.org/uzu/strudel/issues"
},
"homepage": "https://codeberg.org/uzu/strudel#readme",
"dependencies": {
"@strudel/core": "workspace:*"
},
"devDependencies": {
"vite": "^6.0.11"
},
"engines": {
"node": ">=18.0.0"
}
}
-19
View File
@@ -1,19 +0,0 @@
import { defineConfig } from 'vite';
import { dependencies } from './package.json';
import { resolve } from 'path';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [],
build: {
lib: {
entry: resolve(__dirname, 'index.mjs'),
formats: ['es'],
fileName: (ext) => ({ es: 'index.mjs' })[ext],
},
rollupOptions: {
external: [...Object.keys(dependencies)],
},
target: 'esnext',
},
});
-43
View File
@@ -1,43 +0,0 @@
/*
websocket.mjs - simple websocket client as a pattern
Copyright (C) 2026 Strudel contributors -- see <https://codeberg.org/uzu/strudel/src/branch/main/packages/websocket/websocket.mjs>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { logger, signal } from '@strudel/core';
const connections = {};
const values = {};
function connect(addr) {
if (connections[addr]) {
return connections[addr];
}
const ws = new WebSocket(addr);
connections[addr] = ws;
ws.addEventListener('open', () => {
logger(`[websocket] connected to ${addr}`);
});
ws.addEventListener('message', (event) => {
try {
console.log(event.data);
values[addr] = JSON.parse(event.data);
} catch {
logger(`[websocket] received invalid json on ${addr}`);
}
});
ws.addEventListener('close', () => {
logger(`[websocket] disconnected from ${addr}`);
delete connections[addr];
});
ws.addEventListener('error', () => {
logger(`[websocket] failed to connect to ${addr}`);
delete connections[addr];
});
return ws;
}
export function websocket(addr) {
connect(addr);
return signal(() => values[addr] ?? {});
}
+1 -1
View File
@@ -12,7 +12,7 @@ import { register } from '@strudel/core';
*
* Assumes pattern contains numerical scale degrees on the `i` control (see examples below). Accepts a scale name or list of frequencies (see all available names at the link on the reference). Returns a new pattern with all values mapped to a frequency ratio. Similar to `xen`.
* @name tune
* @returns {Pattern}
* @returns Pattern
* @memberof Pattern
* @param {(string | number[] )} scale
* @deprecated
+2 -2
View File
@@ -65,7 +65,7 @@ const trimFreq = (freq) => parseFloat(freq.toPrecision(10));
* Assumes a numerical pattern of scale steps, and a scale. Scales accepted are all preset scale names of `tune`, arbitrary edos such as 31edo, or an array of frequency ratios. Assumes scales repeat at octave (2/1). Returns a new pattern with all values mapped to their associated frequency, assuming a base frequency of 220hz. See first 4 examples for the different ways you can input a scale into `xen`
*
* @name xen
* @returns {Pattern}
* @returns Pattern
* @memberof Pattern
* @param {(string | number[] )} scaleNameOrRatios
* @tags tonal
@@ -209,7 +209,7 @@ export const xen = register(
* mini([1 / 1, 16 / 15, 9 / 8, 6 / 5, 5 / 4].join(' ')).withBase("220:1")
* // mini([1 / 1, 16 / 15, 9 / 8, 6 / 5, 5 / 4].join(' ')).mul(220).freq()
*
* @returns {Pattern}
* @returns Pattern
*/
export const withBase = register('withBase', (b, pat) => {
let base;
-16
View File
@@ -538,9 +538,6 @@ importers:
'@strudel/webaudio':
specifier: workspace:*
version: link:../webaudio
'@strudel/websocket':
specifier: workspace:*
version: link:../websocket
devDependencies:
'@rollup/plugin-replace':
specifier: ^6.0.2
@@ -725,16 +722,6 @@ 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/websocket:
dependencies:
'@strudel/core':
specifier: workspace:*
version: link:../core
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)
packages/xen:
dependencies:
'@strudel/core':
@@ -870,9 +857,6 @@ importers:
'@strudel/webaudio':
specifier: workspace:*
version: link:../packages/webaudio
'@strudel/websocket':
specifier: workspace:*
version: link:../packages/websocket
'@strudel/xen':
specifier: workspace:*
version: link:../packages/xen
-1
View File
@@ -48,7 +48,6 @@
"@strudel/tonal": "workspace:*",
"@strudel/transpiler": "workspace:*",
"@strudel/webaudio": "workspace:*",
"@strudel/websocket": "workspace:*",
"@strudel/mondo": "workspace:*",
"@strudel/xen": "workspace:*",
"@supabase/supabase-js": "^2.48.1",
@@ -219,31 +219,13 @@ export const Reference = memo(function Reference() {
__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>
);
})}
{entry.params?.map(({ name, type, description }, i) => (
<li key={i}>
{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}
+1 -1
View File
@@ -97,7 +97,7 @@ export function loadModules() {
import('@strudel/desktopbridge/oscbridge.mjs'),
]);
} else {
modules = modules.concat([import('@strudel/midi'), import('@strudel/osc'), import('@strudel/websocket')]);
modules = modules.concat([import('@strudel/midi'), import('@strudel/osc')]);
}
return evalScope(settingPatterns, ...modules);