diff options
author | Paul Gilbert | 2012-04-30 23:16:19 +1000 |
---|---|---|
committer | Paul Gilbert | 2012-04-30 23:16:19 +1000 |
commit | 68bcaa61b9eb1108028b3db072ade95431b9f14f (patch) | |
tree | 604032ba514b785f5a3216e7d47c9d4906e32d49 /engines/tony/sound.h | |
parent | b0eef829728183b7ea170b30a33eca091bcc4574 (diff) | |
download | scummvm-rg350-68bcaa61b9eb1108028b3db072ade95431b9f14f.tar.gz scummvm-rg350-68bcaa61b9eb1108028b3db072ade95431b9f14f.tar.bz2 scummvm-rg350-68bcaa61b9eb1108028b3db072ade95431b9f14f.zip |
TONY: More header files and functionality added
Diffstat (limited to 'engines/tony/sound.h')
-rw-r--r-- | engines/tony/sound.h | 365 |
1 files changed, 361 insertions, 4 deletions
diff --git a/engines/tony/sound.h b/engines/tony/sound.h index 75a70553ef..c966c93888 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -54,7 +54,9 @@ namespace Tony { +class FPSTREAM; class FPSFX; +class CODEC; enum CODECS { FPCODEC_RAW, @@ -62,6 +64,144 @@ enum CODECS { FPCODEC_WAV }; + +/****************************************************************************\ +***************************************************************************** +* class FPSound +* ------------- +* Description: Sound driver per Falling Pumpkins +***************************************************************************** +\****************************************************************************/ + +class FPSOUND { + +private: + + bool bSoundSupported; +/* + LPDIRECTSOUND lpDS; + LPDIRECTSOUNDBUFFER lpDSBPrimary; + DSCAPS dscaps; + HWND hwnd; +*/ + +/****************************************************************************\ +* Metodi +\****************************************************************************/ + +public: + +/****************************************************************************\ +* +* Function: FPSOUND::FPSOUND(); +* +* Description: Costruttore di default. Inizializza gli attributi. +* +\****************************************************************************/ + + FPSOUND(); + + +/****************************************************************************\ +* +* Function: FPSOUND::~FPSOUND(); +* +* Description: Deinizializza l'oggetto, disallocando la memoria. +* +\****************************************************************************/ + + ~FPSOUND(); + + +/****************************************************************************\ +* +* Function: bool FPSOUND::Init(HWND hWnd); +* +* Description: Inizializza l'oggetto, e prepara tutto il necessario per +* creare stream e effetti sonori. +* +* Input: HWND hWnd Handle della finestra principale +* +* Return: True se tutto OK, FALSE in caso di errore. +* +\****************************************************************************/ + + + bool Init(/*HWND hWnd*/); + + +/****************************************************************************\ +* +* Function: bool CreateStream(FPSTREAM** lplpStream); +* +* Description: Alloca un oggetti di tipo FPSTREAM, e ritorna il suo +* puntatore dopo averlo inizializzato. +* +* Input: FPSTREAM** lplpStream Conterra' il pointer all'oggetto +* appena creato. +* +* Return: TRUE se tutto OK, FALSE in caso di errore +* +* Note: L'utilizzo di funzioni del tipo CreateStream(), CreateSfx(), +* sono dovute al fatto che i costruttori delle classi FPSTREAM +* e FPSFX richiedono che DirectSound sia gia' stato +* inzializzato. In questo modo quindi si evitano dei bugs +* che si verrebbero a creare se venisse dichiarata un oggetto +* di tipo FPSTREAM o FPSFX globale (o cmq prima della +* inizializzazione di DirectSound). +* +\****************************************************************************/ + + bool CreateStream(FPSTREAM **lplpStream); + + + +/****************************************************************************\ +* +* Function: bool CreateSfx(FPSFX** lplpSfx); +* +* Description: Alloca un oggetti di tipo FPSFX e ritorna il suo +* puntatore dopo averlo inizializzato. +* +* Input: FPSFX** lplpSfx Conterra' il pointer all'oggetto +* appena creato. +* +* Return: TRUE se tutto OK, FALSE in caso di errore +* +* Note: Vedi le note di CreateStream() +* +\****************************************************************************/ + + bool CreateSfx(FPSFX **lplpSfx); + + + +/****************************************************************************\ +* +* Function: void SetMasterVolume(int dwVolume); +* +* Description: Setta il volume generale +* +* Input: int dwVolume Volume da settare (0-63) +* +\****************************************************************************/ + + void SetMasterVolume(int dwVolume); + + +/****************************************************************************\ +* +* Function: void GetMasterVolume(LPINT lpdwVolume); +* +* Description: Richiede il volume generale +* +* Input: LPINT lpdwVolume Variabile che conterra' il volume (0-63) +* +\****************************************************************************/ + + void GetMasterVolume(int *lpdwVolume); +}; + class FPSFX { /****************************************************************************\ @@ -93,7 +233,7 @@ private: // DSBPOSITIONNOTIFY dspnHot[2]; public: -// HANDLE hEndOfBuffer; + HANDLE hEndOfBuffer; private: @@ -159,9 +299,9 @@ public: * \****************************************************************************/ - bool LoadFile(char *lpszFileName, uint32 dwCodec = FPCODEC_RAW); - bool LoadFile(byte *lpBuf, uint32 dwCodec); - bool LoadVoiceFromVDB(HANDLE hvdb); + bool LoadFile(char *lpszFileName, uint32 dwCodec = FPCODEC_RAW); + bool LoadFile(byte *lpBuf, uint32 dwCodec); + bool LoadVoiceFromVDB(Common::File &hvdb); /****************************************************************************\ @@ -249,6 +389,223 @@ public: void GetVolume(int * lpdwVolume); }; +class FPSTREAM { + +/****************************************************************************\ +* Attributi +\****************************************************************************/ + +private: + +/* + HWND hwnd; + LPDIRECTSOUND lpDS; + LPDIRECTSOUNDBUFFER lpDSBuffer; // Buffer DirectSound circolare + LPDIRECTSOUNDNOTIFY lpDSNotify; // Notify degli hotspot nel buffer +*/ + byte *lpTempBuffer; // Buffer temporaneo per decompressione + + uint32 dwBufferSize; // Dimensione del buffer in bytes + uint32 dwSize; // Dimensione dello stream in bytes + uint32 dwCodec; // CODEC utilizzato + + HANDLE hThreadEnd; // Evento per chiudere il thread + HANDLE hFile; // Handle del file di stream + HANDLE hPlayThread; // Handle del thread di play + HANDLE hHot1, hHot2, hHot3; // Eventi settati da DirectSoundNotify + HANDLE hPlayThread_PlayFast; + HANDLE hPlayThread_PlayNormal; + + bool bSoundSupported; // TRUE se il suono e' attivo + bool bFileLoaded; // TRUE se e' stato aperto un file + bool bLoop; // TRUE se bisogna loopare lo stream + bool bDoFadeOut; // TRUE se bisogna fare un fade out + bool bSyncExit; + bool bPaused; + int lastVolume; + FPSTREAM *SyncToPlay; +// DSBPOSITIONNOTIFY dspnHot[3]; + + CODEC *lpCodec; // CODEC da utilizzare. + bool CreateBuffer(int nBufSize); + +public: + bool bIsPlaying; // TRUE se si sta playando lo stream + +private: + + static void PlayThread(FPSTREAM *This); + +/****************************************************************************\ +* Metodi +\****************************************************************************/ + +public: + +/****************************************************************************\ +* +* Function: FPSTREAM(LPDIRECTSOUND lpDS, bool bSoundOn); +* +* Description: Costruttore di default. *NON* bisogna dichiarare direttamente +* un oggetto, ma crearlo piuttosto tramite FPSOUND::CreateStream() +* +\****************************************************************************/ + + FPSTREAM(void * /*LPDIRECTSOUND*/ lpDS, uint32 /*HWND hWnd */, bool bSoundOn); + + +/****************************************************************************\ +* +* Function: ~FPSTREAM(); +* +* Description: Distruttore di default. Si preoccupa anche di fermare stream +* eventualmente in esecuzione, e disallocare la memoria da +* essi occupata. +* +\****************************************************************************/ + + ~FPSTREAM(); + + +/****************************************************************************\ +* +* Function: Release(); +* +* Description: Rilascia la memoria dell'oggetto. Deve essere richiamata quando +* l'oggetto non serve piu' e **SOLO SE** l'oggetto e' stato +* creato con la FPSOUND::CreateStream(). +* +* Note: Eventuali puntatori all'oggetto non sono piu' validi dopo +* questa chiamata. +* +\****************************************************************************/ + + void Release(); + + +/****************************************************************************\ +* +* Function: bool LoadFile(char *lpszFileName, uint32 dwCodec=FPCODEC_RAW); +* +* Description: Apre un file di stream. +* +* Input: char *lpszFile Nome del file di stream da aprire +* uint32 dwCodec CODEC da utilizzare per decomprimere +* i campioni sonori +* +* Return: TRUE se tutto OK, FALSE in caso di errore +* +\****************************************************************************/ + + bool LoadFile(char *lpszFileName, uint32 dwCodec = FPCODEC_RAW, int nSync = 2000); + + + +/****************************************************************************\ +* +* Function: UnloadFile(); +* +* Description: Chiude un file di stream eventualmente aperto. E' necessario +* richiamare questa funzione per disallocare la memoria +* occupata dallo stream. +* +* Return: Il distruttore della classe per sicurezza richiama la +* UnloadFile() se non e' stata richiamata esplicitamente. +* +\****************************************************************************/ + + bool UnloadFile(); + + +/****************************************************************************\ +* +* Function: bool Play(); +* +* Description: Suona lo stream caricato. +* +* Return: TRUE se tutto OK, FALSE in caso di errore. +* +\****************************************************************************/ + + bool Play(); + void PlayFast(void); + void Prefetch(void); + + +/****************************************************************************\ +* +* Function: bool Stop(); +* +* Description: Ferma il play dello stream. +* +* Return: TRUE se tutto OK, FALSE in caso di errore. +* +\****************************************************************************/ + + bool Stop(bool bSync = false); + void WaitForSync(FPSTREAM* toplay); + + +/****************************************************************************\ +* +* Function: void Pause(bool bPause); +* +* Description: Pause dell'effetto sonoro +* +\****************************************************************************/ + + void Pause(bool bPause); + + +/****************************************************************************\ +* +* Function: bool SetLoop(bool bLoop); +* +* Description: Attiva o disattiva il loop dello stream. +* +* Input: bool bLoop TRUE per attivare il loop, FALSE per +* disattivarlo +* +* Note: Il loop deve essere attivato PRIMA di eseguire il play +* dello stream. Qualsiasi modifica effettuata durante il play +* non avra' effetto fino a che lo stream non viene fermato, +* e poi rimesso in play. +* +\****************************************************************************/ + + void SetLoop(bool bLoop); + + + +/****************************************************************************\ +* +* Function: void SetVolume(int dwVolume); +* +* Description: Cambia il volume dello stream +* +* Input: int dwVolume Volume da settare (0-63) +* +\****************************************************************************/ + + void SetVolume(int dwVolume); + + + +/****************************************************************************\ +* +* Function: void GetVolume(LPINT lpdwVolume); +* +* Description: Chiede il volume dello stream +* +* Input: LPINT lpdwVolume Variabile in cui verra' inserito +* il volume corrente +* +\****************************************************************************/ + + void GetVolume(int *lpdwVolume); +}; + + } // End of namespace Tony #endif |