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
)
67 virtual ~wxSoundCodec();
69 void SetIOBuffer(wxSndBuffer
*sndbuf
) { m_io_sndbuf
= sndbuf
; }
72 void InitIO(const wxSoundDataFormat
& format
);
73 void InitMode(int mode
);
76 inline void SetInStream(wxStreamBuffer
*s
)
78 inline void SetOutStream(wxStreamBuffer
*s
)
80 inline wxStreamBuffer
*GetInStream() const { return m_in_sound
; }
81 inline wxStreamBuffer
*GetOutStream() const { return m_out_sound
; }
83 inline bool StreamOk() const
84 { return (m_in_sound
->Stream()->LastError() == wxStream_NOERROR
) &&
85 (m_out_sound
->Stream()->LastError() == wxStream_NOERROR
); }
87 virtual size_t GetByteRate() const = 0;
88 virtual wxSoundDataFormat
GetPreferredFormat(int codec
= 0) const = 0;
90 virtual void Decode() = 0;
91 virtual void Encode() = 0;
93 static wxSoundCodec
*Get(int no
);
98 unsigned short Convert8_16(unsigned char s
) { return (s
& 0xff) << 8; }
99 unsigned char Convert16_8(unsigned short s
) { return (s
& 0xff00) >> 8; }
101 bool ChainCodecBefore(wxSoundDataFormat
& cod_to
);
102 bool ChainCodecAfter(wxSoundDataFormat
& cod_to
);
107 size_t OnSysWrite(const void *buffer
, size_t bsize
);
108 size_t OnSysRead(void *buffer
, size_t bsize
);
111 wxSndBuffer
*m_io_sndbuf
;
112 wxSoundDataFormat m_io_format
;
113 wxStreamBuffer
*m_in_sound
, *m_out_sound
;
114 wxSoundCodec
*m_chain_codec
;
115 bool m_init
, m_chain_before
;