Skylicht Engine
Loading...
Searching...
No Matches
CWavSubDecoderMSADPCM.h
1#ifndef _SKYLICHTAUDIO_WAVESUBDECODER_MSADPCM_
2#define _SKYLICHTAUDIO_WAVESUBDECODER_MSADPCM_
3
4#include "IWavSubDecoder.h"
5
6#define MAX_INT16 32767
7#define MIN_INT16 -32768
8#define MS_ADPCM_MONO_HEADER_SIZE 7
9#define MS_ADPCM_STEREO_HEADER_SIZE 14
10
11namespace Skylicht
12{
13 namespace Audio
14 {
15 const int Adaptive[] =
16 {
17 230, 230, 230, 230, 307, 409, 512, 614,
18 768, 614, 512, 409, 307, 230, 230, 230
19 };
20
21 const int Adaptive16[] =
22 {
23 230, 230, 230, 230, 307, 409, 512, 614,
24 768, 614, 512, 409, 307, 230, 230, 230
25 };
26
28 {
29 unsigned char Predictor;
30 unsigned short Delta;
31 short Sample1, Sample2;
32 };
33
34
35 struct SFmtExtendedInfos
36 {
37 short Size;
38 short SamplesPerBlock;
39 short NumCoefficients;
40 short Coefficients[256][2];
41
42 SFmtExtendedInfos() :
43 Size(0),
44 SamplesPerBlock(0),
45 NumCoefficients(0)
46 {
47 }
48 };
49
50 class CWavSubDecoderMSADPCM : public IWavSubDecoder
51 {
52 public:
53 CWavSubDecoderMSADPCM(IStreamCursor* streamCursor, SWaveChunk* waveChunks);
54 virtual ~CWavSubDecoderMSADPCM();
55
56 virtual int decode(void* buffer, int size);
57
58 virtual int seek(int size);
59
60 protected:
61 int decodeBlock(void* outbuf);
62
63 short decodeSample(SMsAdpcmState* state, unsigned int code, const short* coefficient);
64
65 protected:
66
67 unsigned char* m_readBuffer;
68 unsigned int m_totalDataBytesRead;
69 int m_dataStartPosition;
70 int m_samplesInBuffer;
71 int m_samplesInBufferConsumed;
72 unsigned int m_totalSampleDecoded;
73 unsigned char* m_blockReadBuffer;
74
75 SFmtExtendedInfos m_fmtExtendedInfos;
76
77 };
78 }
79}
80
81#endif
Interface for a stream cursor, providing seek and read operations on an audio stream.
Definition IStream.h:39
Handles all core audio functionality.
Definition AudioDebugLog.h:31
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition AudioDebugLog.h:29
Definition CWavSubDecoderMSADPCM.h:36
Definition CWavSubDecoderMSADPCM.h:28
Definition WavHeader.h:109