2007-01-15 12:09:25 -08:00
|
|
|
/*
|
|
|
|
This file is part of Warzone 2100.
|
|
|
|
Copyright (C) 1999-2004 Eidos Interactive
|
|
|
|
Copyright (C) 2005-2007 Warzone Resurrection Project
|
|
|
|
|
|
|
|
Warzone 2100 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.
|
|
|
|
|
|
|
|
Warzone 2100 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 Warzone 2100; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
2007-06-28 10:47:08 -07:00
|
|
|
/***************************************************************************/
|
|
|
|
|
|
|
|
#ifndef _TRACK_H_
|
|
|
|
#define _TRACK_H_
|
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
/* defines */
|
|
|
|
|
2006-12-30 14:01:34 -08:00
|
|
|
#include "lib/framework/frame.h"
|
2006-08-12 03:45:49 -07:00
|
|
|
|
2007-06-06 10:09:23 -07:00
|
|
|
#ifndef WZ_NOSOUND
|
|
|
|
# ifdef WZ_OS_MAC
|
|
|
|
# include <OpenAL/al.h>
|
|
|
|
# else
|
|
|
|
# include <AL/al.h>
|
|
|
|
# endif
|
2006-08-12 03:45:49 -07:00
|
|
|
#endif
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
#ifndef MAX_STR
|
|
|
|
#define MAX_STR 255
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define MAX_PITCH 127
|
|
|
|
|
|
|
|
#define SAMPLE_NOT_ALLOCATED -1
|
|
|
|
#define SAMPLE_NOT_FOUND -3
|
|
|
|
#define SAMPLE_COORD_INVALID -5
|
|
|
|
|
|
|
|
#define AUDIO_VOL_MIN 0L
|
|
|
|
#define AUDIO_VOL_MAX 100L
|
|
|
|
#define AUDIO_VOL_RANGE (AUDIO_VOL_MAX-AUDIO_VOL_MIN)
|
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
/* enums */
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
/* typedefs
|
|
|
|
*/
|
|
|
|
|
2007-04-12 03:31:11 -07:00
|
|
|
typedef BOOL (* AUDIO_CALLBACK) ( void *psObj );
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
/* structs */
|
|
|
|
|
|
|
|
typedef struct AUDIO_SAMPLE
|
|
|
|
{
|
2007-04-26 10:51:17 -07:00
|
|
|
SDWORD iTrack; // ID number identifying a specific sound; currently (r1182) mapped in audio_id.c
|
2007-06-06 10:09:23 -07:00
|
|
|
#ifndef WZ_NOSOUND
|
2007-04-09 07:35:02 -07:00
|
|
|
ALuint iSample; // OpenAL name of the sound source
|
2007-06-06 10:09:23 -07:00
|
|
|
#endif
|
2007-04-09 07:35:02 -07:00
|
|
|
SDWORD x, y, z;
|
2007-04-12 10:42:15 -07:00
|
|
|
BOOL bFinishedPlaying;
|
2007-04-09 07:35:02 -07:00
|
|
|
AUDIO_CALLBACK pCallback;
|
|
|
|
void *psObj;
|
|
|
|
struct AUDIO_SAMPLE *psPrev;
|
|
|
|
struct AUDIO_SAMPLE *psNext;
|
2007-03-16 09:20:16 -07:00
|
|
|
} AUDIO_SAMPLE;
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
typedef struct TRACK
|
|
|
|
{
|
2007-04-09 07:35:02 -07:00
|
|
|
BOOL bLoop;
|
|
|
|
SDWORD iVol;
|
|
|
|
SDWORD iAudibleRadius;
|
|
|
|
SDWORD iTime; // duration in milliseconds
|
|
|
|
UDWORD iTimeLastFinished; // time last finished in ms
|
|
|
|
UDWORD iNumPlaying;
|
2007-06-06 10:09:23 -07:00
|
|
|
#ifndef WZ_NOSOUND
|
2007-04-09 07:35:02 -07:00
|
|
|
ALuint iBufferName; // OpenAL name of the buffer
|
2007-06-06 10:09:23 -07:00
|
|
|
#endif
|
2007-04-09 07:35:02 -07:00
|
|
|
char *pName; // resource name of the track
|
2006-02-18 10:54:37 -08:00
|
|
|
} TRACK;
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
/* functions
|
|
|
|
*/
|
|
|
|
|
2007-07-13 16:15:24 -07:00
|
|
|
BOOL sound_Init(void);
|
2006-09-13 02:09:05 -07:00
|
|
|
BOOL sound_Shutdown(void);
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2007-04-08 14:39:24 -07:00
|
|
|
TRACK * sound_LoadTrackFromFile(const char *fileName);
|
2007-07-13 16:39:40 -07:00
|
|
|
unsigned int sound_SetTrackVals(const char* fileName, BOOL loop, unsigned int volume, unsigned int audibleRadius);
|
2007-02-19 13:52:27 -08:00
|
|
|
void sound_ReleaseTrack( TRACK * psTrack );
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
void sound_StopTrack( AUDIO_SAMPLE *psSample );
|
|
|
|
void sound_PauseTrack( AUDIO_SAMPLE *psSample );
|
|
|
|
void sound_UpdateSample( AUDIO_SAMPLE *psSample );
|
|
|
|
void sound_CheckAllUnloaded( void );
|
|
|
|
|
|
|
|
BOOL sound_CheckTrack( SDWORD iTrack );
|
|
|
|
|
|
|
|
SDWORD sound_GetTrackTime( SDWORD iTrack );
|
|
|
|
SDWORD sound_GetTrackAudibleRadius( SDWORD iTrack );
|
|
|
|
SDWORD sound_GetTrackVolume( SDWORD iTrack );
|
2006-09-17 13:39:25 -07:00
|
|
|
const char * sound_GetTrackName( SDWORD iTrack );
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
BOOL sound_TrackLooped( SDWORD iTrack );
|
|
|
|
SDWORD sound_TrackAudibleRadius( SDWORD iTrack );
|
|
|
|
void sound_SetCallbackFunction( void * fn );
|
|
|
|
|
|
|
|
BOOL sound_Play2DTrack( AUDIO_SAMPLE *psSample, BOOL bQueued );
|
|
|
|
BOOL sound_Play3DTrack( AUDIO_SAMPLE *psSample );
|
2007-04-09 07:35:02 -07:00
|
|
|
void sound_PlayWithCallback( AUDIO_SAMPLE *psSample, SDWORD iCurTime, AUDIO_CALLBACK pDoneFunc );
|
2007-06-28 10:47:08 -07:00
|
|
|
void sound_FinishedCallback( AUDIO_SAMPLE *psSample );
|
|
|
|
|
|
|
|
BOOL sound_GetSystemActive( void );
|
|
|
|
SDWORD sound_GetTrackID( TRACK *psTrack );
|
|
|
|
SDWORD sound_GetAvailableID( void );
|
|
|
|
SDWORD sound_GetNumPlaying( SDWORD iTrack );
|
|
|
|
|
|
|
|
SDWORD sound_GetGlobalVolume( void );
|
|
|
|
void sound_SetGlobalVolume( SDWORD iVol );
|
|
|
|
|
|
|
|
void sound_SetStoppedCallback( AUDIO_CALLBACK pStopTrackCallback );
|
|
|
|
|
|
|
|
UDWORD sound_GetTrackTimeLastFinished( SDWORD iTrack );
|
|
|
|
void sound_SetTrackTimeLastFinished( SDWORD iTrack, UDWORD iTime );
|
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
|
|
|
|
#endif // _TRACK_H_
|
|
|
|
|
|
|
|
/***************************************************************************/
|