-
Notifications
You must be signed in to change notification settings - Fork 1
/
WAV.h
71 lines (55 loc) · 1.5 KB
/
WAV.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef __WAV_H__
#define __WAV_H__
#include "types.h"
#include <string>
#include "ByteBuffer.h"
using namespace std;
using namespace Utility;
namespace WAV_Class
{
// ============================================================================================
// Constants & Structs
// ============================================================================================
// Class WAV
class WAV
{
public:
WAV();
WAV(string filename);
WAV(const WAV& other);
~WAV();
void showInfo();
void clear();
bool loadFromFile(string filename);
bool saveToFile(string filename);
size_t getSize();
void normalize();
void envelopeCorrection();
struct Header {
BYTE riffId[4]; // "RIFF"
DWORD riffSize; // Size of chunk
BYTE waveId[4]; // "WAVE"
BYTE fmtId[4]; // "fmt "
DWORD fmtSize; // 16 for PCM
WORD wFormatTag; // PCM:1
WORD nChannels; // Mono:1 Stereo:2
DWORD nSamplesPerSec; // SampleRate: 8000, 44100, ...
DWORD nAvgBytesPerSec; // = SampleRate * NumChannels * BitsPerSample/8
WORD nBlockAlign; // = NumChannels * BitsPerSample/8
WORD wBitsPerSample; // 8:8bits 16:16bits
BYTE dataId[4]; // "data"
DWORD dataSize; // Size of data chunk
};
Header *header;
protected:
const char* MAGIC_RIFFID = "RIFF";
const char* MAGIC_WAVEID = "WAVE";
const char* MAGIC_FMTID = "fmt ";
const char* MAGIC_DATAID = "data";
int8_t *data;
size_t size;
bool phase = false;
friend class BlockRipper;
};
}
#endif //__WAV_H__