26 lines
469 B
C++
26 lines
469 B
C++
#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);
|
|
uint64_t getLength(); // length of the sample in ms
|
|
private:
|
|
ma_decoder decoder;
|
|
|
|
uint32_t width = 1;
|
|
uint64_t decoderSize = 0;
|
|
uint32_t stepSize = 0;
|
|
}; |