diff --git a/test/runtime.mjs b/test/runtime.mjs index 17e92954..47ebfe59 100644 --- a/test/runtime.mjs +++ b/test/runtime.mjs @@ -29,7 +29,7 @@ import '@strudel.cycles/xen/xen.mjs'; // import '@strudel.cycles/webaudio/webaudio.mjs'; // import '@strudel.cycles/serial/serial.mjs'; // import controls from '@strudel.cycles/core/controls.mjs'; -import '../website/src/repl/prebake'; +import '../website/src/repl/piano'; class MockedNode { chain() { diff --git a/website/src/repl/piano.mjs b/website/src/repl/piano.mjs new file mode 100644 index 00000000..bb849b20 --- /dev/null +++ b/website/src/repl/piano.mjs @@ -0,0 +1,16 @@ +import { Pattern, noteToMidi, valueToMidi } from '@strudel.cycles/core'; + +const maxPan = noteToMidi('C8'); +const panwidth = (pan, width) => pan * width + (1 - width) / 2; + +Pattern.prototype.piano = function () { + return this.clip(1) + .s('piano') + .release(0.1) + .fmap((value) => { + const midi = valueToMidi(value); + // pan by pitch + const pan = panwidth(Math.min(Math.round(midi) / maxPan, 1), 0.5); + return { ...value, pan: (value.pan || 1) * pan }; + }); +}; diff --git a/website/src/repl/prebake.mjs b/website/src/repl/prebake.mjs index 5cd57303..a9ad87c9 100644 --- a/website/src/repl/prebake.mjs +++ b/website/src/repl/prebake.mjs @@ -1,6 +1,7 @@ import { Pattern, noteToMidi, valueToMidi } from '@strudel.cycles/core'; import { registerSoundfonts } from '@strudel.cycles/soundfonts'; import { registerSynthSounds, samples } from '@strudel.cycles/webaudio'; +import './piano.mjs'; export async function prebake() { // https://archive.org/details/SalamanderGrandPianoV3