Merge pull request #871 from daslyfe/bugfix_sample_select
bugfix: sound select indexes out of bounds
This commit is contained in:
commit
3760f51c3c
4 changed files with 32 additions and 8 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { noteToMidi, freqToMidi } from '@strudel.cycles/core';
|
||||
import { noteToMidi, freqToMidi, getSoundIndex } from '@strudel.cycles/core';
|
||||
import { getAudioContext, registerSound, getEnvelope } from '@strudel.cycles/webaudio';
|
||||
import gm from './gm.mjs';
|
||||
|
||||
|
|
@ -130,9 +130,9 @@ export function registerSoundfonts() {
|
|||
registerSound(
|
||||
name,
|
||||
async (time, value, onended) => {
|
||||
const { n = 0 } = value;
|
||||
const n = getSoundIndex(value.n, fonts.length);
|
||||
const { attack = 0.001, decay = 0.001, sustain = 1, release = 0.001 } = value;
|
||||
const font = fonts[n % fonts.length];
|
||||
const font = fonts[n];
|
||||
const ctx = getAudioContext();
|
||||
const bufferSource = await getFontBufferSource(font, value, ctx);
|
||||
bufferSource.start(time);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue