Merge branch 'main' into envelope_improvements

This commit is contained in:
Jade (Rose) Rowland 2023-12-31 11:51:49 -05:00 committed by GitHub
commit a800b32529
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
79 changed files with 4033 additions and 4306 deletions

View file

@ -1,4 +1,5 @@
import { noteToMidi, freqToMidi } from '@strudel.cycles/core';
import { noteToMidi, freqToMidi, getSoundIndex } from '@strudel.cycles/core';
import { getAudioContext, registerSound, getEnvelope, getADSRValues } from '@strudel.cycles/webaudio';
import gm from './gm.mjs';
@ -130,14 +131,14 @@ export function registerSoundfonts() {
registerSound(
name,
async (time, value, onended) => {
const { n = 0 } = value;
const [attack, decay, sustain, release] = getADSRValues([
value.attack,
value.decay,
value.sustain,
value.release,
]);
const font = fonts[n % fonts.length];
const n = getSoundIndex(value.n, fonts.length);
const font = fonts[n];
const ctx = getAudioContext();
const bufferSource = await getFontBufferSource(font, value, ctx);
bufferSource.start(time);