2015-10-11 19:06:05 +02:00
|
|
|
#ifndef WAVE_H
|
|
|
|
#define WAVE_H
|
|
|
|
|
2015-10-11 19:15:50 +02:00
|
|
|
#include <memory>
|
|
|
|
#include <mutex>
|
2015-10-11 19:06:05 +02:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include <ao/ao.h>
|
|
|
|
|
|
|
|
class Wave {
|
|
|
|
public:
|
|
|
|
|
|
|
|
using Raw = std::vector<char>;
|
|
|
|
|
|
|
|
static Wave fromFile(const std::string &filename);
|
|
|
|
Wave(int bits,
|
|
|
|
int channels,
|
|
|
|
int rate,
|
|
|
|
Raw data);
|
|
|
|
Wave(const Wave &rhs);
|
|
|
|
~Wave();
|
|
|
|
|
|
|
|
Wave &operator=(const Wave &rhs);
|
|
|
|
|
|
|
|
void play() const;
|
2015-10-11 19:15:50 +02:00
|
|
|
void playAsync() const;
|
2015-10-11 19:06:05 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2015-10-11 19:15:50 +02:00
|
|
|
mutable std::mutex _playMutex = { };
|
|
|
|
|
2015-10-11 19:06:05 +02:00
|
|
|
std::unique_ptr<ao_sample_format> _format;
|
|
|
|
ao_device* _device = { nullptr };
|
|
|
|
|
|
|
|
const Raw _data;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|