]> git.saurik.com Git - wxWidgets.git/blob - contrib/include/wx/mmedia/sndmsad.h
added wxConvUI which determines the conversion used for the UI elements and can be...
[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 // License: wxWindows license
8 // --------------------------------------------------------------------------
9 #ifndef _WX_SNDMSAD_H
10 #define _WX_SNDMSAD_H
11
12 #include "wx/defs.h"
13 #include "wx/dynarray.h"
14 #include "wx/mmedia/defs.h"
15 #include "wx/mmedia/sndcodec.h"
16 #include "wx/mmedia/sndbase.h"
17
18 WX_DEFINE_EXPORTED_ARRAY_INT(wxInt16, wxMSAdpcmCoeffs);
19
20 //
21 // MSADPCM format
22 //
23 class WXDLLIMPEXP_MMEDIA wxSoundFormatMSAdpcm: public wxSoundFormatBase {
24 public:
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;
34
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;
48
49 protected:
50 wxUint32 m_srate, m_nchannels;
51 wxInt16 **m_coefs;
52 wxUint16 m_ncoefs, m_coefs_len;
53 wxUint16 m_block_size;
54 };
55
56 //
57 // MS ADPCM converter class
58 //
59 class WXDLLIMPEXP_MMEDIA wxSoundRouterStream;
60 class WXDLLIMPEXP_MMEDIA wxSoundStreamMSAdpcm: public wxSoundStreamCodec {
61 public:
62 wxSoundStreamMSAdpcm(wxSoundStream& sndio);
63 ~wxSoundStreamMSAdpcm();
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
72 protected:
73 wxSoundRouterStream *m_router;
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
92 protected:
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);
100 };
101
102 #endif