Skip to content
Snippets Groups Projects
Commit 3baa0f47 authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #11828: audiofile: fix broken build

parent 6f135ee2
Branches
Tags
No related merge requests found
...@@ -109,7 +109,7 @@ RawFile::RawFile(const std::string& name, sfl::AudioCodec *codec, unsigned int s ...@@ -109,7 +109,7 @@ RawFile::RawFile(const std::string& name, sfl::AudioCodec *codec, unsigned int s
} }
WaveFile::WaveFile(const std::string &fileName, int sampleRate) : AudioFile(fileName, sampleRate) WaveFile::WaveFile(const std::string &fileName, unsigned int sampleRate) : AudioFile(fileName, sampleRate)
{ {
const std::fstream fs(fileName.c_str(), std::ios_base::in); const std::fstream fs(fileName.c_str(), std::ios_base::in);
...@@ -174,7 +174,8 @@ WaveFile::WaveFile(const std::string &fileName, int sampleRate) : AudioFile(file ...@@ -174,7 +174,8 @@ WaveFile::WaveFile(const std::string &fileName, int sampleRate) : AudioFile(file
fileStream.read(data, sizeof data / sizeof *data); fileStream.read(data, sizeof data / sizeof *data);
// Samplerate converter initialized with 88200 sample long // Samplerate converter initialized with 88200 sample long
SamplerateConverter converter(std::max(fileRate, newRate)); const int rate = static_cast<SINT32>(sampleRate_);
SamplerateConverter converter(std::max(fileRate, rate));
// Get length of data from the header. // Get length of data from the header.
SINT32 bytes; SINT32 bytes;
...@@ -200,15 +201,13 @@ WaveFile::WaveFile(const std::string &fileName, int sampleRate) : AudioFile(file ...@@ -200,15 +201,13 @@ WaveFile::WaveFile(const std::string &fileName, int sampleRate) : AudioFile(file
nbSamples *= 0.5; nbSamples *= 0.5;
} }
if (fileRate != newRate) { if (fileRate != rate) {
const float ratio = newRate / (float) fileRate; const float ratio = sampleRate_ / (float) fileRate;
const int outSamples = ceil(nbSamples * ratio); const int outSamples = ceil(nbSamples * ratio);
size_ = outSamples; size_ = outSamples;
buffer_ = new SFLDataFormat[size_]; buffer_ = new SFLDataFormat[size_];
converter.resample(tempBuffer, buffer_, size_, fileRate, newRate, nbSamples); converter.resample(tempBuffer, buffer_, size_, fileRate, sampleRate_, nbSamples);
delete [] tempBuffer; delete [] tempBuffer;
} else } else
buffer_ = tempBuffer; buffer_ = tempBuffer;
sampleRate_ = newRate;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment