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