fix: history

This commit is contained in:
Felix Roos 2023-08-31 04:24:44 +02:00
parent 6bcf8b91cc
commit 88b5b9b21c

View file

@ -2,13 +2,6 @@ import { midiToFreq, noteToMidi } from './util.mjs';
import { registerSound, getAudioContext } from './superdough.mjs'; import { registerSound, getAudioContext } from './superdough.mjs';
import { getOscillator, gainNode, getEnvelope, getExpEnvelope } from './helpers.mjs'; import { getOscillator, gainNode, getEnvelope, getExpEnvelope } from './helpers.mjs';
const fm = (osc, harmonicityRatio, modulationIndex, wave) => {
const carrfreq = osc.frequency.value;
const modfreq = carrfreq * harmonicityRatio;
const modgain = modfreq * modulationIndex;
return mod(modfreq, modgain, wave);
};
const mod = (freq, range = 1, type) => { const mod = (freq, range = 1, type) => {
const ctx = getAudioContext(); const ctx = getAudioContext();
const osc = ctx.createOscillator(); const osc = ctx.createOscillator();
@ -20,6 +13,13 @@ const mod = (freq, range = 1, type) => {
return { node: g, stop: (t) => osc.stop(t) }; return { node: g, stop: (t) => osc.stop(t) };
}; };
const fm = (osc, harmonicityRatio, modulationIndex, wave) => {
const carrfreq = osc.frequency.value;
const modfreq = carrfreq * harmonicityRatio;
const modgain = modfreq * modulationIndex;
return mod(modfreq, modgain, wave);
};
export function registerSynthSounds() { export function registerSynthSounds() {
['sine', 'square', 'triangle', 'sawtooth'].forEach((wave) => { ['sine', 'square', 'triangle', 'sawtooth'].forEach((wave) => {
registerSound( registerSound(