-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWAVFile.h
More file actions
41 lines (35 loc) · 950 Bytes
/
WAVFile.h
File metadata and controls
41 lines (35 loc) · 950 Bytes
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
#include <stdio.h>
#include <stdint.h>
#ifndef WAV_READER_H
#define WAV_READER_H
#pragma pack(1)
typedef struct {
char riff[4];
uint32_t chunk_size;
char wave[4];
char fmt[4];
uint32_t fmtlen;
uint16_t fmtType;
uint16_t channels;
uint32_t sampleRate;
uint32_t byteRate;
uint16_t bytes_per_sample;
uint16_t bits_per_sample;
char data[4];
uint32_t data_size;
}WAVHeader;
typedef unsigned char WAVData;
typedef struct{
FILE *file;
WAVHeader* header;
long current_pos;
int offset;
WAVData* data;
}WAVFile;
WAVFile* WAVOpen(const char* file_path,const char* mode);
void WAVClose(WAVFile* file);
WAVData* WAVReader(WAVFile* wavfile,int size,int count);
double WAVPosInSec(WAVFile *file);
double WAVSeekInSec(WAVFile *file, float seconds, int origin);
size_t WAVWrite(WAVFile* wavfile, WAVData* wavdata, size_t data_size, int samplerate, int channels, int bitspersample);
#endif