13 // Standard Microsoft types (why change ?)
14 #define WXSOUND_PCM 0x0001
15 #define WXSOUND_ADPCM 0x0002
16 #define WXSOUND_ALAW 0x0006
17 #define WXSOUND_ULAW 0x0007
20 class wxSoundDataFormat
{
23 wxSoundDataFormat(const wxSoundDataFormat
& format
);
26 void SetSampleRate(int srate
) { m_srate
= srate
; }
27 void SetChannels(int channels
);
28 void SetStereo(bool on
);
29 void SetCodecNo(int no
);
30 void SetCodecCreate(bool create
) { m_codcreate
= create
; }
32 int GetSampleRate() const { return m_srate
; }
33 int GetChannels() const { return m_channels
; }
34 bool GetStereo() const { return (m_channels
== 2); }
35 int GetCodecNo() const { return m_codno
; }
37 wxSoundCodec
*GetCodec();
39 wxSoundDataFormat
& operator =(const wxSoundDataFormat
& format
);
40 bool operator ==(const wxSoundDataFormat
& format
) const;
41 bool operator !=(const wxSoundDataFormat
& format
) const
42 { return !(operator ==(format
)); }
45 void SetByteOrder(int order
);
46 void SetSign(int sign
);
47 int GetByteOrder() const { return m_byteorder
; }
48 int GetSign() const { return m_sign
; }
51 int GetBps() const { return m_bps
; }
57 int m_srate
, m_bps
, m_channels
, m_codno
;
58 int m_byteorder
, m_sign
;
59 bool m_codchange
, m_codcreate
;
60 wxSoundCodec
*m_codec
;
63 class wxSoundCodec
: public wxObject
, public wxStreamBase
{
64 DECLARE_ABSTRACT_CLASS(wxSoundCodec
)
73 virtual ~wxSoundCodec();
75 void SetIOBuffer(wxSndBuffer
*sndbuf
) { m_io_sndbuf
= sndbuf
; }
78 void InitIO(const wxSoundDataFormat
& format
);
80 inline void SetInStream(wxStreamBuffer
*s
)
82 inline void SetOutStream(wxStreamBuffer
*s
)
84 inline wxStreamBuffer
*GetInStream() const { return m_in_sound
; }
85 inline wxStreamBuffer
*GetOutStream() const { return m_out_sound
; }
87 inline bool StreamOk() const
88 { return (m_in_sound
->Stream()->LastError() == wxStream_NOERROR
) &&
89 (m_out_sound
->Stream()->LastError() == wxStream_NOERROR
); }
91 virtual size_t GetByteRate() const = 0;
92 virtual wxSoundDataFormat
GetPreferredFormat(int codec
= 0) const = 0;
94 virtual void InitMode(ModeType mode
);
95 virtual void ExitMode();
96 virtual void Decode() = 0;
97 virtual void Encode() = 0;
99 static wxSoundCodec
*Get(int no
);
104 unsigned short Convert8_16(unsigned char s
) { return (s
& 0xff) << 8; }
105 unsigned char Convert16_8(unsigned short s
) { return (s
& 0xff00) >> 8; }
107 bool ChainCodecBefore(wxSoundDataFormat
& cod_to
);
108 bool ChainCodecAfter(wxSoundDataFormat
& cod_to
);
113 size_t OnSysWrite(const void *buffer
, size_t bsize
);
114 size_t OnSysRead(void *buffer
, size_t bsize
);
117 wxSndBuffer
*m_io_sndbuf
;
118 wxSoundDataFormat m_io_format
;
119 wxStreamBuffer
*m_in_sound
, *m_out_sound
;
120 wxSoundCodec
*m_chain_codec
;
121 bool m_init
, m_chain_before
;