X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e8482f24cfc00645607f8526fde38d39e0dcaa63..a81c3c2383f9096ef5e96b708a0f1c1ffe7cc6a8:/contrib/include/wx/mmedia/sndmsad.h?ds=inline diff --git a/contrib/include/wx/mmedia/sndmsad.h b/contrib/include/wx/mmedia/sndmsad.h index 7741acd2a0..8073330b50 100644 --- a/contrib/include/wx/mmedia/sndmsad.h +++ b/contrib/include/wx/mmedia/sndmsad.h @@ -5,8 +5,8 @@ // Author: Guilhem Lavaux (C) 2000 // CVSID: $Id$ // -------------------------------------------------------------------------- -#ifndef _WX_SNDULAW_H -#define _WX_SNDULAW_H +#ifndef _WX_SNDMSAD_H +#define _WX_SNDMSAD_H #ifdef __GNUG__ #pragma interface "sndmsad.h" @@ -17,46 +17,52 @@ #include "wx/mmedia/sndcodec.h" #include "wx/mmedia/sndbase.h" -WX_DEFINE_EXPORTED_ARRAY(wxUint16, wxMSAdpcmCoeffs); +WX_DEFINE_EXPORTED_ARRAY_INT(wxInt16, wxMSAdpcmCoeffs); // // MSADPCM format // class WXDLLEXPORT wxSoundFormatMSAdpcm: public wxSoundFormatBase { - public: - wxSoundFormatMSAdpcm(); - ~wxSoundFormatMSAdpcm(); - - void SetSampleRate(wxUint32 srate); - wxUint32 GetSampleRate() const; - - void SetSamplesBlock(wxUint16 sampblock); - wxUint16 GetSamplesBlock() const; - - void SetCoefs(wxMSAdpcmCoefs& coefs); - wxMSAdpcmCoefs& GetCoefs() const; - - wxSoundFormatType GetType() const { return wxSOUND_ULAW; } - wxSoundFormatBase *Clone() const; - - wxUint32 GetTimeFromBytes(wxUint32 bytes) const; - wxUint32 GetBytesFromTime(wxUint32 time) const; +public: + wxSoundFormatMSAdpcm(); + ~wxSoundFormatMSAdpcm(); + + void SetSampleRate(wxUint32 srate); + wxUint32 GetSampleRate() const; + + void SetCoefs(wxInt16 **coefs, wxUint16 ncoefs, wxUint16 coefs_len); + void GetCoefs(wxInt16 **&coefs, wxUint16& ncoefs, + wxUint16& coefs_len) const; - bool operator !=(const wxSoundFormatBase& frmt2) const; + void SetBlockSize(wxUint16 block_size); + wxUint16 GetBlockSize() const; + + void SetChannels(wxUint16 channels); + wxUint16 GetChannels() const; + + wxSoundFormatType GetType() const { return wxSOUND_MSADPCM; } + wxSoundFormatBase *Clone() const; + + wxUint32 GetTimeFromBytes(wxUint32 bytes) const; + wxUint32 GetBytesFromTime(wxUint32 time) const; + + bool operator !=(const wxSoundFormatBase& frmt2) const; - protected: - wxUint32 m_srate; - wxMSAdpcmCoefs *m_coefs; +protected: + wxUint32 m_srate, m_nchannels; + wxInt16 **m_coefs; + wxUint16 m_ncoefs, m_coefs_len; + wxUint16 m_block_size; }; // // MS ADPCM converter class // class WXDLLEXPORT wxSoundRouterStream; -class WXDLLEXPORT wxSoundStreamAdpcm: public wxSoundStreamCodec { +class WXDLLEXPORT wxSoundStreamMSAdpcm: public wxSoundStreamCodec { public: - wxSoundStreamAdpcm(wxSoundStream& sndio); - ~wxSoundStreamAdpcm(); + wxSoundStreamMSAdpcm(wxSoundStream& sndio); + ~wxSoundStreamMSAdpcm(); wxSoundStream& Read(void *buffer, wxUint32 len); wxSoundStream& Write(const void *buffer, wxUint32 len); @@ -67,6 +73,32 @@ public: protected: wxSoundRouterStream *m_router; + + typedef struct { + wxInt32 predictor; + wxInt16 samp1; + wxInt16 samp2; + wxInt16 coeff[2]; + wxInt32 iDelta; + } AdpcmState; + + AdpcmState m_state[1]; + + bool m_got_header; + bool m_stereo; + wxInt16 **m_coefs; + wxUint16 m_block_size; + wxUint16 m_ncoefs; + wxUint16 m_next_block; + +protected: + wxUint32 DecodeMonoADPCM(const void *in_buffer, void *out_buffer, + wxUint32 in_len); + wxUint32 DecodeStereoADPCM(const void *in_buffer, void *out_buffer, + wxUint32 in_len); + void Nibble(wxInt8 nyb, + AdpcmState *state, + wxInt16 **out_buffer); }; #endif