-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwavsource.h
More file actions
55 lines (51 loc) · 1.47 KB
/
Copy pathwavsource.h
File metadata and controls
55 lines (51 loc) · 1.47 KB
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
#ifndef WaveSource_H
#define WaveSource_H
#include "iointer.h"
#include "cautil.h"
namespace wave {
struct GUID {
uint32_t Data1;
uint16_t Data2;
uint16_t Data3;
uint8_t Data4[8];
};
extern const GUID ksFormatSubTypePCM;
extern const GUID ksFormatSubTypeFloat;
}
class WaveSource: public ISeekableSource {
bool m_seekable;
int m_block_align;
int64_t m_data_pos;
int64_t m_position;
uint64_t m_length;
std::shared_ptr<FILE> m_fp;
std::vector<uint32_t> m_chanmap;
std::vector<uint8_t> m_buffer;
AudioStreamBasicDescription m_asbd;
public:
WaveSource(const std::shared_ptr<FILE> &fp, bool ignorelength = false);
uint64_t length() const { return m_length; }
const AudioStreamBasicDescription &getSampleFormat() const
{
return m_asbd;
}
const std::vector<uint32_t> *getChannels() const
{
return m_chanmap.size() ? &m_chanmap : 0;
}
int64_t getPosition() { return m_position; }
size_t readSamples(void *buffer, size_t nsamples);
bool isSeekable() { return util::is_seekable(fileno(m_fp.get())); }
void seekTo(int64_t count);
private:
int fd() { return fileno(m_fp.get()); }
int64_t parse();
void read16le(void *n);
void read32le(void *n);
void read64le(void *n);
void skip(int64_t n);
uint32_t nextChunk(uint32_t *size);
int64_t ds64();
void fmt(size_t size);
};
#endif