Skip to content
Snippets Groups Projects
Commit 244fed54 authored by Emmanuel Lepage's avatar Emmanuel Lepage
Browse files
parents ead86bf6 6f135ee2
Branches
Tags
No related merge requests found
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
#include <cassert> #include <cassert>
#include "logger.h" #include "logger.h"
AudioLoop::AudioLoop() : buffer_(0), size_(0), pos_(0), sampleRate_(0), isRecording_(false) AudioLoop::AudioLoop(unsigned int sampleRate) : buffer_(0), size_(0), pos_(0), sampleRate_(sampleRate), isRecording_(false)
{} {}
AudioLoop::~AudioLoop() AudioLoop::~AudioLoop()
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
class AudioLoop { class AudioLoop {
public: public:
AudioLoop(); AudioLoop(unsigned int sampleRate);
virtual ~AudioLoop(); virtual ~AudioLoop();
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
#include "logger.h" #include "logger.h"
RawFile::RawFile(const std::string& name, sfl::AudioCodec *codec, unsigned int sampleRate) RawFile::RawFile(const std::string& name, sfl::AudioCodec *codec, unsigned int sampleRate)
: AudioFile(name), audioCodec_(codec) : AudioFile(name, sampleRate), audioCodec_(codec)
{ {
if (filepath_.empty()) if (filepath_.empty())
throw AudioFileException("Unable to open audio file: filename is empty"); throw AudioFileException("Unable to open audio file: filename is empty");
...@@ -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 newRate) : AudioFile(fileName) WaveFile::WaveFile(const std::string &fileName, 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);
......
...@@ -52,7 +52,9 @@ class AudioFileException : public std::runtime_error { ...@@ -52,7 +52,9 @@ class AudioFileException : public std::runtime_error {
*/ */
class AudioFile : public AudioLoop { class AudioFile : public AudioLoop {
public: public:
AudioFile(const std::string &filepath) : filepath_(filepath) {} AudioFile(const std::string &filepath, unsigned int sampleRate) : AudioLoop(sampleRate), filepath_(filepath)
{}
std::string getFilePath() const { std::string getFilePath() const {
return filepath_; return filepath_;
} }
...@@ -83,7 +85,7 @@ class WaveFile : public AudioFile { ...@@ -83,7 +85,7 @@ class WaveFile : public AudioFile {
* @param filename The absolute path to the file * @param filename The absolute path to the file
* @param sampleRate The sample rate to read it * @param sampleRate The sample rate to read it
*/ */
WaveFile(const std::string&, int); WaveFile(const std::string&, unsigned int sampleRate);
}; };
#endif // __AUDIOFILE_H__ #endif // __AUDIOFILE_H__
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
#include <vector> #include <vector>
Tone::Tone(const std::string& definition, unsigned int sampleRate) : Tone::Tone(const std::string& definition, unsigned int sampleRate) :
sampleRate_(sampleRate), xhigher_(0.0), xlower_(0.0) AudioLoop(sampleRate), xhigher_(0.0), xlower_(0.0)
{ {
fillWavetable(); fillWavetable();
genBuffer(definition); // allocate memory with definition parameter genBuffer(definition); // allocate memory with definition parameter
......
...@@ -83,9 +83,6 @@ class Tone : public AudioLoop { ...@@ -83,9 +83,6 @@ class Tone : public AudioLoop {
*/ */
void genBuffer(const std::string& definition); void genBuffer(const std::string& definition);
/** Sample rate */
unsigned int sampleRate_;
static const int TABLE_LENGTH = 4096; static const int TABLE_LENGTH = 4096;
double wavetable_[TABLE_LENGTH]; double wavetable_[TABLE_LENGTH];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment