1998-11-09 13:37:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// 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
|
|
|
|
|
1998-12-23 13:16:19 -05:00
|
|
|
#include <wx/wfstream.h>
|
1998-11-09 13:37:38 -05:00
|
|
|
#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;
|
|
|
|
}
|