1 // --------------------------------------------------------------------------
2 // Name: sndmsad(pcm).h
3 // Purpose: MS ADPCM codec
5 // Author: Guilhem Lavaux <lavaux@easynet.fr> (C) 2000
7 // License: wxWindows license
8 // --------------------------------------------------------------------------
13 #pragma interface "sndmsad.h"
17 #include "wx/dynarray.h"
18 #include "wx/mmedia/defs.h"
19 #include "wx/mmedia/sndcodec.h"
20 #include "wx/mmedia/sndbase.h"
22 WX_DEFINE_EXPORTED_ARRAY_INT(wxInt16
, wxMSAdpcmCoeffs
);
27 class WXDLLIMPEXP_MMEDIA wxSoundFormatMSAdpcm
: public wxSoundFormatBase
{
29 wxSoundFormatMSAdpcm();
30 ~wxSoundFormatMSAdpcm();
32 void SetSampleRate(wxUint32 srate
);
33 wxUint32
GetSampleRate() const;
35 void SetCoefs(wxInt16
**coefs
, wxUint16 ncoefs
, wxUint16 coefs_len
);
36 void GetCoefs(wxInt16
**&coefs
, wxUint16
& ncoefs
,
37 wxUint16
& coefs_len
) const;
39 void SetBlockSize(wxUint16 block_size
);
40 wxUint16
GetBlockSize() const;
42 void SetChannels(wxUint16 channels
);
43 wxUint16
GetChannels() const;
45 wxSoundFormatType
GetType() const { return wxSOUND_MSADPCM
; }
46 wxSoundFormatBase
*Clone() const;
48 wxUint32
GetTimeFromBytes(wxUint32 bytes
) const;
49 wxUint32
GetBytesFromTime(wxUint32 time
) const;
51 bool operator !=(const wxSoundFormatBase
& frmt2
) const;
54 wxUint32 m_srate
, m_nchannels
;
56 wxUint16 m_ncoefs
, m_coefs_len
;
57 wxUint16 m_block_size
;
61 // MS ADPCM converter class
63 class WXDLLIMPEXP_MMEDIA wxSoundRouterStream
;
64 class WXDLLIMPEXP_MMEDIA wxSoundStreamMSAdpcm
: public wxSoundStreamCodec
{
66 wxSoundStreamMSAdpcm(wxSoundStream
& sndio
);
67 ~wxSoundStreamMSAdpcm();
69 wxSoundStream
& Read(void *buffer
, wxUint32 len
);
70 wxSoundStream
& Write(const void *buffer
, wxUint32 len
);
72 bool SetSoundFormat(const wxSoundFormatBase
& format
);
74 wxUint32
GetBestSize() const;
77 wxSoundRouterStream
*m_router
;
87 AdpcmState m_state
[1];
92 wxUint16 m_block_size
;
94 wxUint16 m_next_block
;
97 wxUint32
DecodeMonoADPCM(const void *in_buffer
, void *out_buffer
,
99 wxUint32
DecodeStereoADPCM(const void *in_buffer
, void *out_buffer
,
101 void Nibble(wxInt8 nyb
,
103 wxInt16
**out_buffer
);