2024-01-07 19:47:58 +01:00
|
|
|
/*
|
|
|
|
===========================================================================
|
|
|
|
Copyright (C) 2024 the OpenMoHAA team
|
|
|
|
|
|
|
|
This file is part of OpenMoHAA source code.
|
|
|
|
|
|
|
|
OpenMoHAA source code is free software; you can redistribute it
|
|
|
|
and/or modify it under the terms of the GNU General Public License as
|
|
|
|
published by the Free Software Foundation; either version 2 of the License,
|
|
|
|
or (at your option) any later version.
|
|
|
|
|
|
|
|
OpenMoHAA source code is distributed in the hope that it will be
|
|
|
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with OpenMoHAA source code; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
===========================================================================
|
|
|
|
*/
|
|
|
|
|
2024-01-07 23:36:45 +01:00
|
|
|
#pragma once
|
|
|
|
|
2024-01-07 19:47:58 +01:00
|
|
|
#include "../qcommon/q_shared.h"
|
|
|
|
#include "../qcommon/qcommon.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2024-01-09 23:28:28 +01:00
|
|
|
extern cvar_t *s_volume;
|
2024-01-08 23:15:09 +01:00
|
|
|
extern cvar_t *s_khz;
|
2024-01-10 23:02:30 +01:00
|
|
|
extern cvar_t *s_loadas8bit;
|
2024-01-08 23:15:09 +01:00
|
|
|
|
2024-01-07 19:47:58 +01:00
|
|
|
typedef struct {
|
|
|
|
int format;
|
|
|
|
float rate;
|
|
|
|
|
|
|
|
float width;
|
|
|
|
int channels;
|
|
|
|
int samples;
|
|
|
|
|
|
|
|
int dataofs;
|
|
|
|
int datasize;
|
|
|
|
} wavinfo_t;
|
|
|
|
|
|
|
|
typedef struct sfx_s {
|
|
|
|
int iFlags;
|
|
|
|
|
|
|
|
int length;
|
|
|
|
int width;
|
|
|
|
byte *data;
|
|
|
|
char name[64];
|
|
|
|
|
|
|
|
int registration_sequence;
|
|
|
|
int sfx_info_index;
|
|
|
|
float time_length;
|
|
|
|
|
|
|
|
wavinfo_t info;
|
|
|
|
unsigned int buffer;
|
|
|
|
} sfx_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
unsigned short wFormatTag;
|
|
|
|
unsigned short nChannels;
|
|
|
|
unsigned int nSamplesPerSec;
|
|
|
|
unsigned int nAvgBytesPerSec;
|
|
|
|
unsigned short nBlockAlign;
|
|
|
|
unsigned short wBitsPerSample;
|
|
|
|
unsigned short cbSize;
|
|
|
|
} wavinfo_x_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char name[64];
|
|
|
|
|
|
|
|
int loop_start;
|
|
|
|
int loop_end;
|
|
|
|
|
|
|
|
int max_number_playing;
|
|
|
|
float max_factor;
|
|
|
|
} sfx_info_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
vec3_t position;
|
|
|
|
vec3_t velocity;
|
|
|
|
int time;
|
|
|
|
qboolean use_listener;
|
|
|
|
} s_entity_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char alias[32];
|
|
|
|
char path[64];
|
|
|
|
|
|
|
|
int mood_num;
|
|
|
|
int flags;
|
|
|
|
float volume;
|
|
|
|
float fadetime;
|
|
|
|
|
|
|
|
int current_pos;
|
|
|
|
int current_state;
|
|
|
|
} song_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int iFlags;
|
|
|
|
char szName[64];
|
|
|
|
} sfxsavegame_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
qboolean bPlaying;
|
|
|
|
int iStatus;
|
|
|
|
sfxsavegame_t sfx;
|
|
|
|
|
|
|
|
int iEntNum;
|
|
|
|
int iEntChannel;
|
|
|
|
vec3_t vOrigin;
|
|
|
|
float fVolume;
|
|
|
|
int iBaseRate;
|
|
|
|
float fNewPitchMult;
|
|
|
|
float fMinDist;
|
|
|
|
float fMaxDist;
|
|
|
|
|
|
|
|
int iStartTime;
|
|
|
|
int iTime;
|
|
|
|
int iNextCheckObstructionTime;
|
|
|
|
int iEndTime;
|
|
|
|
|
|
|
|
int iFlags;
|
|
|
|
int iOffset;
|
|
|
|
int iLoopCount;
|
|
|
|
} channelbasesavegame_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
channelbasesavegame_t Channels[96];
|
|
|
|
} soundsystemsavegame_t;
|
|
|
|
|
2024-01-12 00:04:20 +01:00
|
|
|
enum channel_flags_t {
|
|
|
|
CHANNEL_FLAG_PLAYABLE = 1,
|
|
|
|
CHANNEL_FLAG_LOCAL_LISTENER = 16,
|
|
|
|
CHANNEL_FLAG_NO_ENTITY = 32,
|
|
|
|
CHANNEL_FLAG_PAUSED = 64,
|
|
|
|
CHANNEL_FLAG_LOOPING = 128,
|
|
|
|
};
|
|
|
|
|
2024-01-08 19:44:04 +01:00
|
|
|
enum sfx_flags_t {
|
2024-01-12 00:04:20 +01:00
|
|
|
SFX_FLAG_DEFAULT_SOUND = 1,
|
|
|
|
SFX_FLAG_MP3 = 2,
|
|
|
|
SFX_FLAG_NO_DATA = 4,
|
|
|
|
SFX_FLAG_NO_OFFSET = 8,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum loopsound_flags_t {
|
|
|
|
LOOPSOUND_FLAG_NO_PAN = 1
|
2024-01-08 19:44:04 +01:00
|
|
|
};
|
|
|
|
|
2024-01-08 23:25:41 +01:00
|
|
|
#define MAX_SFX 1400
|
|
|
|
#define MAX_SFX_INFOS 1000
|
|
|
|
#define MAX_LOOP_SOUNDS 64
|
|
|
|
|
2024-01-10 19:32:44 +01:00
|
|
|
extern qboolean s_bLastInitSound;
|
|
|
|
extern qboolean s_bSoundStarted;
|
|
|
|
extern qboolean s_bSoundPaused;
|
|
|
|
extern qboolean s_bTryUnpause;
|
2024-01-10 23:02:30 +01:00
|
|
|
extern int s_iListenerNumber;
|
2024-01-08 23:25:41 +01:00
|
|
|
extern int number_of_sfx_infos;
|
|
|
|
extern sfx_info_t sfx_infos[];
|
2024-01-09 23:28:28 +01:00
|
|
|
extern sfx_t s_knownSfx[];
|
|
|
|
extern int s_numSfx;
|
2024-01-08 23:25:41 +01:00
|
|
|
|
2024-01-07 23:36:45 +01:00
|
|
|
// The current sound driver.
|
|
|
|
// Currently OPENAL
|
|
|
|
#define SOUND_DRIVER OPENAL
|
|
|
|
|
2024-01-09 23:28:28 +01:00
|
|
|
//
|
|
|
|
// snd_info.cpp
|
|
|
|
//
|
|
|
|
void load_sfx_info();
|
|
|
|
|
2024-01-08 19:44:04 +01:00
|
|
|
//
|
|
|
|
// snd_dma_new.cpp
|
|
|
|
//
|
|
|
|
|
2024-01-07 19:47:58 +01:00
|
|
|
sfx_t *S_FindName(const char *name, int sequenceNumber);
|
|
|
|
void S_DefaultSound(sfx_t *sfx);
|
|
|
|
|
|
|
|
void S_LoadData(soundsystemsavegame_t *pSave);
|
|
|
|
void S_SaveData(soundsystemsavegame_t *pSave);
|
|
|
|
void S_ClearSoundBuffer();
|
|
|
|
|
2024-01-08 19:44:04 +01:00
|
|
|
//
|
|
|
|
// snd_mem.c
|
|
|
|
//
|
|
|
|
qboolean S_LoadSound(const char *fileName, sfx_t *sfx, int streamed, qboolean force_load);
|
|
|
|
|
2024-01-07 19:47:58 +01:00
|
|
|
#define S_StopAllSounds2 S_StopAllSounds
|
|
|
|
|
2024-01-07 23:36:45 +01:00
|
|
|
//
|
|
|
|
// Driver-specific functions
|
|
|
|
//
|
|
|
|
#define S_Call_SndDriver(driver, func) S_##driver##_##func
|
|
|
|
#define S_Call_SndDriverX(driver, func) S_Call_SndDriver(driver, func)
|
|
|
|
|
|
|
|
#define S_Driver_Init S_Call_SndDriverX(SOUND_DRIVER, Init)
|
2024-01-08 19:44:04 +01:00
|
|
|
#define S_Driver_Shutdown S_Call_SndDriverX(SOUND_DRIVER, Shutdown)
|
2024-01-07 23:36:45 +01:00
|
|
|
#define S_Driver_StartSound S_Call_SndDriverX(SOUND_DRIVER, StartSound)
|
|
|
|
#define S_Driver_AddLoopingSound S_Call_SndDriverX(SOUND_DRIVER, AddLoopingSound)
|
|
|
|
#define S_Driver_ClearLoopingSounds S_Call_SndDriverX(SOUND_DRIVER, ClearLoopingSounds)
|
|
|
|
#define S_Driver_StopSound S_Call_SndDriverX(SOUND_DRIVER, StopSound)
|
|
|
|
#define S_Driver_StopAllSounds S_Call_SndDriverX(SOUND_DRIVER, StopAllSounds)
|
|
|
|
#define S_Driver_Respatialize S_Call_SndDriverX(SOUND_DRIVER, Respatialize)
|
|
|
|
#define S_Driver_SetReverb S_Call_SndDriverX(SOUND_DRIVER, SetReverb)
|
|
|
|
#define S_Driver_Update S_Call_SndDriverX(SOUND_DRIVER, Update)
|
|
|
|
|
2024-01-08 19:44:04 +01:00
|
|
|
void S_PrintInfo();
|
|
|
|
void S_DumpInfo();
|
|
|
|
|
|
|
|
extern cvar_t *s_show_sounds;
|
|
|
|
|
2024-01-07 19:47:58 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|