File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -1684,11 +1684,19 @@ class VolumeMeter : public ModifyingStream {
1684
1684
// / Volume Ratio of indicated channel: max amplitude is 1.0
1685
1685
float volumeRatio (int channel) { return volume (channel) / NumberConverter::maxValue (info.bits_per_sample );}
1686
1686
1687
- // / Volume in db: max amplitude is 0
1688
- float volumeDB () { return 20 .0f * log10 (volumeRatio ());}
1687
+ // / Volume in db: max amplitude is 0 (range: -1000 to 0)
1688
+ float volumeDB () {
1689
+ // prevent infinite value
1690
+ if (volumeRatio ()==0 ) return -1000 ;
1691
+ return 20 .0f * log10 (volumeRatio ());
1692
+ }
1689
1693
1690
1694
// / Volume of indicated channel in db: max amplitude is 0
1691
- float volumeDB (int channel) { return 20 .0f * log10 (volumeRatio (channel));}
1695
+ float volumeDB (int channel) {
1696
+ // prevent infinite value
1697
+ if (volumeRatio (channel)==0 ) return -1000 ;
1698
+ return 20 .0f * log10 (volumeRatio (channel));
1699
+ }
1692
1700
1693
1701
// / Volume in %: max amplitude is 100
1694
1702
float volumePercent () { return 100 .0f * volumeRatio ();}
You can’t perform that action at this time.
0 commit comments