mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 00:41:55 +00:00
- added extended sound lookup as well plus menu options.
This commit is contained in:
parent
67a0954c32
commit
9ca1e56713
13 changed files with 29 additions and 131 deletions
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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);
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -451,3 +451,5 @@ inline int S_FindSound(const char* name)
|
|||
{
|
||||
return soundEngine->FindSound(name);
|
||||
}
|
||||
|
||||
int S_LookupSound(const char* fn);
|
||||
|
|
|
@ -13,6 +13,8 @@ xx(QAV)
|
|||
xx(SEQ)
|
||||
xx(SFX)
|
||||
xx(RAW)
|
||||
xx(AIF)
|
||||
xx(AIFF)
|
||||
xx(MAP)
|
||||
xx(RFS)
|
||||
xx(WAV)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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 синтеза
|
||||
|
|
|
|
@ -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 " "
|
||||
|
|
Loading…
Reference in a new issue