-
Notifications
You must be signed in to change notification settings - Fork 2
/
wav_file.h
36 lines (31 loc) · 872 Bytes
/
wav_file.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#pragma once
#include <string>
#include <fstream>
#include <vector>
#include <limits>
#define WAV_INVALID_VAL 0xFFFFFFFFu
class wav_file {
public:
wav_file(const std::string& path);
~wav_file();
void readData(size_t location, double *data, size_t len);
private:
std::ifstream ifs;
std::streampos dataChunkPos;
std::streampos dataChunkEndPos;
size_t loadedChunk = WAV_INVALID_VAL;
std::vector<double> loadBuffer;
size_t loadBufferBlock = std::numeric_limits<size_t>::max();
enum class format_type {
u8, s16, s24, s32,
f32, f64,
} fmt;
uint32_t fmt_size() const;
public:
uint32_t loopStart = 0; // samples
uint32_t loopEnd = std::numeric_limits<uint32_t>::max(); // samples
bool loopEnabled = false;
double tuning = 0.0; // cents
uint8_t midiKey = 60;
uint32_t sampleRate;
};