/
csound.h
52 lines (46 loc) · 1.03 KB
/
csound.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
#ifndef CSOUND_H
#define CSOUND_H
#include<QString>
#include<QSharedPointer>
#include<QTimer>
class QFile;
#pragma pack(1)
struct Riff_Header
{
unsigned char szRiffID[4]; // 'R','I','F','F'
unsigned int dwRiffSize;
unsigned char szRiffFormat[4]; // 'W','A','V','E'
};
#pragma pack()
#pragma pack(1)
struct Wave_Format
{
unsigned short wFormatTag;
unsigned short wChannels;
unsigned int dwSamplesPerSec;
unsigned int dwAvgBytesPerSec;
unsigned short wBlockAlign;
unsigned short wBitsPerSample;
unsigned short pack; //附加信息
};
#pragma pack()
class cSound
{
public:
cSound(const QString &filename);
cSound();
void setFile(const QString &filename);
void play();
private:
QSharedPointer<QFile> file;
unsigned int datasize;
unsigned int dataoffset;
unsigned int channels;
unsigned int samplerate;
unsigned int samplebit;
unsigned int bytespersec;
unsigned int blockalign;
void writesound();
QTimer timer;
};
#endif // CSOUND_H