fix: history
This commit is contained in:
parent
6bcf8b91cc
commit
88b5b9b21c
1 changed files with 7 additions and 7 deletions
|
|
@ -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(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue