comparison data/fileio/CodedAudioFileReader.cpp @ 1161:5b463c7727e5

Use float format for cached files in CodedAudioFileReader, to preserve internal representation (see comment)
author Chris Cannam
date Wed, 24 Feb 2016 10:28:47 +0000
parents 1517d4c60e88
children 6877f4200912
comparison
equal deleted inserted replaced
1158:d9c766274c8b 1161:5b463c7727e5
135 << m_sampleRate << " presented for writing, rounding to " << fileRate 135 << m_sampleRate << " presented for writing, rounding to " << fileRate
136 << endl; 136 << endl;
137 } 137 }
138 fileInfo.samplerate = fileRate; 138 fileInfo.samplerate = fileRate;
139 fileInfo.channels = m_channelCount; 139 fileInfo.channels = m_channelCount;
140 140
141 // No point in writing 24-bit or float; generally this 141 // Previously we were writing SF_FORMAT_PCM_16 and in a
142 // class is used for decoding files that have come from a 142 // comment I wrote: "No point in writing 24-bit or float;
143 // 16 bit source or that decode to only 16 bits anyway. 143 // generally this class is used for decoding files that
144 fileInfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16; 144 // have come from a 16 bit source or that decode to only
145 // 16 bits anyway." That was naive -- we want to preserve
146 // the original values to the same float precision that we
147 // use internally. Saving PCM_16 obviously doesn't
148 // preserve values for sources at bit depths greater than
149 // 16, but it also doesn't always do so for sources at bit
150 // depths less than 16.
151 //
152 // (This came to light with a bug in libsndfile 1.0.26,
153 // which always reports every file as non-seekable, so
154 // that coded readers were being used even for WAV
155 // files. This changed the values that came from PCM_8 WAV
156 // sources, breaking Sonic Annotator's output comparison
157 // tests.)
158 //
159 // So: now we write floats.
160 fileInfo.format = SF_FORMAT_WAV | SF_FORMAT_FLOAT;
145 161
146 m_cacheFileWritePtr = sf_open(m_cacheFileName.toLocal8Bit(), 162 m_cacheFileWritePtr = sf_open(m_cacheFileName.toLocal8Bit(),
147 SFM_WRITE, &fileInfo); 163 SFM_WRITE, &fileInfo);
148 164
149 if (m_cacheFileWritePtr) { 165 if (m_cacheFileWritePtr) {