2 #pragma implementation "sndmulaw.h"
8 #include "adpcm/g72x.h"
10 wxSoundAdpcmCodec::wxSoundAdpcmCodec()
13 g72x_init_state(codec_state
);
16 wxSoundAdpcmCodec::~wxSoundAdpcmCodec()
20 int wxSoundAdpcmCodec::GetBits(int nbits
)
25 if (bits_waiting
== 0)
26 current_byte
= m_in_sound
->GetChar();
28 mask
= (1 << nbits
) - 1;
29 bits
= current_byte
& mask
;
30 current_byte
>>= nbits
;
35 void wxSoundAdpcmCodec::Decode()
38 wxSoundDataFormat pref_frmt
;
40 pref_frmt
= GetPreferredFormat(0);
41 if (!(m_io_format
== pref_frmt
))
42 ChainCodecAfter(pref_frmt
);
45 if (m_io_format
.GetByteOrder() == wxSND_SAMPLE_LE
) {
47 smp
= g721_decoder(bits
, AUDIO_ENCODING_LINEAR
, codec_state
);
48 m_out_sound
->PutChar(smp
& 0x00ff);
49 m_out_sound
->PutChar((smp
& 0xff00) >> 8);
54 smp
= g721_decoder(bits
, AUDIO_ENCODING_LINEAR
, codec_state
);
55 m_out_sound
->PutChar((smp
& 0xff00) >> 8);
56 m_out_sound
->PutChar(smp
& 0x00ff);
62 void wxSoundMulawCodec::Encode()
66 size_t wxSoundMulawCodec::GetByteRate() const
71 wxSoundDataFormat
wxSoundMulawCodec::GetPreferredFormat(int WXUNUSED(no
)) const
73 wxSoundDataFormat format
;
75 format
.SetCodecNo(WXSOUND_PCM
);
76 format
.SetSampleRate(m_srate
);
78 format
.SetChannels(1);
79 format
.SetSign(wxSND_SAMPLE_SIGNED
);
81 format
.SetByteOrder(wxSND_SAMPLE_BE
);
83 format
.SetByteOrder(wxSND_SAMPLE_LE
);