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 #include "wx/dynarray.h"
14 #include "wx/mmedia/defs.h"
15 #include "wx/mmedia/sndcodec.h"
16 #include "wx/mmedia/sndbase.h"
18 WX_DEFINE_EXPORTED_ARRAY_INT(wxInt16
, wxMSAdpcmCoeffs
);
23 class WXDLLIMPEXP_MMEDIA wxSoundFormatMSAdpcm
: public wxSoundFormatBase
{
25 wxSoundFormatMSAdpcm();
26 ~wxSoundFormatMSAdpcm();
28 void SetSampleRate(wxUint32 srate
);
29 wxUint32
GetSampleRate() const;
31 void SetCoefs(wxInt16
**coefs
, wxUint16 ncoefs
, wxUint16 coefs_len
);
32 void GetCoefs(wxInt16
**&coefs
, wxUint16
& ncoefs
,
33 wxUint16
& coefs_len
) const;
35 void SetBlockSize(wxUint16 block_size
);
36 wxUint16
GetBlockSize() const;
38 void SetChannels(wxUint16 channels
);
39 wxUint16
GetChannels() const;
41 wxSoundFormatType
GetType() const { return wxSOUND_MSADPCM
; }
42 wxSoundFormatBase
*Clone() const;
44 wxUint32
GetTimeFromBytes(wxUint32 bytes
) const;
45 wxUint32
GetBytesFromTime(wxUint32 time
) const;
47 bool operator !=(const wxSoundFormatBase
& frmt2
) const;
50 wxUint32 m_srate
, m_nchannels
;
52 wxUint16 m_ncoefs
, m_coefs_len
;
53 wxUint16 m_block_size
;
57 // MS ADPCM converter class
59 class WXDLLIMPEXP_MMEDIA wxSoundRouterStream
;
60 class WXDLLIMPEXP_MMEDIA wxSoundStreamMSAdpcm
: public wxSoundStreamCodec
{
62 wxSoundStreamMSAdpcm(wxSoundStream
& sndio
);
63 ~wxSoundStreamMSAdpcm();
65 wxSoundStream
& Read(void *buffer
, wxUint32 len
);
66 wxSoundStream
& Write(const void *buffer
, wxUint32 len
);
68 bool SetSoundFormat(const wxSoundFormatBase
& format
);
70 wxUint32
GetBestSize() const;
73 wxSoundRouterStream
*m_router
;
83 AdpcmState m_state
[1];
88 wxUint16 m_block_size
;
90 wxUint16 m_next_block
;
93 wxUint32
DecodeMonoADPCM(const void *in_buffer
, void *out_buffer
,
95 wxUint32
DecodeStereoADPCM(const void *in_buffer
, void *out_buffer
,
97 void Nibble(wxInt8 nyb
,
99 wxInt16
**out_buffer
);