]> git.saurik.com Git - wxWidgets.git/blame - contrib/src/mmedia/sndpcm.cpp
adjusting to SetLabel migration
[wxWidgets.git] / contrib / src / mmedia / sndpcm.cpp
CommitLineData
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 8// --------------------------------------------------------------------------
e8482f24 9
92a19c2e 10#include "wx/wxprec.h"
e8482f24
GL
11
12#ifndef WX_PRECOMP
13 #include "wx/defs.h"
14#endif
15
16#ifdef __BORLANDC__
17 #pragma hdrstop
18#endif
19
20#include "wx/mmedia/sndbase.h"
21#include "wx/mmedia/sndpcm.h"
22
23wxSoundFormatPcm::wxSoundFormatPcm(wxUint32 srate, wxUint8 bps,
24 wxUint16 nchannels, bool sign,
25 int order)
26 : m_srate(srate), m_bps(bps), m_nchan(nchannels), m_order(order),
27 m_signed(sign)
28{
29}
30
31wxSoundFormatPcm::~wxSoundFormatPcm()
32{
33}
34
35void wxSoundFormatPcm::SetSampleRate(wxUint32 srate)
36{
37 m_srate = srate;
38}
39
40void wxSoundFormatPcm::SetBPS(wxUint8 bps)
41{
42 m_bps = bps;
43}
44
45void wxSoundFormatPcm::SetChannels(wxUint16 nchannels)
46{
47 m_nchan = nchannels;
48}
49
50void wxSoundFormatPcm::SetOrder(int order)
51{
52 m_order = order;
53}
54
55void wxSoundFormatPcm::Signed(bool sign)
56{
57 m_signed = sign;
58}
59
60wxSoundFormatBase *wxSoundFormatPcm::Clone() const
61{
62 wxSoundFormatPcm *new_pcm;
63
64 new_pcm = new wxSoundFormatPcm();
65 new_pcm->m_srate = m_srate;
66 new_pcm->m_bps = m_bps;
67 new_pcm->m_nchan = m_nchan;
68 new_pcm->m_order = m_order;
69 new_pcm->m_signed= m_signed;
70
71 return new_pcm;
72}
73
74wxUint32 wxSoundFormatPcm::GetTimeFromBytes(wxUint32 bytes) const
75{
76 return (bytes / (m_srate * (m_bps / 8) * m_nchan));
77}
78
79wxUint32 wxSoundFormatPcm::GetBytesFromTime(wxUint32 time) const
80{
81 return (time * (m_srate * (m_bps / 8) * m_nchan));
82}
83
84bool wxSoundFormatPcm::operator!=(const wxSoundFormatBase& format) const
85{
86 wxSoundFormatPcm *format2 = (wxSoundFormatPcm *)&format;
87
88 if (format.GetType() != wxSOUND_PCM)
dea7e44a 89 return true;
e8482f24
GL
90
91 return ( (m_srate != format2->m_srate) ||
92 (m_bps != format2->m_bps) ||
93 (m_nchan != format2->m_nchan) ||
94 (m_order != format2->m_order) ||
95 (m_signed != format2->m_signed) );
96}