From 0af4d57408842d501af2fce4617e19a3bf9466eb Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 22 May 2020 17:40:19 +0300 Subject: opus support --- premake5.lua | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'premake5.lua') diff --git a/premake5.lua b/premake5.lua index c8494884..c6551a21 100644 --- a/premake5.lua +++ b/premake5.lua @@ -17,6 +17,11 @@ newoption { description = "Build and use librw from this solution" } +newoption { + trigger = "with-opus", + description = "Build with opus" +} + if(_OPTIONS["with-librw"]) then Librw = "librw" else @@ -185,8 +190,25 @@ project "re3" includedirs { "milessdk/include" } includedirs { "eax" } + + includedirs { "openal-soft/include" } + includedirs { "mpg123/include" } + includedirs { "libsndfile/include" } + includedirs { "ogg/include" } + includedirs { "opus/include" } + includedirs { "opusfile/include" } libdirs { "milessdk/lib" } + libdirs { "openal-soft/libs/Win32" } + libdirs { "mpg123/lib" } + libdirs { "libsndfile/lib" } + if _OPTIONS["with-opus"] then + filter "platforms:win*" + libdirs { "ogg/win32/VS2015/Win32/%{cfg.buildcfg}" } + libdirs { "opus/win32/VS2015/Win32/%{cfg.buildcfg}" } + libdirs { "opusfile/win32/VS2015/Win32/Release-NoHTTP" } + filter {} + end if(os.getenv("GTA_III_RE_DIR")) then setpaths("$(GTA_III_RE_DIR)/", "%(cfg.buildtarget.name)", "") @@ -202,6 +224,13 @@ project "re3" filter "platforms:linux*" defines { "OPENAL" } links { "openal", "mpg123", "sndfile", "pthread" } + + if _OPTIONS["with-opus"] then + filter {} + links { "libogg" } + links { "opus" } + links { "opusfile" } + end filter "platforms:*RW33*" staticruntime "on" -- cgit v1.2.3 From 97b058d0fa44eb1bb032484a6f4bee6df1f249bd Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 22 May 2020 17:43:26 +0300 Subject: more checks in premake --- premake5.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'premake5.lua') diff --git a/premake5.lua b/premake5.lua index c6551a21..95c03b21 100644 --- a/premake5.lua +++ b/premake5.lua @@ -194,9 +194,11 @@ project "re3" includedirs { "openal-soft/include" } includedirs { "mpg123/include" } includedirs { "libsndfile/include" } - includedirs { "ogg/include" } - includedirs { "opus/include" } - includedirs { "opusfile/include" } + if _OPTIONS["with-opus"] then + includedirs { "ogg/include" } + includedirs { "opus/include" } + includedirs { "opusfile/include" } + end libdirs { "milessdk/lib" } libdirs { "openal-soft/libs/Win32" } -- cgit v1.2.3 From 3a7651e7ab87e21ff510441f98dcbe6711134a18 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sun, 24 May 2020 00:56:20 +0300 Subject: Cleanup --- premake5.lua | 1 + src/audio/sampman_oal.cpp | 48 +++++++++++++++++------------------------------ 2 files changed, 18 insertions(+), 31 deletions(-) (limited to 'premake5.lua') diff --git a/premake5.lua b/premake5.lua index c7321dcb..036dad09 100644 --- a/premake5.lua +++ b/premake5.lua @@ -209,6 +209,7 @@ project "re3" libdirs { "opus/win32/VS2015/Win32/%{cfg.buildcfg}" } libdirs { "opusfile/win32/VS2015/Win32/Release-NoHTTP" } filter {} + defines { "AUDIO_OPUS" } end filter "platforms:*oal" diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index ff50ac07..1cd45e4f 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -45,10 +45,6 @@ bool _bSampmanInitialised = false; uint32 BankStartOffset[MAX_SAMPLEBANKS]; -#ifdef AUDIO_OPUS -OggOpusFile *opusSFX; -#endif - int prevprovider=-1; int curprovider=-1; int usingEAX=0; @@ -76,7 +72,11 @@ char SampleBankDescFilename[] = "audio/sfx.SDT"; char SampleBankDataFilename[] = "audio/sfx.RAW"; FILE *fpSampleDescHandle; +#ifdef AUDIO_OPUS +OggOpusFile *fpSampleDataHandle; +#else FILE *fpSampleDataHandle; +#endif bool bSampleBankLoaded [MAX_SAMPLEBANKS]; int32 nSampleBankDiscStartOffset [MAX_SAMPLEBANKS]; int32 nSampleBankSize [MAX_SAMPLEBANKS]; @@ -753,13 +753,11 @@ cSampleManager::LoadSampleBank(uint8 nBank) } #ifdef AUDIO_OPUS - int ret; - //OggOpusFile *file = op_open_file("AUDIO/SFX0.RAW", &ret); int samplesRead = 0; int samplesSize = nSampleBankSize[nBank] / 2; - op_pcm_seek(opusSFX, 0); + op_pcm_seek(fpSampleDataHandle, 0); while (samplesSize > 0) { - int size = op_read(opusSFX, (opus_int16 *)(nSampleBankMemoryStartAddress[nBank] + samplesRead), samplesSize, NULL); + int size = op_read(fpSampleDataHandle, (opus_int16 *)(nSampleBankMemoryStartAddress[nBank] + samplesRead), samplesSize, NULL); if (size <= 0) { // huh? //assert(0); @@ -768,14 +766,6 @@ cSampleManager::LoadSampleBank(uint8 nBank) samplesRead += size*2; samplesSize -= size; } - //op_free(file); - - //if (samplesRead != nSampleBankSize[nBank]) - // return false; - - //FILE *fsd = fopen("sfx.temp", "wb"); - //fwrite((void *)nSampleBankMemoryStartAddress[nBank], 1, nSampleBankSize[nBank], fsd); - //fclose(fsd); #else if ( fseek(fpSampleDataHandle, nSampleBankDiscStartOffset[nBank], SEEK_SET) != 0 ) return false; @@ -878,10 +868,10 @@ cSampleManager::LoadPedComment(uint32 nComment) #ifdef AUDIO_OPUS int samplesRead = 0; int samplesSize = m_aSamples[nComment].nSize / 2; - op_pcm_seek(opusSFX, m_aSamples[nComment].nOffset / 2); + op_pcm_seek(fpSampleDataHandle, m_aSamples[nComment].nOffset / 2); while (samplesSize > 0) { - int size = - op_read(opusSFX, (opus_int16 *)(nSampleBankMemoryStartAddress[SAMPLEBANK_PED] + PED_BLOCKSIZE * nCurrentPedSlot + samplesRead), samplesSize, NULL); + int size = op_read(fpSampleDataHandle, (opus_int16 *)(nSampleBankMemoryStartAddress[SAMPLEBANK_PED] + PED_BLOCKSIZE * nCurrentPedSlot + samplesRead), + samplesSize, NULL); if (size <= 0) { return false; } @@ -1425,7 +1415,7 @@ cSampleManager::InitialiseSampleBanks(void) fpSampleDescHandle = fopen(SampleBankDescFilename, "rb"); if ( fpSampleDescHandle == NULL ) return false; - +#ifndef AUDIO_OPUS fpSampleDataHandle = fopen(SampleBankDataFilename, "rb"); if ( fpSampleDataHandle == NULL ) { @@ -1438,9 +1428,14 @@ cSampleManager::InitialiseSampleBanks(void) fseek(fpSampleDataHandle, 0, SEEK_END); int32 _nSampleDataEndOffset = ftell(fpSampleDataHandle); rewind(fpSampleDataHandle); - +#else + int e; + fpSampleDataHandle = op_open_file(SampleBankDataFilename, &e); +#endif fread(m_aSamples, sizeof(tSample), TOTAL_AUDIO_SAMPLES, fpSampleDescHandle); - +#ifdef AUDIO_OPUS + int32 _nSampleDataEndOffset = m_aSamples[TOTAL_AUDIO_SAMPLES - 1].nOffset + m_aSamples[TOTAL_AUDIO_SAMPLES - 1].nSize; +#endif fclose(fpSampleDescHandle); fpSampleDescHandle = NULL; @@ -1458,15 +1453,6 @@ cSampleManager::InitialiseSampleBanks(void) nSampleBankSize[SAMPLEBANK_MAIN] = nSampleBankDiscStartOffset[SAMPLEBANK_PED] - nSampleBankDiscStartOffset[SAMPLEBANK_MAIN]; nSampleBankSize[SAMPLEBANK_PED] = _nSampleDataEndOffset - nSampleBankDiscStartOffset[SAMPLEBANK_PED]; - - //int error = 0; - //auto encoder = opus_encoder_create(48000, 1, OPUS_APPLICATION_AUDIO, &error); - //error = opus_encoder_ctl(encoder, OPUS_SET_BITRATE(75.5)); - - //nbBytes = opus_encode(encoder, in, FRAME_SIZE, cbits, MAX_PACKET_SIZE); - - int e; - opusSFX = op_open_file("AUDIO/SFX.opus", &e); return true; } -- cgit v1.2.3 From 550b813d92f484fb278cd2e1606cc262d217ffb4 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Wed, 29 Jul 2020 16:08:01 +0300 Subject: premake fix --- premake5.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'premake5.lua') diff --git a/premake5.lua b/premake5.lua index 87cb9e2d..3ddc554e 100644 --- a/premake5.lua +++ b/premake5.lua @@ -211,10 +211,11 @@ project "re3" includedirs { "opusfile/include" } end - libdirs { "milessdk/lib" } - libdirs { "openal-soft/libs/Win32" } - libdirs { "mpg123/lib" } - libdirs { "libsndfile/lib" } + filter "platforms:*mss" + defines { "AUDIO_MSS" } + includedirs { "milessdk/include" } + libdirs { "sdk/milessdk/lib" } + if _OPTIONS["with-opus"] then filter "platforms:win*" libdirs { "ogg/win32/VS2015/Win32/%{cfg.buildcfg}" } -- cgit v1.2.3 From e823e018600bbc71fd4a58c50d86f1bd2ce467ff Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Wed, 29 Jul 2020 16:10:59 +0300 Subject: more fix --- premake5.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'premake5.lua') diff --git a/premake5.lua b/premake5.lua index 3ddc554e..57db0fe8 100644 --- a/premake5.lua +++ b/premake5.lua @@ -214,7 +214,7 @@ project "re3" filter "platforms:*mss" defines { "AUDIO_MSS" } includedirs { "milessdk/include" } - libdirs { "sdk/milessdk/lib" } + libdirs { "milessdk/lib" } if _OPTIONS["with-opus"] then filter "platforms:win*" -- cgit v1.2.3