mirror of
https://github.com/eliasstepanik/strudel.git
synced 2026-01-13 14:48:32 +00:00
17 lines
492 B
JavaScript
17 lines
492 B
JavaScript
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 };
|
|
});
|
|
};
|