add freq support to sampler

This commit is contained in:
Felix Roos 2022-12-12 20:41:09 +01:00
parent 8b22c2e04f
commit df73ce8a60
5 changed files with 43 additions and 8 deletions

View file

@ -1,4 +1,4 @@
import { Pattern, toMidi } from '@strudel.cycles/core';
import { Pattern, toMidi, valueToMidi } from '@strudel.cycles/core';
import { samples } from '@strudel.cycles/webaudio';
export async function prebake({ isMock = false, baseDir = '.' } = {}) {
@ -25,9 +25,9 @@ Pattern.prototype.piano = function () {
.s('piano')
.release(0.1)
.fmap((value) => {
const midi = typeof value.note === 'string' ? toMidi(value.note) : value.note;
const midi = valueToMidi(value);
// pan by pitch
const pan = panwidth(Math.min(midi / maxPan, 1), 0.5);
const pan = panwidth(Math.min(Math.round(midi) / maxPan, 1), 0.5);
return { ...value, pan: (value.pan || 1) * pan };
});
};