-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwave.hpp
59 lines (51 loc) · 1.04 KB
/
wave.hpp
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#pragma once
#include "fmrs.hpp"
#pragma pack(push, 1)
typedef struct
{
char chunkID[4];
uint32_t chunkSize;
char chunkFormType[4];
} RIFF_CHUNK;
// RIFFチャンクの定義
typedef struct
{
char chunkID[4];
uint32_t chunkSize;
uint16_t waveFormatType;
uint16_t formatChannel;
uint32_t samplesPerSec;
uint32_t bytesPerSec;
uint16_t blockSize;
uint16_t bitsPerSample;
} FMT_CHUNK;
// fmtチャンクの定義
typedef struct
{
char chunkID[4];
uint32_t chunkSize;
} DATA_CHUNK;
// dataチャンクの定義
typedef struct
{
RIFF_CHUNK riffChunk;
FMT_CHUNK fmtChunk;
DATA_CHUNK dataChunk;
} WAVE_FORMAT_HEAD;
#pragma pack(pop)
class WaveData
{
private:
WAVE_FORMAT_HEAD header;
long header_endp;
std::vector<float> InterpolateSpline(const std::vector<float> &data);
template<typename T> void LoadData(std::ifstream &fin, int channel);
public:
std::vector<float> left;
std::vector<float> leftp;
std::vector<float> right;
std::vector<float> rightp;
long loaded_samples;
uint32_t samplerate;
WaveData(char *filename);
};