Cleanup
This commit is contained in:
parent
7cf9db4872
commit
bd73d96847
2 changed files with 38 additions and 35 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
|
import { logger } from './logger.mjs';
|
||||||
|
import { getNoiseBuffer } from './noise.mjs';
|
||||||
import { getAudioContext } from './superdough.mjs';
|
import { getAudioContext } from './superdough.mjs';
|
||||||
import { clamp, nanFallback, midiToFreq, noteToMidi } from './util.mjs';
|
import { clamp, nanFallback, midiToFreq, noteToMidi } from './util.mjs';
|
||||||
import { getNoiseBuffer } from './noise.mjs';
|
|
||||||
|
|
||||||
export const noises = ['pink', 'white', 'brown', 'crackle'];
|
export const noises = ['pink', 'white', 'brown', 'crackle'];
|
||||||
|
|
||||||
|
|
@ -328,7 +329,7 @@ const mod = (freq, type = 'sine') => {
|
||||||
const fm = (frequencyparam, harmonicityRatio, modulationIndex, wave = 'sine') => {
|
const fm = (frequencyparam, harmonicityRatio, modulationIndex, wave = 'sine') => {
|
||||||
const carrfreq = frequencyparam.value;
|
const carrfreq = frequencyparam.value;
|
||||||
const modfreq = carrfreq * harmonicityRatio;
|
const modfreq = carrfreq * harmonicityRatio;
|
||||||
return mod(modfreq, wave)
|
return mod(modfreq, wave);
|
||||||
};
|
};
|
||||||
|
|
||||||
export function applyFM(param, value, begin) {
|
export function applyFM(param, value, begin) {
|
||||||
|
|
@ -349,8 +350,10 @@ export function applyFM(param, value, begin) {
|
||||||
const amt = value[control];
|
const amt = value[control];
|
||||||
if (!amt) continue;
|
if (!amt) continue;
|
||||||
let io = [];
|
let io = [];
|
||||||
for (let [isMod, idx] of [[true, i], [false, j]]) {
|
for (let [isMod, idx] of [
|
||||||
debugger;
|
[true, i],
|
||||||
|
[false, j],
|
||||||
|
]) {
|
||||||
if (idx === 0) {
|
if (idx === 0) {
|
||||||
io.push(param);
|
io.push(param);
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -365,7 +368,7 @@ export function applyFM(param, value, begin) {
|
||||||
};
|
};
|
||||||
const adsr = ['attack', 'decay', 'sustain', 'release'].map((s) => value[`fm${s}${idxS}`]);
|
const adsr = ['attack', 'decay', 'sustain', 'release'].map((s) => value[`fm${s}${idxS}`]);
|
||||||
if (!adsr.some((v) => v !== undefined)) {
|
if (!adsr.some((v) => v !== undefined)) {
|
||||||
fms[idx] = { input: osc.frequency, output: osc, freq};
|
fms[idx] = { input: osc.frequency, output: osc, freq };
|
||||||
} else {
|
} else {
|
||||||
const envGain = ac.createGain();
|
const envGain = ac.createGain();
|
||||||
const [attack, decay, sustain, release] = getADSRValues(adsr);
|
const [attack, decay, sustain, release] = getADSRValues(adsr);
|
||||||
|
|
@ -383,7 +386,7 @@ export function applyFM(param, value, begin) {
|
||||||
holdEnd,
|
holdEnd,
|
||||||
fmEnvelopeType === 'exp' ? 'exponential' : 'linear',
|
fmEnvelopeType === 'exp' ? 'exponential' : 'linear',
|
||||||
);
|
);
|
||||||
fms[idx] = { input: osc.frequency, output: osc.connect(envGain), freq};
|
fms[idx] = { input: osc.frequency, output: osc.connect(envGain), freq };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const { input, output, freq } = fms[idx];
|
const { input, output, freq } = fms[idx];
|
||||||
|
|
|
||||||
|
|
@ -3880,35 +3880,6 @@ exports[`runs examples > example "floor" example index 0 1`] = `
|
||||||
]
|
]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`runs examples > example "fm" example index 0 1`] = `
|
|
||||||
[
|
|
||||||
"[ 0/1 → 1/6 | note:c fmi:0 ]",
|
|
||||||
"[ 1/6 → 1/3 | note:e fmi:0 ]",
|
|
||||||
"[ 1/3 → 1/2 | note:g fmi:0 ]",
|
|
||||||
"[ 1/2 → 2/3 | note:b fmi:0 ]",
|
|
||||||
"[ 2/3 → 5/6 | note:g fmi:0 ]",
|
|
||||||
"[ 5/6 → 1/1 | note:e fmi:0 ]",
|
|
||||||
"[ 1/1 → 7/6 | note:c fmi:1 ]",
|
|
||||||
"[ 7/6 → 4/3 | note:e fmi:1 ]",
|
|
||||||
"[ 4/3 → 3/2 | note:g fmi:1 ]",
|
|
||||||
"[ 3/2 → 5/3 | note:b fmi:1 ]",
|
|
||||||
"[ 5/3 → 11/6 | note:g fmi:1 ]",
|
|
||||||
"[ 11/6 → 2/1 | note:e fmi:1 ]",
|
|
||||||
"[ 2/1 → 13/6 | note:c fmi:2 ]",
|
|
||||||
"[ 13/6 → 7/3 | note:e fmi:2 ]",
|
|
||||||
"[ 7/3 → 5/2 | note:g fmi:2 ]",
|
|
||||||
"[ 5/2 → 8/3 | note:b fmi:2 ]",
|
|
||||||
"[ 8/3 → 17/6 | note:g fmi:2 ]",
|
|
||||||
"[ 17/6 → 3/1 | note:e fmi:2 ]",
|
|
||||||
"[ 3/1 → 19/6 | note:c fmi:8 ]",
|
|
||||||
"[ 19/6 → 10/3 | note:e fmi:8 ]",
|
|
||||||
"[ 10/3 → 7/2 | note:g fmi:8 ]",
|
|
||||||
"[ 7/2 → 11/3 | note:b fmi:8 ]",
|
|
||||||
"[ 11/3 → 23/6 | note:g fmi:8 ]",
|
|
||||||
"[ 23/6 → 4/1 | note:e fmi:8 ]",
|
|
||||||
]
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`runs examples > example "fmattack" example index 0 1`] = `
|
exports[`runs examples > example "fmattack" example index 0 1`] = `
|
||||||
[
|
[
|
||||||
"[ 0/1 → 1/6 | note:c fmi:4 fmattack:0 ]",
|
"[ 0/1 → 1/6 | note:c fmi:4 fmattack:0 ]",
|
||||||
|
|
@ -4025,6 +3996,35 @@ exports[`runs examples > example "fmh" example index 0 1`] = `
|
||||||
]
|
]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`runs examples > example "fmi" example index 0 1`] = `
|
||||||
|
[
|
||||||
|
"[ 0/1 → 1/6 | note:c fmi:0 ]",
|
||||||
|
"[ 1/6 → 1/3 | note:e fmi:0 ]",
|
||||||
|
"[ 1/3 → 1/2 | note:g fmi:0 ]",
|
||||||
|
"[ 1/2 → 2/3 | note:b fmi:0 ]",
|
||||||
|
"[ 2/3 → 5/6 | note:g fmi:0 ]",
|
||||||
|
"[ 5/6 → 1/1 | note:e fmi:0 ]",
|
||||||
|
"[ 1/1 → 7/6 | note:c fmi:1 ]",
|
||||||
|
"[ 7/6 → 4/3 | note:e fmi:1 ]",
|
||||||
|
"[ 4/3 → 3/2 | note:g fmi:1 ]",
|
||||||
|
"[ 3/2 → 5/3 | note:b fmi:1 ]",
|
||||||
|
"[ 5/3 → 11/6 | note:g fmi:1 ]",
|
||||||
|
"[ 11/6 → 2/1 | note:e fmi:1 ]",
|
||||||
|
"[ 2/1 → 13/6 | note:c fmi:2 ]",
|
||||||
|
"[ 13/6 → 7/3 | note:e fmi:2 ]",
|
||||||
|
"[ 7/3 → 5/2 | note:g fmi:2 ]",
|
||||||
|
"[ 5/2 → 8/3 | note:b fmi:2 ]",
|
||||||
|
"[ 8/3 → 17/6 | note:g fmi:2 ]",
|
||||||
|
"[ 17/6 → 3/1 | note:e fmi:2 ]",
|
||||||
|
"[ 3/1 → 19/6 | note:c fmi:8 ]",
|
||||||
|
"[ 19/6 → 10/3 | note:e fmi:8 ]",
|
||||||
|
"[ 10/3 → 7/2 | note:g fmi:8 ]",
|
||||||
|
"[ 7/2 → 11/3 | note:b fmi:8 ]",
|
||||||
|
"[ 11/3 → 23/6 | note:g fmi:8 ]",
|
||||||
|
"[ 23/6 → 4/1 | note:e fmi:8 ]",
|
||||||
|
]
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`runs examples > example "fmsustain" example index 0 1`] = `
|
exports[`runs examples > example "fmsustain" example index 0 1`] = `
|
||||||
[
|
[
|
||||||
"[ 0/1 → 1/6 | note:c fmi:4 fmdecay:0.1 fmsustain:1 ]",
|
"[ 0/1 → 1/6 | note:c fmi:4 fmdecay:0.1 fmsustain:1 ]",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue