1 // --------------------------------------------------------------------------
2 // Name: sndmsad(pcm).h
3 // Purpose: MS ADPCM codec
5 // Author: Guilhem Lavaux <lavaux@easynet.fr> (C) 2000
7 // --------------------------------------------------------------------------
12 #pragma interface "sndmsad.h"
16 #include "wx/dynarray.h"
17 #include "wx/mmedia/sndcodec.h"
18 #include "wx/mmedia/sndbase.h"
20 WX_DEFINE_EXPORTED_ARRAY_INT(wxInt16
, wxMSAdpcmCoeffs
);
25 class WXDLLEXPORT wxSoundFormatMSAdpcm
: public wxSoundFormatBase
{
27 wxSoundFormatMSAdpcm();
28 ~wxSoundFormatMSAdpcm();
30 void SetSampleRate(wxUint32 srate
);
31 wxUint32
GetSampleRate() const;
33 void SetCoefs(wxInt16
**coefs
, wxUint16 ncoefs
, wxUint16 coefs_len
);
34 void GetCoefs(wxInt16
**&coefs
, wxUint16
& ncoefs
,
35 wxUint16
& coefs_len
) const;
37 void SetBlockSize(wxUint16 block_size
);
38 wxUint16
GetBlockSize() const;
40 void SetChannels(wxUint16 channels
);
41 wxUint16
GetChannels() const;
43 wxSoundFormatType
GetType() const { return wxSOUND_MSADPCM
; }
44 wxSoundFormatBase
*Clone() const;
46 wxUint32
GetTimeFromBytes(wxUint32 bytes
) const;
47 wxUint32
GetBytesFromTime(wxUint32 time
) const;
49 bool operator !=(const wxSoundFormatBase
& frmt2
) const;
52 wxUint32 m_srate
, m_nchannels
;
54 wxUint16 m_ncoefs
, m_coefs_len
;
55 wxUint16 m_block_size
;
59 // MS ADPCM converter class
61 class WXDLLEXPORT wxSoundRouterStream
;
62 class WXDLLEXPORT wxSoundStreamMSAdpcm
: public wxSoundStreamCodec
{
64 wxSoundStreamMSAdpcm(wxSoundStream
& sndio
);
65 ~wxSoundStreamMSAdpcm();
67 wxSoundStream
& Read(void *buffer
, wxUint32 len
);
68 wxSoundStream
& Write(const void *buffer
, wxUint32 len
);
70 bool SetSoundFormat(const wxSoundFormatBase
& format
);
72 wxUint32
GetBestSize() const;
75 wxSoundRouterStream
*m_router
;
85 AdpcmState m_state
[1];
90 wxUint16 m_block_size
;
92 wxUint16 m_next_block
;
95 wxUint32
DecodeMonoADPCM(const void *in_buffer
, void *out_buffer
,
97 wxUint32
DecodeStereoADPCM(const void *in_buffer
, void *out_buffer
,
99 void Nibble(wxInt8 nyb
,
101 wxInt16
**out_buffer
);