1 ////////////////////////////////////////////////////////////////////////////////
4 // Author: Guilhem Lavaux
6 // Updated: December 1998
7 // Copyright: (C) 1997, 1998, Guilhem Lavaux
8 // License: wxWindows license
9 ////////////////////////////////////////////////////////////////////////////////
11 #pragma implementation "sndmulaw.h"
17 #include "adpcm/g72x.h"
19 wxSoundMulawCodec::wxSoundMulawCodec()
24 wxSoundMulawCodec::~wxSoundMulawCodec()
28 void wxSoundMulawCodec::Decode()
31 wxSoundDataFormat pref_frmt
;
33 pref_frmt
= GetPreferredFormat(0);
34 if (m_io_format
!= pref_frmt
)
35 ChainCodecAfter(pref_frmt
);
40 smp
= ulaw2linear(m_in_sound
->GetChar());
42 m_out_sound
->PutChar((smp
& 0xff00) >> 8);
43 m_out_sound
->PutChar(smp
& 0xff);
45 m_out_sound
->PutChar(smp
& 0xff);
46 m_out_sound
->PutChar((smp
& 0xff00) >> 8);
51 void wxSoundMulawCodec::Encode()
54 wxSoundDataFormat pref_frmt
;
56 pref_frmt
= GetPreferredFormat(0);
57 if (m_io_format
!= pref_frmt
)
58 ChainCodecBefore(pref_frmt
);
64 smp
= ((unsigned short)m_in_sound
->GetChar()) << 8;
65 smp
|= m_in_sound
->GetChar() & 0xff;
67 smp
= m_in_sound
->GetChar() & 0xff;
68 smp
|= ((unsigned short)m_in_sound
->GetChar()) << 8;
70 m_out_sound
->PutChar(linear2ulaw(smp
));
74 size_t wxSoundMulawCodec::GetByteRate() const
79 wxSoundDataFormat
wxSoundMulawCodec::GetPreferredFormat(int WXUNUSED(no
)) const
81 wxSoundDataFormat format
;
83 format
.SetCodecNo(WXSOUND_PCM
);
84 format
.SetSampleRate(m_srate
);
86 format
.SetChannels(1);
87 format
.SetSign(wxSND_SAMPLE_SIGNED
);
89 format
.SetByteOrder(wxSND_SAMPLE_BE
);
91 format
.SetByteOrder(wxSND_SAMPLE_LE
);