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