- feat: add freq support to gm soundfonts

- refactor: toMidi -> noteToMidi
- refactor: fromMidi -> midiToFreq
This commit is contained in:
Felix Roos 2023-03-23 10:18:24 +01:00
parent 13133583ca
commit ba35a81e9b
10 changed files with 59 additions and 50 deletions

View file

@ -1,4 +1,4 @@
import { logger, toMidi, valueToMidi } from '@strudel.cycles/core';
import { logger, noteToMidi, valueToMidi } from '@strudel.cycles/core';
import { getAudioContext, registerSound } from './index.mjs';
import { getEnvelope } from './helpers.mjs';
@ -34,7 +34,7 @@ export const getSampleBufferSource = async (s, n, note, speed, freq, bank) => {
if (Array.isArray(bank)) {
sampleUrl = bank[n % bank.length];
} else {
const midiDiff = (noteA) => toMidi(noteA) - midi;
const midiDiff = (noteA) => noteToMidi(noteA) - midi;
// object format will expect keys as notes
const closest = Object.keys(bank)
.filter((k) => !k.startsWith('_'))