forked from uliwitness/stackimport
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCSndResource.h
64 lines (49 loc) · 1.43 KB
/
CSndResource.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
//
// CSndResource.h
// stackimport
//
// Created by Uli Kusterer on 2013-12-30.
//
//
/*
C++ class which you give the raw data of a 'snd ' resource and it parses
the interesting bits out of it.
Currently only supports format 2 sound resources (like HyperCard has them), but shouldn't be too hard to extend for other formats.
*/
#ifndef __stackimport__CSndResource__
#define __stackimport__CSndResource__
#include <cstddef>
#include <stdint.h>
// A CSndResource contains a list of these:
class CSoundCommand
{
public:
CSoundCommand(uint16_t inCommandType, uint16_t inParam1, uint32_t inParam2, const char* inData, size_t inDataLen );
uint16_t commandType;
uint16_t param1;
uint32_t param2;
size_t GetSoundHeaderOffset();
uint32_t GetNumBytesInSample();
uint32_t GetSampleRate(); // Fixed-point number, 2 bytes fractional.
uint32_t GetLoopPointStart();
uint32_t GetLoopPointEnd();
uint8_t GetStandardSampleEncoding();
uint8_t GetBaseFrequency();
const char* GetSampleData(); // Length is GetNumBytesInSample().
protected:
const char* mResData;
size_t mResDataLen;
};
// The actual resource:
class CSndResource
{
public:
CSndResource( const char* inData, size_t dataLen );
uint16_t GetFormat(); // 1 or 2.
uint16_t GetNumSoundCommands();
CSoundCommand GetSoundCommandAtIndex( size_t inIndex );
protected:
const char* mResData;
size_t mResDataLen;
};
#endif /* defined(__stackimport__CSndResource__) */