Mercurial > hg > svcore
changeset 1286:40c042780bc9 3.0-integration
A bit more diagnostic info
author | Chris Cannam |
---|---|
date | Wed, 23 Nov 2016 14:34:27 +0000 |
parents | 757a406dabc4 |
children | 97f21b03269b |
files | data/fileio/CodedAudioFileReader.cpp data/fileio/CodedAudioFileReader.h |
diffstat | 2 files changed, 29 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/data/fileio/CodedAudioFileReader.cpp Wed Nov 23 13:57:36 2016 +0000 +++ b/data/fileio/CodedAudioFileReader.cpp Wed Nov 23 14:34:27 2016 +0000 @@ -49,7 +49,8 @@ m_max(0.f), m_gain(1.f), m_clippedCount(0), - m_firstNonzero(0) + m_firstNonzero(0), + m_lastNonzero(0) { SVDEBUG << "CodedAudioFileReader:: cache mode: " << cacheMode << " (" << (cacheMode == CacheInTemporaryFile @@ -346,7 +347,7 @@ SVDEBUG << "CodedAudioFileReader: Signal abs max is " << m_max << ", " << m_clippedCount << " samples clipped, first non-zero frame is at " - << m_firstNonzero << endl; + << m_firstNonzero << ", last at " << m_lastNonzero << endl; if (m_normalised) { SVDEBUG << "CodedAudioFileReader: Normalising, gain is " << m_gain << endl; } @@ -375,38 +376,36 @@ float clip = 1.0; sv_frame_t count = sz * m_channelCount; - if (m_normalised) { - for (sv_frame_t i = 0; i < count; ++i) { - float v = fabsf(buffer[i]); - if (m_firstNonzero == 0 && v != 0.f) { - m_firstNonzero = m_frameCount + i; + for (sv_frame_t j = 0; j < sz; ++j) { + for (int c = 0; c < m_channelCount; ++c) { + sv_frame_t i = j * m_channelCount + c; + float v = buffer[i]; + if (!m_normalised) { + if (v > clip) { + buffer[i] = clip; + ++m_clippedCount; + } else if (v < -clip) { + buffer[i] = -clip; + ++m_clippedCount; + } } - if (v > m_max) { - m_max = v; - m_gain = 1.f / m_max; + v = fabsf(v); + if (v != 0.f) { + if (m_firstNonzero == 0) { + m_firstNonzero = m_frameCount; + } + m_lastNonzero = m_frameCount; + if (v > m_max) { + m_max = v; + } } } - } else { - for (sv_frame_t i = 0; i < count; ++i) { - float v = buffer[i]; - if (v > clip) { - buffer[i] = clip; - ++m_clippedCount; - } else if (v < -clip) { - buffer[i] = -clip; - ++m_clippedCount; - } - v = fabsf(v); - if (m_firstNonzero == 0 && v != 0.f) { - m_firstNonzero = m_frameCount + i; - } - if (v > m_max) { - m_max = v; - } - } + ++m_frameCount; } - m_frameCount += sz; + if (m_max > 0.f) { + m_gain = 1.f / m_max; // used when normalising only + } switch (m_cacheMode) {