]> git.saurik.com Git - wxWidgets.git/blob - contrib/include/wx/mmedia/sndmsad.h
-1, TRUE/true, FALSE/false and tabs replacements.
[wxWidgets.git] / contrib / include / wx / mmedia / sndmsad.h
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$
7 // --------------------------------------------------------------------------
8 #ifndef _WX_SNDMSAD_H
9 #define _WX_SNDMSAD_H
10
11 #ifdef __GNUG__
12 #pragma interface "sndmsad.h"
13 #endif
14
15 #include "wx/defs.h"
16 #include "wx/dynarray.h"
17 #include "wx/mmedia/defs.h"
18 #include "wx/mmedia/sndcodec.h"
19 #include "wx/mmedia/sndbase.h"
20
21 WX_DEFINE_EXPORTED_ARRAY_INT(wxInt16, wxMSAdpcmCoeffs);
22
23 //
24 // MSADPCM format
25 //
26 class WXDLLIMPEXP_MMEDIA wxSoundFormatMSAdpcm: public wxSoundFormatBase {
27 public:
28 wxSoundFormatMSAdpcm();
29 ~wxSoundFormatMSAdpcm();
30
31 void SetSampleRate(wxUint32 srate);
32 wxUint32 GetSampleRate() const;
33
34 void SetCoefs(wxInt16 **coefs, wxUint16 ncoefs, wxUint16 coefs_len);
35 void GetCoefs(wxInt16 **&coefs, wxUint16& ncoefs,
36 wxUint16& coefs_len) const;
37
38 void SetBlockSize(wxUint16 block_size);
39 wxUint16 GetBlockSize() const;
40
41 void SetChannels(wxUint16 channels);
42 wxUint16 GetChannels() const;
43
44 wxSoundFormatType GetType() const { return wxSOUND_MSADPCM; }
45 wxSoundFormatBase *Clone() const;
46
47 wxUint32 GetTimeFromBytes(wxUint32 bytes) const;
48 wxUint32 GetBytesFromTime(wxUint32 time) const;
49
50 bool operator !=(const wxSoundFormatBase& frmt2) const;
51
52 protected:
53 wxUint32 m_srate, m_nchannels;
54 wxInt16 **m_coefs;
55 wxUint16 m_ncoefs, m_coefs_len;
56 wxUint16 m_block_size;
57 };
58
59 //
60 // MS ADPCM converter class
61 //
62 class WXDLLIMPEXP_MMEDIA wxSoundRouterStream;
63 class WXDLLIMPEXP_MMEDIA wxSoundStreamMSAdpcm: public wxSoundStreamCodec {
64 public:
65 wxSoundStreamMSAdpcm(wxSoundStream& sndio);
66 ~wxSoundStreamMSAdpcm();
67
68 wxSoundStream& Read(void *buffer, wxUint32 len);
69 wxSoundStream& Write(const void *buffer, wxUint32 len);
70
71 bool SetSoundFormat(const wxSoundFormatBase& format);
72
73 wxUint32 GetBestSize() const;
74
75 protected:
76 wxSoundRouterStream *m_router;
77
78 typedef struct {
79 wxInt32 predictor;
80 wxInt16 samp1;
81 wxInt16 samp2;
82 wxInt16 coeff[2];
83 wxInt32 iDelta;
84 } AdpcmState;
85
86 AdpcmState m_state[1];
87
88 bool m_got_header;
89 bool m_stereo;
90 wxInt16 **m_coefs;
91 wxUint16 m_block_size;
92 wxUint16 m_ncoefs;
93 wxUint16 m_next_block;
94
95 protected:
96 wxUint32 DecodeMonoADPCM(const void *in_buffer, void *out_buffer,
97 wxUint32 in_len);
98 wxUint32 DecodeStereoADPCM(const void *in_buffer, void *out_buffer,
99 wxUint32 in_len);
100 void Nibble(wxInt8 nyb,
101 AdpcmState *state,
102 wxInt16 **out_buffer);
103 };
104
105 #endif