12 // Standard Microsoft types (why change ?)
13 #define WXSOUND_PCM 0x0001
14 #define WXSOUND_ADPCM 0x0002
15 #define WXSOUND_ALAW 0x0006
16 #define WXSOUND_ULAW 0x0007
19 class wxSoundDataFormat
{
24 void SetSampleRate(int srate
) { m_srate
= srate
; }
25 void SetChannels(int channels
);
26 void SetStereo(bool on
);
27 void SetCodecNo(int no
);
28 void SetCodecCreate(bool create
) { m_codcreate
= create
; }
30 int GetSampleRate() const { return m_srate
; }
31 int GetChannels() const { return m_channels
; }
32 bool GetStereo() const { return (m_channels
== 2); }
33 int GetCodecNo() const { return m_codno
; }
35 wxSoundCodec
*GetCodec();
37 wxSoundDataFormat
& operator =(const wxSoundDataFormat
& format
);
38 bool operator ==(const wxSoundDataFormat
& format
) const;
39 bool operator !=(const wxSoundDataFormat
& format
) const
40 { return !(operator ==(format
)); }
43 void SetByteOrder(int order
);
44 void SetSign(int sign
);
45 int GetByteOrder() const { return m_byteorder
; }
46 int GetSign() const { return m_sign
; }
49 int GetBps() const { return m_bps
; }
55 int m_srate
, m_bps
, m_channels
, m_codno
;
56 int m_byteorder
, m_sign
;
57 bool m_codchange
, m_codcreate
;
58 wxSoundCodec
*m_codec
;
61 class wxSoundCodec
: public wxObject
, public wxStreamBase
{
62 DECLARE_ABSTRACT_CLASS(wxSoundCodec
)
65 virtual ~wxSoundCodec();
67 void SetIOBuffer(wxSndBuffer
*sndbuf
) { m_io_sndbuf
= sndbuf
; }
70 void InitIO(const wxSoundDataFormat
& format
);
71 void InitMode(int mode
);
74 inline void SetInStream(wxStreamBuffer
*s
)
76 inline void SetOutStream(wxStreamBuffer
*s
)
78 inline wxStreamBuffer
*GetInStream() const { return m_in_sound
; }
79 inline wxStreamBuffer
*GetOutStream() const { return m_out_sound
; }
81 inline bool Good() const { return (m_in_sound
->Stream()->LastError() == wxStream_NOERROR
) && (m_out_sound
->Stream()->LastError() == wxStream_NOERROR
); }
83 virtual size_t GetByteRate() const = 0;
84 virtual wxSoundDataFormat
GetPreferredFormat(int codec
= 0) const = 0;
86 virtual void Decode() = 0;
87 virtual void Encode() = 0;
89 static wxSoundCodec
*Get(int no
);
94 unsigned short Convert8_16(unsigned char s
) { return (s
& 0xff) << 8; }
95 unsigned char Convert16_8(unsigned short s
) { return (s
& 0xff00) >> 8; }
97 bool ChainCodecBefore(wxSoundDataFormat
& cod_to
);
98 bool ChainCodecAfter(wxSoundDataFormat
& cod_to
);
103 size_t OnSysWrite(const void *buffer
, size_t bsize
);
104 size_t OnSysRead(void *buffer
, size_t bsize
);
107 wxSndBuffer
*m_io_sndbuf
;
108 wxSoundDataFormat m_io_format
;
109 wxStreamBuffer
*m_in_sound
, *m_out_sound
;
110 wxSoundCodec
*m_chain_codec
;
111 bool m_init
, m_chain_before
;