2 #pragma implementation "sndmulaw.h"
8 #include "adpcm/g72x.h"
10 wxSoundMulawCodec::wxSoundMulawCodec()
15 wxSoundMulawCodec::~wxSoundMulawCodec()
19 void wxSoundMulawCodec::Decode()
22 wxSoundDataFormat pref_frmt
;
24 pref_frmt
= GetPreferredFormat(0);
25 if (m_io_format
!= pref_frmt
)
26 ChainCodecAfter(pref_frmt
);
31 smp
= ulaw2linear(m_in_sound
->GetChar());
33 m_out_sound
->PutChar((smp
& 0xff00) >> 8);
34 m_out_sound
->PutChar(smp
& 0xff);
36 m_out_sound
->PutChar(smp
& 0xff);
37 m_out_sound
->PutChar((smp
& 0xff00) >> 8);
42 void wxSoundMulawCodec::Encode()
45 wxSoundDataFormat pref_frmt
;
47 pref_frmt
= GetPreferredFormat(0);
48 if (m_io_format
!= pref_frmt
)
49 ChainCodecBefore(pref_frmt
);
55 smp
= ((unsigned short)m_in_sound
->GetChar()) << 8;
56 smp
|= m_in_sound
->GetChar() & 0xff;
58 smp
= m_in_sound
->GetChar() & 0xff;
59 smp
|= ((unsigned short)m_in_sound
->GetChar()) << 8;
61 m_out_sound
->PutChar(linear2ulaw(smp
));
65 size_t wxSoundMulawCodec::GetByteRate() const
70 wxSoundDataFormat
wxSoundMulawCodec::GetPreferredFormat(int WXUNUSED(no
)) const
72 wxSoundDataFormat format
;
74 format
.SetCodecNo(WXSOUND_PCM
);
75 format
.SetSampleRate(m_srate
);
77 format
.SetChannels(1);
78 format
.SetSign(wxSND_SAMPLE_SIGNED
);
80 format
.SetByteOrder(wxSND_SAMPLE_BE
);
82 format
.SetByteOrder(wxSND_SAMPLE_LE
);