Skip to content
Snippets Groups Projects
Commit 233ee37d authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#3757] Resample ringtone data

parent 3b20c2b5
Branches
Tags
No related merge requests found
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
*/ */
#include "audiofile.h" #include "audiofile.h"
#include "audio/codecs/codecDescriptor.h" #include "audio/codecs/codecDescriptor.h"
#include "audio/samplerateconverter.h"
#include <fstream> #include <fstream>
#include <math.h> #include <math.h>
#include <samplerate.h> #include <samplerate.h>
...@@ -196,10 +197,10 @@ WaveFile::~WaveFile() ...@@ -196,10 +197,10 @@ WaveFile::~WaveFile()
bool WaveFile::openFile (const std::string& fileName) bool WaveFile::openFile (const std::string& fileName, int audioSamplingRate)
{ {
if (isFileExist (fileName)) { if (isFileExist (fileName)) {
openExistingWaveFile (fileName); openExistingWaveFile (fileName, audioSamplingRate);
} }
return true; return true;
...@@ -244,9 +245,11 @@ bool WaveFile::isFileOpened() ...@@ -244,9 +245,11 @@ bool WaveFile::isFileOpened()
} }
bool WaveFile::openExistingWaveFile (const std::string& fileName) bool WaveFile::openExistingWaveFile (const std::string& fileName, int audioSamplingRate)
{ {
SamplerateConverter _converter;
_debug ("WaveFile: Opening %s", fileName.c_str()); _debug ("WaveFile: Opening %s", fileName.c_str());
_file_stream.open (fileName.c_str(), std::ios::in | std::ios::binary); _file_stream.open (fileName.c_str(), std::ios::in | std::ios::binary);
...@@ -365,6 +368,12 @@ bool WaveFile::openExistingWaveFile (const std::string& fileName) ...@@ -365,6 +368,12 @@ bool WaveFile::openExistingWaveFile (const std::string& fileName)
_debug ("WaveFile: data size in frame %ld", _file_size); _debug ("WaveFile: data size in frame %ld", _file_size);
SFLDataFormat *tempBuffer = new SFLDataFormat[_file_size];
SFLDataFormat *tempBufferRsmpl = new SFLDataFormat[_file_size];
// int nbSample = _converter.upsampleData ( tempBuffer, tempBufferRsmpl, audioSamplingRate, srate, nb_sample_down);
// Init audio loop buffer info // Init audio loop buffer info
_buffer = new SFLDataFormat[_file_size]; _buffer = new SFLDataFormat[_file_size];
_size = _file_size; _size = _file_size;
...@@ -375,6 +384,9 @@ bool WaveFile::openExistingWaveFile (const std::string& fileName) ...@@ -375,6 +384,9 @@ bool WaveFile::openExistingWaveFile (const std::string& fileName)
_debug ("WaveFile: file successfully opened"); _debug ("WaveFile: file successfully opened");
delete[] tempBuffer;
delete[] tempBufferRsmpl;
return true; return true;
} }
...@@ -383,7 +395,7 @@ bool WaveFile::openExistingWaveFile (const std::string& fileName) ...@@ -383,7 +395,7 @@ bool WaveFile::openExistingWaveFile (const std::string& fileName)
bool WaveFile::loadFile (const std::string& filename, AudioCodec *codec , unsigned int sampleRate) bool WaveFile::loadFile (const std::string& filename, AudioCodec *codec , unsigned int sampleRate)
{ {
openFile (filename); openFile (filename, sampleRate);
return true; return true;
} }
...@@ -140,7 +140,7 @@ class WaveFile : public AudioFile ...@@ -140,7 +140,7 @@ class WaveFile : public AudioFile
~WaveFile(); ~WaveFile();
bool openFile (const std::string& fileName); bool openFile (const std::string& fileName, int audioSamplingRate);
bool closeFile(); bool closeFile();
...@@ -161,7 +161,7 @@ class WaveFile : public AudioFile ...@@ -161,7 +161,7 @@ class WaveFile : public AudioFile
bool setWaveFile(); bool setWaveFile();
bool openExistingWaveFile (const std::string& fileName); bool openExistingWaveFile (const std::string& fileName, int audioSamplingRate);
SOUND_FORMAT _snd_format; SOUND_FORMAT _snd_format;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment