- added extended sound lookup as well plus menu options.

This commit is contained in:
Christoph Oelckers 2020-01-27 22:29:45 +01:00
parent 67a0954c32
commit 9ca1e56713
13 changed files with 29 additions and 131 deletions

View file

@ -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

View file

@ -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"

View file

@ -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/<file's parent GRP name>/
// 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
}

View file

@ -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);

View file

@ -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);
}

View file

@ -451,3 +451,5 @@ inline int S_FindSound(const char* name)
{
return soundEngine->FindSound(name);
}
int S_LookupSound(const char* fn);

View file

@ -13,6 +13,8 @@ xx(QAV)
xx(SEQ)
xx(SFX)
xx(RAW)
xx(AIF)
xx(AIFF)
xx(MAP)
xx(RFS)
xx(WAV)

View file

@ -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;

View file

@ -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();

View file

@ -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;

View file

@ -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];

View file

@ -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 синтеза

1 default Identifier Remarks Filter eng enc ena enz eni ens enj enb enl ent enw cs de el eo es esm esn esg esc esa esd esv eso esr ess esf esl esy esz esb ese esh esi esu fi fr hu it jp ko nl pl pt ptg ro ru sr
562 %k vented %o %k sliced %o TXT_OBITUARY46 TXT_OBITUARY44
563 %k ventilated %o %k smacked %o around TXT_OBITUARY47 TXT_OBITUARY45
564 %k wrecked %o %k vented %o TXT_OBITUARY48 TXT_OBITUARY46
565 %k ventilated %o TXT_OBITUARY47
566 %k wrecked %o TXT_OBITUARY48
567 %o is excrement TXT_SELFOBIT1 %o je exkrement %o wurde zu Exkrement verarbeitet %o estas ekskremento %o es excremento %o on ulostetta %o est une merde %o è un escremento %o はもはや排泄物のようだ。 %o 은(는) 배설물이 되었다. %o is uitwerpselen %o został@[ao_pl] odpadkami %o virou escremento %o теперь экскремент %o је сада измет
568 %o is excrement %o is hamburger TXT_SELFOBIT1 TXT_SELFOBIT2 %o je exkrement %o je hamburger %o wurde zu Exkrement verarbeitet %o ist Hamburger %o estas ekskremento %o estas hamburgero %o es excremento %o es una hamburguesa %o on ulostetta %o on hakkelusta %o est une merde %o est un hamburger %o è un escremento %o è un hamburger %o はもはや排泄物のようだ。 %o はハンバーガーになった。 %o 은(는) 배설물이 되었다. %o 은(는) 고기 반죽이 되었다. %o is uitwerpselen %o is hamburger %o został@[ao_pl] odpadkami %o został@[ao_pl] hamburgerem %o virou escremento %o virou hamburguer %o теперь экскремент %o теперь гамбургер %o је сада измет %o је сада пљескавица
569 %o is hamburger %o suffered scrotum separation TXT_SELFOBIT2 TXT_SELFOBIT3 %o je hamburger %o prodělal@[ao_cs] separaci šourku %o ist Hamburger %os Eier wurden gebraten %o estas hamburgero %o suferis skrotan disigon %o es una hamburguesa %o sufrió separación de escroto %o on hakkelusta %o kärsii kivespussin erotuksesta %o est un hamburger %o a souffert d'une séparation du scrotum %o è un hamburger %o ha subito la separazione dello scroto %o はハンバーガーになった。 %o の陰嚢は剥離していた。 %o 은(는) 고기 반죽이 되었다. %o 은(는) 고자가 되었다. %o is hamburger %o leed aan scrotumscheiding... %o został@[ao_pl] hamburgerem %o doznał@[ao_pl] oddzielenia moszny %o virou hamburguer %o sofreu separação escrotal %o теперь гамбургер %o страдает от потери тестикул %o је сада пљескавица %o му је исечена патка
570 %o suffered scrotum separation %o volunteered for population control TXT_SELFOBIT3 TXT_SELFOBIT4 %o prodělal@[ao_cs] separaci šourku %o se zůčastnil@[ao_cs] čistky obyvatelstva %os Eier wurden gebraten %o hat sich freiwillig zur Bevölkerungskontrolle gemeldet %o suferis skrotan disigon %o volontulis por loĝantarkontrolo %o sufrió separación de escroto %o fue voluntario para control de población %o kärsii kivespussin erotuksesta %o ilmoittautui vapaaehtoiseksi väestönhallintaan %o a souffert d'une séparation du scrotum %o s'est proposé pour un contrôle de la population %o ha subito la separazione dello scroto %o si è offerto per il controllo della popolazione %o の陰嚢は剥離していた。 %o は人口削減政策の実験台に志願した。 %o 은(는) 고자가 되었다. %o 은(는) 자연에 의해 낙태 당했다. %o leed aan scrotumscheiding... %o vrijwilliger voor bevolkingscontrole %o doznał@[ao_pl] oddzielenia moszny %o zgłosił@[ao_pl] się na kontrolę ludności %o sofreu separação escrotal %o se voluntariou para o controle populacional %o se voluntariou para o controlo populacional %o страдает от потери тестикул %o борется с перенаселением %o му је исечена патка %o је волунтирао за контролу популације

View file

@ -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 " "