]> git.saurik.com Git - wxWidgets.git/commitdiff
* Fixes.
authorGuilhem Lavaux <lavaux@easynet.fr>
Sun, 10 Jan 1999 20:23:52 +0000 (20:23 +0000)
committerGuilhem Lavaux <lavaux@easynet.fr>
Sun, 10 Jan 1999 20:23:52 +0000 (20:23 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1366 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

utils/wxMMedia/TODO [new file with mode: 0644]
utils/wxMMedia/WARNING [new file with mode: 0644]
utils/wxMMedia/sndadpcm.cpp [new file with mode: 0644]
utils/wxMMedia/sndfrmt.cpp
utils/wxMMedia/sndpcm.h

diff --git a/utils/wxMMedia/TODO b/utils/wxMMedia/TODO
new file mode 100644 (file)
index 0000000..a732d8c
--- /dev/null
@@ -0,0 +1,7 @@
+-------------
+| TODO list |
+-------------
+
+* Update the sound fragmenter to the new codec scheme.
+* Fix the codec scheme.
+* Add more codec.
diff --git a/utils/wxMMedia/WARNING b/utils/wxMMedia/WARNING
new file mode 100644 (file)
index 0000000..b40c1bf
--- /dev/null
@@ -0,0 +1,7 @@
+------------------------------------------------------------------------------
+| WARNING: This sub-package doesn't work, so don't try to compile it if you  |
+| don't want to make some development on it.                                 |
+------------------------------------------------------------------------------
+
+If you want to build it rename Makefile.bd in Makefile and Makefile.ibd in
+Makefile.in. After that, rerun config.status.
diff --git a/utils/wxMMedia/sndadpcm.cpp b/utils/wxMMedia/sndadpcm.cpp
new file mode 100644 (file)
index 0000000..9e7473f
--- /dev/null
@@ -0,0 +1,86 @@
+#ifdef __GNUG__
+#pragma implementation "sndmulaw.h"
+#endif
+
+#include "sndsnd.h"
+#include "sndfrmt.h"
+#include "sndadpcm.h"
+#include "adpcm/g72x.h"
+
+wxSoundAdpcmCodec::wxSoundAdpcmCodec()
+  : wxSoundCodec()
+{
+  g72x_init_state(codec_state);
+}
+
+wxSoundAdpcmCodec::~wxSoundAdpcmCodec()
+{
+}
+
+int wxSoundAdpcmCodec::GetBits(int nbits)
+{
+  unsigned int mask;
+  int bits;
+
+  if (bits_waiting == 0)
+    current_byte = m_in_sound->GetChar();
+
+  mask = (1 << nbits) - 1;
+  bits = current_byte & mask;
+  current_byte >>= nbits;
+  return bits;
+}
+
+
+void wxSoundAdpcmCodec::Decode()
+{
+  int smp;
+  wxSoundDataFormat pref_frmt;
+
+  pref_frmt = GetPreferredFormat(0);
+  if (!(m_io_format == pref_frmt))
+    ChainCodecAfter(pref_frmt);
+
+  bits = GetBits(4);
+  if (m_io_format.GetByteOrder() == wxSND_SAMPLE_LE) {
+    while (!StreamOk()) {
+      smp = g721_decoder(bits, AUDIO_ENCODING_LINEAR, codec_state);
+      m_out_sound->PutChar(smp & 0x00ff);
+      m_out_sound->PutChar((smp & 0xff00) >> 8);
+      bits = GetBits(4);
+    }
+  } else {
+    while (!StreamOk()) {
+      smp = g721_decoder(bits, AUDIO_ENCODING_LINEAR, codec_state);
+      m_out_sound->PutChar((smp & 0xff00) >> 8);
+      m_out_sound->PutChar(smp & 0x00ff);
+      bits = GetBits(4);
+    }
+  }
+}
+
+void wxSoundMulawCodec::Encode()
+{
+}
+
+size_t wxSoundMulawCodec::GetByteRate() const
+{
+  return m_srate;
+}
+
+wxSoundDataFormat wxSoundMulawCodec::GetPreferredFormat(int WXUNUSED(no)) const
+{
+  wxSoundDataFormat format;
+
+  format.SetCodecNo(WXSOUND_PCM);
+  format.SetSampleRate(m_srate);
+  format.SetBps(16);
+  format.SetChannels(1);
+  format.SetSign(wxSND_SAMPLE_SIGNED);
+#ifdef USE_BE_MACH
+  format.SetByteOrder(wxSND_SAMPLE_BE);
+#else
+  format.SetByteOrder(wxSND_SAMPLE_LE);
+#endif
+  return format;
+}
index 2c446375ea81dbb6c07cf016db3e0cdc0a59cfb2..dc6d653ad9a6836ab2b67c1507452a6c515f2ac3 100644 (file)
@@ -106,9 +106,11 @@ void wxSoundDataFormat::CodecChange()
   case WXSOUND_PCM: {
       wxSoundPcmCodec *pcm_codec = (wxSoundPcmCodec *)codec;
 
-      pcm_codec->SetBits(m_bps);
-      pcm_codec->SetByteOrder(m_byteorder);
-      pcm_codec->SetSign(m_sign);
+      pcm_codec->m_orig_format.SetSampleRate(m_srate);
+      pcm_codec->m_orig_format.SetBps(m_bps);
+      pcm_codec->m_orig_format.SetChannels(m_channels);
+      pcm_codec->m_orig_format.SetByteOrder(m_byteorder);
+      pcm_codec->m_orig_format.SetSign(m_sign);
       break;
     }
   default:
index 4c464dda216cdec831ec38ae7444f19b858da3e0..20fa95848d01a49c3bbca3060a00b2a40ae4df09 100644 (file)
@@ -13,11 +13,6 @@ class wxSoundPcmCodec : public wxSoundCodec {
   wxSoundPcmCodec();
   virtual ~wxSoundPcmCodec();
 
-  void SetSampleRate(int srate) { m_orig_format.SetSampleRate(srate); }
-  void SetBits(int bits) { m_orig_format.SetBps(bits); }
-  void SetByteOrder(int order) { m_orig_format.SetByteOrder(order); }
-  void SetSign(int sample_sign) { m_orig_format.SetSign(sample_sign); }
-
   size_t GetByteRate() const;
   wxSoundDataFormat GetPreferredFormat(int codec = 0) const;
 
@@ -31,6 +26,7 @@ class wxSoundPcmCodec : public wxSoundCodec {
   void OutputSwapAndSign16();
 
  protected:
+  friend class wxSoundDataFormat;
   wxSoundDataFormat m_orig_format;
   char m_char_stack;
   bool m_char_bool;