hotfix: regression of #196

- samples loaded as arrays would not be repitched
This commit is contained in:
Felix Roos 2022-09-10 23:19:23 +02:00
parent 88e1211762
commit a5f05b4715

View File

@ -70,6 +70,13 @@ const getSoundfontKey = (s) => {
const getSampleBufferSource = async (s, n, note) => {
let transpose = 0;
let midi;
if (note !== undefined) {
midi = typeof note === 'string' ? toMidi(note) : note;
transpose = midi - 36; // C3 is middle C
}
const ac = getAudioContext();
// is sample from loaded samples(..)
const samples = getLoadedSamples();
@ -90,8 +97,6 @@ const getSampleBufferSource = async (s, n, note) => {
if (!note) {
throw new Error('no note(...) set for sound', s);
}
const midi = typeof note === 'string' ? toMidi(note) : note;
transpose = midi - 36; // C3 is middle C
const midiDiff = (noteA) => toMidi(noteA) - midi;
// object format will expect keys as notes
const closest = Object.keys(bank)