diff --git a/JA2 Splash.cpp b/JA2 Splash.cpp index c9b48c9c..2cde93f0 100644 --- a/JA2 Splash.cpp +++ b/JA2 Splash.cpp @@ -12,8 +12,8 @@ extern HVSURFACE ghFrameBuffer; void InitJA2SplashScreen() { UINT32 uiLogoID = 0; - //HVSURFACE hVSurface; // unused jonathanl - // VSURFACE_DESC VSurfaceDesc; //unused jonathanl + HVSURFACE hVSurface; // unused jonathanl // lalien reenabled for international versions + VSURFACE_DESC VSurfaceDesc; //unused jonathanl // lalien reenabled for international versions INT32 i = 0; #if !defined( ENGLISH ) && defined( JA2TESTVERSION ) diff --git a/JA2.suo b/JA2.suo index 1a56a8c0..47503743 100644 Binary files a/JA2.suo and b/JA2.suo differ diff --git a/JA2.vcproj b/JA2.vcproj index b3577a3c..85f76a6d 100644 --- a/JA2.vcproj +++ b/JA2.vcproj @@ -544,7 +544,7 @@ Name="VCCustomBuildTool"/> - - - - - - - - - - - - - - - - - - - - - - - - - - = 8 ) + if( iStringPos >= 6 ) { break; } @@ -387,9 +387,6 @@ void ProcessPlayerInputActivationString( void ) if( NumberOfMercsOnPlayerTeam() >= 18 ) return; - char charPlayerActivationString[32]; - wcstombs(charPlayerActivationString,pPlayerActivationString,32); - //Madd multiple imps if( ( ( wcscmp(pPlayerActivationString, L"XEP624") == 0 ) || ( wcscmp(pPlayerActivationString, L"xep624") == 0 ) )&&( LaptopSaveInfo.fIMPCompletedFlag == FALSE ) &&( LaptopSaveInfo.gfNewGameLaptop < 2 ) ) if( ( ( wcscmp(pPlayerActivationString, L"XEP624") == 0 ) || ( wcscmp(pPlayerActivationString, L"xep624") == 0 ) ) &&( LaptopSaveInfo.gfNewGameLaptop < 2 ) ) { @@ -400,14 +397,10 @@ void ProcessPlayerInputActivationString( void ) } //Madd multiple imps else if( ( wcscmp(pPlayerActivationString, L"90210") == 0 ) && ( LaptopSaveInfo.fIMPCompletedFlag == FALSE ) ) - else if( wcscmp(pPlayerActivationString, L"90210") == 0 ) + // Madd: load characters by name: + else if ( ImpExists( (STR)pPlayerActivationString ) ) { - LoadImpCharacter( IMP_MERC_FILENAME ); - } - // Madd: load characters by name - else if ( ImpExists( charPlayerActivationString ) ) - { - LoadImpCharacter( charPlayerActivationString ); + LoadImpCharacter( (STR)pPlayerActivationString ); } else diff --git a/Laptop/IMP HomePage.h b/Laptop/IMP HomePage.h index c6d657b8..500ba641 100644 --- a/Laptop/IMP HomePage.h +++ b/Laptop/IMP HomePage.h @@ -12,7 +12,5 @@ void HandleImpHomePage( void ); #define MIN_GLOW_DELTA 100 #define CURSOR_HEIGHT GetFontHeight( FONT14ARIAL ) + 6 -#define IMP_MERC_FILENAME "IMP" - extern INT32 GlowColorsList[][3]; #endif \ No newline at end of file diff --git a/Laptop/laptop.cpp b/Laptop/laptop.cpp index 9fe6e72f..316c3941 100644 --- a/Laptop/laptop.cpp +++ b/Laptop/laptop.cpp @@ -4519,8 +4519,8 @@ BOOLEAN DisplayTitleBarMaximizeGraphic(BOOLEAN fForward, BOOLEAN fInit, UINT16 u sPosBottomY = LAPTOP_TITLE_BAR_HEIGHT; - SrcRect.iLeft = 0; - SrcRect.iTop = 0; + SrcRect.iLeft = iScreenWidthOffset; + SrcRect.iTop = iScreenHeightOffset; SrcRect.iRight = LAPTOP_TITLE_BAR_WIDTH; SrcRect.iBottom = LAPTOP_TITLE_BAR_HEIGHT; diff --git a/Standard Gaming Platform/JA2 SGP ALL.H b/Standard Gaming Platform/JA2 SGP ALL.H index d75a12ca..05b58d61 100644 --- a/Standard Gaming Platform/JA2 SGP ALL.H +++ b/Standard Gaming Platform/JA2 SGP ALL.H @@ -1,10 +1,15 @@ +/* + * ChangeLog: + * 10.12.2005 Lesh ripped out everything that refers to MSS + * 10.12.2005 Lesh added fmod.h + */ #ifndef __JA2_SGP_ALL_H #define __JA2_SGP_ALL_H #pragma message("GENERATED PCH FOR JA2 SGP PROJECT.") //#ifndef INITGUID -// #define INITGUID +// #define INITGUID //#endif @@ -13,9 +18,9 @@ #include "Button Sound Control.h" #include "Sound Control.h" #ifdef _JA2_RENDER_DIRTY - #include "Font Control.h" - #include "Render Dirty.h" - #include "utilities.h" + #include "Font Control.h" + #include "Render Dirty.h" + #include "utilities.h" #endif #include "input.h" #include "memman.h" @@ -28,8 +33,8 @@ #include #include "debug.h" #ifndef NO_ZLIB_COMPRESSION - #include "zlib.h" - #include "Compression.h" + #include "zlib.h" + #include "Compression.h" #endif #include "types.h" #include @@ -73,9 +78,9 @@ #include #include #include "Install.h" -#include "GameSettings.h" +#include "GameSettings.h" #ifdef _DEBUG - #include + #include #endif #include "mousesystem.h" #include "Mutex Manager.h" @@ -83,7 +88,7 @@ #include #include "vobject_private.h" #include "shading.h" -#include "mss.h" +//#include "mss.h" #include "imgfmt.h" #include "timer.h" #include "renderworld.h" @@ -94,5 +99,8 @@ #include "vsurface_private.h" #include "Timer Control.h" +// Lesh modifications +#include "fmod.h" +#include "fmod_errors.h" -#endif \ No newline at end of file +#endif diff --git a/Standard Gaming Platform/Standard Gaming Platform.vcproj b/Standard Gaming Platform/Standard Gaming Platform.vcproj index 8174b842..21594d6e 100644 --- a/Standard Gaming Platform/Standard Gaming Platform.vcproj +++ b/Standard Gaming Platform/Standard Gaming Platform.vcproj @@ -2748,15 +2748,18 @@ + + + + - - @@ -2874,9 +2877,6 @@ - - diff --git a/Standard Gaming Platform/fmod.h b/Standard Gaming Platform/fmod.h new file mode 100644 index 00000000..54d35629 --- /dev/null +++ b/Standard Gaming Platform/fmod.h @@ -0,0 +1,1224 @@ +/* ========================================================================================== */ +/* FMOD Main header file. Copyright (c), Firelight Technologies Pty, Ltd. 1999-2004. */ +/* ========================================================================================== */ + +#ifndef _FMOD_H_ +#define _FMOD_H_ + +/* ========================================================================================== */ +/* DEFINITIONS */ +/* ========================================================================================== */ + +#if (!defined(WIN32) && !defined(_WIN32) && !defined(__WIN32__) && !defined(_WIN64) && !defined(_WIN32_WCE) && !defined(_XBOX)) || (defined(__GNUC__) && defined(WIN32)) + #ifndef __cdecl + #define __cdecl + #endif + #ifndef __stdcall + #define __stdcall + #endif +#endif + +#if defined(_WIN32_WCE) + #define F_API _cdecl + #define F_CALLBACKAPI _cdecl +#else + #define F_API __stdcall + #define F_CALLBACKAPI __stdcall +#endif + +#ifdef DLL_EXPORTS + #define DLL_API __declspec(dllexport) +#else + #if defined(__LCC__) || defined(__MINGW32__) || defined(__CYGWIN32__) + #define DLL_API F_API + #else + #define DLL_API + #endif /* __LCC__ || __MINGW32__ || __CYGWIN32__ */ +#endif /* DLL_EXPORTS */ + +#define FMOD_VERSION 3.75f + +/* + FMOD defined types +*/ +typedef struct FSOUND_SAMPLE FSOUND_SAMPLE; +typedef struct FSOUND_STREAM FSOUND_STREAM; +typedef struct FSOUND_DSPUNIT FSOUND_DSPUNIT; +typedef struct FSOUND_SYNCPOINT FSOUND_SYNCPOINT; +typedef struct FMUSIC_MODULE FMUSIC_MODULE; + +/* + Callback types +*/ +typedef void * (F_CALLBACKAPI *FSOUND_OPENCALLBACK) (const char *name); +typedef void (F_CALLBACKAPI *FSOUND_CLOSECALLBACK) (void *handle); +typedef int (F_CALLBACKAPI *FSOUND_READCALLBACK) (void *buffer, int size, void *handle); +typedef int (F_CALLBACKAPI *FSOUND_SEEKCALLBACK) (void *handle, int pos, signed char mode); +typedef int (F_CALLBACKAPI *FSOUND_TELLCALLBACK) (void *handle); + +typedef void * (F_CALLBACKAPI *FSOUND_ALLOCCALLBACK) (unsigned int size); +typedef void * (F_CALLBACKAPI *FSOUND_REALLOCCALLBACK) (void *ptr, unsigned int size); +typedef void (F_CALLBACKAPI *FSOUND_FREECALLBACK) (void *ptr); + +typedef void * (F_CALLBACKAPI *FSOUND_DSPCALLBACK) (void *originalbuffer, void *newbuffer, int length, void *userdata); +typedef signed char (F_CALLBACKAPI *FSOUND_STREAMCALLBACK) (FSOUND_STREAM *stream, void *buff, int len, void *userdata); +typedef signed char (F_CALLBACKAPI *FSOUND_METADATACALLBACK)(char *name, char *value, void *userdata); +typedef void (F_CALLBACKAPI *FMUSIC_CALLBACK) (FMUSIC_MODULE *mod, unsigned char param); + + +/* +[ENUM] +[ + [DESCRIPTION] + On failure of commands in FMOD, use FSOUND_GetError to attain what happened. + + [SEE_ALSO] + FSOUND_GetError +] +*/ +enum FMOD_ERRORS +{ + FMOD_ERR_NONE, /* No errors */ + FMOD_ERR_BUSY, /* Cannot call this command after FSOUND_Init. Call FSOUND_Close first. */ + FMOD_ERR_UNINITIALIZED, /* This command failed because FSOUND_Init or FSOUND_SetOutput was not called */ + FMOD_ERR_INIT, /* Error initializing output device. */ + FMOD_ERR_ALLOCATED, /* Error initializing output device, but more specifically, the output device is already in use and cannot be reused. */ + FMOD_ERR_PLAY, /* Playing the sound failed. */ + FMOD_ERR_OUTPUT_FORMAT, /* Soundcard does not support the features needed for this soundsystem (16bit stereo output) */ + FMOD_ERR_COOPERATIVELEVEL, /* Error setting cooperative level for hardware. */ + FMOD_ERR_CREATEBUFFER, /* Error creating hardware sound buffer. */ + FMOD_ERR_FILE_NOTFOUND, /* File not found */ + FMOD_ERR_FILE_FORMAT, /* Unknown file format */ + FMOD_ERR_FILE_BAD, /* Error loading file */ + FMOD_ERR_MEMORY, /* Not enough memory or resources */ + FMOD_ERR_VERSION, /* The version number of this file format is not supported */ + FMOD_ERR_INVALID_PARAM, /* An invalid parameter was passed to this function */ + FMOD_ERR_NO_EAX, /* Tried to use an EAX command on a non EAX enabled channel or output. */ + FMOD_ERR_CHANNEL_ALLOC, /* Failed to allocate a new channel */ + FMOD_ERR_RECORD, /* Recording is not supported on this machine */ + FMOD_ERR_MEDIAPLAYER, /* Windows Media Player not installed so cannot play wma or use internet streaming. */ + FMOD_ERR_CDDEVICE /* An error occured trying to open the specified CD device */ +}; + + +/* +[ENUM] +[ + [DESCRIPTION] + These output types are used with FSOUND_SetOutput, to choose which output driver to use. + + FSOUND_OUTPUT_DSOUND will not support hardware 3d acceleration if the sound card driver + does not support DirectX 6 Voice Manager Extensions. + + FSOUND_OUTPUT_WINMM is recommended for NT and CE. + + [SEE_ALSO] + FSOUND_SetOutput + FSOUND_GetOutput +] +*/ +enum FSOUND_OUTPUTTYPES +{ + FSOUND_OUTPUT_NOSOUND, /* NoSound driver, all calls to this succeed but do nothing. */ + FSOUND_OUTPUT_WINMM, /* Windows Multimedia driver. */ + FSOUND_OUTPUT_DSOUND, /* DirectSound driver. You need this to get EAX2 or EAX3 support, or FX api support. */ + FSOUND_OUTPUT_A3D, /* A3D driver. */ + + FSOUND_OUTPUT_OSS, /* Linux/Unix OSS (Open Sound System) driver, i.e. the kernel sound drivers. */ + FSOUND_OUTPUT_ESD, /* Linux/Unix ESD (Enlightment Sound Daemon) driver. */ + FSOUND_OUTPUT_ALSA, /* Linux Alsa driver. */ + + FSOUND_OUTPUT_ASIO, /* Low latency ASIO driver */ + FSOUND_OUTPUT_XBOX, /* Xbox driver */ + FSOUND_OUTPUT_PS2, /* PlayStation 2 driver */ + FSOUND_OUTPUT_MAC, /* Mac SoundManager driver */ + FSOUND_OUTPUT_GC, /* Gamecube driver */ + FSOUND_OUTPUT_PSP, /* PlayStation Portable driver */ + + FSOUND_OUTPUT_NOSOUND_NONREALTIME /* This is the same as nosound, but the sound generation is driven by FSOUND_Update */ +}; + + +/* +[ENUM] +[ + [DESCRIPTION] + These mixer types are used with FSOUND_SetMixer, to choose which mixer to use, or to act + upon for other reasons using FSOUND_GetMixer. + It is not nescessary to set the mixer. FMOD will autodetect the best mixer for you. + + [SEE_ALSO] + FSOUND_SetMixer + FSOUND_GetMixer +] +*/ +enum FSOUND_MIXERTYPES +{ + FSOUND_MIXER_AUTODETECT, /* CE/PS2/GC Only - Non interpolating/low quality mixer. */ + FSOUND_MIXER_BLENDMODE, /* Removed / obsolete. */ + FSOUND_MIXER_MMXP5, /* Removed / obsolete. */ + FSOUND_MIXER_MMXP6, /* Removed / obsolete. */ + + FSOUND_MIXER_QUALITY_AUTODETECT,/* All platforms - Autodetect the fastest quality mixer based on your cpu. */ + FSOUND_MIXER_QUALITY_FPU, /* Win32/Linux only - Interpolating/volume ramping FPU mixer. */ + FSOUND_MIXER_QUALITY_MMXP5, /* Win32/Linux only - Interpolating/volume ramping P5 MMX mixer. */ + FSOUND_MIXER_QUALITY_MMXP6, /* Win32/Linux only - Interpolating/volume ramping ppro+ MMX mixer. */ + + FSOUND_MIXER_MONO, /* CE/PS2/GC only - MONO non interpolating/low quality mixer. For speed*/ + FSOUND_MIXER_QUALITY_MONO, /* CE/PS2/GC only - MONO Interpolating mixer. For speed */ + + FSOUND_MIXER_MAX +}; + + +/* +[ENUM] +[ + [DESCRIPTION] + These definitions describe the type of song being played. + + [SEE_ALSO] + FMUSIC_GetType +] +*/ +enum FMUSIC_TYPES +{ + FMUSIC_TYPE_NONE, + FMUSIC_TYPE_MOD, /* Protracker / Fasttracker */ + FMUSIC_TYPE_S3M, /* ScreamTracker 3 */ + FMUSIC_TYPE_XM, /* FastTracker 2 */ + FMUSIC_TYPE_IT, /* Impulse Tracker. */ + FMUSIC_TYPE_MIDI, /* MIDI file */ + FMUSIC_TYPE_FSB /* FMOD Sample Bank file */ +}; + + +/* +[DEFINE_START] +[ + [NAME] + FSOUND_DSP_PRIORITIES + + [DESCRIPTION] + These default priorities are used by FMOD internal system DSP units. They describe the + position of the DSP chain, and the order of how audio processing is executed. + You can actually through the use of FSOUND_DSP_GetxxxUnit (where xxx is the name of the DSP + unit), disable or even change the priority of a DSP unit. + + [SEE_ALSO] + FSOUND_DSP_Create + FSOUND_DSP_SetPriority + FSOUND_DSP_GetSpectrum +] +*/ +#define FSOUND_DSP_DEFAULTPRIORITY_CLEARUNIT 0 /* DSP CLEAR unit - done first */ +#define FSOUND_DSP_DEFAULTPRIORITY_SFXUNIT 100 /* DSP SFX unit - done second */ +#define FSOUND_DSP_DEFAULTPRIORITY_MUSICUNIT 200 /* DSP MUSIC unit - done third */ +#define FSOUND_DSP_DEFAULTPRIORITY_USER 300 /* User priority, use this as reference for your own DSP units */ +#define FSOUND_DSP_DEFAULTPRIORITY_FFTUNIT 900 /* This reads data for FSOUND_DSP_GetSpectrum, so it comes after user units */ +#define FSOUND_DSP_DEFAULTPRIORITY_CLIPANDCOPYUNIT 1000 /* DSP CLIP AND COPY unit - last */ +/* [DEFINE_END] */ + + +/* +[DEFINE_START] +[ + [NAME] + FSOUND_CAPS + + [DESCRIPTION] + Driver description bitfields. Use FSOUND_Driver_GetCaps to determine if a driver enumerated + has the settings you are after. The enumerated driver depends on the output mode, see + FSOUND_OUTPUTTYPES + + [SEE_ALSO] + FSOUND_GetDriverCaps + FSOUND_OUTPUTTYPES +] +*/ +#define FSOUND_CAPS_HARDWARE 0x1 /* This driver supports hardware accelerated 3d sound. */ +#define FSOUND_CAPS_EAX2 0x2 /* This driver supports EAX 2 reverb */ +#define FSOUND_CAPS_EAX3 0x10 /* This driver supports EAX 3 reverb */ +/* [DEFINE_END] */ + + +/* +[DEFINE_START] +[ + [NAME] + FSOUND_MODES + + [DESCRIPTION] + Sample description bitfields, OR them together for loading and describing samples. + NOTE. If the file format being loaded already has a defined format, such as WAV or MP3, then + trying to override the pre-defined format with a new set of format flags will not work. For + example, an 8 bit WAV file will not load as 16bit if you specify FSOUND_16BITS. It will just + ignore the flag and go ahead loading it as 8bits. For these type of formats the only flags + you can specify that will really alter the behaviour of how it is loaded, are the following. + --------- + Looping behaviour - FSOUND_LOOP_OFF, FSOUND_LOOP_NORMAL, FSOUND_LOOP_BIDI + Load destination - FSOUND_HW3D, FSOUND_HW2D, FSOUND_2D + Loading behaviour - FSOUND_NONBLOCKING, FSOUND_LOADMEMORY, FSOUND_LOADRAW, FSOUND_MPEGACCURATE, FSOUND_MPEGHALFRATE, FSOUND_FORCEMONO + Playback behaviour - FSOUND_STREAMABLE, FSOUND_ENABLEFX + PlayStation 2 only - FSOUND_USECORE0, FSOUND_USECORE1, FSOUND_LOADMEMORYIOP + --------- + See flag descriptions for what these do. +] +*/ +#define FSOUND_LOOP_OFF 0x00000001 /* For non looping samples. */ +#define FSOUND_LOOP_NORMAL 0x00000002 /* For forward looping samples. */ +#define FSOUND_LOOP_BIDI 0x00000004 /* For bidirectional looping samples. (no effect if in hardware). */ +#define FSOUND_8BITS 0x00000008 /* For 8 bit samples. */ +#define FSOUND_16BITS 0x00000010 /* For 16 bit samples. */ +#define FSOUND_MONO 0x00000020 /* For mono samples. */ +#define FSOUND_STEREO 0x00000040 /* For stereo samples. */ +#define FSOUND_UNSIGNED 0x00000080 /* For user created source data containing unsigned samples. */ +#define FSOUND_SIGNED 0x00000100 /* For user created source data containing signed data. */ +#define FSOUND_DELTA 0x00000200 /* For user created source data stored as delta values. */ +#define FSOUND_IT214 0x00000400 /* For user created source data stored using IT214 compression. */ +#define FSOUND_IT215 0x00000800 /* For user created source data stored using IT215 compression. */ +#define FSOUND_HW3D 0x00001000 /* Attempts to make samples use 3d hardware acceleration. (if the card supports it) */ +#define FSOUND_2D 0x00002000 /* Tells software (not hardware) based sample not to be included in 3d processing. */ +#define FSOUND_STREAMABLE 0x00004000 /* For a streamimg sound where you feed the data to it. */ +#define FSOUND_LOADMEMORY 0x00008000 /* "name" will be interpreted as a pointer to data for streaming and samples. */ +#define FSOUND_LOADRAW 0x00010000 /* Will ignore file format and treat as raw pcm. */ +#define FSOUND_MPEGACCURATE 0x00020000 /* For FSOUND_Stream_Open - for accurate FSOUND_Stream_GetLengthMs/FSOUND_Stream_SetTime. WARNING, see FSOUND_Stream_Open for inital opening time performance issues. */ +#define FSOUND_FORCEMONO 0x00040000 /* For forcing stereo streams and samples to be mono - needed if using FSOUND_HW3D and stereo data - incurs a small speed hit for streams */ +#define FSOUND_HW2D 0x00080000 /* 2D hardware sounds. allows hardware specific effects */ +#define FSOUND_ENABLEFX 0x00100000 /* Allows DX8 FX to be played back on a sound. Requires DirectX 8 - Note these sounds cannot be played more than once, be 8 bit, be less than a certain size, or have a changing frequency */ +#define FSOUND_MPEGHALFRATE 0x00200000 /* For FMODCE only - decodes mpeg streams using a lower quality decode, but faster execution */ +#define FSOUND_IMAADPCM 0x00400000 /* Contents are stored compressed as IMA ADPCM */ +#define FSOUND_VAG 0x00800000 /* For PS2 only - Contents are compressed as Sony VAG format */ +#define FSOUND_NONBLOCKING 0x01000000 /* For FSOUND_Stream_Open/FMUSIC_LoadSong - Causes stream or music to open in the background and not block the foreground app. See FSOUND_Stream_GetOpenState or FMUSIC_GetOpenState to determine when it IS ready. */ +#define FSOUND_GCADPCM 0x02000000 /* For Gamecube only - Contents are compressed as Gamecube DSP-ADPCM format */ +#define FSOUND_MULTICHANNEL 0x04000000 /* For PS2 and Gamecube only - Contents are interleaved into a multi-channel (more than stereo) format */ +#define FSOUND_USECORE0 0x08000000 /* For PS2 only - Sample/Stream is forced to use hardware voices 00-23 */ +#define FSOUND_USECORE1 0x10000000 /* For PS2 only - Sample/Stream is forced to use hardware voices 24-47 */ +#define FSOUND_LOADMEMORYIOP 0x20000000 /* For PS2 only - "name" will be interpreted as a pointer to data for streaming and samples. The address provided will be an IOP address */ +#define FSOUND_IGNORETAGS 0x40000000 /* Skips id3v2 etc tag checks when opening a stream, to reduce seek/read overhead when opening files (helps with CD performance) */ +#define FSOUND_STREAM_NET 0x80000000 /* Specifies an internet stream */ + +#define FSOUND_NORMAL (FSOUND_16BITS | FSOUND_SIGNED | FSOUND_MONO) +/* [DEFINE_END] */ + + + +/* +[DEFINE_START] +[ + [NAME] + FSOUND_CDPLAYMODES + + [DESCRIPTION] + Playback method for a CD Audio track, with FSOUND_CD_SetPlayMode + + [SEE_ALSO] + FSOUND_CD_SetPlayMode + FSOUND_CD_Play +] +*/ +#define FSOUND_CD_PLAYCONTINUOUS 0 /* Starts from the current track and plays to end of CD. */ +#define FSOUND_CD_PLAYONCE 1 /* Plays the specified track then stops. */ +#define FSOUND_CD_PLAYLOOPED 2 /* Plays the specified track looped, forever until stopped manually. */ +#define FSOUND_CD_PLAYRANDOM 3 /* Plays tracks in random order */ +/* [DEFINE_END] */ + + +/* +[DEFINE_START] +[ + [NAME] + FSOUND_MISC_VALUES + + [DESCRIPTION] + Miscellaneous values for FMOD functions. + + [SEE_ALSO] + FSOUND_PlaySound + FSOUND_PlaySoundEx + FSOUND_Sample_Alloc + FSOUND_Sample_Load + FSOUND_SetPan +] +*/ +#define FSOUND_FREE -1 /* value to play on any free channel, or to allocate a sample in a free sample slot. */ +#define FSOUND_UNMANAGED -2 /* value to allocate a sample that is NOT managed by FSOUND or placed in a sample slot. */ +#define FSOUND_ALL -3 /* for a channel index , this flag will affect ALL channels available! Not supported by every function. */ +#define FSOUND_STEREOPAN -1 /* value for FSOUND_SetPan so that stereo sounds are not played at half volume. See FSOUND_SetPan for more on this. */ +#define FSOUND_SYSTEMCHANNEL -1000 /* special 'channel' ID for all channel based functions that want to alter the global FSOUND software mixing output channel */ +#define FSOUND_SYSTEMSAMPLE -1000 /* special 'sample' ID for all sample based functions that want to alter the global FSOUND software mixing output sample */ + +/* [DEFINE_END] */ + + +/* +[STRUCTURE] +[ + [DESCRIPTION] + Structure defining a reverb environment. + For more indepth descriptions of the reverb properties under win32, please see the EAX2 and EAX3 + documentation at http://developer.creative.com/ under the 'downloads' section. + If they do not have the EAX3 documentation, then most information can be attained from + the EAX2 documentation, as EAX3 only adds some more parameters and functionality on top of EAX2. + Note the default reverb properties are the same as the FSOUND_PRESET_GENERIC preset. + Note that integer values that typically range from -10,000 to 1000 are represented in decibels, and are of a logarithmic scale, not linear, wheras float values are typically linear. + PORTABILITY: Each member has the platform it supports in braces ie (win32/xbox). + Some reverb parameters are only supported in win32 and some only on xbox. If all parameters are set then the reverb should product a similar effect on either platform. + + The numerical values listed below are the maximum, minimum and default values for each variable respectively. + + [SEE_ALSO] + FSOUND_Reverb_SetProperties + FSOUND_Reverb_GetProperties + FSOUND_REVERB_PRESETS + FSOUND_REVERB_FLAGS +] +*/ +typedef struct _FSOUND_REVERB_PROPERTIES /* MIN MAX DEFAULT DESCRIPTION */ +{ + unsigned int Environment; /* 0 , 25 , 0 , sets all listener properties (WIN32/PS2 only) */ + float EnvSize; /* 1.0 , 100.0 , 7.5 , environment size in meters (WIN32 only) */ + float EnvDiffusion; /* 0.0 , 1.0 , 1.0 , environment diffusion (WIN32/XBOX) */ + int Room; /* -10000, 0 , -1000 , room effect level (at mid frequencies) (WIN32/XBOX/PS2) */ + int RoomHF; /* -10000, 0 , -100 , relative room effect level at high frequencies (WIN32/XBOX) */ + int RoomLF; /* -10000, 0 , 0 , relative room effect level at low frequencies (WIN32 only) */ + float DecayTime; /* 0.1 , 20.0 , 1.49 , reverberation decay time at mid frequencies (WIN32/XBOX) */ + float DecayHFRatio; /* 0.1 , 2.0 , 0.83 , high-frequency to mid-frequency decay time ratio (WIN32/XBOX) */ + float DecayLFRatio; /* 0.1 , 2.0 , 1.0 , low-frequency to mid-frequency decay time ratio (WIN32 only) */ + int Reflections; /* -10000, 1000 , -2602 , early reflections level relative to room effect (WIN32/XBOX) */ + float ReflectionsDelay; /* 0.0 , 0.3 , 0.007 , initial reflection delay time (WIN32/XBOX) */ + float ReflectionsPan[3]; /* , , [0,0,0], early reflections panning vector (WIN32 only) */ + int Reverb; /* -10000, 2000 , 200 , late reverberation level relative to room effect (WIN32/XBOX) */ + float ReverbDelay; /* 0.0 , 0.1 , 0.011 , late reverberation delay time relative to initial reflection (WIN32/XBOX) */ + float ReverbPan[3]; /* , , [0,0,0], late reverberation panning vector (WIN32 only) */ + float EchoTime; /* .075 , 0.25 , 0.25 , echo time (WIN32/PS2 only. PS2 = Delay time for ECHO/DELAY modes only) */ + float EchoDepth; /* 0.0 , 1.0 , 0.0 , echo depth (WIN32/PS2 only. PS2 = Feedback level for ECHO mode only) */ + float ModulationTime; /* 0.04 , 4.0 , 0.25 , modulation time (WIN32 only) */ + float ModulationDepth; /* 0.0 , 1.0 , 0.0 , modulation depth (WIN32 only) */ + float AirAbsorptionHF; /* -100 , 0.0 , -5.0 , change in level per meter at high frequencies (WIN32 only) */ + float HFReference; /* 1000.0, 20000 , 5000.0 , reference high frequency (hz) (WIN32/XBOX) */ + float LFReference; /* 20.0 , 1000.0, 250.0 , reference low frequency (hz) (WIN32 only) */ + float RoomRolloffFactor; /* 0.0 , 10.0 , 0.0 , like FSOUND_3D_SetRolloffFactor but for room effect (WIN32/XBOX) */ + float Diffusion; /* 0.0 , 100.0 , 100.0 , Value that controls the echo density in the late reverberation decay. (XBOX only) */ + float Density; /* 0.0 , 100.0 , 100.0 , Value that controls the modal density in the late reverberation decay (XBOX only) */ + unsigned int Flags; /* FSOUND_REVERB_FLAGS - modifies the behavior of above properties (WIN32/PS2 only) */ +} FSOUND_REVERB_PROPERTIES; + + +/* +[DEFINE_START] +[ + [NAME] + FSOUND_REVERB_FLAGS + + [DESCRIPTION] + Values for the Flags member of the FSOUND_REVERB_PROPERTIES structure. + + [SEE_ALSO] + FSOUND_REVERB_PROPERTIES +] +*/ +#define FSOUND_REVERB_FLAGS_DECAYTIMESCALE 0x00000001 /* 'EnvSize' affects reverberation decay time */ +#define FSOUND_REVERB_FLAGS_REFLECTIONSSCALE 0x00000002 /* 'EnvSize' affects reflection level */ +#define FSOUND_REVERB_FLAGS_REFLECTIONSDELAYSCALE 0x00000004 /* 'EnvSize' affects initial reflection delay time */ +#define FSOUND_REVERB_FLAGS_REVERBSCALE 0x00000008 /* 'EnvSize' affects reflections level */ +#define FSOUND_REVERB_FLAGS_REVERBDELAYSCALE 0x00000010 /* 'EnvSize' affects late reverberation delay time */ +#define FSOUND_REVERB_FLAGS_DECAYHFLIMIT 0x00000020 /* AirAbsorptionHF affects DecayHFRatio */ +#define FSOUND_REVERB_FLAGS_ECHOTIMESCALE 0x00000040 /* 'EnvSize' affects echo time */ +#define FSOUND_REVERB_FLAGS_MODULATIONTIMESCALE 0x00000080 /* 'EnvSize' affects modulation time */ +#define FSOUND_REVERB_FLAGS_CORE0 0x00000100 /* PS2 Only - Reverb is applied to CORE0 (hw voices 0-23) */ +#define FSOUND_REVERB_FLAGS_CORE1 0x00000200 /* PS2 Only - Reverb is applied to CORE1 (hw voices 24-47) */ +#define FSOUND_REVERB_FLAGS_DEFAULT (FSOUND_REVERB_FLAGS_DECAYTIMESCALE | \ + FSOUND_REVERB_FLAGS_REFLECTIONSSCALE | \ + FSOUND_REVERB_FLAGS_REFLECTIONSDELAYSCALE | \ + FSOUND_REVERB_FLAGS_REVERBSCALE | \ + FSOUND_REVERB_FLAGS_REVERBDELAYSCALE | \ + FSOUND_REVERB_FLAGS_DECAYHFLIMIT | \ + FSOUND_REVERB_FLAGS_CORE0 | \ + FSOUND_REVERB_FLAGS_CORE1 ) +/* [DEFINE_END] */ + + + + +/* +[DEFINE_START] +[ + [NAME] + FSOUND_REVERB_PRESETS + + [DESCRIPTION] + A set of predefined environment PARAMETERS, created by Creative Labs + These are used to initialize an FSOUND_REVERB_PROPERTIES structure statically. + ie + FSOUND_REVERB_PROPERTIES prop = FSOUND_PRESET_GENERIC; + + [SEE_ALSO] + FSOUND_Reverb_SetProperties +] +*/ +/* Env Size Diffus Room RoomHF RmLF DecTm DecHF DecLF Refl RefDel RefPan Revb RevDel ReverbPan EchoTm EchDp ModTm ModDp AirAbs HFRef LFRef RRlOff Diffus Densty FLAGS */ +#define FSOUND_PRESET_OFF {0, 7.5f, 1.00f, -10000, -10000, 0, 1.00f, 1.00f, 1.0f, -2602, 0.007f, { 0.0f,0.0f,0.0f }, 200, 0.011f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 0.0f, 0.0f, 0x33f } +#define FSOUND_PRESET_GENERIC {0, 7.5f, 1.00f, -1000, -100, 0, 1.49f, 0.83f, 1.0f, -2602, 0.007f, { 0.0f,0.0f,0.0f }, 200, 0.011f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f } +#define FSOUND_PRESET_PADDEDCELL {1, 1.4f, 1.00f, -1000, -6000, 0, 0.17f, 0.10f, 1.0f, -1204, 0.001f, { 0.0f,0.0f,0.0f }, 207, 0.002f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f } +#define FSOUND_PRESET_ROOM {2, 1.9f, 1.00f, -1000, -454, 0, 0.40f, 0.83f, 1.0f, -1646, 0.002f, { 0.0f,0.0f,0.0f }, 53, 0.003f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f } +#define FSOUND_PRESET_BATHROOM {3, 1.4f, 1.00f, -1000, -1200, 0, 1.49f, 0.54f, 1.0f, -370, 0.007f, { 0.0f,0.0f,0.0f }, 1030, 0.011f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 60.0f, 0x3f } +#define FSOUND_PRESET_LIVINGROOM {4, 2.5f, 1.00f, -1000, -6000, 0, 0.50f, 0.10f, 1.0f, -1376, 0.003f, { 0.0f,0.0f,0.0f }, -1104, 0.004f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f } +#define FSOUND_PRESET_STONEROOM {5, 11.6f, 1.00f, -1000, -300, 0, 2.31f, 0.64f, 1.0f, -711, 0.012f, { 0.0f,0.0f,0.0f }, 83, 0.017f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f } +#define FSOUND_PRESET_AUDITORIUM {6, 21.6f, 1.00f, -1000, -476, 0, 4.32f, 0.59f, 1.0f, -789, 0.020f, { 0.0f,0.0f,0.0f }, -289, 0.030f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f } +#define FSOUND_PRESET_CONCERTHALL {7, 19.6f, 1.00f, -1000, -500, 0, 3.92f, 0.70f, 1.0f, -1230, 0.020f, { 0.0f,0.0f,0.0f }, -2, 0.029f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f } +#define FSOUND_PRESET_CAVE {8, 14.6f, 1.00f, -1000, 0, 0, 2.91f, 1.30f, 1.0f, -602, 0.015f, { 0.0f,0.0f,0.0f }, -302, 0.022f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x1f } +#define FSOUND_PRESET_ARENA {9, 36.2f, 1.00f, -1000, -698, 0, 7.24f, 0.33f, 1.0f, -1166, 0.020f, { 0.0f,0.0f,0.0f }, 16, 0.030f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f } +#define FSOUND_PRESET_HANGAR {10, 50.3f, 1.00f, -1000, -1000, 0, 10.05f, 0.23f, 1.0f, -602, 0.020f, { 0.0f,0.0f,0.0f }, 198, 0.030f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f } +#define FSOUND_PRESET_CARPETTEDHALLWAY {11, 1.9f, 1.00f, -1000, -4000, 0, 0.30f, 0.10f, 1.0f, -1831, 0.002f, { 0.0f,0.0f,0.0f }, -1630, 0.030f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f } +#define FSOUND_PRESET_HALLWAY {12, 1.8f, 1.00f, -1000, -300, 0, 1.49f, 0.59f, 1.0f, -1219, 0.007f, { 0.0f,0.0f,0.0f }, 441, 0.011f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f } +#define FSOUND_PRESET_STONECORRIDOR {13, 13.5f, 1.00f, -1000, -237, 0, 2.70f, 0.79f, 1.0f, -1214, 0.013f, { 0.0f,0.0f,0.0f }, 395, 0.020f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f } +#define FSOUND_PRESET_ALLEY {14, 7.5f, 0.30f, -1000, -270, 0, 1.49f, 0.86f, 1.0f, -1204, 0.007f, { 0.0f,0.0f,0.0f }, -4, 0.011f, { 0.0f,0.0f,0.0f }, 0.125f, 0.95f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f } +#define FSOUND_PRESET_FOREST {15, 38.0f, 0.30f, -1000, -3300, 0, 1.49f, 0.54f, 1.0f, -2560, 0.162f, { 0.0f,0.0f,0.0f }, -229, 0.088f, { 0.0f,0.0f,0.0f }, 0.125f, 1.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 79.0f, 100.0f, 0x3f } +#define FSOUND_PRESET_CITY {16, 7.5f, 0.50f, -1000, -800, 0, 1.49f, 0.67f, 1.0f, -2273, 0.007f, { 0.0f,0.0f,0.0f }, -1691, 0.011f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 50.0f, 100.0f, 0x3f } +#define FSOUND_PRESET_MOUNTAINS {17, 100.0f, 0.27f, -1000, -2500, 0, 1.49f, 0.21f, 1.0f, -2780, 0.300f, { 0.0f,0.0f,0.0f }, -1434, 0.100f, { 0.0f,0.0f,0.0f }, 0.250f, 1.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 27.0f, 100.0f, 0x1f } +#define FSOUND_PRESET_QUARRY {18, 17.5f, 1.00f, -1000, -1000, 0, 1.49f, 0.83f, 1.0f, -10000, 0.061f, { 0.0f,0.0f,0.0f }, 500, 0.025f, { 0.0f,0.0f,0.0f }, 0.125f, 0.70f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f } +#define FSOUND_PRESET_PLAIN {19, 42.5f, 0.21f, -1000, -2000, 0, 1.49f, 0.50f, 1.0f, -2466, 0.179f, { 0.0f,0.0f,0.0f }, -1926, 0.100f, { 0.0f,0.0f,0.0f }, 0.250f, 1.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 21.0f, 100.0f, 0x3f } +#define FSOUND_PRESET_PARKINGLOT {20, 8.3f, 1.00f, -1000, 0, 0, 1.65f, 1.50f, 1.0f, -1363, 0.008f, { 0.0f,0.0f,0.0f }, -1153, 0.012f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x1f } +#define FSOUND_PRESET_SEWERPIPE {21, 1.7f, 0.80f, -1000, -1000, 0, 2.81f, 0.14f, 1.0f, 429, 0.014f, { 0.0f,0.0f,0.0f }, 1023, 0.021f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 80.0f, 60.0f, 0x3f } +#define FSOUND_PRESET_UNDERWATER {22, 1.8f, 1.00f, -1000, -4000, 0, 1.49f, 0.10f, 1.0f, -449, 0.007f, { 0.0f,0.0f,0.0f }, 1700, 0.011f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 1.18f, 0.348f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f } + +/* Non I3DL2 presets */ + +#define FSOUND_PRESET_DRUGGED {23, 1.9f, 0.50f, -1000, 0, 0, 8.39f, 1.39f, 1.0f, -115, 0.002f, { 0.0f,0.0f,0.0f }, 985, 0.030f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 1.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x1f } +#define FSOUND_PRESET_DIZZY {24, 1.8f, 0.60f, -1000, -400, 0, 17.23f, 0.56f, 1.0f, -1713, 0.020f, { 0.0f,0.0f,0.0f }, -613, 0.030f, { 0.0f,0.0f,0.0f }, 0.250f, 1.00f, 0.81f, 0.310f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x1f } +#define FSOUND_PRESET_PSYCHOTIC {25, 1.0f, 0.50f, -1000, -151, 0, 7.56f, 0.91f, 1.0f, -626, 0.020f, { 0.0f,0.0f,0.0f }, 774, 0.030f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 4.00f, 1.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x1f } + +/* PlayStation 2 and PlayStation Portable only presets */ + +#define FSOUND_PRESET_PS2_ROOM {1, 0, 0, 0, 0, 0, 0.0f, 0.0f, 0.0f, 0, 0.000f, { 0.0f,0.0f,0.0f }, 0, 0.000f, { 0.0f,0.0f,0.0f }, 0.000f, 0.00f, 0.00f, 0.000f, 0.0f, 0000.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0x31f } +#define FSOUND_PRESET_PS2_STUDIO_A {2, 0, 0, 0, 0, 0, 0.0f, 0.0f, 0.0f, 0, 0.000f, { 0.0f,0.0f,0.0f }, 0, 0.000f, { 0.0f,0.0f,0.0f }, 0.000f, 0.00f, 0.00f, 0.000f, 0.0f, 0000.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0x31f } +#define FSOUND_PRESET_PS2_STUDIO_B {3, 0, 0, 0, 0, 0, 0.0f, 0.0f, 0.0f, 0, 0.000f, { 0.0f,0.0f,0.0f }, 0, 0.000f, { 0.0f,0.0f,0.0f }, 0.000f, 0.00f, 0.00f, 0.000f, 0.0f, 0000.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0x31f } +#define FSOUND_PRESET_PS2_STUDIO_C {4, 0, 0, 0, 0, 0, 0.0f, 0.0f, 0.0f, 0, 0.000f, { 0.0f,0.0f,0.0f }, 0, 0.000f, { 0.0f,0.0f,0.0f }, 0.000f, 0.00f, 0.00f, 0.000f, 0.0f, 0000.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0x31f } +#define FSOUND_PRESET_PS2_HALL {5, 0, 0, 0, 0, 0, 0.0f, 0.0f, 0.0f, 0, 0.000f, { 0.0f,0.0f,0.0f }, 0, 0.000f, { 0.0f,0.0f,0.0f }, 0.000f, 0.00f, 0.00f, 0.000f, 0.0f, 0000.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0x31f } +#define FSOUND_PRESET_PS2_SPACE {6, 0, 0, 0, 0, 0, 0.0f, 0.0f, 0.0f, 0, 0.000f, { 0.0f,0.0f,0.0f }, 0, 0.000f, { 0.0f,0.0f,0.0f }, 0.000f, 0.00f, 0.00f, 0.000f, 0.0f, 0000.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0x31f } +#define FSOUND_PRESET_PS2_ECHO {7, 0, 0, 0, 0, 0, 0.0f, 0.0f, 0.0f, 0, 0.000f, { 0.0f,0.0f,0.0f }, 0, 0.000f, { 0.0f,0.0f,0.0f }, 0.000f, 0.00f, 0.00f, 0.000f, 0.0f, 0000.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0x31f } +#define FSOUND_PRESET_PS2_DELAY {8, 0, 0, 0, 0, 0, 0.0f, 0.0f, 0.0f, 0, 0.000f, { 0.0f,0.0f,0.0f }, 0, 0.000f, { 0.0f,0.0f,0.0f }, 0.000f, 0.00f, 0.00f, 0.000f, 0.0f, 0000.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0x31f } +#define FSOUND_PRESET_PS2_PIPE {9, 0, 0, 0, 0, 0, 0.0f, 0.0f, 0.0f, 0, 0.000f, { 0.0f,0.0f,0.0f }, 0, 0.000f, { 0.0f,0.0f,0.0f }, 0.000f, 0.00f, 0.00f, 0.000f, 0.0f, 0000.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0x31f } + +/* [DEFINE_END] */ + + +/* +[STRUCTURE] +[ + [DESCRIPTION] + Structure defining the properties for a reverb source, related to a FSOUND channel. + For more indepth descriptions of the reverb properties under win32, please see the EAX3 + documentation at http://developer.creative.com/ under the 'downloads' section. + If they do not have the EAX3 documentation, then most information can be attained from + the EAX2 documentation, as EAX3 only adds some more parameters and functionality on top of + EAX2. + + Note the default reverb properties are the same as the FSOUND_PRESET_GENERIC preset. + Note that integer values that typically range from -10,000 to 1000 are represented in + decibels, and are of a logarithmic scale, not linear, wheras float values are typically linear. + PORTABILITY: Each member has the platform it supports in braces ie (win32/xbox). + Some reverb parameters are only supported in win32 and some only on xbox. If all parameters are set then + the reverb should product a similar effect on either platform. + Linux and FMODCE do not support the reverb api. + + The numerical values listed below are the maximum, minimum and default values for each variable respectively. + + [SEE_ALSO] + FSOUND_Reverb_SetChannelProperties + FSOUND_Reverb_GetChannelProperties + FSOUND_REVERB_CHANNELFLAGS +] +*/ +typedef struct _FSOUND_REVERB_CHANNELPROPERTIES /* MIN MAX DEFAULT */ +{ + int Direct; /* -10000, 1000, 0, direct path level (at low and mid frequencies) (WIN32/XBOX) */ + int DirectHF; /* -10000, 0, 0, relative direct path level at high frequencies (WIN32/XBOX) */ + int Room; /* -10000, 1000, 0, room effect level (at low and mid frequencies) (WIN32/XBOX/PS2) */ + int RoomHF; /* -10000, 0, 0, relative room effect level at high frequencies (WIN32/XBOX) */ + int Obstruction; /* -10000, 0, 0, main obstruction control (attenuation at high frequencies) (WIN32/XBOX) */ + float ObstructionLFRatio; /* 0.0, 1.0, 0.0, obstruction low-frequency level re. main control (WIN32/XBOX) */ + int Occlusion; /* -10000, 0, 0, main occlusion control (attenuation at high frequencies) (WIN32/XBOX) */ + float OcclusionLFRatio; /* 0.0, 1.0, 0.25, occlusion low-frequency level re. main control (WIN32/XBOX) */ + float OcclusionRoomRatio; /* 0.0, 10.0, 1.5, relative occlusion control for room effect (WIN32) */ + float OcclusionDirectRatio; /* 0.0, 10.0, 1.0, relative occlusion control for direct path (WIN32) */ + int Exclusion; /* -10000, 0, 0, main exlusion control (attenuation at high frequencies) (WIN32) */ + float ExclusionLFRatio; /* 0.0, 1.0, 1.0, exclusion low-frequency level re. main control (WIN32) */ + int OutsideVolumeHF; /* -10000, 0, 0, outside sound cone level at high frequencies (WIN32) */ + float DopplerFactor; /* 0.0, 10.0, 0.0, like DS3D flDopplerFactor but per source (WIN32) */ + float RolloffFactor; /* 0.0, 10.0, 0.0, like DS3D flRolloffFactor but per source (WIN32) */ + float RoomRolloffFactor; /* 0.0, 10.0, 0.0, like DS3D flRolloffFactor but for room effect (WIN32/XBOX) */ + float AirAbsorptionFactor; /* 0.0, 10.0, 1.0, multiplies AirAbsorptionHF member of FSOUND_REVERB_PROPERTIES (WIN32) */ + int Flags; /* FSOUND_REVERB_CHANNELFLAGS - modifies the behavior of properties (WIN32) */ +} FSOUND_REVERB_CHANNELPROPERTIES; + + +/* +[DEFINE_START] +[ + [NAME] + FSOUND_REVERB_CHANNELFLAGS + + [DESCRIPTION] + Values for the Flags member of the FSOUND_REVERB_CHANNELPROPERTIES structure. + + [SEE_ALSO] + FSOUND_REVERB_CHANNELPROPERTIES +] +*/ +#define FSOUND_REVERB_CHANNELFLAGS_DIRECTHFAUTO 0x00000001 /* Automatic setting of 'Direct' due to distance from listener */ +#define FSOUND_REVERB_CHANNELFLAGS_ROOMAUTO 0x00000002 /* Automatic setting of 'Room' due to distance from listener */ +#define FSOUND_REVERB_CHANNELFLAGS_ROOMHFAUTO 0x00000004 /* Automatic setting of 'RoomHF' due to distance from listener */ +#define FSOUND_REVERB_CHANNELFLAGS_DEFAULT (FSOUND_REVERB_CHANNELFLAGS_DIRECTHFAUTO | \ + FSOUND_REVERB_CHANNELFLAGS_ROOMAUTO| \ + FSOUND_REVERB_CHANNELFLAGS_ROOMHFAUTO) +/* [DEFINE_END] */ + + +/* +[ENUM] +[ + [DESCRIPTION] + These values are used with FSOUND_FX_Enable to enable DirectX 8 FX for a channel. + + [SEE_ALSO] + FSOUND_FX_Enable + FSOUND_FX_Disable + FSOUND_FX_SetChorus + FSOUND_FX_SetCompressor + FSOUND_FX_SetDistortion + FSOUND_FX_SetEcho + FSOUND_FX_SetFlanger + FSOUND_FX_SetGargle + FSOUND_FX_SetI3DL2Reverb + FSOUND_FX_SetParamEQ + FSOUND_FX_SetWavesReverb +] +*/ +enum FSOUND_FX_MODES +{ + FSOUND_FX_CHORUS, + FSOUND_FX_COMPRESSOR, + FSOUND_FX_DISTORTION, + FSOUND_FX_ECHO, + FSOUND_FX_FLANGER, + FSOUND_FX_GARGLE, + FSOUND_FX_I3DL2REVERB, + FSOUND_FX_PARAMEQ, + FSOUND_FX_WAVES_REVERB, + + FSOUND_FX_MAX +}; + +/* +[ENUM] +[ + [DESCRIPTION] + These are speaker types defined for use with the FSOUND_SetSpeakerMode command. + Note - Only reliably works with FSOUND_OUTPUT_DSOUND or FSOUND_OUTPUT_XBOX output modes. Other output modes will only + interpret FSOUND_SPEAKERMODE_MONO and set everything else to be stereo. + + Using either DolbyDigital or DTS will use whatever 5.1 digital mode is available if destination hardware is unsure. + + [SEE_ALSO] + FSOUND_SetSpeakerMode + +] +*/ +enum FSOUND_SPEAKERMODES +{ + FSOUND_SPEAKERMODE_DOLBYDIGITAL, /* Dolby Digital Output (XBOX or PC only). */ + FSOUND_SPEAKERMODE_HEADPHONES, /* The speakers are headphones. */ + FSOUND_SPEAKERMODE_MONO, /* The speakers are monaural. */ + FSOUND_SPEAKERMODE_QUAD, /* The speakers are quadraphonic. */ + FSOUND_SPEAKERMODE_STEREO, /* The speakers are stereo (default value). */ + FSOUND_SPEAKERMODE_SURROUND, /* The speakers are surround sound. */ + FSOUND_SPEAKERMODE_DTS, /* DTS output (XBOX only). */ + FSOUND_SPEAKERMODE_PROLOGIC2, /* Dolby Prologic 2. Playstation 2 and Gamecube only. PlayStation 2 doesnt support interior panning, but supports 48 voices simultaneously. */ + FSOUND_SPEAKERMODE_PROLOGIC2_INTERIOR /* Dolby Prologic 2. Playstation 2 and Gamecube only. PlayStation 2 does support interior panning, but only supports 24 voices simultaneously. */ +}; + + +/* +[DEFINE_START] +[ + [NAME] + FSOUND_INIT_FLAGS + + [DESCRIPTION] + Initialization flags. Use them with FSOUND_Init in the flags parameter to change various behaviour. + + FSOUND_INIT_ENABLESYSTEMCHANNELFX Is an init mode which enables the FSOUND mixer buffer to be affected by DirectX 8 effects. + Note that due to limitations of DirectSound, FSOUND_Init may fail if this is enabled because the buffersize is too small. + This can be fixed with FSOUND_SetBufferSize. Increase the BufferSize until it works. + When it is enabled you can use the FSOUND_FX api, and use FSOUND_SYSTEMCHANNEL as the channel id when setting parameters. + + [SEE_ALSO] + FSOUND_Init +] +*/ +#define FSOUND_INIT_USEDEFAULTMIDISYNTH 0x0001 /* Win32 only - Causes MIDI playback to force software decoding. */ +#define FSOUND_INIT_GLOBALFOCUS 0x0002 /* Win32 only - For DirectSound output - sound is not muted when window is out of focus. */ +#define FSOUND_INIT_ENABLESYSTEMCHANNELFX 0x0004 /* Win32 only - For DirectSound output - Allows FSOUND_FX api to be used on global software mixer output! (use FSOUND_SYSTEMCHANNEL as channel id) */ +#define FSOUND_INIT_ACCURATEVULEVELS 0x0008 /* This latency adjusts FSOUND_GetCurrentLevels, but incurs a small cpu and memory hit */ +#define FSOUND_INIT_PS2_DISABLECORE0REVERB 0x0010 /* PS2 only - Disable reverb on CORE 0 (SPU2 voices 00-23) to regain SRAM */ +#define FSOUND_INIT_PS2_DISABLECORE1REVERB 0x0020 /* PS2 only - Disable reverb on CORE 1 (SPU2 voices 24-47) to regain SRAM */ +#define FSOUND_INIT_PS2_SWAPDMACORES 0x0040 /* PS2 only - By default FMOD uses DMA CH0 for mixing, CH1 for uploads, this flag swaps them around */ +#define FSOUND_INIT_DONTLATENCYADJUST 0x0080 /* Callbacks are not latency adjusted, and are called at mix time. Also information functions are immediate */ +#define FSOUND_INIT_GC_INITLIBS 0x0100 /* GC only - Initializes GC audio libraries */ +#define FSOUND_INIT_STREAM_FROM_MAIN_THREAD 0x0200 /* Turns off fmod streamer thread, and makes streaming update from FSOUND_Update called by the user */ +#define FSOUND_INIT_PS2_USEVOLUMERAMPING 0x0400 /* PS2 only - Turns on volume ramping system to remove hardware clicks. */ +#define FSOUND_INIT_DSOUND_DEFERRED 0x0800 /* Win32 only - For DirectSound output. 3D commands are batched together and executed at FSOUND_Update. */ +#define FSOUND_INIT_DSOUND_HRTF_LIGHT 0x1000 /* Win32 only - For DirectSound output. FSOUND_HW3D buffers use a slightly higher quality algorithm when 3d hardware acceleration is not present. */ +#define FSOUND_INIT_DSOUND_HRTF_FULL 0x2000 /* Win32 only - For DirectSound output. FSOUND_HW3D buffers use full quality 3d playback when 3d hardware acceleration is not present. */ +#define FSOUND_INIT_XBOX_REMOVEHEADROOM 0x4000 /* XBox only - By default directsound attenuates all sound by 6db to avoid clipping/distortion. CAUTION. If you use this flag you are responsible for the final mix to make sure clipping / distortion doesn't happen. */ +#define FSOUND_INIT_PSP_SILENCEONUNDERRUN 0x8000 /* PSP only - If streams skip / stutter when device is powered on, either increase stream buffersize, or use this flag instead to play silence while the UMD is recovering. */ +/* [DEFINE_END] */ + + +/* +[ENUM] +[ + [DESCRIPTION] + Status values for internet streams. Use FSOUND_Stream_Net_GetStatus to get the current status of an internet stream. + + [SEE_ALSO] + FSOUND_Stream_Net_GetStatus +] +*/ +enum FSOUND_STREAM_NET_STATUS +{ + FSOUND_STREAM_NET_NOTCONNECTED = 0, /* Stream hasn't connected yet */ + FSOUND_STREAM_NET_CONNECTING, /* Stream is connecting to remote host */ + FSOUND_STREAM_NET_BUFFERING, /* Stream is buffering data */ + FSOUND_STREAM_NET_READY, /* Stream is ready to play */ + FSOUND_STREAM_NET_ERROR /* Stream has suffered a fatal error */ +}; + + +/* +[ENUM] +[ + [DESCRIPTION] + Describes the type of a particular tag field. + + [SEE_ALSO] + FSOUND_Stream_GetNumTagFields + FSOUND_Stream_GetTagField + FSOUND_Stream_FindTagField +] +*/ +enum FSOUND_TAGFIELD_TYPE +{ + FSOUND_TAGFIELD_VORBISCOMMENT = 0, /* A vorbis comment */ + FSOUND_TAGFIELD_ID3V1, /* Part of an ID3v1 tag */ + FSOUND_TAGFIELD_ID3V2, /* An ID3v2 frame */ + FSOUND_TAGFIELD_SHOUTCAST, /* A SHOUTcast header line */ + FSOUND_TAGFIELD_ICECAST, /* An Icecast header line */ + FSOUND_TAGFIELD_ASF /* An Advanced Streaming Format header line */ +}; + + +/* +[DEFINE_START] +[ + [NAME] + FSOUND_STATUS_FLAGS + + [DESCRIPTION] + These values describe the protocol and format of an internet stream. Use FSOUND_Stream_Net_GetStatus to retrieve this information for an open internet stream. + + [SEE_ALSO] + FSOUND_Stream_Net_GetStatus +] +*/ +#define FSOUND_PROTOCOL_SHOUTCAST 0x00000001 +#define FSOUND_PROTOCOL_ICECAST 0x00000002 +#define FSOUND_PROTOCOL_HTTP 0x00000004 +#define FSOUND_FORMAT_MPEG 0x00010000 +#define FSOUND_FORMAT_OGGVORBIS 0x00020000 +/* [DEFINE_END] */ + + +/* +[STRUCTURE] +[ + [DESCRIPTION] + Structure defining a CD table of contents. This structure is returned as a tag from FSOUND_Stream_FindTagField when the tag name "CD_TOC" is specified. + Note: All tracks on the CD - including data tracks- will be represented in this structure so it's use for anything other than generating disc id information is not recommended. + See the cdda example program for info on retrieving and using this structure. + + [SEE_ALSO] + FSOUND_Stream_Open + FSOUND_Stream_FindTagField +] +*/ +typedef struct _FSOUND_TOC_TAG +{ + char name[4]; /* The string "TOC", just in case this structure is accidentally treated as a string */ + int numtracks; /* The number of tracks on the CD */ + int min[100]; /* The start offset of each track in minutes */ + int sec[100]; /* The start offset of each track in seconds */ + int frame[100]; /* The start offset of each track in frames */ + +} FSOUND_TOC_TAG; + + +/* ========================================================================================== */ +/* FUNCTION PROTOTYPES */ +/* ========================================================================================== */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* ================================== */ +/* Initialization / Global functions. */ +/* ================================== */ + +/* + PRE - FSOUND_Init functions. These can't be called after FSOUND_Init is + called (they will fail). They set up FMOD system functionality. +*/ + +DLL_API signed char F_API FSOUND_SetOutput(int outputtype); +DLL_API signed char F_API FSOUND_SetDriver(int driver); +DLL_API signed char F_API FSOUND_SetMixer(int mixer); +DLL_API signed char F_API FSOUND_SetBufferSize(int len_ms); +DLL_API signed char F_API FSOUND_SetHWND(void *hwnd); +DLL_API signed char F_API FSOUND_SetMinHardwareChannels(int min); +DLL_API signed char F_API FSOUND_SetMaxHardwareChannels(int max); +DLL_API signed char F_API FSOUND_SetMemorySystem(void *pool, + int poollen, + FSOUND_ALLOCCALLBACK useralloc, + FSOUND_REALLOCCALLBACK userrealloc, + FSOUND_FREECALLBACK userfree); +/* + Main initialization / closedown functions. + Note : Use FSOUND_INIT_USEDEFAULTMIDISYNTH with FSOUND_Init for software override + with MIDI playback. + : Use FSOUND_INIT_GLOBALFOCUS with FSOUND_Init to make sound audible no matter + which window is in focus. (FSOUND_OUTPUT_DSOUND only) +*/ + +DLL_API signed char F_API FSOUND_Init(int mixrate, int maxsoftwarechannels, unsigned int flags); +DLL_API void F_API FSOUND_Close(); + +/* + Runtime system level functions +*/ + +DLL_API void F_API FSOUND_Update(); /* This is called to update 3d sound / non-realtime output */ + +DLL_API void F_API FSOUND_SetSpeakerMode(unsigned int speakermode); +DLL_API void F_API FSOUND_SetSFXMasterVolume(int volume); +DLL_API void F_API FSOUND_SetPanSeperation(float pansep); +DLL_API void F_API FSOUND_File_SetCallbacks(FSOUND_OPENCALLBACK useropen, + FSOUND_CLOSECALLBACK userclose, + FSOUND_READCALLBACK userread, + FSOUND_SEEKCALLBACK userseek, + FSOUND_TELLCALLBACK usertell); + +/* + System information functions. +*/ + +DLL_API int F_API FSOUND_GetError(); +DLL_API float F_API FSOUND_GetVersion(); +DLL_API int F_API FSOUND_GetOutput(); +DLL_API void * F_API FSOUND_GetOutputHandle(); +DLL_API int F_API FSOUND_GetDriver(); +DLL_API int F_API FSOUND_GetMixer(); +DLL_API int F_API FSOUND_GetNumDrivers(); +DLL_API const char * F_API FSOUND_GetDriverName(int id); +DLL_API signed char F_API FSOUND_GetDriverCaps(int id, unsigned int *caps); +DLL_API int F_API FSOUND_GetOutputRate(); +DLL_API int F_API FSOUND_GetMaxChannels(); +DLL_API int F_API FSOUND_GetMaxSamples(); +DLL_API unsigned int F_API FSOUND_GetSpeakerMode(); +DLL_API int F_API FSOUND_GetSFXMasterVolume(); +DLL_API signed char F_API FSOUND_GetNumHWChannels(int *num2d, int *num3d, int *total); +DLL_API int F_API FSOUND_GetChannelsPlaying(); +DLL_API float F_API FSOUND_GetCPUUsage(); +DLL_API void F_API FSOUND_GetMemoryStats(unsigned int *currentalloced, unsigned int *maxalloced); + +/* =================================== */ +/* Sample management / load functions. */ +/* =================================== */ + +/* + Sample creation and management functions + Note : Use FSOUND_LOADMEMORY flag with FSOUND_Sample_Load to load from memory. + Use FSOUND_LOADRAW flag with FSOUND_Sample_Load to treat as as raw pcm data. +*/ + +DLL_API FSOUND_SAMPLE * F_API FSOUND_Sample_Load(int index, const char *name_or_data, unsigned int mode, int offset, int length); +DLL_API FSOUND_SAMPLE * F_API FSOUND_Sample_Alloc(int index, int length, unsigned int mode, int deffreq, int defvol, int defpan, int defpri); +DLL_API void F_API FSOUND_Sample_Free(FSOUND_SAMPLE *sptr); +DLL_API signed char F_API FSOUND_Sample_Upload(FSOUND_SAMPLE *sptr, void *srcdata, unsigned int mode); +DLL_API signed char F_API FSOUND_Sample_Lock(FSOUND_SAMPLE *sptr, int offset, int length, void **ptr1, void **ptr2, unsigned int *len1, unsigned int *len2); +DLL_API signed char F_API FSOUND_Sample_Unlock(FSOUND_SAMPLE *sptr, void *ptr1, void *ptr2, unsigned int len1, unsigned int len2); + +/* + Sample control functions +*/ + +DLL_API signed char F_API FSOUND_Sample_SetMode(FSOUND_SAMPLE *sptr, unsigned int mode); +DLL_API signed char F_API FSOUND_Sample_SetLoopPoints(FSOUND_SAMPLE *sptr, int loopstart, int loopend); +DLL_API signed char F_API FSOUND_Sample_SetDefaults(FSOUND_SAMPLE *sptr, int deffreq, int defvol, int defpan, int defpri); +DLL_API signed char F_API FSOUND_Sample_SetDefaultsEx(FSOUND_SAMPLE *sptr, int deffreq, int defvol, int defpan, int defpri, int varfreq, int varvol, int varpan); +DLL_API signed char F_API FSOUND_Sample_SetMinMaxDistance(FSOUND_SAMPLE *sptr, float min, float max); +DLL_API signed char F_API FSOUND_Sample_SetMaxPlaybacks(FSOUND_SAMPLE *sptr, int max); + +/* + Sample information functions +*/ + +DLL_API FSOUND_SAMPLE * F_API FSOUND_Sample_Get(int sampno); +DLL_API const char * F_API FSOUND_Sample_GetName(FSOUND_SAMPLE *sptr); +DLL_API unsigned int F_API FSOUND_Sample_GetLength(FSOUND_SAMPLE *sptr); +DLL_API signed char F_API FSOUND_Sample_GetLoopPoints(FSOUND_SAMPLE *sptr, int *loopstart, int *loopend); +DLL_API signed char F_API FSOUND_Sample_GetDefaults(FSOUND_SAMPLE *sptr, int *deffreq, int *defvol, int *defpan, int *defpri); +DLL_API signed char F_API FSOUND_Sample_GetDefaultsEx(FSOUND_SAMPLE *sptr, int *deffreq, int *defvol, int *defpan, int *defpri, int *varfreq, int *varvol, int *varpan); +DLL_API unsigned int F_API FSOUND_Sample_GetMode(FSOUND_SAMPLE *sptr); +DLL_API signed char F_API FSOUND_Sample_GetMinMaxDistance(FSOUND_SAMPLE *sptr, float *min, float *max); + +/* ============================ */ +/* Channel control functions. */ +/* ============================ */ + +/* + Playing and stopping sounds. + Note : Use FSOUND_FREE as the 'channel' variable, to let FMOD pick a free channel for you. + Use FSOUND_ALL as the 'channel' variable to control ALL channels with one function call! +*/ + +DLL_API int F_API FSOUND_PlaySound(int channel, FSOUND_SAMPLE *sptr); +DLL_API int F_API FSOUND_PlaySoundEx(int channel, FSOUND_SAMPLE *sptr, FSOUND_DSPUNIT *dsp, signed char startpaused); +DLL_API signed char F_API FSOUND_StopSound(int channel); + +/* + Functions to control playback of a channel. + Note : FSOUND_ALL can be used on most of these functions as a channel value. +*/ + +DLL_API signed char F_API FSOUND_SetFrequency(int channel, int freq); +DLL_API signed char F_API FSOUND_SetVolume(int channel, int vol); +DLL_API signed char F_API FSOUND_SetVolumeAbsolute(int channel, int vol); +DLL_API signed char F_API FSOUND_SetPan(int channel, int pan); +DLL_API signed char F_API FSOUND_SetSurround(int channel, signed char surround); +DLL_API signed char F_API FSOUND_SetMute(int channel, signed char mute); +DLL_API signed char F_API FSOUND_SetPriority(int channel, int priority); +DLL_API signed char F_API FSOUND_SetReserved(int channel, signed char reserved); +DLL_API signed char F_API FSOUND_SetPaused(int channel, signed char paused); +DLL_API signed char F_API FSOUND_SetLoopMode(int channel, unsigned int loopmode); +DLL_API signed char F_API FSOUND_SetCurrentPosition(int channel, unsigned int offset); +DLL_API signed char F_API FSOUND_3D_SetAttributes(int channel, const float *pos, const float *vel); +DLL_API signed char F_API FSOUND_3D_SetMinMaxDistance(int channel, float min, float max); + +/* + Channel information functions. +*/ + +DLL_API signed char F_API FSOUND_IsPlaying(int channel); +DLL_API int F_API FSOUND_GetFrequency(int channel); +DLL_API int F_API FSOUND_GetVolume(int channel); +DLL_API int F_API FSOUND_GetAmplitude(int channel); +DLL_API int F_API FSOUND_GetPan(int channel); +DLL_API signed char F_API FSOUND_GetSurround(int channel); +DLL_API signed char F_API FSOUND_GetMute(int channel); +DLL_API int F_API FSOUND_GetPriority(int channel); +DLL_API signed char F_API FSOUND_GetReserved(int channel); +DLL_API signed char F_API FSOUND_GetPaused(int channel); +DLL_API unsigned int F_API FSOUND_GetLoopMode(int channel); +DLL_API unsigned int F_API FSOUND_GetCurrentPosition(int channel); +DLL_API FSOUND_SAMPLE * F_API FSOUND_GetCurrentSample(int channel); +DLL_API signed char F_API FSOUND_GetCurrentLevels(int channel, float *l, float *r); +DLL_API int F_API FSOUND_GetNumSubChannels(int channel); +DLL_API int F_API FSOUND_GetSubChannel(int channel, int subchannel); +DLL_API signed char F_API FSOUND_3D_GetAttributes(int channel, float *pos, float *vel); +DLL_API signed char F_API FSOUND_3D_GetMinMaxDistance(int channel, float *min, float *max); + +/* ========================== */ +/* Global 3D sound functions. */ +/* ========================== */ + +/* + See also 3d sample and channel based functions above. + Call FSOUND_Update once a frame to process 3d information. +*/ + +DLL_API void F_API FSOUND_3D_Listener_SetAttributes(const float *pos, const float *vel, float fx, float fy, float fz, float tx, float ty, float tz); +DLL_API void F_API FSOUND_3D_Listener_GetAttributes(float *pos, float *vel, float *fx, float *fy, float *fz, float *tx, float *ty, float *tz); +DLL_API void F_API FSOUND_3D_Listener_SetCurrent(int current, int numlisteners); /* use this if you use multiple listeners / splitscreen */ +DLL_API void F_API FSOUND_3D_SetDopplerFactor(float scale); +DLL_API void F_API FSOUND_3D_SetDistanceFactor(float scale); +DLL_API void F_API FSOUND_3D_SetRolloffFactor(float scale); + +/* =================== */ +/* FX functions. */ +/* =================== */ + +/* + Functions to control DX8 only effects processing. + + - FX enabled samples can only be played once at a time, not multiple times at once. + - Sounds have to be created with FSOUND_HW2D or FSOUND_HW3D for this to work. + - FSOUND_INIT_ENABLESYSTEMCHANNELFX can be used to apply hardware effect processing to the + global mixed output of FMOD's software channels. + - FSOUND_FX_Enable returns an FX handle that you can use to alter fx parameters. + - FSOUND_FX_Enable can be called multiple times in a row, even on the same FX type, + it will return a unique handle for each FX. + - FSOUND_FX_Enable cannot be called if the sound is playing or locked. + - FSOUND_FX_Disable must be called to reset/clear the FX from a channel. +*/ + +DLL_API int F_API FSOUND_FX_Enable(int channel, unsigned int fxtype); /* See FSOUND_FX_MODES */ +DLL_API signed char F_API FSOUND_FX_Disable(int channel); /* Disables all effects */ + +DLL_API signed char F_API FSOUND_FX_SetChorus(int fxid, float WetDryMix, float Depth, float Feedback, float Frequency, int Waveform, float Delay, int Phase); +DLL_API signed char F_API FSOUND_FX_SetCompressor(int fxid, float Gain, float Attack, float Release, float Threshold, float Ratio, float Predelay); +DLL_API signed char F_API FSOUND_FX_SetDistortion(int fxid, float Gain, float Edge, float PostEQCenterFrequency, float PostEQBandwidth, float PreLowpassCutoff); +DLL_API signed char F_API FSOUND_FX_SetEcho(int fxid, float WetDryMix, float Feedback, float LeftDelay, float RightDelay, int PanDelay); +DLL_API signed char F_API FSOUND_FX_SetFlanger(int fxid, float WetDryMix, float Depth, float Feedback, float Frequency, int Waveform, float Delay, int Phase); +DLL_API signed char F_API FSOUND_FX_SetGargle(int fxid, int RateHz, int WaveShape); +DLL_API signed char F_API FSOUND_FX_SetI3DL2Reverb(int fxid, int Room, int RoomHF, float RoomRolloffFactor, float DecayTime, float DecayHFRatio, int Reflections, float ReflectionsDelay, int Reverb, float ReverbDelay, float Diffusion, float Density, float HFReference); +DLL_API signed char F_API FSOUND_FX_SetParamEQ(int fxid, float Center, float Bandwidth, float Gain); +DLL_API signed char F_API FSOUND_FX_SetWavesReverb(int fxid, float InGain, float ReverbMix, float ReverbTime, float HighFreqRTRatio); + +/* ========================= */ +/* File Streaming functions. */ +/* ========================= */ + +/* + Note : Use FSOUND_LOADMEMORY flag with FSOUND_Stream_Open to stream from memory. + Use FSOUND_LOADRAW flag with FSOUND_Stream_Open to treat stream as raw pcm data. + Use FSOUND_MPEGACCURATE flag with FSOUND_Stream_Open to open mpegs in 'accurate mode' for settime/gettime/getlengthms. + Use FSOUND_FREE as the 'channel' variable, to let FMOD pick a free channel for you. +*/ + +DLL_API signed char F_API FSOUND_Stream_SetBufferSize(int ms); /* call this before opening streams, not after */ + +DLL_API FSOUND_STREAM * F_API FSOUND_Stream_Open(const char *name_or_data, unsigned int mode, int offset, int length); +DLL_API FSOUND_STREAM * F_API FSOUND_Stream_Create(FSOUND_STREAMCALLBACK callback, int length, unsigned int mode, int samplerate, void *userdata); +DLL_API signed char F_API FSOUND_Stream_Close(FSOUND_STREAM *stream); + +DLL_API int F_API FSOUND_Stream_Play(int channel, FSOUND_STREAM *stream); +DLL_API int F_API FSOUND_Stream_PlayEx(int channel, FSOUND_STREAM *stream, FSOUND_DSPUNIT *dsp, signed char startpaused); +DLL_API signed char F_API FSOUND_Stream_Stop(FSOUND_STREAM *stream); + +DLL_API signed char F_API FSOUND_Stream_SetPosition(FSOUND_STREAM *stream, unsigned int position); +DLL_API unsigned int F_API FSOUND_Stream_GetPosition(FSOUND_STREAM *stream); +DLL_API signed char F_API FSOUND_Stream_SetTime(FSOUND_STREAM *stream, int ms); +DLL_API int F_API FSOUND_Stream_GetTime(FSOUND_STREAM *stream); +DLL_API int F_API FSOUND_Stream_GetLength(FSOUND_STREAM *stream); +DLL_API int F_API FSOUND_Stream_GetLengthMs(FSOUND_STREAM *stream); + +DLL_API signed char F_API FSOUND_Stream_SetMode(FSOUND_STREAM *stream, unsigned int mode); +DLL_API unsigned int F_API FSOUND_Stream_GetMode(FSOUND_STREAM *stream); +DLL_API signed char F_API FSOUND_Stream_SetLoopPoints(FSOUND_STREAM *stream, unsigned int loopstartpcm, unsigned int loopendpcm); +DLL_API signed char F_API FSOUND_Stream_SetLoopCount(FSOUND_STREAM *stream, int count); +DLL_API int F_API FSOUND_Stream_GetOpenState(FSOUND_STREAM *stream); /* use with FSOUND_NONBLOCKING opened streams */ +DLL_API FSOUND_SAMPLE * F_API FSOUND_Stream_GetSample(FSOUND_STREAM *stream); +DLL_API FSOUND_DSPUNIT * F_API FSOUND_Stream_CreateDSP(FSOUND_STREAM *stream, FSOUND_DSPCALLBACK callback, int priority, void *userdata); + +DLL_API signed char F_API FSOUND_Stream_SetEndCallback(FSOUND_STREAM *stream, FSOUND_STREAMCALLBACK callback, void *userdata); +DLL_API signed char F_API FSOUND_Stream_SetSyncCallback(FSOUND_STREAM *stream, FSOUND_STREAMCALLBACK callback, void *userdata); + +DLL_API FSOUND_SYNCPOINT * F_API FSOUND_Stream_AddSyncPoint(FSOUND_STREAM *stream, unsigned int pcmoffset, const char *name); +DLL_API signed char F_API FSOUND_Stream_DeleteSyncPoint(FSOUND_SYNCPOINT *point); +DLL_API int F_API FSOUND_Stream_GetNumSyncPoints(FSOUND_STREAM *stream); +DLL_API FSOUND_SYNCPOINT * F_API FSOUND_Stream_GetSyncPoint(FSOUND_STREAM *stream, int index); +DLL_API char * F_API FSOUND_Stream_GetSyncPointInfo(FSOUND_SYNCPOINT *point, unsigned int *pcmoffset); + +DLL_API signed char F_API FSOUND_Stream_SetSubStream(FSOUND_STREAM *stream, int index); /* For FMOD .FSB bank files. */ +DLL_API int F_API FSOUND_Stream_GetNumSubStreams(FSOUND_STREAM *stream); /* For FMOD .FSB bank files. */ +DLL_API signed char F_API FSOUND_Stream_SetSubStreamSentence(FSOUND_STREAM *stream, const int *sentencelist, int numitems); + +DLL_API signed char F_API FSOUND_Stream_GetNumTagFields(FSOUND_STREAM *stream, int *num); +DLL_API signed char F_API FSOUND_Stream_GetTagField(FSOUND_STREAM *stream, int num, int *type, char **name, void **value, int *length); +DLL_API signed char F_API FSOUND_Stream_FindTagField(FSOUND_STREAM *stream, int type, const char *name, void **value, int *length); + +/* + Internet streaming functions +*/ + +DLL_API signed char F_API FSOUND_Stream_Net_SetProxy(const char *proxy); +DLL_API signed char F_API FSOUND_Stream_Net_SetTimeout(int timeout); +DLL_API char * F_API FSOUND_Stream_Net_GetLastServerStatus(); +DLL_API signed char F_API FSOUND_Stream_Net_SetBufferProperties(int buffersize, int prebuffer_percent, int rebuffer_percent); +DLL_API signed char F_API FSOUND_Stream_Net_GetBufferProperties(int *buffersize, int *prebuffer_percent, int *rebuffer_percent); +DLL_API signed char F_API FSOUND_Stream_Net_SetMetadataCallback(FSOUND_STREAM *stream, FSOUND_METADATACALLBACK callback, void *userdata); +DLL_API signed char F_API FSOUND_Stream_Net_GetStatus(FSOUND_STREAM *stream, int *status, int *bufferpercentused, int *bitrate, unsigned int *flags); + +/* =================== */ +/* CD audio functions. */ +/* =================== */ + +/* + Note : 0 = default cdrom. Otherwise specify the drive letter, for example. 'D'. +*/ + +DLL_API signed char F_API FSOUND_CD_Play(char drive, int track); +DLL_API void F_API FSOUND_CD_SetPlayMode(char drive, signed char mode); +DLL_API signed char F_API FSOUND_CD_Stop(char drive); +DLL_API signed char F_API FSOUND_CD_SetPaused(char drive, signed char paused); +DLL_API signed char F_API FSOUND_CD_SetVolume(char drive, int volume); +DLL_API signed char F_API FSOUND_CD_SetTrackTime(char drive, unsigned int ms); +DLL_API signed char F_API FSOUND_CD_OpenTray(char drive, signed char open); + +DLL_API signed char F_API FSOUND_CD_GetPaused(char drive); +DLL_API int F_API FSOUND_CD_GetTrack(char drive); +DLL_API int F_API FSOUND_CD_GetNumTracks(char drive); +DLL_API int F_API FSOUND_CD_GetVolume(char drive); +DLL_API int F_API FSOUND_CD_GetTrackLength(char drive, int track); +DLL_API int F_API FSOUND_CD_GetTrackTime(char drive); + +/* ============== */ +/* DSP functions. */ +/* ============== */ + +/* + DSP Unit control and information functions. + These functions allow you access to the mixed stream that FMOD uses to play back sound on. +*/ + +DLL_API FSOUND_DSPUNIT *F_API FSOUND_DSP_Create(FSOUND_DSPCALLBACK callback, int priority, void *userdata); +DLL_API void F_API FSOUND_DSP_Free(FSOUND_DSPUNIT *unit); +DLL_API void F_API FSOUND_DSP_SetPriority(FSOUND_DSPUNIT *unit, int priority); +DLL_API int F_API FSOUND_DSP_GetPriority(FSOUND_DSPUNIT *unit); +DLL_API void F_API FSOUND_DSP_SetActive(FSOUND_DSPUNIT *unit, signed char active); +DLL_API signed char F_API FSOUND_DSP_GetActive(FSOUND_DSPUNIT *unit); + +/* + Functions to get hold of FSOUND 'system DSP unit' handles. +*/ + +DLL_API FSOUND_DSPUNIT *F_API FSOUND_DSP_GetClearUnit(); +DLL_API FSOUND_DSPUNIT *F_API FSOUND_DSP_GetSFXUnit(); +DLL_API FSOUND_DSPUNIT *F_API FSOUND_DSP_GetMusicUnit(); +DLL_API FSOUND_DSPUNIT *F_API FSOUND_DSP_GetFFTUnit(); +DLL_API FSOUND_DSPUNIT *F_API FSOUND_DSP_GetClipAndCopyUnit(); + +/* + Miscellaneous DSP functions + Note for the spectrum analysis function to work, you have to enable the FFT DSP unit with + the following code FSOUND_DSP_SetActive(FSOUND_DSP_GetFFTUnit(), TRUE); + It is off by default to save cpu usage. +*/ + +DLL_API signed char F_API FSOUND_DSP_MixBuffers(void *destbuffer, void *srcbuffer, int len, int freq, int vol, int pan, unsigned int mode); +DLL_API void F_API FSOUND_DSP_ClearMixBuffer(); +DLL_API int F_API FSOUND_DSP_GetBufferLength(); /* Length of each DSP update */ +DLL_API int F_API FSOUND_DSP_GetBufferLengthTotal(); /* Total buffer length due to FSOUND_SetBufferSize */ +DLL_API float * F_API FSOUND_DSP_GetSpectrum(); /* Array of 512 floats - call FSOUND_DSP_SetActive(FSOUND_DSP_GetFFTUnit(), TRUE)) for this to work. */ + +/* =================================================================================== */ +/* Reverb functions. (eax2/eax3 reverb) (ONLY SUPPORTED ON WIN32 W/ FSOUND_HW3D FLAG) */ +/* =================================================================================== */ + +/* + See top of file for definitions and information on the reverb parameters. +*/ + +DLL_API signed char F_API FSOUND_Reverb_SetProperties(const FSOUND_REVERB_PROPERTIES *prop); +DLL_API signed char F_API FSOUND_Reverb_GetProperties(FSOUND_REVERB_PROPERTIES *prop); +DLL_API signed char F_API FSOUND_Reverb_SetChannelProperties(int channel, const FSOUND_REVERB_CHANNELPROPERTIES *prop); +DLL_API signed char F_API FSOUND_Reverb_GetChannelProperties(int channel, FSOUND_REVERB_CHANNELPROPERTIES *prop); + +/* ===================================================== */ +/* Recording functions (ONLY SUPPORTED IN WIN32, WINCE) */ +/* ===================================================== */ + +/* + Recording initialization functions +*/ + +DLL_API signed char F_API FSOUND_Record_SetDriver(int outputtype); +DLL_API int F_API FSOUND_Record_GetNumDrivers(); +DLL_API const char * F_API FSOUND_Record_GetDriverName(int id); +DLL_API int F_API FSOUND_Record_GetDriver(); + +/* + Recording functionality. Only one recording session will work at a time. +*/ + +DLL_API signed char F_API FSOUND_Record_StartSample(FSOUND_SAMPLE *sptr, signed char loop); +DLL_API signed char F_API FSOUND_Record_Stop(); +DLL_API int F_API FSOUND_Record_GetPosition(); + +/* ========================================================================================== */ +/* FMUSIC API (MOD,S3M,XM,IT,MIDI PLAYBACK) */ +/* ========================================================================================== */ + +/* + Song management / playback functions. +*/ + +DLL_API FMUSIC_MODULE * F_API FMUSIC_LoadSong(const char *name); +DLL_API FMUSIC_MODULE * F_API FMUSIC_LoadSongEx(const char *name_or_data, int offset, int length, unsigned int mode, const int *samplelist, int samplelistnum); +DLL_API int F_API FMUSIC_GetOpenState(FMUSIC_MODULE *mod); +DLL_API signed char F_API FMUSIC_FreeSong(FMUSIC_MODULE *mod); +DLL_API signed char F_API FMUSIC_PlaySong(FMUSIC_MODULE *mod); +DLL_API signed char F_API FMUSIC_StopSong(FMUSIC_MODULE *mod); +DLL_API void F_API FMUSIC_StopAllSongs(); + +DLL_API signed char F_API FMUSIC_SetZxxCallback(FMUSIC_MODULE *mod, FMUSIC_CALLBACK callback); +DLL_API signed char F_API FMUSIC_SetRowCallback(FMUSIC_MODULE *mod, FMUSIC_CALLBACK callback, int rowstep); +DLL_API signed char F_API FMUSIC_SetOrderCallback(FMUSIC_MODULE *mod, FMUSIC_CALLBACK callback, int orderstep); +DLL_API signed char F_API FMUSIC_SetInstCallback(FMUSIC_MODULE *mod, FMUSIC_CALLBACK callback, int instrument); + +DLL_API signed char F_API FMUSIC_SetSample(FMUSIC_MODULE *mod, int sampno, FSOUND_SAMPLE *sptr); +DLL_API signed char F_API FMUSIC_SetUserData(FMUSIC_MODULE *mod, void *userdata); +DLL_API signed char F_API FMUSIC_OptimizeChannels(FMUSIC_MODULE *mod, int maxchannels, int minvolume); + +/* + Runtime song functions. +*/ + +DLL_API signed char F_API FMUSIC_SetReverb(signed char reverb); /* MIDI only */ +DLL_API signed char F_API FMUSIC_SetLooping(FMUSIC_MODULE *mod, signed char looping); +DLL_API signed char F_API FMUSIC_SetOrder(FMUSIC_MODULE *mod, int order); +DLL_API signed char F_API FMUSIC_SetPaused(FMUSIC_MODULE *mod, signed char pause); +DLL_API signed char F_API FMUSIC_SetMasterVolume(FMUSIC_MODULE *mod, int volume); +DLL_API signed char F_API FMUSIC_SetMasterSpeed(FMUSIC_MODULE *mode, float speed); +DLL_API signed char F_API FMUSIC_SetPanSeperation(FMUSIC_MODULE *mod, float pansep); + +/* + Static song information functions. +*/ + +DLL_API const char * F_API FMUSIC_GetName(FMUSIC_MODULE *mod); +DLL_API int F_API FMUSIC_GetType(FMUSIC_MODULE *mod); +DLL_API int F_API FMUSIC_GetNumOrders(FMUSIC_MODULE *mod); +DLL_API int F_API FMUSIC_GetNumPatterns(FMUSIC_MODULE *mod); +DLL_API int F_API FMUSIC_GetNumInstruments(FMUSIC_MODULE *mod); +DLL_API int F_API FMUSIC_GetNumSamples(FMUSIC_MODULE *mod); +DLL_API int F_API FMUSIC_GetNumChannels(FMUSIC_MODULE *mod); +DLL_API FSOUND_SAMPLE * F_API FMUSIC_GetSample(FMUSIC_MODULE *mod, int sampno); +DLL_API int F_API FMUSIC_GetPatternLength(FMUSIC_MODULE *mod, int orderno); + +/* + Runtime song information. +*/ + +DLL_API signed char F_API FMUSIC_IsFinished(FMUSIC_MODULE *mod); +DLL_API signed char F_API FMUSIC_IsPlaying(FMUSIC_MODULE *mod); +DLL_API int F_API FMUSIC_GetMasterVolume(FMUSIC_MODULE *mod); +DLL_API int F_API FMUSIC_GetGlobalVolume(FMUSIC_MODULE *mod); +DLL_API int F_API FMUSIC_GetOrder(FMUSIC_MODULE *mod); +DLL_API int F_API FMUSIC_GetPattern(FMUSIC_MODULE *mod); +DLL_API int F_API FMUSIC_GetSpeed(FMUSIC_MODULE *mod); +DLL_API int F_API FMUSIC_GetBPM(FMUSIC_MODULE *mod); +DLL_API int F_API FMUSIC_GetRow(FMUSIC_MODULE *mod); +DLL_API signed char F_API FMUSIC_GetPaused(FMUSIC_MODULE *mod); +DLL_API int F_API FMUSIC_GetTime(FMUSIC_MODULE *mod); +DLL_API int F_API FMUSIC_GetRealChannel(FMUSIC_MODULE *mod, int modchannel); +DLL_API void * F_API FMUSIC_GetUserData(FMUSIC_MODULE *mod); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Standard Gaming Platform/fmod_errors.h b/Standard Gaming Platform/fmod_errors.h new file mode 100644 index 00000000..b28b9c4f --- /dev/null +++ b/Standard Gaming Platform/fmod_errors.h @@ -0,0 +1,32 @@ +#ifndef _FMOD_ERRORS_H +#define _FMOD_ERRORS_H + +static char *FMOD_ErrorString(int errcode) +{ + switch (errcode) + { + case FMOD_ERR_NONE: return "No errors"; + case FMOD_ERR_BUSY: return "Cannot call this command after FSOUND_Init. Call FSOUND_Close first."; + case FMOD_ERR_UNINITIALIZED: return "This command failed because FSOUND_Init was not called"; + case FMOD_ERR_PLAY: return "Playing the sound failed."; + case FMOD_ERR_INIT: return "Error initializing output device."; + case FMOD_ERR_ALLOCATED: return "The output device is already in use and cannot be reused."; + case FMOD_ERR_OUTPUT_FORMAT: return "Soundcard does not support the features needed for this soundsystem (16bit stereo output)"; + case FMOD_ERR_COOPERATIVELEVEL: return "Error setting cooperative level for hardware."; + case FMOD_ERR_CREATEBUFFER: return "Error creating hardware sound buffer."; + case FMOD_ERR_FILE_NOTFOUND: return "File not found"; + case FMOD_ERR_FILE_FORMAT: return "Unknown file format"; + case FMOD_ERR_FILE_BAD: return "Error loading file"; + case FMOD_ERR_MEMORY: return "Not enough memory "; + case FMOD_ERR_VERSION: return "The version number of this file format is not supported"; + case FMOD_ERR_INVALID_PARAM: return "An invalid parameter was passed to this function"; + case FMOD_ERR_NO_EAX: return "Tried to use an EAX command on a non EAX enabled channel or output."; + case FMOD_ERR_CHANNEL_ALLOC: return "Failed to allocate a new channel"; + case FMOD_ERR_RECORD: return "Recording not supported on this device"; + case FMOD_ERR_MEDIAPLAYER: return "Required Mediaplayer codec is not installed"; + + default : return "Unknown error"; + }; +} + +#endif diff --git a/Standard Gaming Platform/soundman.cpp b/Standard Gaming Platform/soundman.cpp index 96c7e508..abea0c4b 100644 --- a/Standard Gaming Platform/soundman.cpp +++ b/Standard Gaming Platform/soundman.cpp @@ -4,10 +4,10 @@ * This module handles the playing of digital samples, preloaded or streamed. * * Derek Beland, May 28, 1997 +* *********************************************************************************/ #ifdef JA2_PRECOMPILED_HEADERS #include "JA2 SGP ALL.H" - #include "Debug Control.h" #elif defined( WIZ8_PRECOMPILED_HEADERS ) #include "WIZ8 SGP ALL.H" #else @@ -17,62 +17,16 @@ #include "FileMan.h" #include "debug.h" #include "MemMan.h" - #include "mss.h" #include "random.h" - #include "Debug Control.h" + #include "fmod.h" + #include "fmod_errors.h" #endif // Uncomment this to disable the startup of sound hardware //#define SOUND_DISABLE -#pragma pack(push,1) - -// WAV file chunk definitions -typedef struct { - // General chunk header - CHAR8 cTag[4]; - UINT32 uiChunkSize; - } WAVCHUNK; - -typedef struct { - // WAV header - CHAR8 cRiff[4]; // "RIFF" - UINT32 uiChunkSize; // Chunk length - CHAR8 cFileType[4]; // "WAVE" - } WAVRIFF; - -typedef struct { - // FMT chunk - CHAR8 cFormat[4]; // "FMT " - UINT32 uiChunkSize; // Chunk length - UINT16 uiStereo; // 1 if stereo, 0 if mono (Not reliable, use channels instead) - UINT16 uiChannels; // number of channels used 1=mono, 2=stereo, etc. - UINT32 uiSpeed; // Sampling Rate (speed) - UINT32 uiBytesSec; // Number of bytes per sec - UINT16 uiBytesSample; // Number of bytes per sample (1 = 8 bit mono, - // 2 = 8 bit stereo or 16 bit mono, 4 = 16 bit stereo - UINT16 uiBitsSample; // bits per sample - } WAVFMT; - -typedef struct { - // Data chunk - CHAR8 cName[4]; // "DATA" - UINT32 uiChunkSize; // Chunk length - } WAVDATA; - -#pragma pack(pop) - -#define WAV_CHUNK_RIFF 0 -#define WAV_CHUNK_FMT 1 -#define WAV_CHUNK_DATA 2 - -#define NUM_WAV_CHUNKS 3 - -CHAR8 *cWAVChunks[3]={"RIFF", "FMT ", "DATA"}; - - // global settings -#define SOUND_MAX_CACHED 128 // number of cache slots +#define SOUND_MAX_CACHED 128 // number of cache slots #ifdef JA2 #define SOUND_MAX_CHANNELS 16 // number of mixer channels @@ -80,101 +34,142 @@ CHAR8 *cWAVChunks[3]={"RIFF", "FMT ", "DATA"}; #define SOUND_MAX_CHANNELS 32 // number of mixer channels #endif -#pragma message("TEMP!") +// default memory limit +#define SOUND_DEFAULT_MEMORY (8048*1024) -#define SOUND_DEFAULT_MEMORY (8048*1024) // default memory limit -#define SOUND_DEFAULT_THRESH (256*8024) // size for sample to be double-buffered -#define SOUND_DEFAULT_STREAM (64*1024) // double-buffered buffer size +// size for sample to be double-buffered +#define SOUND_DEFAULT_THRESH (256*8024) -/*#define SOUND_DEFAULT_MEMORY (2048*1024) // default memory limit -#define SOUND_DEFAULT_THRESH (256*1024) // size for sample to be double-buffered -#define SOUND_DEFAULT_STREAM (64*1024) // double-buffered buffer size -*/ // playing/random value to indicate default #define SOUND_PARMS_DEFAULT 0xffffffff // Sound status flags -#define SOUND_CALLBACK 0x00000008 +#define SOUND_CALLBACK 0x00000008 +// Max volume +#define MAX_VOLUME (127) -// Local Function Prototypes +// Initialization parameters +#define AUDIO_BUFFER_LEN 100 +#define STREAM_BUFFER_LEN 100 + +// Lesh modifications +// Sound debug + +CHAR8 SndDebugFileName[]="sound.log"; +FILE *SndDebug; + +// Debug logging +void SoundLog(CHAR8 *strMessage); +void InitLogging(); + +// Cache system BOOLEAN SoundInitCache(void); BOOLEAN SoundShutdownCache(void); - UINT32 SoundLoadSample(STR pFilename); UINT32 SoundFreeSample(STR pFilename); UINT32 SoundGetCached(STR pFilename); UINT32 SoundLoadDisk(STR pFilename); +BOOLEAN SoundCleanCache(void); +UINT32 SoundFreeSampleIndex(UINT32 uiSample); // Low level -UINT32 SoundGetEmptySample(void); -BOOLEAN SoundProcessWAVHeader(UINT32 uiSample); -UINT32 SoundFreeSampleIndex(UINT32 uiSample); -UINT32 SoundGetIndexByID(UINT32 uiSoundID); -static HDIGDRIVER SoundInitDriver(UINT32 uiRate, UINT16 uiBits, UINT16 uiChans); +// Init, de-init BOOLEAN SoundInitHardware(void); -BOOLEAN SoundGetDriverName(HDIGDRIVER DIG, CHAR8 *cBuf); BOOLEAN SoundShutdownHardware(void); -UINT32 SoundGetFreeChannel(void); + +// Playing UINT32 SoundStartSample(UINT32 uiSample, UINT32 uiChannel, SOUNDPARMS *pParms); UINT32 SoundStartStream(STR pFilename, UINT32 uiChannel, SOUNDPARMS *pParms); -UINT32 SoundGetUniqueID(void); BOOLEAN SoundPlayStreamed(STR pFilename); -BOOLEAN SoundCleanCache(void); +UINT32 SoundStartRandom(UINT32 uiSample); +BOOLEAN SoundRandomShouldPlay(UINT32 uiSample); + +// Stopping +BOOLEAN SoundStopIndex(UINT32 uiSound); + +// Checks BOOLEAN SoundSampleIsPlaying(UINT32 uiSample); BOOLEAN SoundIndexIsPlaying(UINT32 uiSound); -BOOLEAN SoundStopIndex(UINT32 uiSound); +BOOLEAN SoundSampleIsInUse(UINT32 uiSample); + +// Volume operations UINT32 SoundGetVolumeIndex(UINT32 uiChannel); BOOLEAN SoundSetVolumeIndex(UINT32 uiChannel, UINT32 uiVolume); +// Cleaning +UINT32 SoundGetEmptySample(void); + +// Index, ID, other... +UINT32 SoundGetIndexByID(UINT32 uiSoundID); +UINT32 SoundGetFreeChannel(void); +UINT32 SoundGetUniqueID(void); + +// Callbacks +void * F_CALLBACKAPI SoundFileOpen (const CHAR8 *pName); +void F_CALLBACKAPI SoundFileClose(void *uiHandle); +INT F_CALLBACKAPI SoundFileRead (void *pBuffer, INT iSize, void *uiHandle); +INT F_CALLBACKAPI SoundFileSeek (void *uiHandle, INT iPos, signed char cMode); +INT F_CALLBACKAPI SoundFileTell (void *uiHandle); + // Global variables UINT32 guiSoundDefaultVolume = 127; -UINT32 guiSoundMemoryLimit=SOUND_DEFAULT_MEMORY; // Maximum memory used for sounds -UINT32 guiSoundMemoryUsed=0; // Memory currently in use +UINT32 guiSoundMemoryLimit=SOUND_DEFAULT_MEMORY; // Maximum memory used for sounds +UINT32 guiSoundMemoryUsed=0; // Memory currently in use UINT32 guiSoundCacheThreshold=SOUND_DEFAULT_THRESH; // Double-buffered threshold -HDIGDRIVER hSoundDriver; // Sound driver handle -BOOLEAN fDirectSound=TRUE; // Using Direct Sound +BOOLEAN hSoundDriver; // Sound driver ready ? +BOOLEAN fDirectSound=TRUE; // Using Direct Sound // Local module variables -BOOLEAN fSoundSystemInit=FALSE; // Startup called T/F -BOOLEAN gfEnableStartup=TRUE; // Allow hardware to starup +BOOLEAN fSoundSystemInit=FALSE; // Startup called T/F +BOOLEAN gfEnableStartup=TRUE; // Allow hardware to starup + +// Struct definition for sample slots in the cache +// Holds the regular sample data, as well as the +// data for the random samples + +typedef struct { + CHAR8 pName[128]; // Sample path + UINT32 uiSize; // Sample size + UINT32 uiFlags; // Status flags + PTR pData; // Pointer to loaded sample + UINT32 uiCacheHits; // Cache hits for this sample + + UINT32 uiTimeNext; // Random sound data + UINT32 uiTimeMin, uiTimeMax; + UINT32 uiVolMin, uiVolMax; + UINT32 uiPanMin, uiPanMax; + UINT32 uiPriority; // Priority + UINT32 uiInstances; // Instances of sample sounding at this moment + UINT32 uiMaxInstances; // Max allowable instances of sample + } SAMPLETAG; + +// Structure definition for slots in the sound output +// These are used for both the cached and double-buffered +// streams +typedef struct { + UINT32 uiSample; // Sample slot in cache + FSOUND_STREAM* hStream; // Stream fmod handler + UINT32 uiFMODChannel; // Fmod channel + UINT32 uiFlags; // Sample flags + UINT32 uiSoundID; // Sound unique ID + UINT32 uiPriority; // Priority + void (*EOSCallback)(void *); + void *pCallbackData; + UINT32 uiTimeStamp; // Time stamp + BOOLEAN fLooping; // Loop flag + BOOLEAN fStopAtZero; // Stop at zero volume + UINT32 uiFadeVolume; + UINT32 uiFadeRate; + UINT32 uiFadeTime; + } SOUNDTAG; // Sample cache list for files loaded SAMPLETAG pSampleList[SOUND_MAX_CACHED]; // Sound channel list for output channels SOUNDTAG pSoundList[SOUND_MAX_CHANNELS]; -// 3D sound globals -CHAR8 *gpProviderName=NULL; -HPROVIDER gh3DProvider=0; -H3DPOBJECT gh3DListener=0; -BOOLEAN gfUsingEAX=TRUE; -UINT32 guiRoomTypeIndex=0; - -CHAR8* pEAXRoomTypes[EAXROOMTYPE_NUM_TYPES] = -{ - // None - "PLAIN", - - // S,M,L Cave - "STONECORRIDOR", - "CAVE", - "CONCERTHALL", - - // S,M,L Room - "LIVINGROOM", - "ROOM", - "AUDITORIUM", - - // Flat open, valley - "CITY", - "MOUNTAINS", - - // Swimming - "UNDERWATER" -}; - //******************************************************************************* // High Level Interface //******************************************************************************* @@ -192,6 +187,19 @@ void SoundEnableSound(BOOLEAN fEnable) gfEnableStartup=fEnable; } +//******************************************************************************* +// SoundGetDriverHandle +// +// Returns: Pointer to the system level output device module. +// +//******************************************************************************* +void *SoundGetDriverHandle( void ) +{ + if(fSoundSystemInit) + return(FSOUND_GetOutputHandle()); + else + return(NULL); +} //******************************************************************************* // InitializeSoundManager @@ -203,28 +211,42 @@ void SoundEnableSound(BOOLEAN fEnable) //******************************************************************************* BOOLEAN InitializeSoundManager(void) { -UINT32 uiCount; + UINT32 uiCount; + + InitLogging(); if(fSoundSystemInit) + { + SoundLog("Reopening JA2 sound manager"); ShutdownSoundManager(); + } + else + SoundLog("Initialising JA2 sound manager"); + + SoundLog((CHAR8 *)String(" Using %d channels", SOUND_MAX_CHANNELS)); for(uiCount=0; uiCount < SOUND_MAX_CHANNELS; uiCount++) + { memset(&pSoundList[uiCount], 0, sizeof(SOUNDTAG)); - + } + + // Setup callbacks + FSOUND_File_SetCallbacks(SoundFileOpen, SoundFileClose, SoundFileRead, SoundFileSeek, SoundFileTell); + #ifndef SOUND_DISABLE if(gfEnableStartup && SoundInitHardware()) fSoundSystemInit=TRUE; #endif SoundInitCache(); - + + SoundLog((CHAR8 *)String(" Sound memory limit = %i", SOUND_DEFAULT_MEMORY)); + SoundLog((CHAR8 *)String(" Cache threshold = %i", SOUND_DEFAULT_THRESH)); + guiSoundMemoryLimit=SOUND_DEFAULT_MEMORY; guiSoundMemoryUsed=0; guiSoundCacheThreshold=SOUND_DEFAULT_THRESH; - if(gpProviderName && !gh3DProvider) - Sound3DInitProvider(gpProviderName); - return(TRUE); } @@ -237,17 +259,14 @@ UINT32 uiCount; //******************************************************************************* void ShutdownSoundManager(void) { - if(gh3DProvider) - Sound3DShutdownProvider(); + SoundLog("Closing sound system..."); SoundStopAll(); - SoundStopMusic(); SoundShutdownCache(); Sleep(1000); SoundShutdownHardware(); - //Sleep(1000); fSoundSystemInit=FALSE; - + SoundLog("JA2 sound manager shutdown"); } //******************************************************************************* @@ -286,12 +305,6 @@ UINT32 SoundPlay(STR pFilename, SOUNDPARMS *pParms) else { //Trying to play a sound which is bigger then the 'guiSoundCacheThreshold' - - // This line was causing a page fault in the Wiz 8 project, so - // I changed it to the second line, which works OK. -- DB - - //DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("\n*******\nSoundPlay(): ERROR: trying to play %s which is bigger then the 'guiSoundCacheThreshold', use SoundPlayStreamedFile() instead\n", pFilename ) ); - FastDebugMsg(String("SoundPlay: ERROR: Trying to play %s sound is too lardge to load into cache, use SoundPlayStreamedFile() instead\n", pFilename ) ); } } @@ -316,55 +329,23 @@ UINT32 SoundPlay(STR pFilename, SOUNDPARMS *pParms) UINT32 SoundPlayStreamedFile( STR pFilename, SOUNDPARMS *pParms ) { UINT32 uiChannel; - HANDLE hRealFileHandle; - CHAR8 pFileHandlefileName[ 128 ]; HWFILE hFile; - UINT32 uiRetVal=FALSE; if( fSoundSystemInit ) { if((uiChannel=SoundGetFreeChannel())!=SOUND_ERROR) { - //Open the file hFile = FileOpen( pFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); if( !hFile ) { - FastDebugMsg(String("\n*******\nSoundPlayStreamedFile(): ERROR: Couldnt open '%s' in SoundPlayStreamedFile()\n", pFilename ) ); + SoundLog((CHAR8 *)String(" ERROR in SoundPlayStreamedFile(): Couldnt open '%s'", pFilename ) ); return( SOUND_ERROR ); } - // MSS cannot determine which provider to play if you don't give it a real filename - // so if the file isn't in a library, play it normally - if(DB_EXTRACT_LIBRARY(hFile) == REAL_FILE_LIBRARY_ID) - { - FileClose(hFile); - return(SoundStartStream( pFilename, uiChannel, pParms)); - } - - //Get the real file handle of the file - hRealFileHandle = GetRealFileHandleFromFileManFileHandle( hFile ); - if( hRealFileHandle == 0 ) - { - FastDebugMsg(String("\n*******\nSoundPlayStreamedFile(): ERROR: Couldnt get a real file handle for '%s' in SoundPlayStreamedFile()\n", pFilename ) ); - return( SOUND_ERROR ); - } - - //Convert the file handle into a 'name' - sprintf( pFileHandlefileName, "\\\\\\\\%d", hRealFileHandle ); - - //Start the sound stream - uiRetVal = SoundStartStream( pFileHandlefileName, uiChannel, pParms); - - //if it succeeded, record the file handle - if( uiRetVal != SOUND_ERROR ) - pSoundList[uiChannel].hFile = hFile; - else - FileClose( hFile ); - - return( uiRetVal ); + FileClose(hFile); + return(SoundStartStream( pFilename, uiChannel, pParms)); } } - return(SOUND_ERROR); } @@ -386,14 +367,16 @@ UINT32 SoundPlayStreamedFile( STR pFilename, SOUNDPARMS *pParms ) //******************************************************************************* UINT32 SoundPlayRandom(STR pFilename, RANDOMPARMS *pParms) { -UINT32 uiSample, uiTicks; - + UINT32 uiSample; + if(fSoundSystemInit) { if((uiSample=SoundLoadSample(pFilename))!=NO_SAMPLE) { + // Sample loaded - marking slot pSampleList[uiSample].uiFlags|=(SAMPLE_RANDOM|SAMPLE_LOCKED); + // Setup time intervals if(pParms->uiTimeMin==SOUND_PARMS_DEFAULT) return(SOUND_ERROR); else @@ -404,10 +387,7 @@ UINT32 uiSample, uiTicks; else pSampleList[uiSample].uiTimeMax=pParms->uiTimeMax; - pSampleList[uiSample].uiSpeedMin=pParms->uiSpeedMin; - - pSampleList[uiSample].uiSpeedMax=pParms->uiSpeedMax; - + // Volume if(pParms->uiVolMin==SOUND_PARMS_DEFAULT) pSampleList[uiSample].uiVolMin=guiSoundDefaultVolume; else @@ -418,21 +398,25 @@ UINT32 uiSample, uiTicks; else pSampleList[uiSample].uiVolMax=pParms->uiVolMax; + // Panning if(pParms->uiPanMin==SOUND_PARMS_DEFAULT) - pSampleList[uiSample].uiPanMin=64; + { + pSampleList[uiSample].uiPanMin=128; + pSampleList[uiSample].uiPanMax=128; + } else + { pSampleList[uiSample].uiPanMin=pParms->uiPanMin; + pSampleList[uiSample].uiPanMax=pParms->uiPanMax; + } - if(pParms->uiPanMax==SOUND_PARMS_DEFAULT) - pSampleList[uiSample].uiPanMax=64; - else - pSampleList[uiSample].uiPanMax=pParms->uiPanMax; - + // Max instances if(pParms->uiMaxInstances==SOUND_PARMS_DEFAULT) pSampleList[uiSample].uiMaxInstances=1; else pSampleList[uiSample].uiMaxInstances=pParms->uiMaxInstances; + // Priority if(pParms->uiPriority==SOUND_PARMS_DEFAULT) pSampleList[uiSample].uiPriority=PRIORITY_RANDOM; else @@ -440,48 +424,20 @@ UINT32 uiSample, uiTicks; pSampleList[uiSample].uiInstances=0; - uiTicks=GetTickCount(); + // Time stamp pSampleList[uiSample].uiTimeNext=GetTickCount()+pSampleList[uiSample].uiTimeMin+Random(pSampleList[uiSample].uiTimeMax-pSampleList[uiSample].uiTimeMin); + return(uiSample); } + else + { + SoundLog((CHAR8 *)String(" ERROR in SoundPlayRandom(): Couldnt open '%s'", pFilename ) ); + } } return(SOUND_ERROR); } -//******************************************************************************* -// SoundStreamCallback -// -// Plays a sound through streaming, and executes a callback for each buffer -// loaded. -// -// Returns: If successful, it returns the sample index it is loaded to, else -// SOUND_ERROR is returned. -// -//******************************************************************************* -UINT32 SoundStreamCallback(STR pFilename, SOUNDPARMS *pParms, void (*pCallback)(UINT8 *, UINT32, UINT32, UINT32, void *), void *pData) -{ -UINT32 uiChannel, uiSoundID; - - if(fSoundSystemInit) - { - if((uiChannel=SoundGetFreeChannel())!=SOUND_ERROR) - { - uiSoundID=SoundStartStream(pFilename, uiChannel, pParms); - if(uiSoundID!=SOUND_ERROR) - { - AIL_auto_service_stream(pSoundList[uiChannel].hMSSStream, FALSE); - pSoundList[uiChannel].pCallback=pCallback; - pSoundList[uiChannel].pData=pData; - pSoundList[uiChannel].uiFlags|=SOUND_CALLBACK; - - return(uiSoundID); - } - } - } - return(SOUND_ERROR); -} - //******************************************************************************* // SoundIsPlaying // @@ -491,18 +447,19 @@ UINT32 uiChannel, uiSoundID; BOOLEAN SoundIsPlaying(UINT32 uiSoundID) { UINT32 uiSound; - + if(fSoundSystemInit) { uiSound=SoundGetIndexByID(uiSoundID); if(uiSound!=NO_SAMPLE) - return(SoundIndexIsPlaying(uiSound)); + { + return(SoundIndexIsPlaying(uiSound)); + } } return(FALSE); } - //***************************************************************************************** // SoundIndexIsPlaying // @@ -516,20 +473,10 @@ UINT32 uiSound; //***************************************************************************************** BOOLEAN SoundIndexIsPlaying(UINT32 uiSound) { -INT32 iStatus=SMP_DONE; - if(fSoundSystemInit) { - if(pSoundList[uiSound].hMSS!=NULL) - iStatus = AIL_sample_status(pSoundList[uiSound].hMSS); - - if(pSoundList[uiSound].hMSSStream!=NULL) - iStatus = AIL_stream_status(pSoundList[uiSound].hMSSStream); - - if(pSoundList[uiSound].hM3D!=NULL) - iStatus = AIL_3D_sample_status(pSoundList[uiSound].hM3D); - - return((iStatus!=SMP_DONE) && (iStatus!=SMP_STOPPED)); + if( pSoundList[uiSound].hStream!=NULL ) + return(FSOUND_IsPlaying(pSoundList[uiSound].uiFMODChannel)); } return(FALSE); @@ -560,41 +507,10 @@ UINT32 uiSound; } } } + return(FALSE); } -//******************************************************************************* -// SoundStopGroup -// -// Stops multiple instances of sounds that have the indicated priority. This -// is useful for silencing all ambient sounds when switching to menus, etc. -// -// Returns: TRUE if samples were actually stopped, FALSE if none were found -// -//******************************************************************************* -BOOLEAN SoundStopGroup(UINT32 uiPriority) -{ -UINT32 uiCount; -BOOLEAN fStopped=FALSE; - - if(fSoundSystemInit) - { - for(uiCount=0; uiCount < SOUND_MAX_CHANNELS; uiCount++) - { - if((pSoundList[uiCount].hMSS!=NULL) || (pSoundList[uiCount].hMSSStream!=NULL) || (pSoundList[uiCount].hM3D!=NULL)) - { - if(pSoundList[uiCount].uiPriority==uiPriority) - { - SoundStop(pSoundList[uiCount].uiSoundID); - fStopped=TRUE; - } - } - } - } - - return(fStopped); -} - //******************************************************************************* // SoundSetMemoryLimit // @@ -630,45 +546,6 @@ BOOLEAN SoundGetSystemInfo(void) return(FALSE); } -//******************************************************************************* -// SoundSetDigitalVolume -// -// Sets the master volume for the digital section. All sample volumes will be -// affected by this setting. -// -// Returns: TRUE, always -// -//******************************************************************************* -BOOLEAN SoundSetDigitalVolume(UINT32 uiVolume) -{ -UINT32 uiVolClip; - - if(fSoundSystemInit) - { - uiVolClip=__min(uiVolume, 127); - AIL_set_digital_master_volume(hSoundDriver, uiVolClip); - } - return(TRUE); -} - -//******************************************************************************* -// SoundGetDigitalVolume -// -// Returns the current value of the digital master volume. -// -// Returns: 0-127 -// -//******************************************************************************* -UINT32 SoundGetDigitalVolume(UINT32 uiVolume) -{ - if(fSoundSystemInit) - return((UINT32)AIL_digital_master_volume(hSoundDriver)); - else - return(0); -} - - - //***************************************************************************************** // SoundSetDefaultVolume // @@ -682,10 +559,9 @@ UINT32 SoundGetDigitalVolume(UINT32 uiVolume) //***************************************************************************************** void SoundSetDefaultVolume(UINT32 uiVolume) { - guiSoundDefaultVolume=__min(uiVolume, 127); + guiSoundDefaultVolume=__min(uiVolume, MAX_VOLUME); } - //***************************************************************************************** // SoundGetDefaultVolume // @@ -702,8 +578,6 @@ UINT32 SoundGetDefaultVolume(void) return(guiSoundDefaultVolume); } - - //******************************************************************************* // SoundStopAll // @@ -716,10 +590,11 @@ BOOLEAN SoundStopAll(void) { UINT32 uiCount; + SoundLog(" Stopping all sounds"); + if(fSoundSystemInit) { for(uiCount=0; uiCount < SOUND_MAX_CHANNELS; uiCount++) - if(!pSoundList[uiCount].fMusic) SoundStopIndex(uiCount); } @@ -727,47 +602,6 @@ UINT32 uiCount; } -//***************************************************************************************** -// SoundSetFadeVolume -// -// Sets a target volume to fade towards. The fade volume is updated in SoundServiceStreams. -// -// Returns BOOLEAN - TRUE if the fading volume was set, FALSE otherwise -// -// UINT32 uiSoundID - ID of sound -// UINT32 uiVolume - Volume to fade towards (0-127) -// UINT32 uiRate - Total time taken to change volume -// BOOLEAN fStopAtZero - If TRUE, sample is stopped when volume reaches zero -// -// Created: 3/17/00 Derek Beland -//***************************************************************************************** -BOOLEAN SoundSetFadeVolume(UINT32 uiSoundID, UINT32 uiVolume, UINT32 uiRate, BOOLEAN fStopAtZero) -{ -UINT32 uiSound, uiVolCap, uiVolumeDiff; - - if(fSoundSystemInit) - { - uiVolCap=__min(uiVolume, 127); - - if((uiSound=SoundGetIndexByID(uiSoundID))!=NO_SAMPLE) - { - uiVolumeDiff = abs((long)(uiVolCap - SoundGetVolumeIndex(uiSound))); - - if(!uiVolumeDiff) - return(FALSE); - - pSoundList[uiSound].uiFadeVolume = uiVolCap; - pSoundList[uiSound].fStopAtZero = fStopAtZero; - pSoundList[uiSound].uiFadeRate = uiRate / uiVolumeDiff; - pSoundList[uiSound].uiFadeTime = GetTickCount(); - - return(TRUE); - } - } - - return(FALSE); -} - //******************************************************************************* // SoundSetVolume // @@ -781,18 +615,18 @@ BOOLEAN SoundSetVolume(UINT32 uiSoundID, UINT32 uiVolume) { UINT32 uiSound, uiVolCap; - if(fSoundSystemInit) + if(fSoundSystemInit) { - uiVolCap=__min(uiVolume, 127); + uiVolCap=__min(uiVolume, MAX_VOLUME); if((uiSound=SoundGetIndexByID(uiSoundID))!=NO_SAMPLE) { pSoundList[uiSound].uiFadeVolume = uiVolume; - return(SoundSetVolumeIndex(uiSound, uiVolume)); + return(SoundSetVolumeIndex(uiSound, uiVolume)); } } - - return(FALSE); + + return(FALSE); } @@ -814,18 +648,12 @@ UINT32 uiVolCap; if(fSoundSystemInit) { - uiVolCap=__min(uiVolume, 127); + uiVolCap=__min(uiVolume, MAX_VOLUME); - if(pSoundList[uiChannel].hMSS!=NULL) - AIL_set_sample_volume(pSoundList[uiChannel].hMSS, uiVolCap); + if( pSoundList[uiChannel].hStream!=NULL ) + FSOUND_SetVolume(pSoundList[uiChannel].uiFMODChannel, uiVolCap * 2); - if(pSoundList[uiChannel].hMSSStream!=NULL) - AIL_set_stream_volume(pSoundList[uiChannel].hMSSStream, uiVolCap); - - if(pSoundList[uiChannel].hM3D!=NULL) - AIL_set_3D_sample_volume(pSoundList[uiChannel].hM3D, uiVolCap); - - return(TRUE); + return(TRUE); } return(FALSE); @@ -846,15 +674,12 @@ UINT32 uiSound, uiPanCap; if(fSoundSystemInit) { - uiPanCap=__min(uiPan, 127); + uiPanCap=__min(uiPan, 255); if((uiSound=SoundGetIndexByID(uiSoundID))!=NO_SAMPLE) { - if(pSoundList[uiSound].hMSS!=NULL) - AIL_set_sample_pan(pSoundList[uiSound].hMSS, uiPanCap); - - if(pSoundList[uiSound].hMSSStream!=NULL) - AIL_set_stream_pan(pSoundList[uiSound].hMSSStream, uiPanCap); + if( pSoundList[uiSound].hStream!=NULL ) + FSOUND_SetPan(pSoundList[uiSound].uiFMODChannel, uiPanCap); return(TRUE); } @@ -863,75 +688,6 @@ UINT32 uiSound, uiPanCap; return(FALSE); } -//******************************************************************************* -// SoundSetFrequency -// -// Sets the frequency on a currently playing sound. -// -// Returns: TRUE if the frequency was actually set on the sample, FALSE if the -// sample had already expired or couldn't be found -// -//******************************************************************************* -BOOLEAN SoundSetFrequency(UINT32 uiSoundID, UINT32 uiFreq) -{ -UINT32 uiSound, uiFreqCap; - - if(fSoundSystemInit) - { - uiFreqCap=__min(uiFreq, 44100); - - if((uiSound=SoundGetIndexByID(uiSoundID))!=NO_SAMPLE) - { - if(pSoundList[uiSound].hMSS!=NULL) - AIL_set_sample_playback_rate(pSoundList[uiSound].hMSS, uiFreqCap); - - if(pSoundList[uiSound].hMSSStream!=NULL) - AIL_set_stream_playback_rate(pSoundList[uiSound].hMSSStream, uiFreqCap); - - if(pSoundList[uiSound].hM3D!=NULL) - AIL_set_3D_sample_playback_rate(pSoundList[uiSound].hM3D, uiFreqCap); - - return(TRUE); - } - } - - return(FALSE); -} - -//******************************************************************************* -// SoundSetLoop -// -// Sets the loop on a currently playing sound. -// -// Returns: TRUE if the loop was actually set on the sample, FALSE if the -// sample had already expired or couldn't be found -// -//******************************************************************************* -BOOLEAN SoundSetLoop(UINT32 uiSoundID, UINT32 uiLoop) -{ -UINT32 uiSound, uiLoopCap; - - if(fSoundSystemInit) - { - uiLoopCap=__min(uiLoop, 10000); - - if((uiSound=SoundGetIndexByID(uiSoundID))!=NO_SAMPLE) - { - if(pSoundList[uiSound].hMSS!=NULL) - AIL_set_sample_loop_count(pSoundList[uiSound].hMSS, uiLoopCap); - - if(pSoundList[uiSound].hMSSStream!=NULL) - AIL_set_stream_loop_count(pSoundList[uiSound].hMSSStream, uiLoopCap); - - if(pSoundList[uiSound].hM3D!=NULL) - AIL_set_3D_sample_loop_count(pSoundList[uiSound].hM3D, uiLoopCap); - - return(TRUE); - } - } - - return(FALSE); -} //******************************************************************************* // SoundGetVolume @@ -967,100 +723,10 @@ UINT32 uiSound; //***************************************************************************************** UINT32 SoundGetVolumeIndex(UINT32 uiChannel) { - if(fSoundSystemInit) + if(fSoundSystemInit) { - if(pSoundList[uiChannel].hMSS!=NULL) - return((UINT32)AIL_sample_volume(pSoundList[uiChannel].hMSS)); - - if(pSoundList[uiChannel].hMSSStream!=NULL) - return((UINT32)AIL_stream_volume(pSoundList[uiChannel].hMSSStream)); - - if(pSoundList[uiChannel].hM3D!=NULL) - return((UINT32)AIL_3D_sample_volume(pSoundList[uiChannel].hM3D)); - } - - return(SOUND_ERROR); -} - -//******************************************************************************* -// SoundGetPan -// -// Returns the current pan setting of a sound that is playing. If the sound -// has expired, or could not be found, SOUND_ERROR is returned. -// -//******************************************************************************* -UINT32 SoundGetPan(UINT32 uiSoundID) -{ -UINT32 uiSound; - - if(fSoundSystemInit) - { - if((uiSound=SoundGetIndexByID(uiSoundID))!=NO_SAMPLE) - { - if(pSoundList[uiSound].hMSS!=NULL) - return((UINT32)AIL_sample_pan(pSoundList[uiSound].hMSS)); - - if(pSoundList[uiSound].hMSSStream!=NULL) - return((UINT32)AIL_stream_pan(pSoundList[uiSound].hMSSStream)); - } - } - - return(SOUND_ERROR); -} - -//******************************************************************************* -// SoundGetFrequency -// -// Returns the current frequency setting of a sound that is playing. If the sound -// has expired, or could not be found, SOUND_ERROR is returned. -// -//******************************************************************************* -UINT32 SoundGetFrequency(UINT32 uiSoundID) -{ -UINT32 uiSound; - - if(fSoundSystemInit) - { - if((uiSound=SoundGetIndexByID(uiSoundID))!=NO_SAMPLE) - { - if(pSoundList[uiSound].hMSS!=NULL) - return((UINT32)AIL_sample_playback_rate(pSoundList[uiSound].hMSS)); - - if(pSoundList[uiSound].hMSSStream!=NULL) - return((UINT32)AIL_stream_playback_rate(pSoundList[uiSound].hMSSStream)); - - if(pSoundList[uiSound].hM3D!=NULL) - return((UINT32)AIL_3D_sample_playback_rate(pSoundList[uiSound].hM3D)); - } - } - - return(SOUND_ERROR); -} - -//******************************************************************************* -// SoundGetLoop -// -// Returns the current loop count of a sound that is playing. If the sound -// has expired, or could not be found, SOUND_ERROR is returned. -// -//******************************************************************************* -UINT32 SoundGetLoop(UINT32 uiSoundID) -{ -UINT32 uiSound; - - if(fSoundSystemInit) - { - if((uiSound=SoundGetIndexByID(uiSoundID))!=NO_SAMPLE) - { - if(pSoundList[uiSound].hMSS!=NULL) - return((UINT32)AIL_sample_loop_count(pSoundList[uiSound].hMSS)); - - if(pSoundList[uiSound].hMSSStream!=NULL) - return((UINT32)AIL_stream_loop_count(pSoundList[uiSound].hMSSStream)); - - if(pSoundList[uiSound].hM3D!=NULL) - return((UINT32)AIL_3D_sample_loop_count(pSoundList[uiSound].hM3D)); - } + if( pSoundList[uiChannel].hStream!=NULL ) + return((UINT32)FSOUND_GetVolume(pSoundList[uiChannel].uiFMODChannel) / 2); } return(SOUND_ERROR); @@ -1082,15 +748,15 @@ UINT32 uiSound; BOOLEAN SoundServiceRandom(void) { UINT32 uiCount; -// DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"SoundServiceRandom "); - for(uiCount=0; uiCount < SOUND_MAX_CACHED; uiCount++) +BOOLEAN fRandomSoundWasCreated=FALSE; + + for(uiCount=0; uiCount < SOUND_MAX_CACHED; uiCount++) { if(!(pSampleList[uiCount].uiFlags&SAMPLE_RANDOM_MANUAL) && SoundRandomShouldPlay(uiCount)) - SoundStartRandom(uiCount); -// DebugMsg (TOPIC_JA2,DBG_LEVEL_3,String("SoundStartRandom uicount = %d",uiCount)); + fRandomSoundWasCreated |= SoundStartRandom(uiCount); } - return(FALSE); + return(fRandomSoundWasCreated); } //******************************************************************************* @@ -1103,13 +769,12 @@ UINT32 uiCount; //******************************************************************************* BOOLEAN SoundRandomShouldPlay(UINT32 uiSample) { -UINT32 uiTicks; - - uiTicks=GetTickCount(); if(pSampleList[uiSample].uiFlags&SAMPLE_RANDOM) if(pSampleList[uiSample].uiTimeNext <= GetTickCount()) if(pSampleList[uiSample].uiInstances < pSampleList[uiSample].uiMaxInstances) + { return(TRUE); + } return(FALSE); } @@ -1124,34 +789,31 @@ UINT32 uiTicks; //******************************************************************************* UINT32 SoundStartRandom(UINT32 uiSample) { -DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"SoundStartRandom "); UINT32 uiChannel, uiSoundID; SOUNDPARMS spParms; - DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"SoundStartRandom: SoundGetFreeChannel "); - if((uiChannel=SoundGetFreeChannel())!=SOUND_ERROR) + if((uiChannel=SoundGetFreeChannel())!=SOUND_ERROR) { - DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"SoundStartRandom: memset "); memset(&spParms, 0xff, sizeof(SOUNDPARMS)); - DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"SoundStartRandom: set sample info"); -// spParms.uiSpeed=pSampleList[uiSample].uiSpeedMin+Random(pSampleList[uiSample].uiSpeedMax-pSampleList[uiSample].uiSpeedMin); spParms.uiVolume=pSampleList[uiSample].uiVolMin+Random(pSampleList[uiSample].uiVolMax-pSampleList[uiSample].uiVolMin); spParms.uiPan=pSampleList[uiSample].uiPanMin+Random(pSampleList[uiSample].uiPanMax-pSampleList[uiSample].uiPanMin); spParms.uiLoop=1; spParms.uiPriority=pSampleList[uiSample].uiPriority; - DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"SoundStartRandom: SoundStartSample"); if((uiSoundID=SoundStartSample(uiSample, uiChannel, &spParms))!=SOUND_ERROR) { pSampleList[uiSample].uiTimeNext=GetTickCount()+pSampleList[uiSample].uiTimeMin+Random(pSampleList[uiSample].uiTimeMax-pSampleList[uiSample].uiTimeMin); pSampleList[uiSample].uiInstances++; - DebugMsg (TOPIC_JA2,DBG_LEVEL_3,String("SoundStartRandom: returing sound %d ", uiSoundID)); - return(uiSoundID); + //SoundLog((CHAR8 *)String(" SoundPlayRandom(): Sample #%d = '%s'", uiSample, pFilename ) ); + return(TRUE); } + else + SoundLog((CHAR8 *)String(" ERROR in SoundStartRandom(): Sample #%d start error - %s", uiSample, FMOD_ErrorString(FSOUND_GetError()))); } - DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"SoundStartRandom: sound error "); - return(NO_SAMPLE); + else + SoundLog(" ERROR in SoundStartRandom(): Failed to get free channel"); + return(FALSE); } //******************************************************************************* @@ -1174,12 +836,12 @@ UINT32 uiChannel, uiSample; // Stop all currently playing random sounds for(uiChannel=0; uiChannel < SOUND_MAX_CHANNELS; uiChannel++) { - if((pSoundList[uiChannel].hMSS!=NULL) || (pSoundList[uiChannel].hM3D!=NULL)) + if( pSoundList[uiChannel].hStream!=NULL ) { uiSample=pSoundList[uiChannel].uiSample; // if this was a random sample, decrease the iteration count - if(pSampleList[uiSample].uiFlags&SAMPLE_RANDOM) + if ( (uiSample != -1) && (pSampleList[uiSample].uiFlags&SAMPLE_RANDOM) ) SoundStopIndex(uiChannel); } } @@ -1192,7 +854,7 @@ UINT32 uiChannel, uiSample; pSampleList[uiSample].uiFlags &= (~(SAMPLE_RANDOM | SAMPLE_LOCKED)); } - return(FALSE); + return(TRUE); } //******************************************************************************* @@ -1210,36 +872,19 @@ UINT32 uiChannel, uiSample; //******************************************************************************* BOOLEAN SoundServiceStreams(void) { -UINT32 uiCount, uiSpeed, uiBuffLen, uiBytesPerSample; -UINT8 *pBuffer; -void *pData; +UINT32 uiCount; - - if(fSoundSystemInit) + if(fSoundSystemInit) { for(uiCount=0; uiCount < SOUND_MAX_CHANNELS; uiCount++) { - if(pSoundList[uiCount].hMSSStream!=NULL) - { - if(AIL_service_stream(pSoundList[uiCount].hMSSStream, 0)) - { - if(pSoundList[uiCount].uiFlags&SOUND_CALLBACK) - { - uiSpeed=pSoundList[uiCount].hMSSStream->datarate; - uiBuffLen=pSoundList[uiCount].hMSSStream->bufsize; - pBuffer=pSoundList[uiCount].hMSSStream->bufs[pSoundList[uiCount].hMSSStream->buf1]; - uiBytesPerSample=pSoundList[uiCount].hMSSStream->samp->format; - pData=pSoundList[uiCount].pData; - pSoundList[uiCount].pCallback(pBuffer, uiBuffLen, uiSpeed, uiBytesPerSample, pData); - } - } - } - - if(pSoundList[uiCount].hMSS || pSoundList[uiCount].hMSSStream || pSoundList[uiCount].hM3D) + if( (pSoundList[uiCount].hStream!=NULL) && (pSoundList[uiCount].uiSample==-1) ) { // If a sound has a handle, but isn't playing, stop it and free up the handle if(!SoundIsPlaying(pSoundList[uiCount].uiSoundID)) + { SoundStopIndex(uiCount); + } else { // Check the volume fades on currently playing sounds UINT32 uiVolume = SoundGetVolumeIndex(uiCount); @@ -1253,7 +898,10 @@ void *pData; { uiVolume--; if(!uiVolume && pSoundList[uiCount].fStopAtZero) + { SoundStopIndex(uiCount); + SoundLog((CHAR8 *)String(" SoundServiceStreams(): Stop at zero volume on channel %d", uiCount)); + } else SoundSetVolumeIndex(uiCount, uiVolume); } @@ -1282,46 +930,12 @@ void *pData; //******************************************************************************* UINT32 SoundGetPosition(UINT32 uiSoundID) { -//UINT32 uiSound, uiFreq=0, uiPosition=0, uiBytesPerSample=0, uiFormat=0; UINT32 uiSound, uiTime, uiPosition; if(fSoundSystemInit) { if((uiSound=SoundGetIndexByID(uiSoundID))!=NO_SAMPLE) { -/* if(pSoundList[uiSound].hMSSStream!=NULL) - { - uiPosition=(UINT32)AIL_stream_position(pSoundList[uiSound].hMSSStream); - uiFreq=(UINT32)pSoundList[uiSound].hMSSStream->samp->playback_rate; - uiFormat=(UINT32)pSoundList[uiSound].hMSSStream->samp->format; - - } - else if(pSoundList[uiSound].hMSS!=NULL) - { - uiPosition=(UINT32)AIL_sample_position(pSoundList[uiSound].hMSS); - uiFreq=(UINT32)pSoundList[uiSound].hMSS->playback_rate; - uiFormat=(UINT32)pSoundList[uiSound].hMSS->format; - } - } - - switch(uiFormat) - { - case DIG_F_MONO_8: uiBytesPerSample=1; - break; - case DIG_F_MONO_16: uiBytesPerSample=2; - break; - case DIG_F_STEREO_8: uiBytesPerSample=2; - break; - case DIG_F_STEREO_16: uiBytesPerSample=4; - break; - } - - if(uiFreq) - { - return((uiPosition/uiBytesPerSample)/(uiFreq/1000)); - } - } -*/ uiTime=GetTickCount(); // check for rollover if(uiTime < pSoundList[uiSound].uiTimeStamp) @@ -1331,52 +945,10 @@ UINT32 uiSound, uiTime, uiPosition; return(uiPosition); } - } - + } return(0); } -//***************************************************************************************** -// -// SoundGetMilliSecondPosition -// -// Get the sounds total length and our current position within that -// sound in milliseconds -// -// -// Returns BOOLEAN: TRUE if the sound exists. -// -// Created by: Gilles Beauparlant -// Created on: 7/23/99 -// -//***************************************************************************************** -BOOLEAN SoundGetMilliSecondPosition(UINT32 uiSoundID, UINT32 *puiTotalMilliseconds, UINT32 *puiCurrentMilliseconds) -{ -UINT32 uiSound; - - if(fSoundSystemInit) - { - uiSound=SoundGetIndexByID(uiSoundID); - if(uiSound!=NO_SAMPLE) - { - if(pSoundList[uiSound].hMSS!=NULL) - { - AIL_sample_ms_position(pSoundList[uiSound].hMSS, (long *)puiTotalMilliseconds, (long *)puiCurrentMilliseconds); - return TRUE; - } - - if(pSoundList[uiSound].hMSSStream!=NULL) - { - AIL_stream_ms_position(pSoundList[uiSound].hMSSStream, (long *)puiTotalMilliseconds, (long *)puiCurrentMilliseconds); - return TRUE; - } - } - } - - *puiTotalMilliseconds = 0; - *puiCurrentMilliseconds = 0; - return FALSE; -} //******************************************************************************* // Cacheing Subsystem @@ -1390,10 +962,15 @@ UINT32 uiSound; //******************************************************************************* BOOLEAN SoundInitCache(void) { -UINT32 uiCount; + UINT32 uiCount; + + SoundLog("Init cache..."); + SoundLog((CHAR8 *)String(" Using %d cache slots", SOUND_MAX_CACHED)); for(uiCount=0; uiCount < SOUND_MAX_CACHED; uiCount++) + { memset(&pSampleList[uiCount], 0, sizeof(SAMPLETAG)); + } return(TRUE); } @@ -1409,6 +986,7 @@ UINT32 uiCount; BOOLEAN SoundShutdownCache(void) { SoundEmptyCache(); + SoundLog("Cache shutdown"); return(TRUE); } @@ -1443,6 +1021,7 @@ BOOLEAN SoundEmptyCache(void) { UINT32 uiCount; + SoundLog("Cleaning cache"); SoundStopAll(); for(uiCount=0; uiCount < SOUND_MAX_CACHED; uiCount++) @@ -1455,12 +1034,12 @@ UINT32 uiCount; //******************************************************************************* // SoundLoadSample // -// Frees up all samples in the cache. +// Loads a sample into cache. // -// Returns: TRUE, always +// Returns: Sample index, if OK. NO_SAMPLE - if error. // //******************************************************************************* -UINT32 SoundLoadSample(STR pFilename) +UINT32 SoundLoadSample(STR pFilename) { UINT32 uiSample=NO_SAMPLE; @@ -1540,27 +1119,6 @@ UINT32 uiSample; return(NO_SAMPLE); } -//******************************************************************************* -// SoundFreeGroup -// -// Releases a group of samples with a given priority. Does not take into -// account locked/unlocked status. -// -// Returns: TRUE if samples were freed, FALSE if none -// -// NOTE: -// This function is going to be removed! If you are attempting to stop all -// random sounds, call SoundStopAllRandom instead. -// -//******************************************************************************* -BOOLEAN SoundFreeGroup(UINT32 uiPriority) -{ -BOOLEAN fFreed=FALSE; - - SoundStopGroup(uiPriority); - - return(fFreed); -} //******************************************************************************* // SoundGetCached // @@ -1599,9 +1157,7 @@ UINT32 SoundLoadDisk(STR pFilename) { HWFILE hFile; UINT32 uiSize, uiSample; -BOOLEAN fRemoved=TRUE; - - Assert(pFilename!=NULL); +BOOLEAN fRemoved; if((hFile=FileOpen(pFilename, FILE_ACCESS_READ, FALSE))!=0) { @@ -1616,7 +1172,7 @@ BOOLEAN fRemoved=TRUE; // if we still don't fit if((uiSize + guiSoundMemoryUsed) > guiSoundMemoryLimit) { - FastDebugMsg(String("SoundLoadDisk: ERROR: trying to play %s, not enough memory\n", pFilename ) ); + SoundLog((CHAR8 *)String(" ERROR in SoundLoadDisk(): trying to play '%s', not enough memory", pFilename ) ); FileClose(hFile); return(NO_SAMPLE); } @@ -1631,16 +1187,16 @@ BOOLEAN fRemoved=TRUE; // if we still don't have a sample slot if(uiSample==NO_SAMPLE) { - FastDebugMsg(String("SoundLoadDisk: ERROR: Trying to play %s, sound channels are full\n", pFilename ) ); + SoundLog((CHAR8 *)String(" ERROR in SoundLoadDisk(): Trying to play '%s', cache slots are full", pFilename ) ); FileClose(hFile); return(NO_SAMPLE); } memset(&pSampleList[uiSample], 0, sizeof(SAMPLETAG)); - if((pSampleList[uiSample].pData=AIL_mem_alloc_lock(uiSize))==NULL) + if((pSampleList[uiSample].pData=MemAlloc(uiSize))==NULL) { - FastDebugMsg(String("SoundLoadDisk: ERROR: Trying to play %s, AIL channels are full\n", pFilename ) ); + SoundLog((CHAR8 *)String(" ERROR in SoundLoadDisk(): Trying to play '%s', memory allocation failed", pFilename ) ); FileClose(hFile); return(NO_SAMPLE); } @@ -1650,17 +1206,17 @@ BOOLEAN fRemoved=TRUE; FileRead(hFile, pSampleList[uiSample].pData, uiSize, NULL); FileClose(hFile); - strcpy(pSampleList[uiSample].pName, pFilename); strupr(pSampleList[uiSample].pName); pSampleList[uiSample].uiSize=uiSize; pSampleList[uiSample].uiFlags|=SAMPLE_ALLOCATED; - -/* if(!strstr(pFilename, ".MP3")) - SoundProcessWAVHeader(uiSample); -*/ return(uiSample); + return(uiSample); } + else + { + SoundLog((CHAR8 *)String(" ERROR in SoundLoadDisk(): Failed to open '%s'", pFilename)); + } return(NO_SAMPLE); } @@ -1693,7 +1249,7 @@ UINT32 uiCount, uiLowestHits=NO_SAMPLE, uiLowestHitsCount=0; } } - if(uiLowestHits!=NO_SAMPLE) + if(uiLowestHits!=NO_SAMPLE) { SoundFreeSampleIndex(uiLowestHits); return(TRUE); @@ -1746,37 +1302,6 @@ UINT32 uiCount; return(NO_SAMPLE); } -//******************************************************************************* -// SoundProcessWAVHeader -// -// Reads the information contained in the header of a loaded WAV file, and -// transfers it to the system structures for that slot. -// -// Returns: TRUE if a good header was processed, FALSE if an error occurred. -// -//******************************************************************************* -BOOLEAN SoundProcessWAVHeader(UINT32 uiSample) -{ -CHAR8 *pChunk; -AILSOUNDINFO ailInfo; - - pChunk=(CHAR8 *)pSampleList[uiSample].pData; - if(!AIL_WAV_info((void *)pChunk, &ailInfo)) - return(FALSE); - - pSampleList[uiSample].uiSpeed=ailInfo.rate; - pSampleList[uiSample].fStereo=(BOOLEAN)(ailInfo.channels==2); - pSampleList[uiSample].ubBits=(UINT8)ailInfo.bits; - - pSampleList[uiSample].pSoundStart=(PTR)ailInfo.data_ptr; - pSampleList[uiSample].uiSoundSize=ailInfo.data_len; - - pSampleList[uiSample].uiAilWaveFormat=ailInfo.format; - pSampleList[uiSample].uiADPCMBlockSize=ailInfo.block_size; - - return(TRUE); -} - //******************************************************************************* // SoundFreeSampleIndex // @@ -1792,7 +1317,7 @@ UINT32 SoundFreeSampleIndex(UINT32 uiSample) if(pSampleList[uiSample].pData!=NULL) { guiSoundMemoryUsed-=pSampleList[uiSample].uiSize; - AIL_mem_free_lock(pSampleList[uiSample].pData); + MemFree(pSampleList[uiSample].pData); } memset(&pSampleList[uiSample], 0, sizeof(SAMPLETAG)); @@ -1834,94 +1359,26 @@ UINT32 uiCount; //******************************************************************************* BOOLEAN SoundInitHardware(void) { -UINT32 uiCount; -CHAR8 cDriverName[128]; + SoundLog("Init hardware..."); - // Try to start up the Miles Sound System - if(!AIL_startup()) + // Try to start up the FMOD Sound System + FSOUND_SetOutput(FSOUND_OUTPUT_DSOUND); + FSOUND_SetBufferSize(AUDIO_BUFFER_LEN); + if( !FSOUND_Init(44100, SOUND_MAX_CHANNELS, FSOUND_INIT_GLOBALFOCUS|FSOUND_INIT_DONTLATENCYADJUST) ) + { + SoundLog((CHAR8 *)String(" ERROR in SoundInitHardware(): %s", FMOD_ErrorString(FSOUND_GetError()))); return(FALSE); + } - // Initialize the driver handle - hSoundDriver = NULL; + SoundLog(" FMOD started"); + SoundLog((CHAR8 *)String(" Using DirectSound driver: %s", FSOUND_GetDriverName(FSOUND_GetDriver()))); + SoundLog((CHAR8 *)String(" Mixing rate: %d", FSOUND_GetOutputRate())); - // Set up preferences, to try to use DirectSound and to set the - // maximum number of handles that we are allowed to allocate. Note - // that this is not the number we may have playing at one time-- - // that number is set by SOUND_MAX_CHANNELS - AIL_set_preference(DIG_MIXER_CHANNELS, SOUND_MAX_CHANNELS); + // Driver is ready + hSoundDriver = TRUE; + fDirectSound = TRUE; - - fDirectSound=TRUE; - - AIL_set_preference(DIG_USE_WAVEOUT,NO); - // startup with DirectSound - if (hSoundDriver == NULL) - hSoundDriver = SoundInitDriver(44100, 16, 2); - if (hSoundDriver == NULL) - hSoundDriver = SoundInitDriver(44100, 8, 2); - if (hSoundDriver == NULL) - hSoundDriver = SoundInitDriver(22050, 8, 2); - if (hSoundDriver == NULL) - hSoundDriver = SoundInitDriver(11025, 8, 1); - - - if(hSoundDriver) - { - // Detect if the driver is emulated or not - SoundGetDriverName(hSoundDriver, cDriverName); - _strlwr(cDriverName); - // If it is, we don't want to use it, since the extra - // code layer can slow us down by up to 40% under NT - if(strstr(cDriverName, "emulated")) - { - AIL_waveOutClose(hSoundDriver); - hSoundDriver=NULL; - } - } - - // nothing in DirectSound worked, so try waveOut - if (hSoundDriver == NULL) - { - fDirectSound=FALSE; - AIL_set_preference(DIG_USE_WAVEOUT,YES); - } - - if (hSoundDriver == NULL) - hSoundDriver = SoundInitDriver(44100, 16, 2); - if (hSoundDriver == NULL) - hSoundDriver = SoundInitDriver(44100, 8, 2); - if (hSoundDriver == NULL) - hSoundDriver = SoundInitDriver(22050, 8, 2); - if (hSoundDriver == NULL) - hSoundDriver = SoundInitDriver(11025, 8, 1); - - if (hSoundDriver!=NULL) - { - for(uiCount = 0; uiCount < SOUND_MAX_CHANNELS; uiCount++) - memset(&pSoundList[uiCount], 0, sizeof(SOUNDTAG)); - - return(TRUE); - } - - return(FALSE); - -/* - // midi startup - if (hSoundDriver!=NULL) - { - soundMDI = MIDI_init_driver(); - if (soundMDI==NULL) - { - _RPT1(_CRT_WARN, "MIDI: %s", AIL_last_error()); - } - else - { - soundSEQ = MIDI_load_sequence(soundMDI, "SOUNDS\\DEMO.XMI"); - if (soundSEQ==NULL) - _RPT1(_CRT_WARN, "MIDI: %s", AIL_last_error()); - } - } -*/ + return(hSoundDriver); } //******************************************************************************* @@ -1935,63 +1392,12 @@ CHAR8 cDriverName[128]; BOOLEAN SoundShutdownHardware(void) { if(fSoundSystemInit) - AIL_shutdown(); - + FSOUND_Close(); + + SoundLog(" FMOD closed"); return(TRUE); } -//******************************************************************************* -// SoundInitDriver -// -// Tries to initialize the sound driver using the specified settings. -// -// Returns: Pointer to the driver if successful, NULL otherwise. -// -//******************************************************************************* -static HDIGDRIVER SoundInitDriver(UINT32 uiRate, UINT16 uiBits, UINT16 uiChans) -{ -static PCMWAVEFORMAT sPCMWF; -HDIGDRIVER DIG; -CHAR8 cBuf[128]; - - memset(&sPCMWF, 0, sizeof(PCMWAVEFORMAT)); - sPCMWF.wf.wFormatTag = WAVE_FORMAT_PCM; - sPCMWF.wf.nChannels = uiChans; - sPCMWF.wf.nSamplesPerSec = uiRate; - sPCMWF.wf.nAvgBytesPerSec = uiRate * (uiBits / 8) * uiChans; - sPCMWF.wf.nBlockAlign = (uiBits / 8) * uiChans; - sPCMWF.wBitsPerSample = uiBits; - - if(AIL_waveOutOpen(&DIG, NULL, 0, (LPWAVEFORMAT) &sPCMWF)) - return(NULL); - - memset(cBuf, 0, 128); - AIL_digital_configuration(DIG,0,0,cBuf); - FastDebugMsg(String("Sound Init: %dKHz, %d uiBits, %s %s\n", uiRate, uiBits, (uiChans==1)? "Mono": "Stereo", cBuf)); - - return(DIG); -} - -//******************************************************************************* -// SoundGetDriverName -// -// Returns the name of the AIL device. -// -// Returns: TRUE or FALSE if the string was filled. -// -//******************************************************************************* -BOOLEAN SoundGetDriverName(HDIGDRIVER DIG, CHAR8 *cBuf) -{ - if(DIG) - { - cBuf[0]='\0'; - AIL_digital_configuration(DIG, NULL, NULL, cBuf); - return(TRUE); - } - else - return(FALSE); -} - //******************************************************************************* // SoundGetFreeChannel // @@ -2011,7 +1417,7 @@ UINT32 uiCount; SoundStopIndex(uiCount); } - if((pSoundList[uiCount].hMSS==NULL) && (pSoundList[uiCount].hMSSStream==NULL) && (pSoundList[uiCount].hM3D==NULL)) + if( pSoundList[uiCount].hStream==NULL ) return(uiCount); } @@ -2030,86 +1436,26 @@ UINT32 uiCount; //******************************************************************************* UINT32 SoundStartSample(UINT32 uiSample, UINT32 uiChannel, SOUNDPARMS *pParms) { - DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"SoundStartSample"); +UINT32 uiSoundID; - UINT32 uiSoundID; -CHAR8 AILString[200]; - - DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"SoundStartSample: check sound init"); - if(!fSoundSystemInit) + if(!fSoundSystemInit) return(SOUND_ERROR); - DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"SoundStartSample: check sound driver"); - if((pSoundList[uiChannel].hMSS = AIL_allocate_sample_handle(hSoundDriver))==NULL) + // Setting up stream buffer + FSOUND_Stream_SetBufferSize(STREAM_BUFFER_LEN); + + // Creating stream + pSoundList[uiChannel].hStream=FSOUND_Stream_Open((char *)pSampleList[uiSample].pData, FSOUND_LOADMEMORY|FSOUND_LOOP_NORMAL|FSOUND_2D, 0, pSampleList[uiSample].uiSize); + if(pSoundList[uiChannel].hStream==NULL) { - sprintf(AILString, "Sample Error: %s", AIL_last_error()); - FastDebugMsg(AILString); + SoundLog((CHAR8 *)String(" ERROR in SoundStartSample(): %s", FMOD_ErrorString(FSOUND_GetError()) )); return(SOUND_ERROR); } - DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"SoundStartSample: AL_init_sample "); - AIL_init_sample(pSoundList[uiChannel].hMSS); - - DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"SoundStartSample: check sample"); - if(!AIL_set_named_sample_file(pSoundList[uiChannel].hMSS, pSampleList[uiSample].pName, pSampleList[uiSample].pData, pSampleList[uiSample].uiSize, 0)) - { - DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"SoundStartSample: sample sound error"); - AIL_release_sample_handle(pSoundList[uiChannel].hMSS); - pSoundList[uiChannel].hMSS=NULL; - - sprintf(AILString, "AIL Set Sample Error: %s", AIL_last_error()); - DbgMessage(TOPIC_GAME, DBG_LEVEL_0, AILString); - return(SOUND_ERROR); - } - - DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"SoundStartSample: store playback rate"); - // Store the natural playback rate before we modify it below - pSampleList[uiSample].uiSpeed=AIL_sample_playback_rate(pSoundList[uiChannel].hMSS); - - DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"SoundStartSample: check if random sample"); - if(pSampleList[uiSample].uiFlags & SAMPLE_RANDOM) - { - DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"SoundStartSample: random sample"); - if((pSampleList[uiSample].uiSpeedMin != SOUND_PARMS_DEFAULT) && (pSampleList[uiSample].uiSpeedMin != SOUND_PARMS_DEFAULT)) - { - DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"SoundStartSample: get random sample"); - - UINT32 uiSpeed = pSampleList[uiSample].uiSpeedMin+Random(pSampleList[uiSample].uiSpeedMax-pSampleList[uiSample].uiSpeedMin); - - DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"SoundStartSample: set playback rate"); - AIL_set_sample_playback_rate(pSoundList[uiChannel].hMSS, uiSpeed); - } - } - else - { - DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"SoundStartSample: not random sample"); - if((pParms!=NULL) && (pParms->uiSpeed!=SOUND_PARMS_DEFAULT)) - { - DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"SoundStartSample: check speed "); - Assert((pParms->uiSpeed > 0) && (pParms->uiSpeed <= 60000)); - AIL_set_sample_playback_rate(pSoundList[uiChannel].hMSS, pParms->uiSpeed); - } - } - - DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"SoundStartSample: check pitch bend"); - if((pParms!=NULL) && (pParms->uiPitchBend!=SOUND_PARMS_DEFAULT)) - { - UINT32 uiRate = AIL_sample_playback_rate(pSoundList[uiChannel].hMSS); - UINT32 uiBend = uiRate * pParms->uiPitchBend/100; - AIL_set_sample_playback_rate(pSoundList[uiChannel].hMSS, uiRate + (Random(uiBend*2)-uiBend)); - } - - DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"SoundStartSample: check volume"); - if((pParms!=NULL) && (pParms->uiVolume!=SOUND_PARMS_DEFAULT)) - AIL_set_sample_volume(pSoundList[uiChannel].hMSS, pParms->uiVolume); - else - AIL_set_sample_volume(pSoundList[uiChannel].hMSS, guiSoundDefaultVolume); - - DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"SoundStartSample: check looping"); + // Setup sample params + // Loop if((pParms!=NULL) && (pParms->uiLoop!=SOUND_PARMS_DEFAULT)) { - AIL_set_sample_loop_count(pSoundList[uiChannel].hMSS, pParms->uiLoop); - // If looping infinately, lock the sample so it can't be unloaded // and mark it as a looping sound if(pParms->uiLoop==0) @@ -2117,19 +1463,43 @@ CHAR8 AILString[200]; pSampleList[uiSample].uiFlags|=SAMPLE_LOCKED; pSoundList[uiChannel].fLooping=TRUE; } + else + FSOUND_Stream_SetLoopCount(pSoundList[uiChannel].hStream, pParms->uiLoop-1); } - DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"SoundStartSample: check pan"); - if((pParms!=NULL) && (pParms->uiPan!=SOUND_PARMS_DEFAULT)) - AIL_set_sample_pan(pSoundList[uiChannel].hMSS, pParms->uiPan); + // Starting stream in pause + pSoundList[uiChannel].uiFMODChannel = FSOUND_Stream_PlayEx(uiChannel, pSoundList[uiChannel].hStream, NULL, TRUE); + if(pSoundList[uiChannel].uiFMODChannel==-1) + { + FSOUND_Stream_Close(pSoundList[uiChannel].hStream); + SoundLog((CHAR8 *)String(" ERROR in SoundStartSample(): %s", FMOD_ErrorString(FSOUND_GetError()) )); + return(SOUND_ERROR); + } - DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"SoundStartSample: check priority"); + // Speed and pitchbend don't use + + // Volume + if((pParms!=NULL) && (pParms->uiVolume!=SOUND_PARMS_DEFAULT)) + FSOUND_SetVolume(pSoundList[uiChannel].uiFMODChannel, pParms->uiVolume * 2); + else + FSOUND_SetVolume(pSoundList[uiChannel].uiFMODChannel, guiSoundDefaultVolume); + + // Panning + if((pParms!=NULL) && (pParms->uiPan!=SOUND_PARMS_DEFAULT)) + FSOUND_SetPan(pSoundList[uiChannel].uiFMODChannel, pParms->uiPan); + else + FSOUND_SetPan(pSoundList[uiChannel].uiFMODChannel, 128); + + // Start sound! + FSOUND_SetPaused(pSoundList[uiChannel].uiFMODChannel, FALSE); + + // Priority if((pParms!=NULL) && (pParms->uiPriority!=SOUND_PARMS_DEFAULT)) pSoundList[uiChannel].uiPriority=pParms->uiPriority; else pSoundList[uiChannel].uiPriority=PRIORITY_MAX; - DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"SoundStartSample: check EOS callback"); + // Callback at end of playback if((pParms!=NULL) && ((UINT32)pParms->EOSCallback!=SOUND_PARMS_DEFAULT)) { pSoundList[uiChannel].EOSCallback=pParms->EOSCallback; @@ -2141,7 +1511,7 @@ CHAR8 AILString[200]; pSoundList[uiChannel].pCallbackData=NULL; } - DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"SoundStartSample: set up channel in sound list"); + // Other stuff... uiSoundID=SoundGetUniqueID(); pSoundList[uiChannel].uiSoundID=uiSoundID; pSoundList[uiChannel].uiSample=uiSample; @@ -2149,11 +1519,7 @@ CHAR8 AILString[200]; pSoundList[uiChannel].uiFadeVolume = SoundGetVolumeIndex(uiChannel); pSampleList[uiSample].uiCacheHits++; - - DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"SoundStartSample: start sample"); - AIL_start_sample(pSoundList[uiChannel].hMSS); - DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"SoundStartSample: done"); return(uiSoundID); } @@ -2169,73 +1535,65 @@ CHAR8 AILString[200]; //******************************************************************************* UINT32 SoundStartStream(STR pFilename, UINT32 uiChannel, SOUNDPARMS *pParms) { -UINT32 uiSoundID, uiSpeed; -CHAR8 AILString[200]; +UINT32 uiSoundID; if(!fSoundSystemInit) return(SOUND_ERROR); - // Snap: First see if the file is in the custom Data catalogue: - std::string filePath; - if ( gCustomDataCat.FindFile(pFilename) ) { - filePath = gCustomDataCat.GetRootDir() + '\\'; - } - filePath += pFilename; - // Bad cast! pFilename should have been const. Oh well... - pFilename = const_cast( filePath.c_str() ); - // Now pFilename points either to the original file name, - // or to the full file path in the custom Data directory. - // Except for this substitution, the rest of the function is unchanged. + // Setting up stream buffer + FSOUND_Stream_SetBufferSize(STREAM_BUFFER_LEN); - if((pSoundList[uiChannel].hMSSStream=AIL_open_stream(hSoundDriver, pFilename, SOUND_DEFAULT_STREAM))==NULL) + // Creating stream + pSoundList[uiChannel].hStream=FSOUND_Stream_Open(pFilename, FSOUND_LOOP_NORMAL|FSOUND_2D, 0, 0); + if(pSoundList[uiChannel].hStream==NULL) { - SoundCleanCache(); - pSoundList[uiChannel].hMSSStream=AIL_open_stream(hSoundDriver, pFilename, SOUND_DEFAULT_STREAM); - } - - if(pSoundList[uiChannel].hMSSStream==NULL) - { - sprintf(AILString, "Stream Error: %s", AIL_last_error()); - DbgMessage(TOPIC_GAME, DBG_LEVEL_0, AILString); + SoundLog((CHAR8 *)String(" ERROR in SoundStartStream(): %s ('%s')", FMOD_ErrorString(FSOUND_GetError()), pFilename)); return(SOUND_ERROR); } - if((pParms!=NULL) && (pParms->uiSpeed!=SOUND_PARMS_DEFAULT)) - uiSpeed=pParms->uiSpeed; - else - uiSpeed=AIL_stream_playback_rate(pSoundList[uiChannel].hMSSStream); - - if((pParms!=NULL) && (pParms->uiPitchBend!=SOUND_PARMS_DEFAULT)) + // Setup params + // Loop + if( (pParms!=NULL) && (pParms->uiLoop!=SOUND_PARMS_DEFAULT ) ) { - UINT32 uiBend = uiSpeed * pParms->uiPitchBend/100; - uiSpeed+=(Random(uiBend*2)-uiBend); - } + if(pParms->uiLoop>0) + FSOUND_Stream_SetLoopCount(pSoundList[uiChannel].hStream, pParms->uiLoop-1); + } - AIL_set_stream_playback_rate(pSoundList[uiChannel].hMSSStream, uiSpeed); + // Starting stream in pause + pSoundList[uiChannel].uiFMODChannel = FSOUND_Stream_PlayEx(uiChannel, pSoundList[uiChannel].hStream, NULL, TRUE); + if(pSoundList[uiChannel].uiFMODChannel==-1) + { + FSOUND_Stream_Close(pSoundList[uiChannel].hStream); + SoundLog((CHAR8 *)String(" ERROR in SoundStartStream(): %s ('%s')", FMOD_ErrorString(FSOUND_GetError()), pFilename)); + return(SOUND_ERROR); + } + // Speed and pitchbend don't use + + // Volume if((pParms!=NULL) && (pParms->uiVolume!=SOUND_PARMS_DEFAULT)) - AIL_set_stream_volume(pSoundList[uiChannel].hMSSStream, pParms->uiVolume); + FSOUND_SetVolume(pSoundList[uiChannel].uiFMODChannel, pParms->uiVolume * 2); else - AIL_set_stream_volume(pSoundList[uiChannel].hMSSStream, guiSoundDefaultVolume); - - if( pParms!=NULL ) - { - if (pParms->uiLoop!=SOUND_PARMS_DEFAULT ) - AIL_set_stream_loop_count(pSoundList[uiChannel].hMSSStream, pParms->uiLoop); - } + FSOUND_SetVolume(pSoundList[uiChannel].uiFMODChannel, guiSoundDefaultVolume); + // Panning if((pParms!=NULL) && (pParms->uiPan!=SOUND_PARMS_DEFAULT)) - AIL_set_stream_pan(pSoundList[uiChannel].hMSSStream, pParms->uiPan); + FSOUND_SetPan(pSoundList[uiChannel].uiFMODChannel, pParms->uiPan); - AIL_start_stream(pSoundList[uiChannel].hMSSStream); + // Start sound! + FSOUND_SetPaused(pSoundList[uiChannel].uiFMODChannel, FALSE); + // Get ID uiSoundID=SoundGetUniqueID(); pSoundList[uiChannel].uiSoundID=uiSoundID; + + // Priority if(pParms) pSoundList[uiChannel].uiPriority=pParms->uiPriority; else pSoundList[uiChannel].uiPriority=SOUND_PARMS_DEFAULT; + // Callback at end of playback if((pParms!=NULL) && ((UINT32)pParms->EOSCallback!=SOUND_PARMS_DEFAULT)) { pSoundList[uiChannel].EOSCallback=pParms->EOSCallback; @@ -2247,10 +1605,57 @@ CHAR8 AILString[200]; pSoundList[uiChannel].pCallbackData=NULL; } + // Other stuff pSoundList[uiChannel].uiTimeStamp=GetTickCount(); pSoundList[uiChannel].uiFadeVolume = SoundGetVolumeIndex(uiChannel); + pSoundList[uiChannel].uiSample = -1; // it's streaming directly from file !!!! - return(uiSoundID); + return(uiSoundID); +} + +// ------------------------ +// Callbacks implementation +// ======================== +static void * F_CALLBACKAPI SoundFileOpen(const CHAR8 *pName) +{ + return((void*)FileOpen((STR)pName, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE)); +} + +static void F_CALLBACKAPI SoundFileClose(void *uiHandle) +{ + FileClose((UINT32)uiHandle); +} + +static INT F_CALLBACKAPI SoundFileRead(void *pBuffer, INT iSize, void *uiHandle) +{ + UINT32 uiActuallyRead; + + FileRead((UINT32)uiHandle, pBuffer, iSize, &uiActuallyRead); + return(uiActuallyRead); +} + +static INT F_CALLBACKAPI SoundFileSeek(void *uiHandle, INT iPos, signed char cMode) +{ + UINT8 uiHow; + + switch(cMode) + { + case SEEK_END: + uiHow = FILE_SEEK_FROM_END; + break; + case SEEK_CUR: + uiHow = FILE_SEEK_FROM_CURRENT; + break; + default: + uiHow = FILE_SEEK_FROM_START; + } + + return(!FileSeek((UINT32)uiHandle, iPos, uiHow)); +} + +static INT F_CALLBACKAPI SoundFileTell(void *uiHandle) +{ + return(FileGetPos((UINT32)uiHandle)); } //******************************************************************************* @@ -2264,7 +1669,7 @@ UINT32 SoundGetUniqueID(void) { static UINT32 uiNextID=0; - if(uiNextID==SOUND_ERROR) + if(uiNextID==NO_SAMPLE) uiNextID++; return(uiNextID++); @@ -2308,88 +1713,39 @@ UINT32 uiFilesize; //******************************************************************************* BOOLEAN SoundStopIndex(UINT32 uiChannel) { -UINT32 uiSample; +UINT32 uiSample; if(fSoundSystemInit) { if(uiChannel!=NO_SAMPLE) { - if(pSoundList[uiChannel].hMSS!=NULL) - { - AIL_stop_sample(pSoundList[uiChannel].hMSS); - AIL_release_sample_handle(pSoundList[uiChannel].hMSS); - pSoundList[uiChannel].hMSS=NULL; - uiSample=pSoundList[uiChannel].uiSample; - - // if this was a random sample, decrease the iteration count - if(pSampleList[uiSample].uiFlags&SAMPLE_RANDOM) - pSampleList[uiSample].uiInstances--; + if(pSoundList[uiChannel].hStream!=NULL) + { + FSOUND_Stream_Stop(pSoundList[uiChannel].hStream); + FSOUND_Stream_Close(pSoundList[uiChannel].hStream); - if(pSoundList[uiChannel].EOSCallback!=NULL) - pSoundList[uiChannel].EOSCallback(pSoundList[uiChannel].pCallbackData); + uiSample=pSoundList[uiChannel].uiSample; - if(pSoundList[uiChannel].fLooping && !SoundSampleIsInUse(uiChannel)) - SoundRemoveSampleFlags(uiSample, SAMPLE_LOCKED); + // if this was a random sample, decrease the iteration count + if ( (uiSample != -1) && (pSampleList[uiSample].uiFlags&SAMPLE_RANDOM) ) + pSampleList[uiSample].uiInstances--; - pSoundList[uiChannel].uiSample=NO_SAMPLE; - } + if(pSoundList[uiChannel].EOSCallback!=NULL) + pSoundList[uiChannel].EOSCallback(pSoundList[uiChannel].pCallbackData); - if(pSoundList[uiChannel].hMSSStream!=NULL) - { - AIL_close_stream(pSoundList[uiChannel].hMSSStream); - pSoundList[uiChannel].hMSSStream=NULL; - if(pSoundList[uiChannel].EOSCallback!=NULL) - pSoundList[uiChannel].EOSCallback(pSoundList[uiChannel].pCallbackData); + if(!pSoundList[uiChannel].fLooping && !SoundSampleIsInUse(uiChannel)) + SoundRemoveSampleFlags(uiSample, SAMPLE_LOCKED); - pSoundList[uiChannel].uiSample=NO_SAMPLE; - } - - if(pSoundList[uiChannel].hM3D!=NULL) - { - AIL_stop_3D_sample(pSoundList[uiChannel].hM3D); - AIL_release_3D_sample_handle(pSoundList[uiChannel].hM3D); - pSoundList[uiChannel].hM3D=NULL; - uiSample=pSoundList[uiChannel].uiSample; - - // if this was a random sample, decrease the iteration count - if(pSampleList[uiSample].uiFlags&SAMPLE_RANDOM) - pSampleList[uiSample].uiInstances--; - - if(pSoundList[uiChannel].EOSCallback!=NULL) - pSoundList[uiChannel].EOSCallback(pSoundList[uiChannel].pCallbackData); - - if(pSoundList[uiChannel].fLooping && !SoundSampleIsInUse(uiChannel)) - SoundRemoveSampleFlags(uiSample, SAMPLE_LOCKED); - - pSoundList[uiChannel].uiSample=NO_SAMPLE; - } - - if( pSoundList[uiChannel].hFile != 0 ) - { - FileClose( pSoundList[uiChannel].hFile ); - pSoundList[uiChannel].hFile = 0; - - pSoundList[uiChannel].uiSample=NO_SAMPLE; - } - - return(TRUE); + memset(&pSoundList[uiChannel], 0, sizeof(SOUNDTAG)); + } + + return(TRUE); } } return(FALSE); } -//******************************************************************************* -// SoundGetDriverHandle -// -// Returns: Pointer to the current sound driver -// -//******************************************************************************* -HDIGDRIVER SoundGetDriverHandle(void) -{ - return(hSoundDriver); -} - // FUNCTIONS TO SET / RESET SAMPLE FLAGS void SoundSetSampleFlags( UINT32 uiSample, UINT32 uiFlags ) { @@ -2431,817 +1787,38 @@ UINT32 uiCount; } +// Lesh modifications +// Sound debug + //***************************************************************************************** -// SoundFileIsPlaying +// SoundLog +// Writes string into log file // -// Returns true or false on whether a certain file is currently being played. This function -// will only work on sounds loaded into the cache, it will NOT work on streamed sounds. +// Returns nothing // -// Returns BOOLEAN - -// -// CHAR8 *pFilename - -// -// Created: 2/24/00 Derek Beland +// Created: 10.12.2005 Lesh //***************************************************************************************** -BOOLEAN SoundFileIsPlaying(CHAR8 *pFilename) +void SoundLog(CHAR8 *strMessage) { -UINT32 uiCount; - - for(uiCount=0; uiCount < SOUND_MAX_CHANNELS; uiCount++) - { - if(SoundIndexIsPlaying(uiCount)) - { - if(stricmp(pSampleList[pSoundList[uiCount].uiSample].pName, pFilename)==0) - return(TRUE); - } - } - - return(FALSE); -} -//***************************************************************************************** -// SoundSampleSetVolumeRange -// -// Sets the minimum and maximum volume for a sample. -// -// Returns nothing. -// -// UINT32 uiSample - Sample handle -// UINT32 uiVolMin - Minimum volume -// UINT32 uiVolMax - Maximum volume -// -// Created: 10/29/97 Andrew Emmons -//***************************************************************************************** -void SoundSampleSetVolumeRange(UINT32 uiSample, UINT32 uiVolMin, UINT32 uiVolMax) -{ - Assert((uiSample >= 0) && (uiSample < SOUND_MAX_CACHED)); - - pSampleList[uiSample].uiVolMin=uiVolMin; - pSampleList[uiSample].uiVolMax=uiVolMax; -} - - -//***************************************************************************************** -// SoundSampleSetPanRange -// -// Sets the left/right pan values for a sample. -// -// Returns nothing. -// -// UINT32 uiSample - Sample handle -// UINT32 uiPanMin - Left setting -// UINT32 uiPanMax - Right setting -// -// Created: 10/29/97 Andrew Emmons -//***************************************************************************************** -void SoundSampleSetPanRange(UINT32 uiSample, UINT32 uiPanMin, UINT32 uiPanMax) -{ - Assert((uiSample >= 0) && (uiSample < SOUND_MAX_CACHED)); - - pSampleList[uiSample].uiPanMin=uiPanMin; - pSampleList[uiSample].uiPanMax=uiPanMax; -} - - - -//***************************************************************************************** -// SoundSetMusic -// -// Marks a sample as being music. Cannot be stopped by anything other than SoundStopMusic. -// -// Returns nothing. -// -// UINT32 uiSound - Sound instance to stop -// -// Created: 3/16/00 Derek Beland -//***************************************************************************************** -void SoundSetMusic(UINT32 uiSoundID) -{ -UINT32 uiSound=SoundGetIndexByID(uiSoundID); - - if(uiSound!=NO_SAMPLE) - pSoundList[uiSound].fMusic=TRUE; -} - - -//***************************************************************************************** -// SoundStopMusic -// -// Stops any sound instance with the music flag. -// -// Returns nothing. -// -// Created: 3/16/00 Derek Beland -//***************************************************************************************** -BOOLEAN SoundStopMusic(void) -{ -UINT32 uiCount; -BOOLEAN fStopped=FALSE; - - if(fSoundSystemInit) - { - for(uiCount=0; uiCount < SOUND_MAX_CHANNELS; uiCount++) - { - if((pSoundList[uiCount].hMSS!=NULL) || (pSoundList[uiCount].hMSSStream!=NULL) || (pSoundList[uiCount].hM3D!=NULL)) - { - if(pSoundList[uiCount].fMusic) - { - SoundStop(pSoundList[uiCount].uiSoundID); - fStopped=TRUE; - } - } - } - } - - return(fStopped); -} - -//***************************************************************************************** -// -// -// -// -// New 3D Sound Code -// -// -// -// -//***************************************************************************************** - - - - - - -//***************************************************************************************** -// Sound3DSetProvider -// -// Sets the name of the 3D provider to initialize with. -// -// Returns nothing. -// -// CHAR8 *pProviderName - Pointer to provider name -// -// Created: 8/17/99 Derek Beland -//***************************************************************************************** -void Sound3DSetProvider(CHAR8 *pProviderName) -{ - Assert(pProviderName); - - if(pProviderName) - { - gpProviderName = (CHAR8 *)MemAlloc(strlen(pProviderName)+1); - strcpy(gpProviderName, pProviderName); - } -} - - -//***************************************************************************************** -// Sound3DInitProvider -// -// Attempt -// -// Returns BOOLEAN - -// -// CHAR8 *pProviderName - -// -// Created: 8/17/99 Derek Beland -//***************************************************************************************** -BOOLEAN Sound3DInitProvider(CHAR8 *pProviderName) -{ -HPROENUM hEnum=HPROENUM_FIRST; -HPROVIDER hProvider=0; -BOOLEAN fDone=FALSE; -CHAR8 *pName; -INT32 iResult; - - // 3D sound providers depend on the 2D sound system being initialized first - if(!fSoundSystemInit || !pProviderName) - return(FALSE); - - // We're already booted up - if(gh3DProvider) - return(TRUE); - - while(!fDone) - { - if(!AIL_enumerate_3D_providers(&hEnum, &hProvider, &pName)) - fDone=TRUE; - else if(hProvider) - { - if(strcmp(pProviderName, pName)==0) - { - fDone=TRUE; - if(AIL_open_3D_provider(hProvider)==M3D_NOERR) - { - gh3DProvider = hProvider; - - // Create a "listener" which represents our position in space - gh3DListener = AIL_open_3D_listener(gh3DProvider); - if(!gh3DListener) - { - AIL_close_3D_provider(gh3DProvider); - return(FALSE); - } - Sound3DSetListener(0.0f, 0.0f, 0.0f); - - AIL_3D_provider_attribute(gh3DProvider, "EAX environment selection", &iResult); - if(iResult!=(-1)) - gfUsingEAX = TRUE; - - return(TRUE); - } - - } - } - } - - // We didn't find a provider with a matching name that would boot up - return(FALSE); -} - - -//***************************************************************************************** -// Sound3DShutdownProvider -// -// Shuts down and deallocates the 3D sound system -// -// Returns nothing. -// -// Created: 8/17/99 Derek Beland -//***************************************************************************************** -void Sound3DShutdownProvider(void) -{ - Sound3DStopAll(); - - if(gh3DListener) - { - AIL_close_3D_listener(gh3DListener); - gh3DListener=0; - } - - if(gh3DProvider) - { - AIL_close_3D_provider(gh3DProvider); - gh3DProvider=0; - } -} - - -//***************************************************************************************** -// Sound3DSetPosition -// -// Sets the 3-space position of a sound sample. -// -// Returns nothing. -// -// UINT32 uiSample - ID of sample -// FLOAT flX - X coordinate -// FLOAT flY - Y coordinate -// FLOAT flZ - Z coordinate -// -// Created: 8/17/99 Derek Beland -//***************************************************************************************** -void Sound3DSetPosition(UINT32 uiSample, FLOAT flX, FLOAT flY, FLOAT flZ) -{ -UINT32 uiChannel; - - if(fSoundSystemInit && gh3DProvider) - { - if((uiChannel=SoundGetIndexByID(uiSample))!=NO_SAMPLE) - { - if(pSoundList[uiChannel].hM3D!=NULL) - { - AIL_set_3D_position(pSoundList[uiChannel].hM3D, flX, flY, flZ); - } - } + if ((SndDebug = fopen(SndDebugFileName, "a+t")) != NULL) + { + fprintf(SndDebug, "%s\n", strMessage); + fclose(SndDebug); } } //***************************************************************************************** -// Sound3DSetVelocity +// InitLogging +// Creates empty log file // -// Sets the velocity of a sample. This is important for calculation of doppler effect (pitch -// shifting, think of a train whistle as it passes by you). +// Returns nothing // -// Returns nothing. -// -// UINT32 uiSample - ID of sample -// FLOAT flX - X coordinate -// FLOAT flY - Y coordinate -// FLOAT flZ - Z coordinate -// -// Created: 8/17/99 Derek Beland +// Created: 10.12.2005 Lesh //***************************************************************************************** -void Sound3DSetVelocity(UINT32 uiSample, FLOAT flX, FLOAT flY, FLOAT flZ) +void InitLogging() { -UINT32 uiChannel; - - if(fSoundSystemInit && gh3DProvider) - { - if((uiChannel=SoundGetIndexByID(uiSample))!=NO_SAMPLE) - { - if(pSoundList[uiChannel].hM3D!=NULL) - { - } - } + if ((SndDebug = fopen(SndDebugFileName, "wt")) != NULL) + { + fclose(SndDebug); } -} - - -//***************************************************************************************** -// Sound3DSetListener -// -// Sets the listener location. This should be set to the current camera location. -// -// Returns nothing. -// -// FLOAT flX - X coordinate -// FLOAT flY - Y coordinate -// FLOAT flZ - Z coordinate -// -// Created: 8/17/99 Derek Beland -//***************************************************************************************** -void Sound3DSetListener(FLOAT flX, FLOAT flY, FLOAT flZ) -{ - if(fSoundSystemInit && gh3DListener) - AIL_set_3D_position(gh3DListener, flX, flY, flZ); -} - - -//***************************************************************************************** -// Sound3DSetFacing -// -// Sets the orientation of the listener. The inputs are two vectors that are *always* at -// right angles to each other. The first is the facing vector, and the second is the up -// vector, which points out of the top of the listeners head. -// -// Returns nothing. -// -// FLOAT flXFace - X coordinate facing -// FLOAT flYFace - Y coordinate facing -// FLOAT flZFace - Z coordinate facing -// FLOAT flXUp - X coordinate up -// FLOAT flYUp - Y coordinate up -// FLOAT flZUp - Z coordinate up -// -// Created: 8/17/99 Derek Beland -//***************************************************************************************** -void Sound3DSetFacing(FLOAT flXFace, FLOAT flYFace, FLOAT flZFace, FLOAT flXUp, FLOAT flYUp, FLOAT flZUp) -{ - if(fSoundSystemInit && gh3DListener) - AIL_set_3D_orientation(gh3DListener, flXFace, flYFace, flZFace, flXUp, flYUp, flZUp); -} - -//***************************************************************************************** -// Sound3DSetDirection -// -// Sets the orientation of the listener. The inputs are two vectors that are *always* at -// right angles to each other. The first is the facing vector, and the second is the up -// vector, which points out of the top of the listeners head. -// -// Returns nothing. -// -// FLOAT flXFace - X coordinate facing -// FLOAT flYFace - Y coordinate facing -// FLOAT flZFace - Z coordinate facing -// FLOAT flXUp - X coordinate up -// FLOAT flYUp - Y coordinate up -// FLOAT flZUp - Z coordinate up -// -// Created: 8/17/99 Derek Beland -//***************************************************************************************** -void Sound3DSetDirection(UINT32 uiSample, FLOAT flXFace, FLOAT flYFace, FLOAT flZFace, FLOAT flXUp, FLOAT flYUp, FLOAT flZUp) -{ -UINT32 uiChannel; - - if(fSoundSystemInit && gh3DProvider) - { - if((uiChannel=SoundGetIndexByID(uiSample))!=NO_SAMPLE) - { - if(pSoundList[uiChannel].hM3D!=NULL) - { - AIL_set_3D_orientation(pSoundList[uiChannel].hM3D, flXFace, flYFace, flZFace, flXUp, flYUp, flZUp); - } - } - } -} - - -//***************************************************************************************** -// Sound3DSetFalloff -// -// Sets the falloff of the sound which determines the maximum radius at which the sample -// produces any sound, and the minimum distance before the sound volume begins to fall off -// towards zero. -// -// Returns nothing. -// -// UINT32 uiSample - Sample index -// FLOAT flMax - Point at which the sound volume is zero -// FLOAT flMin - Point at which the sound volume begins to fall off -// -// Created: 8/17/99 Derek Beland -//***************************************************************************************** -void Sound3DSetFalloff(UINT32 uiSample, FLOAT flMax, FLOAT flMin) -{ -UINT32 uiChannel; -// max = far -// min = near - - if(fSoundSystemInit && gh3DProvider) - { - if((uiChannel=SoundGetIndexByID(uiSample))!=NO_SAMPLE) - { - if(pSoundList[uiChannel].hM3D!=NULL) - { - AIL_set_3D_sample_distances(pSoundList[uiChannel].hM3D, flMax, flMin); - } - } - } -} - - -//***************************************************************************************** -// Sound3DActiveSounds -// -// Returns the number of active sounds. -// -// Returns INT32 - Number of 3D sounds playing -// -// Created: 8/17/99 Derek Beland -//***************************************************************************************** -INT32 Sound3DActiveSounds(void) -{ - return((INT32)AIL_active_3D_sample_count(gh3DProvider)); -} - - -//***************************************************************************************** -// Sound3DSetEnvironment -// -// Sets the current environment type for the listener. This determines which atmospheric -// effects are applied to the 3D sounds. Eg. Caves, underwater, etc. -// -// Returns nothing. -// -// INT32 iEnvironment - Index of environment type -// -// Created: 8/17/99 Derek Beland -//***************************************************************************************** -void Sound3DSetEnvironment(INT32 iEnvironment) -{ - if(fSoundSystemInit && gh3DProvider) - { - } -} - - -//***************************************************************************************** -// Sound3DPlay -// -// Starts a 3D sample playing. -// -// Returns UINT32 - Sound index -// -// STR pFilename - Pointer to filename of sound -// SOUNDPARMS *pParms - Parameter struct (or NULL for defaults) -// -// Created: 8/17/99 Derek Beland -//***************************************************************************************** -UINT32 Sound3DPlay(STR pFilename, SOUND3DPARMS *pParms) -{ - UINT32 uiSample, uiChannel; - - if(fSoundSystemInit && gh3DProvider) - { - if((uiSample=SoundLoadSample(pFilename))!=NO_SAMPLE) - { - if((uiChannel=SoundGetFreeChannel())!=SOUND_ERROR) - { - return(Sound3DStartSample(uiSample, uiChannel, pParms)); - } - } - else - { - FastDebugMsg(String("Sound3DPlay: ERROR: Failed loading sample %s\n", pFilename ) ); - } - } - - return(SOUND_ERROR); -} - -//******************************************************************************* -// Sound3DStartSample -// -// Starts up a sample on the specified channel. Override parameters are passed -// in through the structure pointer pParms. Any entry with a value of 0xffffffff -// will be filled in by the system. -// -// Returns: Unique sound ID if successful, SOUND_ERROR if not. -// -//******************************************************************************* -UINT32 Sound3DStartSample(UINT32 uiSample, UINT32 uiChannel, SOUND3DPARMS *pParms) -{ -UINT32 uiSoundID; -CHAR8 AILString[200]; - - if(!fSoundSystemInit || !gh3DProvider) - return(SOUND_ERROR); - - // Stereo samples have no purpose in 3D, nor MP3 files - if(pSampleList[uiSample].fStereo || strstr(pSampleList[uiSample].pName, ".MP3")) - return(SOUND_ERROR); - - if((pSoundList[uiChannel].hM3D = AIL_allocate_3D_sample_handle(gh3DProvider))==NULL) - { - sprintf(AILString, "AIL3D Error: %s", AIL_last_error()); - DbgMessage(TOPIC_GAME, DBG_LEVEL_0, AILString); - return(SOUND_ERROR); - } - - if(!AIL_set_3D_sample_file(pSoundList[uiChannel].hM3D, pSampleList[uiSample].pData)) - { - AIL_release_3D_sample_handle(pSoundList[uiChannel].hM3D); - pSoundList[uiChannel].hM3D=NULL; - - sprintf(AILString, "AIL3D Set Sample Error: %s", AIL_last_error()); - DbgMessage(TOPIC_GAME, DBG_LEVEL_0, AILString); - return(SOUND_ERROR); - } - - // Store the natural playback rate before we modify it below - pSampleList[uiSample].uiSpeed=AIL_3D_sample_playback_rate(pSoundList[uiChannel].hM3D); - - if(pSampleList[uiSample].uiFlags & SAMPLE_RANDOM) - { - if((pSampleList[uiSample].uiSpeedMin != SOUND_PARMS_DEFAULT) && (pSampleList[uiSample].uiSpeedMax != SOUND_PARMS_DEFAULT)) - { - UINT32 uiSpeed = pSampleList[uiSample].uiSpeedMin+Random(pSampleList[uiSample].uiSpeedMax-pSampleList[uiSample].uiSpeedMin); - - AIL_set_3D_sample_playback_rate(pSoundList[uiChannel].hM3D, uiSpeed); - } - } - else - { - if((pParms!=NULL) && (pParms->uiSpeed!=SOUND_PARMS_DEFAULT)) - AIL_set_3D_sample_playback_rate(pSoundList[uiChannel].hM3D, pParms->uiSpeed); - } - - if((pParms!=NULL) && (pParms->uiPitchBend!=SOUND_PARMS_DEFAULT)) - { - UINT32 uiRate = AIL_3D_sample_playback_rate(pSoundList[uiChannel].hM3D); - UINT32 uiBend = uiRate * pParms->uiPitchBend/100; - AIL_set_3D_sample_playback_rate(pSoundList[uiChannel].hM3D, uiRate + (Random(uiBend*2)-uiBend)); - } - - if((pParms!=NULL) && (pParms->uiVolume!=SOUND_PARMS_DEFAULT)) - AIL_set_3D_sample_volume(pSoundList[uiChannel].hM3D, pParms->uiVolume); - else - AIL_set_3D_sample_volume(pSoundList[uiChannel].hM3D, guiSoundDefaultVolume); - - if((pParms!=NULL) && (pParms->uiLoop!=SOUND_PARMS_DEFAULT)) - { - AIL_set_3D_sample_loop_count(pSoundList[uiChannel].hM3D, pParms->uiLoop); - - // If looping infinately, lock the sample so it can't be unloaded - // and mark it as a looping sound - if(pParms->uiLoop==0) - { - pSampleList[uiSample].uiFlags|=SAMPLE_LOCKED; - pSoundList[uiChannel].fLooping=TRUE; - } - } - - if((pParms!=NULL) && (pParms->uiPriority!=SOUND_PARMS_DEFAULT)) - pSoundList[uiChannel].uiPriority=pParms->uiPriority; - else - pSoundList[uiChannel].uiPriority=PRIORITY_MAX; - - if((pParms!=NULL) && ((UINT32)pParms->EOSCallback!=SOUND_PARMS_DEFAULT)) - { - pSoundList[uiChannel].EOSCallback=pParms->EOSCallback; - pSoundList[uiChannel].pCallbackData=pParms->pCallbackData; - } - else - { - pSoundList[uiChannel].EOSCallback=NULL; - pSoundList[uiChannel].pCallbackData=NULL; - } - - - AIL_set_3D_position(pSoundList[uiChannel].hM3D, pParms->Pos.flX, pParms->Pos.flY, pParms->Pos.flZ); - AIL_set_3D_velocity_vector(pSoundList[uiChannel].hM3D, pParms->Pos.flVelX, pParms->Pos.flVelY, pParms->Pos.flVelZ); - AIL_set_3D_orientation(pSoundList[uiChannel].hM3D, pParms->Pos.flFaceX, pParms->Pos.flFaceY, pParms->Pos.flFaceZ, pParms->Pos.flUpX, pParms->Pos.flUpY, pParms->Pos.flUpZ); -// AIL_set_3D_sample_distances(pSoundList[uiChannel].hM3D, pParms->Pos.flFalloffMax, pParms->Pos.flFalloffMin); - AIL_set_3D_sample_distances(pSoundList[uiChannel].hM3D, 99999999.9f, 99999999.9f); - - uiSoundID=SoundGetUniqueID(); - pSoundList[uiChannel].uiSoundID=uiSoundID; - pSoundList[uiChannel].uiSample=uiSample; - pSoundList[uiChannel].uiTimeStamp=GetTickCount(); - - pSampleList[uiSample].uiCacheHits++; - - AIL_start_3D_sample(pSoundList[uiChannel].hM3D); - - return(uiSoundID); -} - - -//***************************************************************************************** -// Sound3DStopAll -// -// Stops all currently playing 3D samples. -// -// Returns nothing. -// -// Created: 8/17/99 Derek Beland -//***************************************************************************************** -void Sound3DStopAll(void) -{ -UINT32 uiChannel; - - // Stop all currently playing random sounds - for(uiChannel=0; uiChannel < SOUND_MAX_CHANNELS; uiChannel++) - { - if(pSoundList[uiChannel].hM3D!=NULL) - SoundStopIndex(uiChannel); - } -} - -//******************************************************************************* -// Sound3DStartRandom -// -// Starts an instance of a random sample. -// -// Returns: TRUE if a new random sound was created, FALSE if nothing was done. -// -//******************************************************************************* -UINT32 Sound3DStartRandom(UINT32 uiSample, SOUND3DPOS *pPos) -{ -UINT32 uiChannel, uiSoundID; -SOUND3DPARMS sp3DParms; - - if(pPos && ((uiChannel=SoundGetFreeChannel())!=SOUND_ERROR)) - { - memset(&sp3DParms, 0xff, sizeof(SOUND3DPARMS)); - -// sp3DParms.uiSpeed=pSampleList[uiSample].uiSpeedMin+Random(pSampleList[uiSample].uiSpeedMax-pSampleList[uiSample].uiSpeedMin); - sp3DParms.uiLoop=1; - sp3DParms.uiPriority=pSampleList[uiSample].uiPriority; - -// memcpy(&sp3DParms.Pos, pPos, sizeof(SOUND3DPOS)); - - sp3DParms.Pos.flX=pPos->flX; - sp3DParms.Pos.flY=pPos->flY; - sp3DParms.Pos.flZ=pPos->flZ; - - sp3DParms.Pos.flVelX=pPos->flVelX; - sp3DParms.Pos.flVelY=pPos->flVelY; - sp3DParms.Pos.flVelZ=pPos->flVelZ; - - sp3DParms.Pos.flFaceX=pPos->flFaceX; - sp3DParms.Pos.flFaceY=pPos->flFaceY; - sp3DParms.Pos.flFaceZ=pPos->flFaceZ; - - sp3DParms.Pos.flUpX=pPos->flUpX; - sp3DParms.Pos.flUpY=pPos->flUpY; - sp3DParms.Pos.flUpZ=pPos->flUpZ; - - sp3DParms.Pos.flFalloffMax=pPos->flFalloffMax; - sp3DParms.Pos.flFalloffMin=pPos->flFalloffMin; - - sp3DParms.Pos.uiVolume=pPos->uiVolume; - sp3DParms.uiVolume=pPos->uiVolume; - - if((uiSoundID=Sound3DStartSample(uiSample, uiChannel, &sp3DParms))!=SOUND_ERROR) - { - pSampleList[uiSample].uiTimeNext=GetTickCount()+pSampleList[uiSample].uiTimeMin+Random(pSampleList[uiSample].uiTimeMax-pSampleList[uiSample].uiTimeMin); - pSampleList[uiSample].uiInstances++; - return(uiSoundID); - } - } - - return(NO_SAMPLE); -} - - -//***************************************************************************************** -// Sound3DSetRoomType -// -// Sets the environment presets (reverb, chorus, etc) for 3D sounds. Currently only -// has effect for EAX cards. -// -// Returns nothing. -// -// UINT32 uiRoomType - Index of room type (see Soundman.h e_EAXRoomTypes) -// -// Created: 8/23/99 Derek Beland -//***************************************************************************************** -void Sound3DSetRoomType(UINT32 uiRoomType) -{ - if(gh3DProvider && gfUsingEAX && (guiRoomTypeIndex!=uiRoomType)) - { - CHAR8 cName[128]; - - sprintf(cName, "EAX_ENVIRONMENT_%s", pEAXRoomTypes[uiRoomType]); - - AIL_set_3D_provider_preference(gh3DProvider, cName, (void *)(&uiRoomType)); - guiRoomTypeIndex = uiRoomType; - } -} - - -//***************************************************************************************** -// Sound3DChannelsUsed -// -// -// -// Returns UINT32 - -// -// Created: 5/26/00 Derek Beland -//***************************************************************************************** -UINT32 Sound3DChannelsInUse(void) -{ -UINT32 uiChannel, uiUsed=0; - - // Stop all currently playing random sounds - for(uiChannel=0; uiChannel < SOUND_MAX_CHANNELS; uiChannel++) - { - if(pSoundList[uiChannel].hM3D!=NULL) - uiUsed++; - } - - return(uiUsed); -} - - -//***************************************************************************************** -// SoundStreamsInUse -// -// -// -// Returns UINT32 - -// -// Created: 5/26/00 Derek Beland -//***************************************************************************************** -UINT32 SoundStreamsInUse(void) -{ -UINT32 uiChannel, uiUsed=0; - - // Stop all currently playing random sounds - for(uiChannel=0; uiChannel < SOUND_MAX_CHANNELS; uiChannel++) - { - if(pSoundList[uiChannel].hMSSStream!=NULL) - uiUsed++; - } - - return(uiUsed); -} - - -//***************************************************************************************** -// Sound2DChannelsInUse -// -// -// -// Returns UINT32 - -// -// Created: 5/26/00 Derek Beland -//***************************************************************************************** -UINT32 Sound2DChannelsInUse(void) -{ -UINT32 uiChannel, uiUsed=0; - - // Stop all currently playing random sounds - for(uiChannel=0; uiChannel < SOUND_MAX_CHANNELS; uiChannel++) - { - if(pSoundList[uiChannel].hMSS!=NULL) - uiUsed++; - } - - return(uiUsed); -} - -//***************************************************************************************** -// SoundChannelsInUse -// -// -// -// Returns UINT32 - -// -// Created: 5/26/00 Derek Beland -//***************************************************************************************** -UINT32 SoundTotalChannelsInUse(void) -{ -UINT32 uiChannel, uiUsed=0; - - // Stop all currently playing random sounds - for(uiChannel=0; uiChannel < SOUND_MAX_CHANNELS; uiChannel++) - { - if(SoundIndexIsPlaying(uiChannel)) - uiUsed++; - } - - return(uiUsed); -} +} \ No newline at end of file diff --git a/Standard Gaming Platform/soundman.h b/Standard Gaming Platform/soundman.h index 086dbd54..2d1f71f1 100644 --- a/Standard Gaming Platform/soundman.h +++ b/Standard Gaming Platform/soundman.h @@ -2,7 +2,8 @@ #define __SOUNDMAN_ #include "types.h" -#include "mss.h" +#include "fmod.h" +#include "fmod_errors.h" /* #ifdef __cplusplus @@ -10,91 +11,22 @@ extern "C" { #endif */ - // Sample status flags -#define SAMPLE_ALLOCATED 0x00000001 -#define SAMPLE_LOCKED 0x00000002 -#define SAMPLE_RANDOM 0x00000004 +// Sample status flags +#define SAMPLE_ALLOCATED 0x00000001 +#define SAMPLE_LOCKED 0x00000002 +#define SAMPLE_RANDOM 0x00000004 #define SAMPLE_RANDOM_MANUAL 0x00000008 -#define SAMPLE_3D 0x00000010 - // Sound error values (they're all the same) -#define NO_SAMPLE 0xffffffff -#define SOUND_ERROR 0xffffffff +#define NO_SAMPLE 0xffffffff +#define SOUND_ERROR 0xffffffff // Maximum allowable priority value -#define PRIORITY_MAX 0xfffffffe -#define PRIORITY_RANDOM PRIORITY_MAX-1 +#define PRIORITY_MAX 0xfffffffe +#define PRIORITY_RANDOM PRIORITY_MAX-1 -// Structure definition for 3D sound positional information used by -// various other structs and functions -typedef struct { - FLOAT flX, flY, flZ; - FLOAT flVelX, flVelY, flVelZ; - FLOAT flFaceX, flFaceY, flFaceZ; - FLOAT flUpX, flUpY, flUpZ; - FLOAT flFalloffMin, flFalloffMax; - UINT32 uiVolume; - } SOUND3DPOS; -// Struct definition for sample slots in the cache -// Holds the regular sample data, as well as the -// data for the random samples - -typedef struct { - CHAR8 pName[128]; // Path to sample data - UINT32 uiSize; // Size of sample data - UINT32 uiSoundSize; // Playable sound size - UINT32 uiFlags; // Status flags - UINT32 uiSpeed; // Playback frequency - BOOLEAN fStereo; // Stereo/Mono - UINT8 ubBits; // 8/16 bits - PTR pData; // pointer to sample data memory - PTR pSoundStart; // pointer to start of sound data - UINT32 uiCacheHits; - - UINT32 uiTimeNext; // Random sound data - UINT32 uiTimeMin, uiTimeMax; - UINT32 uiSpeedMin, uiSpeedMax; - UINT32 uiVolMin, uiVolMax; - UINT32 uiPanMin, uiPanMax; - UINT32 uiPriority; - UINT32 uiInstances; - UINT32 uiMaxInstances; - - UINT32 uiAilWaveFormat; // AIL wave sample type - UINT32 uiADPCMBlockSize; // Block size for compressed files - - } SAMPLETAG; - -// Structure definition for slots in the sound output -// These are used for both the cached and double-buffered -// streams -typedef struct { - SAMPLETAG *pSample; - UINT32 uiSample; - HSAMPLE hMSS; - HSTREAM hMSSStream; - H3DSAMPLE hM3D; - UINT32 uiFlags; - UINT32 uiSoundID; - UINT32 uiPriority; - void (*pCallback)(UINT8*, UINT32, UINT32, UINT32, void *); - void *pData; - void (*EOSCallback)(void *); - void *pCallbackData; - UINT32 uiTimeStamp; - BOOLEAN fLooping; - HWFILE hFile; - BOOLEAN fMusic; - BOOLEAN fStopAtZero; - UINT32 uiFadeVolume; - UINT32 uiFadeRate; - UINT32 uiFadeTime; - } SOUNDTAG; - -// Structure definition for sound parameters being passed down to -// the sample playing function +// Structure definition for sound parameters being passed down to the sample playing function typedef struct { UINT32 uiSpeed; UINT32 uiPitchBend; // Random pitch bend range +/- @@ -102,27 +34,12 @@ typedef struct { UINT32 uiPan; UINT32 uiLoop; UINT32 uiPriority; - void (*EOSCallback)(void *); - void *pCallbackData; + void (*EOSCallback)(void *); + void *pCallbackData; } SOUNDPARMS; -// Structure definition for 3D sound parameters being passed down to -// the sample playing function -typedef struct { - UINT32 uiSpeed; - UINT32 uiPitchBend; // Random pitch bend range +/- - UINT32 uiVolume; // volume at distance zero - UINT32 uiLoop; - UINT32 uiPriority; - void (*EOSCallback)(void *); - void *pCallbackData; - SOUND3DPOS Pos; // NOT optional, MUST be set - } SOUND3DPARMS; - - -// Structure definition for parameters to the random sample playing -// function +// Structure definition for parameters to the random sample playing function typedef struct { UINT32 uiTimeMin, uiTimeMax; UINT32 uiSpeedMin, uiSpeedMax; @@ -132,128 +49,52 @@ typedef struct { UINT32 uiMaxInstances; } RANDOMPARMS; -// Structure definition for parameters to the random 3D sample playing -// function -typedef struct { - UINT32 uiTimeMin, uiTimeMax; - UINT32 uiSpeedMin, uiSpeedMax; - UINT32 uiVolMin, uiVolMax; - UINT32 uiPriority; - UINT32 uiMaxInstances; - - SOUND3DPOS Pos; // NOT optional, MUST be set - } RANDOM3DPARMS; - - - enum e_EAXRoomTypes - { - EAXROOMTYPE_NONE=0, - EAXROOMTYPE_SMALL_CAVE, - EAXROOMTYPE_MEDIUM_CAVE, - EAXROOMTYPE_LARGE_CAVE, - EAXROOMTYPE_SMALL_ROOM, - EAXROOMTYPE_MEDIUM_ROOM, - EAXROOMTYPE_LARGE_ROOM, - EAXROOMTYPE_OUTDOORS_FLAT, - EAXROOMTYPE_OUTDOORS_CANYON, - EAXROOMTYPE_UNDERWATER, - - EAXROOMTYPE_NUM_TYPES - }; // Global startup/shutdown functions extern BOOLEAN InitializeSoundManager(void); -extern void ShutdownSoundManager(void); +extern void ShutdownSoundManager(void); // Configuration functions extern BOOLEAN SoundSetMemoryLimit(UINT32 uiLimit); extern BOOLEAN SoundSetCacheThreshhold(UINT32 uiThreshold); -extern HDIGDRIVER SoundGetDriverHandle(void); +extern void * SoundGetDriverHandle( void ); // Master volume control functions -extern BOOLEAN SoundSetDigitalVolume(UINT32 uiVolume); -extern UINT32 SoundGetDigitalVolume(UINT32 uiVolume); -extern void SoundSetDefaultVolume(UINT32 uiVolume); -extern UINT32 SoundGetDefaultVolume(void); - +extern void SoundSetDefaultVolume(UINT32 uiVolume); +extern UINT32 SoundGetDefaultVolume(void); // Cache control functions -UINT32 SoundLoadSample(STR pFilename); +//extern UINT32 SoundLoadSample(STR pFilename); +UINT32 SoundLoadSample(STR pFilename); -extern UINT32 SoundFreeSample(STR pFilename); -extern UINT32 SoundLockSample(STR pFilename); -extern UINT32 SoundUnlockSample(STR pFilename); +extern UINT32 SoundFreeSample(STR pFilename); +extern UINT32 SoundLockSample(STR pFilename); +extern UINT32 SoundUnlockSample(STR pFilename); extern BOOLEAN SoundEmptyCache(void); -extern BOOLEAN SoundSampleIsInUse(UINT32 uiSample); // Play/service sample functions -extern UINT32 SoundPlay(STR pFilename, SOUNDPARMS *pParms); -extern UINT32 SoundPlayStreamedFile( STR pFilename, SOUNDPARMS *pParms ); - -extern UINT32 SoundPlayRandom(STR pFilename, RANDOMPARMS *pParms); -extern BOOLEAN SoundRandomShouldPlay(UINT32 uiSample); -extern UINT32 SoundStartRandom(UINT32 uiSample); -extern UINT32 SoundStreamCallback(STR pFilename, SOUNDPARMS *pParms, void (*pCallback)(UINT8 *, UINT32, UINT32, UINT32, void *), void *); +extern UINT32 SoundPlay(STR pFilename, SOUNDPARMS *pParms); +extern UINT32 SoundPlayStreamedFile( STR pFilename, SOUNDPARMS *pParms ); +extern UINT32 SoundPlayRandom(STR pFilename, RANDOMPARMS *pParms); extern BOOLEAN SoundServiceStreams(void); extern BOOLEAN SoundServiceRandom(void); -extern void SoundSampleSetVolumeRange(UINT32 uiSample, UINT32 uiVolMin, UINT32 uiVolMax); -extern void SoundSampleSetPanRange(UINT32 uiSample, UINT32 uiPanMin, UINT32 uiPanMax); // Sound instance manipulation functions -extern void SoundSetMusic(UINT32 uiSound); -extern BOOLEAN SoundStopMusic(void); extern BOOLEAN SoundStopAll(void); extern BOOLEAN SoundStopAllRandom(void); extern BOOLEAN SoundStop(UINT32 uiSoundID); extern BOOLEAN SoundIsPlaying(UINT32 uiSoundID); -extern BOOLEAN SoundFileIsPlaying(CHAR8 *pFilename); -extern BOOLEAN SoundSetFadeVolume(UINT32 uiSoundID, UINT32 uiVolume, UINT32 uiRate, BOOLEAN fStopAtZero); extern BOOLEAN SoundSetVolume(UINT32 uiSoundID, UINT32 uiVolume); extern BOOLEAN SoundSetPan(UINT32 uiSoundID, UINT32 uiPan); -extern BOOLEAN SoundSetFrequency(UINT32 uiSoundID, UINT32 uiFreq); -extern BOOLEAN SoundSetLoop(UINT32 uiSoundID, UINT32 uiLoop); -extern UINT32 SoundGetVolume(UINT32 uiSoundID); -extern UINT32 SoundGetPan(UINT32 uiSoundID); -extern UINT32 SoundGetFrequency(UINT32 uiSoundID); -extern UINT32 SoundGetLoop(UINT32 uiSoundID); -extern UINT32 SoundGetPosition(UINT32 uiSoundID); -extern BOOLEAN SoundGetMilliSecondPosition(UINT32 uiSoundID, UINT32 *puiTotalMilliseconds, UINT32 *puiCurrentMilliseconds); - -// Sound instance group functions -extern BOOLEAN SoundStopGroup(UINT32 uiPriority); -extern BOOLEAN SoundFreeGroup(UINT32 uiPriority); +extern UINT32 SoundGetVolume(UINT32 uiSoundID); +extern UINT32 SoundGetPosition(UINT32 uiSoundID); extern void SoundSetSampleFlags( UINT32 uiSample, UINT32 uiFlags ); extern void SoundRemoveSampleFlags( UINT32 uiSample, UINT32 uiFlags ); extern void SoundEnableSound(BOOLEAN fEnable); - -// New 3D sound priovider -extern void Sound3DSetProvider(CHAR8 *pProviderName); -extern BOOLEAN Sound3DInitProvider(CHAR8 *pProviderName); -extern void Sound3DShutdownProvider(void); - -// 3D sound control -extern void Sound3DSetPosition(UINT32 uiSample, FLOAT flX, FLOAT flY, FLOAT flZ); -extern void Sound3DSetVelocity(UINT32 uiSample, FLOAT flX, FLOAT flY, FLOAT flZ); -extern void Sound3DSetListener(FLOAT flX, FLOAT flY, FLOAT flZ); -extern void Sound3DSetFacing(FLOAT flXFace, FLOAT flYFace, FLOAT flZFace, FLOAT flXUp, FLOAT flYUp, FLOAT flZUp); -extern void Sound3DSetDirection(UINT32 uiSample, FLOAT flXFace, FLOAT flYFace, FLOAT flZFace, FLOAT flXUp, FLOAT flYUp, FLOAT flZUp); -extern void Sound3DSetFalloff(UINT32 uiSample, FLOAT flMax, FLOAT flMin); -extern void Sound3DSetEnvironment(INT32 iEnvironment); -extern UINT32 Sound3DPlay(STR pFilename, SOUND3DPARMS *pParms); -extern UINT32 Sound3DStartSample(UINT32 uiSample, UINT32 uiChannel, SOUND3DPARMS *pParms); -extern void Sound3DStopAll(void); -extern UINT32 Sound3DPlayRandom(STR pFilename, RANDOM3DPARMS *pParms); -extern UINT32 Sound3DStartRandom(UINT32 uiSample, SOUND3DPOS *Pos); -extern void Sound3DSetRoomType(UINT32 uiRoomType); - -// Status query functions -extern UINT32 Sound3DChannelsInUse(void); -extern UINT32 SoundStreamsInUse(void); -extern UINT32 Sound2DChannelsInUse(void); -extern UINT32 SoundTotalChannelsInUse(void); +extern void SoundLog(CHAR8 *strMessage); /* #ifdef __cplusplus diff --git a/Strategic/Auto Resolve.cpp b/Strategic/Auto Resolve.cpp index b5023eb9..e216a19b 100644 --- a/Strategic/Auto Resolve.cpp +++ b/Strategic/Auto Resolve.cpp @@ -3908,7 +3908,7 @@ void AttackTarget( SOLDIERCELL *pAttacker, SOLDIERCELL *pTarget ) if( pAttacker->bWeaponSlot != HANDPOS ) { //switch items memcpy( &tempItem, &pAttacker->pSoldier->inv[ HANDPOS ], sizeof( OBJECTTYPE ) ); - memcpy( &pAttacker->pSoldier->inv[ HANDPOS ], &pAttacker->pSoldier->inv[ pAttacker->bWeaponSlot ], sizeof( OBJECTTYPE ) ); + memcpy( &pAttacker->pSoldier->inv[ HANDPOS ], &pAttacker->pSoldier->inv[ pAttacker->bWeaponSlot ], sizeof( OBJECTTYPE ) ); //CTD iImpact = HTHImpact( pAttacker->pSoldier, pTarget->pSoldier, ubAccuracy, (BOOLEAN)(fKnife | fClaw) ); memcpy( &pAttacker->pSoldier->inv[ pAttacker->bWeaponSlot ], &pAttacker->pSoldier->inv[ HANDPOS ], sizeof( OBJECTTYPE ) ); memcpy( &pAttacker->pSoldier->inv[ HANDPOS ], &tempItem, sizeof( OBJECTTYPE ) ); diff --git a/Strategic/Game Event Hook.cpp b/Strategic/Game Event Hook.cpp index 64d9ed61..0d9e0612 100644 --- a/Strategic/Game Event Hook.cpp +++ b/Strategic/Game Event Hook.cpp @@ -154,7 +154,7 @@ BOOLEAN ExecuteStrategicEvent( STRATEGICEVENT *pEvent ) else { DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"ExecuteStrategicEvent: SetupNewAmbientSound"); - pEvent->uiParam = SetupNewAmbientSound( pEvent->uiParam ); + pEvent->uiParam = SetupNewAmbientSound( pEvent->uiParam ); //bug Nr14 DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"ExecuteStrategicEvent: SetupNewAmbientSound done"); } break; diff --git a/Tactical/Dialogue Control.cpp b/Tactical/Dialogue Control.cpp index 2159ceec..dc2fc0d4 100644 --- a/Tactical/Dialogue Control.cpp +++ b/Tactical/Dialogue Control.cpp @@ -1768,7 +1768,7 @@ INT8 *GetDialogueDataFilename( UINT8 ubCharacterNum, UINT16 usQuoteNum, BOOLEAN #ifdef RUSSIAN if( ubCharacterNum >= FIRST_RPC && ubCharacterNum < GASTON && gMercProfiles[ ubCharacterNum ].ubMiscFlags & PROFILE_MISC_FLAG_RECRUITED ) { - sprintf( zFileName,"SPEECH\\r_%03d_%03d.wav",ubCharacterNum,usQuoteNum ); + sprintf( (char *) zFileName,"SPEECH\\r_%03d_%03d.wav",ubCharacterNum,usQuoteNum ); } else #endif diff --git a/Tactical/Tactical.vcproj b/Tactical/Tactical.vcproj index 8521eb70..86e6e17a 100644 --- a/Tactical/Tactical.vcproj +++ b/Tactical/Tactical.vcproj @@ -5767,10 +5767,6 @@ RelativePath=".\XML.h"> - - diff --git a/TileEngine/Ambient Control.cpp b/TileEngine/Ambient Control.cpp index 8ea7fc2e..a3c048a4 100644 --- a/TileEngine/Ambient Control.cpp +++ b/TileEngine/Ambient Control.cpp @@ -227,6 +227,8 @@ UINT32 SetupNewAmbientSound( UINT32 uiAmbientID ) { RANDOMPARMS rpParms; + //SoundLog((CHAR8 *)String(" SetupNewAmbientSound()1: uiAmbientID: '%d'", uiAmbientID ) ); + memset(&rpParms, 0xff, sizeof(RANDOMPARMS)); rpParms.uiTimeMin = gAmbData[ uiAmbientID ].uiMinTime; @@ -235,7 +237,9 @@ UINT32 SetupNewAmbientSound( UINT32 uiAmbientID ) rpParms.uiVolMax = CalculateSoundEffectsVolume( gAmbData[ uiAmbientID ].uiVol ); rpParms.uiPriority = GROUP_AMBIENT; - return SoundPlayRandom( gAmbData[ uiAmbientID ].zFilename, &rpParms ); + //SoundLog((CHAR8 *)String(" SetupNewAmbientSound()2: gAmbData[ uiAmbientID ].zFilename: '%s', Params: '%s'", gAmbData[ uiAmbientID ].zFilename, &rpParms ) ); + + return SoundPlayRandom( gAmbData[ uiAmbientID ].zFilename, &rpParms ); //bug Nr14 } diff --git a/TileEngine/TileEngine.vcproj b/TileEngine/TileEngine.vcproj index 651a2610..3bf84e5a 100644 --- a/TileEngine/TileEngine.vcproj +++ b/TileEngine/TileEngine.vcproj @@ -3097,10 +3097,6 @@ RelativePath="worldman.h"> - - diff --git a/Utils/Cinematics.cpp b/Utils/Cinematics.cpp index 10283212..73dd89c6 100644 --- a/Utils/Cinematics.cpp +++ b/Utils/Cinematics.cpp @@ -5,6 +5,9 @@ // Stolen from Nemesis by Derek Beland. // Originally by Derek Beland and Bret Rowden. // +// ChangeLog: +// 10.12.2005 Lesh ripped everything that refers to MSS +// 15.12.2005 Lesh enabled sound in video //---------------------------------------------------------------------------------- //#include "LocalCodeAll.h" @@ -23,7 +26,6 @@ #include "FileMan.h" #include "smack.h" #include "ddraw.h" -#include "mss.h" #include "DirectX Common.h" #include "DirectDraw Calls.h" #include "Cinematics.h" @@ -131,9 +133,10 @@ DDSURFACEDESC SurfaceDescription; return(fFlicStatus); } +// Lesh changed this function only ----------------------------- void SmkInitialize(HWND hWindow, UINT32 uiWidth, UINT32 uiHeight) { - HDIGDRIVER pSoundDriver = NULL; + void *pSoundDriver = NULL; // Wipe the flic list clean memset(SmkList, 0, sizeof(SMKFLIC)*SMK_NUM_FLICS); @@ -151,7 +154,7 @@ void SmkInitialize(HWND hWindow, UINT32 uiWidth, UINT32 uiHeight) //if we got the sound handle, use sound during the intro if( pSoundDriver ) - SmackSoundUseMSS( pSoundDriver ); + SmackSoundUseDirectSound( pSoundDriver ); } void SmkShutdown(void) diff --git a/Utils/Music Control.cpp b/Utils/Music Control.cpp index 837bbbb2..e3db439c 100644 --- a/Utils/Music Control.cpp +++ b/Utils/Music Control.cpp @@ -109,6 +109,7 @@ SOUNDPARMS spParms; memset(&spParms, 0xff, sizeof(SOUNDPARMS)); spParms.uiPriority=PRIORITY_MAX; spParms.uiVolume=0; + spParms.uiLoop=1; // Lesh: only 1 line added spParms.EOSCallback = MusicStopCallback; diff --git a/Utils/Sound Control.cpp b/Utils/Sound Control.cpp index 3b5ce807..8009ac44 100644 --- a/Utils/Sound Control.cpp +++ b/Utils/Sound Control.cpp @@ -11,7 +11,7 @@ #include "renderworld.h" #endif -#define SOUND_FAR_VOLUME_MOD 25 +#define SOUND_FAR_VOLUME_MOD 25 /* UINT32 LOWVOLUME START_LOWVOLUME; @@ -24,306 +24,306 @@ UINT32 guiSoundEffectsVolume = MIDVOLUME; char szSoundEffects[MAX_SAMPLES][255];// = //{ -// "SOUNDS\\RICOCHET 01.WAV", -// "SOUNDS\\RICOCHET 02.WAV", -// "SOUNDS\\RICOCHET 01.WAV", -// "SOUNDS\\RICOCHET 02.WAV", -// "SOUNDS\\RICOCHET 01.WAV", -// "SOUNDS\\RICOCHET 02.WAV", -// "SOUNDS\\RICOCHET 01.WAV", -// "SOUNDS\\RICOCHET 02.WAV", -// "SOUNDS\\DIRT IMPACT 01.WAV", -// "SOUNDS\\DIRT IMPACT 01.WAV", -// "SOUNDS\\KNIFE HIT GROUND.WAV", -// "SOUNDS\\FALL TO KNEES 01.WAV", -// "SOUNDS\\FALL TO KNEES 02.WAV", -// "SOUNDS\\KNEES TO DIRT 01.WAV", -// "SOUNDS\\KNEES TO DIRT 02.WAV", -// "SOUNDS\\KNEES TO DIRT 03.WAV", -// "SOUNDS\\HEAVY FALL 01.WAV", -// "SOUNDS\\BODY_SPLAT.WAV", -// "SOUNDS\\GLASS_BREAK1.WAV", -// "SOUNDS\\GLASS_BREAK2.WAV", +// "SOUNDS\\RICOCHET 01.WAV", +// "SOUNDS\\RICOCHET 02.WAV", +// "SOUNDS\\RICOCHET 01.WAV", +// "SOUNDS\\RICOCHET 02.WAV", +// "SOUNDS\\RICOCHET 01.WAV", +// "SOUNDS\\RICOCHET 02.WAV", +// "SOUNDS\\RICOCHET 01.WAV", +// "SOUNDS\\RICOCHET 02.WAV", +// "SOUNDS\\DIRT IMPACT 01.WAV", +// "SOUNDS\\DIRT IMPACT 01.WAV", +// "SOUNDS\\KNIFE HIT GROUND.WAV", +// "SOUNDS\\FALL TO KNEES 01.WAV", +// "SOUNDS\\FALL TO KNEES 02.WAV", +// "SOUNDS\\KNEES TO DIRT 01.WAV", +// "SOUNDS\\KNEES TO DIRT 02.WAV", +// "SOUNDS\\KNEES TO DIRT 03.WAV", +// "SOUNDS\\HEAVY FALL 01.WAV", +// "SOUNDS\\BODY_SPLAT.WAV", +// "SOUNDS\\GLASS_BREAK1.WAV", +// "SOUNDS\\GLASS_BREAK2.WAV", // -// "SOUNDS\\DOOR OPEN 01.WAV", -// "SOUNDS\\DOOR OPEN 02.WAV", -// "SOUNDS\\DOOR OPEN 03.WAV", -// "SOUNDS\\DOOR CLOSE 01.WAV", -// "SOUNDS\\DOOR CLOSE 02.WAV", -// "SOUNDS\\UNLOCK LOCK.WAV", -// "SOUNDS\\KICKIN LOCK.WAV", -// "SOUNDS\\BREAK LOCK.WAV", -// "SOUNDS\\PICKING LOCK.WAV", +// "SOUNDS\\DOOR OPEN 01.WAV", +// "SOUNDS\\DOOR OPEN 02.WAV", +// "SOUNDS\\DOOR OPEN 03.WAV", +// "SOUNDS\\DOOR CLOSE 01.WAV", +// "SOUNDS\\DOOR CLOSE 02.WAV", +// "SOUNDS\\UNLOCK LOCK.WAV", +// "SOUNDS\\KICKIN LOCK.WAV", +// "SOUNDS\\BREAK LOCK.WAV", +// "SOUNDS\\PICKING LOCK.WAV", // -// "SOUNDS\\GARAGE DOOR OPEN.WAV", -// "SOUNDS\\GARAGE DOOR CLOSE.WAV", -// "SOUNDS\\ELEVATOR DOOR OPEN.WAV", -// "SOUNDS\\ELEVATOR DOOR CLOSE.WAV", -// "SOUNDS\\HIGH TECH DOOR OPEN.WAV", -// "SOUNDS\\HIGH TECH DOOR CLOSE.WAV", -// "SOUNDS\\CURTAINS DOOR OPEN.WAV", -// "SOUNDS\\CURTAINS DOOR CLOSE.WAV", -// "SOUNDS\\METAL DOOR OPEN.WAV", -// "SOUNDS\\METAL DOOR CLOSE.WAV", +// "SOUNDS\\GARAGE DOOR OPEN.WAV", +// "SOUNDS\\GARAGE DOOR CLOSE.WAV", +// "SOUNDS\\ELEVATOR DOOR OPEN.WAV", +// "SOUNDS\\ELEVATOR DOOR CLOSE.WAV", +// "SOUNDS\\HIGH TECH DOOR OPEN.WAV", +// "SOUNDS\\HIGH TECH DOOR CLOSE.WAV", +// "SOUNDS\\CURTAINS DOOR OPEN.WAV", +// "SOUNDS\\CURTAINS DOOR CLOSE.WAV", +// "SOUNDS\\METAL DOOR OPEN.WAV", +// "SOUNDS\\METAL DOOR CLOSE.WAV", // -// "SOUNDS\\ftp gravel 01.WAV", -// "SOUNDS\\ftp gravel 02.WAV", -// "SOUNDS\\ftp gravel 03.WAV", -// "SOUNDS\\ftp gravel 04.WAV", -// "SOUNDS\\ftp gritty 01.WAV", -// "SOUNDS\\ftp gritty 02.WAV", -// "SOUNDS\\ftp gritty 03.WAV", -// "SOUNDS\\ftp gritty 04.WAV", -// "SOUNDS\\ftp leaves 01.WAV", -// "SOUNDS\\ftp leaves 02.WAV", -// "SOUNDS\\ftp leaves 03.WAV", -// "SOUNDS\\ftp leaves 04.WAV", +// "SOUNDS\\ftp gravel 01.WAV", +// "SOUNDS\\ftp gravel 02.WAV", +// "SOUNDS\\ftp gravel 03.WAV", +// "SOUNDS\\ftp gravel 04.WAV", +// "SOUNDS\\ftp gritty 01.WAV", +// "SOUNDS\\ftp gritty 02.WAV", +// "SOUNDS\\ftp gritty 03.WAV", +// "SOUNDS\\ftp gritty 04.WAV", +// "SOUNDS\\ftp leaves 01.WAV", +// "SOUNDS\\ftp leaves 02.WAV", +// "SOUNDS\\ftp leaves 03.WAV", +// "SOUNDS\\ftp leaves 04.WAV", // -// "SOUNDS\\CRAWLING 01.WAV", -// "SOUNDS\\CRAWLING 02.WAV", -// "SOUNDS\\CRAWLING 03.WAV", -// "SOUNDS\\CRAWLING 04.WAV", -// "SOUNDS\\BEEP2.WAV", -// "SOUNDS\\ENDTURN.WAV", -// "SOUNDS\\JA2 DEATH HIT.WAV", -// "SOUNDS\\DOORCR_B.WAV", -// "SOUNDS\\HEAD EXPLODING 01.WAV", -// "SOUNDS\\BODY EXPLODING.WAV", -// "SOUNDS\\EXPLODE1.WAV", -// "SOUNDS\\CROW EXPLODING.WAV", -// "SOUNDS\\SMALL EXPLOSION 01.WAV", +// "SOUNDS\\CRAWLING 01.WAV", +// "SOUNDS\\CRAWLING 02.WAV", +// "SOUNDS\\CRAWLING 03.WAV", +// "SOUNDS\\CRAWLING 04.WAV", +// "SOUNDS\\BEEP2.WAV", +// "SOUNDS\\ENDTURN.WAV", +// "SOUNDS\\JA2 DEATH HIT.WAV", +// "SOUNDS\\DOORCR_B.WAV", +// "SOUNDS\\HEAD EXPLODING 01.WAV", +// "SOUNDS\\BODY EXPLODING.WAV", +// "SOUNDS\\EXPLODE1.WAV", +// "SOUNDS\\CROW EXPLODING.WAV", +// "SOUNDS\\SMALL EXPLOSION 01.WAV", // -// "SOUNDS\\HELI1.WAV", -// "SOUNDS\\BULLET IMPACT 01.WAV", -// "SOUNDS\\BULLET IMPACT 02.WAV", -// "SOUNDS\\BULLET IMPACT 02.WAV", +// "SOUNDS\\HELI1.WAV", +// "SOUNDS\\BULLET IMPACT 01.WAV", +// "SOUNDS\\BULLET IMPACT 02.WAV", +// "SOUNDS\\BULLET IMPACT 02.WAV", // -// "STSOUNDS\\BLAH.WAV", // CREATURE ATTACK -// -// "SOUNDS\\STEP INTO WATER.WAV", -// "SOUNDS\\SPLASH FROM SHALLOW TO DEEP.WAV", +// "STSOUNDS\\BLAH.WAV", // CREATURE ATTACK +// +// "SOUNDS\\STEP INTO WATER.WAV", +// "SOUNDS\\SPLASH FROM SHALLOW TO DEEP.WAV", // -// "SOUNDS\\COW HIT.WAV", // COW HIT -// "SOUNDS\\COW DIE.WAV", // COW DIE +// "SOUNDS\\COW HIT.WAV", // COW HIT +// "SOUNDS\\COW DIE.WAV", // COW DIE // -// // THREE COMPUTER VOICE SOUNDS FOR RG -// "SOUNDS\\LINE 02 FX.WAV", -// "SOUNDS\\LINE 01 FX.WAV", -// "SOUNDS\\LINE 03 FX.WAV", +// // THREE COMPUTER VOICE SOUNDS FOR RG +// "SOUNDS\\LINE 02 FX.WAV", +// "SOUNDS\\LINE 01 FX.WAV", +// "SOUNDS\\LINE 03 FX.WAV", // -// "SOUNDS\\CAVE COLLAPSING.WAV", // CAVE_COLLAPSE +// "SOUNDS\\CAVE COLLAPSING.WAV", // CAVE_COLLAPSE // // -// "SOUNDS\\RAID WHISTLE.WAV", // RAID -// "SOUNDS\\RAID AMBIENT.WAV", -// "SOUNDS\\RAID DIVE.WAV", -// "SOUNDS\\RAID DIVE.WAV", -// "SOUNDS\\RAID WHISTLE.WAV", // RAID +// "SOUNDS\\RAID WHISTLE.WAV", // RAID +// "SOUNDS\\RAID AMBIENT.WAV", +// "SOUNDS\\RAID DIVE.WAV", +// "SOUNDS\\RAID DIVE.WAV", +// "SOUNDS\\RAID WHISTLE.WAV", // RAID // -// // VEHICLES -// "SOUNDS\\DRIVING 01.WAV", // DRIVING -// "SOUNDS\\ENGINE START.WAV", // ON -// "SOUNDS\\ENGINE OFF.WAV", // OFF -// "SOUNDS\\INTO VEHICLE.WAV", // INTO +// // VEHICLES +// "SOUNDS\\DRIVING 01.WAV", // DRIVING +// "SOUNDS\\ENGINE START.WAV", // ON +// "SOUNDS\\ENGINE OFF.WAV", // OFF +// "SOUNDS\\INTO VEHICLE.WAV", // INTO // // -// "SOUNDS\\WEAPONS\\DRY FIRE 1.WAV", // Dry fire sound ( for gun jam ) +// "SOUNDS\\WEAPONS\\DRY FIRE 1.WAV", // Dry fire sound ( for gun jam ) // -// // IMPACTS -// "SOUNDS\\WOOD IMPACT 01A.WAV", // S_WOOD_IMPACT1 -// "SOUNDS\\WOOD IMPACT 01B.WAV", -// "SOUNDS\\WOOD IMPACT 01A.WAV", -// "SOUNDS\\PORCELAIN IMPACT.WAV", -// "SOUNDS\\TIRE IMPACT 01.WAV", -// "SOUNDS\\STONE IMPACT 01.WAV", -// "SOUNDS\\WATER IMPACT 01.WAV", -// "SOUNDS\\VEG IMPACT 01.WAV", -// "SOUNDS\\METAL HIT 01.WAV", // S_METAL_HIT1 -// "SOUNDS\\METAL HIT 01.WAV", -// "SOUNDS\\METAL HIT 01.WAV", +// // IMPACTS +// "SOUNDS\\WOOD IMPACT 01A.WAV", // S_WOOD_IMPACT1 +// "SOUNDS\\WOOD IMPACT 01B.WAV", +// "SOUNDS\\WOOD IMPACT 01A.WAV", +// "SOUNDS\\PORCELAIN IMPACT.WAV", +// "SOUNDS\\TIRE IMPACT 01.WAV", +// "SOUNDS\\STONE IMPACT 01.WAV", +// "SOUNDS\\WATER IMPACT 01.WAV", +// "SOUNDS\\VEG IMPACT 01.WAV", +// "SOUNDS\\METAL HIT 01.WAV", // S_METAL_HIT1 +// "SOUNDS\\METAL HIT 01.WAV", +// "SOUNDS\\METAL HIT 01.WAV", // -// "SOUNDS\\SLAP_IMPACT.WAV", +// "SOUNDS\\SLAP_IMPACT.WAV", // -// // FIREARM RELOAD -// "SOUNDS\\WEAPONS\\REVOLVER RELOAD.WAV", // REVOLVER -// "SOUNDS\\WEAPONS\\PISTOL RELOAD.WAV", // PISTOL -// "SOUNDS\\WEAPONS\\SMG RELOAD.WAV", // SMG -// "SOUNDS\\WEAPONS\\RIFLE RELOAD.WAV", // RIFLE -// "SOUNDS\\WEAPONS\\SHOTGUN RELOAD.WAV", // SHOTGUN -// "SOUNDS\\WEAPONS\\LMG RELOAD.WAV", // LMG +// // FIREARM RELOAD +// "SOUNDS\\WEAPONS\\REVOLVER RELOAD.WAV", // REVOLVER +// "SOUNDS\\WEAPONS\\PISTOL RELOAD.WAV", // PISTOL +// "SOUNDS\\WEAPONS\\SMG RELOAD.WAV", // SMG +// "SOUNDS\\WEAPONS\\RIFLE RELOAD.WAV", // RIFLE +// "SOUNDS\\WEAPONS\\SHOTGUN RELOAD.WAV", // SHOTGUN +// "SOUNDS\\WEAPONS\\LMG RELOAD.WAV", // LMG // -// // FIREARM LOCKNLOAD -// "SOUNDS\\WEAPONS\\REVOLVER LNL.WAV", // REVOLVER -// "SOUNDS\\WEAPONS\\PISTOL LNL.WAV", // PISTOL -// "SOUNDS\\WEAPONS\\SMG LNL.WAV", // SMG -// "SOUNDS\\WEAPONS\\RIFLE LNL.WAV", // RIFLE -// "SOUNDS\\WEAPONS\\SHOTGUN LNL.WAV", // SHOTGUN -// "SOUNDS\\WEAPONS\\LMG LNL.WAV", // LMG +// // FIREARM LOCKNLOAD +// "SOUNDS\\WEAPONS\\REVOLVER LNL.WAV", // REVOLVER +// "SOUNDS\\WEAPONS\\PISTOL LNL.WAV", // PISTOL +// "SOUNDS\\WEAPONS\\SMG LNL.WAV", // SMG +// "SOUNDS\\WEAPONS\\RIFLE LNL.WAV", // RIFLE +// "SOUNDS\\WEAPONS\\SHOTGUN LNL.WAV", // SHOTGUN +// "SOUNDS\\WEAPONS\\LMG LNL.WAV", // LMG // -// // ROCKET LAUCNHER -// "SOUNDS\\WEAPONS\\SMALL ROCKET LAUNCHER.WAV", // SMALL ROCKET LUANCHER -// "SOUNDS\\WEAPONS\\MORTAR FIRE 01.WAV", // GRENADE LAUNCHER -// "SOUNDS\\WEAPONS\\MORTAR FIRE 01.WAV", // UNDERSLUNG GRENADE LAUNCHER -// "SOUNDS\\WEAPONS\\ROCKET LAUNCHER.WAV", -// "SOUNDS\\WEAPONS\\MORTAR FIRE 01.WAV", +// // ROCKET LAUCNHER +// "SOUNDS\\WEAPONS\\SMALL ROCKET LAUNCHER.WAV", // SMALL ROCKET LUANCHER +// "SOUNDS\\WEAPONS\\MORTAR FIRE 01.WAV", // GRENADE LAUNCHER +// "SOUNDS\\WEAPONS\\MORTAR FIRE 01.WAV", // UNDERSLUNG GRENADE LAUNCHER +// "SOUNDS\\WEAPONS\\ROCKET LAUNCHER.WAV", +// "SOUNDS\\WEAPONS\\MORTAR FIRE 01.WAV", // -// // FIREARMS -// "SOUNDS\\WEAPONS\\9mm SINGLE SHOT.WAV", // S_GLOCK17 9mm -// "SOUNDS\\WEAPONS\\9mm SINGLE SHOT.WAV", // S_GLOCK18 9mm -// "SOUNDS\\WEAPONS\\9mm SINGLE SHOT.WAV", // S_BERETTA92 9mm -// "SOUNDS\\WEAPONS\\9mm SINGLE SHOT.WAV", // S_BERETTA93 9mm -// "SOUNDS\\WEAPONS\\38 CALIBER.WAV", // S_SWSPECIAL .38 -// "SOUNDS\\WEAPONS\\357 SINGLE SHOT.WAV", // S_BARRACUDA .357 -// "SOUNDS\\WEAPONS\\357 SINGLE SHOT.WAV", // S_DESERTEAGLE .357 -// "SOUNDS\\WEAPONS\\45 CALIBER SINGLE SHOT.WAV", // S_M1911 .45 -// "SOUNDS\\WEAPONS\\9mm SINGLE SHOT.WAV", // S_MP5K 9mm -// "SOUNDS\\WEAPONS\\45 CALIBER SINGLE SHOT.WAV", // S_MAC10 .45 -// "SOUNDS\\WEAPONS\\45 CALIBER SINGLE SHOT.WAV", // S_THOMPSON .45 -// "SOUNDS\\WEAPONS\\5,56 SINGLE SHOT.WAV", // S_COMMANDO 5.56 -// "SOUNDS\\WEAPONS\\5,56 SINGLE SHOT.WAV", // S_MP53 5.56? -// "SOUNDS\\WEAPONS\\5,45 SINGLE SHOT.WAV", // S_AKSU74 5.45 -// "SOUNDS\\WEAPONS\\5,7 SINGLE SHOT.WAV", // S_P90 5.7 -// "SOUNDS\\WEAPONS\\7,62 WP SINGLE SHOT.WAV", // S_TYPE85 7.62 WP -// "SOUNDS\\WEAPONS\\7,62 WP SINGLE SHOT.WAV", // S_SKS 7.62 WP -// "SOUNDS\\WEAPONS\\7,62 WP SINGLE SHOT.WAV", // S_DRAGUNOV 7.62 WP -// "SOUNDS\\WEAPONS\\7,62 NATO SINGLE SHOT.WAV", // S_M24 7.62 NATO -// "SOUNDS\\WEAPONS\\5,56 SINGLE SHOT.WAV", // S_AUG 5.56mm -// "SOUNDS\\WEAPONS\\5,56 SINGLE SHOT.WAV", // S_G41 5.56mm -// "SOUNDS\\WEAPONS\\5,56 SINGLE SHOT.WAV", // S_RUGERMINI 5.56mm -// "SOUNDS\\WEAPONS\\5,56 SINGLE SHOT.WAV", // S_C7 5.56mm -// "SOUNDS\\WEAPONS\\5,56 SINGLE SHOT.WAV", // S_FAMAS 5.56mm -// "SOUNDS\\WEAPONS\\5,45 SINGLE SHOT.WAV", // S_AK74 5.45mm -// "SOUNDS\\WEAPONS\\7,62 WP SINGLE SHOT.WAV", // S_AKM 7.62mm WP -// "SOUNDS\\WEAPONS\\7,62 NATO SINGLE SHOT.WAV", // S_M14 7.62mm NATO -// "SOUNDS\\WEAPONS\\7,62 NATO SINGLE SHOT.WAV", // S_FNFAL 7.62mm NATO -// "SOUNDS\\WEAPONS\\7,62 NATO SINGLE SHOT.WAV", // S_G3A3 7.62mm NATO -// "SOUNDS\\WEAPONS\\4,7 SINGLE SHOT.WAV", // S_G11 4.7mm -// "SOUNDS\\WEAPONS\\SHOTGUN SINGLE SHOT.WAV", // S_M870 SHOTGUN -// "SOUNDS\\WEAPONS\\SHOTGUN SINGLE SHOT.WAV", // S_SPAS SHOTGUN -// "SOUNDS\\WEAPONS\\SHOTGUN SINGLE SHOT.WAV", // S_CAWS SHOTGUN -// "SOUNDS\\WEAPONS\\5,56 SINGLE SHOT.WAV", // S_FNMINI 5.56mm -// "SOUNDS\\WEAPONS\\5,45 SINGLE SHOT.WAV", // S_RPK74 5.45mm -// "SOUNDS\\WEAPONS\\7,62 WP SINGLE SHOT.WAV", // S_21E 7.62mm -// "SOUNDS\\WEAPONS\\KNIFE THROW SWOOSH.WAV", // KNIFE THROW -// "SOUNDS\\WEAPONS\\TANK_CANNON.WAV", -// "SOUNDS\\WEAPONS\\BURSTTYPE1.WAV", -// "SOUNDS\\WEAPONS\\AUTOMAG SINGLE.WAV", +// // FIREARMS +// "SOUNDS\\WEAPONS\\9mm SINGLE SHOT.WAV", // S_GLOCK17 9mm +// "SOUNDS\\WEAPONS\\9mm SINGLE SHOT.WAV", // S_GLOCK18 9mm +// "SOUNDS\\WEAPONS\\9mm SINGLE SHOT.WAV", // S_BERETTA92 9mm +// "SOUNDS\\WEAPONS\\9mm SINGLE SHOT.WAV", // S_BERETTA93 9mm +// "SOUNDS\\WEAPONS\\38 CALIBER.WAV", // S_SWSPECIAL .38 +// "SOUNDS\\WEAPONS\\357 SINGLE SHOT.WAV", // S_BARRACUDA .357 +// "SOUNDS\\WEAPONS\\357 SINGLE SHOT.WAV", // S_DESERTEAGLE .357 +// "SOUNDS\\WEAPONS\\45 CALIBER SINGLE SHOT.WAV", // S_M1911 .45 +// "SOUNDS\\WEAPONS\\9mm SINGLE SHOT.WAV", // S_MP5K 9mm +// "SOUNDS\\WEAPONS\\45 CALIBER SINGLE SHOT.WAV", // S_MAC10 .45 +// "SOUNDS\\WEAPONS\\45 CALIBER SINGLE SHOT.WAV", // S_THOMPSON .45 +// "SOUNDS\\WEAPONS\\5,56 SINGLE SHOT.WAV", // S_COMMANDO 5.56 +// "SOUNDS\\WEAPONS\\5,56 SINGLE SHOT.WAV", // S_MP53 5.56? +// "SOUNDS\\WEAPONS\\5,45 SINGLE SHOT.WAV", // S_AKSU74 5.45 +// "SOUNDS\\WEAPONS\\5,7 SINGLE SHOT.WAV", // S_P90 5.7 +// "SOUNDS\\WEAPONS\\7,62 WP SINGLE SHOT.WAV", // S_TYPE85 7.62 WP +// "SOUNDS\\WEAPONS\\7,62 WP SINGLE SHOT.WAV", // S_SKS 7.62 WP +// "SOUNDS\\WEAPONS\\7,62 WP SINGLE SHOT.WAV", // S_DRAGUNOV 7.62 WP +// "SOUNDS\\WEAPONS\\7,62 NATO SINGLE SHOT.WAV", // S_M24 7.62 NATO +// "SOUNDS\\WEAPONS\\5,56 SINGLE SHOT.WAV", // S_AUG 5.56mm +// "SOUNDS\\WEAPONS\\5,56 SINGLE SHOT.WAV", // S_G41 5.56mm +// "SOUNDS\\WEAPONS\\5,56 SINGLE SHOT.WAV", // S_RUGERMINI 5.56mm +// "SOUNDS\\WEAPONS\\5,56 SINGLE SHOT.WAV", // S_C7 5.56mm +// "SOUNDS\\WEAPONS\\5,56 SINGLE SHOT.WAV", // S_FAMAS 5.56mm +// "SOUNDS\\WEAPONS\\5,45 SINGLE SHOT.WAV", // S_AK74 5.45mm +// "SOUNDS\\WEAPONS\\7,62 WP SINGLE SHOT.WAV", // S_AKM 7.62mm WP +// "SOUNDS\\WEAPONS\\7,62 NATO SINGLE SHOT.WAV", // S_M14 7.62mm NATO +// "SOUNDS\\WEAPONS\\7,62 NATO SINGLE SHOT.WAV", // S_FNFAL 7.62mm NATO +// "SOUNDS\\WEAPONS\\7,62 NATO SINGLE SHOT.WAV", // S_G3A3 7.62mm NATO +// "SOUNDS\\WEAPONS\\4,7 SINGLE SHOT.WAV", // S_G11 4.7mm +// "SOUNDS\\WEAPONS\\SHOTGUN SINGLE SHOT.WAV", // S_M870 SHOTGUN +// "SOUNDS\\WEAPONS\\SHOTGUN SINGLE SHOT.WAV", // S_SPAS SHOTGUN +// "SOUNDS\\WEAPONS\\SHOTGUN SINGLE SHOT.WAV", // S_CAWS SHOTGUN +// "SOUNDS\\WEAPONS\\5,56 SINGLE SHOT.WAV", // S_FNMINI 5.56mm +// "SOUNDS\\WEAPONS\\5,45 SINGLE SHOT.WAV", // S_RPK74 5.45mm +// "SOUNDS\\WEAPONS\\7,62 WP SINGLE SHOT.WAV", // S_21E 7.62mm +// "SOUNDS\\WEAPONS\\KNIFE THROW SWOOSH.WAV", // KNIFE THROW +// "SOUNDS\\WEAPONS\\TANK_CANNON.WAV", +// "SOUNDS\\WEAPONS\\BURSTTYPE1.WAV", +// "SOUNDS\\WEAPONS\\AUTOMAG SINGLE.WAV", // -// "SOUNDS\\WEAPONS\\SILENCER 02.WAV", -// "SOUNDS\\WEAPONS\\SILENCER 03.WAV", +// "SOUNDS\\WEAPONS\\SILENCER 02.WAV", +// "SOUNDS\\WEAPONS\\SILENCER 03.WAV", // -// "SOUNDS\\SWOOSH 01.WAV", -// "SOUNDS\\SWOOSH 03.WAV", -// "SOUNDS\\SWOOSH 05.WAV", -// "SOUNDS\\SWOOSH 06.WAV", -// "SOUNDS\\SWOOSH 11.WAV", -// "SOUNDS\\SWOOSH 14.WAV", +// "SOUNDS\\SWOOSH 01.WAV", +// "SOUNDS\\SWOOSH 03.WAV", +// "SOUNDS\\SWOOSH 05.WAV", +// "SOUNDS\\SWOOSH 06.WAV", +// "SOUNDS\\SWOOSH 11.WAV", +// "SOUNDS\\SWOOSH 14.WAV", // -// // CREATURE_SOUNDS -// "SOUNDS\\ADULT FALL 01.WAV", -// "SOUNDS\\ADULT STEP 01.WAV", -// "SOUNDS\\ADULT STEP 02.WAV", -// "SOUNDS\\ADULT SWIPE 01.WAV", -// "SOUNDS\\Eating_Flesh 01.WAV", -// "SOUNDS\\ADULT CRIPPLED.WAV", -// "SOUNDS\\ADULT DYING PART 1.WAV", -// "SOUNDS\\ADULT DYING PART 2.WAV", -// "SOUNDS\\ADULT LUNGE 01.WAV", -// "SOUNDS\\ADULT SMELLS THREAT.WAV", -// "SOUNDS\\ADULT SMELLS PREY.WAV", -// "SOUNDS\\ADULT SPIT.WAV", +// // CREATURE_SOUNDS +// "SOUNDS\\ADULT FALL 01.WAV", +// "SOUNDS\\ADULT STEP 01.WAV", +// "SOUNDS\\ADULT STEP 02.WAV", +// "SOUNDS\\ADULT SWIPE 01.WAV", +// "SOUNDS\\Eating_Flesh 01.WAV", +// "SOUNDS\\ADULT CRIPPLED.WAV", +// "SOUNDS\\ADULT DYING PART 1.WAV", +// "SOUNDS\\ADULT DYING PART 2.WAV", +// "SOUNDS\\ADULT LUNGE 01.WAV", +// "SOUNDS\\ADULT SMELLS THREAT.WAV", +// "SOUNDS\\ADULT SMELLS PREY.WAV", +// "SOUNDS\\ADULT SPIT.WAV", // -// // BABY -// "SOUNDS\\BABY DYING 01.WAV", -// "SOUNDS\\BABY DRAGGING 01.WAV", -// "SOUNDS\\BABY SHRIEK 01.WAV", -// "SOUNDS\\BABY SPITTING 01.WAV", +// // BABY +// "SOUNDS\\BABY DYING 01.WAV", +// "SOUNDS\\BABY DRAGGING 01.WAV", +// "SOUNDS\\BABY SHRIEK 01.WAV", +// "SOUNDS\\BABY SPITTING 01.WAV", // -// // LARVAE -// "SOUNDS\\LARVAE MOVEMENT 01.WAV", -// "SOUNDS\\LARVAE RUPTURE 01.WAV", +// // LARVAE +// "SOUNDS\\LARVAE MOVEMENT 01.WAV", +// "SOUNDS\\LARVAE RUPTURE 01.WAV", // -// //QUEEN -// "SOUNDS\\QUEEN SHRIEK 01.WAV", -// "SOUNDS\\QUEEN DYING 01.WAV", -// "SOUNDS\\QUEEN ENRAGED ATTACK.WAV", -// "SOUNDS\\QUEEN RUPTURING.WAV", -// "SOUNDS\\QUEEN CRIPPLED.WAV", -// "SOUNDS\\QUEEN SMELLS THREAT.WAV", -// "SOUNDS\\QUEEN WHIP ATTACK.WAV", +// //QUEEN +// "SOUNDS\\QUEEN SHRIEK 01.WAV", +// "SOUNDS\\QUEEN DYING 01.WAV", +// "SOUNDS\\QUEEN ENRAGED ATTACK.WAV", +// "SOUNDS\\QUEEN RUPTURING.WAV", +// "SOUNDS\\QUEEN CRIPPLED.WAV", +// "SOUNDS\\QUEEN SMELLS THREAT.WAV", +// "SOUNDS\\QUEEN WHIP ATTACK.WAV", // -// "SOUNDS\\ROCK HIT 01.WAV", -// "SOUNDS\\ROCK HIT 02.WAV", +// "SOUNDS\\ROCK HIT 01.WAV", +// "SOUNDS\\ROCK HIT 02.WAV", // -// "SOUNDS\\SCRATCH.WAV", -// "SOUNDS\\ARMPIT.WAV", -// "SOUNDS\\CRACKING BACK.WAV", +// "SOUNDS\\SCRATCH.WAV", +// "SOUNDS\\ARMPIT.WAV", +// "SOUNDS\\CRACKING BACK.WAV", // -// "SOUNDS\\WEAPONS\\Auto Resolve Composite 02 (8-22).wav", // The FF sound in autoresolve interface +// "SOUNDS\\WEAPONS\\Auto Resolve Composite 02 (8-22).wav",// The FF sound in autoresolve interface // -// "SOUNDS\\Email Alert 01.wav", -// "SOUNDS\\Entering Text 02.wav", -// "SOUNDS\\Removing Text 02.wav", -// "SOUNDS\\Computer Beep 01 In.wav", -// "SOUNDS\\Computer Beep 01 Out.wav", -// "SOUNDS\\Computer Switch 01 In.wav", -// "SOUNDS\\Computer Switch 01 Out.wav", -// "SOUNDS\\Very Small Switch 01 In.wav", -// "SOUNDS\\Very Small Switch 01 Out.wav", -// "SOUNDS\\Very Small Switch 02 In.wav", -// "SOUNDS\\Very Small Switch 02 Out.wav", -// "SOUNDS\\Small Switch 01 In.wav", -// "SOUNDS\\Small Switch 01 Out.wav", -// "SOUNDS\\Small Switch 02 In.wav", -// "SOUNDS\\Small Switch 02 Out.wav", -// "SOUNDS\\Small Switch 03 In.wav", -// "SOUNDS\\Small Switch 03 Out.wav", -// "SOUNDS\\Big Switch 03 In.wav", -// "SOUNDS\\Big Switch 03 Out.wav", -// "SOUNDS\\Alarm.wav", -// "SOUNDS\\Fight Bell.wav", -// "SOUNDS\\Helicopter Crash Sequence.wav", -// "SOUNDS\\Attachment.wav", -// "SOUNDS\\Ceramic Armour Insert.wav", -// "SOUNDS\\Detonator Beep.wav", -// "SOUNDS\\Grab Roof.wav", -// "SOUNDS\\Land On Roof.wav", -// "SOUNDS\\Branch Snap 01.wav", -// "SOUNDS\\Branch Snap 02.wav", -// "SOUNDS\\Indoor Bump 01.wav", +// "SOUNDS\\Email Alert 01.wav", +// "SOUNDS\\Entering Text 02.wav", +// "SOUNDS\\Removing Text 02.wav", +// "SOUNDS\\Computer Beep 01 In.wav", +// "SOUNDS\\Computer Beep 01 Out.wav", +// "SOUNDS\\Computer Switch 01 In.wav", +// "SOUNDS\\Computer Switch 01 Out.wav", +// "SOUNDS\\Very Small Switch 01 In.wav", +// "SOUNDS\\Very Small Switch 01 Out.wav", +// "SOUNDS\\Very Small Switch 02 In.wav", +// "SOUNDS\\Very Small Switch 02 Out.wav", +// "SOUNDS\\Small Switch 01 In.wav", +// "SOUNDS\\Small Switch 01 Out.wav", +// "SOUNDS\\Small Switch 02 In.wav", +// "SOUNDS\\Small Switch 02 Out.wav", +// "SOUNDS\\Small Switch 03 In.wav", +// "SOUNDS\\Small Switch 03 Out.wav", +// "SOUNDS\\Big Switch 03 In.wav", +// "SOUNDS\\Big Switch 03 Out.wav", +// "SOUNDS\\Alarm.wav", +// "SOUNDS\\Fight Bell.wav", +// "SOUNDS\\Helicopter Crash Sequence.wav", +// "SOUNDS\\Attachment.wav", +// "SOUNDS\\Ceramic Armour Insert.wav", +// "SOUNDS\\Detonator Beep.wav", +// "SOUNDS\\Grab Roof.wav", +// "SOUNDS\\Land On Roof.wav", +// "SOUNDS\\Branch Snap 01.wav", +// "SOUNDS\\Branch Snap 02.wav", +// "SOUNDS\\Indoor Bump 01.wav", // -// "SOUNDS\\Fridge Door Open.wav", -// "SOUNDS\\Fridge Door Close.wav", +// "SOUNDS\\Fridge Door Open.wav", +// "SOUNDS\\Fridge Door Close.wav", // -// "SOUNDS\\Fire 03 Loop.wav", -// "SOUNDS\\GLASS_CRACK.wav", -// "SOUNDS\\SPIT RICOCHET.WAV", -// "SOUNDS\\TIGER HIT.WAV", -// "SOUNDS\\bloodcat dying 02.WAV", -// "SOUNDS\\SLAP.WAV", -// "SOUNDS\\ROBOT BEEP.WAV", -// "SOUNDS\\ELECTRICITY.WAV", -// "SOUNDS\\SWIMMING 01.WAV", -// "SOUNDS\\SWIMMING 02.WAV", -// "SOUNDS\\KEY FAILURE.WAV", -// "SOUNDS\\target cursor.WAV", -// "SOUNDS\\statue open.WAV", -// "SOUNDS\\remote activate.WAV", -// "SOUNDS\\wirecutters.WAV", -// "SOUNDS\\drink from canteen.WAV", +// "SOUNDS\\Fire 03 Loop.wav", +// "SOUNDS\\GLASS_CRACK.wav", +// "SOUNDS\\SPIT RICOCHET.WAV", +// "SOUNDS\\TIGER HIT.WAV", +// "SOUNDS\\bloodcat dying 02.WAV", +// "SOUNDS\\SLAP.WAV", +// "SOUNDS\\ROBOT BEEP.WAV", +// "SOUNDS\\ELECTRICITY.WAV", +// "SOUNDS\\SWIMMING 01.WAV", +// "SOUNDS\\SWIMMING 02.WAV", +// "SOUNDS\\KEY FAILURE.WAV", +// "SOUNDS\\target cursor.WAV", +// "SOUNDS\\statue open.WAV", +// "SOUNDS\\remote activate.WAV", +// "SOUNDS\\wirecutters.WAV", +// "SOUNDS\\drink from canteen.WAV", // "SOUNDS\\bloodcat attack.wav", // "SOUNDS\\bloodcat loud roar.wav", // "SOUNDS\\robot greeting.wav", // "SOUNDS\\robot death.wav", -// "SOUNDS\\gas grenade explode.WAV", -// "SOUNDS\\air escaping.WAV", -// "SOUNDS\\drawer open.WAV", -// "SOUNDS\\drawer close.WAV", -// "SOUNDS\\locker door open.WAV", -// "SOUNDS\\locker door close.WAV", -// "SOUNDS\\wooden box open.WAV", -// "SOUNDS\\wooden box close.WAV", -// "SOUNDS\\robot stop moving.WAV", +// "SOUNDS\\gas grenade explode.WAV", +// "SOUNDS\\air escaping.WAV", +// "SOUNDS\\drawer open.WAV", +// "SOUNDS\\drawer close.WAV", +// "SOUNDS\\locker door open.WAV", +// "SOUNDS\\locker door close.WAV", +// "SOUNDS\\wooden box open.WAV", +// "SOUNDS\\wooden box close.WAV", +// "SOUNDS\\robot stop moving.WAV", // "SOUNDS\\water movement 01.wav", // "SOUNDS\\water movement 02.wav", // "SOUNDS\\water movement 03.wav", @@ -339,7 +339,7 @@ char szSoundEffects[MAX_SAMPLES][255];// = // "SOUNDS\\bloodcat_growl_03.wav", // "SOUNDS\\bloodcat_growl_04.wav", // "SOUNDS\\spit ricochet.wav", -// "SOUNDS\\ADULT crippled.WAV", +// "SOUNDS\\ADULT crippled.WAV", // "SOUNDS\\death disintegration.wav", // "SOUNDS\\Queen Ambience.wav", // "SOUNDS\\Alien Impact.wav", @@ -355,11 +355,11 @@ char szSoundEffects[MAX_SAMPLES][255];// = // "SOUNDS\\stab into flesh.wav", // "SOUNDS\\explosion 10.wav", // "SOUNDS\\explosion 12.wav", -// "SOUNDS\\drink from canteen male.WAV", -// "SOUNDS\\x ray activated.WAV", +// "SOUNDS\\drink from canteen male.WAV", +// "SOUNDS\\x ray activated.WAV", // "SOUNDS\\catch object.wav", // "SOUNDS\\fence open.wav", -// + ////MADD MARKER ////New Guns // "SOUNDS\\WEAPONS\\50CAL.WAV", @@ -369,20 +369,20 @@ char szSoundEffects[MAX_SAMPLES][255];// = char szAmbientEffects[NUM_AMBIENTS][255] = { - "SOUNDS\\storm1.wav", - "SOUNDS\\storm2.wav", - "SOUNDS\\rain_loop_22k.wav", - "SOUNDS\\bird1-22k.wav", - "SOUNDS\\bird3-22k.wav", - "SOUNDS\\crickety_loop.wav", - "SOUNDS\\crickety_loop2.wav", - "SOUNDS\\cricket1.wav", - "SOUNDS\\cricket2.wav", - "SOUNDS\\owl1.wav", - "SOUNDS\\owl2.wav", - "SOUNDS\\owl3.wav", - "SOUNDS\\night_bird1.wav", - "SOUNDS\\night_bird3.wav" + "SOUNDS\\storm1.wav", + "SOUNDS\\storm2.wav", + "SOUNDS\\rain_loop_22k.wav", + "SOUNDS\\bird1-22k.wav", + "SOUNDS\\bird3-22k.wav", + "SOUNDS\\crickety_loop.wav", + "SOUNDS\\crickety_loop2.wav", + "SOUNDS\\cricket1.wav", + "SOUNDS\\cricket2.wav", + "SOUNDS\\owl1.wav", + "SOUNDS\\owl2.wav", + "SOUNDS\\owl3.wav", + "SOUNDS\\night_bird1.wav", + "SOUNDS\\night_bird3.wav" }; UINT8 AmbientVols[NUM_AMBIENTS]={ @@ -404,7 +404,7 @@ UINT8 AmbientVols[NUM_AMBIENTS]={ SOUNDPARMS gDelayedSoundParms; -UINT32 guiDelayedSoundNum; +UINT32 guiDelayedSoundNum; void DelayedSoundTimerCallback( void ); @@ -443,8 +443,9 @@ UINT32 PlayJA2Sample( UINT32 usNum, UINT32 usRate, UINT32 ubVolume, UINT32 ubLoo spParms.uiSpeed = usRate; spParms.uiVolume = CalculateSoundEffectsVolume( ubVolume ); + spParms.uiVolume &= 0xFFL; spParms.uiLoop = ubLoops; - spParms.uiPan = uiPan; + spParms.uiPan = uiPan & 0xFFL; spParms.uiPriority=GROUP_PLAYER; return(SoundPlay(szSoundEffects[usNum], &spParms)); @@ -466,6 +467,7 @@ UINT32 PlayJA2StreamingSample( UINT32 usNum, UINT32 usRate, UINT32 ubVolume, UIN return(SoundPlayStreamedFile(szSoundEffects[usNum], &spParms)); } + UINT32 PlayJA2SampleFromFile( STR8 szFileName, UINT32 usRate, UINT32 ubVolume, UINT32 ubLoops, UINT32 uiPan ) { @@ -481,6 +483,7 @@ UINT32 PlayJA2SampleFromFile( STR8 szFileName, UINT32 usRate, UINT32 ubVolume, U spParms.uiPan = uiPan; spParms.uiPriority=GROUP_PLAYER; + //return(SoundPlay(szFileName, &spParms)); return(SoundPlay((STR) szFileName, &spParms)); } @@ -499,7 +502,7 @@ UINT32 PlayJA2StreamingSampleFromFile( STR8 szFileName, UINT32 usRate, UINT32 ub spParms.uiLoop = ubLoops; spParms.uiPan = uiPan; spParms.uiPriority=GROUP_PLAYER; - spParms.EOSCallback=EndsCallback; + spParms.EOSCallback=EndsCallback; return( SoundPlayStreamedFile(szFileName, &spParms) ); } @@ -507,7 +510,7 @@ UINT32 PlayJA2StreamingSampleFromFile( STR8 szFileName, UINT32 usRate, UINT32 ub UINT32 PlayJA2Ambient( UINT32 usNum, UINT32 ubVolume, UINT32 ubLoops) { -SOUNDPARMS spParms; + SOUNDPARMS spParms; memset(&spParms, 0xff, sizeof(SOUNDPARMS)); @@ -557,7 +560,7 @@ UINT32 PlaySoldierJA2Sample( UINT16 usID, UINT32 usNum, UINT32 usRate, UINT32 ub void SetSpeechVolume( UINT32 uiNewVolume ) { - guiSpeechVolume = __min( uiNewVolume, 127); + guiSpeechVolume = __min( uiNewVolume, 127); } @@ -570,7 +573,7 @@ UINT32 GetSpeechVolume( ) void SetSoundEffectsVolume( UINT32 uiNewVolume ) { - guiSoundEffectsVolume = __min( uiNewVolume, 127); + guiSoundEffectsVolume = __min( uiNewVolume, 127); } @@ -626,12 +629,13 @@ int x,dif,absDif; } #endif -INT8 SoundDir( INT16 sGridNo ) +// == Lesh slightly changed this function ============ +INT32 SoundDir( INT16 sGridNo ) { INT16 sWorldX, sWorldY; INT16 sScreenX, sScreenY; - INT16 sMiddleX; - INT16 sDif, sAbsDif; + INT16 sMiddleX; + INT16 sDif, sAbsDif; if ( sGridNo == NOWHERE ) { @@ -650,23 +654,21 @@ INT8 SoundDir( INT16 sGridNo ) sDif = sMiddleX - sScreenX; if ( ( sAbsDif = abs( sDif ) ) > 64 ) - { + { // OK, NOT the middle. - // Is it outside the screen? if ( sAbsDif > ( ( gsBottomRightWorldX - gsTopLeftWorldX ) / 2 ) ) - { + { // yes, outside... if ( sDif > 0 ) { - //return( FARLEFT ); - return( 1 ); + return( FARLEFT ); + //return( 1 ); } - else - //return( FARRIGHT ); - return( 126 ); - - } + else + return( FARRIGHT ); + //return( 126 ); + } else // inside screen { if ( sDif > 0) @@ -674,13 +676,13 @@ INT8 SoundDir( INT16 sGridNo ) else return( RIGHTSIDE ); } - } + } else // hardly any difference, so sound should be played from middle return(MIDDLE); } -INT8 SoundVolume( INT8 bInitialVolume, INT16 sGridNo ) +INT32 SoundVolume( INT8 bInitialVolume, INT16 sGridNo ) { INT16 sWorldX, sWorldY; INT16 sScreenX, sScreenY; @@ -688,10 +690,10 @@ INT8 SoundVolume( INT8 bInitialVolume, INT16 sGridNo ) INT16 sDifX, sAbsDifX; INT16 sDifY, sAbsDifY; - if ( sGridNo == NOWHERE ) - { - return( bInitialVolume ); - } + if ( sGridNo == NOWHERE ) + { + return( bInitialVolume ); + } // OK, get screen position of gridno..... ConvertGridNoToXY( sGridNo, &sWorldX, &sWorldY ); @@ -710,17 +712,15 @@ INT8 SoundVolume( INT8 bInitialVolume, INT16 sGridNo ) sAbsDifY = abs( sDifY ); if ( sAbsDifX > 64 || sAbsDifY > 64 ) - { + { // OK, NOT the middle. - // Is it outside the screen? if ( sAbsDifX > ( ( gsBottomRightWorldX - gsTopLeftWorldX ) / 2 ) || sAbsDifY > ( ( gsBottomRightWorldY - gsTopLeftWorldY ) / 2 ) ) - { + { return( __max( LOWVOLUME, ( bInitialVolume - SOUND_FAR_VOLUME_MOD ) ) ); + } } - } - return( bInitialVolume ); } @@ -940,7 +940,8 @@ void SetPositionSndsInActive( ) } } -INT8 PositionSoundDir( INT16 sGridNo ) +// == Lesh slightly changed this function ============ +INT32 PositionSoundDir( INT16 sGridNo ) { INT16 sWorldX, sWorldY; INT16 sScreenX, sScreenY; @@ -973,12 +974,12 @@ INT8 PositionSoundDir( INT16 sGridNo ) // yes, outside... if ( sDif > 0 ) { - //return( FARLEFT ); - return( 1 ); + return( FARLEFT ); + //return( 1 ); } else - //return( FARRIGHT ); - return( 126 ); + return( FARRIGHT ); + //return( 126 ); } else // inside screen @@ -994,7 +995,7 @@ INT8 PositionSoundDir( INT16 sGridNo ) } -INT8 PositionSoundVolume( INT8 bInitialVolume, INT16 sGridNo ) +INT32 PositionSoundVolume( INT8 bInitialVolume, INT16 sGridNo ) { INT16 sWorldX, sWorldY; INT16 sScreenX, sScreenY; @@ -1079,15 +1080,16 @@ void SetPositionSndsVolumeAndPanning( ) } } - //if the sound is from a stationay object - if( pPositionSnd->uiFlags & POSITION_SOUND_STATIONATY_OBJECT ) - { - // make sure you can always hear it - if ( bVolume < 5 ) - { - bVolume = 5; - } - } + //if the sound is from a stationay object + if( pPositionSnd->uiFlags & POSITION_SOUND_STATIONATY_OBJECT ) + { + // make sure you can always hear it + if ( bVolume < 5 ) + { + bVolume = 5; + } + } + SoundSetVolume( pPositionSnd->iSoundSampleID, bVolume ); bPan = PositionSoundDir( pPositionSnd->sGridNo ); diff --git a/Utils/Sound Control.h b/Utils/Sound Control.h index 8f2161a1..203c5d9f 100644 --- a/Utils/Sound Control.h +++ b/Utils/Sound Control.h @@ -1,31 +1,36 @@ +/* + * ChangeLog: + * 11.12.2005 Lesh changed balance settings + */ #ifndef SOUND_CONTROL_H #define SOUND_CONTROL_H - +// == Lesh modifications ====== #define FARLEFT 0 -#define LEFTSIDE 48 -#define MIDDLE 64 -#define MIDDLEPAN 64 -#define RIGHTSIDE 80 -#define FARRIGHT 127 +#define LEFTSIDE 96 +#define MIDDLE 128 +#define MIDDLEPAN 128 +#define RIGHTSIDE 160 +#define FARRIGHT 255 +// == Lesh modifications ends = + +#define LOWVOLUME 25 +#define BTNVOLUME 40 +#define MIDVOLUME 65 +#define HIGHVOLUME 127 -#define LOWVOLUME 25 -#define BTNVOLUME 40 -#define MIDVOLUME 65 -#define HIGHVOLUME 127 +#define RATE_11025 0xffffffff -#define RATE_11025 0xffffffff - - -#define LOOPING 0 +#define LOOPING 0 // sound group priorities (higher = more important) -#define GROUP_PLAYER 1000 -#define GROUP_AMBIENT 0 +#define GROUP_PLAYER 1000 +#define GROUP_AMBIENT 0 -#define MAX_SAMPLES 10000 + +#define MAX_SAMPLES 5000 // SOUNDS ENUMERATION @@ -207,7 +212,7 @@ enum SoundDefines S_THROWKNIFE, S_TANK_CANNON, S_BURSTTYPE1, - S_AUTOMAG, + S_AUTOMAG, S_SILENCER_1, S_SILENCER_2, @@ -310,73 +315,73 @@ enum SoundDefines SWIM_2, KEY_FAILURE, TARGET_OUT_OF_RANGE, - OPEN_STATUE, - USE_STATUE_REMOTE, - USE_WIRE_CUTTERS, - DRINK_CANTEEN_FEMALE, - BLOODCAT_ATTACK, - BLOODCAT_ROAR, - ROBOT_GREETING, - ROBOT_DEATH, - GAS_EXPLODE_1, - AIR_ESCAPING_1, + OPEN_STATUE, + USE_STATUE_REMOTE, + USE_WIRE_CUTTERS, + DRINK_CANTEEN_FEMALE, + BLOODCAT_ATTACK, + BLOODCAT_ROAR, + ROBOT_GREETING, + ROBOT_DEATH, + GAS_EXPLODE_1, + AIR_ESCAPING_1, - OPEN_DRAWER, - CLOSE_DRAWER, - OPEN_LOCKER, - CLOSE_LOCKER, - OPEN_WOODEN_BOX, - CLOSE_WOODEN_BOX, - ROBOT_STOP, + OPEN_DRAWER, + CLOSE_DRAWER, + OPEN_LOCKER, + CLOSE_LOCKER, + OPEN_WOODEN_BOX, + CLOSE_WOODEN_BOX, + ROBOT_STOP, WATER_WALK1_IN, WATER_WALK1_OUT, WATER_WALK2_IN, WATER_WALK2_OUT, - PRONE_UP_SOUND, - PRONE_DOWN_SOUND, - KNEEL_UP_SOUND, - KNEEL_DOWN_SOUND, - PICKING_SOMETHING_UP, + PRONE_UP_SOUND, + PRONE_DOWN_SOUND, + KNEEL_UP_SOUND, + KNEEL_DOWN_SOUND, + PICKING_SOMETHING_UP, - COW_FALL, + COW_FALL, - BLOODCAT_GROWL_1, - BLOODCAT_GROWL_2, - BLOODCAT_GROWL_3, - BLOODCAT_GROWL_4, - CREATURE_GAS_NOISE, - CREATURE_FALL_PART_2, - CREATURE_DISSOLVE_1, - QUEEN_AMBIENT_NOISE, - CREATURE_FALL, - CROW_PECKING_AT_FLESH, - CROW_FLYING_AWAY, - SLAP_2, - MORTAR_START, - MORTAR_WHISTLE, - MORTAR_LOAD, + BLOODCAT_GROWL_1, + BLOODCAT_GROWL_2, + BLOODCAT_GROWL_3, + BLOODCAT_GROWL_4, + CREATURE_GAS_NOISE, + CREATURE_FALL_PART_2, + CREATURE_DISSOLVE_1, + QUEEN_AMBIENT_NOISE, + CREATURE_FALL, + CROW_PECKING_AT_FLESH, + CROW_FLYING_AWAY, + SLAP_2, + MORTAR_START, + MORTAR_WHISTLE, + MORTAR_LOAD, - TURRET_MOVE, - TURRET_STOP, - COW_FALL_2, - KNIFE_IMPACT, - EXPLOSION_ALT_BLAST_1, - EXPLOSION_BLAST_2, - DRINK_CANTEEN_MALE, - USE_X_RAY_MACHINE, - CATCH_OBJECT, - FENCE_OPEN, + TURRET_MOVE, + TURRET_STOP, + COW_FALL_2, + KNIFE_IMPACT, + EXPLOSION_ALT_BLAST_1, + EXPLOSION_BLAST_2, + DRINK_CANTEEN_MALE, + USE_X_RAY_MACHINE, + CATCH_OBJECT, + FENCE_OPEN, + + //MADD MARKER + S_BARRETT, + S_VAL, + //BREAK_LIGHT_IGNITING, - //MADD MARKER - S_BARRETT, - S_VAL, -// BREAK_LIGHT_IGNITING, NUM_SAMPLES }; - enum AmbientDefines { LIGHTNING_1 = 0, @@ -411,7 +416,6 @@ UINT32 PlayJA2Sample( UINT32 usNum, UINT32 usRate, UINT32 ubVolume, UINT32 ubLoo UINT32 PlayJA2StreamingSample( UINT32 usNum, UINT32 usRate, UINT32 ubVolume, UINT32 ubLoops, UINT32 uiPan ); UINT32 PlayJA2SampleFromFile( STR8 szFileName, UINT32 usRate, UINT32 ubVolume, UINT32 ubLoops, UINT32 uiPan ); - UINT32 PlayJA2StreamingSampleFromFile( STR8 szFileName, UINT32 usRate, UINT32 ubVolume, UINT32 ubLoops, UINT32 uiPan, SOUND_STOP_CALLBACK EndsCallback ); UINT32 PlayJA2Ambient( UINT32 usNum, UINT32 ubVolume, UINT32 ubLoops); @@ -422,10 +426,10 @@ UINT32 PlaySoldierJA2Sample( UINT16 usID, UINT32 usNum, UINT32 usRate, UINT32 ub UINT32 GetSoundEffectsVolume( ); -void SetSoundEffectsVolume( UINT32 uiNewVolume ); +void SetSoundEffectsVolume( UINT32 uiNewVolume ); UINT32 GetSpeechVolume( ); -void SetSpeechVolume( UINT32 uiNewVolume ); +void SetSpeechVolume( UINT32 uiNewVolume ); //Calculates a volume based on the current Speech Volume level @@ -435,8 +439,8 @@ UINT32 CalculateSpeechVolume( UINT32 uiVolume ); //Calculates a volume based on the current Sound Effects Volume level UINT32 CalculateSoundEffectsVolume( UINT32 uiVolume ); -INT8 SoundDir( INT16 sGridNo ); -INT8 SoundVolume( INT8 bInitialVolume, INT16 sGridNo ); +INT32 SoundDir( INT16 sGridNo ); +INT32 SoundVolume( INT8 bInitialVolume, INT16 sGridNo ); // ATE: Warning! Use this sparingly! NOT very robust - can // have only 1 delayed sound at a time, and uses the global custom @@ -445,7 +449,7 @@ void PlayDelayedJA2Sample( UINT32 uiDelay, UINT32 usNum, UINT32 usRate, UINT32 u #define POSITION_SOUND_FROM_SOLDIER 0x00000001 -#define POSITION_SOUND_STATIONATY_OBJECT 0x00000002 +#define POSITION_SOUND_STATIONATY_OBJECT 0x00000002 INT32 NewPositionSnd( INT16 sGridNo, UINT32 uiFlags, UINT32 uiData, UINT32 iSoundToPlay ); void DeletePositionSnd( INT32 iPositionSndIndex ); diff --git a/Utils/Utils.vcproj b/Utils/Utils.vcproj index 3baae2e1..da3e0d36 100644 --- a/Utils/Utils.vcproj +++ b/Utils/Utils.vcproj @@ -966,6 +966,9 @@ BrowseInformation="1"/> + + + + @@ -3140,10 +3146,6 @@ RelativePath="Utils All.h"> - - diff --git a/fmodvc.lib b/fmodvc.lib new file mode 100644 index 00000000..b3c9fd9a Binary files /dev/null and b/fmodvc.lib differ