@@ -6,6 +6,7 @@ import { warn } from "../../core/util/Debug";
66
77export interface MeterOptions extends MeterBaseOptions {
88 smoothing : NormalRange ;
9+ normalRange : boolean ;
910}
1011
1112/**
@@ -27,6 +28,13 @@ export class Meter extends MeterBase<MeterOptions> {
2728
2829 readonly name : string = "Meter" ;
2930
31+ /**
32+ * If the output should be in decibels or normal range between 0-1. If `normalRange` is false,
33+ * the output range will be the measured decibel value, otherwise the decibel value will be converted to
34+ * the range of 0-1
35+ */
36+ normalRange : boolean ;
37+
3038 /**
3139 * A value from between 0 and 1 where 0 represents no time averaging with the last analysis frame.
3240 */
@@ -49,11 +57,13 @@ export class Meter extends MeterBase<MeterOptions> {
4957 this . smoothing = options . smoothing ;
5058 this . _analyser . size = 256 ;
5159 this . _analyser . type = "waveform" ;
60+ this . normalRange = options . normalRange ;
5261 }
5362
5463 static getDefaults ( ) : MeterOptions {
5564 return Object . assign ( MeterBase . getDefaults ( ) , {
5665 smoothing : 0.8 ,
66+ normalRange : false ,
5767 } ) ;
5868 }
5969
@@ -76,7 +86,7 @@ export class Meter extends MeterBase<MeterOptions> {
7686 // the rms can only fall at the rate of the smoothing
7787 // but can jump up instantly
7888 this . _rms = Math . max ( rms , this . _rms * this . smoothing ) ;
79- return gainToDb ( this . _rms ) ;
89+ return this . normalRange ? this . _rms : gainToDb ( this . _rms ) ;
8090 }
8191
8292 dispose ( ) : this {
0 commit comments