1import { Pattern, noteToMidi, valueToMidi } from '@strudel/core'; 2 3const maxPan = noteToMidi('C8'); 4const panwidth = (pan, width) => pan * width + (1 - width) / 2; 5 6Pattern.prototype.piano = function () { 7 return this.clip(1) 8 .s('piano') 9 .release(0.1) 10 .fmap((value) => { 11 const midi = valueToMidi(value); 12 // pan by pitch 13 const pan = panwidth(Math.min(Math.round(midi) / maxPan, 1), 0.5); 14 return { ...value, pan: (value.pan || 1) * pan }; 15 }); 16};