Fixing density and adding documentation

This commit is contained in:
Raphael Forment 2023-11-17 13:18:49 +01:00
parent 476bda812e
commit fb28083ce6
5 changed files with 22 additions and 4 deletions

View file

@ -35,7 +35,8 @@ function getNoiseBuffer(type, density) {
output[i] *= 0.11;
b6 = white * 0.115926;
} else if (type === 'crackle') {
if (Math.random() < (Math.random() * (density - 0.001) + density).toFixed(4)) {
const probability = density * 0.01
if (Math.random() < probability) {
output[i] = Math.random() * 2 - 1;
} else {
output[i] = 0;

View file

@ -241,6 +241,7 @@ export const superdough = async (value, deadline, hapDuration) => {
source,
gain = 0.8,
postgain = 1,
density = 0.03,
// filters
ftype = '12db',
fanchor = 0.5,

View file

@ -36,7 +36,8 @@ export function registerSynthSounds() {
if (waveforms.includes(s)) {
sound = getOscillator(s, t, value);
} else {
sound = getNoiseOscillator(s, t, 0.002);
let { density } = value;
sound = getNoiseOscillator(s, t, density);
}
let { node: o, stop, triggerRelease } = sound;