home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 26
/
CD_ASCQ_26_1295.iso
/
vrac
/
mfcwave.zip
/
WAVE.HXX
< prev
next >
Wrap
Text File
|
1995-07-21
|
7KB
|
245 lines
/////////////////////////////////////////////////////////////////////////////
//
// $Id: wave.hxx 1.1 1995/07/21 20:10:06 neuer Exp $
//
//
// Interface to the CWave class.
//
//
// Description
// ===========
//
// The CWave class is to be used to ease the handling of
// Windows Multimedia Extensions with the Microsoft Foundation
// Class Library.
//
//
// Contruction:
//
// - CWave();
// Creates an uninitialized (empty) wave object.
//
// - CWave( LPCSTR lpszWave );
// Creates a wave object from a string.
// The string may either specify a wave file (*.wav)
// or an entry in the sounds section of the win.ini
// file.
//
// - CWave( UINT nWave );
// Creates a wave object from a wave resource.
// The parameter specifies the resource identification
// number.
//
// - CWave( CWave const &Wave );
// Creates a wave object from another wave object.
//
//
// Destruction:
//
// - ~CWave();
// Destroys a wave object.
//
//
// Loading Waves:
//
// - BOOL LoadWave( LPCSTR lpszWave );
// Loads a wave form into a wave object.
// The parameter specifies either a wave form file (*.wav)
// or an entry in the sounds section of the win.ini file.
// If the wave object is already loaded with a wave form,
// the new wave is loaded over the old one.
//
// - BOOL LoadWave( UINT nWave );
// Loads a wave form into a wave object.
// The parameter specifies the resource identification
// number.
// If the wave object is already loaded with a wave form,
// the new wave is loaded over the old one.
//
//
// Assignment:
//
// - void operator =( CWave const &wave );
// Assigns a wave object from another wave.
//
//
// Output Operations:
//
// - BOOL PlaySound( UINT flags = SND_SYNC );
// Plays a wave.
// Flag values can be found in the <mmsystem.h> include file.
// The default is SND_SYNC which causes the program to wait
// until the wave is completely send to the wave output device.
// The wave class automatically takes care of the difference
// between memory resident (resource) waves and external wave
// (*.wav) files.
// The function will abort in the debugging version of this
// class if the class is not initialized with a valid wave.
//
// - void StopSound();
// Stops any wave that is currently played.
//
//
// Status:
//
// - BOOL IsLoaded() const;
// TRUE if the object is initialized with a wave form.
//
// - BOOL IsResident() const;
// TRUE if the object is initialized with a resident
// (resource) wave form.
//
// - BOOL IsExternal() const;
// TRUE if the object is initialized with an external
// (wave file) wave form.
//
//
// Debugging:
//
// - virtual void AssertValid() const;
// In the debugging version of this class, this function
// overrides CObject::AssertValid().
// For more information refer to CObject::AssertValid()
// in the MFC documentation.
//
// - virtual void Dump( CDumpContext &dc ) const;
// In the debugging version of this class, this function
// overrides CObject::Dump().
// For more information refer to CObject::Dump() in the
// MFC documentation.
//
//
// $Revision: 1.1 $
// $Date: 1995/07/21 20:10:06 $
// $Author: neuer $
//
// $Log: wave.hxx $
// Revision 1.1 1995/07/21 20:10:06 neuer
// Initial revision
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(__WAVE_H__)
#define __WAVE_H__
#include "stdafx.h"
#include <mmsystem.h>
class CWave : public CObject
{
private:
HANDLE m_Resource;
LPSTR m_Name;
UINT m_Flags;
protected:
DECLARE_DYNAMIC( CWave );
public:
inline CWave();
inline CWave( LPCSTR lpszWave );
inline CWave( UINT nWave );
inline CWave( CWave const &Wave );
inline ~CWave();
BOOL LoadWave( LPCSTR lpszWave );
BOOL LoadWave( UINT nWave );
inline void operator =( CWave const &wave );
inline BOOL PlaySound( UINT flags = SND_SYNC );
inline void StopSound();
inline BOOL IsLoaded() const; // wave loaded?
inline BOOL IsResident() const; // resident wave resource?
inline BOOL IsExternal() const; // external wave file?
private:
void DiscardWave();
inline void InitWave();
public:
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump( CDumpContext &dc ) const;
#endif
};
inline void CWave::InitWave()
{
m_Resource = NULL;
m_Name = NULL;
m_Flags = 0;
} // InitWave()
inline CWave::CWave()
{
InitWave();
} // CWave()
inline CWave::CWave( LPCSTR lpszWave )
{
InitWave();
VERIFY( LoadWave( lpszWave ) );
} // CWave()
inline CWave::CWave( UINT nWave )
{
InitWave();
VERIFY( LoadWave( nWave ) );
} // CWave()
inline CWave::CWave( CWave const &Wave )
{
m_Resource = Wave.m_Resource;
m_Name = Wave.m_Name;
m_Flags = Wave.m_Flags;
} // CWave()
inline CWave::~CWave()
{
DiscardWave();
} // ~CWave()
inline BOOL CWave::PlaySound( UINT flags )
{
ASSERT( IsLoaded() );
return sndPlaySound( m_Name, m_Flags | flags );
} // PlaySound()
inline void CWave::StopSound()
{
sndPlaySound( NULL, 0 );
} // StopSound()
inline BOOL CWave::IsLoaded() const
{
return (m_Name != NULL);
} // IsLoaded()
inline BOOL CWave::IsResident() const
{
return (m_Flags != 0);
} // IsResident()
inline BOOL CWave::IsExternal() const
{
return (m_Flags == 0);
} // IsExternal()
inline void CWave::operator =( CWave const &wave )
{
m_Resource = wave.m_Resource;
m_Name = wave.m_Name;
m_Flags = wave.m_Flags;
} // operator=()
/////////////////////////////////////////////////////////////////////////////
#endif