diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 469beea00..eafccce39 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -720,7 +720,6 @@ set (PCH_SOURCES common/inputstate.cpp common/searchpaths.cpp common/initfs.cpp - common/openaudio.cpp common/statistics.cpp common/secrets.cpp common/compositesavegame.cpp diff --git a/source/blood/src/sound.cpp b/source/blood/src/sound.cpp index 9889bb87c..43fdcbe02 100644 --- a/source/blood/src/sound.cpp +++ b/source/blood/src/sound.cpp @@ -30,7 +30,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "resource.h" #include "sound.h" #include "baselayer.h" -#include "openaudio.h" #include "z_music.h" #include "sfx.h" #include "sound/s_soundinternal.h" diff --git a/source/common/openaudio.cpp b/source/common/openaudio.cpp deleted file mode 100644 index c94cb9001..000000000 --- a/source/common/openaudio.cpp +++ /dev/null @@ -1,119 +0,0 @@ - - -#include "openaudio.h" -#include "gamecvars.h" - - -////////// - -#if 0 // disabled pending a rewrite from the ground up. - -static FileReader S_TryFormats(char * const testfn, char * const fn_suffix, char const searchfirst) -{ -#ifdef HAVE_FLAC - { - Bstrcpy(fn_suffix, ".flac"); - auto fp = fileSystem.OpenFileReader(testfn, searchfirst); - if (fp.isOpen()) - return fp; - } -#endif - -#ifdef HAVE_VORBIS - { - Bstrcpy(fn_suffix, ".ogg"); - auto fp = fileSystem.OpenFileReader(testfn, searchfirst); - if (fp.isOpen()) - return fp; - } -#endif - - return FileReader(); -} - -static FileReader S_TryExtensionReplacements(char * const testfn, char const searchfirst, uint8_t const ismusic) -{ - char * extension = Bstrrchr(testfn, '.'); - char * const fn_end = Bstrchr(testfn, '\0'); - - // ex: grabbag.voc --> grabbag_voc.* - if (extension != NULL) - { - *extension = '_'; - - auto fp = S_TryFormats(testfn, fn_end, searchfirst); - if (fp.isOpen()) - return fp; - } - else - { - extension = fn_end; - } - - // ex: grabbag.mid --> grabbag.* - if (ismusic) - { - auto fp = S_TryFormats(testfn, extension, searchfirst); - if (fp.isOpen()) - return fp; - } - - return FileReader(); -} -#endif - -FileReader S_OpenAudio(const char *fn, char searchfirst, uint8_t const ismusic) -{ - auto origfp = fileSystem.OpenFileReader(fn, searchfirst); - if (!snd_tryformats) return origfp; - return origfp; -#if 0 // this needs to be redone - char const* const origparent = origfp.isOpen() ? kfileparent(origfp) : NULL; - uint32_t const parentlength = origparent != NULL ? Bstrlen(origparent) : 0; - - auto testfn = (char *)Xmalloc(Bstrlen(fn) + 12 + parentlength); // "music/" + overestimation of parent minus extension + ".flac" + '\0' - - // look in ./ - // ex: ./grabbag.mid - Bstrcpy(testfn, fn); - auto fp = S_TryExtensionReplacements(testfn, searchfirst, ismusic); - if (fp.isOpen()) - { - Xfree(testfn); - return fp; - } - - // look in ./music// - // ex: ./music/duke3d/grabbag.mid - // ex: ./music/nwinter/grabbag.mid - if (origparent != NULL) - { - char const * const parentextension = Bstrrchr(origparent, '.'); - uint32_t const namelength = parentextension != NULL ? (unsigned)(parentextension - origparent) : parentlength; - - Bsprintf(testfn, "music/%.*s/%s", namelength, origparent, fn); - auto fp = S_TryExtensionReplacements(testfn, searchfirst, ismusic); - if (fp.isOpen()) - { - Xfree(testfn); - return fp; - } - } - - // look in ./music/ - // ex: ./music/grabbag.mid - { - Bsprintf(testfn, "music/%s", fn); - auto fp = S_TryExtensionReplacements(testfn, searchfirst, ismusic); - if (fp.isOpen()) - { - Xfree(testfn); - return fp; - } - } - - Xfree(testfn); - return origfp; -#endif -} - diff --git a/source/common/openaudio.h b/source/common/openaudio.h deleted file mode 100644 index ac3a6c2de..000000000 --- a/source/common/openaudio.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once - -#include "filesystem/filesystem.h" - -// This really, really needs to be redone in its entirety, the audio lookup code is hideous. -extern FileReader S_OpenAudio(const char *fn, char searchfirst, uint8_t ismusic); diff --git a/source/common/sound/s_sound.cpp b/source/common/sound/s_sound.cpp index e407e2205..415232950 100644 --- a/source/common/sound/s_sound.cpp +++ b/source/common/sound/s_sound.cpp @@ -40,6 +40,9 @@ #include "m_swap.h" #include "superfasthash.h" #include "c_cvars.h" +#include "name.h" +#include "filesystem.h" +#include "cmdlib.h" #ifdef _WIN32 #undef DrawText @@ -1805,4 +1808,15 @@ ADD_STAT(sounddebug) return soundEngine->NoiseDebug(); } +CVAR(Bool, snd_extendedlookup, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +int S_LookupSound(const char* fn) +{ + static const FName sndformats[] = { NAME_OGG, NAME_FLAC, NAME_WAV }; + if (snd_extendedlookup) + { + int lump = fileSystem.FindFileWithExtensions(StripExtension(fn), sndformats, countof(sndformats)); + if (lump >= 0) return lump; + } + return fileSystem.FindFile(fn); +} diff --git a/source/common/sound/s_soundinternal.h b/source/common/sound/s_soundinternal.h index 0fdc5d107..174209182 100644 --- a/source/common/sound/s_soundinternal.h +++ b/source/common/sound/s_soundinternal.h @@ -451,3 +451,5 @@ inline int S_FindSound(const char* name) { return soundEngine->FindSound(name); } + +int S_LookupSound(const char* fn); diff --git a/source/common/utility/namedef.h b/source/common/utility/namedef.h index e6690280d..653b7b3d3 100644 --- a/source/common/utility/namedef.h +++ b/source/common/utility/namedef.h @@ -13,6 +13,8 @@ xx(QAV) xx(SEQ) xx(SFX) xx(RAW) +xx(AIF) +xx(AIFF) xx(MAP) xx(RFS) xx(WAV) diff --git a/source/duke3d/src/sounds.cpp b/source/duke3d/src/sounds.cpp index a2b0e84e1..92beb5f1a 100644 --- a/source/duke3d/src/sounds.cpp +++ b/source/duke3d/src/sounds.cpp @@ -150,7 +150,7 @@ int S_DefineSound(unsigned index, const char *filename, int minpitch, int maxpit if (sndinf->flags & SF_LOOP) sndinf->flags |= SF_ONEINST_INTERNAL; - sfx->lumpnum = fileSystem.FindFile(filename); + sfx->lumpnum = S_LookupSound(filename); sndinf->pitchStart = clamp(minpitch, INT16_MIN, INT16_MAX); sndinf->pitchEnd = clamp(maxpitch, INT16_MIN, INT16_MAX); sndinf->priority = priority & 255; diff --git a/source/exhumed/src/sound.cpp b/source/exhumed/src/sound.cpp index a50e7a3eb..fbb4b6307 100644 --- a/source/exhumed/src/sound.cpp +++ b/source/exhumed/src/sound.cpp @@ -233,7 +233,7 @@ int LoadSound(const char* name) if (sndid > 0) return sndid - 1; FStringf filename("%s.voc", nname.GetChars()); - auto lump = fileSystem.FindFile(filename); + auto lump = S_LookupSound(filename); if (lump > 0) { auto &S_sfx = soundEngine->GetSounds(); diff --git a/source/rr/src/sounds.cpp b/source/rr/src/sounds.cpp index 206e20995..43d1ea925 100644 --- a/source/rr/src/sounds.cpp +++ b/source/rr/src/sounds.cpp @@ -149,7 +149,7 @@ int S_DefineSound(unsigned index, const char *filename, int minpitch, int maxpit if (sndinf->flags & SF_LOOP) sndinf->flags |= SF_ONEINST_INTERNAL; - sfx->lumpnum = fileSystem.FindFile(filename); + sfx->lumpnum = S_LookupSound(filename); sndinf->pitchStart = clamp(minpitch, INT16_MIN, INT16_MAX); sndinf->pitchEnd = clamp(maxpitch, INT16_MIN, INT16_MAX); sndinf->priority = priority & 255; diff --git a/source/sw/src/sounds.cpp b/source/sw/src/sounds.cpp index c49edb985..1f715314b 100644 --- a/source/sw/src/sounds.cpp +++ b/source/sw/src/sounds.cpp @@ -480,7 +480,7 @@ void InitFX(void) for (size_t i = 1; i < countof(voc); i++) { auto& entry = voc[i]; - auto lump = fileSystem.FindFile(entry.name); + auto lump = S_LookupSound(entry.name); if (lump > 0) { auto& newsfx = S_sfx[i]; diff --git a/wadsrc/static/engine/language.csv b/wadsrc/static/engine/language.csv index 07f16bb2b..b4a2e8b8d 100644 --- a/wadsrc/static/engine/language.csv +++ b/wadsrc/static/engine/language.csv @@ -562,6 +562,9 @@ Module replayer options,SNDMNU_MODREPLAYER,,,,Nastavení přehrávače modulů,M Midi player options,SNDMNU_MIDIPLAYER,,,,Nastavení MIDI přehrávače,MIDI-Spieler-Optionen,,Agordoj por MIDI-ludilo,Opciones de reproductor MIDI,,MIDI-soitinasetukset,Option lecteur MIDI,,Opzioni Midi player,Midi再生のオプション,MIDI 플레이어 설정,Midi speler opties,Opcje Odtwarzacza Midi,Opções de reprodutor MIDI,,,Настройки MIDI-проигрывателя,MIDI плејер подешавања Sound in Menus,SNDMNU_MENUSOUND,,,,,Sound in Menüs,,,,,,,,,,,,,,,,, Advanced Sound Options,ADVSNDMNU_TITLE,,,,Pokročilá nastavení zvuku,Erweiterte Soundoptionen,,Altnivelaj Son-agordoj,Opciones avanzadas de sonido,,Edistyneet ääniasetukset,Options Sonores Avancées,,Opzioni avanzate dei suoni,高度なサウンドオプション,고급 음향 설정,Geavanceerde geluidsopties,Zaawansowane Opcje Dźwięku,Opções de Áudio Avançadas,,,Расширенные настройки,Напредна подешавања звука +"Ignore file type for music lookup +",ADVSNDMNU_LOOKUPMUS,,,,,,,,,,,,,,,,,,,,,, +Ignore file type for sound lookup,ADVSNDMNU_LOOKUPSND,,,,,,,,,,,,,,,,,,,,,, Sample rate,ADVSNDMNU_SAMPLERATE,,,,Vzorkovací frekvence,Samplerate,,Specimenrapideco,Frecuencia de muestreo,,Näytteenottotaajuus,Cadence de Sampling,,,サンプルレート,샘플링레이트,Steekproeftarief,Częstotliwość próbkowania,Taxa de amostragem,,,Частота дискретизации,Фреквенција узорковања HRTF,ADVSNDMNU_HRTF,,,,,,,,,,,,,,,머리전달함수,,HRTF,,,,, OPL Synthesis,ADVSNDMNU_OPLSYNTHESIS,,,,Emulace OPL,OPL Synthese,,OPL-Sintezo,Síntesis OPL,,OPL-synteesi,Synthèse OPL,,,OPLシンセサイズ,OPL 합성,OPL synthese,Synteza OPL,Síntese OPL,,,Синтез OPL,OPL синтеза diff --git a/wadsrc/static/engine/menudef.txt b/wadsrc/static/engine/menudef.txt index 87a8aa32e..a8c4cceef 100644 --- a/wadsrc/static/engine/menudef.txt +++ b/wadsrc/static/engine/menudef.txt @@ -1360,6 +1360,10 @@ OptionMenu SoundOptions //protected OptionMenu AdvSoundOptions //protected { Title "$ADVSNDMNU_TITLE" + Option "$ADVSNDMNU_LOOKUPMUS", "mus_extendedlookup", "OnOff" + Option "$ADVSNDMNU_LOOKUPSND", "snd_extendedlookup", "OnOff" + StaticText " " + Option "$ADVSNDMNU_SAMPLERATE", "snd_mixrate", "SampleRates" //Option "$ADVSNDMNU_HRTF", "snd_hrtf", "AutoOffOn" StaticText " "