]>
Commit | Line | Data |
---|---|---|
e8482f24 GL |
1 | // -------------------------------------------------------------------------- |
2 | // Name: sndpcm.cpp | |
3 | // Purpose: | |
4 | // Date: 08/11/1999 | |
5 | // Author: Guilhem Lavaux <lavaux@easynet.fr> (C) 1999 | |
6 | // CVSID: $Id$ | |
58b9c9ba | 7 | // wxWindows licence |
e8482f24 GL |
8 | // -------------------------------------------------------------------------- |
9 | #ifdef __GNUG__ | |
10 | #pragma implementation "sndpcm.cpp" | |
11 | #endif | |
12 | ||
92a19c2e | 13 | #include "wx/wxprec.h" |
e8482f24 GL |
14 | |
15 | #ifndef WX_PRECOMP | |
16 | #include "wx/defs.h" | |
17 | #endif | |
18 | ||
19 | #ifdef __BORLANDC__ | |
20 | #pragma hdrstop | |
21 | #endif | |
22 | ||
23 | #include "wx/mmedia/sndbase.h" | |
24 | #include "wx/mmedia/sndpcm.h" | |
25 | ||
26 | wxSoundFormatPcm::wxSoundFormatPcm(wxUint32 srate, wxUint8 bps, | |
27 | wxUint16 nchannels, bool sign, | |
28 | int order) | |
29 | : m_srate(srate), m_bps(bps), m_nchan(nchannels), m_order(order), | |
30 | m_signed(sign) | |
31 | { | |
32 | } | |
33 | ||
34 | wxSoundFormatPcm::~wxSoundFormatPcm() | |
35 | { | |
36 | } | |
37 | ||
38 | void wxSoundFormatPcm::SetSampleRate(wxUint32 srate) | |
39 | { | |
40 | m_srate = srate; | |
41 | } | |
42 | ||
43 | void wxSoundFormatPcm::SetBPS(wxUint8 bps) | |
44 | { | |
45 | m_bps = bps; | |
46 | } | |
47 | ||
48 | void wxSoundFormatPcm::SetChannels(wxUint16 nchannels) | |
49 | { | |
50 | m_nchan = nchannels; | |
51 | } | |
52 | ||
53 | void wxSoundFormatPcm::SetOrder(int order) | |
54 | { | |
55 | m_order = order; | |
56 | } | |
57 | ||
58 | void wxSoundFormatPcm::Signed(bool sign) | |
59 | { | |
60 | m_signed = sign; | |
61 | } | |
62 | ||
63 | wxSoundFormatBase *wxSoundFormatPcm::Clone() const | |
64 | { | |
65 | wxSoundFormatPcm *new_pcm; | |
66 | ||
67 | new_pcm = new wxSoundFormatPcm(); | |
68 | new_pcm->m_srate = m_srate; | |
69 | new_pcm->m_bps = m_bps; | |
70 | new_pcm->m_nchan = m_nchan; | |
71 | new_pcm->m_order = m_order; | |
72 | new_pcm->m_signed= m_signed; | |
73 | ||
74 | return new_pcm; | |
75 | } | |
76 | ||
77 | wxUint32 wxSoundFormatPcm::GetTimeFromBytes(wxUint32 bytes) const | |
78 | { | |
79 | return (bytes / (m_srate * (m_bps / 8) * m_nchan)); | |
80 | } | |
81 | ||
82 | wxUint32 wxSoundFormatPcm::GetBytesFromTime(wxUint32 time) const | |
83 | { | |
84 | return (time * (m_srate * (m_bps / 8) * m_nchan)); | |
85 | } | |
86 | ||
87 | bool wxSoundFormatPcm::operator!=(const wxSoundFormatBase& format) const | |
88 | { | |
89 | wxSoundFormatPcm *format2 = (wxSoundFormatPcm *)&format; | |
90 | ||
91 | if (format.GetType() != wxSOUND_PCM) | |
dea7e44a | 92 | return true; |
e8482f24 GL |
93 | |
94 | return ( (m_srate != format2->m_srate) || | |
95 | (m_bps != format2->m_bps) || | |
96 | (m_nchan != format2->m_nchan) || | |
97 | (m_order != format2->m_order) || | |
98 | (m_signed != format2->m_signed) ); | |
99 | } |