mirror of
https://github.com/eliasstepanik/strudel.git
synced 2026-01-11 21:58:37 +00:00
Merge branch 'main' into astro-3
This commit is contained in:
commit
048502ecd1
@ -18,4 +18,5 @@ vite.config.js
|
||||
**/*.json
|
||||
**/dev-dist
|
||||
**/dist
|
||||
/src-tauri/target/**/*
|
||||
/src-tauri/target/**/*
|
||||
reverbGen.mjs
|
||||
2
.github/workflows/tauri.yml
vendored
2
.github/workflows/tauri.yml
vendored
@ -42,7 +42,7 @@ jobs:
|
||||
if: matrix.platform == 'ubuntu-latest'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf
|
||||
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf libasound2-dev
|
||||
|
||||
- name: Install app dependencies from lockfile and build web
|
||||
run: pnpm install
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
export * from './codemirror.mjs';
|
||||
export * from './highlight.mjs';
|
||||
export * from './flash.mjs';
|
||||
export * from './slider.mjs';
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/codemirror",
|
||||
"version": "0.8.4",
|
||||
"version": "0.9.0",
|
||||
"description": "Codemirror Extensions for Strudel",
|
||||
"main": "index.mjs",
|
||||
"publishConfig": {
|
||||
|
||||
135
packages/codemirror/slider.mjs
Normal file
135
packages/codemirror/slider.mjs
Normal file
@ -0,0 +1,135 @@
|
||||
import { ref, pure } from '@strudel.cycles/core';
|
||||
import { WidgetType, ViewPlugin, Decoration } from '@codemirror/view';
|
||||
import { StateEffect, StateField } from '@codemirror/state';
|
||||
|
||||
export let sliderValues = {};
|
||||
const getSliderID = (from) => `slider_${from}`;
|
||||
|
||||
export class SliderWidget extends WidgetType {
|
||||
constructor(value, min, max, from, to, step, view) {
|
||||
super();
|
||||
this.value = value;
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.from = from;
|
||||
this.originalFrom = from;
|
||||
this.to = to;
|
||||
this.step = step;
|
||||
this.view = view;
|
||||
}
|
||||
|
||||
eq() {
|
||||
return false;
|
||||
}
|
||||
|
||||
toDOM() {
|
||||
let wrap = document.createElement('span');
|
||||
wrap.setAttribute('aria-hidden', 'true');
|
||||
wrap.className = 'cm-slider'; // inline-flex items-center
|
||||
let slider = wrap.appendChild(document.createElement('input'));
|
||||
slider.type = 'range';
|
||||
slider.min = this.min;
|
||||
slider.max = this.max;
|
||||
slider.step = this.step ?? (this.max - this.min) / 1000;
|
||||
slider.originalValue = this.value;
|
||||
// to make sure the code stays in sync, let's save the original value
|
||||
// becuase .value automatically clamps values so it'll desync with the code
|
||||
slider.value = slider.originalValue;
|
||||
slider.from = this.from;
|
||||
slider.originalFrom = this.originalFrom;
|
||||
slider.to = this.to;
|
||||
slider.style = 'width:64px;margin-right:4px;transform:translateY(4px)';
|
||||
this.slider = slider;
|
||||
slider.addEventListener('input', (e) => {
|
||||
const next = e.target.value;
|
||||
let insert = next;
|
||||
//let insert = next.toFixed(2);
|
||||
const to = slider.from + slider.originalValue.length;
|
||||
let change = { from: slider.from, to, insert };
|
||||
slider.originalValue = insert;
|
||||
slider.value = insert;
|
||||
this.view.dispatch({ changes: change });
|
||||
const id = getSliderID(slider.originalFrom); // matches id generated in transpiler
|
||||
window.postMessage({ type: 'cm-slider', value: Number(next), id });
|
||||
});
|
||||
return wrap;
|
||||
}
|
||||
|
||||
ignoreEvent(e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
export const setWidgets = StateEffect.define();
|
||||
|
||||
export const updateWidgets = (view, widgets) => {
|
||||
view.dispatch({ effects: setWidgets.of(widgets) });
|
||||
};
|
||||
|
||||
function getWidgets(widgetConfigs, view) {
|
||||
return widgetConfigs.map(({ from, to, value, min, max, step }) => {
|
||||
return Decoration.widget({
|
||||
widget: new SliderWidget(value, min, max, from, to, step, view),
|
||||
side: 0,
|
||||
}).range(from /* , to */);
|
||||
});
|
||||
}
|
||||
|
||||
export const sliderPlugin = ViewPlugin.fromClass(
|
||||
class {
|
||||
decorations; //: DecorationSet
|
||||
|
||||
constructor(view /* : EditorView */) {
|
||||
this.decorations = Decoration.set([]);
|
||||
}
|
||||
|
||||
update(update /* : ViewUpdate */) {
|
||||
update.transactions.forEach((tr) => {
|
||||
if (tr.docChanged) {
|
||||
this.decorations = this.decorations.map(tr.changes);
|
||||
const iterator = this.decorations.iter();
|
||||
while (iterator.value) {
|
||||
// when the widgets are moved, we need to tell the dom node the current position
|
||||
// this is important because the updateSliderValue function has to work with the dom node
|
||||
if (iterator.value?.widget?.slider) {
|
||||
iterator.value.widget.slider.from = iterator.from;
|
||||
iterator.value.widget.slider.to = iterator.to;
|
||||
}
|
||||
iterator.next();
|
||||
}
|
||||
}
|
||||
for (let e of tr.effects) {
|
||||
if (e.is(setWidgets)) {
|
||||
this.decorations = Decoration.set(getWidgets(e.value, update.view));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
decorations: (v) => v.decorations,
|
||||
},
|
||||
);
|
||||
|
||||
export let slider = (value) => {
|
||||
console.warn('slider will only work when the transpiler is used... passing value as is');
|
||||
return pure(value);
|
||||
};
|
||||
// function transpiled from slider = (value, min, max)
|
||||
export let sliderWithID = (id, value, min, max) => {
|
||||
sliderValues[id] = value; // sync state at eval time (code -> state)
|
||||
return ref(() => sliderValues[id]); // use state at query time
|
||||
};
|
||||
// update state when sliders are moved
|
||||
if (typeof window !== 'undefined') {
|
||||
window.addEventListener('message', (e) => {
|
||||
if (e.data.type === 'cm-slider') {
|
||||
if (sliderValues[e.data.id] !== undefined) {
|
||||
// update state when slider is moved
|
||||
sliderValues[e.data.id] = e.data.value;
|
||||
} else {
|
||||
console.warn(`slider with id "${e.data.id}" is not registered. Only ${Object.keys(sliderValues)}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -86,6 +86,16 @@ const generic_params = [
|
||||
*
|
||||
*/
|
||||
['gain'],
|
||||
/**
|
||||
* Gain applied after all effects have been processed.
|
||||
*
|
||||
* @name postgain
|
||||
* @example
|
||||
* s("bd sd,hh*4")
|
||||
* .compressor("-20:20:10:.002:.02").postgain(1.5)
|
||||
*
|
||||
*/
|
||||
['postgain'],
|
||||
/**
|
||||
* Like {@link gain}, but linear.
|
||||
*
|
||||
@ -299,16 +309,52 @@ const generic_params = [
|
||||
*/
|
||||
['end'],
|
||||
/**
|
||||
* Loops the sample (from `begin` to `end`) the specified number of times.
|
||||
* Loops the sample.
|
||||
* Note that the tempo of the loop is not synced with the cycle tempo.
|
||||
* To change the loop region, use loopBegin / loopEnd.
|
||||
*
|
||||
* @name loop
|
||||
* @param {number | Pattern} times How often the sample is looped
|
||||
* @param {number | Pattern} on If 1, the sample is looped
|
||||
* @example
|
||||
* s("bd").loop("<1 2 3 4>").osc()
|
||||
* s("casio").loop(1)
|
||||
*
|
||||
*/
|
||||
['loop'],
|
||||
/**
|
||||
* Begin to loop at a specific point in the sample (inbetween `begin` and `end`).
|
||||
* Note that the loop point must be inbetween `begin` and `end`, and before `loopEnd`!
|
||||
* Note: Samples starting with wt_ will automatically loop! (wt = wavetable)
|
||||
*
|
||||
* @name loopBegin
|
||||
* @param {number | Pattern} time between 0 and 1, where 1 is the length of the sample
|
||||
* @synonyms loopb
|
||||
* @example
|
||||
* s("space").loop(1)
|
||||
* .loopBegin("<0 .125 .25>").scope()
|
||||
*/
|
||||
['loopBegin', 'loopb'],
|
||||
/**
|
||||
*
|
||||
* End the looping section at a specific point in the sample (inbetween `begin` and `end`).
|
||||
* Note that the loop point must be inbetween `begin` and `end`, and after `loopBegin`!
|
||||
*
|
||||
* @name loopEnd
|
||||
* @param {number | Pattern} time between 0 and 1, where 1 is the length of the sample
|
||||
* @synonyms loope
|
||||
* @example
|
||||
* s("space").loop(1)
|
||||
* .loopEnd("<1 .75 .5 .25>").scope()
|
||||
*/
|
||||
['loopEnd', 'loope'],
|
||||
/**
|
||||
* bit crusher effect.
|
||||
*
|
||||
* @name crush
|
||||
* @param {number | Pattern} depth between 1 (for drastic reduction in bit-depth) to 16 (for barely no reduction).
|
||||
* @example
|
||||
* s("<bd sd>,hh*3").fast(2).crush("<16 8 7 6 5 4 3 2>")
|
||||
*
|
||||
*/
|
||||
// TODO: currently duplicated with "native" legato
|
||||
// TODO: superdirt legato will do more: https://youtu.be/dQPmE1WaD1k?t=419
|
||||
/**
|
||||
@ -323,15 +369,6 @@ const generic_params = [
|
||||
*/
|
||||
// ['legato'],
|
||||
// ['clhatdecay'],
|
||||
/**
|
||||
* bit crusher effect.
|
||||
*
|
||||
* @name crush
|
||||
* @param {number | Pattern} depth between 1 (for drastic reduction in bit-depth) to 16 (for barely no reduction).
|
||||
* @example
|
||||
* s("<bd sd>,hh*3").fast(2).crush("<16 8 7 6 5 4 3 2>")
|
||||
*
|
||||
*/
|
||||
['crush'],
|
||||
/**
|
||||
* fake-resampling for lowering the sample rate. Caution: This effect seems to only work in chromium based browsers
|
||||
@ -343,7 +380,6 @@ const generic_params = [
|
||||
*
|
||||
*/
|
||||
['coarse'],
|
||||
|
||||
/**
|
||||
* choose the channel the pattern is sent to in superdirt
|
||||
*
|
||||
@ -377,6 +413,227 @@ const generic_params = [
|
||||
*
|
||||
*/
|
||||
[['cutoff', 'resonance'], 'ctf', 'lpf', 'lp'],
|
||||
|
||||
/**
|
||||
* Sets the lowpass filter envelope modulation depth.
|
||||
* @name lpenv
|
||||
* @param {number | Pattern} modulation depth of the lowpass filter envelope between 0 and _n_
|
||||
* @synonyms lpe
|
||||
* @example
|
||||
* note("<c2 e2 f2 g2>")
|
||||
* .sound('sawtooth')
|
||||
* .lpf(500)
|
||||
* .lpa(.5)
|
||||
* .lpenv("<4 2 1 0 -1 -2 -4>/4")
|
||||
*/
|
||||
['lpenv', 'lpe'],
|
||||
/**
|
||||
* Sets the highpass filter envelope modulation depth.
|
||||
* @name hpenv
|
||||
* @param {number | Pattern} modulation depth of the highpass filter envelope between 0 and _n_
|
||||
* @synonyms hpe
|
||||
* @example
|
||||
* note("<c2 e2 f2 g2>")
|
||||
* .sound('sawtooth')
|
||||
* .hpf(500)
|
||||
* .hpa(.5)
|
||||
* .hpenv("<4 2 1 0 -1 -2 -4>/4")
|
||||
*/
|
||||
['hpenv', 'hpe'],
|
||||
/**
|
||||
* Sets the bandpass filter envelope modulation depth.
|
||||
* @name bpenv
|
||||
* @param {number | Pattern} modulation depth of the bandpass filter envelope between 0 and _n_
|
||||
* @synonyms bpe
|
||||
* @example
|
||||
* note("<c2 e2 f2 g2>")
|
||||
* .sound('sawtooth')
|
||||
* .bpf(500)
|
||||
* .bpa(.5)
|
||||
* .bpenv("<4 2 1 0 -1 -2 -4>/4")
|
||||
*/
|
||||
['bpenv', 'bpe'],
|
||||
/**
|
||||
* Sets the attack duration for the lowpass filter envelope.
|
||||
* @name lpattack
|
||||
* @param {number | Pattern} attack time of the filter envelope
|
||||
* @synonyms lpa
|
||||
* @example
|
||||
* note("<c2 e2 f2 g2>")
|
||||
* .sound('sawtooth')
|
||||
* .lpf(500)
|
||||
* .lpa("<.5 .25 .1 .01>/4")
|
||||
* .lpenv(4)
|
||||
*/
|
||||
['lpattack', 'lpa'],
|
||||
/**
|
||||
* Sets the attack duration for the highpass filter envelope.
|
||||
* @name hpattack
|
||||
* @param {number | Pattern} attack time of the highpass filter envelope
|
||||
* @synonyms hpa
|
||||
* @example
|
||||
* note("<c2 e2 f2 g2>")
|
||||
* .sound('sawtooth')
|
||||
* .hpf(500)
|
||||
* .hpa("<.5 .25 .1 .01>/4")
|
||||
* .hpenv(4)
|
||||
*/
|
||||
['hpattack', 'hpa'],
|
||||
/**
|
||||
* Sets the attack duration for the bandpass filter envelope.
|
||||
* @name bpattack
|
||||
* @param {number | Pattern} attack time of the bandpass filter envelope
|
||||
* @synonyms bpa
|
||||
* @example
|
||||
* note("<c2 e2 f2 g2>")
|
||||
* .sound('sawtooth')
|
||||
* .bpf(500)
|
||||
* .bpa("<.5 .25 .1 .01>/4")
|
||||
* .bpenv(4)
|
||||
*/
|
||||
['bpattack', 'bpa'],
|
||||
/**
|
||||
* Sets the decay duration for the lowpass filter envelope.
|
||||
* @name lpdecay
|
||||
* @param {number | Pattern} decay time of the filter envelope
|
||||
* @synonyms lpd
|
||||
* @example
|
||||
* note("<c2 e2 f2 g2>")
|
||||
* .sound('sawtooth')
|
||||
* .lpf(500)
|
||||
* .lpd("<.5 .25 .1 0>/4")
|
||||
* .lps(0.2)
|
||||
* .lpenv(4)
|
||||
*/
|
||||
['lpdecay', 'lpd'],
|
||||
/**
|
||||
* Sets the decay duration for the highpass filter envelope.
|
||||
* @name hpdecay
|
||||
* @param {number | Pattern} decay time of the highpass filter envelope
|
||||
* @synonyms hpd
|
||||
* @example
|
||||
* note("<c2 e2 f2 g2>")
|
||||
* .sound('sawtooth')
|
||||
* .hpf(500)
|
||||
* .hpd("<.5 .25 .1 0>/4")
|
||||
* .hps(0.2)
|
||||
* .hpenv(4)
|
||||
*/
|
||||
['hpdecay', 'hpd'],
|
||||
/**
|
||||
* Sets the decay duration for the bandpass filter envelope.
|
||||
* @name bpdecay
|
||||
* @param {number | Pattern} decay time of the bandpass filter envelope
|
||||
* @synonyms bpd
|
||||
* @example
|
||||
* note("<c2 e2 f2 g2>")
|
||||
* .sound('sawtooth')
|
||||
* .bpf(500)
|
||||
* .bpd("<.5 .25 .1 0>/4")
|
||||
* .bps(0.2)
|
||||
* .bpenv(4)
|
||||
*/
|
||||
['bpdecay', 'bpd'],
|
||||
/**
|
||||
* Sets the sustain amplitude for the lowpass filter envelope.
|
||||
* @name lpsustain
|
||||
* @param {number | Pattern} sustain amplitude of the lowpass filter envelope
|
||||
* @synonyms lps
|
||||
* @example
|
||||
* note("<c2 e2 f2 g2>")
|
||||
* .sound('sawtooth')
|
||||
* .lpf(500)
|
||||
* .lpd(.5)
|
||||
* .lps("<0 .25 .5 1>/4")
|
||||
* .lpenv(4)
|
||||
*/
|
||||
['lpsustain', 'lps'],
|
||||
/**
|
||||
* Sets the sustain amplitude for the highpass filter envelope.
|
||||
* @name hpsustain
|
||||
* @param {number | Pattern} sustain amplitude of the highpass filter envelope
|
||||
* @synonyms hps
|
||||
* @example
|
||||
* note("<c2 e2 f2 g2>")
|
||||
* .sound('sawtooth')
|
||||
* .hpf(500)
|
||||
* .hpd(.5)
|
||||
* .hps("<0 .25 .5 1>/4")
|
||||
* .hpenv(4)
|
||||
*/
|
||||
['hpsustain', 'hps'],
|
||||
/**
|
||||
* Sets the sustain amplitude for the bandpass filter envelope.
|
||||
* @name bpsustain
|
||||
* @param {number | Pattern} sustain amplitude of the bandpass filter envelope
|
||||
* @synonyms bps
|
||||
* @example
|
||||
* note("<c2 e2 f2 g2>")
|
||||
* .sound('sawtooth')
|
||||
* .bpf(500)
|
||||
* .bpd(.5)
|
||||
* .bps("<0 .25 .5 1>/4")
|
||||
* .bpenv(4)
|
||||
*/
|
||||
['bpsustain', 'bps'],
|
||||
/**
|
||||
* Sets the release time for the lowpass filter envelope.
|
||||
* @name lprelease
|
||||
* @param {number | Pattern} release time of the filter envelope
|
||||
* @synonyms lpr
|
||||
* @example
|
||||
* note("<c2 e2 f2 g2>")
|
||||
* .sound('sawtooth')
|
||||
* .clip(.5)
|
||||
* .lpf(500)
|
||||
* .lpenv(4)
|
||||
* .lpr("<.5 .25 .1 0>/4")
|
||||
* .release(.5)
|
||||
*/
|
||||
['lprelease', 'lpr'],
|
||||
/**
|
||||
* Sets the release time for the highpass filter envelope.
|
||||
* @name hprelease
|
||||
* @param {number | Pattern} release time of the highpass filter envelope
|
||||
* @synonyms hpr
|
||||
* @example
|
||||
* note("<c2 e2 f2 g2>")
|
||||
* .sound('sawtooth')
|
||||
* .clip(.5)
|
||||
* .hpf(500)
|
||||
* .hpenv(4)
|
||||
* .hpr("<.5 .25 .1 0>/4")
|
||||
* .release(.5)
|
||||
*/
|
||||
['hprelease', 'hpr'],
|
||||
/**
|
||||
* Sets the release time for the bandpass filter envelope.
|
||||
* @name bprelease
|
||||
* @param {number | Pattern} release time of the bandpass filter envelope
|
||||
* @synonyms bpr
|
||||
* @example
|
||||
* note("<c2 e2 f2 g2>")
|
||||
* .sound('sawtooth')
|
||||
* .clip(.5)
|
||||
* .bpf(500)
|
||||
* .bpenv(4)
|
||||
* .bpr("<.5 .25 .1 0>/4")
|
||||
* .release(.5)
|
||||
*/
|
||||
['bprelease', 'bpr'],
|
||||
/**
|
||||
* Sets the filter type. The 24db filter is more aggressive. More types might be added in the future.
|
||||
* @name ftype
|
||||
* @param {number | Pattern} type 12db (default) or 24db
|
||||
* @example
|
||||
* note("<c2 e2 f2 g2>")
|
||||
* .sound('sawtooth')
|
||||
* .lpf(500)
|
||||
* .bpenv(4)
|
||||
* .ftype("<12db 24db>")
|
||||
*/
|
||||
['ftype'],
|
||||
['fanchor'],
|
||||
/**
|
||||
* Applies the cutoff frequency of the **h**igh-**p**ass **f**ilter.
|
||||
*
|
||||
@ -393,6 +650,45 @@ const generic_params = [
|
||||
*/
|
||||
// currently an alias of 'hcutoff' https://github.com/tidalcycles/strudel/issues/496
|
||||
// ['hpf'],
|
||||
/**
|
||||
* Applies a vibrato to the frequency of the oscillator.
|
||||
*
|
||||
* @name vib
|
||||
* @synonyms vibrato, v
|
||||
* @param {number | Pattern} frequency of the vibrato in hertz
|
||||
* @example
|
||||
* note("a")
|
||||
* .vib("<.5 1 2 4 8 16>")
|
||||
* @example
|
||||
* // change the modulation depth with ":"
|
||||
* note("a")
|
||||
* .vib("<.5 1 2 4 8 16>:12")
|
||||
*/
|
||||
[['vib', 'vibmod'], 'vibrato', 'v'],
|
||||
/**
|
||||
* Adds pink noise to the mix
|
||||
*
|
||||
* @name noise
|
||||
* @param {number | Pattern} wet wet amount
|
||||
* @example
|
||||
* sound("<white pink brown>/2")
|
||||
*/
|
||||
['noise'],
|
||||
/**
|
||||
* Sets the vibrato depth in semitones. Only has an effect if `vibrato` | `vib` | `v` is is also set
|
||||
*
|
||||
* @name vibmod
|
||||
* @synonyms vmod
|
||||
* @param {number | Pattern} depth of vibrato (in semitones)
|
||||
* @example
|
||||
* note("a").vib(4)
|
||||
* .vibmod("<.25 .5 1 2 12>")
|
||||
* @example
|
||||
* // change the vibrato frequency with ":"
|
||||
* note("a")
|
||||
* .vibmod("<.25 .5 1 2 12>:8")
|
||||
*/
|
||||
[['vibmod', 'vib'], 'vmod'],
|
||||
[['hcutoff', 'hresonance'], 'hpf', 'hp'],
|
||||
/**
|
||||
* Controls the **h**igh-**p**ass **q**-value.
|
||||
@ -693,20 +989,73 @@ const generic_params = [
|
||||
*
|
||||
*/
|
||||
[['room', 'size']],
|
||||
/**
|
||||
* Reverb lowpass starting frequency (in hertz).
|
||||
* When this property is changed, the reverb will be recaculated, so only change this sparsely..
|
||||
*
|
||||
* @name roomlp
|
||||
* @synonyms rlp
|
||||
* @param {number} frequency between 0 and 20000hz
|
||||
* @example
|
||||
* s("bd sd").room(0.5).rlp(10000)
|
||||
* @example
|
||||
* s("bd sd").room(0.5).rlp(5000)
|
||||
*/
|
||||
['roomlp', 'rlp'],
|
||||
/**
|
||||
* Reverb lowpass frequency at -60dB (in hertz).
|
||||
* When this property is changed, the reverb will be recaculated, so only change this sparsely..
|
||||
*
|
||||
* @name roomdim
|
||||
* @synonyms rdim
|
||||
* @param {number} frequency between 0 and 20000hz
|
||||
* @example
|
||||
* s("bd sd").room(0.5).rlp(10000).rdim(8000)
|
||||
* @example
|
||||
* s("bd sd").room(0.5).rlp(5000).rdim(400)
|
||||
*
|
||||
*/
|
||||
['roomdim', 'rdim'],
|
||||
/**
|
||||
* Reverb fade time (in seconds).
|
||||
* When this property is changed, the reverb will be recaculated, so only change this sparsely..
|
||||
*
|
||||
* @name roomfade
|
||||
* @synonyms rfade
|
||||
* @param {number} seconds for the reverb to fade
|
||||
* @example
|
||||
* s("bd sd").room(0.5).rlp(10000).rfade(0.5)
|
||||
* @example
|
||||
* s("bd sd").room(0.5).rlp(5000).rfade(4)
|
||||
*
|
||||
*/
|
||||
['roomfade', 'rfade'],
|
||||
/**
|
||||
* Sets the sample to use as an impulse response for the reverb. * * @name iresponse
|
||||
* @param {string | Pattern} sample to use as an impulse response
|
||||
* @synonyms ir
|
||||
* @example
|
||||
* s("bd sd").room(.8).ir("<shaker_large:0 shaker_large:2>")
|
||||
*
|
||||
*/
|
||||
[['ir', 'i'], 'iresponse'],
|
||||
/**
|
||||
* Sets the room size of the reverb, see {@link room}.
|
||||
* When this property is changed, the reverb will be recaculated, so only change this sparsely..
|
||||
*
|
||||
* @name roomsize
|
||||
* @param {number | Pattern} size between 0 and 10
|
||||
* @synonyms size, sz
|
||||
* @synonyms rsize, sz, size
|
||||
* @example
|
||||
* s("bd sd").room(.8).roomsize("<0 1 2 4 8>")
|
||||
* s("bd sd").room(.8).rsize(1)
|
||||
* @example
|
||||
* s("bd sd").room(.8).rsize(4)
|
||||
*
|
||||
*/
|
||||
// TODO: find out why :
|
||||
// s("bd sd").room(.8).roomsize("<0 .2 .4 .6 .8 [1,0]>").osc()
|
||||
// .. does not work. Is it because room is only one effect?
|
||||
['size', 'sz', 'roomsize'],
|
||||
['roomsize', 'size', 'sz', 'rsize'],
|
||||
// ['sagogo'],
|
||||
// ['sclap'],
|
||||
// ['sclaves'],
|
||||
@ -721,6 +1070,21 @@ const generic_params = [
|
||||
*
|
||||
*/
|
||||
['shape'],
|
||||
/**
|
||||
* Dynamics Compressor. The params are `compressor("threshold:ratio:knee:attack:release")`
|
||||
* More info [here](https://developer.mozilla.org/en-US/docs/Web/API/DynamicsCompressorNode?retiredLocale=de#instance_properties)
|
||||
*
|
||||
* @name compressor
|
||||
* @example
|
||||
* s("bd sd,hh*4")
|
||||
* .compressor("-20:20:10:.002:.02")
|
||||
*
|
||||
*/
|
||||
[['compressor', 'compressorRatio', 'compressorKnee', 'compressorAttack', 'compressorRelease']],
|
||||
['compressorKnee'],
|
||||
['compressorRatio'],
|
||||
['compressorAttack'],
|
||||
['compressorRelease'],
|
||||
/**
|
||||
* Changes the speed of sample playback, i.e. a cheap way of changing pitch.
|
||||
*
|
||||
@ -876,7 +1240,7 @@ const generic_params = [
|
||||
['pitchJump'],
|
||||
['pitchJumpTime'],
|
||||
['lfo', 'repeatTime'],
|
||||
['noise'],
|
||||
['znoise'], // noise on the frequency or as bubo calls it "frequency fog" :)
|
||||
['zmod'],
|
||||
['zcrush'], // like crush but scaled differently
|
||||
['zdelay'],
|
||||
|
||||
@ -3,6 +3,6 @@
|
||||
This folder demonstrates how to set up a strudel repl using vite and vanilla JS + codemirror. Run it using:
|
||||
|
||||
```sh
|
||||
npm i
|
||||
npm run dev
|
||||
pnpm i
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel.cycles/core",
|
||||
"version": "0.8.2",
|
||||
"version": "0.9.0",
|
||||
"description": "Port of Tidal Cycles to JavaScript",
|
||||
"main": "index.mjs",
|
||||
"type": "module",
|
||||
|
||||
@ -2273,14 +2273,14 @@ export const slice = register(
|
||||
false, // turns off auto-patternification
|
||||
);
|
||||
|
||||
/*
|
||||
/**
|
||||
* Works the same as slice, but changes the playback speed of each slice to match the duration of its step.
|
||||
* @name splice
|
||||
* @memberof Pattern
|
||||
* @returns Pattern
|
||||
* @example
|
||||
* await samples('github:tidalcycles/Dirt-Samples/master')
|
||||
* s("breaks165").splice(8, "0 1 [2 3 0]@2 3 0@2 7").hurry(0.65)
|
||||
* s("breaks165")
|
||||
* .splice(8, "0 1 [2 3 0]@2 3 0@2 7")
|
||||
* .hurry(0.65)
|
||||
*/
|
||||
|
||||
export const splice = register(
|
||||
@ -2307,9 +2307,16 @@ export const { loopAt, loopat } = register(['loopAt', 'loopat'], function (facto
|
||||
return _loopAt(factor, pat, 1);
|
||||
});
|
||||
|
||||
// this function will be redefined in repl.mjs to use the correct cps value.
|
||||
// the fit function will be redefined in repl.mjs to use the correct cps value.
|
||||
// It is still here to work in cases where repl.mjs is not used
|
||||
|
||||
/**
|
||||
* Makes the sample fit its event duration. Good for rhythmical loops like drum breaks.
|
||||
* Similar to loopAt.
|
||||
* @name fit
|
||||
* @example
|
||||
* samples({ rhodes: 'https://cdn.freesound.org/previews/132/132051_316502-lq.mp3' })
|
||||
* s("rhodes/4").fit()
|
||||
*/
|
||||
export const fit = register('fit', (pat) =>
|
||||
pat.withHap((hap) =>
|
||||
hap.withValue((v) => ({
|
||||
@ -2336,3 +2343,9 @@ export const fit = register('fit', (pat) =>
|
||||
export const { loopAtCps, loopatcps } = register(['loopAtCps', 'loopatcps'], function (factor, cps, pat) {
|
||||
return _loopAt(factor, pat, cps);
|
||||
});
|
||||
|
||||
/** exposes a custom value at query time. basically allows mutating state without evaluation */
|
||||
export const ref = (accessor) =>
|
||||
pure(1)
|
||||
.withValue(() => reify(accessor()))
|
||||
.innerJoin();
|
||||
|
||||
@ -160,7 +160,11 @@ export const __chooseWith = (pat, xs) => {
|
||||
if (xs.length == 0) {
|
||||
return silence;
|
||||
}
|
||||
return pat.range(0, xs.length).fmap((i) => xs[Math.floor(i)]);
|
||||
|
||||
return pat.range(0, xs.length).fmap((i) => {
|
||||
const key = Math.min(Math.max(Math.floor(i), 0), xs.length - 1);
|
||||
return xs[key];
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Choose from the list of values (or patterns of values) using the given
|
||||
@ -168,6 +172,8 @@ export const __chooseWith = (pat, xs) => {
|
||||
* @param {Pattern} pat
|
||||
* @param {*} xs
|
||||
* @returns {Pattern}
|
||||
* @example
|
||||
* note("c2 g2!2 d2 f1").s(chooseWith(sine.fast(2), ["sawtooth", "triangle", "bd:6"]))
|
||||
*/
|
||||
export const chooseWith = (pat, xs) => {
|
||||
return __chooseWith(pat, xs).outerJoin();
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel.cycles/csound",
|
||||
"version": "0.8.0",
|
||||
"version": "0.9.0",
|
||||
"description": "csound bindings for strudel",
|
||||
"main": "index.mjs",
|
||||
"publishConfig": {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "@strudel/desktopbridge",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"description": "tools/shims for communicating between the JS and Tauri (Rust) sides of the Studel desktop app",
|
||||
"main": "index.mjs",
|
||||
"type": "module",
|
||||
|
||||
@ -5,7 +5,7 @@ This program is free software: you can redistribute it and/or modify it under th
|
||||
*/
|
||||
|
||||
import * as _WebMidi from 'webmidi';
|
||||
import { Pattern, isPattern, logger } from '@strudel.cycles/core';
|
||||
import { Pattern, isPattern, logger, ref } from '@strudel.cycles/core';
|
||||
import { noteToMidi } from '@strudel.cycles/core';
|
||||
import { Note } from 'webmidi';
|
||||
// if you use WebMidi from outside of this package, make sure to import that instance:
|
||||
@ -15,8 +15,8 @@ function supportsMidi() {
|
||||
return typeof navigator.requestMIDIAccess === 'function';
|
||||
}
|
||||
|
||||
function getMidiDeviceNamesString(outputs) {
|
||||
return outputs.map((o) => `'${o.name}'`).join(' | ');
|
||||
function getMidiDeviceNamesString(devices) {
|
||||
return devices.map((o) => `'${o.name}'`).join(' | ');
|
||||
}
|
||||
|
||||
export function enableWebMidi(options = {}) {
|
||||
@ -52,30 +52,41 @@ export function enableWebMidi(options = {}) {
|
||||
});
|
||||
});
|
||||
}
|
||||
// const outputByName = (name: string) => WebMidi.getOutputByName(name);
|
||||
const outputByName = (name) => WebMidi.getOutputByName(name);
|
||||
|
||||
// output?: string | number, outputs: typeof WebMidi.outputs
|
||||
function getDevice(output, outputs) {
|
||||
if (!outputs.length) {
|
||||
function getDevice(indexOrName, devices) {
|
||||
if (!devices.length) {
|
||||
throw new Error(`🔌 No MIDI devices found. Connect a device or enable IAC Driver.`);
|
||||
}
|
||||
if (typeof output === 'number') {
|
||||
return outputs[output];
|
||||
if (typeof indexOrName === 'number') {
|
||||
return devices[indexOrName];
|
||||
}
|
||||
if (typeof output === 'string') {
|
||||
return outputByName(output);
|
||||
const byName = (name) => devices.find((output) => output.name.includes(name));
|
||||
if (typeof indexOrName === 'string') {
|
||||
return byName(indexOrName);
|
||||
}
|
||||
// attempt to default to first IAC device if none is specified
|
||||
const IACOutput = outputs.find((output) => output.name.includes('IAC'));
|
||||
const device = IACOutput ?? outputs[0];
|
||||
const IACOutput = byName('IAC');
|
||||
const device = IACOutput ?? devices[0];
|
||||
if (!device) {
|
||||
throw new Error(
|
||||
`🔌 MIDI device '${output ? output : ''}' not found. Use one of ${getMidiDeviceNamesString(WebMidi.outputs)}`,
|
||||
`🔌 MIDI device '${device ? device : ''}' not found. Use one of ${getMidiDeviceNamesString(devices)}`,
|
||||
);
|
||||
}
|
||||
|
||||
return IACOutput ?? outputs[0];
|
||||
return IACOutput ?? devices[0];
|
||||
}
|
||||
|
||||
// send start/stop messages to outputs when repl starts/stops
|
||||
if (typeof window !== 'undefined') {
|
||||
window.addEventListener('message', (e) => {
|
||||
if (!WebMidi?.enabled) {
|
||||
return;
|
||||
}
|
||||
if (e.data === 'strudel-stop') {
|
||||
WebMidi.outputs.forEach((output) => output.sendStop());
|
||||
}
|
||||
// cannot start here, since we have no timing info, see sendStart below
|
||||
});
|
||||
}
|
||||
|
||||
Pattern.prototype.midi = function (output) {
|
||||
@ -103,6 +114,7 @@ Pattern.prototype.midi = function (output) {
|
||||
|
||||
return this.onTrigger((time, hap, currentTime, cps) => {
|
||||
if (!WebMidi.enabled) {
|
||||
console.log('not enabled');
|
||||
return;
|
||||
}
|
||||
const device = getDevice(output, WebMidi.outputs);
|
||||
@ -113,7 +125,7 @@ Pattern.prototype.midi = function (output) {
|
||||
const timeOffsetString = `+${offset}`;
|
||||
|
||||
// destructure value
|
||||
const { note, nrpnn, nrpv, ccn, ccv, midichan = 1 } = hap.value;
|
||||
const { note, nrpnn, nrpv, ccn, ccv, midichan = 1, midicmd } = hap.value;
|
||||
const velocity = hap.context?.velocity ?? 0.9; // TODO: refactor velocity
|
||||
|
||||
// note off messages will often a few ms arrive late, try to prevent glitching by subtracting from the duration length
|
||||
@ -125,7 +137,7 @@ Pattern.prototype.midi = function (output) {
|
||||
time: timeOffsetString,
|
||||
});
|
||||
}
|
||||
if (ccv && ccn) {
|
||||
if (ccv !== undefined && ccn !== undefined) {
|
||||
if (typeof ccv !== 'number' || ccv < 0 || ccv > 1) {
|
||||
throw new Error('expected ccv to be a number between 0 and 1');
|
||||
}
|
||||
@ -135,5 +147,46 @@ Pattern.prototype.midi = function (output) {
|
||||
const scaled = Math.round(ccv * 127);
|
||||
device.sendControlChange(ccn, scaled, midichan, { time: timeOffsetString });
|
||||
}
|
||||
if (hap.whole.begin + 0 === 0) {
|
||||
// we need to start here because we have the timing info
|
||||
device.sendStart({ time: timeOffsetString });
|
||||
}
|
||||
if (['clock', 'midiClock'].includes(midicmd)) {
|
||||
device.sendClock({ time: timeOffsetString });
|
||||
} else if (['start'].includes(midicmd)) {
|
||||
device.sendStart({ time: timeOffsetString });
|
||||
} else if (['stop'].includes(midicmd)) {
|
||||
device.sendStop({ time: timeOffsetString });
|
||||
} else if (['continue'].includes(midicmd)) {
|
||||
device.sendContinue({ time: timeOffsetString });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
let listeners = {};
|
||||
const refs = {};
|
||||
|
||||
export async function midin(input) {
|
||||
const initial = await enableWebMidi(); // only returns on first init
|
||||
const device = getDevice(input, WebMidi.inputs);
|
||||
|
||||
if (initial) {
|
||||
const otherInputs = WebMidi.inputs.filter((o) => o.name !== device.name);
|
||||
logger(
|
||||
`Midi enabled! Using "${device.name}". ${
|
||||
otherInputs?.length ? `Also available: ${getMidiDeviceNamesString(otherInputs)}` : ''
|
||||
}`,
|
||||
);
|
||||
refs[input] = {};
|
||||
}
|
||||
const cc = (cc) => ref(() => refs[input][cc] || 0);
|
||||
|
||||
listeners[input] && device.removeListener('midimessage', listeners[input]);
|
||||
listeners[input] = (e) => {
|
||||
const cc = e.dataBytes[0];
|
||||
const v = e.dataBytes[1];
|
||||
refs[input] && (refs[input][cc] = v / 127);
|
||||
};
|
||||
device.addListener('midimessage', listeners[input]);
|
||||
return cc;
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel.cycles/midi",
|
||||
"version": "0.8.0",
|
||||
"version": "0.9.0",
|
||||
"description": "Midi API for strudel",
|
||||
"main": "index.mjs",
|
||||
"publishConfig": {
|
||||
|
||||
@ -200,20 +200,21 @@ function peg$parse(input, options) {
|
||||
var peg$c23 = "*";
|
||||
var peg$c24 = "?";
|
||||
var peg$c25 = ":";
|
||||
var peg$c26 = "struct";
|
||||
var peg$c27 = "target";
|
||||
var peg$c28 = "euclid";
|
||||
var peg$c29 = "slow";
|
||||
var peg$c30 = "rotL";
|
||||
var peg$c31 = "rotR";
|
||||
var peg$c32 = "fast";
|
||||
var peg$c33 = "scale";
|
||||
var peg$c34 = "//";
|
||||
var peg$c35 = "cat";
|
||||
var peg$c36 = "$";
|
||||
var peg$c37 = "setcps";
|
||||
var peg$c38 = "setbpm";
|
||||
var peg$c39 = "hush";
|
||||
var peg$c26 = "..";
|
||||
var peg$c27 = "struct";
|
||||
var peg$c28 = "target";
|
||||
var peg$c29 = "euclid";
|
||||
var peg$c30 = "slow";
|
||||
var peg$c31 = "rotL";
|
||||
var peg$c32 = "rotR";
|
||||
var peg$c33 = "fast";
|
||||
var peg$c34 = "scale";
|
||||
var peg$c35 = "//";
|
||||
var peg$c36 = "cat";
|
||||
var peg$c37 = "$";
|
||||
var peg$c38 = "setcps";
|
||||
var peg$c39 = "setbpm";
|
||||
var peg$c40 = "hush";
|
||||
|
||||
var peg$r0 = /^[1-9]/;
|
||||
var peg$r1 = /^[eE]/;
|
||||
@ -255,64 +256,67 @@ function peg$parse(input, options) {
|
||||
var peg$e30 = peg$literalExpectation("*", false);
|
||||
var peg$e31 = peg$literalExpectation("?", false);
|
||||
var peg$e32 = peg$literalExpectation(":", false);
|
||||
var peg$e33 = peg$literalExpectation("struct", false);
|
||||
var peg$e34 = peg$literalExpectation("target", false);
|
||||
var peg$e35 = peg$literalExpectation("euclid", false);
|
||||
var peg$e36 = peg$literalExpectation("slow", false);
|
||||
var peg$e37 = peg$literalExpectation("rotL", false);
|
||||
var peg$e38 = peg$literalExpectation("rotR", false);
|
||||
var peg$e39 = peg$literalExpectation("fast", false);
|
||||
var peg$e40 = peg$literalExpectation("scale", false);
|
||||
var peg$e41 = peg$literalExpectation("//", false);
|
||||
var peg$e42 = peg$classExpectation(["\n"], true, false);
|
||||
var peg$e43 = peg$literalExpectation("cat", false);
|
||||
var peg$e44 = peg$literalExpectation("$", false);
|
||||
var peg$e45 = peg$literalExpectation("setcps", false);
|
||||
var peg$e46 = peg$literalExpectation("setbpm", false);
|
||||
var peg$e47 = peg$literalExpectation("hush", false);
|
||||
var peg$e33 = peg$literalExpectation("..", false);
|
||||
var peg$e34 = peg$literalExpectation("struct", false);
|
||||
var peg$e35 = peg$literalExpectation("target", false);
|
||||
var peg$e36 = peg$literalExpectation("euclid", false);
|
||||
var peg$e37 = peg$literalExpectation("slow", false);
|
||||
var peg$e38 = peg$literalExpectation("rotL", false);
|
||||
var peg$e39 = peg$literalExpectation("rotR", false);
|
||||
var peg$e40 = peg$literalExpectation("fast", false);
|
||||
var peg$e41 = peg$literalExpectation("scale", false);
|
||||
var peg$e42 = peg$literalExpectation("//", false);
|
||||
var peg$e43 = peg$classExpectation(["\n"], true, false);
|
||||
var peg$e44 = peg$literalExpectation("cat", false);
|
||||
var peg$e45 = peg$literalExpectation("$", false);
|
||||
var peg$e46 = peg$literalExpectation("setcps", false);
|
||||
var peg$e47 = peg$literalExpectation("setbpm", false);
|
||||
var peg$e48 = peg$literalExpectation("hush", false);
|
||||
|
||||
var peg$f0 = function() { return parseFloat(text()); };
|
||||
var peg$f1 = function(chars) { return new AtomStub(chars.join("")) };
|
||||
var peg$f2 = function(s) { return s };
|
||||
var peg$f3 = function(s, stepsPerCycle) { s.arguments_.stepsPerCycle = stepsPerCycle ; return s; };
|
||||
var peg$f4 = function(a) { return a };
|
||||
var peg$f5 = function(s) { s.arguments_.alignment = 'slowcat'; return s; };
|
||||
var peg$f6 = function(a) { return x => x.options_['weight'] = a };
|
||||
var peg$f7 = function(a) { return x => x.options_['reps'] = a };
|
||||
var peg$f8 = function(p, s, r) { return x => x.options_['ops'].push({ type_: "bjorklund", arguments_ :{ pulse: p, step:s, rotation:r }}) };
|
||||
var peg$f9 = function(a) { return x => x.options_['ops'].push({ type_: "stretch", arguments_ :{ amount:a, type: 'slow' }}) };
|
||||
var peg$f10 = function(a) { return x => x.options_['ops'].push({ type_: "stretch", arguments_ :{ amount:a, type: 'fast' }}) };
|
||||
var peg$f11 = function(a) { return x => x.options_['ops'].push({ type_: "degradeBy", arguments_ :{ amount:a, seed: seed++ } }) };
|
||||
var peg$f12 = function(s) { return x => x.options_['ops'].push({ type_: "tail", arguments_ :{ element:s } }) };
|
||||
var peg$f13 = function(s, ops) { const result = new ElementStub(s, {ops: [], weight: 1, reps: 1});
|
||||
var peg$f1 = function() { return parseInt(text()); };
|
||||
var peg$f2 = function(chars) { return new AtomStub(chars.join("")) };
|
||||
var peg$f3 = function(s) { return s };
|
||||
var peg$f4 = function(s, stepsPerCycle) { s.arguments_.stepsPerCycle = stepsPerCycle ; return s; };
|
||||
var peg$f5 = function(a) { return a };
|
||||
var peg$f6 = function(s) { s.arguments_.alignment = 'slowcat'; return s; };
|
||||
var peg$f7 = function(a) { return x => x.options_['weight'] = a };
|
||||
var peg$f8 = function(a) { return x => x.options_['reps'] = a };
|
||||
var peg$f9 = function(p, s, r) { return x => x.options_['ops'].push({ type_: "bjorklund", arguments_ :{ pulse: p, step:s, rotation:r }}) };
|
||||
var peg$f10 = function(a) { return x => x.options_['ops'].push({ type_: "stretch", arguments_ :{ amount:a, type: 'slow' }}) };
|
||||
var peg$f11 = function(a) { return x => x.options_['ops'].push({ type_: "stretch", arguments_ :{ amount:a, type: 'fast' }}) };
|
||||
var peg$f12 = function(a) { return x => x.options_['ops'].push({ type_: "degradeBy", arguments_ :{ amount:a, seed: seed++ } }) };
|
||||
var peg$f13 = function(s) { return x => x.options_['ops'].push({ type_: "tail", arguments_ :{ element:s } }) };
|
||||
var peg$f14 = function(s) { return x => x.options_['ops'].push({ type_: "range", arguments_ :{ element:s } }) };
|
||||
var peg$f15 = function(s, ops) { const result = new ElementStub(s, {ops: [], weight: 1, reps: 1});
|
||||
for (const op of ops) {
|
||||
op(result);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
var peg$f14 = function(s) { return new PatternStub(s, 'fastcat'); };
|
||||
var peg$f15 = function(tail) { return { alignment: 'stack', list: tail }; };
|
||||
var peg$f16 = function(tail) { return { alignment: 'rand', list: tail, seed: seed++ }; };
|
||||
var peg$f17 = function(head, tail) { if (tail && tail.list.length > 0) { return new PatternStub([head, ...tail.list], tail.alignment, tail.seed); } else { return head; } };
|
||||
var peg$f18 = function(head, tail) { return new PatternStub(tail ? [head, ...tail.list] : [head], 'polymeter'); };
|
||||
var peg$f19 = function(sc) { return sc; };
|
||||
var peg$f20 = function(s) { return { name: "struct", args: { mini:s }}};
|
||||
var peg$f21 = function(s) { return { name: "target", args : { name:s}}};
|
||||
var peg$f22 = function(p, s, r) { return { name: "bjorklund", args :{ pulse: p, step:parseInt(s) }}};
|
||||
var peg$f23 = function(a) { return { name: "stretch", args :{ amount: a}}};
|
||||
var peg$f24 = function(a) { return { name: "shift", args :{ amount: "-"+a}}};
|
||||
var peg$f25 = function(a) { return { name: "shift", args :{ amount: a}}};
|
||||
var peg$f26 = function(a) { return { name: "stretch", args :{ amount: "1/"+a}}};
|
||||
var peg$f27 = function(s) { return { name: "scale", args :{ scale: s.join("")}}};
|
||||
var peg$f28 = function(s, v) { return v};
|
||||
var peg$f29 = function(s, ss) { ss.unshift(s); return new PatternStub(ss, 'slowcat'); };
|
||||
var peg$f30 = function(sg) {return sg};
|
||||
var peg$f31 = function(o, soc) { return new OperatorStub(o.name,o.args,soc)};
|
||||
var peg$f32 = function(sc) { return sc };
|
||||
var peg$f33 = function(c) { return c };
|
||||
var peg$f34 = function(v) { return new CommandStub("setcps", { value: v})};
|
||||
var peg$f35 = function(v) { return new CommandStub("setcps", { value: (v/120/2)})};
|
||||
var peg$f36 = function() { return new CommandStub("hush")};
|
||||
var peg$f16 = function(s) { return new PatternStub(s, 'fastcat'); };
|
||||
var peg$f17 = function(tail) { return { alignment: 'stack', list: tail }; };
|
||||
var peg$f18 = function(tail) { return { alignment: 'rand', list: tail, seed: seed++ }; };
|
||||
var peg$f19 = function(head, tail) { if (tail && tail.list.length > 0) { return new PatternStub([head, ...tail.list], tail.alignment, tail.seed); } else { return head; } };
|
||||
var peg$f20 = function(head, tail) { return new PatternStub(tail ? [head, ...tail.list] : [head], 'polymeter'); };
|
||||
var peg$f21 = function(sc) { return sc; };
|
||||
var peg$f22 = function(s) { return { name: "struct", args: { mini:s }}};
|
||||
var peg$f23 = function(s) { return { name: "target", args : { name:s}}};
|
||||
var peg$f24 = function(p, s, r) { return { name: "bjorklund", args :{ pulse: p, step:parseInt(s) }}};
|
||||
var peg$f25 = function(a) { return { name: "stretch", args :{ amount: a}}};
|
||||
var peg$f26 = function(a) { return { name: "shift", args :{ amount: "-"+a}}};
|
||||
var peg$f27 = function(a) { return { name: "shift", args :{ amount: a}}};
|
||||
var peg$f28 = function(a) { return { name: "stretch", args :{ amount: "1/"+a}}};
|
||||
var peg$f29 = function(s) { return { name: "scale", args :{ scale: s.join("")}}};
|
||||
var peg$f30 = function(s, v) { return v};
|
||||
var peg$f31 = function(s, ss) { ss.unshift(s); return new PatternStub(ss, 'slowcat'); };
|
||||
var peg$f32 = function(sg) {return sg};
|
||||
var peg$f33 = function(o, soc) { return new OperatorStub(o.name,o.args,soc)};
|
||||
var peg$f34 = function(sc) { return sc };
|
||||
var peg$f35 = function(c) { return c };
|
||||
var peg$f36 = function(v) { return new CommandStub("setcps", { value: v})};
|
||||
var peg$f37 = function(v) { return new CommandStub("setcps", { value: (v/120/2)})};
|
||||
var peg$f38 = function() { return new CommandStub("hush")};
|
||||
var peg$currPos = 0;
|
||||
var peg$savedPos = 0;
|
||||
var peg$posDetailsCache = [{ line: 1, column: 1 }];
|
||||
@ -651,6 +655,26 @@ function peg$parse(input, options) {
|
||||
return s0;
|
||||
}
|
||||
|
||||
function peg$parseintneg() {
|
||||
var s0, s1, s2;
|
||||
|
||||
s0 = peg$currPos;
|
||||
s1 = peg$parseminus();
|
||||
if (s1 === peg$FAILED) {
|
||||
s1 = null;
|
||||
}
|
||||
s2 = peg$parseint();
|
||||
if (s2 !== peg$FAILED) {
|
||||
peg$savedPos = s0;
|
||||
s0 = peg$f1();
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
}
|
||||
|
||||
return s0;
|
||||
}
|
||||
|
||||
function peg$parseminus() {
|
||||
var s0;
|
||||
|
||||
@ -884,7 +908,7 @@ function peg$parse(input, options) {
|
||||
if (s2 !== peg$FAILED) {
|
||||
s3 = peg$parsews();
|
||||
peg$savedPos = s0;
|
||||
s0 = peg$f1(s2);
|
||||
s0 = peg$f2(s2);
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
@ -920,7 +944,7 @@ function peg$parse(input, options) {
|
||||
if (s6 !== peg$FAILED) {
|
||||
s7 = peg$parsews();
|
||||
peg$savedPos = s0;
|
||||
s0 = peg$f2(s4);
|
||||
s0 = peg$f3(s4);
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
@ -968,7 +992,7 @@ function peg$parse(input, options) {
|
||||
}
|
||||
s8 = peg$parsews();
|
||||
peg$savedPos = s0;
|
||||
s0 = peg$f3(s4, s7);
|
||||
s0 = peg$f4(s4, s7);
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
@ -1000,7 +1024,7 @@ function peg$parse(input, options) {
|
||||
s2 = peg$parseslice();
|
||||
if (s2 !== peg$FAILED) {
|
||||
peg$savedPos = s0;
|
||||
s0 = peg$f4(s2);
|
||||
s0 = peg$f5(s2);
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
@ -1040,7 +1064,7 @@ function peg$parse(input, options) {
|
||||
if (s6 !== peg$FAILED) {
|
||||
s7 = peg$parsews();
|
||||
peg$savedPos = s0;
|
||||
s0 = peg$f5(s4);
|
||||
s0 = peg$f6(s4);
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
@ -1090,6 +1114,9 @@ function peg$parse(input, options) {
|
||||
s0 = peg$parseop_degrade();
|
||||
if (s0 === peg$FAILED) {
|
||||
s0 = peg$parseop_tail();
|
||||
if (s0 === peg$FAILED) {
|
||||
s0 = peg$parseop_range();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1115,7 +1142,7 @@ function peg$parse(input, options) {
|
||||
s2 = peg$parsenumber();
|
||||
if (s2 !== peg$FAILED) {
|
||||
peg$savedPos = s0;
|
||||
s0 = peg$f6(s2);
|
||||
s0 = peg$f7(s2);
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
@ -1143,7 +1170,7 @@ function peg$parse(input, options) {
|
||||
s2 = peg$parsenumber();
|
||||
if (s2 !== peg$FAILED) {
|
||||
peg$savedPos = s0;
|
||||
s0 = peg$f7(s2);
|
||||
s0 = peg$f8(s2);
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
@ -1197,7 +1224,7 @@ function peg$parse(input, options) {
|
||||
}
|
||||
if (s13 !== peg$FAILED) {
|
||||
peg$savedPos = s0;
|
||||
s0 = peg$f8(s3, s7, s11);
|
||||
s0 = peg$f9(s3, s7, s11);
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
@ -1237,7 +1264,7 @@ function peg$parse(input, options) {
|
||||
s2 = peg$parseslice();
|
||||
if (s2 !== peg$FAILED) {
|
||||
peg$savedPos = s0;
|
||||
s0 = peg$f9(s2);
|
||||
s0 = peg$f10(s2);
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
@ -1265,7 +1292,7 @@ function peg$parse(input, options) {
|
||||
s2 = peg$parseslice();
|
||||
if (s2 !== peg$FAILED) {
|
||||
peg$savedPos = s0;
|
||||
s0 = peg$f10(s2);
|
||||
s0 = peg$f11(s2);
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
@ -1295,7 +1322,7 @@ function peg$parse(input, options) {
|
||||
s2 = null;
|
||||
}
|
||||
peg$savedPos = s0;
|
||||
s0 = peg$f11(s2);
|
||||
s0 = peg$f12(s2);
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
@ -1319,7 +1346,35 @@ function peg$parse(input, options) {
|
||||
s2 = peg$parseslice();
|
||||
if (s2 !== peg$FAILED) {
|
||||
peg$savedPos = s0;
|
||||
s0 = peg$f12(s2);
|
||||
s0 = peg$f13(s2);
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
}
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
}
|
||||
|
||||
return s0;
|
||||
}
|
||||
|
||||
function peg$parseop_range() {
|
||||
var s0, s1, s2;
|
||||
|
||||
s0 = peg$currPos;
|
||||
if (input.substr(peg$currPos, 2) === peg$c26) {
|
||||
s1 = peg$c26;
|
||||
peg$currPos += 2;
|
||||
} else {
|
||||
s1 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e33); }
|
||||
}
|
||||
if (s1 !== peg$FAILED) {
|
||||
s2 = peg$parseslice();
|
||||
if (s2 !== peg$FAILED) {
|
||||
peg$savedPos = s0;
|
||||
s0 = peg$f14(s2);
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
@ -1345,7 +1400,7 @@ function peg$parse(input, options) {
|
||||
s3 = peg$parseslice_op();
|
||||
}
|
||||
peg$savedPos = s0;
|
||||
s0 = peg$f13(s1, s2);
|
||||
s0 = peg$f15(s1, s2);
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
@ -1370,7 +1425,7 @@ function peg$parse(input, options) {
|
||||
}
|
||||
if (s1 !== peg$FAILED) {
|
||||
peg$savedPos = s0;
|
||||
s1 = peg$f14(s1);
|
||||
s1 = peg$f16(s1);
|
||||
}
|
||||
s0 = s1;
|
||||
|
||||
@ -1419,7 +1474,7 @@ function peg$parse(input, options) {
|
||||
}
|
||||
if (s1 !== peg$FAILED) {
|
||||
peg$savedPos = s0;
|
||||
s1 = peg$f15(s1);
|
||||
s1 = peg$f17(s1);
|
||||
}
|
||||
s0 = s1;
|
||||
|
||||
@ -1468,7 +1523,7 @@ function peg$parse(input, options) {
|
||||
}
|
||||
if (s1 !== peg$FAILED) {
|
||||
peg$savedPos = s0;
|
||||
s1 = peg$f16(s1);
|
||||
s1 = peg$f18(s1);
|
||||
}
|
||||
s0 = s1;
|
||||
|
||||
@ -1489,7 +1544,7 @@ function peg$parse(input, options) {
|
||||
s2 = null;
|
||||
}
|
||||
peg$savedPos = s0;
|
||||
s0 = peg$f17(s1, s2);
|
||||
s0 = peg$f19(s1, s2);
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
@ -1509,7 +1564,7 @@ function peg$parse(input, options) {
|
||||
s2 = null;
|
||||
}
|
||||
peg$savedPos = s0;
|
||||
s0 = peg$f18(s1, s2);
|
||||
s0 = peg$f20(s1, s2);
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
@ -1532,7 +1587,7 @@ function peg$parse(input, options) {
|
||||
s6 = peg$parsequote();
|
||||
if (s6 !== peg$FAILED) {
|
||||
peg$savedPos = s0;
|
||||
s0 = peg$f19(s4);
|
||||
s0 = peg$f21(s4);
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
@ -1582,19 +1637,19 @@ function peg$parse(input, options) {
|
||||
var s0, s1, s2, s3;
|
||||
|
||||
s0 = peg$currPos;
|
||||
if (input.substr(peg$currPos, 6) === peg$c26) {
|
||||
s1 = peg$c26;
|
||||
if (input.substr(peg$currPos, 6) === peg$c27) {
|
||||
s1 = peg$c27;
|
||||
peg$currPos += 6;
|
||||
} else {
|
||||
s1 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e33); }
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e34); }
|
||||
}
|
||||
if (s1 !== peg$FAILED) {
|
||||
s2 = peg$parsews();
|
||||
s3 = peg$parsemini_or_operator();
|
||||
if (s3 !== peg$FAILED) {
|
||||
peg$savedPos = s0;
|
||||
s0 = peg$f20(s3);
|
||||
s0 = peg$f22(s3);
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
@ -1611,12 +1666,12 @@ function peg$parse(input, options) {
|
||||
var s0, s1, s2, s3, s4, s5;
|
||||
|
||||
s0 = peg$currPos;
|
||||
if (input.substr(peg$currPos, 6) === peg$c27) {
|
||||
s1 = peg$c27;
|
||||
if (input.substr(peg$currPos, 6) === peg$c28) {
|
||||
s1 = peg$c28;
|
||||
peg$currPos += 6;
|
||||
} else {
|
||||
s1 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e34); }
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e35); }
|
||||
}
|
||||
if (s1 !== peg$FAILED) {
|
||||
s2 = peg$parsews();
|
||||
@ -1627,7 +1682,7 @@ function peg$parse(input, options) {
|
||||
s5 = peg$parsequote();
|
||||
if (s5 !== peg$FAILED) {
|
||||
peg$savedPos = s0;
|
||||
s0 = peg$f21(s4);
|
||||
s0 = peg$f23(s4);
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
@ -1652,12 +1707,12 @@ function peg$parse(input, options) {
|
||||
var s0, s1, s2, s3, s4, s5, s6, s7;
|
||||
|
||||
s0 = peg$currPos;
|
||||
if (input.substr(peg$currPos, 6) === peg$c28) {
|
||||
s1 = peg$c28;
|
||||
if (input.substr(peg$currPos, 6) === peg$c29) {
|
||||
s1 = peg$c29;
|
||||
peg$currPos += 6;
|
||||
} else {
|
||||
s1 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e35); }
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e36); }
|
||||
}
|
||||
if (s1 !== peg$FAILED) {
|
||||
s2 = peg$parsews();
|
||||
@ -1672,7 +1727,7 @@ function peg$parse(input, options) {
|
||||
s7 = null;
|
||||
}
|
||||
peg$savedPos = s0;
|
||||
s0 = peg$f22(s3, s5, s7);
|
||||
s0 = peg$f24(s3, s5, s7);
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
@ -1692,35 +1747,6 @@ function peg$parse(input, options) {
|
||||
function peg$parseslow() {
|
||||
var s0, s1, s2, s3;
|
||||
|
||||
s0 = peg$currPos;
|
||||
if (input.substr(peg$currPos, 4) === peg$c29) {
|
||||
s1 = peg$c29;
|
||||
peg$currPos += 4;
|
||||
} else {
|
||||
s1 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e36); }
|
||||
}
|
||||
if (s1 !== peg$FAILED) {
|
||||
s2 = peg$parsews();
|
||||
s3 = peg$parsenumber();
|
||||
if (s3 !== peg$FAILED) {
|
||||
peg$savedPos = s0;
|
||||
s0 = peg$f23(s3);
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
}
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
}
|
||||
|
||||
return s0;
|
||||
}
|
||||
|
||||
function peg$parserotL() {
|
||||
var s0, s1, s2, s3;
|
||||
|
||||
s0 = peg$currPos;
|
||||
if (input.substr(peg$currPos, 4) === peg$c30) {
|
||||
s1 = peg$c30;
|
||||
@ -1729,35 +1755,6 @@ function peg$parse(input, options) {
|
||||
s1 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e37); }
|
||||
}
|
||||
if (s1 !== peg$FAILED) {
|
||||
s2 = peg$parsews();
|
||||
s3 = peg$parsenumber();
|
||||
if (s3 !== peg$FAILED) {
|
||||
peg$savedPos = s0;
|
||||
s0 = peg$f24(s3);
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
}
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
}
|
||||
|
||||
return s0;
|
||||
}
|
||||
|
||||
function peg$parserotR() {
|
||||
var s0, s1, s2, s3;
|
||||
|
||||
s0 = peg$currPos;
|
||||
if (input.substr(peg$currPos, 4) === peg$c31) {
|
||||
s1 = peg$c31;
|
||||
peg$currPos += 4;
|
||||
} else {
|
||||
s1 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e38); }
|
||||
}
|
||||
if (s1 !== peg$FAILED) {
|
||||
s2 = peg$parsews();
|
||||
s3 = peg$parsenumber();
|
||||
@ -1776,16 +1773,16 @@ function peg$parse(input, options) {
|
||||
return s0;
|
||||
}
|
||||
|
||||
function peg$parsefast() {
|
||||
function peg$parserotL() {
|
||||
var s0, s1, s2, s3;
|
||||
|
||||
s0 = peg$currPos;
|
||||
if (input.substr(peg$currPos, 4) === peg$c32) {
|
||||
s1 = peg$c32;
|
||||
if (input.substr(peg$currPos, 4) === peg$c31) {
|
||||
s1 = peg$c31;
|
||||
peg$currPos += 4;
|
||||
} else {
|
||||
s1 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e39); }
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e38); }
|
||||
}
|
||||
if (s1 !== peg$FAILED) {
|
||||
s2 = peg$parsews();
|
||||
@ -1805,16 +1802,74 @@ function peg$parse(input, options) {
|
||||
return s0;
|
||||
}
|
||||
|
||||
function peg$parserotR() {
|
||||
var s0, s1, s2, s3;
|
||||
|
||||
s0 = peg$currPos;
|
||||
if (input.substr(peg$currPos, 4) === peg$c32) {
|
||||
s1 = peg$c32;
|
||||
peg$currPos += 4;
|
||||
} else {
|
||||
s1 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e39); }
|
||||
}
|
||||
if (s1 !== peg$FAILED) {
|
||||
s2 = peg$parsews();
|
||||
s3 = peg$parsenumber();
|
||||
if (s3 !== peg$FAILED) {
|
||||
peg$savedPos = s0;
|
||||
s0 = peg$f27(s3);
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
}
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
}
|
||||
|
||||
return s0;
|
||||
}
|
||||
|
||||
function peg$parsefast() {
|
||||
var s0, s1, s2, s3;
|
||||
|
||||
s0 = peg$currPos;
|
||||
if (input.substr(peg$currPos, 4) === peg$c33) {
|
||||
s1 = peg$c33;
|
||||
peg$currPos += 4;
|
||||
} else {
|
||||
s1 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e40); }
|
||||
}
|
||||
if (s1 !== peg$FAILED) {
|
||||
s2 = peg$parsews();
|
||||
s3 = peg$parsenumber();
|
||||
if (s3 !== peg$FAILED) {
|
||||
peg$savedPos = s0;
|
||||
s0 = peg$f28(s3);
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
}
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
}
|
||||
|
||||
return s0;
|
||||
}
|
||||
|
||||
function peg$parsescale() {
|
||||
var s0, s1, s2, s3, s4, s5;
|
||||
|
||||
s0 = peg$currPos;
|
||||
if (input.substr(peg$currPos, 5) === peg$c33) {
|
||||
s1 = peg$c33;
|
||||
if (input.substr(peg$currPos, 5) === peg$c34) {
|
||||
s1 = peg$c34;
|
||||
peg$currPos += 5;
|
||||
} else {
|
||||
s1 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e40); }
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e41); }
|
||||
}
|
||||
if (s1 !== peg$FAILED) {
|
||||
s2 = peg$parsews();
|
||||
@ -1834,7 +1889,7 @@ function peg$parse(input, options) {
|
||||
s5 = peg$parsequote();
|
||||
if (s5 !== peg$FAILED) {
|
||||
peg$savedPos = s0;
|
||||
s0 = peg$f27(s4);
|
||||
s0 = peg$f29(s4);
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
@ -1859,12 +1914,12 @@ function peg$parse(input, options) {
|
||||
var s0, s1, s2, s3;
|
||||
|
||||
s0 = peg$currPos;
|
||||
if (input.substr(peg$currPos, 2) === peg$c34) {
|
||||
s1 = peg$c34;
|
||||
if (input.substr(peg$currPos, 2) === peg$c35) {
|
||||
s1 = peg$c35;
|
||||
peg$currPos += 2;
|
||||
} else {
|
||||
s1 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e41); }
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e42); }
|
||||
}
|
||||
if (s1 !== peg$FAILED) {
|
||||
s2 = [];
|
||||
@ -1873,7 +1928,7 @@ function peg$parse(input, options) {
|
||||
peg$currPos++;
|
||||
} else {
|
||||
s3 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e42); }
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e43); }
|
||||
}
|
||||
while (s3 !== peg$FAILED) {
|
||||
s2.push(s3);
|
||||
@ -1882,7 +1937,7 @@ function peg$parse(input, options) {
|
||||
peg$currPos++;
|
||||
} else {
|
||||
s3 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e42); }
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e43); }
|
||||
}
|
||||
}
|
||||
s1 = [s1, s2];
|
||||
@ -1899,12 +1954,12 @@ function peg$parse(input, options) {
|
||||
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;
|
||||
|
||||
s0 = peg$currPos;
|
||||
if (input.substr(peg$currPos, 3) === peg$c35) {
|
||||
s1 = peg$c35;
|
||||
if (input.substr(peg$currPos, 3) === peg$c36) {
|
||||
s1 = peg$c36;
|
||||
peg$currPos += 3;
|
||||
} else {
|
||||
s1 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e43); }
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e44); }
|
||||
}
|
||||
if (s1 !== peg$FAILED) {
|
||||
s2 = peg$parsews();
|
||||
@ -1926,7 +1981,7 @@ function peg$parse(input, options) {
|
||||
s9 = peg$parsemini_or_operator();
|
||||
if (s9 !== peg$FAILED) {
|
||||
peg$savedPos = s7;
|
||||
s7 = peg$f28(s5, s9);
|
||||
s7 = peg$f30(s5, s9);
|
||||
} else {
|
||||
peg$currPos = s7;
|
||||
s7 = peg$FAILED;
|
||||
@ -1943,7 +1998,7 @@ function peg$parse(input, options) {
|
||||
s9 = peg$parsemini_or_operator();
|
||||
if (s9 !== peg$FAILED) {
|
||||
peg$savedPos = s7;
|
||||
s7 = peg$f28(s5, s9);
|
||||
s7 = peg$f30(s5, s9);
|
||||
} else {
|
||||
peg$currPos = s7;
|
||||
s7 = peg$FAILED;
|
||||
@ -1963,7 +2018,7 @@ function peg$parse(input, options) {
|
||||
}
|
||||
if (s8 !== peg$FAILED) {
|
||||
peg$savedPos = s0;
|
||||
s0 = peg$f29(s5, s6);
|
||||
s0 = peg$f31(s5, s6);
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
@ -2009,7 +2064,7 @@ function peg$parse(input, options) {
|
||||
s4 = peg$parsecomment();
|
||||
}
|
||||
peg$savedPos = s0;
|
||||
s0 = peg$f30(s1);
|
||||
s0 = peg$f32(s1);
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
@ -2020,18 +2075,18 @@ function peg$parse(input, options) {
|
||||
if (s1 !== peg$FAILED) {
|
||||
s2 = peg$parsews();
|
||||
if (input.charCodeAt(peg$currPos) === 36) {
|
||||
s3 = peg$c36;
|
||||
s3 = peg$c37;
|
||||
peg$currPos++;
|
||||
} else {
|
||||
s3 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e44); }
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e45); }
|
||||
}
|
||||
if (s3 !== peg$FAILED) {
|
||||
s4 = peg$parsews();
|
||||
s5 = peg$parsemini_or_operator();
|
||||
if (s5 !== peg$FAILED) {
|
||||
peg$savedPos = s0;
|
||||
s0 = peg$f31(s1, s5);
|
||||
s0 = peg$f33(s1, s5);
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
@ -2056,7 +2111,7 @@ function peg$parse(input, options) {
|
||||
s1 = peg$parsemini_or_operator();
|
||||
if (s1 !== peg$FAILED) {
|
||||
peg$savedPos = s0;
|
||||
s1 = peg$f32(s1);
|
||||
s1 = peg$f34(s1);
|
||||
}
|
||||
s0 = s1;
|
||||
if (s0 === peg$FAILED) {
|
||||
@ -2089,7 +2144,7 @@ function peg$parse(input, options) {
|
||||
if (s2 !== peg$FAILED) {
|
||||
s3 = peg$parsews();
|
||||
peg$savedPos = s0;
|
||||
s0 = peg$f33(s2);
|
||||
s0 = peg$f35(s2);
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
@ -2102,19 +2157,19 @@ function peg$parse(input, options) {
|
||||
var s0, s1, s2, s3;
|
||||
|
||||
s0 = peg$currPos;
|
||||
if (input.substr(peg$currPos, 6) === peg$c37) {
|
||||
s1 = peg$c37;
|
||||
if (input.substr(peg$currPos, 6) === peg$c38) {
|
||||
s1 = peg$c38;
|
||||
peg$currPos += 6;
|
||||
} else {
|
||||
s1 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e45); }
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e46); }
|
||||
}
|
||||
if (s1 !== peg$FAILED) {
|
||||
s2 = peg$parsews();
|
||||
s3 = peg$parsenumber();
|
||||
if (s3 !== peg$FAILED) {
|
||||
peg$savedPos = s0;
|
||||
s0 = peg$f34(s3);
|
||||
s0 = peg$f36(s3);
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
@ -2131,19 +2186,19 @@ function peg$parse(input, options) {
|
||||
var s0, s1, s2, s3;
|
||||
|
||||
s0 = peg$currPos;
|
||||
if (input.substr(peg$currPos, 6) === peg$c38) {
|
||||
s1 = peg$c38;
|
||||
if (input.substr(peg$currPos, 6) === peg$c39) {
|
||||
s1 = peg$c39;
|
||||
peg$currPos += 6;
|
||||
} else {
|
||||
s1 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e46); }
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e47); }
|
||||
}
|
||||
if (s1 !== peg$FAILED) {
|
||||
s2 = peg$parsews();
|
||||
s3 = peg$parsenumber();
|
||||
if (s3 !== peg$FAILED) {
|
||||
peg$savedPos = s0;
|
||||
s0 = peg$f35(s3);
|
||||
s0 = peg$f37(s3);
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
@ -2160,16 +2215,16 @@ function peg$parse(input, options) {
|
||||
var s0, s1;
|
||||
|
||||
s0 = peg$currPos;
|
||||
if (input.substr(peg$currPos, 4) === peg$c39) {
|
||||
s1 = peg$c39;
|
||||
if (input.substr(peg$currPos, 4) === peg$c40) {
|
||||
s1 = peg$c40;
|
||||
peg$currPos += 4;
|
||||
} else {
|
||||
s1 = peg$FAILED;
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e47); }
|
||||
if (peg$silentFails === 0) { peg$fail(peg$e48); }
|
||||
}
|
||||
if (s1 !== peg$FAILED) {
|
||||
peg$savedPos = s0;
|
||||
s1 = peg$f36();
|
||||
s1 = peg$f38();
|
||||
}
|
||||
s0 = s1;
|
||||
|
||||
|
||||
@ -79,6 +79,9 @@ frac
|
||||
int
|
||||
= zero / (digit1_9 DIGIT*)
|
||||
|
||||
intneg
|
||||
= minus? int { return parseInt(text()); }
|
||||
|
||||
minus
|
||||
= "-"
|
||||
|
||||
@ -123,7 +126,7 @@ slice = step / sub_cycle / polymeter / slow_sequence
|
||||
|
||||
// slice modifier affects the timing/size of a slice (e.g. [a b c]@3)
|
||||
// at this point, we assume we can represent them as regular sequence operators
|
||||
slice_op = op_weight / op_bjorklund / op_slow / op_fast / op_replicate / op_degrade / op_tail
|
||||
slice_op = op_weight / op_bjorklund / op_slow / op_fast / op_replicate / op_degrade / op_tail / op_range
|
||||
|
||||
op_weight = "@" a:number
|
||||
{ return x => x.options_['weight'] = a }
|
||||
@ -146,6 +149,9 @@ op_degrade = "?"a:number?
|
||||
op_tail = ":" s:slice
|
||||
{ return x => x.options_['ops'].push({ type_: "tail", arguments_ :{ element:s } }) }
|
||||
|
||||
op_range = ".." s:slice
|
||||
{ return x => x.options_['ops'].push({ type_: "range", arguments_ :{ element:s } }) }
|
||||
|
||||
// a slice with an modifier applied i.e [bd@4 sd@3]@2 hh]
|
||||
slice_with_ops = s:slice ops:slice_op*
|
||||
{ const result = new ElementStub(s, {ops: [], weight: 1, reps: 1});
|
||||
|
||||
@ -45,6 +45,17 @@ const applyOptions = (parent, enter) => (pat, i) => {
|
||||
pat = pat.fmap((a) => (b) => Array.isArray(a) ? [...a, b] : [a, b]).appLeft(friend);
|
||||
break;
|
||||
}
|
||||
case 'range': {
|
||||
const friend = enter(op.arguments_.element);
|
||||
pat = strudel.reify(pat);
|
||||
const arrayRange = (start, stop, step = 1) =>
|
||||
Array.from({ length: Math.abs(stop - start) / step + 1 }, (value, index) =>
|
||||
start < stop ? start + index * step : start - index * step,
|
||||
);
|
||||
let range = (apat, bpat) => apat.squeezeBind((a) => bpat.bind((b) => strudel.fastcat(...arrayRange(a, b))));
|
||||
pat = range(pat, friend);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
console.warn(`operator "${op.type_}" not implemented`);
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel.cycles/mini",
|
||||
"version": "0.8.2",
|
||||
"version": "0.9.0",
|
||||
"description": "Mini notation for strudel",
|
||||
"main": "index.mjs",
|
||||
"type": "module",
|
||||
|
||||
@ -184,6 +184,12 @@ describe('mini', () => {
|
||||
it('supports lists', () => {
|
||||
expect(minV('a:b c:d:[e:f] g')).toEqual([['a', 'b'], ['c', 'd', ['e', 'f']], 'g']);
|
||||
});
|
||||
it('supports ranges', () => {
|
||||
expect(minV('0 .. 4')).toEqual([0, 1, 2, 3, 4]);
|
||||
});
|
||||
it('supports patterned ranges', () => {
|
||||
expect(minS('[<0 1> .. <2 4>]*2')).toEqual(minS('[0 1 2] [1 2 3 4]'));
|
||||
});
|
||||
});
|
||||
|
||||
describe('getLeafLocation', () => {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel.cycles/osc",
|
||||
"version": "0.8.0",
|
||||
"version": "0.9.0",
|
||||
"description": "OSC messaging for strudel",
|
||||
"main": "osc.mjs",
|
||||
"publishConfig": {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel.cycles/react",
|
||||
"version": "0.8.0",
|
||||
"version": "0.9.0",
|
||||
"description": "React components for strudel",
|
||||
"main": "src/index.js",
|
||||
"publishConfig": {
|
||||
|
||||
@ -15,10 +15,11 @@ import {
|
||||
updateMiniLocations,
|
||||
} from '@strudel/codemirror';
|
||||
import './style.css';
|
||||
import { sliderPlugin } from '@strudel/codemirror/slider.mjs';
|
||||
|
||||
export { flash, highlightMiniLocations, updateMiniLocations };
|
||||
|
||||
const staticExtensions = [javascript(), flashField, highlightExtension];
|
||||
const staticExtensions = [javascript(), flashField, highlightExtension, sliderPlugin];
|
||||
|
||||
export default function CodeMirror({
|
||||
value,
|
||||
|
||||
13
packages/react/src/hooks/useWidgets.mjs
Normal file
13
packages/react/src/hooks/useWidgets.mjs
Normal file
@ -0,0 +1,13 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { updateWidgets } from '@strudel/codemirror';
|
||||
|
||||
// i know this is ugly.. in the future, repl needs to run without react
|
||||
export function useWidgets(view) {
|
||||
const [widgets, setWidgets] = useState([]);
|
||||
useEffect(() => {
|
||||
if (view) {
|
||||
updateWidgets(view, widgets);
|
||||
}
|
||||
}, [view, widgets]);
|
||||
return { widgets, setWidgets };
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel.cycles/serial",
|
||||
"version": "0.8.0",
|
||||
"version": "0.9.0",
|
||||
"description": "Webserial API for strudel",
|
||||
"main": "serial.mjs",
|
||||
"publishConfig": {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel.cycles/soundfonts",
|
||||
"version": "0.8.2",
|
||||
"version": "0.9.0",
|
||||
"description": "Soundsfont support for strudel",
|
||||
"main": "index.mjs",
|
||||
"publishConfig": {
|
||||
|
||||
79
packages/superdough/dspworklet.mjs
Normal file
79
packages/superdough/dspworklet.mjs
Normal file
@ -0,0 +1,79 @@
|
||||
import { getAudioContext } from './superdough.mjs';
|
||||
|
||||
let worklet;
|
||||
export async function dspWorklet(ac, code) {
|
||||
const name = `dsp-worklet-${Date.now()}`;
|
||||
const workletCode = `${code}
|
||||
let __q = []; // trigger queue
|
||||
class MyProcessor extends AudioWorkletProcessor {
|
||||
constructor() {
|
||||
super();
|
||||
this.t = 0;
|
||||
this.stopped = false;
|
||||
this.port.onmessage = (e) => {
|
||||
if(e.data==='stop') {
|
||||
this.stopped = true;
|
||||
} else if(e.data?.dough) {
|
||||
__q.push(e.data)
|
||||
} else {
|
||||
msg?.(e.data)
|
||||
}
|
||||
};
|
||||
}
|
||||
process(inputs, outputs, parameters) {
|
||||
const output = outputs[0];
|
||||
if(__q.length) {
|
||||
for(let i=0;i<__q.length;++i) {
|
||||
const deadline = __q[i].time-currentTime;
|
||||
if(deadline<=0) {
|
||||
trigger(__q[i].dough)
|
||||
__q.splice(i,1)
|
||||
}
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < output[0].length; i++) {
|
||||
const out = dsp(this.t / sampleRate);
|
||||
output.forEach((channel) => {
|
||||
channel[i] = out;
|
||||
});
|
||||
this.t++;
|
||||
}
|
||||
return !this.stopped;
|
||||
}
|
||||
}
|
||||
registerProcessor('${name}', MyProcessor);
|
||||
`;
|
||||
const base64String = btoa(workletCode);
|
||||
const dataURL = `data:text/javascript;base64,${base64String}`;
|
||||
await ac.audioWorklet.addModule(dataURL);
|
||||
const node = new AudioWorkletNode(ac, name);
|
||||
const stop = () => node.port.postMessage('stop');
|
||||
return { node, stop };
|
||||
}
|
||||
const stop = () => {
|
||||
if (worklet) {
|
||||
worklet?.stop();
|
||||
worklet?.node?.disconnect();
|
||||
}
|
||||
};
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
window.addEventListener('message', (e) => {
|
||||
if (e.data === 'strudel-stop') {
|
||||
stop();
|
||||
} else if (e.data?.dough) {
|
||||
worklet?.node.port.postMessage(e.data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export const dough = async (code) => {
|
||||
const ac = getAudioContext();
|
||||
stop();
|
||||
worklet = await dspWorklet(ac, code);
|
||||
worklet.node.connect(ac.destination);
|
||||
};
|
||||
|
||||
export function doughTrigger(t, hap, currentTime, duration, cps) {
|
||||
window.postMessage({ time: t, dough: hap.value, currentTime, duration, cps });
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
import { getAudioContext } from './superdough.mjs';
|
||||
import { clamp } from './util.mjs';
|
||||
|
||||
export function gainNode(value) {
|
||||
const node = getAudioContext().createGain();
|
||||
@ -66,10 +67,81 @@ export const getADSR = (attack, decay, sustain, release, velocity, begin, end) =
|
||||
return gainNode;
|
||||
};
|
||||
|
||||
export const getFilter = (type, frequency, Q) => {
|
||||
const filter = getAudioContext().createBiquadFilter();
|
||||
filter.type = type;
|
||||
filter.frequency.value = frequency;
|
||||
filter.Q.value = Q;
|
||||
return filter;
|
||||
export const getParamADSR = (param, attack, decay, sustain, release, min, max, begin, end) => {
|
||||
const range = max - min;
|
||||
const peak = min + range;
|
||||
const sustainLevel = min + sustain * range;
|
||||
param.setValueAtTime(min, begin);
|
||||
param.linearRampToValueAtTime(peak, begin + attack);
|
||||
param.linearRampToValueAtTime(sustainLevel, begin + attack + decay);
|
||||
param.setValueAtTime(sustainLevel, end);
|
||||
param.linearRampToValueAtTime(min, end + Math.max(release, 0.1));
|
||||
};
|
||||
|
||||
export function getCompressor(ac, threshold, ratio, knee, attack, release) {
|
||||
const options = {
|
||||
threshold: threshold ?? -3,
|
||||
ratio: ratio ?? 10,
|
||||
knee: knee ?? 10,
|
||||
attack: attack ?? 0.005,
|
||||
release: release ?? 0.05,
|
||||
};
|
||||
return new DynamicsCompressorNode(ac, options);
|
||||
}
|
||||
|
||||
export function createFilter(
|
||||
context,
|
||||
type,
|
||||
frequency,
|
||||
Q,
|
||||
attack,
|
||||
decay,
|
||||
sustain,
|
||||
release,
|
||||
fenv,
|
||||
start,
|
||||
end,
|
||||
fanchor = 0.5,
|
||||
) {
|
||||
const filter = context.createBiquadFilter();
|
||||
filter.type = type;
|
||||
filter.Q.value = Q;
|
||||
filter.frequency.value = frequency;
|
||||
|
||||
// Apply ADSR to filter frequency
|
||||
if (!isNaN(fenv) && fenv !== 0) {
|
||||
const offset = fenv * fanchor;
|
||||
|
||||
const min = clamp(2 ** -offset * frequency, 0, 20000);
|
||||
const max = clamp(2 ** (fenv - offset) * frequency, 0, 20000);
|
||||
|
||||
// console.log('min', min, 'max', max);
|
||||
|
||||
getParamADSR(filter.frequency, attack, decay, sustain, release, min, max, start, end);
|
||||
return filter;
|
||||
}
|
||||
|
||||
return filter;
|
||||
}
|
||||
|
||||
// stays 1 until .5, then fades out
|
||||
let wetfade = (d) => (d < 0.5 ? 1 : 1 - (d - 0.5) / 0.5);
|
||||
|
||||
// mix together dry and wet nodes. 0 = only dry 1 = only wet
|
||||
// still not too sure about how this could be used more generally...
|
||||
export function drywet(dry, wet, wetAmount = 0) {
|
||||
const ac = getAudioContext();
|
||||
if (!wetAmount) {
|
||||
return dry;
|
||||
}
|
||||
let dry_gain = ac.createGain();
|
||||
let wet_gain = ac.createGain();
|
||||
dry.connect(dry_gain);
|
||||
wet.connect(wet_gain);
|
||||
dry_gain.gain.value = wetfade(wetAmount);
|
||||
wet_gain.gain.value = wetfade(1 - wetAmount);
|
||||
let mix = ac.createGain();
|
||||
dry_gain.connect(mix);
|
||||
wet_gain.connect(mix);
|
||||
return mix;
|
||||
}
|
||||
|
||||
@ -10,3 +10,4 @@ export * from './helpers.mjs';
|
||||
export * from './synth.mjs';
|
||||
export * from './zzfx.mjs';
|
||||
export * from './logger.mjs';
|
||||
export * from './dspworklet.mjs';
|
||||
|
||||
63
packages/superdough/noise.mjs
Normal file
63
packages/superdough/noise.mjs
Normal file
@ -0,0 +1,63 @@
|
||||
import { drywet } from './helpers.mjs';
|
||||
import { getAudioContext } from './superdough.mjs';
|
||||
|
||||
let noiseCache = {};
|
||||
|
||||
// lazy generates noise buffers and keeps them forever
|
||||
function getNoiseBuffer(type) {
|
||||
const ac = getAudioContext();
|
||||
if (noiseCache[type]) {
|
||||
return noiseCache[type];
|
||||
}
|
||||
const bufferSize = 2 * ac.sampleRate;
|
||||
const noiseBuffer = ac.createBuffer(1, bufferSize, ac.sampleRate);
|
||||
const output = noiseBuffer.getChannelData(0);
|
||||
let lastOut = 0;
|
||||
let b0, b1, b2, b3, b4, b5, b6;
|
||||
b0 = b1 = b2 = b3 = b4 = b5 = b6 = 0.0;
|
||||
|
||||
for (let i = 0; i < bufferSize; i++) {
|
||||
if (type === 'white') {
|
||||
output[i] = Math.random() * 2 - 1;
|
||||
} else if (type === 'brown') {
|
||||
let white = Math.random() * 2 - 1;
|
||||
output[i] = (lastOut + 0.02 * white) / 1.02;
|
||||
lastOut = output[i];
|
||||
} else if (type === 'pink') {
|
||||
let white = Math.random() * 2 - 1;
|
||||
b0 = 0.99886 * b0 + white * 0.0555179;
|
||||
b1 = 0.99332 * b1 + white * 0.0750759;
|
||||
b2 = 0.969 * b2 + white * 0.153852;
|
||||
b3 = 0.8665 * b3 + white * 0.3104856;
|
||||
b4 = 0.55 * b4 + white * 0.5329522;
|
||||
b5 = -0.7616 * b5 - white * 0.016898;
|
||||
output[i] = b0 + b1 + b2 + b3 + b4 + b5 + b6 + white * 0.5362;
|
||||
output[i] *= 0.11;
|
||||
b6 = white * 0.115926;
|
||||
}
|
||||
}
|
||||
noiseCache[type] = noiseBuffer;
|
||||
return noiseBuffer;
|
||||
}
|
||||
|
||||
// expects one of noises as type
|
||||
export function getNoiseOscillator(type = 'white', t) {
|
||||
const ac = getAudioContext();
|
||||
const o = ac.createBufferSource();
|
||||
o.buffer = getNoiseBuffer(type);
|
||||
o.loop = true;
|
||||
o.start(t);
|
||||
return {
|
||||
node: o,
|
||||
stop: (time) => o.stop(time),
|
||||
};
|
||||
}
|
||||
|
||||
export function getNoiseMix(inputNode, wet, t) {
|
||||
const noiseOscillator = getNoiseOscillator('pink', t);
|
||||
const noiseMix = drywet(inputNode, noiseOscillator.node, wet);
|
||||
return {
|
||||
node: noiseMix,
|
||||
stop: (time) => noiseOscillator?.stop(time),
|
||||
};
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "superdough",
|
||||
"version": "0.9.6",
|
||||
"version": "0.9.10",
|
||||
"description": "simple web audio synth and sampler intended for live coding. inspired by superdirt and webdirt.",
|
||||
"main": "index.mjs",
|
||||
"type": "module",
|
||||
|
||||
@ -1,23 +1,47 @@
|
||||
import reverbGen from './reverbGen.mjs';
|
||||
|
||||
if (typeof AudioContext !== 'undefined') {
|
||||
AudioContext.prototype.impulseResponse = function (duration, channels = 1) {
|
||||
const length = this.sampleRate * duration;
|
||||
const impulse = this.createBuffer(channels, length, this.sampleRate);
|
||||
const IR = impulse.getChannelData(0);
|
||||
for (let i = 0; i < length; i++) IR[i] = (2 * Math.random() - 1) * Math.pow(1 - i / length, duration);
|
||||
return impulse;
|
||||
AudioContext.prototype.adjustLength = function (duration, buffer) {
|
||||
const newLength = buffer.sampleRate * duration;
|
||||
const newBuffer = this.createBuffer(buffer.numberOfChannels, buffer.length, buffer.sampleRate);
|
||||
for (let channel = 0; channel < buffer.numberOfChannels; channel++) {
|
||||
let oldData = buffer.getChannelData(channel);
|
||||
let newData = newBuffer.getChannelData(channel);
|
||||
|
||||
for (let i = 0; i < newLength; i++) {
|
||||
newData[i] = oldData[i] || 0;
|
||||
}
|
||||
}
|
||||
return newBuffer;
|
||||
};
|
||||
|
||||
AudioContext.prototype.createReverb = function (duration) {
|
||||
AudioContext.prototype.createReverb = function (duration, fade, lp, dim, ir) {
|
||||
const convolver = this.createConvolver();
|
||||
convolver.setDuration = (d) => {
|
||||
convolver.buffer = this.impulseResponse(d);
|
||||
convolver.duration = duration;
|
||||
return convolver;
|
||||
convolver.generate = (d = 2, fade = 0.1, lp = 15000, dim = 1000, ir) => {
|
||||
convolver.duration = d;
|
||||
convolver.fade = fade;
|
||||
convolver.lp = lp;
|
||||
convolver.dim = dim;
|
||||
convolver.ir = ir;
|
||||
if (ir) {
|
||||
convolver.buffer = this.adjustLength(d, ir);
|
||||
} else {
|
||||
reverbGen.generateReverb(
|
||||
{
|
||||
audioContext: this,
|
||||
numChannels: 2,
|
||||
decayTime: d,
|
||||
fadeInTime: fade,
|
||||
lpFreqStart: lp,
|
||||
lpFreqEnd: dim,
|
||||
},
|
||||
(buffer) => {
|
||||
convolver.buffer = buffer;
|
||||
},
|
||||
);
|
||||
}
|
||||
};
|
||||
convolver.setDuration(duration);
|
||||
convolver.generate(duration, fade, lp, dim, ir);
|
||||
return convolver;
|
||||
};
|
||||
}
|
||||
|
||||
// TODO: make the reverb more exciting
|
||||
// check out https://blog.gskinner.com/archives/2019/02/reverb-web-audio-api.html
|
||||
|
||||
130
packages/superdough/reverbGen.mjs
Normal file
130
packages/superdough/reverbGen.mjs
Normal file
@ -0,0 +1,130 @@
|
||||
// Copyright 2014 Alan deLespinasse
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
var reverbGen = {};
|
||||
|
||||
/** Generates a reverb impulse response.
|
||||
|
||||
@param {!Object} params TODO: Document the properties.
|
||||
@param {!function(!AudioBuffer)} callback Function to call when
|
||||
the impulse response has been generated. The impulse response
|
||||
is passed to this function as its parameter. May be called
|
||||
immediately within the current execution context, or later. */
|
||||
reverbGen.generateReverb = function (params, callback) {
|
||||
var audioContext = params.audioContext || new AudioContext();
|
||||
var sampleRate = audioContext.sampleRate;
|
||||
var numChannels = params.numChannels || 2;
|
||||
// params.decayTime is the -60dB fade time. We let it go 50% longer to get to -90dB.
|
||||
var totalTime = params.decayTime * 1.5;
|
||||
var decaySampleFrames = Math.round(params.decayTime * sampleRate);
|
||||
var numSampleFrames = Math.round(totalTime * sampleRate);
|
||||
var fadeInSampleFrames = Math.round((params.fadeInTime || 0) * sampleRate);
|
||||
// 60dB is a factor of 1 million in power, or 1000 in amplitude.
|
||||
var decayBase = Math.pow(1 / 1000, 1 / decaySampleFrames);
|
||||
var reverbIR = audioContext.createBuffer(numChannels, numSampleFrames, sampleRate);
|
||||
for (var i = 0; i < numChannels; i++) {
|
||||
var chan = reverbIR.getChannelData(i);
|
||||
for (var j = 0; j < numSampleFrames; j++) {
|
||||
chan[j] = randomSample() * Math.pow(decayBase, j);
|
||||
}
|
||||
for (var j = 0; j < fadeInSampleFrames; j++) {
|
||||
chan[j] *= j / fadeInSampleFrames;
|
||||
}
|
||||
}
|
||||
|
||||
applyGradualLowpass(reverbIR, params.lpFreqStart || 0, params.lpFreqEnd || 0, params.decayTime, callback);
|
||||
};
|
||||
|
||||
/** Creates a canvas element showing a graph of the given data.
|
||||
|
||||
|
||||
@param {!Float32Array} data An array of numbers, or a Float32Array.
|
||||
@param {number} width Width in pixels of the canvas.
|
||||
@param {number} height Height in pixels of the canvas.
|
||||
@param {number} min Minimum value of data for the graph (lower edge).
|
||||
@param {number} max Maximum value of data in the graph (upper edge).
|
||||
@return {!CanvasElement} The generated canvas element. */
|
||||
reverbGen.generateGraph = function (data, width, height, min, max) {
|
||||
var canvas = document.createElement('canvas');
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
var gc = canvas.getContext('2d');
|
||||
gc.fillStyle = '#000';
|
||||
gc.fillRect(0, 0, canvas.width, canvas.height);
|
||||
gc.fillStyle = '#fff';
|
||||
var xscale = width / data.length;
|
||||
var yscale = height / (max - min);
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
gc.fillRect(i * xscale, height - (data[i] - min) * yscale, 1, 1);
|
||||
}
|
||||
return canvas;
|
||||
};
|
||||
|
||||
/** Applies a constantly changing lowpass filter to the given sound.
|
||||
|
||||
@private
|
||||
@param {!AudioBuffer} input
|
||||
@param {number} lpFreqStart
|
||||
@param {number} lpFreqEnd
|
||||
@param {number} lpFreqEndAt
|
||||
@param {!function(!AudioBuffer)} callback May be called
|
||||
immediately within the current execution context, or later.*/
|
||||
var applyGradualLowpass = function (input, lpFreqStart, lpFreqEnd, lpFreqEndAt, callback) {
|
||||
if (lpFreqStart == 0) {
|
||||
callback(input);
|
||||
return;
|
||||
}
|
||||
var channelData = getAllChannelData(input);
|
||||
var context = new OfflineAudioContext(input.numberOfChannels, channelData[0].length, input.sampleRate);
|
||||
var player = context.createBufferSource();
|
||||
player.buffer = input;
|
||||
var filter = context.createBiquadFilter();
|
||||
|
||||
lpFreqStart = Math.min(lpFreqStart, input.sampleRate / 2);
|
||||
lpFreqEnd = Math.min(lpFreqEnd, input.sampleRate / 2);
|
||||
|
||||
filter.type = 'lowpass';
|
||||
filter.Q.value = 0.0001;
|
||||
filter.frequency.setValueAtTime(lpFreqStart, 0);
|
||||
filter.frequency.linearRampToValueAtTime(lpFreqEnd, lpFreqEndAt);
|
||||
|
||||
player.connect(filter);
|
||||
filter.connect(context.destination);
|
||||
player.start();
|
||||
context.oncomplete = function (event) {
|
||||
callback(event.renderedBuffer);
|
||||
};
|
||||
context.startRendering();
|
||||
|
||||
window.filterNode = filter;
|
||||
};
|
||||
|
||||
/** @private
|
||||
@param {!AudioBuffer} buffer
|
||||
@return {!Array.<!Float32Array>} An array containing the Float32Array of each channel's samples. */
|
||||
var getAllChannelData = function (buffer) {
|
||||
var channels = [];
|
||||
for (var i = 0; i < buffer.numberOfChannels; i++) {
|
||||
channels[i] = buffer.getChannelData(i);
|
||||
}
|
||||
return channels;
|
||||
};
|
||||
|
||||
/** @private
|
||||
@return {number} A random number from -1 to 1. */
|
||||
var randomSample = function () {
|
||||
return Math.random() * 2 - 1;
|
||||
};
|
||||
|
||||
export default reverbGen;
|
||||
@ -64,6 +64,7 @@ export const getSampleBufferSource = async (s, n, note, speed, freq, bank, resol
|
||||
|
||||
export const loadBuffer = (url, ac, s, n = 0) => {
|
||||
const label = s ? `sound "${s}:${n}"` : 'sample';
|
||||
url = url.replace('#', '%23');
|
||||
if (!loadCache[url]) {
|
||||
logger(`[sampler] load ${label}..`, 'load-sample', { url });
|
||||
const timestamp = Date.now();
|
||||
@ -196,7 +197,7 @@ export const samples = async (sampleMap, baseUrl = sampleMap._base || '', option
|
||||
const cutGroups = [];
|
||||
|
||||
export async function onTriggerSample(t, value, onended, bank, resolveUrl) {
|
||||
const {
|
||||
let {
|
||||
s,
|
||||
freq,
|
||||
unit,
|
||||
@ -207,7 +208,9 @@ export async function onTriggerSample(t, value, onended, bank, resolveUrl) {
|
||||
n = 0,
|
||||
note,
|
||||
speed = 1, // sample playback speed
|
||||
loopBegin = 0,
|
||||
begin = 0,
|
||||
loopEnd = 1,
|
||||
end = 1,
|
||||
} = value;
|
||||
// load sample
|
||||
@ -215,6 +218,7 @@ export async function onTriggerSample(t, value, onended, bank, resolveUrl) {
|
||||
// no playback
|
||||
return;
|
||||
}
|
||||
loop = s.startsWith('wt_') ? 1 : value.loop;
|
||||
const ac = getAudioContext();
|
||||
// destructure adsr here, because the default should be different for synths and samples
|
||||
const { attack = 0.001, decay = 0.001, sustain = 1, release = 0.001 } = value;
|
||||
@ -242,19 +246,12 @@ export async function onTriggerSample(t, value, onended, bank, resolveUrl) {
|
||||
// rather than the current playback rate, so even if the sound is playing at twice its normal speed,
|
||||
// the midway point through a 10-second audio buffer is still 5."
|
||||
const offset = begin * bufferSource.buffer.duration;
|
||||
bufferSource.start(time, offset);
|
||||
const bufferDuration = bufferSource.buffer.duration / bufferSource.playbackRate.value;
|
||||
/*if (loop) {
|
||||
// TODO: idea for loopBegin / loopEnd
|
||||
// if one of [loopBegin,loopEnd] is <= 1, interpret it as normlized
|
||||
// if [loopBegin,loopEnd] is bigger >= 1, interpret it as sample number
|
||||
// this will simplify perfectly looping things, while still keeping the normalized option
|
||||
// the only drawback is that looping between samples 0 and 1 is not possible (which is not real use case)
|
||||
if (loop) {
|
||||
bufferSource.loop = true;
|
||||
bufferSource.loopStart = offset;
|
||||
bufferSource.loopEnd = offset + duration;
|
||||
duration = loop * duration;
|
||||
}*/
|
||||
bufferSource.loopStart = loopBegin * bufferSource.buffer.duration - offset;
|
||||
bufferSource.loopEnd = loopEnd * bufferSource.buffer.duration - offset;
|
||||
}
|
||||
bufferSource.start(time, offset);
|
||||
const { node: envelope, stop: releaseEnvelope } = getEnvelope(attack, decay, sustain, release, 1, t);
|
||||
bufferSource.connect(envelope);
|
||||
const out = ac.createGain(); // we need a separate gain for the cutgroups because firefox...
|
||||
@ -265,9 +262,10 @@ export async function onTriggerSample(t, value, onended, bank, resolveUrl) {
|
||||
out.disconnect();
|
||||
onended();
|
||||
};
|
||||
const stop = (endTime, playWholeBuffer = clip === undefined) => {
|
||||
const stop = (endTime, playWholeBuffer = clip === undefined && loop === undefined) => {
|
||||
let releaseTime = endTime;
|
||||
if (playWholeBuffer) {
|
||||
const bufferDuration = bufferSource.buffer.duration / bufferSource.playbackRate.value;
|
||||
releaseTime = t + (end - begin) * bufferDuration;
|
||||
}
|
||||
bufferSource.stop(releaseTime + release);
|
||||
|
||||
@ -9,17 +9,21 @@ import './reverb.mjs';
|
||||
import './vowel.mjs';
|
||||
import { clamp } from './util.mjs';
|
||||
import workletsUrl from './worklets.mjs?url';
|
||||
import { getFilter, gainNode } from './helpers.mjs';
|
||||
import { createFilter, gainNode, getCompressor } from './helpers.mjs';
|
||||
import { map } from 'nanostores';
|
||||
import { logger } from './logger.mjs';
|
||||
import { loadBuffer } from './sampler.mjs';
|
||||
|
||||
export const soundMap = map();
|
||||
|
||||
export function registerSound(key, onTrigger, data = {}) {
|
||||
soundMap.setKey(key, { onTrigger, data });
|
||||
}
|
||||
|
||||
export function getSound(s) {
|
||||
return soundMap.get()[s];
|
||||
}
|
||||
|
||||
export const resetLoadedSounds = () => soundMap.set({});
|
||||
|
||||
let audioContext;
|
||||
@ -46,6 +50,7 @@ export const panic = () => {
|
||||
};
|
||||
|
||||
let workletsLoading;
|
||||
|
||||
function loadWorklets() {
|
||||
if (workletsLoading) {
|
||||
return workletsLoading;
|
||||
@ -89,6 +94,7 @@ export async function initAudioOnFirstClick(options) {
|
||||
|
||||
let delays = {};
|
||||
const maxfeedback = 0.98;
|
||||
|
||||
function getDelay(orbit, delaytime, delayfeedback, t) {
|
||||
if (delayfeedback > maxfeedback) {
|
||||
//logger(`delayfeedback was clamped to ${maxfeedback} to save your ears`);
|
||||
@ -107,21 +113,36 @@ function getDelay(orbit, delaytime, delayfeedback, t) {
|
||||
}
|
||||
|
||||
let reverbs = {};
|
||||
function getReverb(orbit, duration = 2) {
|
||||
|
||||
let hasChanged = (now, before) => now !== undefined && now !== before;
|
||||
|
||||
function getReverb(orbit, duration, fade, lp, dim, ir) {
|
||||
// If no reverb has been created for a given orbit, create one
|
||||
if (!reverbs[orbit]) {
|
||||
const ac = getAudioContext();
|
||||
const reverb = ac.createReverb(duration);
|
||||
const reverb = ac.createReverb(duration, fade, lp, dim, ir);
|
||||
reverb.connect(getDestination());
|
||||
reverbs[orbit] = reverb;
|
||||
}
|
||||
if (reverbs[orbit].duration !== duration) {
|
||||
reverbs[orbit] = reverbs[orbit].setDuration(duration);
|
||||
reverbs[orbit].duration = duration;
|
||||
if (
|
||||
hasChanged(duration, reverbs[orbit].duration) ||
|
||||
hasChanged(fade, reverbs[orbit].fade) ||
|
||||
hasChanged(lp, reverbs[orbit].lp) ||
|
||||
hasChanged(dim, reverbs[orbit].dim) ||
|
||||
reverbs[orbit].ir !== ir
|
||||
) {
|
||||
// only regenerate when something has changed
|
||||
// avoids endless regeneration on things like
|
||||
// stack(s("a"), s("b").rsize(8)).room(.5)
|
||||
// this only works when args may stay undefined until here
|
||||
// setting default values breaks this
|
||||
reverbs[orbit].generate(duration, fade, lp, dim, ir);
|
||||
}
|
||||
return reverbs[orbit];
|
||||
}
|
||||
|
||||
export let analyser, analyserData /* s = {} */;
|
||||
|
||||
export function getAnalyser(/* orbit, */ fftSize = 2048) {
|
||||
if (!analyser /*s [orbit] */) {
|
||||
const analyserNode = getAudioContext().createAnalyser();
|
||||
@ -177,14 +198,33 @@ export const superdough = async (value, deadline, hapDuration) => {
|
||||
bank,
|
||||
source,
|
||||
gain = 0.8,
|
||||
postgain = 1,
|
||||
// filters
|
||||
ftype = '12db',
|
||||
fanchor = 0.5,
|
||||
// low pass
|
||||
cutoff,
|
||||
lpenv,
|
||||
lpattack = 0.01,
|
||||
lpdecay = 0.01,
|
||||
lpsustain = 1,
|
||||
lprelease = 0.01,
|
||||
resonance = 1,
|
||||
// high pass
|
||||
hpenv,
|
||||
hcutoff,
|
||||
hpattack = 0.01,
|
||||
hpdecay = 0.01,
|
||||
hpsustain = 1,
|
||||
hprelease = 0.01,
|
||||
hresonance = 1,
|
||||
// band pass
|
||||
bpenv,
|
||||
bandf,
|
||||
bpattack = 0.01,
|
||||
bpdecay = 0.01,
|
||||
bpsustain = 1,
|
||||
bprelease = 0.01,
|
||||
bandq = 1,
|
||||
//
|
||||
coarse,
|
||||
@ -197,10 +237,20 @@ export const superdough = async (value, deadline, hapDuration) => {
|
||||
delaytime = 0.25,
|
||||
orbit = 1,
|
||||
room,
|
||||
size = 2,
|
||||
roomfade,
|
||||
roomlp,
|
||||
roomdim,
|
||||
roomsize,
|
||||
ir,
|
||||
i = 0,
|
||||
velocity = 1,
|
||||
analyze, // analyser wet
|
||||
fft = 8, // fftSize 0 - 10
|
||||
compressor: compressorThreshold,
|
||||
compressorRatio,
|
||||
compressorKnee,
|
||||
compressorAttack,
|
||||
compressorRelease,
|
||||
} = value;
|
||||
gain *= velocity; // legacy fix for velocity
|
||||
let toDisconnect = []; // audio nodes that will be disconnected when the source has ended
|
||||
@ -229,6 +279,7 @@ export const superdough = async (value, deadline, hapDuration) => {
|
||||
// this can be used for things like speed(0) in the sampler
|
||||
return;
|
||||
}
|
||||
|
||||
if (ac.currentTime > t) {
|
||||
logger('[webaudio] skip hap: still loading', ac.currentTime - t);
|
||||
return;
|
||||
@ -239,17 +290,87 @@ export const superdough = async (value, deadline, hapDuration) => {
|
||||
// gain stage
|
||||
chain.push(gainNode(gain));
|
||||
|
||||
// filters
|
||||
cutoff !== undefined && chain.push(getFilter('lowpass', cutoff, resonance));
|
||||
hcutoff !== undefined && chain.push(getFilter('highpass', hcutoff, hresonance));
|
||||
bandf !== undefined && chain.push(getFilter('bandpass', bandf, bandq));
|
||||
vowel !== undefined && chain.push(ac.createVowelFilter(vowel));
|
||||
if (cutoff !== undefined) {
|
||||
let lp = () =>
|
||||
createFilter(
|
||||
ac,
|
||||
'lowpass',
|
||||
cutoff,
|
||||
resonance,
|
||||
lpattack,
|
||||
lpdecay,
|
||||
lpsustain,
|
||||
lprelease,
|
||||
lpenv,
|
||||
t,
|
||||
t + hapDuration,
|
||||
fanchor,
|
||||
);
|
||||
chain.push(lp());
|
||||
if (ftype === '24db') {
|
||||
chain.push(lp());
|
||||
}
|
||||
}
|
||||
|
||||
if (hcutoff !== undefined) {
|
||||
let hp = () =>
|
||||
createFilter(
|
||||
ac,
|
||||
'highpass',
|
||||
hcutoff,
|
||||
hresonance,
|
||||
hpattack,
|
||||
hpdecay,
|
||||
hpsustain,
|
||||
hprelease,
|
||||
hpenv,
|
||||
t,
|
||||
t + hapDuration,
|
||||
fanchor,
|
||||
);
|
||||
chain.push(hp());
|
||||
if (ftype === '24db') {
|
||||
chain.push(hp());
|
||||
}
|
||||
}
|
||||
|
||||
if (bandf !== undefined) {
|
||||
let bp = () =>
|
||||
createFilter(
|
||||
ac,
|
||||
'bandpass',
|
||||
bandf,
|
||||
bandq,
|
||||
bpattack,
|
||||
bpdecay,
|
||||
bpsustain,
|
||||
bprelease,
|
||||
bpenv,
|
||||
t,
|
||||
t + hapDuration,
|
||||
fanchor,
|
||||
);
|
||||
chain.push(bp());
|
||||
if (ftype === '24db') {
|
||||
chain.push(bp());
|
||||
}
|
||||
}
|
||||
|
||||
if (vowel !== undefined) {
|
||||
const vowelFilter = ac.createVowelFilter(vowel);
|
||||
chain.push(vowelFilter);
|
||||
}
|
||||
|
||||
// effects
|
||||
coarse !== undefined && chain.push(getWorklet(ac, 'coarse-processor', { coarse }));
|
||||
crush !== undefined && chain.push(getWorklet(ac, 'crush-processor', { crush }));
|
||||
shape !== undefined && chain.push(getWorklet(ac, 'shape-processor', { shape }));
|
||||
|
||||
compressorThreshold !== undefined &&
|
||||
chain.push(
|
||||
getCompressor(ac, compressorThreshold, compressorRatio, compressorKnee, compressorAttack, compressorRelease),
|
||||
);
|
||||
|
||||
// panning
|
||||
if (pan !== undefined) {
|
||||
const panner = ac.createStereoPanner();
|
||||
@ -258,7 +379,7 @@ export const superdough = async (value, deadline, hapDuration) => {
|
||||
}
|
||||
|
||||
// last gain
|
||||
const post = gainNode(1);
|
||||
const post = gainNode(postgain);
|
||||
chain.push(post);
|
||||
post.connect(getDestination());
|
||||
|
||||
@ -270,8 +391,19 @@ export const superdough = async (value, deadline, hapDuration) => {
|
||||
}
|
||||
// reverb
|
||||
let reverbSend;
|
||||
if (room > 0 && size > 0) {
|
||||
const reverbNode = getReverb(orbit, size);
|
||||
if (room > 0) {
|
||||
let roomIR;
|
||||
if (ir !== undefined) {
|
||||
let url;
|
||||
let sample = getSound(ir);
|
||||
if (Array.isArray(sample)) {
|
||||
url = sample.data.samples[i % sample.data.samples.length];
|
||||
} else if (typeof sample === 'object') {
|
||||
url = Object.values(sample.data.samples).flat()[i % Object.values(sample.data.samples).length];
|
||||
}
|
||||
roomIR = await loadBuffer(url, ac, ir, 0);
|
||||
}
|
||||
const reverbNode = getReverb(orbit, roomsize, roomfade, roomlp, roomdim, roomIR);
|
||||
reverbSend = effectSend(post, reverbNode, room);
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { midiToFreq, noteToMidi } from './util.mjs';
|
||||
import { registerSound, getAudioContext } from './superdough.mjs';
|
||||
import { gainNode, getEnvelope, getExpEnvelope } from './helpers.mjs';
|
||||
import { getNoiseMix, getNoiseOscillator } from './noise.mjs';
|
||||
|
||||
const mod = (freq, range = 1, type = 'sine') => {
|
||||
const ctx = getAudioContext();
|
||||
@ -20,66 +21,26 @@ const fm = (osc, harmonicityRatio, modulationIndex, wave = 'sine') => {
|
||||
return mod(modfreq, modgain, wave);
|
||||
};
|
||||
|
||||
const waveforms = ['sine', 'square', 'triangle', 'sawtooth'];
|
||||
const noises = ['pink', 'white', 'brown'];
|
||||
|
||||
export function registerSynthSounds() {
|
||||
['sine', 'square', 'triangle', 'sawtooth'].forEach((wave) => {
|
||||
[...waveforms, ...noises].forEach((s) => {
|
||||
registerSound(
|
||||
wave,
|
||||
s,
|
||||
(t, value, onended) => {
|
||||
// destructure adsr here, because the default should be different for synths and samples
|
||||
let {
|
||||
attack = 0.001,
|
||||
decay = 0.05,
|
||||
sustain = 0.6,
|
||||
release = 0.01,
|
||||
fmh: fmHarmonicity = 1,
|
||||
fmi: fmModulationIndex,
|
||||
fmenv: fmEnvelopeType = 'lin',
|
||||
fmattack: fmAttack,
|
||||
fmdecay: fmDecay,
|
||||
fmsustain: fmSustain,
|
||||
fmrelease: fmRelease,
|
||||
fmvelocity: fmVelocity,
|
||||
fmwave: fmWaveform = 'sine',
|
||||
} = value;
|
||||
let { n, note, freq } = value;
|
||||
// with synths, n and note are the same thing
|
||||
note = note || 36;
|
||||
if (typeof note === 'string') {
|
||||
note = noteToMidi(note); // e.g. c3 => 48
|
||||
}
|
||||
// get frequency
|
||||
if (!freq && typeof note === 'number') {
|
||||
freq = midiToFreq(note); // + 48);
|
||||
}
|
||||
// maybe pull out the above frequency resolution?? (there is also getFrequency but it has no default)
|
||||
// make oscillator
|
||||
const { node: o, stop } = getOscillator({ t, s: wave, freq, partials: n });
|
||||
let { attack = 0.001, decay = 0.05, sustain = 0.6, release = 0.01 } = value;
|
||||
|
||||
// FM + FM envelope
|
||||
let stopFm, fmEnvelope;
|
||||
if (fmModulationIndex) {
|
||||
const { node: modulator, stop } = fm(o, fmHarmonicity, fmModulationIndex, fmWaveform);
|
||||
if (![fmAttack, fmDecay, fmSustain, fmRelease, fmVelocity].find((v) => v !== undefined)) {
|
||||
// no envelope by default
|
||||
modulator.connect(o.frequency);
|
||||
} else {
|
||||
fmAttack = fmAttack ?? 0.001;
|
||||
fmDecay = fmDecay ?? 0.001;
|
||||
fmSustain = fmSustain ?? 1;
|
||||
fmRelease = fmRelease ?? 0.001;
|
||||
fmVelocity = fmVelocity ?? 1;
|
||||
fmEnvelope = getEnvelope(fmAttack, fmDecay, fmSustain, fmRelease, fmVelocity, t);
|
||||
if (fmEnvelopeType === 'exp') {
|
||||
fmEnvelope = getExpEnvelope(fmAttack, fmDecay, fmSustain, fmRelease, fmVelocity, t);
|
||||
fmEnvelope.node.maxValue = fmModulationIndex * 2;
|
||||
fmEnvelope.node.minValue = 0.00001;
|
||||
}
|
||||
modulator.connect(fmEnvelope.node);
|
||||
fmEnvelope.node.connect(o.frequency);
|
||||
}
|
||||
stopFm = stop;
|
||||
let sound;
|
||||
if (waveforms.includes(s)) {
|
||||
sound = getOscillator(s, t, value);
|
||||
} else {
|
||||
sound = getNoiseOscillator(s, t);
|
||||
}
|
||||
|
||||
let { node: o, stop, triggerRelease } = sound;
|
||||
|
||||
// turn down
|
||||
const g = gainNode(0.3);
|
||||
|
||||
@ -95,10 +56,9 @@ export function registerSynthSounds() {
|
||||
node: o.connect(g).connect(envelope),
|
||||
stop: (releaseTime) => {
|
||||
releaseEnvelope(releaseTime);
|
||||
fmEnvelope?.stop(releaseTime);
|
||||
triggerRelease?.(releaseTime);
|
||||
let end = releaseTime + release;
|
||||
stop(end);
|
||||
stopFm?.(end);
|
||||
},
|
||||
};
|
||||
},
|
||||
@ -137,18 +97,108 @@ export function waveformN(partials, type) {
|
||||
return osc;
|
||||
}
|
||||
|
||||
export function getOscillator({ s, freq, t, partials }) {
|
||||
// make oscillator
|
||||
// expects one of waveforms as s
|
||||
export function getOscillator(
|
||||
s,
|
||||
t,
|
||||
{
|
||||
n: partials,
|
||||
note,
|
||||
freq,
|
||||
vib = 0,
|
||||
vibmod = 0.5,
|
||||
noise = 0,
|
||||
// fm
|
||||
fmh: fmHarmonicity = 1,
|
||||
fmi: fmModulationIndex,
|
||||
fmenv: fmEnvelopeType = 'lin',
|
||||
fmattack: fmAttack,
|
||||
fmdecay: fmDecay,
|
||||
fmsustain: fmSustain,
|
||||
fmrelease: fmRelease,
|
||||
fmvelocity: fmVelocity,
|
||||
fmwave: fmWaveform = 'sine',
|
||||
},
|
||||
) {
|
||||
let ac = getAudioContext();
|
||||
let o;
|
||||
// If no partials are given, use stock waveforms
|
||||
if (!partials || s === 'sine') {
|
||||
o = getAudioContext().createOscillator();
|
||||
o.type = s || 'triangle';
|
||||
} else {
|
||||
}
|
||||
// generate custom waveform if partials are given
|
||||
else {
|
||||
o = waveformN(partials, s);
|
||||
}
|
||||
|
||||
// get frequency from note...
|
||||
note = note || 36;
|
||||
if (typeof note === 'string') {
|
||||
note = noteToMidi(note); // e.g. c3 => 48
|
||||
}
|
||||
// get frequency
|
||||
if (!freq && typeof note === 'number') {
|
||||
freq = midiToFreq(note); // + 48);
|
||||
}
|
||||
|
||||
// set frequency
|
||||
o.frequency.value = Number(freq);
|
||||
o.start(t);
|
||||
//o.stop(t + duration + release);
|
||||
const stop = (time) => o.stop(time);
|
||||
return { node: o, stop };
|
||||
|
||||
// FM
|
||||
let stopFm, fmEnvelope;
|
||||
if (fmModulationIndex) {
|
||||
const { node: modulator, stop } = fm(o, fmHarmonicity, fmModulationIndex, fmWaveform);
|
||||
if (![fmAttack, fmDecay, fmSustain, fmRelease, fmVelocity].find((v) => v !== undefined)) {
|
||||
// no envelope by default
|
||||
modulator.connect(o.frequency);
|
||||
} else {
|
||||
fmAttack = fmAttack ?? 0.001;
|
||||
fmDecay = fmDecay ?? 0.001;
|
||||
fmSustain = fmSustain ?? 1;
|
||||
fmRelease = fmRelease ?? 0.001;
|
||||
fmVelocity = fmVelocity ?? 1;
|
||||
fmEnvelope = getEnvelope(fmAttack, fmDecay, fmSustain, fmRelease, fmVelocity, t);
|
||||
if (fmEnvelopeType === 'exp') {
|
||||
fmEnvelope = getExpEnvelope(fmAttack, fmDecay, fmSustain, fmRelease, fmVelocity, t);
|
||||
fmEnvelope.node.maxValue = fmModulationIndex * 2;
|
||||
fmEnvelope.node.minValue = 0.00001;
|
||||
}
|
||||
modulator.connect(fmEnvelope.node);
|
||||
fmEnvelope.node.connect(o.frequency);
|
||||
}
|
||||
stopFm = stop;
|
||||
}
|
||||
|
||||
// Additional oscillator for vibrato effect
|
||||
let vibratoOscillator;
|
||||
if (vib > 0) {
|
||||
vibratoOscillator = getAudioContext().createOscillator();
|
||||
vibratoOscillator.frequency.value = vib;
|
||||
const gain = getAudioContext().createGain();
|
||||
// Vibmod is the amount of vibrato, in semitones
|
||||
gain.gain.value = vibmod * 100;
|
||||
vibratoOscillator.connect(gain);
|
||||
gain.connect(o.detune);
|
||||
vibratoOscillator.start(t);
|
||||
}
|
||||
|
||||
let noiseMix;
|
||||
if (noise) {
|
||||
noiseMix = getNoiseMix(o, noise, t);
|
||||
}
|
||||
|
||||
return {
|
||||
node: noiseMix?.node || o,
|
||||
stop: (time) => {
|
||||
vibratoOscillator?.stop(time);
|
||||
noiseMix?.stop(time);
|
||||
stopFm?.(time);
|
||||
o.stop(time);
|
||||
},
|
||||
triggerRelease: (time) => {
|
||||
fmEnvelope?.stop(time);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@ -20,7 +20,7 @@ export const getZZFX = (value, t) => {
|
||||
pitchJump = 0,
|
||||
pitchJumpTime = 0,
|
||||
lfo = 0,
|
||||
noise = 0,
|
||||
znoise = 0,
|
||||
zmod = 0,
|
||||
zcrush = 0,
|
||||
zdelay = 0,
|
||||
@ -54,7 +54,7 @@ export const getZZFX = (value, t) => {
|
||||
pitchJump,
|
||||
pitchJumpTime,
|
||||
lfo,
|
||||
noise,
|
||||
znoise,
|
||||
zmod,
|
||||
zcrush,
|
||||
zdelay,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel.cycles/tonal",
|
||||
"version": "0.8.2",
|
||||
"version": "0.9.0",
|
||||
"description": "Tonal functions for strudel",
|
||||
"main": "index.mjs",
|
||||
"publishConfig": {
|
||||
|
||||
@ -150,6 +150,9 @@ export const scale = register('scale', function (scale, pat) {
|
||||
return pat.withHap((hap) => {
|
||||
const isObject = typeof hap.value === 'object';
|
||||
let note = isObject ? hap.value.n : hap.value;
|
||||
if (isObject) {
|
||||
delete hap.value.n; // remove n so it won't cause trouble
|
||||
}
|
||||
const asNumber = Number(note);
|
||||
if (!isNaN(asNumber)) {
|
||||
// TODO: worth keeping for supporting ':' in (non-mininotation) strings?
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel.cycles/transpiler",
|
||||
"version": "0.8.2",
|
||||
"version": "0.9.0",
|
||||
"description": "Transpiler for strudel user code. Converts syntactically correct but semantically meaningless JS into evaluatable strudel code.",
|
||||
"main": "index.mjs",
|
||||
"publishConfig": {
|
||||
|
||||
@ -5,7 +5,7 @@ import { isNoteWithOctave } from '@strudel.cycles/core';
|
||||
import { getLeafLocations } from '@strudel.cycles/mini';
|
||||
|
||||
export function transpiler(input, options = {}) {
|
||||
const { wrapAsync = false, addReturn = true, emitMiniLocations = true } = options;
|
||||
const { wrapAsync = false, addReturn = true, emitMiniLocations = true, emitWidgets = true } = options;
|
||||
|
||||
let ast = parse(input, {
|
||||
ecmaVersion: 2022,
|
||||
@ -16,9 +16,9 @@ export function transpiler(input, options = {}) {
|
||||
let miniLocations = [];
|
||||
const collectMiniLocations = (value, node) => {
|
||||
const leafLocs = getLeafLocations(`"${value}"`, node.start); // stimmt!
|
||||
//const withOffset = leafLocs.map((offsets) => offsets.map((o) => o + node.start));
|
||||
miniLocations = miniLocations.concat(leafLocs);
|
||||
};
|
||||
let widgets = [];
|
||||
|
||||
walk(ast, {
|
||||
enter(node, parent /* , prop, index */) {
|
||||
@ -35,6 +35,18 @@ export function transpiler(input, options = {}) {
|
||||
emitMiniLocations && collectMiniLocations(value, node);
|
||||
return this.replace(miniWithLocation(value, node));
|
||||
}
|
||||
if (isWidgetFunction(node)) {
|
||||
emitWidgets &&
|
||||
widgets.push({
|
||||
from: node.arguments[0].start,
|
||||
to: node.arguments[0].end,
|
||||
value: node.arguments[0].raw, // don't use value!
|
||||
min: node.arguments[1]?.value ?? 0,
|
||||
max: node.arguments[2]?.value ?? 1,
|
||||
step: node.arguments[3]?.value,
|
||||
});
|
||||
return this.replace(widgetWithLocation(node));
|
||||
}
|
||||
// TODO: remove pseudo note variables?
|
||||
if (node.type === 'Identifier' && isNoteWithOctave(node.name)) {
|
||||
this.skip();
|
||||
@ -64,15 +76,14 @@ export function transpiler(input, options = {}) {
|
||||
if (!emitMiniLocations) {
|
||||
return { output };
|
||||
}
|
||||
return { output, miniLocations };
|
||||
return { output, miniLocations, widgets };
|
||||
}
|
||||
|
||||
function isStringWithDoubleQuotes(node, locations, code) {
|
||||
const { raw, type } = node;
|
||||
if (type !== 'Literal') {
|
||||
if (node.type !== 'Literal') {
|
||||
return false;
|
||||
}
|
||||
return raw[0] === '"';
|
||||
return node.raw[0] === '"';
|
||||
}
|
||||
|
||||
function isBackTickString(node, parent) {
|
||||
@ -94,3 +105,22 @@ function miniWithLocation(value, node) {
|
||||
optional: false,
|
||||
};
|
||||
}
|
||||
|
||||
// these functions are connected to @strudel/codemirror -> slider.mjs
|
||||
// maybe someday there will be pluggable transpiler functions, then move this there
|
||||
function isWidgetFunction(node) {
|
||||
return node.type === 'CallExpression' && node.callee.name === 'slider';
|
||||
}
|
||||
|
||||
function widgetWithLocation(node) {
|
||||
const id = 'slider_' + node.arguments[0].start; // use loc of first arg for id
|
||||
// add loc as identifier to first argument
|
||||
// the sliderWithID function is assumed to be sliderWithID(id, value, min?, max?)
|
||||
node.arguments.unshift({
|
||||
type: 'Literal',
|
||||
value: id,
|
||||
raw: id,
|
||||
});
|
||||
node.callee.name = 'sliderWithID';
|
||||
return node;
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel/web",
|
||||
"version": "0.8.3",
|
||||
"version": "0.9.0",
|
||||
"description": "Easy to setup, opiniated bundle of Strudel for the browser.",
|
||||
"main": "web.mjs",
|
||||
"publishConfig": {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel.cycles/webaudio",
|
||||
"version": "0.8.2",
|
||||
"version": "0.9.0",
|
||||
"description": "Web Audio helpers for Strudel",
|
||||
"main": "index.mjs",
|
||||
"type": "module",
|
||||
|
||||
@ -5,7 +5,7 @@ This program is free software: you can redistribute it and/or modify it under th
|
||||
*/
|
||||
|
||||
import * as strudel from '@strudel.cycles/core';
|
||||
import { superdough, getAudioContext, setLogger } from 'superdough';
|
||||
import { superdough, getAudioContext, setLogger, doughTrigger } from 'superdough';
|
||||
const { Pattern, logger } = strudel;
|
||||
|
||||
setLogger(logger);
|
||||
@ -35,3 +35,7 @@ export function webaudioScheduler(options = {}) {
|
||||
onTrigger: strudel.getTrigger({ defaultOutput, getTime }),
|
||||
});
|
||||
}
|
||||
|
||||
Pattern.prototype.dough = function () {
|
||||
return this.onTrigger(doughTrigger, 1);
|
||||
};
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@strudel.cycles/xen",
|
||||
"version": "0.8.0",
|
||||
"version": "0.9.0",
|
||||
"description": "Xenharmonic API for strudel",
|
||||
"main": "index.mjs",
|
||||
"publishConfig": {
|
||||
|
||||
18
pnpm-lock.yaml
generated
18
pnpm-lock.yaml
generated
@ -588,6 +588,9 @@ importers:
|
||||
'@strudel.cycles/xen':
|
||||
specifier: workspace:*
|
||||
version: link:../packages/xen
|
||||
'@strudel/codemirror':
|
||||
specifier: workspace:*
|
||||
version: link:../packages/codemirror
|
||||
'@strudel/desktopbridge':
|
||||
specifier: workspace:*
|
||||
version: link:../packages/desktopbridge
|
||||
@ -1426,6 +1429,7 @@ packages:
|
||||
/@babel/plugin-proposal-async-generator-functions@7.20.7(@babel/core@7.21.5):
|
||||
resolution: {integrity: sha512-xMbiLsn/8RK7Wq7VeVytytS2L6qE69bXPB10YCmMdDZbKF4okCqY74pI/jJQ/8U0b/F6NrT2+14b8/P9/3AMGA==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-async-generator-functions instead.
|
||||
peerDependencies:
|
||||
'@babel/core': ^7.0.0-0
|
||||
dependencies:
|
||||
@ -1441,6 +1445,7 @@ packages:
|
||||
/@babel/plugin-proposal-class-properties@7.18.6(@babel/core@7.21.5):
|
||||
resolution: {integrity: sha512-cumfXOF0+nzZrrN8Rf0t7M+tF6sZc7vhQwYQck9q1/5w2OExlD+b4v4RpMJFaV1Z7WcDRgO6FqvxqxGlwo+RHQ==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
|
||||
peerDependencies:
|
||||
'@babel/core': ^7.0.0-0
|
||||
dependencies:
|
||||
@ -1454,6 +1459,7 @@ packages:
|
||||
/@babel/plugin-proposal-class-static-block@7.20.7(@babel/core@7.21.5):
|
||||
resolution: {integrity: sha512-AveGOoi9DAjUYYuUAG//Ig69GlazLnoyzMw68VCDux+c1tsnnH/OkYcpz/5xzMkEFC6UxjR5Gw1c+iY2wOGVeQ==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-static-block instead.
|
||||
peerDependencies:
|
||||
'@babel/core': ^7.12.0
|
||||
dependencies:
|
||||
@ -1468,6 +1474,7 @@ packages:
|
||||
/@babel/plugin-proposal-dynamic-import@7.18.6(@babel/core@7.21.5):
|
||||
resolution: {integrity: sha512-1auuwmK+Rz13SJj36R+jqFPMJWyKEDd7lLSdOj4oJK0UTgGueSAtkrCvz9ewmgyU/P941Rv2fQwZJN8s6QruXw==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-dynamic-import instead.
|
||||
peerDependencies:
|
||||
'@babel/core': ^7.0.0-0
|
||||
dependencies:
|
||||
@ -1479,6 +1486,7 @@ packages:
|
||||
/@babel/plugin-proposal-export-namespace-from@7.18.9(@babel/core@7.21.5):
|
||||
resolution: {integrity: sha512-k1NtHyOMvlDDFeb9G5PhUXuGj8m/wiwojgQVEhJ/fsVsMCpLyOP4h0uGEjYJKrRI+EVPlb5Jk+Gt9P97lOGwtA==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-export-namespace-from instead.
|
||||
peerDependencies:
|
||||
'@babel/core': ^7.0.0-0
|
||||
dependencies:
|
||||
@ -1490,6 +1498,7 @@ packages:
|
||||
/@babel/plugin-proposal-json-strings@7.18.6(@babel/core@7.21.5):
|
||||
resolution: {integrity: sha512-lr1peyn9kOdbYc0xr0OdHTZ5FMqS6Di+H0Fz2I/JwMzGmzJETNeOFq2pBySw6X/KFL5EWDjlJuMsUGRFb8fQgQ==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-json-strings instead.
|
||||
peerDependencies:
|
||||
'@babel/core': ^7.0.0-0
|
||||
dependencies:
|
||||
@ -1501,6 +1510,7 @@ packages:
|
||||
/@babel/plugin-proposal-logical-assignment-operators@7.20.7(@babel/core@7.21.5):
|
||||
resolution: {integrity: sha512-y7C7cZgpMIjWlKE5T7eJwp+tnRYM89HmRvWM5EQuB5BoHEONjmQ8lSNmBUwOyy/GFRsohJED51YBF79hE1djug==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-logical-assignment-operators instead.
|
||||
peerDependencies:
|
||||
'@babel/core': ^7.0.0-0
|
||||
dependencies:
|
||||
@ -1512,6 +1522,7 @@ packages:
|
||||
/@babel/plugin-proposal-nullish-coalescing-operator@7.18.6(@babel/core@7.21.5):
|
||||
resolution: {integrity: sha512-wQxQzxYeJqHcfppzBDnm1yAY0jSRkUXR2z8RePZYrKwMKgMlE8+Z6LUno+bd6LvbGh8Gltvy74+9pIYkr+XkKA==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
|
||||
peerDependencies:
|
||||
'@babel/core': ^7.0.0-0
|
||||
dependencies:
|
||||
@ -1523,6 +1534,7 @@ packages:
|
||||
/@babel/plugin-proposal-numeric-separator@7.18.6(@babel/core@7.21.5):
|
||||
resolution: {integrity: sha512-ozlZFogPqoLm8WBr5Z8UckIoE4YQ5KESVcNudyXOR8uqIkliTEgJ3RoketfG6pmzLdeZF0H/wjE9/cCEitBl7Q==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-numeric-separator instead.
|
||||
peerDependencies:
|
||||
'@babel/core': ^7.0.0-0
|
||||
dependencies:
|
||||
@ -1534,6 +1546,7 @@ packages:
|
||||
/@babel/plugin-proposal-object-rest-spread@7.20.7(@babel/core@7.21.5):
|
||||
resolution: {integrity: sha512-d2S98yCiLxDVmBmE8UjGcfPvNEUbA1U5q5WxaWFUGRzJSVAZqm5W6MbPct0jxnegUZ0niLeNX+IOzEs7wYg9Dg==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.
|
||||
peerDependencies:
|
||||
'@babel/core': ^7.0.0-0
|
||||
dependencies:
|
||||
@ -1548,6 +1561,7 @@ packages:
|
||||
/@babel/plugin-proposal-optional-catch-binding@7.18.6(@babel/core@7.21.5):
|
||||
resolution: {integrity: sha512-Q40HEhs9DJQyaZfUjjn6vE8Cv4GmMHCYuMGIWUnlxH6400VGxOuwWsPt4FxXxJkC/5eOzgn0z21M9gMT4MOhbw==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-catch-binding instead.
|
||||
peerDependencies:
|
||||
'@babel/core': ^7.0.0-0
|
||||
dependencies:
|
||||
@ -1559,6 +1573,7 @@ packages:
|
||||
/@babel/plugin-proposal-optional-chaining@7.20.7(@babel/core@7.21.5):
|
||||
resolution: {integrity: sha512-T+A7b1kfjtRM51ssoOfS1+wbyCVqorfyZhT99TvxxLMirPShD8CzKMRepMlCBGM5RpHMbn8s+5MMHnPstJH6mQ==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
|
||||
peerDependencies:
|
||||
'@babel/core': ^7.0.0-0
|
||||
dependencies:
|
||||
@ -1571,6 +1586,7 @@ packages:
|
||||
/@babel/plugin-proposal-private-methods@7.18.6(@babel/core@7.21.5):
|
||||
resolution: {integrity: sha512-nutsvktDItsNn4rpGItSNV2sz1XwS+nfU0Rg8aCx3W3NOKVzdMjJRu0O5OkgDp3ZGICSTbgRpxZoWsxoKRvbeA==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-private-methods instead.
|
||||
peerDependencies:
|
||||
'@babel/core': ^7.0.0-0
|
||||
dependencies:
|
||||
@ -1584,6 +1600,7 @@ packages:
|
||||
/@babel/plugin-proposal-private-property-in-object@7.20.5(@babel/core@7.21.5):
|
||||
resolution: {integrity: sha512-Vq7b9dUA12ByzB4EjQTPo25sFhY+08pQDBSZRtUAkj7lb7jahaHR5igera16QZ+3my1nYR4dKsNdYj5IjPHilQ==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-private-property-in-object instead.
|
||||
peerDependencies:
|
||||
'@babel/core': ^7.0.0-0
|
||||
dependencies:
|
||||
@ -1599,6 +1616,7 @@ packages:
|
||||
/@babel/plugin-proposal-unicode-property-regex@7.18.6(@babel/core@7.21.5):
|
||||
resolution: {integrity: sha512-2BShG/d5yoZyXZfVePH91urL5wTG6ASZU9M4o03lKK8u8UW1y08OMttBSOADTcJrnPMpvDXRG3G8fyLh4ovs8w==}
|
||||
engines: {node: '>=4'}
|
||||
deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-unicode-property-regex instead.
|
||||
peerDependencies:
|
||||
'@babel/core': ^7.0.0-0
|
||||
dependencies:
|
||||
|
||||
@ -900,6 +900,33 @@ exports[`runs examples > example "begin" example index 0 1`] = `
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "bpattack" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/1 | note:c2 s:sawtooth bandf:500 bpattack:0.5 bpenv:4 ]",
|
||||
"[ 1/1 → 2/1 | note:e2 s:sawtooth bandf:500 bpattack:0.5 bpenv:4 ]",
|
||||
"[ 2/1 → 3/1 | note:f2 s:sawtooth bandf:500 bpattack:0.5 bpenv:4 ]",
|
||||
"[ 3/1 → 4/1 | note:g2 s:sawtooth bandf:500 bpattack:0.5 bpenv:4 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "bpdecay" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/1 | note:c2 s:sawtooth bandf:500 bpdecay:0.5 bpsustain:0.2 bpenv:4 ]",
|
||||
"[ 1/1 → 2/1 | note:e2 s:sawtooth bandf:500 bpdecay:0.5 bpsustain:0.2 bpenv:4 ]",
|
||||
"[ 2/1 → 3/1 | note:f2 s:sawtooth bandf:500 bpdecay:0.5 bpsustain:0.2 bpenv:4 ]",
|
||||
"[ 3/1 → 4/1 | note:g2 s:sawtooth bandf:500 bpdecay:0.5 bpsustain:0.2 bpenv:4 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "bpenv" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/1 | note:c2 s:sawtooth bandf:500 bpattack:0.5 bpenv:4 ]",
|
||||
"[ 1/1 → 2/1 | note:e2 s:sawtooth bandf:500 bpattack:0.5 bpenv:4 ]",
|
||||
"[ 2/1 → 3/1 | note:f2 s:sawtooth bandf:500 bpattack:0.5 bpenv:4 ]",
|
||||
"[ 3/1 → 4/1 | note:g2 s:sawtooth bandf:500 bpattack:0.5 bpenv:4 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "bpf" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/3 | s:hh bandf:1000 ]",
|
||||
@ -938,6 +965,24 @@ exports[`runs examples > example "bpq" example index 0 1`] = `
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "bprelease" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/1 | note:c2 s:sawtooth clip:0.5 bandf:500 bpenv:4 bprelease:0.5 release:0.5 ]",
|
||||
"[ 1/1 → 2/1 | note:e2 s:sawtooth clip:0.5 bandf:500 bpenv:4 bprelease:0.5 release:0.5 ]",
|
||||
"[ 2/1 → 3/1 | note:f2 s:sawtooth clip:0.5 bandf:500 bpenv:4 bprelease:0.5 release:0.5 ]",
|
||||
"[ 3/1 → 4/1 | note:g2 s:sawtooth clip:0.5 bandf:500 bpenv:4 bprelease:0.5 release:0.5 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "bpsustain" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/1 | note:c2 s:sawtooth bandf:500 bpdecay:0.5 bpsustain:0 bpenv:4 ]",
|
||||
"[ 1/1 → 2/1 | note:e2 s:sawtooth bandf:500 bpdecay:0.5 bpsustain:0 bpenv:4 ]",
|
||||
"[ 2/1 → 3/1 | note:f2 s:sawtooth bandf:500 bpdecay:0.5 bpsustain:0 bpenv:4 ]",
|
||||
"[ 3/1 → 4/1 | note:g2 s:sawtooth bandf:500 bpdecay:0.5 bpsustain:0 bpenv:4 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "cat" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/2 | s:hh ]",
|
||||
@ -1026,6 +1071,31 @@ exports[`runs examples > example "chooseCycles" example index 1 1`] = `
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "chooseWith" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/5 | note:c2 s:bd n:6 ]",
|
||||
"[ 1/5 → 2/5 | note:g2 s:sawtooth ]",
|
||||
"[ 2/5 → 3/5 | note:g2 s:triangle ]",
|
||||
"[ 3/5 → 4/5 | note:d2 s:bd n:6 ]",
|
||||
"[ 4/5 → 1/1 | note:f1 s:sawtooth ]",
|
||||
"[ 1/1 → 6/5 | note:c2 s:bd n:6 ]",
|
||||
"[ 6/5 → 7/5 | note:g2 s:sawtooth ]",
|
||||
"[ 7/5 → 8/5 | note:g2 s:triangle ]",
|
||||
"[ 8/5 → 9/5 | note:d2 s:bd n:6 ]",
|
||||
"[ 9/5 → 2/1 | note:f1 s:sawtooth ]",
|
||||
"[ 2/1 → 11/5 | note:c2 s:bd n:6 ]",
|
||||
"[ 11/5 → 12/5 | note:g2 s:sawtooth ]",
|
||||
"[ 12/5 → 13/5 | note:g2 s:triangle ]",
|
||||
"[ 13/5 → 14/5 | note:d2 s:bd n:6 ]",
|
||||
"[ 14/5 → 3/1 | note:f1 s:sawtooth ]",
|
||||
"[ 3/1 → 16/5 | note:c2 s:bd n:6 ]",
|
||||
"[ 16/5 → 17/5 | note:g2 s:sawtooth ]",
|
||||
"[ 17/5 → 18/5 | note:g2 s:triangle ]",
|
||||
"[ 18/5 → 19/5 | note:d2 s:bd n:6 ]",
|
||||
"[ 19/5 → 4/1 | note:f1 s:sawtooth ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "chop" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/1 | s:rhodes begin:0.75 end:1 speed:0.25 unit:c ]",
|
||||
@ -1140,6 +1210,35 @@ exports[`runs examples > example "compress" example index 0 1`] = `
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "compressor" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/4 | s:hh compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 ]",
|
||||
"[ 0/1 → 1/2 | s:bd compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 ]",
|
||||
"[ 1/4 → 1/2 | s:hh compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 ]",
|
||||
"[ 1/2 → 3/4 | s:hh compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 ]",
|
||||
"[ 1/2 → 1/1 | s:sd compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 ]",
|
||||
"[ 3/4 → 1/1 | s:hh compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 ]",
|
||||
"[ 1/1 → 5/4 | s:hh compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 ]",
|
||||
"[ 1/1 → 3/2 | s:bd compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 ]",
|
||||
"[ 5/4 → 3/2 | s:hh compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 ]",
|
||||
"[ 3/2 → 7/4 | s:hh compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 ]",
|
||||
"[ 3/2 → 2/1 | s:sd compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 ]",
|
||||
"[ 7/4 → 2/1 | s:hh compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 ]",
|
||||
"[ 2/1 → 9/4 | s:hh compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 ]",
|
||||
"[ 2/1 → 5/2 | s:bd compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 ]",
|
||||
"[ 9/4 → 5/2 | s:hh compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 ]",
|
||||
"[ 5/2 → 11/4 | s:hh compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 ]",
|
||||
"[ 5/2 → 3/1 | s:sd compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 ]",
|
||||
"[ 11/4 → 3/1 | s:hh compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 ]",
|
||||
"[ 3/1 → 13/4 | s:hh compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 ]",
|
||||
"[ 3/1 → 7/2 | s:bd compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 ]",
|
||||
"[ 13/4 → 7/2 | s:hh compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 ]",
|
||||
"[ 7/2 → 15/4 | s:hh compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 ]",
|
||||
"[ 7/2 → 4/1 | s:sd compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 ]",
|
||||
"[ 15/4 → 4/1 | s:hh compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "cosine" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/8 | note:Eb4 ]",
|
||||
@ -1783,6 +1882,15 @@ exports[`runs examples > example "firstOf" example index 0 1`] = `
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "fit" example index 0 1`] = `
|
||||
[
|
||||
"[ (0/1 → 1/1) ⇝ 4/1 | s:rhodes speed:0.25 unit:c ]",
|
||||
"[ 0/1 ⇜ (1/1 → 2/1) ⇝ 4/1 | s:rhodes speed:0.25 unit:c ]",
|
||||
"[ 0/1 ⇜ (2/1 → 3/1) ⇝ 4/1 | s:rhodes speed:0.25 unit:c ]",
|
||||
"[ 0/1 ⇜ (3/1 → 4/1) | s:rhodes speed:0.25 unit:c ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "floor" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/4 | note:42 ]",
|
||||
@ -2013,6 +2121,15 @@ exports[`runs examples > example "freq" example index 1 1`] = `
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "ftype" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/1 | note:c2 s:sawtooth cutoff:500 bpenv:4 ftype:12db ]",
|
||||
"[ 1/1 → 2/1 | note:e2 s:sawtooth cutoff:500 bpenv:4 ftype:24db ]",
|
||||
"[ 2/1 → 3/1 | note:f2 s:sawtooth cutoff:500 bpenv:4 ftype:12db ]",
|
||||
"[ 3/1 → 4/1 | note:g2 s:sawtooth cutoff:500 bpenv:4 ftype:24db ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "gain" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/8 | s:hh gain:0.4 ]",
|
||||
@ -2050,6 +2167,33 @@ exports[`runs examples > example "gain" example index 0 1`] = `
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "hpattack" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/1 | note:c2 s:sawtooth hcutoff:500 hpattack:0.5 hpenv:4 ]",
|
||||
"[ 1/1 → 2/1 | note:e2 s:sawtooth hcutoff:500 hpattack:0.5 hpenv:4 ]",
|
||||
"[ 2/1 → 3/1 | note:f2 s:sawtooth hcutoff:500 hpattack:0.5 hpenv:4 ]",
|
||||
"[ 3/1 → 4/1 | note:g2 s:sawtooth hcutoff:500 hpattack:0.5 hpenv:4 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "hpdecay" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/1 | note:c2 s:sawtooth hcutoff:500 hpdecay:0.5 hpsustain:0.2 hpenv:4 ]",
|
||||
"[ 1/1 → 2/1 | note:e2 s:sawtooth hcutoff:500 hpdecay:0.5 hpsustain:0.2 hpenv:4 ]",
|
||||
"[ 2/1 → 3/1 | note:f2 s:sawtooth hcutoff:500 hpdecay:0.5 hpsustain:0.2 hpenv:4 ]",
|
||||
"[ 3/1 → 4/1 | note:g2 s:sawtooth hcutoff:500 hpdecay:0.5 hpsustain:0.2 hpenv:4 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "hpenv" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/1 | note:c2 s:sawtooth hcutoff:500 hpattack:0.5 hpenv:4 ]",
|
||||
"[ 1/1 → 2/1 | note:e2 s:sawtooth hcutoff:500 hpattack:0.5 hpenv:4 ]",
|
||||
"[ 2/1 → 3/1 | note:f2 s:sawtooth hcutoff:500 hpattack:0.5 hpenv:4 ]",
|
||||
"[ 3/1 → 4/1 | note:g2 s:sawtooth hcutoff:500 hpattack:0.5 hpenv:4 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "hpf" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/4 | s:hh hcutoff:4000 ]",
|
||||
@ -2137,6 +2281,24 @@ exports[`runs examples > example "hpq" example index 0 1`] = `
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "hprelease" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/1 | note:c2 s:sawtooth clip:0.5 hcutoff:500 hpenv:4 hprelease:0.5 release:0.5 ]",
|
||||
"[ 1/1 → 2/1 | note:e2 s:sawtooth clip:0.5 hcutoff:500 hpenv:4 hprelease:0.5 release:0.5 ]",
|
||||
"[ 2/1 → 3/1 | note:f2 s:sawtooth clip:0.5 hcutoff:500 hpenv:4 hprelease:0.5 release:0.5 ]",
|
||||
"[ 3/1 → 4/1 | note:g2 s:sawtooth clip:0.5 hcutoff:500 hpenv:4 hprelease:0.5 release:0.5 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "hpsustain" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/1 | note:c2 s:sawtooth hcutoff:500 hpdecay:0.5 hpsustain:0 hpenv:4 ]",
|
||||
"[ 1/1 → 2/1 | note:e2 s:sawtooth hcutoff:500 hpdecay:0.5 hpsustain:0 hpenv:4 ]",
|
||||
"[ 2/1 → 3/1 | note:f2 s:sawtooth hcutoff:500 hpdecay:0.5 hpsustain:0 hpenv:4 ]",
|
||||
"[ 3/1 → 4/1 | note:g2 s:sawtooth hcutoff:500 hpdecay:0.5 hpsustain:0 hpenv:4 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "hurry" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 3/4 | s:bd speed:1 ]",
|
||||
@ -2541,10 +2703,10 @@ exports[`runs examples > example "linger" example index 0 1`] = `
|
||||
|
||||
exports[`runs examples > example "loop" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/1 | s:bd loop:1 ]",
|
||||
"[ 1/1 → 2/1 | s:bd loop:2 ]",
|
||||
"[ 2/1 → 3/1 | s:bd loop:3 ]",
|
||||
"[ 3/1 → 4/1 | s:bd loop:4 ]",
|
||||
"[ 0/1 → 1/1 | s:casio loop:1 ]",
|
||||
"[ 1/1 → 2/1 | s:casio loop:1 ]",
|
||||
"[ 2/1 → 3/1 | s:casio loop:1 ]",
|
||||
"[ 3/1 → 4/1 | s:casio loop:1 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
@ -2566,6 +2728,51 @@ exports[`runs examples > example "loopAtCps" example index 0 1`] = `
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "loopBegin" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/1 | s:space loop:1 loopBegin:0 analyze:1 ]",
|
||||
"[ 1/1 → 2/1 | s:space loop:1 loopBegin:0.125 analyze:1 ]",
|
||||
"[ 2/1 → 3/1 | s:space loop:1 loopBegin:0.25 analyze:1 ]",
|
||||
"[ 3/1 → 4/1 | s:space loop:1 loopBegin:0 analyze:1 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "loopEnd" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/1 | s:space loop:1 loopEnd:1 analyze:1 ]",
|
||||
"[ 1/1 → 2/1 | s:space loop:1 loopEnd:0.75 analyze:1 ]",
|
||||
"[ 2/1 → 3/1 | s:space loop:1 loopEnd:0.5 analyze:1 ]",
|
||||
"[ 3/1 → 4/1 | s:space loop:1 loopEnd:0.25 analyze:1 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "lpattack" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/1 | note:c2 s:sawtooth cutoff:500 lpattack:0.5 lpenv:4 ]",
|
||||
"[ 1/1 → 2/1 | note:e2 s:sawtooth cutoff:500 lpattack:0.5 lpenv:4 ]",
|
||||
"[ 2/1 → 3/1 | note:f2 s:sawtooth cutoff:500 lpattack:0.5 lpenv:4 ]",
|
||||
"[ 3/1 → 4/1 | note:g2 s:sawtooth cutoff:500 lpattack:0.5 lpenv:4 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "lpdecay" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/1 | note:c2 s:sawtooth cutoff:500 lpdecay:0.5 lpsustain:0.2 lpenv:4 ]",
|
||||
"[ 1/1 → 2/1 | note:e2 s:sawtooth cutoff:500 lpdecay:0.5 lpsustain:0.2 lpenv:4 ]",
|
||||
"[ 2/1 → 3/1 | note:f2 s:sawtooth cutoff:500 lpdecay:0.5 lpsustain:0.2 lpenv:4 ]",
|
||||
"[ 3/1 → 4/1 | note:g2 s:sawtooth cutoff:500 lpdecay:0.5 lpsustain:0.2 lpenv:4 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "lpenv" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/1 | note:c2 s:sawtooth cutoff:500 lpattack:0.5 lpenv:4 ]",
|
||||
"[ 1/1 → 2/1 | note:e2 s:sawtooth cutoff:500 lpattack:0.5 lpenv:4 ]",
|
||||
"[ 2/1 → 3/1 | note:f2 s:sawtooth cutoff:500 lpattack:0.5 lpenv:4 ]",
|
||||
"[ 3/1 → 4/1 | note:g2 s:sawtooth cutoff:500 lpattack:0.5 lpenv:4 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "lpf" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/3 | s:hh cutoff:4000 ]",
|
||||
@ -2657,6 +2864,24 @@ exports[`runs examples > example "lpq" example index 0 1`] = `
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "lprelease" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/1 | note:c2 s:sawtooth clip:0.5 cutoff:500 lpenv:4 lprelease:0.5 release:0.5 ]",
|
||||
"[ 1/1 → 2/1 | note:e2 s:sawtooth clip:0.5 cutoff:500 lpenv:4 lprelease:0.5 release:0.5 ]",
|
||||
"[ 2/1 → 3/1 | note:f2 s:sawtooth clip:0.5 cutoff:500 lpenv:4 lprelease:0.5 release:0.5 ]",
|
||||
"[ 3/1 → 4/1 | note:g2 s:sawtooth clip:0.5 cutoff:500 lpenv:4 lprelease:0.5 release:0.5 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "lpsustain" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/1 | note:c2 s:sawtooth cutoff:500 lpdecay:0.5 lpsustain:0 lpenv:4 ]",
|
||||
"[ 1/1 → 2/1 | note:e2 s:sawtooth cutoff:500 lpdecay:0.5 lpsustain:0 lpenv:4 ]",
|
||||
"[ 2/1 → 3/1 | note:f2 s:sawtooth cutoff:500 lpdecay:0.5 lpsustain:0 lpenv:4 ]",
|
||||
"[ 3/1 → 4/1 | note:g2 s:sawtooth cutoff:500 lpdecay:0.5 lpsustain:0 lpenv:4 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "lrate" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/1 | n:0 s:supersquare leslie:1 lrate:1 ]",
|
||||
@ -2788,6 +3013,15 @@ exports[`runs examples > example "never" example index 0 1`] = `
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "noise" example index 0 1`] = `
|
||||
[
|
||||
"[ (0/1 → 1/1) ⇝ 2/1 | s:white ]",
|
||||
"[ 0/1 ⇜ (1/1 → 2/1) | s:white ]",
|
||||
"[ (2/1 → 3/1) ⇝ 4/1 | s:pink ]",
|
||||
"[ 2/1 ⇜ (3/1 → 4/1) | s:pink ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "note" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/4 | note:c ]",
|
||||
@ -3113,6 +3347,35 @@ exports[`runs examples > example "polymeterSteps" example index 0 1`] = `
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "postgain" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/4 | s:hh compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 postgain:1.5 ]",
|
||||
"[ 0/1 → 1/2 | s:bd compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 postgain:1.5 ]",
|
||||
"[ 1/4 → 1/2 | s:hh compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 postgain:1.5 ]",
|
||||
"[ 1/2 → 3/4 | s:hh compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 postgain:1.5 ]",
|
||||
"[ 1/2 → 1/1 | s:sd compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 postgain:1.5 ]",
|
||||
"[ 3/4 → 1/1 | s:hh compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 postgain:1.5 ]",
|
||||
"[ 1/1 → 5/4 | s:hh compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 postgain:1.5 ]",
|
||||
"[ 1/1 → 3/2 | s:bd compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 postgain:1.5 ]",
|
||||
"[ 5/4 → 3/2 | s:hh compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 postgain:1.5 ]",
|
||||
"[ 3/2 → 7/4 | s:hh compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 postgain:1.5 ]",
|
||||
"[ 3/2 → 2/1 | s:sd compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 postgain:1.5 ]",
|
||||
"[ 7/4 → 2/1 | s:hh compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 postgain:1.5 ]",
|
||||
"[ 2/1 → 9/4 | s:hh compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 postgain:1.5 ]",
|
||||
"[ 2/1 → 5/2 | s:bd compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 postgain:1.5 ]",
|
||||
"[ 9/4 → 5/2 | s:hh compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 postgain:1.5 ]",
|
||||
"[ 5/2 → 11/4 | s:hh compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 postgain:1.5 ]",
|
||||
"[ 5/2 → 3/1 | s:sd compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 postgain:1.5 ]",
|
||||
"[ 11/4 → 3/1 | s:hh compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 postgain:1.5 ]",
|
||||
"[ 3/1 → 13/4 | s:hh compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 postgain:1.5 ]",
|
||||
"[ 3/1 → 7/2 | s:bd compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 postgain:1.5 ]",
|
||||
"[ 13/4 → 7/2 | s:hh compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 postgain:1.5 ]",
|
||||
"[ 7/2 → 15/4 | s:hh compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 postgain:1.5 ]",
|
||||
"[ 7/2 → 4/1 | s:sd compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 postgain:1.5 ]",
|
||||
"[ 15/4 → 4/1 | s:hh compressor:-20 compressorRatio:20 compressorKnee:10 compressorAttack:0.002 compressorRelease:0.02 postgain:1.5 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "press" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/2 | s:hh ]",
|
||||
@ -3483,16 +3746,107 @@ exports[`runs examples > example "room" example index 1 1`] = `
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "roomdim" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/2 | s:bd room:0.5 roomlp:10000 roomdim:8000 ]",
|
||||
"[ 1/2 → 1/1 | s:sd room:0.5 roomlp:10000 roomdim:8000 ]",
|
||||
"[ 1/1 → 3/2 | s:bd room:0.5 roomlp:10000 roomdim:8000 ]",
|
||||
"[ 3/2 → 2/1 | s:sd room:0.5 roomlp:10000 roomdim:8000 ]",
|
||||
"[ 2/1 → 5/2 | s:bd room:0.5 roomlp:10000 roomdim:8000 ]",
|
||||
"[ 5/2 → 3/1 | s:sd room:0.5 roomlp:10000 roomdim:8000 ]",
|
||||
"[ 3/1 → 7/2 | s:bd room:0.5 roomlp:10000 roomdim:8000 ]",
|
||||
"[ 7/2 → 4/1 | s:sd room:0.5 roomlp:10000 roomdim:8000 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "roomdim" example index 1 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/2 | s:bd room:0.5 roomlp:5000 roomdim:400 ]",
|
||||
"[ 1/2 → 1/1 | s:sd room:0.5 roomlp:5000 roomdim:400 ]",
|
||||
"[ 1/1 → 3/2 | s:bd room:0.5 roomlp:5000 roomdim:400 ]",
|
||||
"[ 3/2 → 2/1 | s:sd room:0.5 roomlp:5000 roomdim:400 ]",
|
||||
"[ 2/1 → 5/2 | s:bd room:0.5 roomlp:5000 roomdim:400 ]",
|
||||
"[ 5/2 → 3/1 | s:sd room:0.5 roomlp:5000 roomdim:400 ]",
|
||||
"[ 3/1 → 7/2 | s:bd room:0.5 roomlp:5000 roomdim:400 ]",
|
||||
"[ 7/2 → 4/1 | s:sd room:0.5 roomlp:5000 roomdim:400 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "roomfade" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/2 | s:bd room:0.5 roomlp:10000 roomfade:0.5 ]",
|
||||
"[ 1/2 → 1/1 | s:sd room:0.5 roomlp:10000 roomfade:0.5 ]",
|
||||
"[ 1/1 → 3/2 | s:bd room:0.5 roomlp:10000 roomfade:0.5 ]",
|
||||
"[ 3/2 → 2/1 | s:sd room:0.5 roomlp:10000 roomfade:0.5 ]",
|
||||
"[ 2/1 → 5/2 | s:bd room:0.5 roomlp:10000 roomfade:0.5 ]",
|
||||
"[ 5/2 → 3/1 | s:sd room:0.5 roomlp:10000 roomfade:0.5 ]",
|
||||
"[ 3/1 → 7/2 | s:bd room:0.5 roomlp:10000 roomfade:0.5 ]",
|
||||
"[ 7/2 → 4/1 | s:sd room:0.5 roomlp:10000 roomfade:0.5 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "roomfade" example index 1 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/2 | s:bd room:0.5 roomlp:5000 roomfade:4 ]",
|
||||
"[ 1/2 → 1/1 | s:sd room:0.5 roomlp:5000 roomfade:4 ]",
|
||||
"[ 1/1 → 3/2 | s:bd room:0.5 roomlp:5000 roomfade:4 ]",
|
||||
"[ 3/2 → 2/1 | s:sd room:0.5 roomlp:5000 roomfade:4 ]",
|
||||
"[ 2/1 → 5/2 | s:bd room:0.5 roomlp:5000 roomfade:4 ]",
|
||||
"[ 5/2 → 3/1 | s:sd room:0.5 roomlp:5000 roomfade:4 ]",
|
||||
"[ 3/1 → 7/2 | s:bd room:0.5 roomlp:5000 roomfade:4 ]",
|
||||
"[ 7/2 → 4/1 | s:sd room:0.5 roomlp:5000 roomfade:4 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "roomlp" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/2 | s:bd room:0.5 roomlp:10000 ]",
|
||||
"[ 1/2 → 1/1 | s:sd room:0.5 roomlp:10000 ]",
|
||||
"[ 1/1 → 3/2 | s:bd room:0.5 roomlp:10000 ]",
|
||||
"[ 3/2 → 2/1 | s:sd room:0.5 roomlp:10000 ]",
|
||||
"[ 2/1 → 5/2 | s:bd room:0.5 roomlp:10000 ]",
|
||||
"[ 5/2 → 3/1 | s:sd room:0.5 roomlp:10000 ]",
|
||||
"[ 3/1 → 7/2 | s:bd room:0.5 roomlp:10000 ]",
|
||||
"[ 7/2 → 4/1 | s:sd room:0.5 roomlp:10000 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "roomlp" example index 1 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/2 | s:bd room:0.5 roomlp:5000 ]",
|
||||
"[ 1/2 → 1/1 | s:sd room:0.5 roomlp:5000 ]",
|
||||
"[ 1/1 → 3/2 | s:bd room:0.5 roomlp:5000 ]",
|
||||
"[ 3/2 → 2/1 | s:sd room:0.5 roomlp:5000 ]",
|
||||
"[ 2/1 → 5/2 | s:bd room:0.5 roomlp:5000 ]",
|
||||
"[ 5/2 → 3/1 | s:sd room:0.5 roomlp:5000 ]",
|
||||
"[ 3/1 → 7/2 | s:bd room:0.5 roomlp:5000 ]",
|
||||
"[ 7/2 → 4/1 | s:sd room:0.5 roomlp:5000 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "roomsize" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/2 | s:bd room:0.8 size:0 ]",
|
||||
"[ 1/2 → 1/1 | s:sd room:0.8 size:0 ]",
|
||||
"[ 1/1 → 3/2 | s:bd room:0.8 size:1 ]",
|
||||
"[ 3/2 → 2/1 | s:sd room:0.8 size:1 ]",
|
||||
"[ 2/1 → 5/2 | s:bd room:0.8 size:2 ]",
|
||||
"[ 5/2 → 3/1 | s:sd room:0.8 size:2 ]",
|
||||
"[ 3/1 → 7/2 | s:bd room:0.8 size:4 ]",
|
||||
"[ 7/2 → 4/1 | s:sd room:0.8 size:4 ]",
|
||||
"[ 0/1 → 1/2 | s:bd room:0.8 roomsize:1 ]",
|
||||
"[ 1/2 → 1/1 | s:sd room:0.8 roomsize:1 ]",
|
||||
"[ 1/1 → 3/2 | s:bd room:0.8 roomsize:1 ]",
|
||||
"[ 3/2 → 2/1 | s:sd room:0.8 roomsize:1 ]",
|
||||
"[ 2/1 → 5/2 | s:bd room:0.8 roomsize:1 ]",
|
||||
"[ 5/2 → 3/1 | s:sd room:0.8 roomsize:1 ]",
|
||||
"[ 3/1 → 7/2 | s:bd room:0.8 roomsize:1 ]",
|
||||
"[ 7/2 → 4/1 | s:sd room:0.8 roomsize:1 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "roomsize" example index 1 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/2 | s:bd room:0.8 roomsize:4 ]",
|
||||
"[ 1/2 → 1/1 | s:sd room:0.8 roomsize:4 ]",
|
||||
"[ 1/1 → 3/2 | s:bd room:0.8 roomsize:4 ]",
|
||||
"[ 3/2 → 2/1 | s:sd room:0.8 roomsize:4 ]",
|
||||
"[ 2/1 → 5/2 | s:bd room:0.8 roomsize:4 ]",
|
||||
"[ 5/2 → 3/1 | s:sd room:0.8 roomsize:4 ]",
|
||||
"[ 3/1 → 7/2 | s:bd room:0.8 roomsize:4 ]",
|
||||
"[ 7/2 → 4/1 | s:sd room:0.8 roomsize:4 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
@ -3671,96 +4025,96 @@ exports[`runs examples > example "saw" example index 1 1`] = `
|
||||
|
||||
exports[`runs examples > example "scale" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/6 | n:0 note:C3 ]",
|
||||
"[ 1/6 → 1/3 | n:2 note:E3 ]",
|
||||
"[ 1/3 → 1/2 | n:4 note:G3 ]",
|
||||
"[ 1/2 → 2/3 | n:6 note:B3 ]",
|
||||
"[ 2/3 → 5/6 | n:4 note:G3 ]",
|
||||
"[ 5/6 → 1/1 | n:2 note:E3 ]",
|
||||
"[ 1/1 → 7/6 | n:0 note:C3 ]",
|
||||
"[ 7/6 → 4/3 | n:2 note:E3 ]",
|
||||
"[ 4/3 → 3/2 | n:4 note:G3 ]",
|
||||
"[ 3/2 → 5/3 | n:6 note:B3 ]",
|
||||
"[ 5/3 → 11/6 | n:4 note:G3 ]",
|
||||
"[ 11/6 → 2/1 | n:2 note:E3 ]",
|
||||
"[ 2/1 → 13/6 | n:0 note:C3 ]",
|
||||
"[ 13/6 → 7/3 | n:2 note:E3 ]",
|
||||
"[ 7/3 → 5/2 | n:4 note:G3 ]",
|
||||
"[ 5/2 → 8/3 | n:6 note:B3 ]",
|
||||
"[ 8/3 → 17/6 | n:4 note:G3 ]",
|
||||
"[ 17/6 → 3/1 | n:2 note:E3 ]",
|
||||
"[ 3/1 → 19/6 | n:0 note:C3 ]",
|
||||
"[ 19/6 → 10/3 | n:2 note:E3 ]",
|
||||
"[ 10/3 → 7/2 | n:4 note:G3 ]",
|
||||
"[ 7/2 → 11/3 | n:6 note:B3 ]",
|
||||
"[ 11/3 → 23/6 | n:4 note:G3 ]",
|
||||
"[ 23/6 → 4/1 | n:2 note:E3 ]",
|
||||
"[ 0/1 → 1/6 | note:C3 ]",
|
||||
"[ 1/6 → 1/3 | note:E3 ]",
|
||||
"[ 1/3 → 1/2 | note:G3 ]",
|
||||
"[ 1/2 → 2/3 | note:B3 ]",
|
||||
"[ 2/3 → 5/6 | note:G3 ]",
|
||||
"[ 5/6 → 1/1 | note:E3 ]",
|
||||
"[ 1/1 → 7/6 | note:C3 ]",
|
||||
"[ 7/6 → 4/3 | note:E3 ]",
|
||||
"[ 4/3 → 3/2 | note:G3 ]",
|
||||
"[ 3/2 → 5/3 | note:B3 ]",
|
||||
"[ 5/3 → 11/6 | note:G3 ]",
|
||||
"[ 11/6 → 2/1 | note:E3 ]",
|
||||
"[ 2/1 → 13/6 | note:C3 ]",
|
||||
"[ 13/6 → 7/3 | note:E3 ]",
|
||||
"[ 7/3 → 5/2 | note:G3 ]",
|
||||
"[ 5/2 → 8/3 | note:B3 ]",
|
||||
"[ 8/3 → 17/6 | note:G3 ]",
|
||||
"[ 17/6 → 3/1 | note:E3 ]",
|
||||
"[ 3/1 → 19/6 | note:C3 ]",
|
||||
"[ 19/6 → 10/3 | note:E3 ]",
|
||||
"[ 10/3 → 7/2 | note:G3 ]",
|
||||
"[ 7/2 → 11/3 | note:B3 ]",
|
||||
"[ 11/3 → 23/6 | note:G3 ]",
|
||||
"[ 23/6 → 4/1 | note:E3 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "scale" example index 1 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/4 | n:0 note:C3 s:piano ]",
|
||||
"[ 0/1 → 1/4 | n:7 note:C4 s:piano ]",
|
||||
"[ 1/4 → 1/2 | n:4 note:G3 s:piano ]",
|
||||
"[ 1/2 → 3/4 | n:2 note:E3 s:piano ]",
|
||||
"[ 1/2 → 3/4 | n:7 note:C4 s:piano ]",
|
||||
"[ 3/4 → 1/1 | n:4 note:G3 s:piano ]",
|
||||
"[ 1/1 → 5/4 | n:0 note:C3 s:piano ]",
|
||||
"[ 1/1 → 5/4 | n:7 note:C4 s:piano ]",
|
||||
"[ 5/4 → 3/2 | n:4 note:G3 s:piano ]",
|
||||
"[ 3/2 → 7/4 | n:2 note:E3 s:piano ]",
|
||||
"[ 3/2 → 7/4 | n:7 note:C4 s:piano ]",
|
||||
"[ 7/4 → 2/1 | n:4 note:G3 s:piano ]",
|
||||
"[ 2/1 → 9/4 | n:0 note:C3 s:piano ]",
|
||||
"[ 2/1 → 9/4 | n:7 note:C4 s:piano ]",
|
||||
"[ 9/4 → 5/2 | n:4 note:G3 s:piano ]",
|
||||
"[ 5/2 → 11/4 | n:2 note:Eb3 s:piano ]",
|
||||
"[ 5/2 → 11/4 | n:7 note:C4 s:piano ]",
|
||||
"[ 11/4 → 3/1 | n:4 note:G3 s:piano ]",
|
||||
"[ 3/1 → 13/4 | n:0 note:C3 s:piano ]",
|
||||
"[ 3/1 → 13/4 | n:7 note:C4 s:piano ]",
|
||||
"[ 13/4 → 7/2 | n:4 note:G3 s:piano ]",
|
||||
"[ 7/2 → 15/4 | n:2 note:Eb3 s:piano ]",
|
||||
"[ 7/2 → 15/4 | n:7 note:C4 s:piano ]",
|
||||
"[ 15/4 → 4/1 | n:4 note:G3 s:piano ]",
|
||||
"[ 0/1 → 1/4 | note:C3 s:piano ]",
|
||||
"[ 0/1 → 1/4 | note:C4 s:piano ]",
|
||||
"[ 1/4 → 1/2 | note:G3 s:piano ]",
|
||||
"[ 1/2 → 3/4 | note:E3 s:piano ]",
|
||||
"[ 1/2 → 3/4 | note:C4 s:piano ]",
|
||||
"[ 3/4 → 1/1 | note:G3 s:piano ]",
|
||||
"[ 1/1 → 5/4 | note:C3 s:piano ]",
|
||||
"[ 1/1 → 5/4 | note:C4 s:piano ]",
|
||||
"[ 5/4 → 3/2 | note:G3 s:piano ]",
|
||||
"[ 3/2 → 7/4 | note:E3 s:piano ]",
|
||||
"[ 3/2 → 7/4 | note:C4 s:piano ]",
|
||||
"[ 7/4 → 2/1 | note:G3 s:piano ]",
|
||||
"[ 2/1 → 9/4 | note:C3 s:piano ]",
|
||||
"[ 2/1 → 9/4 | note:C4 s:piano ]",
|
||||
"[ 9/4 → 5/2 | note:G3 s:piano ]",
|
||||
"[ 5/2 → 11/4 | note:Eb3 s:piano ]",
|
||||
"[ 5/2 → 11/4 | note:C4 s:piano ]",
|
||||
"[ 11/4 → 3/1 | note:G3 s:piano ]",
|
||||
"[ 3/1 → 13/4 | note:C3 s:piano ]",
|
||||
"[ 3/1 → 13/4 | note:C4 s:piano ]",
|
||||
"[ 13/4 → 7/2 | note:G3 s:piano ]",
|
||||
"[ 7/2 → 15/4 | note:Eb3 s:piano ]",
|
||||
"[ 7/2 → 15/4 | note:C4 s:piano ]",
|
||||
"[ 15/4 → 4/1 | note:G3 s:piano ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "scale" example index 2 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/8 | n:10 note:C5 s:folkharp ]",
|
||||
"[ 1/8 → 1/4 | n:2 note:F3 s:folkharp ]",
|
||||
"[ 1/4 → 3/8 | n:7 note:F4 s:folkharp ]",
|
||||
"[ 3/8 → 1/2 | n:4 note:A3 s:folkharp ]",
|
||||
"[ 1/2 → 5/8 | n:2 note:F3 s:folkharp ]",
|
||||
"[ 5/8 → 3/4 | n:5 note:C4 s:folkharp ]",
|
||||
"[ 3/4 → 7/8 | n:9 note:A4 s:folkharp ]",
|
||||
"[ 7/8 → 1/1 | n:8 note:G4 s:folkharp ]",
|
||||
"[ 1/1 → 9/8 | n:7 note:F4 s:folkharp ]",
|
||||
"[ 9/8 → 5/4 | n:1 note:D3 s:folkharp ]",
|
||||
"[ 5/4 → 11/8 | n:1 note:D3 s:folkharp ]",
|
||||
"[ 11/8 → 3/2 | n:6 note:D4 s:folkharp ]",
|
||||
"[ 3/2 → 13/8 | n:2 note:F3 s:folkharp ]",
|
||||
"[ 13/8 → 7/4 | n:4 note:A3 s:folkharp ]",
|
||||
"[ 7/4 → 15/8 | n:6 note:D4 s:folkharp ]",
|
||||
"[ 15/8 → 2/1 | n:10 note:C5 s:folkharp ]",
|
||||
"[ 2/1 → 17/8 | n:4 note:A3 s:folkharp ]",
|
||||
"[ 17/8 → 9/4 | n:0 note:C3 s:folkharp ]",
|
||||
"[ 9/4 → 19/8 | n:8 note:G4 s:folkharp ]",
|
||||
"[ 19/8 → 5/2 | n:2 note:F3 s:folkharp ]",
|
||||
"[ 5/2 → 21/8 | n:7 note:F4 s:folkharp ]",
|
||||
"[ 21/8 → 11/4 | n:6 note:D4 s:folkharp ]",
|
||||
"[ 11/4 → 23/8 | n:11 note:D5 s:folkharp ]",
|
||||
"[ 23/8 → 3/1 | n:3 note:G3 s:folkharp ]",
|
||||
"[ 3/1 → 25/8 | n:0 note:C3 s:folkharp ]",
|
||||
"[ 25/8 → 13/4 | n:11 note:D5 s:folkharp ]",
|
||||
"[ 13/4 → 27/8 | n:4 note:A3 s:folkharp ]",
|
||||
"[ 27/8 → 7/2 | n:9 note:A4 s:folkharp ]",
|
||||
"[ 7/2 → 29/8 | n:10 note:C5 s:folkharp ]",
|
||||
"[ 29/8 → 15/4 | n:12 note:F5 s:folkharp ]",
|
||||
"[ 15/4 → 31/8 | n:1 note:D3 s:folkharp ]",
|
||||
"[ 31/8 → 4/1 | n:4 note:A3 s:folkharp ]",
|
||||
"[ 0/1 → 1/8 | note:C5 s:folkharp ]",
|
||||
"[ 1/8 → 1/4 | note:F3 s:folkharp ]",
|
||||
"[ 1/4 → 3/8 | note:F4 s:folkharp ]",
|
||||
"[ 3/8 → 1/2 | note:A3 s:folkharp ]",
|
||||
"[ 1/2 → 5/8 | note:F3 s:folkharp ]",
|
||||
"[ 5/8 → 3/4 | note:C4 s:folkharp ]",
|
||||
"[ 3/4 → 7/8 | note:A4 s:folkharp ]",
|
||||
"[ 7/8 → 1/1 | note:G4 s:folkharp ]",
|
||||
"[ 1/1 → 9/8 | note:F4 s:folkharp ]",
|
||||
"[ 9/8 → 5/4 | note:D3 s:folkharp ]",
|
||||
"[ 5/4 → 11/8 | note:D3 s:folkharp ]",
|
||||
"[ 11/8 → 3/2 | note:D4 s:folkharp ]",
|
||||
"[ 3/2 → 13/8 | note:F3 s:folkharp ]",
|
||||
"[ 13/8 → 7/4 | note:A3 s:folkharp ]",
|
||||
"[ 7/4 → 15/8 | note:D4 s:folkharp ]",
|
||||
"[ 15/8 → 2/1 | note:C5 s:folkharp ]",
|
||||
"[ 2/1 → 17/8 | note:A3 s:folkharp ]",
|
||||
"[ 17/8 → 9/4 | note:C3 s:folkharp ]",
|
||||
"[ 9/4 → 19/8 | note:G4 s:folkharp ]",
|
||||
"[ 19/8 → 5/2 | note:F3 s:folkharp ]",
|
||||
"[ 5/2 → 21/8 | note:F4 s:folkharp ]",
|
||||
"[ 21/8 → 11/4 | note:D4 s:folkharp ]",
|
||||
"[ 11/4 → 23/8 | note:D5 s:folkharp ]",
|
||||
"[ 23/8 → 3/1 | note:G3 s:folkharp ]",
|
||||
"[ 3/1 → 25/8 | note:C3 s:folkharp ]",
|
||||
"[ 25/8 → 13/4 | note:D5 s:folkharp ]",
|
||||
"[ 13/4 → 27/8 | note:A3 s:folkharp ]",
|
||||
"[ 27/8 → 7/2 | note:A4 s:folkharp ]",
|
||||
"[ 7/2 → 29/8 | note:C5 s:folkharp ]",
|
||||
"[ 29/8 → 15/4 | note:F5 s:folkharp ]",
|
||||
"[ 15/4 → 31/8 | note:D3 s:folkharp ]",
|
||||
"[ 31/8 → 4/1 | note:A3 s:folkharp ]",
|
||||
]
|
||||
`;
|
||||
|
||||
@ -4179,6 +4533,36 @@ exports[`runs examples > example "speed" example index 1 1`] = `
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "splice" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 5/26 | speed:0.65 unit:c begin:0 end:0.125 _slices:8 s:breaks165 ]",
|
||||
"[ 5/26 → 5/13 | speed:0.65 unit:c begin:0.125 end:0.25 _slices:8 s:breaks165 ]",
|
||||
"[ 5/13 → 20/39 | speed:0.9750000000000001 unit:c begin:0.25 end:0.375 _slices:8 s:breaks165 ]",
|
||||
"[ 20/39 → 25/39 | speed:0.9750000000000001 unit:c begin:0.375 end:0.5 _slices:8 s:breaks165 ]",
|
||||
"[ 25/39 → 10/13 | speed:0.9750000000000001 unit:c begin:0 end:0.125 _slices:8 s:breaks165 ]",
|
||||
"[ 10/13 → 25/26 | speed:0.65 unit:c begin:0.375 end:0.5 _slices:8 s:breaks165 ]",
|
||||
"[ (25/26 → 1/1) ⇝ 35/26 | speed:0.325 unit:c begin:0 end:0.125 _slices:8 s:breaks165 ]",
|
||||
"[ 25/26 ⇜ (1/1 → 35/26) | speed:0.325 unit:c begin:0 end:0.125 _slices:8 s:breaks165 ]",
|
||||
"[ 35/26 → 20/13 | speed:0.65 unit:c begin:0.875 end:1 _slices:8 s:breaks165 ]",
|
||||
"[ 20/13 → 45/26 | speed:0.65 unit:c begin:0 end:0.125 _slices:8 s:breaks165 ]",
|
||||
"[ 45/26 → 25/13 | speed:0.65 unit:c begin:0.125 end:0.25 _slices:8 s:breaks165 ]",
|
||||
"[ (25/13 → 2/1) ⇝ 80/39 | speed:0.9750000000000001 unit:c begin:0.25 end:0.375 _slices:8 s:breaks165 ]",
|
||||
"[ 25/13 ⇜ (2/1 → 80/39) | speed:0.9750000000000001 unit:c begin:0.25 end:0.375 _slices:8 s:breaks165 ]",
|
||||
"[ 80/39 → 85/39 | speed:0.9750000000000001 unit:c begin:0.375 end:0.5 _slices:8 s:breaks165 ]",
|
||||
"[ 85/39 → 30/13 | speed:0.9750000000000001 unit:c begin:0 end:0.125 _slices:8 s:breaks165 ]",
|
||||
"[ 30/13 → 5/2 | speed:0.65 unit:c begin:0.375 end:0.5 _slices:8 s:breaks165 ]",
|
||||
"[ 5/2 → 75/26 | speed:0.325 unit:c begin:0 end:0.125 _slices:8 s:breaks165 ]",
|
||||
"[ (75/26 → 3/1) ⇝ 40/13 | speed:0.65 unit:c begin:0.875 end:1 _slices:8 s:breaks165 ]",
|
||||
"[ 75/26 ⇜ (3/1 → 40/13) | speed:0.65 unit:c begin:0.875 end:1 _slices:8 s:breaks165 ]",
|
||||
"[ 40/13 → 85/26 | speed:0.65 unit:c begin:0 end:0.125 _slices:8 s:breaks165 ]",
|
||||
"[ 85/26 → 45/13 | speed:0.65 unit:c begin:0.125 end:0.25 _slices:8 s:breaks165 ]",
|
||||
"[ 45/13 → 140/39 | speed:0.9750000000000001 unit:c begin:0.25 end:0.375 _slices:8 s:breaks165 ]",
|
||||
"[ 140/39 → 145/39 | speed:0.9750000000000001 unit:c begin:0.375 end:0.5 _slices:8 s:breaks165 ]",
|
||||
"[ 145/39 → 50/13 | speed:0.9750000000000001 unit:c begin:0 end:0.125 _slices:8 s:breaks165 ]",
|
||||
"[ (50/13 → 4/1) ⇝ 105/26 | speed:0.65 unit:c begin:0.375 end:0.5 _slices:8 s:breaks165 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "square" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/2 | note:C3 ]",
|
||||
@ -4557,6 +4941,42 @@ exports[`runs examples > example "velocity" example index 0 1`] = `
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "vib" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/1 | note:a vib:0.5 ]",
|
||||
"[ 1/1 → 2/1 | note:a vib:1 ]",
|
||||
"[ 2/1 → 3/1 | note:a vib:2 ]",
|
||||
"[ 3/1 → 4/1 | note:a vib:4 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "vib" example index 1 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/1 | note:a vib:0.5 vibmod:12 ]",
|
||||
"[ 1/1 → 2/1 | note:a vib:1 vibmod:12 ]",
|
||||
"[ 2/1 → 3/1 | note:a vib:2 vibmod:12 ]",
|
||||
"[ 3/1 → 4/1 | note:a vib:4 vibmod:12 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "vibmod" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/1 | note:a vib:4 vibmod:0.25 ]",
|
||||
"[ 1/1 → 2/1 | note:a vib:4 vibmod:0.5 ]",
|
||||
"[ 2/1 → 3/1 | note:a vib:4 vibmod:1 ]",
|
||||
"[ 3/1 → 4/1 | note:a vib:4 vibmod:2 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "vibmod" example index 1 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/1 | note:a vibmod:0.25 vib:8 ]",
|
||||
"[ 1/1 → 2/1 | note:a vibmod:0.5 vib:8 ]",
|
||||
"[ 2/1 → 3/1 | note:a vibmod:1 vib:8 ]",
|
||||
"[ 3/1 → 4/1 | note:a vibmod:2 vib:8 ]",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`runs examples > example "voicing" example index 0 1`] = `
|
||||
[
|
||||
"[ 0/1 → 1/1 | note:E4 ]",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -28,6 +28,7 @@
|
||||
"@strudel.cycles/mini": "workspace:*",
|
||||
"@strudel.cycles/osc": "workspace:*",
|
||||
"@strudel.cycles/react": "workspace:*",
|
||||
"@strudel/codemirror": "workspace:*",
|
||||
"@strudel.cycles/serial": "workspace:*",
|
||||
"@strudel.cycles/soundfonts": "workspace:*",
|
||||
"@strudel.cycles/tonal": "workspace:*",
|
||||
|
||||
@ -70,12 +70,10 @@ export const SIDEBAR: Sidebar = {
|
||||
{ text: 'MIDI & OSC', link: 'learn/input-output' },
|
||||
],
|
||||
More: [
|
||||
{ text: 'Recipes', link: 'recipes/recipes' },
|
||||
{ text: 'Mini-Notation', link: 'learn/mini-notation' },
|
||||
{ text: 'Coding syntax', link: 'learn/code' },
|
||||
{ text: 'Offline', link: 'learn/pwa' },
|
||||
{ text: 'Patterns', link: 'technical-manual/patterns' },
|
||||
{ text: 'Pattern Alignment', link: 'technical-manual/alignment' },
|
||||
{ text: 'Strudel vs Tidal', link: 'learn/strudel-vs-tidal' },
|
||||
{ text: 'Music metadata', link: 'learn/metadata' },
|
||||
{ text: 'CSound', link: 'learn/csound' },
|
||||
],
|
||||
@ -89,7 +87,13 @@ export const SIDEBAR: Sidebar = {
|
||||
{ text: 'Accumulation', link: 'learn/accumulation' },
|
||||
{ text: 'Tonal Functions', link: 'learn/tonal' },
|
||||
],
|
||||
Understand: [{ text: 'Pitch', link: 'understand/pitch' }],
|
||||
Understand: [
|
||||
{ text: 'Coding syntax', link: 'learn/code' },
|
||||
{ text: 'Pitch', link: 'understand/pitch' },
|
||||
{ text: 'Cycles', link: 'understand/cycles' },
|
||||
{ text: 'Pattern Alignment', link: 'technical-manual/alignment' },
|
||||
{ text: 'Strudel vs Tidal', link: 'learn/strudel-vs-tidal' },
|
||||
],
|
||||
Development: [
|
||||
{ text: 'REPL', link: 'technical-manual/repl' },
|
||||
{ text: 'Sounds', link: 'technical-manual/sounds' },
|
||||
|
||||
@ -12,10 +12,11 @@ export function JsDoc({ name, h = 3, hideDescription, punchcard, canvasHeight })
|
||||
}
|
||||
const synonyms = getTag('synonyms', item)?.split(', ') || [];
|
||||
const CustomHeading = `h${h}`;
|
||||
const description = item.description.replaceAll(/\{@link ([a-zA-Z\.]+)?#?([a-zA-Z]*)\}/g, (_, a, b) => {
|
||||
// console.log(_, 'a', a, 'b', b);
|
||||
return `<a href="#${a.replaceAll('.', '').toLowerCase()}${b ? `-${b}` : ''}">${a}${b ? `#${b}` : ''}</a>`;
|
||||
});
|
||||
const description =
|
||||
item.description?.replaceAll(/\{@link ([a-zA-Z\.]+)?#?([a-zA-Z]*)\}/g, (_, a, b) => {
|
||||
// console.log(_, 'a', a, 'b', b);
|
||||
return `<a href="#${a.replaceAll('.', '').toLowerCase()}${b ? `-${b}` : ''}">${a}${b ? `#${b}` : ''}</a>`;
|
||||
}) || '';
|
||||
return (
|
||||
<>
|
||||
{!!h && <CustomHeading>{item.longname}</CustomHeading>}
|
||||
|
||||
@ -49,6 +49,10 @@ Each filter has 2 parameters:
|
||||
|
||||
<JsDoc client:idle name="bpq" h={0} />
|
||||
|
||||
## ftype
|
||||
|
||||
<JsDoc client:idle name="ftype" h={0} />
|
||||
|
||||
## vowel
|
||||
|
||||
<JsDoc client:idle name="vowel" h={0} />
|
||||
@ -78,6 +82,58 @@ Strudel uses ADSR envelopes, which are probably the most common way to describe
|
||||
|
||||
<JsDoc client:idle name="release" h={0} />
|
||||
|
||||
# Filter Envelope
|
||||
|
||||
Each filter can receive an additional filter envelope controlling the cutoff value dynamically. It uses an ADSR envelope similar to the one used for amplitude. There is an additional parameter to control the depth of the filter modulation: `lpenv`|`hpenv`|`bpenv`. This allows you to play subtle or huge filter modulations just the same by only increasing or decreasing the depth.
|
||||
|
||||
<MiniRepl
|
||||
client:idle
|
||||
tune={`note("[c eb g <f bb>](3,8,<0 1>)".sub(12))
|
||||
.s("<sawtooth>/64")
|
||||
.lpf(sine.range(500,3000).slow(16))
|
||||
.lpa(0.005)
|
||||
.lpd(perlin.range(.02,.2))
|
||||
.lps(perlin.range(0,.5).slow(3))
|
||||
.lpq(sine.range(2,10).slow(32))
|
||||
.release(.5)
|
||||
.lpenv(perlin.range(1,8).slow(2))
|
||||
.ftype('24db')
|
||||
.room(1)
|
||||
.juxBy(.5,rev)
|
||||
.sometimes(add(note(12)))
|
||||
.stack(s("bd*2").bank('RolandTR909'))
|
||||
.gain(.5)`}
|
||||
/>
|
||||
|
||||
There is one filter envelope for each filter type and thus one set of envelope filter parameters preceded either by `lp`, `hp` or `bp`:
|
||||
|
||||
- `lpattack`, `lpdecay`, `lpsustain`, `lprelease`, `lpenv`: filter envelope for the lowpass filter.
|
||||
- alternatively: `lpa`, `lpd`, `lps`, `lpr` and `lpe`.
|
||||
- `hpattack`, `hpdecay`, `hpsustain`, `hprelease`, `hpenv`: filter envelope for the highpass filter.
|
||||
- alternatively: `hpa`, `hpd`, `hps`, `hpr` and `hpe`.
|
||||
- `bpattack`, `bpdecay`, `bpsustain`, `bprelease`, `bpenv`: filter envelope for the bandpass filter.
|
||||
- alternatively: `bpa`, `bpd`, `bps`, `bpr` and `bpe`.
|
||||
|
||||
## lpattack
|
||||
|
||||
<JsDoc client:idle name="lpattack" h={0} />
|
||||
|
||||
## lpdecay
|
||||
|
||||
<JsDoc client:idle name="lpdecay" h={0} />
|
||||
|
||||
## lpsustain
|
||||
|
||||
<JsDoc client:idle name="lpsustain" h={0} />
|
||||
|
||||
## lprelease
|
||||
|
||||
<JsDoc client:idle name="lprelease" h={0} />
|
||||
|
||||
## lpenv
|
||||
|
||||
<JsDoc client:idle name="lpenv" h={0} />
|
||||
|
||||
# Dynamics
|
||||
|
||||
## gain
|
||||
@ -88,6 +144,14 @@ Strudel uses ADSR envelopes, which are probably the most common way to describe
|
||||
|
||||
<JsDoc client:idle name="velocity" h={0} />
|
||||
|
||||
## compressor
|
||||
|
||||
<JsDoc client:idle name="compressor" h={0} />
|
||||
|
||||
## postgain
|
||||
|
||||
<JsDoc client:idle name="postgain" h={0} />
|
||||
|
||||
# Panning
|
||||
|
||||
## jux
|
||||
@ -127,24 +191,44 @@ global effects use the same chain for all events of the same orbit:
|
||||
|
||||
<JsDoc client:idle name="orbit" h={0} />
|
||||
|
||||
## delay
|
||||
## Delay
|
||||
|
||||
### delay
|
||||
|
||||
<JsDoc client:idle name="delay" h={0} />
|
||||
|
||||
## delaytime
|
||||
### delaytime
|
||||
|
||||
<JsDoc client:idle name="delaytime" h={0} />
|
||||
|
||||
## delayfeedback
|
||||
### delayfeedback
|
||||
|
||||
<JsDoc client:idle name="delayfeedback" h={0} />
|
||||
|
||||
## room
|
||||
## Reverb
|
||||
|
||||
### room
|
||||
|
||||
<JsDoc client:idle name="room" h={0} />
|
||||
|
||||
## roomsize
|
||||
### roomsize
|
||||
|
||||
<JsDoc client:idle name="roomsize" h={0} />
|
||||
|
||||
### roomfade
|
||||
|
||||
<JsDoc client:idle name="roomfade" h={0} />
|
||||
|
||||
### roomlp
|
||||
|
||||
<JsDoc client:idle name="roomlp" h={0} />
|
||||
|
||||
### roomdim
|
||||
|
||||
<JsDoc client:idle name="roomdim" h={0} />
|
||||
|
||||
### iresponse
|
||||
|
||||
<JsDoc client:idle name="iresponse" h={0} />
|
||||
|
||||
Next, we'll look at strudel's support for [Csound](/learn/csound).
|
||||
|
||||
@ -303,6 +303,18 @@ Sampler effects are functions that can be used to change the behaviour of sample
|
||||
|
||||
<JsDoc client:idle name="Pattern.end" h={0} />
|
||||
|
||||
### loop
|
||||
|
||||
<JsDoc client:idle name="loop" h={0} />
|
||||
|
||||
### loopBegin
|
||||
|
||||
<JsDoc client:idle name="loopBegin" h={0} />
|
||||
|
||||
### loopEnd
|
||||
|
||||
<JsDoc client:idle name="loopEnd" h={0} />
|
||||
|
||||
### cut
|
||||
|
||||
<JsDoc client:idle name="cut" h={0} />
|
||||
@ -315,6 +327,10 @@ Sampler effects are functions that can be used to change the behaviour of sample
|
||||
|
||||
<JsDoc client:idle name="Pattern.loopAt" h={0} />
|
||||
|
||||
### fit
|
||||
|
||||
<JsDoc client:idle name="fit" h={0} />
|
||||
|
||||
### chop
|
||||
|
||||
<JsDoc client:idle name="Pattern.chop" h={0} />
|
||||
@ -323,6 +339,10 @@ Sampler effects are functions that can be used to change the behaviour of sample
|
||||
|
||||
<JsDoc client:idle name="Pattern.slice" h={0} />
|
||||
|
||||
### splice
|
||||
|
||||
<JsDoc client:idle name="splice" h={0} />
|
||||
|
||||
### speed
|
||||
|
||||
<JsDoc client:idle name="speed" h={0} />
|
||||
|
||||
@ -23,6 +23,25 @@ The basic waveforms are `sine`, `sawtooth`, `square` and `triangle`, which can b
|
||||
|
||||
If you don't set a `sound` but a `note` the default value for `sound` is `triangle`!
|
||||
|
||||
## Noise
|
||||
|
||||
You can also use noise as a source by setting the waveform to: `white`, `pink` or `brown`. These are different
|
||||
flavours of noise, here written from hard to soft.
|
||||
|
||||
<MiniRepl client:idle tune={`sound("<white pink brown>/2").scope()`} />
|
||||
|
||||
Here's a more musical example of how to use noise for hihats:
|
||||
|
||||
<MiniRepl
|
||||
client:idle
|
||||
tune={`sound("bd*2,<white pink brown>*8")
|
||||
.decay(.04).sustain(0).scope()`}
|
||||
/>
|
||||
|
||||
Some amount of pink noise can also be added to any oscillator by using the `noise` paremeter:
|
||||
|
||||
<MiniRepl client:idle tune={`note("c3").noise("<0.1 0.25 0.5>").scope()`} />
|
||||
|
||||
### Additive Synthesis
|
||||
|
||||
To tame the harsh sound of the basic waveforms, we can set the `n` control to limit the overtones of the waveform:
|
||||
@ -48,6 +67,16 @@ You can also set `n` directly in mini notation with `sound`:
|
||||
Note for tidal users: `n` in tidal is synonymous to `note` for synths only.
|
||||
In strudel, this is not the case, where `n` will always change timbre, be it though different samples or different waveforms.
|
||||
|
||||
## Vibrato
|
||||
|
||||
### vib
|
||||
|
||||
<JsDoc client:idle name="vib" h={0} />
|
||||
|
||||
### vibmod
|
||||
|
||||
<JsDoc client:idle name="vibmod" h={0} />
|
||||
|
||||
## FM Synthesis
|
||||
|
||||
FM Synthesis is a technique that changes the frequency of a basic waveform rapidly to alter the timbre.
|
||||
@ -78,6 +107,23 @@ You can use fm with any of the above waveforms, although the below examples all
|
||||
|
||||
<JsDoc client:idle name="fmenv" h={0} />
|
||||
|
||||
## Wavetable Synthesis
|
||||
|
||||
Strudel can also use the sampler to load custom waveforms as a replacement of the default waveforms used by WebAudio for the base synth. A default set of more than 1000 wavetables is accessible by default (coming from the [AKWF](https://www.adventurekid.se/akrt/waveforms/adventure-kid-waveforms/) set). You can also import/use your own. A wavetable is a one-cycle waveform, which is then repeated to create a sound at the desired frequency. It is a classic but very effective synthesis technique.
|
||||
|
||||
Any sample preceded by the `wt_` prefix will be loaded as a wavetable. This means that the `loop` argument will be set to `1` by defalt. You can scan over the wavetable by using `loopBegin` and `loopEnd` as well.
|
||||
|
||||
<MiniRepl
|
||||
client:idle
|
||||
tune={`samples('github:Bubobubobubobubo/Dough-Waveforms/main/');
|
||||
|
||||
note("<[g3,b3,e4]!2 [a3,c3,e4] [b3,d3,f#4]>")
|
||||
.n("<1 2 3 4 5 6 7 8 9 10>/2").room(0.5).size(0.9)
|
||||
.s('wt_flute').velocity(0.25).often(n => n.ply(2))
|
||||
.release(0.125).decay("<0.1 0.25 0.3 0.4>").sustain(0)
|
||||
.cutoff(2000).scope({}).cutoff("<1000 2000 4000>").fast(2)`}
|
||||
/>
|
||||
|
||||
## ZZFX
|
||||
|
||||
The "Zuper Zmall Zound Zynth" [ZZFX](https://github.com/KilledByAPixel/ZzFX) is also integrated in strudel.
|
||||
|
||||
312
website/src/pages/recipes/recipes.mdx
Normal file
312
website/src/pages/recipes/recipes.mdx
Normal file
@ -0,0 +1,312 @@
|
||||
---
|
||||
title: Recipes
|
||||
layout: ../../layouts/MainLayout.astro
|
||||
---
|
||||
|
||||
import { MiniRepl } from '../../docs/MiniRepl';
|
||||
|
||||
# Recipes
|
||||
|
||||
This page shows possible ways to achieve common (or not so common) musical goals.
|
||||
There are often many ways to do a thing and there is no right or wrong.
|
||||
The fun part is that each representation will give you different impulses when improvising.
|
||||
|
||||
## Arpeggios
|
||||
|
||||
An arpeggio is when the notes of a chord are played in sequence.
|
||||
We can either write the notes by hand:
|
||||
|
||||
<MiniRepl
|
||||
client:visible
|
||||
tune={`note("c eb g c4")
|
||||
.clip(2).s("gm_electric_guitar_clean")`}
|
||||
punchcard
|
||||
/>
|
||||
|
||||
...or use scales:
|
||||
|
||||
<MiniRepl
|
||||
client:visible
|
||||
tune={`n("0 2 4 7").scale("C:minor")
|
||||
.clip(2).s("gm_electric_guitar_clean")`}
|
||||
punchcard
|
||||
/>
|
||||
|
||||
...or chord symbols:
|
||||
|
||||
<MiniRepl
|
||||
client:visible
|
||||
tune={`n("0 1 2 3").chord("Cm").mode("above:c3").voicing()
|
||||
.clip(2).s("gm_electric_guitar_clean")`}
|
||||
punchcard
|
||||
/>
|
||||
|
||||
...using off:
|
||||
|
||||
<MiniRepl
|
||||
client:visible
|
||||
tune={`"0"
|
||||
.off(1/3, add(2))
|
||||
.off(1/2, add(4))
|
||||
.n()
|
||||
.scale("C:minor")
|
||||
.s("gm_electric_guitar_clean")`}
|
||||
punchcard
|
||||
/>
|
||||
|
||||
## Chopping Breaks
|
||||
|
||||
A sample can be looped and chopped like this:
|
||||
|
||||
<MiniRepl
|
||||
client:visible
|
||||
tune={`await samples('github:yaxu/clean-breaks/main')
|
||||
s("amen/8").fit().chop(16)`}
|
||||
punchcard
|
||||
/>
|
||||
|
||||
This fits the break into 8 cycles + chops it in 16 pieces.
|
||||
The chops are not audible yet, because we're not doing any manipulation.
|
||||
Let's add randmized doubling + reversing:
|
||||
|
||||
<MiniRepl
|
||||
client:visible
|
||||
tune={`await samples('github:yaxu/clean-breaks/main')
|
||||
s("amen/8").fit().chop(16).cut(1)
|
||||
.sometimesBy(.5, ply(2))
|
||||
.sometimesBy(.25, mul(speed(-1)))`}
|
||||
punchcard
|
||||
/>
|
||||
|
||||
If we want to specify the order of samples, we can replace `chop` with `slice`:
|
||||
|
||||
<MiniRepl
|
||||
client:visible
|
||||
tune={`await samples('github:yaxu/clean-breaks/main')
|
||||
s("amen/8").fit()
|
||||
.slice(8, "<0 1 2 3 4*2 5 6 [6 7]>")
|
||||
.cut(1).rarely(ply(2))`}
|
||||
punchcard
|
||||
/>
|
||||
|
||||
If we use `splice` instead of `slice`, the speed adjusts to the duration of the event:
|
||||
|
||||
<MiniRepl
|
||||
client:visible
|
||||
tune={`await samples('github:yaxu/clean-breaks/main')
|
||||
s("amen")
|
||||
.splice(8, "<0 1 2 3 4*2 5 6 [6 7]>")
|
||||
.cut(1).rarely(ply(2))`}
|
||||
punchcard
|
||||
/>
|
||||
|
||||
Note that we don't need `fit`, because `splice` will do that by itself.
|
||||
|
||||
## Filter Envelopes
|
||||
|
||||
A minimal filter envelope looks like this:
|
||||
|
||||
<MiniRepl
|
||||
client:visible
|
||||
tune={`note("g1 bb1 <c2 eb2> d2")
|
||||
.s("sawtooth")
|
||||
.lpf(400).lpa(.2).lpenv(4)
|
||||
.scope()`}
|
||||
/>
|
||||
|
||||
We can flip the envelope by setting `lpenv` negative + add some resonance `lpq`:
|
||||
|
||||
<MiniRepl
|
||||
client:visible
|
||||
tune={`note("g1 bb1 <c2 eb2> d2")
|
||||
.s("sawtooth").lpq(8)
|
||||
.lpf(400).lpa(.2).lpenv(-4)
|
||||
.scope()`}
|
||||
/>
|
||||
|
||||
## Layering Sounds
|
||||
|
||||
We can layer sounds by separating them with ",":
|
||||
|
||||
<MiniRepl
|
||||
client:visible
|
||||
tune={`note("<g1 bb1 d2 f1>")
|
||||
.s("sawtooth, square") // <------
|
||||
.scope()`}
|
||||
/>
|
||||
|
||||
We can control the gain of individual sounds like this:
|
||||
|
||||
<MiniRepl
|
||||
client:visible
|
||||
tune={`note("<g1 bb1 d2 f1>")
|
||||
.s("sawtooth, square:0:.5") // <--- "name:number:gain"
|
||||
.scope()`}
|
||||
/>
|
||||
|
||||
For more control over each voice, we can use `layer`:
|
||||
|
||||
<MiniRepl
|
||||
client:visible
|
||||
tune={`note("<g1 bb1 d2 f1>").layer(
|
||||
x=>x.s("sawtooth").vib(4),
|
||||
x=>x.s("square").add(note(12))
|
||||
).scope()`}
|
||||
/>
|
||||
|
||||
Here, we give the sawtooth a vibrato and the square is moved an octave up.
|
||||
With `layer`, you can use any pattern method available on each voice, so sky is the limit..
|
||||
|
||||
## Oscillator Detune
|
||||
|
||||
We can fatten a sound by adding a detuned version to itself:
|
||||
|
||||
<MiniRepl
|
||||
client:visible
|
||||
tune={`note("<g1 bb1 d2 f1>")
|
||||
.add(note("0,.1")) // <------ chorus
|
||||
.s("sawtooth").scope()`}
|
||||
punchcard
|
||||
/>
|
||||
|
||||
Try out different values, or add another voice!
|
||||
|
||||
## Polyrhythms
|
||||
|
||||
Here is a simple example of a polyrhythm:
|
||||
|
||||
<MiniRepl client:visible tune={`s("bd*2,hh*3")`} punchcard />
|
||||
|
||||
A polyrhythm is when 2 different tempos happen at the same time.
|
||||
|
||||
## Polymeter
|
||||
|
||||
This is a polymeter:
|
||||
|
||||
<MiniRepl client:visible tune={`s("<bd rim>,<hh hh oh>").fast(2)`} punchcard />
|
||||
|
||||
A polymeter is when 2 different bar lengths play at the same tempo.
|
||||
|
||||
## Phasing
|
||||
|
||||
This is a phasing:
|
||||
|
||||
<MiniRepl client:visible tune={`note("<C D G A Bb D C A G D Bb A>*[6,6.1]").piano()`} punchcard />
|
||||
|
||||
Phasing happens when the same sequence plays at slightly different tempos.
|
||||
|
||||
## Running through samples
|
||||
|
||||
Using `run` with `n`, we can rush through a sample bank:
|
||||
|
||||
<MiniRepl
|
||||
client:visible
|
||||
tune={`await samples('github:Bubobubobubobubo/Dough-Fox/main')
|
||||
n(run(8)).s("ftabla")`}
|
||||
punchcard
|
||||
/>
|
||||
|
||||
This works great with sample banks that contain similar sounds, like in this case different recordings of a tabla.
|
||||
Often times, you'll hear the beginning of the phrase not where the pattern begins.
|
||||
In this case, I hear the beginning at the third sample, which can be accounted for with `early`.
|
||||
|
||||
<MiniRepl
|
||||
client:visible
|
||||
tune={`await samples('github:Bubobubobubobubo/Dough-Fox/main')
|
||||
n(run(8)).s("ftabla").early(2/8)`}
|
||||
/>
|
||||
|
||||
Let's add some randomness:
|
||||
|
||||
<MiniRepl
|
||||
client:visible
|
||||
tune={`await samples('github:Bubobubobubobubo/Dough-Fox/main')
|
||||
n(run(8)).s("ftabla").early(2/8)
|
||||
.sometimes(mul(speed(1.5)))`}
|
||||
/>
|
||||
|
||||
## Tape Warble
|
||||
|
||||
We can emulate a pitch warbling effect like this:
|
||||
|
||||
<MiniRepl
|
||||
client:visible
|
||||
tune={`note("c4 bb f eb")
|
||||
.add(note(perlin.range(0,.5))) // <------ warble
|
||||
.clip(2).s("gm_electric_guitar_clean")`}
|
||||
/>
|
||||
|
||||
## Sound Duration
|
||||
|
||||
There are a number of ways to change the sound duration. Using clip:
|
||||
|
||||
<MiniRepl
|
||||
client:visible
|
||||
tune={`note("f ab bb c")
|
||||
.clip("<2 1 .5 .25>/2")`}
|
||||
/>
|
||||
|
||||
The value of clip is relative to the duration of each event.
|
||||
We can also create overlaps using release:
|
||||
|
||||
<MiniRepl
|
||||
client:visible
|
||||
tune={`note("f ab bb c")
|
||||
.release("<2 1 .5 .002>/2")`}
|
||||
/>
|
||||
|
||||
This will smoothly fade out each sound for the given number of seconds.
|
||||
We could also make the notes shorter with decay / sustain:
|
||||
|
||||
<MiniRepl
|
||||
client:visible
|
||||
tune={`note("f ab bb c")
|
||||
.decay("<.2 .1 .02>/2").sustain(0)`}
|
||||
/>
|
||||
|
||||
For now, there is a limitation where decay values that exceed the event duration may cause little cracks, so use higher numbers with caution..
|
||||
|
||||
When using samples, we also have `.end` to cut relative to the sample length:
|
||||
|
||||
<MiniRepl client:visible tune={`s("oh*4").end("<1 .5 .25 .1>")`} />
|
||||
|
||||
Compare that to clip:
|
||||
|
||||
<MiniRepl client:visible tune={`s("oh*4").clip("<1 .5 .25 .1>")`} />
|
||||
|
||||
or decay / sustain
|
||||
|
||||
<MiniRepl client:visible tune={`s("oh*4").decay("<.2 .12 .06 .01>").sustain(0)`} />
|
||||
|
||||
## Wavetable Synthesis
|
||||
|
||||
You can loop a sample with `loop` / `loopEnd`:
|
||||
|
||||
<MiniRepl client:visible tune={`note("<c eb g f>").s("bd").loop(1).loopEnd(.05).gain(.2)`} />
|
||||
|
||||
This allows us to play the first 5% of the bass drum as a synth!
|
||||
To simplify loading wavetables, any sample that starts with `wt_` will be looped automatically:
|
||||
|
||||
<MiniRepl
|
||||
client:visible
|
||||
tune={`await samples('github:bubobubobubobubo/dough-waveforms/main')
|
||||
note("c eb g bb").s("wt_dbass").clip(2)`}
|
||||
/>
|
||||
|
||||
Running through different wavetables can also give interesting variations:
|
||||
|
||||
<MiniRepl
|
||||
client:visible
|
||||
tune={`await samples('github:bubobubobubobubo/dough-waveforms/main')
|
||||
note("c2*8").s("wt_dbass").n(run(8))`}
|
||||
/>
|
||||
|
||||
...adding a filter envelope + reverb:
|
||||
|
||||
<MiniRepl
|
||||
client:visible
|
||||
tune={`await samples('github:bubobubobubobubo/dough-waveforms/main')
|
||||
note("c2*8").s("wt_dbass").n(run(8))
|
||||
.lpf(perlin.range(200,2000).slow(8))
|
||||
.lpenv(-3).lpa(.1).room(.5)`}
|
||||
/>
|
||||
130
website/src/pages/understand/cycles.mdx
Normal file
130
website/src/pages/understand/cycles.mdx
Normal file
@ -0,0 +1,130 @@
|
||||
---
|
||||
title: Understanding Cycles
|
||||
layout: ../../layouts/MainLayout.astro
|
||||
---
|
||||
|
||||
import { MiniRepl } from '../../docs/MiniRepl';
|
||||
import { PitchSlider } from '../../components/PitchSlider';
|
||||
import Box from '@components/Box.astro';
|
||||
|
||||
# Understanding Cycles
|
||||
|
||||
The concept of cycles is very central to be able to understand how Strudel works.
|
||||
Strudel's mother language, TidalCycles, even has it in its name.
|
||||
|
||||
## Cycles and BPM
|
||||
|
||||
In most music software, the unit BPM (beats per minute) is used to set the tempo.
|
||||
Strudel expresses tempo as CPS (cycles per second), with a default of 1CPS:
|
||||
|
||||
<MiniRepl client:visible tune={`s("bd")`} />
|
||||
|
||||
Here we can hear the 1CPS in action: The kick repeats once per second like a clock.
|
||||
We could say 1CPS = 1BPS (beats per second) = 60BPM. Let's add another kick:
|
||||
|
||||
<MiniRepl client:visible tune={`s("bd bd")`} />
|
||||
|
||||
Now we have 2 kicks per second, but the whole pattern still plays at 1CPS.
|
||||
In terms of BPM, most musicians would tell you this is playing at 120bpm.
|
||||
What about this one:
|
||||
|
||||
<MiniRepl client:visible tune={`s("bd hh")`} />
|
||||
|
||||
Because the second sound is now a hihat, the tempo feels slower again.
|
||||
This brings us to an important realization:
|
||||
|
||||
<Box>
|
||||
|
||||
Tempo is based on perception.
|
||||
The choice of sounds also has an impact on the tempo feel.
|
||||
This is why the same CPS can produce different perceived tempos.
|
||||
|
||||
</Box>
|
||||
|
||||
## Setting CPM
|
||||
|
||||
If you're familiar with BPM, you can use the `cpm` method to set the tempo in cycles per minute:
|
||||
|
||||
<MiniRepl client:visible tune={`s("bd hh").cpm(110)`} />
|
||||
|
||||
If you want to add more beats per cycle, you might want to divide the cpm:
|
||||
|
||||
<MiniRepl client:visible tune={`s("bd sd bd rim, hh*8").cpm(110/4)`} />
|
||||
|
||||
Or using 2 beats per cycle:
|
||||
|
||||
<MiniRepl client:visible tune={`s("bd sd, hh*4").cpm(110/2)`} />
|
||||
|
||||
<Box>
|
||||
|
||||
To set a specific bpm, use `.cpm(bpm/bpc)`
|
||||
|
||||
- bpm: the target beats per minute
|
||||
- bpc: the number of perceived beats per cycle
|
||||
|
||||
</Box>
|
||||
|
||||
## Cycles and Bars
|
||||
|
||||
Also in most music software, multiple beats form a bar (or measure).
|
||||
The so called time signature specifies how many beats are in each bar.
|
||||
In many types of music, it is common to use 4 beats per bar, also known as 4/4 time.
|
||||
Many music programs use it as a default.
|
||||
|
||||
Strudel does not a have concept of bars or measures, there are only cycles.
|
||||
How you use them is up to you. Above, we've had this example:
|
||||
|
||||
<MiniRepl client:visible tune={`s("bd sd bd rim, hh*8").cpm(110/4)`} />
|
||||
|
||||
This could be interpreted as 4/4 time with a tempo of 110bpm.
|
||||
We could write out multiple bars like this:
|
||||
|
||||
<MiniRepl
|
||||
client:visible
|
||||
tune={`s(\`<
|
||||
[bd sd bd rim, hh*8]
|
||||
[bd sd bd rim*2, hh*8]
|
||||
>\`).cpm(110/4)`}
|
||||
/>
|
||||
|
||||
Instead of writing out each bar separately, we could express this much shorter:
|
||||
|
||||
<MiniRepl client:visible tune={`s("bd <sd rim*<1 2>>,hh*4").cpm(110/2)`} />
|
||||
|
||||
Here we can see that thinking in cycles rather than bars simplifies things a lot!
|
||||
These types of simplifications work because of the repetitive nature of rhythm.
|
||||
In computational terms, you could say the former notation has a lot of redundancy.
|
||||
|
||||
## Time Signatures
|
||||
|
||||
To get a time signature, just change the number of elements per bar. Here is a rhythm with 7 beats:
|
||||
|
||||
<MiniRepl client:visible tune={`s("bd ~ rim bd bd rim ~")`} />
|
||||
|
||||
or with 5:
|
||||
|
||||
<MiniRepl client:visible tune={`s("<bd hh hh bd hh hh bd rim bd hh>*5")`} />
|
||||
|
||||
We could also write multiple bars with different time signatures:
|
||||
|
||||
<MiniRepl
|
||||
client:visible
|
||||
tune={`s(\`<
|
||||
[bd hh rim]@3
|
||||
[bd hh rim sd]@4
|
||||
>\`).cpm(110*2)`}
|
||||
/>
|
||||
|
||||
Here we switch between 3/4 and 4/4, keeping the same tempo.
|
||||
|
||||
If we don't specify the length, we get what's called a metric modulation:
|
||||
|
||||
<MiniRepl
|
||||
client:visible
|
||||
tune={`s(\`<
|
||||
[bd hh rim]
|
||||
[bd hh rim sd]
|
||||
>\`).cpm(110/2)`}
|
||||
/>
|
||||
|
||||
Now the 3 elements get the same time as the 4 elements, which is why the tempo changes.
|
||||
@ -22,6 +22,7 @@ import Loader from './Loader';
|
||||
import { settingPatterns } from '../settings.mjs';
|
||||
import { code2hash, hash2code } from './helpers.mjs';
|
||||
import { isTauri } from '../tauri.mjs';
|
||||
import { useWidgets } from '@strudel.cycles/react/src/hooks/useWidgets.mjs';
|
||||
|
||||
const { latestCode } = settingsMap.get();
|
||||
|
||||
@ -33,25 +34,26 @@ const supabase = createClient(
|
||||
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InBpZHhkc3hwaGxoempuem1pZnRoIiwicm9sZSI6ImFub24iLCJpYXQiOjE2NTYyMzA1NTYsImV4cCI6MTk3MTgwNjU1Nn0.bqlw7802fsWRnqU5BLYtmXk_k-D1VFmbkHMywWc15NM',
|
||||
);
|
||||
|
||||
const modules = [
|
||||
let modules = [
|
||||
import('@strudel.cycles/core'),
|
||||
import('@strudel.cycles/tonal'),
|
||||
import('@strudel.cycles/mini'),
|
||||
import('@strudel.cycles/xen'),
|
||||
import('@strudel.cycles/webaudio'),
|
||||
import('@strudel/codemirror'),
|
||||
|
||||
import('@strudel.cycles/serial'),
|
||||
import('@strudel.cycles/soundfonts'),
|
||||
import('@strudel.cycles/csound'),
|
||||
];
|
||||
if (isTauri()) {
|
||||
modules.concat([
|
||||
modules = modules.concat([
|
||||
import('@strudel/desktopbridge/loggerbridge.mjs'),
|
||||
import('@strudel/desktopbridge/midibridge.mjs'),
|
||||
import('@strudel/desktopbridge/oscbridge.mjs'),
|
||||
]);
|
||||
} else {
|
||||
modules.concat([import('@strudel.cycles/midi'), import('@strudel.cycles/osc')]);
|
||||
modules = modules.concat([import('@strudel.cycles/midi'), import('@strudel.cycles/osc')]);
|
||||
}
|
||||
|
||||
const modulesLoading = evalScope(
|
||||
@ -128,7 +130,7 @@ export function Repl({ embedded = false }) {
|
||||
} = useSettings();
|
||||
|
||||
const paintOptions = useMemo(() => ({ fontFamily }), [fontFamily]);
|
||||
|
||||
const { setWidgets } = useWidgets(view);
|
||||
const { code, setCode, scheduler, evaluate, activateCode, isDirty, activeCode, pattern, started, stop, error } =
|
||||
useStrudel({
|
||||
initialCode: '// LOADING...',
|
||||
@ -142,6 +144,7 @@ export function Repl({ embedded = false }) {
|
||||
},
|
||||
afterEval: ({ code, meta }) => {
|
||||
setMiniLocations(meta.miniLocations);
|
||||
setWidgets(meta.widgets);
|
||||
setPending(false);
|
||||
setLatestCode(code);
|
||||
window.location.hash = '#' + code2hash(code);
|
||||
@ -149,7 +152,14 @@ export function Repl({ embedded = false }) {
|
||||
onEvalError: (err) => {
|
||||
setPending(false);
|
||||
},
|
||||
onToggle: (play) => !play && cleanupDraw(false),
|
||||
onToggle: (play) => {
|
||||
if (!play) {
|
||||
cleanupDraw(false);
|
||||
window.postMessage('strudel-stop');
|
||||
} else {
|
||||
window.postMessage('strudel-start');
|
||||
}
|
||||
},
|
||||
drawContext,
|
||||
// drawTime: [0, 6],
|
||||
paintOptions,
|
||||
@ -212,7 +222,7 @@ export function Repl({ embedded = false }) {
|
||||
const handleChangeCode = useCallback(
|
||||
(c) => {
|
||||
setCode(c);
|
||||
started && logger('[edit] code changed. hit ctrl+enter to update');
|
||||
//started && logger('[edit] code changed. hit ctrl+enter to update');
|
||||
},
|
||||
[started],
|
||||
);
|
||||
|
||||
@ -229,7 +229,9 @@ stack(
|
||||
.add("0,.02")
|
||||
.note().gain(.3)
|
||||
.clip("<1@3 [.3 1]>/2")
|
||||
.s('sawtooth').cutoff(600).color('#F8E71C'),
|
||||
.cutoff(600)
|
||||
.lpa(.2).lpenv(-4)
|
||||
.s('sawtooth').color('#F8E71C'),
|
||||
).fast(3/2)
|
||||
//.pianoroll({fold:1})`;
|
||||
|
||||
@ -430,7 +432,7 @@ export const waa2 = `// "Waa2"
|
||||
// @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||
// @by Felix Roos
|
||||
|
||||
n(
|
||||
note(
|
||||
"a4 [a3 c3] a3 c3"
|
||||
.sub("<7 12 5 12>".slow(2))
|
||||
.off(1/4,x=>x.add(7))
|
||||
@ -442,7 +444,7 @@ n(
|
||||
.cutoff(cosine.range(500,4000).slow(16))
|
||||
.gain(.5)
|
||||
.room(.5)
|
||||
`;
|
||||
.lpa(.125).lpenv(-2).v("8:.125").fanchor(.25)`;
|
||||
|
||||
export const hyperpop = `// "Hyperpop"
|
||||
// @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||
@ -468,7 +470,9 @@ stack(
|
||||
.note()
|
||||
.s("sawtooth,square")
|
||||
.gain(.3).attack(0.01).decay(0.1).sustain(.5)
|
||||
.apply(filter1),
|
||||
.apply(filter1)
|
||||
.lpa(.1).lpenv(2).ftype('24db')
|
||||
,
|
||||
"~@3 [<2 3>,<4 5>]"
|
||||
.echo(4,1/16,.7)
|
||||
.scale(scales)
|
||||
@ -537,6 +541,7 @@ stack(
|
||||
.s('sawtooth') // waveform
|
||||
.gain(.4) // turn down
|
||||
.cutoff(sine.slow(7).range(300,5000)) // automate cutoff
|
||||
.lpa(.1).lpenv(-2)
|
||||
//.hush()
|
||||
,chord("<Am7!3 <Em7 E7b13 Em7 Ebm7b5>>")
|
||||
.dict('lefthand').voicing() // chords
|
||||
@ -559,6 +564,7 @@ stack(
|
||||
)
|
||||
.slow(3/2)`;
|
||||
|
||||
/*
|
||||
export const outroMusic = `// "Outro music"
|
||||
// @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||
// @by Felix Roos
|
||||
@ -576,8 +582,8 @@ chord("<C^7 Am7 Dm7 G7>*2").dict('lefthand').anchor("G4").voicing()
|
||||
.s("gm_epiano1:1")
|
||||
.color('steelblue')
|
||||
.stack(
|
||||
n("<-7 ~@2 [~@2 -7] -9 ~@2 [~@2 -9] -10!2 ~ [~@2 -10] -5 ~ [-3 -2 -10]@2>*2")
|
||||
.scale('C3 major')
|
||||
"<-7 ~@2 [~@2 -7] -9 ~@2 [~@2 -9] -10!2 ~ [~@2 -10] -5 ~ [-3 -2 -10]@2>*2"
|
||||
.scale('C3 major').note()
|
||||
.s('sawtooth').color('brown')
|
||||
)
|
||||
.attack(0.05).decay(.1).sustain(.7)
|
||||
@ -589,7 +595,8 @@ chord("<C^7 Am7 Dm7 G7>*2").dict('lefthand').anchor("G4").voicing()
|
||||
.n(3).color('gray')
|
||||
).slow(3/2)
|
||||
//.pianoroll({autorange:1,vertical:1,fold:0})
|
||||
`;
|
||||
`;
|
||||
*/
|
||||
|
||||
export const bassFuge = `// "Bass fuge"
|
||||
// @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||
@ -772,7 +779,8 @@ stack(
|
||||
.gain("0.4,0.4(5,8,-1)"),
|
||||
|
||||
note("<0 2 5 3>".scale('G1 minor')).struct("x(5,8,-1)")
|
||||
.s('sawtooth').decay(.1).sustain(0),
|
||||
.s('sawtooth').decay(.1).sustain(0)
|
||||
.lpa(.1).lpenv(-4).lpf(800).lpq(8),
|
||||
|
||||
note("<G4 A4 Bb4 A4>,Bb3,D3").struct("~ x*2").s('square').clip(1)
|
||||
.cutoff(sine.range(500,4000).slow(16)).resonance(10)
|
||||
@ -803,14 +811,16 @@ stack(
|
||||
sine.add(saw.slow(4)).range(0,7).segment(8)
|
||||
.superimpose(x=>x.add(.1))
|
||||
.scale('G0 minor').note()
|
||||
.s("sawtooth").decay(.1).sustain(0)
|
||||
.gain(.4).cutoff(perlin.range(300,3000).slow(8)).resonance(10)
|
||||
.s("sawtooth")
|
||||
.gain(.4).decay(.1).sustain(0)
|
||||
.lpa(.1).lpenv(-4).lpq(10)
|
||||
.cutoff(perlin.range(300,3000).slow(8))
|
||||
.degradeBy("0 0.1 .5 .1")
|
||||
.rarely(add(note("12")))
|
||||
,
|
||||
// chord
|
||||
note("Bb3,D4".superimpose(x=>x.add(.2)))
|
||||
.s('sawtooth').cutoff(1000).struct("<~@3 [~ x]>")
|
||||
.s('sawtooth').lpf(1000).struct("<~@3 [~ x]>")
|
||||
.decay(.05).sustain(.0).delay(.8).delaytime(.125).room(.8)
|
||||
,
|
||||
// alien
|
||||
@ -827,8 +837,8 @@ note("c3 eb3 g3 bb3").palindrome()
|
||||
.s('sawtooth')
|
||||
.jux(x=>x.rev().color('green').s('sawtooth'))
|
||||
.off(1/4, x=>x.add(note("<7 12>/2")).slow(2).late(.005).s('triangle'))
|
||||
//.delay(.5)
|
||||
.fast(1).cutoff(sine.range(200,2000).slow(8))
|
||||
.lpf(sine.range(200,2000).slow(8))
|
||||
.lpa(.2).lpenv(-2)
|
||||
.decay(.05).sustain(0)
|
||||
.room(.6)
|
||||
.delay(.5).delaytime(.1).delayfeedback(.4)
|
||||
@ -907,7 +917,13 @@ n("[0,3] 2 [1,3] 2".fast(3).lastOf(4, fast(2))).clip(2)
|
||||
.delay(.2)
|
||||
.room(.5).pan(sine.range(.3,.6))
|
||||
.s('piano')
|
||||
.stack("<<A1 C2>!2 F2 [F2 E2]>".add.out("0 -5".fast(2)).add("0,.12").note().s('sawtooth').clip(1).cutoff(300))
|
||||
.stack(
|
||||
"<<A1 C2>!2 F2 F2>"
|
||||
.add.out("0 -5".fast(2))
|
||||
.add("0,.12").note()
|
||||
.s('sawtooth').cutoff(180)
|
||||
.lpa(.1).lpenv(2)
|
||||
)
|
||||
.slow(4)
|
||||
.stack(s("bd*4, [~ [hh hh? hh?]]*2,~ [sd ~ [sd:2? bd?]]").bank('RolandTR909').gain(.5).slow(2))
|
||||
`;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user