4d6306eb4d
* WARNING! It is quite unstable on Windows and it doesn't work on Linux for the moment because I didn't finish fixing the CODEC stream. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@975 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
66 lines
1.2 KiB
C++
66 lines
1.2 KiB
C++
/////////////////////////////////////////////////////////////////////////////
|
|
// Name: wave.cpp
|
|
// Purpose: wxWave class
|
|
// Author: Guilhem Lavaux / API by Julian Smart
|
|
// Modified by:
|
|
// Created: 04/23/98
|
|
// RCS-ID: $Id$
|
|
// Copyright: (c) Guilhem Lavaux
|
|
// Licence: wxWindows license
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
#ifdef __GNUG__
|
|
#pragma implementation "wave.h"
|
|
#endif
|
|
|
|
#include <wx/fstream.h>
|
|
#include "wave.h"
|
|
|
|
wxWave::wxWave()
|
|
{
|
|
m_wave = NULL;
|
|
m_iowave = NULL;
|
|
}
|
|
|
|
wxWave::wxWave(const wxString& fileName, bool isResource = FALSE)
|
|
{
|
|
Create(fileName, isResource);
|
|
}
|
|
|
|
wxWave::~wxWave()
|
|
{
|
|
Free();
|
|
}
|
|
|
|
bool wxWave::Create(const wxString& sFileName, bool isResource = FALSE)
|
|
{
|
|
m_iowave = new wxFileInputStream(sFileName);
|
|
m_wave = new wxSndWavCodec(*m_iowave);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
bool wxWave::Play(bool async, bool looped) const
|
|
{
|
|
if (!m_wave)
|
|
return FALSE;
|
|
|
|
if (looped)
|
|
m_wave->Set(wxSND_LOOP);
|
|
if (!m_wave->StartPlay());
|
|
return FALSE;
|
|
if (!async)
|
|
m_wave->Wait();
|
|
|
|
m_wave->Clear(wxSND_LOOP);
|
|
return TRUE;
|
|
}
|
|
|
|
bool wxWave::Free()
|
|
{
|
|
if (m_wave) {
|
|
delete m_wave;
|
|
delete m_iowave;
|
|
}
|
|
return TRUE;
|
|
}
|