From d486f7a976786d51e68e683bacd4a30f7413622d Mon Sep 17 00:00:00 2001 From: JulienH2000 Date: Wed, 6 Sep 2023 22:38:54 +0200 Subject: [PATCH] dbgain now using 'gain' to allow positive gain, clamped dbgain value below +10dB + corrected documentation --- src/classes/SoundEvent.ts | 2 +- src/documentation/engine.ts | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/classes/SoundEvent.ts b/src/classes/SoundEvent.ts index 202e08c..125c3eb 100644 --- a/src/classes/SoundEvent.ts +++ b/src/classes/SoundEvent.ts @@ -102,7 +102,7 @@ export class SoundEvent extends AudibleEvent { public begin = (value: number) => this.updateValue("begin", value); public end = (value: number) => this.updateValue("end", value); public gain = (value: number) => this.updateValue("gain", value); - public dbgain = (value: number) => this.updateValue("velocity", Math.pow(10, value / 20)); + public dbgain = (value: number) => this.updateValue("gain", Math.min(Math.pow(10, value / 20)), 0); public db = this.dbgain; public cutoff = (value: number) => this.updateValue("cutoff", value); public lpf = this.cutoff; diff --git a/src/documentation/engine.ts b/src/documentation/engine.ts index a7846ab..209aa10 100644 --- a/src/documentation/engine.ts +++ b/src/documentation/engine.ts @@ -136,11 +136,11 @@ There is a special method to choose the _orbit_ that your sound is going to use: Simple controls over the amplitude (volume) of a given sound. -| Method | Alias | Description | -|----------|-------|-----------------------------------------------------------------------------------| -| gain | | Volume of the synth/sample (exponential) | -| velocity | vel | Velocity (amplitude) from 0 to 1. Multipled with gain | -| dbgain | db | Attenuation in dB from -inf to 0 (acts as a sound mixer fader) | +| Method | Alias | Description | +|----------|-------|------------------------------------------------------------------------------------| +| gain | | Volume of the synth/sample (exponential) | +| velocity | vel | Velocity (amplitude) from 0 to 1. Multipled with gain | +| dbgain | db | Attenuation in dB from -inf to +10 (acts as a sound mixer fader) | ${makeExample( "Velocity manipulated by a counter",