diff data/fileio/WavFileReader.cpp @ 1520:954d0cf29ca7 import-audio-data

Switch the normalisation option in WritableWaveFileModel from normalising on read to normalising on write, so that the saved file is already normalised and therefore can be read again without having to remember to normalise it
author Chris Cannam
date Wed, 12 Sep 2018 13:56:56 +0100
parents 75d92155fa20
children 70e172e6cc59 f8e3dcbafb4d
line wrap: on
line diff
--- a/data/fileio/WavFileReader.cpp	Tue Sep 11 14:36:51 2018 +0100
+++ b/data/fileio/WavFileReader.cpp	Wed Sep 12 13:56:56 2018 +0100
@@ -27,14 +27,14 @@
 
 WavFileReader::WavFileReader(FileSource source,
                              bool fileUpdating,
-                             bool normalise) :
+                             Normalisation normalisation) :
     m_file(0),
     m_source(source),
     m_path(source.getLocalFilename()),
     m_seekable(false),
     m_lastStart(0),
     m_lastCount(0),
-    m_normalise(normalise),
+    m_normalisation(normalisation),
     m_max(0.f),
     m_updating(fileUpdating)
 {
@@ -92,12 +92,12 @@
             m_seekable = true;
         }
 
-        if (m_normalise && !m_updating) {
+        if (m_normalisation != Normalisation::None && !m_updating) {
             m_max = getMax();
         }
     }
 
-    SVDEBUG << "WavFileReader: Filename " << m_path << ", frame count " << m_frameCount << ", channel count " << m_channelCount << ", sample rate " << m_sampleRate << ", format " << m_fileInfo.format << ", seekable " << m_fileInfo.seekable << " adjusted to " << m_seekable << ", normalise " << m_normalise << endl;
+    SVDEBUG << "WavFileReader: Filename " << m_path << ", frame count " << m_frameCount << ", channel count " << m_channelCount << ", sample rate " << m_sampleRate << ", format " << m_fileInfo.format << ", seekable " << m_fileInfo.seekable << " adjusted to " << m_seekable << ", normalisation " << int(m_normalisation) << endl;
 }
 
 WavFileReader::~WavFileReader()
@@ -144,7 +144,7 @@
 {
     updateFrameCount();
     m_updating = false;
-    if (m_normalise) {
+    if (m_normalisation != Normalisation::None) {
         m_max = getMax();
     }
 }
@@ -154,7 +154,7 @@
 {
     floatvec_t frames = getInterleavedFramesUnnormalised(start, count);
 
-    if (!m_normalise || m_max == 0.f) {
+    if (m_normalisation == Normalisation::None || m_max == 0.f) {
         return frames;
     }