]> git.saurik.com Git - wxWidgets.git/blame - contrib/include/wx/mmedia/sndmsad.h
Keep wxSTC_LEX_ASP and _PHP available for now.
[wxWidgets.git] / contrib / include / wx / mmedia / sndmsad.h
CommitLineData
e8482f24
GL
1// --------------------------------------------------------------------------
2// Name: sndmsad(pcm).h
3// Purpose: MS ADPCM codec
4// Date: 25/02/2000
5// Author: Guilhem Lavaux <lavaux@easynet.fr> (C) 2000
6// CVSID: $Id$
05aa8cf3 7// License: wxWindows license
e8482f24 8// --------------------------------------------------------------------------
c42b1de6
GL
9#ifndef _WX_SNDMSAD_H
10#define _WX_SNDMSAD_H
e8482f24 11
e8482f24
GL
12#include "wx/defs.h"
13#include "wx/dynarray.h"
15e8daec 14#include "wx/mmedia/defs.h"
e8482f24
GL
15#include "wx/mmedia/sndcodec.h"
16#include "wx/mmedia/sndbase.h"
17
e53191be 18WX_DEFINE_EXPORTED_ARRAY_INT(wxInt16, wxMSAdpcmCoeffs);
e8482f24
GL
19
20//
21// MSADPCM format
22//
15e8daec 23class WXDLLIMPEXP_MMEDIA wxSoundFormatMSAdpcm: public wxSoundFormatBase {
c42b1de6
GL
24public:
25 wxSoundFormatMSAdpcm();
26 ~wxSoundFormatMSAdpcm();
27
28 void SetSampleRate(wxUint32 srate);
29 wxUint32 GetSampleRate() const;
30
31 void SetCoefs(wxInt16 **coefs, wxUint16 ncoefs, wxUint16 coefs_len);
32 void GetCoefs(wxInt16 **&coefs, wxUint16& ncoefs,
33 wxUint16& coefs_len) const;
e8482f24 34
c42b1de6
GL
35 void SetBlockSize(wxUint16 block_size);
36 wxUint16 GetBlockSize() const;
37
38 void SetChannels(wxUint16 channels);
39 wxUint16 GetChannels() const;
40
41 wxSoundFormatType GetType() const { return wxSOUND_MSADPCM; }
42 wxSoundFormatBase *Clone() const;
43
44 wxUint32 GetTimeFromBytes(wxUint32 bytes) const;
45 wxUint32 GetBytesFromTime(wxUint32 time) const;
46
47 bool operator !=(const wxSoundFormatBase& frmt2) const;
e8482f24 48
c42b1de6
GL
49protected:
50 wxUint32 m_srate, m_nchannels;
51 wxInt16 **m_coefs;
52 wxUint16 m_ncoefs, m_coefs_len;
53 wxUint16 m_block_size;
e8482f24
GL
54};
55
56//
57// MS ADPCM converter class
58//
15e8daec
VS
59class WXDLLIMPEXP_MMEDIA wxSoundRouterStream;
60class WXDLLIMPEXP_MMEDIA wxSoundStreamMSAdpcm: public wxSoundStreamCodec {
e8482f24 61public:
c42b1de6
GL
62 wxSoundStreamMSAdpcm(wxSoundStream& sndio);
63 ~wxSoundStreamMSAdpcm();
e8482f24
GL
64
65 wxSoundStream& Read(void *buffer, wxUint32 len);
66 wxSoundStream& Write(const void *buffer, wxUint32 len);
67
68 bool SetSoundFormat(const wxSoundFormatBase& format);
69
70 wxUint32 GetBestSize() const;
71
72protected:
73 wxSoundRouterStream *m_router;
c42b1de6
GL
74
75 typedef struct {
76 wxInt32 predictor;
77 wxInt16 samp1;
78 wxInt16 samp2;
79 wxInt16 coeff[2];
80 wxInt32 iDelta;
81 } AdpcmState;
82
83 AdpcmState m_state[1];
84
85 bool m_got_header;
86 bool m_stereo;
87 wxInt16 **m_coefs;
88 wxUint16 m_block_size;
89 wxUint16 m_ncoefs;
90 wxUint16 m_next_block;
91
92protected:
93 wxUint32 DecodeMonoADPCM(const void *in_buffer, void *out_buffer,
94 wxUint32 in_len);
95 wxUint32 DecodeStereoADPCM(const void *in_buffer, void *out_buffer,
96 wxUint32 in_len);
97 void Nibble(wxInt8 nyb,
98 AdpcmState *state,
99 wxInt16 **out_buffer);
e8482f24
GL
100};
101
102#endif