]> git.saurik.com Git - wxWidgets.git/blobdiff - contrib/include/wx/mmedia/sndmsad.h
removed libxpm dependencies from makefiles
[wxWidgets.git] / contrib / include / wx / mmedia / sndmsad.h
index 7741acd2a03af84efffbb715c3a2ae5df8eb185d..dfe15bc6af819ae4a01239334dc79fd83cc08ab0 100644 (file)
@@ -5,8 +5,8 @@
 // Author: Guilhem Lavaux <lavaux@easynet.fr> (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"
 #include "wx/mmedia/sndcodec.h"
 #include "wx/mmedia/sndbase.h"
 
-WX_DEFINE_EXPORTED_ARRAY(wxUint16, wxMSAdpcmCoeffs);
+WX_DEFINE_EXPORTED_ARRAY(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