]> git.saurik.com Git - wxWidgets.git/blob - utils/wxMMedia/wave.cpp
Changed BidEndianOrdered to BigEndianOrdered in datstrm.h
[wxWidgets.git] / utils / wxMMedia / wave.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wave.cpp
3 // Purpose: wxWave class
4 // Author: Guilhem Lavaux / API by Julian Smart
5 // Modified by:
6 // Created: 04/23/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Guilhem Lavaux
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11 #ifdef __GNUG__
12 #pragma implementation "wave.h"
13 #endif
14
15 #include <wx/wfstream.h>
16 #include "wave.h"
17
18 wxWave::wxWave()
19 {
20 m_wave = NULL;
21 m_iowave = NULL;
22 }
23
24 wxWave::wxWave(const wxString& fileName, bool isResource = FALSE)
25 {
26 Create(fileName, isResource);
27 }
28
29 wxWave::~wxWave()
30 {
31 Free();
32 }
33
34 bool wxWave::Create(const wxString& sFileName, bool isResource = FALSE)
35 {
36 m_iowave = new wxFileInputStream(sFileName);
37 m_wave = new wxSndWavCodec(*m_iowave);
38
39 return TRUE;
40 }
41
42 bool wxWave::Play(bool async, bool looped) const
43 {
44 if (!m_wave)
45 return FALSE;
46
47 if (looped)
48 m_wave->Set(wxSND_LOOP);
49 if (!m_wave->StartPlay());
50 return FALSE;
51 if (!async)
52 m_wave->Wait();
53
54 m_wave->Clear(wxSND_LOOP);
55 return TRUE;
56 }
57
58 bool wxWave::Free()
59 {
60 if (m_wave) {
61 delete m_wave;
62 delete m_iowave;
63 }
64 return TRUE;
65 }