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