diff options
author | James Cowgill <jcowgill@debian.org> | 2018-06-17 09:48:25 +0100 |
---|---|---|
committer | James Cowgill <jcowgill@debian.org> | 2018-06-17 09:48:25 +0100 |
commit | 5dc6e89cb009da0ebe2a434f76db35414cd696ed (patch) | |
tree | 100f600b3db7a1a38a594b8fad9c7a5540eba116 /openmpt123 | |
parent | bec06ae5b9e0510f50f13e127be0f84ff529787d (diff) |
New upstream version 0.3.10
Diffstat (limited to 'openmpt123')
-rw-r--r-- | openmpt123/openmpt123.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/openmpt123/openmpt123.cpp b/openmpt123/openmpt123.cpp index c4d2160..5d9d82d 100644 --- a/openmpt123/openmpt123.cpp +++ b/openmpt123/openmpt123.cpp @@ -888,10 +888,16 @@ static const char * const channel_tags[4][4] = { }; static std::string channel_to_string( int channels, int channel, const meter_channel & meter, bool tiny = false ) { - float db = 20.0f * std::log10( meter.peak ); - float db_hold = 20.0f * std::log10( meter.hold ); - int val = static_cast<int>( db + 48.0f ); - int hold_pos = static_cast<int>( db_hold + 48.0f ); + int val = std::numeric_limits<int>::min(); + int hold_pos = std::numeric_limits<int>::min(); + if ( meter.peak > 0.0f ) { + float db = 20.0f * std::log10( meter.peak ); + val = static_cast<int>( db + 48.0f ); + } + if ( meter.hold > 0.0f ) { + float db_hold = 20.0f * std::log10( meter.hold ); + hold_pos = static_cast<int>( db_hold + 48.0f ); + } if ( val < 0 ) { val = 0; } @@ -911,13 +917,13 @@ static std::string channel_to_string( int channels, int channel, const meter_cha headroom = 0; } if ( tiny ) { - if ( meter.clip != 0.0f || db >= 0.0f ) { + if ( meter.clip != 0.0f || meter.peak >= 1.0f ) { return "#"; - } else if ( db > -6.0f ) { + } else if ( meter.peak > std::pow( 10.0f, -6.0f / 20.0f ) ) { return "O"; - } else if ( db > -12.0f ) { + } else if ( meter.peak > std::pow( 10.0f, -12.0f / 20.0f ) ) { return "o"; - } else if ( db > -18.0f ) { + } else if ( meter.peak > std::pow( 10.0f, -18.0f / 20.0f ) ) { return "."; } else { return " "; |