2021-12-20 00:19:35 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "miniaudio.h"
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
class SampleReader {
|
|
|
|
private:
|
|
|
|
SampleReader();
|
|
|
|
public:
|
|
|
|
//returns nullptr on error
|
|
|
|
static SampleReader* createSampleReader(const std::string& filepath);
|
|
|
|
~SampleReader();
|
|
|
|
|
|
|
|
void setWidth(uint32_t w);
|
|
|
|
|
|
|
|
float readSample(uint32_t pos);
|
2021-12-20 15:59:03 +01:00
|
|
|
uint64_t getLength(); // length of the sample in ms
|
2021-12-20 00:19:35 +01:00
|
|
|
private:
|
|
|
|
ma_decoder decoder;
|
|
|
|
|
|
|
|
uint32_t width = 1;
|
|
|
|
uint64_t decoderSize = 0;
|
|
|
|
uint32_t stepSize = 0;
|
|
|
|
};
|