2012-04-30 09:27:12 +10:00
|
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
|
*
|
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
*
|
|
|
|
|
*/
|
2012-05-14 07:43:50 +02:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* This code is based on original Tony Tough source code
|
|
|
|
|
*
|
|
|
|
|
* Copyright (c) 1997-2003 Nayma Software
|
|
|
|
|
*/
|
2012-04-30 09:27:12 +10:00
|
|
|
|
|
|
|
|
|
#ifndef TONY_SOUND_H
|
|
|
|
|
#define TONY_SOUND_H
|
|
|
|
|
|
2012-06-10 21:23:28 -04:00
|
|
|
|
#include "audio/mixer.h"
|
2012-05-03 21:43:00 +10:00
|
|
|
|
#include "common/file.h"
|
2012-04-30 09:27:12 +10:00
|
|
|
|
#include "tony/gfxcore.h"
|
|
|
|
|
#include "tony/loc.h"
|
|
|
|
|
#include "tony/utils.h"
|
|
|
|
|
|
2012-06-10 21:23:28 -04:00
|
|
|
|
namespace Audio {
|
|
|
|
|
class RewindableAudioStream;
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-30 09:27:12 +10:00
|
|
|
|
namespace Tony {
|
|
|
|
|
|
2012-04-30 23:16:19 +10:00
|
|
|
|
class FPSTREAM;
|
2012-04-30 09:27:12 +10:00
|
|
|
|
class FPSFX;
|
|
|
|
|
|
|
|
|
|
enum CODECS {
|
|
|
|
|
FPCODEC_RAW,
|
2012-06-09 18:09:54 -04:00
|
|
|
|
FPCODEC_ADPCM
|
2012-04-30 09:27:12 +10:00
|
|
|
|
};
|
|
|
|
|
|
2012-04-30 23:16:19 +10:00
|
|
|
|
|
|
|
|
|
/****************************************************************************\
|
|
|
|
|
*****************************************************************************
|
|
|
|
|
* class FPSound
|
|
|
|
|
* -------------
|
|
|
|
|
* Description: Sound driver per Falling Pumpkins
|
|
|
|
|
*****************************************************************************
|
|
|
|
|
\****************************************************************************/
|
|
|
|
|
|
|
|
|
|
class FPSOUND {
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
bool bSoundSupported;
|
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
/****************************************************************************\
|
2012-06-12 00:07:50 +02:00
|
|
|
|
* Methods
|
2012-05-21 23:53:13 +02:00
|
|
|
|
\****************************************************************************/
|
2012-04-30 23:16:19 +10:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
/****************************************************************************\
|
|
|
|
|
*
|
|
|
|
|
* Function: FPSOUND::FPSOUND();
|
|
|
|
|
*
|
2012-06-12 00:07:50 +02:00
|
|
|
|
* Description: Default constructor. Initializes the attributes
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
|
|
|
|
\****************************************************************************/
|
2012-04-30 23:16:19 +10:00
|
|
|
|
|
|
|
|
|
FPSOUND();
|
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
/****************************************************************************\
|
|
|
|
|
*
|
|
|
|
|
* Function: FPSOUND::~FPSOUND();
|
|
|
|
|
*
|
2012-06-12 00:07:50 +02:00
|
|
|
|
* Description: Deinitialize the object, free memory
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
|
|
|
|
\****************************************************************************/
|
2012-04-30 23:16:19 +10:00
|
|
|
|
|
|
|
|
|
~FPSOUND();
|
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
/****************************************************************************\
|
|
|
|
|
*
|
2012-06-09 18:35:08 -04:00
|
|
|
|
* Function: bool FPSOUND::Init();
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
2012-06-12 00:07:50 +02:00
|
|
|
|
* Description: Initializes the objects, and prepare everything required to
|
|
|
|
|
* create streams and sound effects.
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
2012-06-12 00:07:50 +02:00
|
|
|
|
* Return: True if everything is OK, False otherwise.
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
|
|
|
|
\****************************************************************************/
|
2012-04-30 23:16:19 +10:00
|
|
|
|
|
2012-06-09 18:35:08 -04:00
|
|
|
|
bool Init();
|
2012-04-30 23:16:19 +10:00
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
/****************************************************************************\
|
|
|
|
|
*
|
|
|
|
|
* Function: bool CreateStream(FPSTREAM** lplpStream);
|
|
|
|
|
*
|
2012-06-12 00:07:50 +02:00
|
|
|
|
* Description: Allocates an object of type FPSTREAM, and return its
|
|
|
|
|
* pointer after it has been initialized.
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
2012-06-12 00:07:50 +02:00
|
|
|
|
* Input: FPSTREAM** lplpStream Will contain the pointer of the
|
|
|
|
|
* object
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
2012-06-12 00:07:50 +02:00
|
|
|
|
* Return: True is everything i OK, False otherwise
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
2012-06-12 00:07:50 +02:00
|
|
|
|
* Note: The use of functions like CreateStream () and CreateSfx ()
|
|
|
|
|
* are due to the fact that the class constructors and
|
|
|
|
|
* FPSTREAM FPSFX require that DirectSound is already initialized.
|
|
|
|
|
* In this way, you avoid the bugs that would be created if an
|
|
|
|
|
* object type is declared FPSTREAM FPSFX or global
|
|
|
|
|
* (or anyway before initializing DirectSound).
|
2012-05-21 23:53:13 +02:00
|
|
|
|
\****************************************************************************/
|
2012-04-30 23:16:19 +10:00
|
|
|
|
|
|
|
|
|
bool CreateStream(FPSTREAM **lplpStream);
|
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
/****************************************************************************\
|
|
|
|
|
*
|
|
|
|
|
* Function: bool CreateSfx(FPSFX** lplpSfx);
|
|
|
|
|
*
|
2012-06-12 00:07:50 +02:00
|
|
|
|
* Description: Allocates an object of type FPSFX and returns a pointer
|
|
|
|
|
* pointing to it
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
2012-06-12 00:07:50 +02:00
|
|
|
|
* Input: FPSFX** lplpSfx Will contain the pointer of the
|
|
|
|
|
* object
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
2012-06-12 00:07:50 +02:00
|
|
|
|
* Return: True is everything i OK, False otherwise
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
2012-06-12 00:07:50 +02:00
|
|
|
|
* Note: See notes about CreateStream()
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
|
|
|
|
\****************************************************************************/
|
2012-04-30 23:16:19 +10:00
|
|
|
|
|
|
|
|
|
bool CreateSfx(FPSFX **lplpSfx);
|
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
/****************************************************************************\
|
|
|
|
|
*
|
|
|
|
|
* Function: void SetMasterVolume(int dwVolume);
|
|
|
|
|
*
|
2012-06-12 00:07:50 +02:00
|
|
|
|
* Description: Set main volume
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
2012-06-12 00:07:50 +02:00
|
|
|
|
* Input: int dwVolume Volume to be set (0-63)
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
|
|
|
|
\****************************************************************************/
|
2012-04-30 23:16:19 +10:00
|
|
|
|
|
|
|
|
|
void SetMasterVolume(int dwVolume);
|
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
/****************************************************************************\
|
|
|
|
|
*
|
|
|
|
|
* Function: void GetMasterVolume(LPINT lpdwVolume);
|
|
|
|
|
*
|
2012-06-12 00:07:50 +02:00
|
|
|
|
* Description: Get main volume
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
2012-06-12 00:07:50 +02:00
|
|
|
|
* Input: LPINT lpdwVolume This variable will contain the
|
|
|
|
|
* current volume (0-63)
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
|
|
|
|
\****************************************************************************/
|
2012-04-30 23:16:19 +10:00
|
|
|
|
|
|
|
|
|
void GetMasterVolume(int *lpdwVolume);
|
|
|
|
|
};
|
|
|
|
|
|
2012-04-30 09:27:12 +10:00
|
|
|
|
class FPSFX {
|
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
/****************************************************************************\
|
2012-06-12 00:07:50 +02:00
|
|
|
|
* Attributes
|
2012-05-21 23:53:13 +02:00
|
|
|
|
\****************************************************************************/
|
2012-04-30 09:27:12 +10:00
|
|
|
|
|
|
|
|
|
private:
|
2012-06-12 00:07:50 +02:00
|
|
|
|
bool bSoundSupported; // True if the sound is active
|
|
|
|
|
bool bFileLoaded; // True is a file is opened
|
|
|
|
|
bool bLoop; // True is sound effect should loop
|
2012-04-30 09:27:12 +10:00
|
|
|
|
int lastVolume;
|
|
|
|
|
|
|
|
|
|
bool bIsVoice;
|
2012-06-10 21:23:28 -04:00
|
|
|
|
bool bPaused;
|
2012-04-30 09:27:12 +10:00
|
|
|
|
|
2012-06-12 11:35:27 -04:00
|
|
|
|
Audio::AudioStream *_loopStream;
|
2012-06-10 22:03:52 -04:00
|
|
|
|
Audio::RewindableAudioStream *_rewindableStream;
|
2012-06-10 21:23:28 -04:00
|
|
|
|
Audio::SoundHandle _handle;
|
2012-05-21 23:53:13 +02:00
|
|
|
|
|
2012-04-30 09:27:12 +10:00
|
|
|
|
public:
|
2012-05-09 00:42:27 +10:00
|
|
|
|
uint32 hEndOfBuffer;
|
2012-04-30 09:27:12 +10:00
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
/****************************************************************************\
|
2012-06-12 00:07:50 +02:00
|
|
|
|
* Methods
|
2012-05-21 23:53:13 +02:00
|
|
|
|
\****************************************************************************/
|
2012-04-30 09:27:12 +10:00
|
|
|
|
|
|
|
|
|
public:
|
2012-06-11 12:20:12 +10:00
|
|
|
|
/**
|
|
|
|
|
* Check process for whether sounds have finished playing
|
|
|
|
|
*/
|
|
|
|
|
static void soundCheckProcess(CORO_PARAM, const void *param);
|
2012-04-30 09:27:12 +10:00
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
/****************************************************************************\
|
|
|
|
|
*
|
2012-06-09 18:35:08 -04:00
|
|
|
|
* Function: FPSFX(bool bSoundOn);
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
2012-06-12 00:07:50 +02:00
|
|
|
|
* Description: Default constructor. *DO NOT* declare the object directly,
|
|
|
|
|
* create it though FPSOUND::CreateSfx() instead
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
|
|
|
|
\****************************************************************************/
|
|
|
|
|
|
2012-06-09 18:35:08 -04:00
|
|
|
|
FPSFX(bool bSoundOn);
|
2012-05-21 23:53:13 +02:00
|
|
|
|
|
|
|
|
|
/****************************************************************************\
|
|
|
|
|
*
|
|
|
|
|
* Function: ~FPSFX();
|
|
|
|
|
*
|
2012-06-12 00:07:50 +02:00
|
|
|
|
* Description: Default destructor. It also stops the sound effect that
|
|
|
|
|
* may be running, and free the memory used.
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
|
|
|
|
\****************************************************************************/
|
|
|
|
|
|
|
|
|
|
~FPSFX();
|
|
|
|
|
|
|
|
|
|
/****************************************************************************\
|
|
|
|
|
*
|
|
|
|
|
* Function: Release();
|
|
|
|
|
*
|
2012-06-12 00:07:50 +02:00
|
|
|
|
* Description: Releases the memory object. Must be called when the object
|
|
|
|
|
* is no longer useful and **ONLY** when the object was created
|
|
|
|
|
* with the FPSOUND :: CreateStream ().
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
2012-06-12 00:07:50 +02:00
|
|
|
|
* Note: Any object pointers are no longer valid after this call.
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
|
|
|
|
\****************************************************************************/
|
2012-04-30 09:27:12 +10:00
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
void Release();
|
2012-04-30 09:27:12 +10:00
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
/****************************************************************************\
|
|
|
|
|
*
|
|
|
|
|
* Function: bool LoadFile(char *lpszFileName, uint32 dwCodec=FPCODEC_RAW);
|
|
|
|
|
*
|
2012-06-12 00:07:50 +02:00
|
|
|
|
* Description: Opens a file and load sound effect
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
2012-06-12 00:07:50 +02:00
|
|
|
|
* Input: char *lpszFile SFX filename
|
|
|
|
|
* uint32 dwCodec CODEC to be used to decompress
|
|
|
|
|
* the sound samples
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
2012-06-12 00:07:50 +02:00
|
|
|
|
* Return: True if everything is OK, False otherwise
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
|
|
|
|
\****************************************************************************/
|
2012-04-30 09:27:12 +10:00
|
|
|
|
|
2012-05-04 22:28:51 +10:00
|
|
|
|
bool LoadFile(const char *lpszFileName, uint32 dwCodec = FPCODEC_RAW);
|
2012-06-09 18:09:54 -04:00
|
|
|
|
bool loadWave(Common::SeekableReadStream *stream);
|
2012-05-03 21:43:00 +10:00
|
|
|
|
bool LoadVoiceFromVDB(Common::File &vdbFP);
|
2012-04-30 09:27:12 +10:00
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
/****************************************************************************\
|
|
|
|
|
*
|
|
|
|
|
* Function: bool Play();
|
|
|
|
|
*
|
2012-06-12 00:07:50 +02:00
|
|
|
|
* Description: Play the loaded FX.
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
2012-06-12 00:07:50 +02:00
|
|
|
|
* Return: True if everything is OK, False otherwise
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
|
|
|
|
\****************************************************************************/
|
2012-04-30 09:27:12 +10:00
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
bool Play();
|
2012-04-30 09:27:12 +10:00
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
/****************************************************************************\
|
|
|
|
|
*
|
|
|
|
|
* Function: bool Stop();
|
|
|
|
|
*
|
2012-06-12 00:07:50 +02:00
|
|
|
|
* Description: Stop a FX
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
2012-06-12 00:07:50 +02:00
|
|
|
|
* Return: True if everything is OK, False otherwise
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
|
|
|
|
\****************************************************************************/
|
2012-04-30 09:27:12 +10:00
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
bool Stop();
|
2012-04-30 09:27:12 +10:00
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
/****************************************************************************\
|
|
|
|
|
*
|
|
|
|
|
* Function: void Pause(bool bPause);
|
|
|
|
|
*
|
2012-06-12 00:07:50 +02:00
|
|
|
|
* Description: Pause a FX
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
|
|
|
|
\****************************************************************************/
|
2012-04-30 09:27:12 +10:00
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
void Pause(bool bPause);
|
2012-04-30 09:27:12 +10:00
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
/****************************************************************************\
|
|
|
|
|
*
|
|
|
|
|
* Function: bool SetLoop(bool bLoop);
|
|
|
|
|
*
|
2012-06-12 08:03:51 +02:00
|
|
|
|
* Description: Enables or disables SFX loop
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
2012-06-12 08:03:51 +02:00
|
|
|
|
* Input: bool bLoop True to activate the loop, else False
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
2012-06-12 08:03:51 +02:00
|
|
|
|
* Note: The loop must be activated before the SFX starts to play,
|
|
|
|
|
* else the effect will only be noticable next time the SFX is
|
|
|
|
|
* played
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
|
|
|
|
\****************************************************************************/
|
2012-04-30 09:27:12 +10:00
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
void SetLoop(bool bLoop);
|
2012-04-30 09:27:12 +10:00
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
/****************************************************************************\
|
|
|
|
|
*
|
|
|
|
|
* Function: void SetVolume(int dwVolume);
|
|
|
|
|
*
|
2012-06-12 08:03:51 +02:00
|
|
|
|
* Description: Set SFX Volume
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
2012-06-12 08:03:51 +02:00
|
|
|
|
* Input: int dwVolume Volume to set (0-63)
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
|
|
|
|
\****************************************************************************/
|
2012-04-30 09:27:12 +10:00
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
void SetVolume(int dwVolume);
|
2012-04-30 09:27:12 +10:00
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
/****************************************************************************\
|
|
|
|
|
*
|
|
|
|
|
* Function: void GetVolume(int * lpdwVolume);
|
|
|
|
|
*
|
2012-06-12 08:03:51 +02:00
|
|
|
|
* Description: Get SFX volume
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
2012-06-12 08:03:51 +02:00
|
|
|
|
* Input: int * lpdwVolume Will contain the current volume
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
|
|
|
|
\****************************************************************************/
|
2012-04-30 09:27:12 +10:00
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
void GetVolume(int *lpdwVolume);
|
2012-06-11 12:20:12 +10:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns true if the sound has finished playing
|
|
|
|
|
*/
|
|
|
|
|
bool endOfBuffer() const;
|
2012-04-30 09:27:12 +10:00
|
|
|
|
};
|
|
|
|
|
|
2012-04-30 23:16:19 +10:00
|
|
|
|
class FPSTREAM {
|
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
/****************************************************************************\
|
2012-06-12 08:03:51 +02:00
|
|
|
|
* Attributes
|
2012-05-21 23:53:13 +02:00
|
|
|
|
\****************************************************************************/
|
2012-04-30 23:16:19 +10:00
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
/*
|
|
|
|
|
HWND hwnd;
|
|
|
|
|
LPDIRECTSOUND lpDS;
|
2012-06-12 08:03:51 +02:00
|
|
|
|
LPDIRECTSOUNDBUFFER lpDSBuffer; // DirectSound circular buffer
|
|
|
|
|
LPDIRECTSOUNDNOTIFY lpDSNotify; // Notify hotspots in the buffer
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*/
|
2012-06-12 08:03:51 +02:00
|
|
|
|
byte *lpTempBuffer; // Temporary buffer use for decompression
|
2012-04-30 23:16:19 +10:00
|
|
|
|
|
2012-06-12 08:03:51 +02:00
|
|
|
|
uint32 dwBufferSize; // Buffer size (bytes)
|
|
|
|
|
uint32 dwSize; // Stream size (bytes)
|
|
|
|
|
uint32 dwCodec; // CODEC used
|
2012-04-30 23:16:19 +10:00
|
|
|
|
|
2012-06-12 08:03:51 +02:00
|
|
|
|
HANDLE hThreadEnd; // Event used to close thread
|
|
|
|
|
Common::File _file; // File handle used for the stream
|
|
|
|
|
HANDLE hPlayThread; // Handle of the Play thread
|
|
|
|
|
HANDLE hHot1, hHot2, hHot3; // Events set by DirectSoundNotify
|
2012-04-30 23:16:19 +10:00
|
|
|
|
HANDLE hPlayThread_PlayFast;
|
|
|
|
|
HANDLE hPlayThread_PlayNormal;
|
|
|
|
|
|
2012-06-12 08:03:51 +02:00
|
|
|
|
bool bSoundSupported; // True if the sound is active
|
|
|
|
|
bool bFileLoaded; // True if the file is open
|
|
|
|
|
bool bLoop; // True if the stream should loop
|
|
|
|
|
bool bDoFadeOut; // True if fade out is required
|
2012-04-30 23:16:19 +10:00
|
|
|
|
bool bSyncExit;
|
|
|
|
|
bool bPaused;
|
|
|
|
|
int lastVolume;
|
|
|
|
|
FPSTREAM *SyncToPlay;
|
|
|
|
|
// DSBPOSITIONNOTIFY dspnHot[3];
|
|
|
|
|
|
|
|
|
|
bool CreateBuffer(int nBufSize);
|
|
|
|
|
|
|
|
|
|
public:
|
2012-06-12 08:03:51 +02:00
|
|
|
|
bool bIsPlaying; // True if the stream is playing
|
2012-04-30 23:16:19 +10:00
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
static void PlayThread(FPSTREAM *This);
|
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
/****************************************************************************\
|
2012-06-12 08:03:51 +02:00
|
|
|
|
* Methods
|
2012-05-21 23:53:13 +02:00
|
|
|
|
\****************************************************************************/
|
2012-04-30 23:16:19 +10:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
/****************************************************************************\
|
|
|
|
|
*
|
2012-06-09 18:35:08 -04:00
|
|
|
|
* Function: FPSTREAM(bool bSoundOn);
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
2012-06-12 08:03:51 +02:00
|
|
|
|
* Description: Default contractor. *DO NOT* declare the object directly: use
|
|
|
|
|
* FPSOUND::CreateStream() indtead
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
|
|
|
|
\****************************************************************************/
|
2012-04-30 23:16:19 +10:00
|
|
|
|
|
2012-06-09 18:35:08 -04:00
|
|
|
|
FPSTREAM(bool bSoundOn);
|
2012-04-30 23:16:19 +10:00
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
/****************************************************************************\
|
|
|
|
|
*
|
|
|
|
|
* Function: ~FPSTREAM();
|
|
|
|
|
*
|
2012-06-12 08:03:51 +02:00
|
|
|
|
* Description: Destructor by default. Stops the playing stream (if any) and
|
|
|
|
|
* frees the memory used by them
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
|
|
|
|
\****************************************************************************/
|
2012-04-30 23:16:19 +10:00
|
|
|
|
|
|
|
|
|
~FPSTREAM();
|
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
/****************************************************************************\
|
|
|
|
|
*
|
|
|
|
|
* Function: Release();
|
|
|
|
|
*
|
2012-06-12 08:03:51 +02:00
|
|
|
|
* Description: Releases memory used by object. Must be used when the object
|
|
|
|
|
* is no longer used. *ONLY*<EFBFBD>for objects created by
|
|
|
|
|
* FPSOUND::CreateStream().
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
2012-06-12 08:03:51 +02:00
|
|
|
|
* Note: Object pointers are no longer valid after this call.
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
|
|
|
|
\****************************************************************************/
|
2012-04-30 23:16:19 +10:00
|
|
|
|
|
|
|
|
|
void Release();
|
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
/****************************************************************************\
|
|
|
|
|
*
|
|
|
|
|
* Function: bool LoadFile(char *lpszFileName, uint32 dwCodec=FPCODEC_RAW);
|
|
|
|
|
*
|
2012-06-12 08:03:51 +02:00
|
|
|
|
* Description: Open a file for a stream.
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
2012-06-12 08:03:51 +02:00
|
|
|
|
* Input: char *lpszFile Filename to be opened
|
|
|
|
|
* uint32 dwCodec CODEC to be used to decompress
|
|
|
|
|
* sound samples
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
2012-06-12 08:03:51 +02:00
|
|
|
|
* Return: True if everything is OK, False otherwise
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
|
|
|
|
\****************************************************************************/
|
2012-04-30 23:16:19 +10:00
|
|
|
|
|
2012-05-03 21:43:00 +10:00
|
|
|
|
bool LoadFile(const char *lpszFileName, uint32 dwCodec = FPCODEC_RAW, int nSync = 2000);
|
2012-04-30 23:16:19 +10:00
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
/****************************************************************************\
|
|
|
|
|
*
|
|
|
|
|
* Function: UnloadFile();
|
|
|
|
|
*
|
2012-06-12 08:03:51 +02:00
|
|
|
|
* Description: Close a file stream (if opened). This function must be
|
|
|
|
|
* called to free the memory used by the stream
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
2012-06-12 08:03:51 +02:00
|
|
|
|
* Return: Just to be sure, the destructor of this class calls
|
|
|
|
|
* UnloadFile() if it has not been mentioned explicitly
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
|
|
|
|
\****************************************************************************/
|
2012-04-30 23:16:19 +10:00
|
|
|
|
|
|
|
|
|
bool UnloadFile();
|
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
/****************************************************************************\
|
|
|
|
|
*
|
|
|
|
|
* Function: bool Play();
|
|
|
|
|
*
|
2012-06-12 08:03:51 +02:00
|
|
|
|
* Description: Play the loaded stream.
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
2012-06-12 08:03:51 +02:00
|
|
|
|
* Return: True if everything is OK, False otherwise
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
|
|
|
|
\****************************************************************************/
|
2012-04-30 23:16:19 +10:00
|
|
|
|
|
|
|
|
|
bool Play();
|
|
|
|
|
void PlayFast(void);
|
|
|
|
|
void Prefetch(void);
|
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
/****************************************************************************\
|
|
|
|
|
*
|
|
|
|
|
* Function: bool Stop();
|
|
|
|
|
*
|
2012-06-12 08:03:51 +02:00
|
|
|
|
* Description: Stops the play of the stream.
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
2012-06-12 08:03:51 +02:00
|
|
|
|
* Return: True if everything is OK, False otherwise
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
|
|
|
|
\****************************************************************************/
|
2012-04-30 23:16:19 +10:00
|
|
|
|
|
|
|
|
|
bool Stop(bool bSync = false);
|
2012-05-21 23:53:13 +02:00
|
|
|
|
void WaitForSync(FPSTREAM *toplay);
|
2012-04-30 23:16:19 +10:00
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
/****************************************************************************\
|
|
|
|
|
*
|
|
|
|
|
* Function: void Pause(bool bPause);
|
|
|
|
|
*
|
2012-06-12 08:03:51 +02:00
|
|
|
|
* Description: Pause sound effect
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
|
|
|
|
\****************************************************************************/
|
2012-04-30 23:16:19 +10:00
|
|
|
|
|
|
|
|
|
void Pause(bool bPause);
|
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
/****************************************************************************\
|
|
|
|
|
*
|
|
|
|
|
* Function: bool SetLoop(bool bLoop);
|
|
|
|
|
*
|
2012-06-12 08:03:51 +02:00
|
|
|
|
* Description: Enable of disable stream loop
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
2012-06-12 08:03:51 +02:00
|
|
|
|
* Input: bool bLoop True to enable loop, false otherwise
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
2012-06-12 08:03:51 +02:00
|
|
|
|
* Note: The loop must be activated BEFORE you play back the stream.
|
|
|
|
|
* Any changes made during play will not have 'effect until
|
|
|
|
|
* the stream is not stopped, and then comes back into play.
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
|
|
|
|
\****************************************************************************/
|
2012-04-30 23:16:19 +10:00
|
|
|
|
|
|
|
|
|
void SetLoop(bool bLoop);
|
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
/****************************************************************************\
|
|
|
|
|
*
|
|
|
|
|
* Function: void SetVolume(int dwVolume);
|
|
|
|
|
*
|
2012-06-12 08:03:51 +02:00
|
|
|
|
* Description: Change stream colume
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
2012-06-12 08:03:51 +02:00
|
|
|
|
* Input: int dwVolume Volume to be set (0-63)
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
|
|
|
|
\****************************************************************************/
|
2012-04-30 23:16:19 +10:00
|
|
|
|
|
|
|
|
|
void SetVolume(int dwVolume);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-21 23:53:13 +02:00
|
|
|
|
/****************************************************************************\
|
|
|
|
|
*
|
|
|
|
|
* Function: void GetVolume(LPINT lpdwVolume);
|
|
|
|
|
*
|
2012-06-12 08:03:51 +02:00
|
|
|
|
* Description: Get stream volume
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
2012-06-12 08:03:51 +02:00
|
|
|
|
* Input: LPINT lpdwVolume Will contain the current stream volume
|
2012-05-21 23:53:13 +02:00
|
|
|
|
*
|
|
|
|
|
\****************************************************************************/
|
2012-04-30 23:16:19 +10:00
|
|
|
|
|
|
|
|
|
void GetVolume(int *lpdwVolume);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2012-04-30 09:27:12 +10:00
|
|
|
|
} // End of namespace Tony
|
|
|
|
|
|
|
|
|
|
#endif
|