diff --git a/CMakeLists.txt b/CMakeLists.txt index 48f39608..ac6ed6c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -128,15 +128,6 @@ if (NOT BUILD_NO_CLIENT) set_target_properties(openmohaa PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}) target_link_libraries(openmohaa PRIVATE jpeg8) - if (USE_OPENAL) - # Try to use OpenAL - find_package(OpenAL) - if (OPENAL_FOUND) - target_compile_definitions(openmohaa PRIVATE USE_OPENAL=1) - target_include_directories(openmohaa PRIVATE ${OPENAL_INCLUDE_DIR}) - target_link_libraries(openmohaa PRIVATE ${OPENAL_LIBRARY}) - endif() - endif() if (MSVC) target_link_options(openmohaa PRIVATE "/MANIFEST:NO") diff --git a/code/client/CMakeLists.txt b/code/client/CMakeLists.txt index 8ba2b753..babaf736 100644 --- a/code/client/CMakeLists.txt +++ b/code/client/CMakeLists.txt @@ -8,7 +8,6 @@ file(GLOB_RECURSE SOURCES_UILIB "../uilib/*.c*") # Made as an interface and not static, as static only links used methods add_library(omohclient INTERFACE) -target_sources(omohclient INTERFACE ${SOURCES_CLIENT} ${SOURCES_UILIB}) target_compile_definitions(omohclient INTERFACE APP_MODULE) target_compile_features(omohclient INTERFACE cxx_nullptr) target_compile_features(omohclient INTERFACE c_variadic_macros) @@ -18,5 +17,33 @@ target_link_libraries(omohclient INTERFACE gcd) # Sound stuff target_compile_definitions(omohclient INTERFACE USE_CODEC_MP3) +if (USE_SOUND_NEW) + # Try to use OpenAL + find_package(OpenAL) + if (OPENAL_FOUND) + target_compile_definitions(omohclient INTERFACE USE_SOUND_NEW=1) + if (MSVC) + target_include_directories(omohclient INTERFACE ${OPENAL_INCLUDE_DIR}/AL) + else() + target_include_directories(omohclient INTERFACE ${OPENAL_INCLUDE_DIR}) + endif() + target_link_libraries(omohclient INTERFACE ${OPENAL_LIBRARY}) + endif() + + list(FILTER SOURCES_CLIENT EXCLUDE REGEX "./snd_([a-zA-Z0-9_]+)\.c$") +endif() + +if (USE_OPENAL) + # Try to use OpenAL + find_package(OpenAL) + if (OPENAL_FOUND) + target_compile_definitions(omohclient INTERFACE USE_OPENAL=1) + target_include_directories(omohclient INTERFACE ${OPENAL_INCLUDE_DIR}/AL) + target_link_libraries(omohclient INTERFACE ${OPENAL_LIBRARY}) + endif() +endif() + +target_sources(omohclient INTERFACE ${SOURCES_CLIENT} ${SOURCES_UILIB}) + add_subdirectory("../libmad-0.15.1b" "./libmad") target_link_libraries(omohclient INTERFACE libmad) \ No newline at end of file diff --git a/code/client/cl_avi.cpp b/code/client/cl_avi.cpp index a6e018f0..051599a3 100644 --- a/code/client/cl_avi.cpp +++ b/code/client/cl_avi.cpp @@ -334,6 +334,9 @@ writing the actual data can begin */ qboolean CL_OpenAVIForWriting( const char *fileName ) { + return qfalse; + // Removed in OPM +#if 0 if( afd.fileOpen ) return qfalse; @@ -425,6 +428,7 @@ qboolean CL_OpenAVIForWriting( const char *fileName ) afd.fileOpen = qtrue; return qtrue; +#endif } /* diff --git a/code/client/cl_cin.cpp b/code/client/cl_cin.cpp index 0150222a..38d7a0d6 100644 --- a/code/client/cl_cin.cpp +++ b/code/client/cl_cin.cpp @@ -1091,6 +1091,8 @@ static void RoQReset( void ) { static void RoQInterrupt(void) { + // Removed in OPM +#if 0 byte *framedata; short sbuf[32768]; int ssize; @@ -1214,6 +1216,7 @@ redump: // assert(cinTable[currentHandle].RoQFrameSize <= 65536); // r = FS_Read( cin.file, cinTable[currentHandle].RoQFrameSize+8, cinTable[currentHandle].iFile ); cinTable[currentHandle].RoQPlayed += cinTable[currentHandle].RoQFrameSize+8; +#endif } /****************************************************************************** @@ -1397,6 +1400,9 @@ CIN_PlayCinematic ================== */ int CIN_PlayCinematic( const char *arg, int x, int y, int w, int h, int systemBits ) { + return 0; + // Removed in OPM +#if 0 unsigned short RoQID; char name[MAX_OSPATH]; int i; @@ -1478,6 +1484,7 @@ int CIN_PlayCinematic( const char *arg, int x, int y, int w, int h, int systemBi RoQShutdown(); return -1; +#endif } void CIN_SetExtents (int handle, int x, int y, int w, int h) { diff --git a/code/client/cl_main.cpp b/code/client/cl_main.cpp index 7f90dd3c..5f836f81 100644 --- a/code/client/cl_main.cpp +++ b/code/client/cl_main.cpp @@ -769,7 +769,9 @@ void CL_ShutdownAll(qboolean shutdownRef) { CL_cURL_Shutdown(); #endif // clear sounds +#if !defined(USE_SOUND_NEW) || !USE_SOUND_NEW S_DisableSounds(); +#endif // shutdown CGame CL_ShutdownCGame(); // shutdown UI @@ -1547,7 +1549,11 @@ void CL_Vid_Restart_f( void ) { SV_FinishSvsTimeFixups(); +#if !defined(USE_SOUND_NEW) || !USE_SOUND_NEW S_Init(); +#else + S_Init(qtrue); +#endif if (clc.state > CA_CONNECTED && clc.state != CA_CINEMATIC) { @@ -1569,8 +1575,13 @@ handles will be invalid ================= */ void CL_Snd_Restart_f( void ) { +#if !defined(USE_SOUND_NEW) || !USE_SOUND_NEW S_Shutdown(); S_Init(); +#else + S_Shutdown(qfalse); + S_Init(qfalse); +#endif CL_Vid_Restart_f(); } @@ -3387,7 +3398,9 @@ void CL_Init( void ) { Cvar_Set( "cl_running", "1" ); +#if !defined(USE_SOUND_NEW) || !USE_SOUND_NEW S_Init2(); +#endif // fixme: should we leave it? CL_GenerateQKey(); @@ -3428,7 +3441,11 @@ void CL_Shutdown(const char* finalmsg, qboolean disconnect, qboolean quit) { if(disconnect) CL_Disconnect(); +#if !defined(USE_SOUND_NEW) || !USE_SOUND_NEW S_Shutdown(); +#else + S_Shutdown(qtrue); +#endif CL_ShutdownRef(); CL_ShutdownUI(); diff --git a/code/client/new/snd_main_new.cpp b/code/client/new/snd_main_new.cpp index 67b91156..3490119d 100644 --- a/code/client/new/snd_main_new.cpp +++ b/code/client/new/snd_main_new.cpp @@ -22,6 +22,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "../snd_local.h" +#if !defined(USE_SOUND_NEW) || !USE_SOUND_NEW + void S_Init2() { S_Init(); @@ -448,3 +450,5 @@ void S_LoadData(soundsystemsavegame_t* pSave) { void S_SaveData(soundsystemsavegame_t* pSave) { // FIXME: unimplemented } + +#endif diff --git a/code/client/snd_dma_new.cpp b/code/client/snd_dma_new.cpp new file mode 100644 index 00000000..7e6c50d4 --- /dev/null +++ b/code/client/snd_dma_new.cpp @@ -0,0 +1,231 @@ +/* +=========================================================================== +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 +=========================================================================== +*/ + +#if USE_SOUND_NEW + +# include "snd_local.h" + +typedef struct { + vec3_t origin; + vec3_t velocity; + sfx_t *sfx; + int mergeFrame; +} loopSound_t; + +# define MAX_SFX 1400 +# define MAX_SFX_INFOS 1000 +# define MAX_LOOP_SOUNDS 64 + +qboolean s_bLastInitSound = qfalse; +qboolean s_bSoundStarted = qfalse; +qboolean s_bSoundPaused = qfalse; +qboolean s_bTryUnpause = qfalse; +int s_iListenerNumber = 0; +float s_fAmbientVolume = 1.f; + +int number_of_sfx_infos = 0; + +cvar_t *s_volume; +cvar_t *s_loadas8bit; +cvar_t *s_khz; +cvar_t *s_show; +cvar_t *s_testsound; +cvar_t *s_separation; +cvar_t *s_musicVolume; +cvar_t *s_ambientVolume; + +sfx_info_t sfx_infos[MAX_SFX_INFOS]; + +sfx_t s_knownSfx[MAX_SFX]; +int s_numSfx; + +s_entity_t s_entity[MAX_GENTITIES]; + +static int s_registrationSequence; +static qboolean s_inRegistration; + +cvar_t *s_mixPreStep; +cvar_t *s_dialogscale; + +int numLoopSounds; +loopSound_t loopSounds[MAX_LOOP_SOUNDS]; + +void S_SoundInfo_f() +{ + // FIXME: unimplemented +} + +void S_SoundDump_f() +{ + // FIXME: unimplemented +} + +void S_Init(qboolean full_startup) +{ + // FIXME: unimplemented +} + +void S_Shutdown(qboolean full_shutdown) +{ + // FIXME: unimplemented +} + +qboolean S_NameExists(const char *name) +{ + // FIXME: unimplemented + return qfalse; +} + +sfx_t *S_FindName(const char *name, int sequenceNumber) +{ + // FIXME: unimplemented + return NULL; +} + +void S_BeginRegistration() +{ + // FIXME: unimplemented +} + +void S_DefaultSound(sfx_t *sfx) +{ + // FIXME: unimplemented +} + +qboolean S_IsSoundRegistered(const char *name) +{ + // FIXME: unimplemented + return qfalse; +} + +sfxHandle_t S_RegisterSound(const char *name, int streamed, qboolean force_load) +{ + // FIXME: unimplemented + return 0; +} + +float S_GetSoundTime(sfxHandle_t handle) +{ + // FIXME: unimplemented + return 0; +} + +void S_EndRegistration() +{ + // FIXME: unimplemented +} + +void S_UpdateEntity(int entityNum, const vec3_t origin, const vec3_t vel, qboolean use_listener) +{ + // FIXME: unimplemented +} + +void S_SetGlobalAmbientVolumeLevel(float volume) +{ + // FIXME: unimplemented +} + +void S_StartSound( + const vec3_t origin, + int entnum, + int entchannel, + sfxHandle_t sfxHandle, + float volume, + float min_dist, + float pitch, + float maxDist, + int streamed +) +{ + // FIXME: unimplemented +} + +void S_StartLocalSound(const char *sound_name, qboolean force_load) +{ + // FIXME: unimplemented +} + +void S_StartLocalSoundChannel(const char *sound_name, qboolean force_load, soundChannel_t channel) +{ + // FIXME: unimplemented +} + +void S_StopAllSounds(qboolean stop_music) +{ + // FIXME: unimplemented +} + +void S_ClearLoopingSounds() +{ + // FIXME: unimplemented +} + +void S_AddLoopingSound( + const vec3_t origin, + const vec3_t velocity, + sfxHandle_t sfxHandle, + float volume, + float min_dist, + float max_dist, + float pitch, + int flags +) +{ + // FIXME: unimplemented +} + +void S_Respatialize(int entityNum, const vec3_t head, vec3_t axis[3]) +{ + // FIXME: unimplemented +} + +void S_Update() +{ + // FIXME: unimplemented +} + +void S_StopSound(int entnum, int channel) +{ + // FIXME: unimplemented +} + +void S_SetReverb(int reverb_type, float reverb_level) +{ + // FIXME: unimplemented +} + +void S_Play() +{ + // FIXME: unimplemented +} + +void S_SoundList() +{ + // FIXME: unimplemented +} + +void S_ClearSoundBuffer() +{ + // TODO: Remove once AL is fully implemented +} + +#endif diff --git a/code/client/snd_local.h b/code/client/snd_local.h index d92c6700..e0ec8609 100644 --- a/code/client/snd_local.h +++ b/code/client/snd_local.h @@ -27,6 +27,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "../qcommon/qcommon.h" #include "snd_public.h" +#if !defined(USE_SOUND_NEW) || !USE_SOUND_NEW + #define PAINTBUFFER_SIZE 4096 // this is in samples #define SND_CHUNK_SIZE 1024 // samples @@ -281,3 +283,7 @@ void S_PaintChannelFrom16_altivec( portable_samplepair_t paintbuffer[PAINTBUFFER #ifdef __cplusplus } #endif + +#else +# include "snd_local_new.h" +#endif diff --git a/code/client/snd_local_new.h b/code/client/snd_local_new.h new file mode 100644 index 00000000..34355de1 --- /dev/null +++ b/code/client/snd_local_new.h @@ -0,0 +1,142 @@ +/* +=========================================================================== +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 +=========================================================================== +*/ + +#include "../qcommon/q_shared.h" +#include "../qcommon/qcommon.h" + +#ifdef __cplusplus +extern "C" { +#endif + +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; + +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(); + +#define S_StopAllSounds2 S_StopAllSounds + +#ifdef __cplusplus +} +#endif diff --git a/code/client/snd_openal_new.cpp b/code/client/snd_openal_new.cpp new file mode 100644 index 00000000..0fb82e89 --- /dev/null +++ b/code/client/snd_openal_new.cpp @@ -0,0 +1,757 @@ +/* +=========================================================================== +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 +=========================================================================== +*/ + +#if USE_SOUND_NEW + +# include "snd_local.h" +# include "snd_openal_new.h" + +typedef struct { + char *funcname; + void **funcptr; + bool required; +} extensions_table_t; + +# define MAX_MUSIC_SONGS 16 + +static int s_iNextLoopingWarning = 0; +static int s_iReverbType = 0; +static float s_fReverbLevel = 0; +static bool s_bReverbChanged = false; +static bool s_bFading = false; +static float s_fFadeVolume = 1.f; + +cvar_t *s_milesdriver; +cvar_t *s_openaldevice; +cvar_t *s_reverb; +cvar_t *s_show_cpu; +cvar_t *s_show_num_active_sounds; +cvar_t *s_show_sounds; +cvar_t *s_speaker_type; +cvar_t *s_obstruction_cal_time; +cvar_t *s_lastSoundTime; + +static float reverb_table[] = { + 0.5f, 0.25f, 0.417f, 0.653f, 0.208f, 0.5f, 0.403f, 0.5f, 0.5f, + 0.361f, 0.5f, 0.153f, 0.361f, 0.44400001f, 0.25f, 0.111f, 0.111f, 0.19400001f, + 1.0f, 0.097000003f, 0.208f, 0.65200001f, 1.0f, 0.875f, 0.139f, 0.486f, +}; + +static vec3_t vec_zero = {0, 0, 0}; +int s_iNumMilesAudioProviders = 0; +bool s_bProvidersEmunerated = false; +static bool al_initialized = false; +static bool al_use_reverb = false; +static float al_current_volume = 0; +static unsigned int al_frequency = 22050; +static void *al_context_id = NULL; +static ALCdevice *al_device = NULL; + +static ALboolean (*_alutLoadMP3_LOKI)(unsigned int buffer, const byte *data, int length); +static void (*_alReverbScale_LOKI)(); +static void (*_alReverbDelay_LOKI)(); + +static qboolean music_active = qfalse; +int music_current_mood = 0; +int music_fallback_mood = 0; +float old_music_volume = 1.f; +float music_volume = 1.f; +float new_music_volume = 1.f; +float music_volume_fade_time = 0; +long int music_volume_start_time = 0; +int music_volume_direction = 0; +int music_volume_changed = 0; +int music_loaded = 0; +int music_numsongs = 0; +int music_currentsong = 0; + +song_t music_songs[MAX_MUSIC_SONGS]; +openal_internal_t openal; +static float s_fFadeStartTime; +static float s_fFadeStopTime; +static char current_soundtrack[128]; + +static void __alDieIfError(char *file) +{ + // FIXME: unimplemented +} + +static void S_OPENAL_NukeSource(ALuint *srcptr) +{ + // FIXME: unimplemented +} + +static void S_OPENAL_NukeBuffer(ALuint *bufptr) +{ + // FIXME: unimplemented +} + +static void S_OPENAL_NukeChannel(openal_channel *channel) +{ + // FIXME: unimplemented +} + +static void S_OPENAL_NukeContext() +{ + // FIXME: unimplemented +} + +static bool S_OPENAL_InitContext() +{ + // FIXME: unimplemented + return false; +} + +static bool S_OPENAL_InitExtensions() +{ + // FIXME: unimplemented + return false; +} + +static bool S_OPENAL_InitChannel(int idx, openal_channel *chan) +{ + // FIXME: unimplemented + return false; +} + +qboolean S_OPENAL_Init() +{ + // FIXME: unimplemented + return qfalse; +} + +void S_OPENAL_Shutdown() +{ + // FIXME: unimplemented +} + +void S_FadeSound(float fTime) +{ + // FIXME: unimplemented +} + +float S_GetBaseVolume() +{ + // FIXME: unimplemented + return 0; +} + +qboolean S_NeedFullRestart() +{ + // FIXME: unimplemented + return qfalse; +} + +void S_PrintInfo() +{ + // FIXME: unimplemented +} + +static void S_DumpStatus(const char *pszChanName, int iChanNum, openal_channel *channel) +{ + // FIXME: unimplemented +} + +void S_DumpInfo() +{ + // FIXME: unimplemented +} + +static void S_OPENAL_Pitch() +{ + // FIXME: unimplemented +} + +static bool S_OPENAL_LoadMP3(const char *_path, openal_channel *chan) +{ + // FIXME: unimplemented + return false; +} + +static void S_OPENAL_PlayMP3() +{ + // FIXME: unimplemented +} + +static void S_OPENAL_StopMP3() +{ + // FIXME: unimplemented +} + +void MUSIC_Pause() +{ + // FIXME: unimplemented +} + +void MUSIC_Unpause() +{ + // FIXME: unimplemented +} + +void S_PauseSound() +{ + // FIXME: unimplemented +} + +void S_UnpauseSound() +{ + // FIXME: unimplemented +} + +static qboolean S_OPENAL_ShouldPlay(sfx_t *pSfx) +{ + // FIXME: unimplemented + return qfalse; +} + +static qboolean S_OPENAL_ShouldStart(float *vOrigin, float fMinDist, float fMaxDist) +{ + // FIXME: unimplemented + return qfalse; +} + +static int S_OPENAL_PickChannelBase(int iEntNum, int iEntChannel, int iFirstChannel, int iLastChannel) +{ + // FIXME: unimplemented + return 0; +} + +static int S_OPENAL_PickChannel3D(int iEntNum, int iEntChannel) +{ + // FIXME: unimplemented + return 0; +} + +static int S_OPENAL_PickChannel2D(int iEntNum, int iEntChannel) +{ + // FIXME: unimplemented + return 0; +} + +static int S_OPENAL_PickChannel2DStreamed(int iEntNum, int iEntChannel) +{ + // FIXME: unimplemented + return 0; +} + +void callbackServer(int entnum, int channel_number, const char *name) +{ + // FIXME: unimplemented +} + +static void S_OPENAL_Start2DSound( + float *vOrigin, + int iEntNum, + int iEntChannel, + sfx_t *pSfx, + float fVolume, + float fMinDistance, + float fPitch, + float fMaxDistance +) +{ + // FIXME: unimplemented +} + +void S_OPENAL_StartSound( + float *vOrigin, + int iEntNum, + int iEntChannel, + sfxHandle_t sfxHandle, + float fVolume, + float fMinDist, + float fPitch, + float fMaxDist, + qboolean bStreamed +) +{ + // FIXME: unimplemented +} + +void S_OPENAL_AddLoopingSound( + float *vOrigin, + float *vVelocity, + sfxHandle_t sfxHandle, + float fVolume, + float fMinDist, + float fMaxDist, + float fPitch, + int iFlags +) +{ + // FIXME: unimplemented +} + +void S_OPENAL_StopLoopingSound(openal_loop_sound_t *pLoopSound) +{ + // FIXME: unimplemented +} + +void S_OPENAL_ClearLoopingSounds() +{ + // FIXME: unimplemented +} + +void S_OPENAL_StopLoopingSounds() +{ + // FIXME: unimplemented +} + +void S_OPENAL_StopSound(int iEntNum) +{ + // FIXME: unimplemented +} + +void S_OPENAL_StopAllSounds(qboolean bStopMusic) +{ + // FIXME: unimplemented +} + +static int S_OPENAL_Start2DLoopSound( + openal_loop_sound_t *pLoopSound, float fVolume, float fVolumeToPlay, float fMinDistance, float *vLoopOrigin +) +{ + // FIXME: unimplemented + return 0; +} + +static int S_OPENAL_Start3DLoopSound( + openal_loop_sound_t *pLoopSound, + float fVolumeToPlay, + float fMinDistance, + float fMaxDistance, + float *vLoopOrigin, + float *vListenerOrigin +) +{ + // FIXME: unimplemented + return 0; +} + +static bool S_OPENAL_UpdateLoopSound( + openal_loop_sound_t *pLoopSound, + float fVolumeToPlay, + float fMinDistance, + float fMaxDistance, + float *vListenerOrigin, + float *vTempAxis, + float *vLoopOrigin +) +{ + // FIXME: unimplemented + return false; +} + +void S_OPENAL_AddLoopSounds(float *vTempAxis) +{ + // FIXME: unimplemented +} + +void S_OPENAL_Respatialize(int iEntNum, float *vHeadPos, float (*vAxis)[3]) +{ + // FIXME: unimplemented +} + +static int S_OPENAL_SpatializeStereoSound(float *listener_origin, float *listener_left, float *origin) +{ + // FIXME: unimplemented + return 0; +} + +static void S_OPENAL_reverb(int iChannel, int iReverbType, float fReverbLevel) +{ + // FIXME: unimplemented +} + +void S_OPENAL_SetReverb(int iType, float fLevel) +{ + // FIXME: unimplemented +} + +void S_OPENAL_Update() +{ + // FIXME: unimplemented +} + +qboolean S_IsSoundPlaying(int channel_number, const char *sfxName) +{ + // FIXME: unimplemented + return qfalse; +} + +static void S_StoreBase(channelbasesavegame_t *pBase, openal_channel *pChannel) +{ + // FIXME: unimplemented +} + +static void +S_StartSoundFromBase(channelbasesavegame_t *pBase, openal_channel *pChannel, sfx_t *pSfx, bool bStartUnpaused) +{ + // FIXME: unimplemented +} + +static void S_LoadBase(channelbasesavegame_t *pBase, openal_channel *pChannel, bool bStartUnpaused) +{ + // FIXME: unimplemented +} + +void S_SaveData(soundsystemsavegame_t *pSave) +{ + // FIXME: unimplemented +} + +void S_ReLoad(soundsystemsavegame_t *pSave) +{ + // FIXME: unimplemented +} + +static void S_InitBase(channelbasesavegame_t *pBase) +{ + // FIXME: unimplemented +} + +void S_LoadData(soundsystemsavegame_t *pSave) +{ + // FIXME: unimplemented +} + +void openal_channel::set_velocity(float v0, float v1, float v2) +{ + // FIXME: unimplemented +} + +void openal_channel::set_position(float v0, float v1, float v2) +{ + // FIXME: unimplemented +} + +void openal_channel::set_gain(float gain) +{ + // FIXME: unimplemented +} + +void openal_channel::set_no_3d() +{ + // FIXME: unimplemented +} + +void openal_channel::set_3d() +{ + // FIXME: unimplemented +} + +void openal_channel::play() +{ + // FIXME: unimplemented +} + +void openal_channel::pause() +{ + // FIXME: unimplemented +} + +void openal_channel::stop() +{ + // FIXME: unimplemented +} + +ALint openal_channel::get_state() +{ + // FIXME: unimplemented + return 0; +} + +bool openal_channel::is_free() +{ + // FIXME: unimplemented + return false; +} + +bool openal_channel::is_paused() +{ + // FIXME: unimplemented + return false; +} + +bool openal_channel::is_playing() +{ + // FIXME: unimplemented + return false; +} + +void openal_channel::force_free() +{ + // FIXME: unimplemented +} + +bool openal_channel::set_sfx(sfx_t *pSfx) +{ + // FIXME: unimplemented + return false; +} + +void openal_channel::start_sample() +{ + // FIXME: unimplemented +} + +void openal_channel::stop_sample() +{ + // FIXME: unimplemented +} + +void openal_channel::resume_sample() +{ + // FIXME: unimplemented +} + +void openal_channel::end_sample() +{ + // FIXME: unimplemented +} + +void openal_channel::set_sample_pan(S32 pan) +{ + // FIXME: unimplemented +} + +void openal_channel::set_sample_playback_rate(S32 rate) +{ + // FIXME: unimplemented +} + +S32 openal_channel::sample_playback_rate() +{ + // FIXME: unimplemented + return 0; +} + +S32 openal_channel::sample_volume() +{ + // FIXME: unimplemented + return 0; +} + +U32 openal_channel::sample_offset() +{ + // FIXME: unimplemented + return 0; +} + +U32 openal_channel::sample_ms_offset() +{ + // FIXME: unimplemented + return 0; +} + +U32 openal_channel::sample_loop_count() +{ + // FIXME: unimplemented + return 0; +} + +void openal_channel::set_sample_offset(U32 offset) +{ + // FIXME: unimplemented +} + +void openal_channel::set_sample_ms_offset(U32 offset) +{ + // FIXME: unimplemented +} + +void openal_channel::set_sample_loop_count(S32 count) +{ + // FIXME: unimplemented +} + +void openal_channel::set_sample_loop_block(S32 start_offset, S32 end_offset) +{ + // FIXME: unimplemented +} + +U32 openal_channel::sample_status() +{ + // FIXME: unimplemented + return 0; +} + +qboolean MUSIC_LoadSoundtrackFile(const char *filename) +{ + // FIXME: unimplemented + return qfalse; +} + +qboolean MUSIC_SongValid(const char *mood) +{ + // FIXME: unimplemented + return qfalse; +} + +qboolean MUSIC_Loaded() +{ + // FIXME: unimplemented + return qfalse; +} + +void Music_Update() +{ + // FIXME: unimplemented +} + +void MUSIC_SongEnded() +{ + // FIXME: unimplemented +} + +void MUSIC_NewSoundtrack(const char *name) +{ + // FIXME: unimplemented +} + +void MUSIC_UpdateMood(int current, int fallback) +{ + // FIXME: unimplemented +} + +void MUSIC_UpdateVolume(float volume, float fade_time) +{ + // FIXME: unimplemented +} + +void MUSIC_StopAllSongs() +{ + // FIXME: unimplemented +} + +void MUSIC_FreeAllSongs() +{ + // FIXME: unimplemented +} + +qboolean MUSIC_Playing() +{ + // FIXME: unimplemented + return qfalse; +} + +int MUSIC_FindSong(const char *name) +{ + // FIXME: unimplemented + return 0; +} + +void S_loadsoundtrack() +{ + // FIXME: unimplemented +} + +const char *S_CurrentSoundtrack() +{ + // FIXME: unimplemented + return NULL; +} + +void S_PlaySong() +{ + // FIXME: unimplemented +} + +int MUSIC_CurrentSongChannel() +{ + // FIXME: unimplemented + return 0; +} + +void MUSIC_StopChannel(int channel_number) +{ + // FIXME: unimplemented +} + +qboolean MUSIC_PlaySong(const char *alias) +{ + // FIXME: unimplemented + return qfalse; +} + +void MUSIC_UpdateMusicVolumes() +{ + // FIXME: unimplemented +} + +void MUSIC_CheckForStoppedSongs() +{ + // FIXME: unimplemented +} + +void S_TriggeredMusic_SetupHandle(const char *pszName, int iLoopCount, int iOffset, qboolean autostart) +{ + // FIXME: unimplemented +} + +void S_TriggeredMusic_Start() +{ + // FIXME: unimplemented +} + +void S_TriggeredMusic_StartLoop() +{ + // FIXME: unimplemented +} + +void S_TriggeredMusic_Stop() +{ + // FIXME: unimplemented +} + +void S_TriggeredMusic_Pause() +{ + // FIXME: unimplemented +} + +void S_TriggeredMusic_Unpause() +{ + // FIXME: unimplemented +} + +void S_TriggeredMusic_PlayIntroMusic() +{ + // FIXME: unimplemented +} + +void S_StopMovieAudio() +{ + // FIXME: unimplemented +} + +void S_SetupMovieAudio(const char *pszMovieName) +{ + // FIXME: unimplemented +} + +int S_CurrentMoviePosition() +{ + // FIXME: unimplemented + return 0; +} + +#endif diff --git a/code/client/snd_openal_new.h b/code/client/snd_openal_new.h new file mode 100644 index 00000000..37dcaa25 --- /dev/null +++ b/code/client/snd_openal_new.h @@ -0,0 +1,129 @@ +/* +=========================================================================== +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 +=========================================================================== +*/ + +#include "qal.h" + +typedef int S32; +typedef unsigned int U32; + +typedef enum { + FADE_NONE, + FADE_IN, + FADE_OUT +} fade_t; + +typedef struct { + vec3_t vOrigin; + vec3_t vRelativeOrigin; + vec3_t vVelocity; + sfx_t *pSfx; + qboolean bPlaying; + int iChannel; + float fVolume; + float fPitch; + int iStartTime; + qboolean bInUse; + qboolean bCombine; + float fBaseVolume; + float fMinDist; + float fMaxDist; + int iFlags; +} openal_loop_sound_t; + +struct openal_channel { + sfx_t *pSfx; + int iEntNum; + int iEntChannel; + vec3_t vOrigin; + float fVolume; + int iBaseRate; + float fNewPitchMult; + float fMinDist; + float fMaxDist; + int iStartTime; + int iTime; + int iEndTime; + int iFlags; + int iPausedOffset; + int song_number; + fade_t fading; + int fade_time; + int fade_start_time; + ALuint source; + ALuint buffer; + ALubyte *bufferdata; + + void play(); + void stop(); + void pause(); + + void set_no_3d(); + void set_3d(); + ALint get_state(); + + void set_gain(float gain); + void set_velocity(float v0, float v1, float v2); + void set_position(float v0, float v1, float v2); + + bool is_free(); + bool is_paused(); + bool is_playing(); + + void force_free(); + bool set_sfx(sfx_t *pSfx); + + void start_sample(); + void stop_sample(); + void resume_sample(); + void end_sample(); + + void set_sample_pan(S32 pan); + void set_sample_playback_rate(S32 pan); + S32 sample_playback_rate(); + + S32 sample_volume(); + U32 sample_offset(); + U32 sample_ms_offset(); + U32 sample_loop_count(); + void set_sample_offset(U32 offset); + void set_sample_ms_offset(U32 offset); + void set_sample_loop_count(S32 count); + void set_sample_loop_block(S32 start_offset, S32 end_offset); + + U32 sample_status(); +}; + +struct openal_internal_t { + openal_channel chan_3D[32]; + openal_channel chan_2D[32]; + openal_channel chan_2D_stream[32]; + openal_channel chan_song[2]; + openal_channel chan_mp3; + openal_channel chan_trig_music; + openal_channel chan_movie; + openal_channel *channel[101]; + openal_loop_sound_t loop_sounds[64]; + openal_channel movieChannel; + sfx_t movieSFX; + char tm_filename[64]; + int tm_loopcount; +}; diff --git a/code/client/snd_public.h b/code/client/snd_public.h index e37453f4..ce3069bf 100644 --- a/code/client/snd_public.h +++ b/code/client/snd_public.h @@ -20,6 +20,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ +#if !defined(USE_SOUND_NEW) || !USE_SOUND_NEW + #ifdef __cplusplus extern "C" { #endif @@ -89,3 +91,74 @@ void S_MasterGain(float gain); #endif #include "new/snd_public_new.h" + +#else + +#ifdef __cplusplus +extern "C" { +#endif + +void S_SoundInfo_f(); +void S_SoundDump_f(); +void S_Init(qboolean full_startup); +void S_Shutdown(qboolean full_shutdown); +qboolean S_NameExists(const char* name); +void S_BeginRegistration(); +qboolean S_IsSoundRegistered(const char* name); +sfxHandle_t S_RegisterSound(const char* name, int streamed, qboolean force_load); +float S_GetSoundTime(sfxHandle_t handle); +void S_EndRegistration(); +void S_UpdateEntity(int entityNum, const vec3_t origin, const vec3_t vel, qboolean use_listener); +void S_SetGlobalAmbientVolumeLevel(float volume); +void S_StartSound(const vec3_t origin, int entnum, int entchannel, sfxHandle_t sfxHandle, float volume, float min_dist, float pitch, float maxDist, int streamed); +void S_StartLocalSound(const char* sound_name, qboolean force_load); +void S_StartLocalSoundChannel(const char* sound_name, qboolean force_load, soundChannel_t channel); +void S_StopAllSounds(qboolean stop_music); +void S_ClearLoopingSounds(); +void S_AddLoopingSound(const vec3_t origin, const vec3_t velocity, sfxHandle_t sfxHandle, float volume, float min_dist, float max_dist, float pitch, int flags); +void S_Respatialize(int entityNum, const vec3_t head, vec3_t axis[3]); +void S_Update(); +void S_StopSound(int entnum, int channel); +void S_SetReverb(int reverb_type, float reverb_level); +void S_Play(); +void S_SoundList(); + +qboolean S_IsSoundPlaying(int channel_number, const char* sfxName); +void S_FadeSound(float fTime); + +qboolean MUSIC_LoadSoundtrackFile(const char* filename); +qboolean MUSIC_SongValid(const char* mood); +qboolean MUSIC_Loaded(); +void Music_Update(); +void MUSIC_SongEnded(); +void MUSIC_NewSoundtrack(const char* name); +void MUSIC_UpdateMood(int current, int fallback); +void MUSIC_UpdateVolume(float volume, float fade_time); +void MUSIC_StopAllSongs(); +void MUSIC_FreeAllSongs(); +qboolean MUSIC_Playing(); +int MUSIC_FindSong(const char* name); +void S_loadsoundtrack(); +const char* S_CurrentSoundtrack(); +void S_PlaySong(); +int MUSIC_CurrentSongChannel(); +void MUSIC_StopChannel(int channel_number); +qboolean MUSIC_PlaySong(const char* alias); +void MUSIC_UpdateMusicVolumes(); +void MUSIC_CheckForStoppedSongs(); +void S_TriggeredMusic_SetupHandle(const char* pszName, int iLoopCount, int iOffset, qboolean autostart); +void S_TriggeredMusic_Start(); +void S_TriggeredMusic_StartLoop(); +void S_TriggeredMusic_Stop(); +void S_TriggeredMusic_Pause(); +void S_TriggeredMusic_Unpause(); +void S_TriggeredMusic_PlayIntroMusic(); +void S_StopMovieAudio(); +void S_SetupMovieAudio(const char* pszMovieName); +int S_CurrentMoviePosition(); + +#ifdef __cplusplus +} +#endif + +#endif