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);

View file

@ -36,7 +36,7 @@
"soundfont2": "^0.4.0"
},
"devDependencies": {
"node-fetch": "^3.3.1",
"vite": "^4.3.3"
"node-fetch": "^3.3.2",
"vite": "^5.0.10"
}
}

View file

@ -9,7 +9,7 @@ export default defineConfig({
lib: {
entry: resolve(__dirname, 'index.mjs'),
formats: ['es', 'cjs'],
fileName: (ext) => ({ es: 'index.mjs', cjs: 'index.js' }[ext]),
fileName: (ext) => ({ es: 'index.mjs', cjs: 'index.js' })[ext],
},
rollupOptions: {
external: [...Object.keys(dependencies)],