Miniaudio Implementation (+stb_vorbis) (#624)

* Miniaudio Implementation

* Do not link miles + remove miles lib
This commit is contained in:
GuglioIsStupid
2026-03-05 19:48:12 -05:00
committed by GitHub
parent f012250219
commit 8398eb16b8
479 changed files with 102027 additions and 14765 deletions

View File

@@ -15,7 +15,6 @@
#define _SEKRIT
#include "..\..\Durango\Miles\include\mss.h"
#elif defined _WINDOWS64
#include "..\..\windows64\Miles\include\mss.h"
#else // PS4
// 4J Stu - Temp define to get Miles to link, can likely be removed when we get a new version of Miles
#define _SEKRIT2
@@ -97,4 +96,4 @@ private:
bool m_bIsPlayingStreamingGameMusic;
bool m_bIsPlayingEndMusic;
bool m_bIsPlayingNetherMusic;
};
};

File diff suppressed because it is too large Load Diff

View File

@@ -4,6 +4,8 @@ class Options;
using namespace std;
#include "..\..\Minecraft.World\SoundTypes.h"
#include "miniaudio.h"
enum eMUSICFILES
{
eStream_Overworld_Calm1 = 0,
@@ -76,7 +78,11 @@ enum MUSIC_STREAMSTATE
typedef struct
{
#ifndef _WINDOWS64
F32 x,y,z,volume,pitch;
#else
float x,y,z,volume,pitch;
#endif
int iSound;
bool bIs3D;
bool bUseSoundsPitchVal;
@@ -86,6 +92,17 @@ typedef struct
}
AUDIO_INFO;
#ifdef _WINDOWS64
struct MiniAudioSound
{
ma_sound sound;
AUDIO_INFO info;
bool active;
};
extern std::vector<MiniAudioSound*> m_activeSounds;
#endif
class SoundEngine : public ConsoleSoundEngine
{
static const int MAX_SAME_SOUNDS_PLAYING = 8; // 4J added
@@ -112,7 +129,7 @@ public:
int getMusicID(int iDomain);
int getMusicID(const wstring& name);
void SetStreamingSounds(int iOverworldMin, int iOverWorldMax, int iNetherMin, int iNetherMax, int iEndMin, int iEndMax, int iCD1);
void updateMiles(); // AP added so Vita can update all the Miles functions during the mixer callback
void updateMiniAudio();
void playMusicUpdate();
private:
@@ -126,9 +143,10 @@ private:
int GetRandomishTrack(int iStart,int iEnd);
HMSOUNDBANK m_hBank;
HDIGDRIVER m_hDriver;
HSTREAM m_hStream;
ma_engine m_engine;
ma_engine_config m_engineConfig;
ma_sound m_musicStream;
bool m_musicStreamActive;
static char m_szSoundPath[];
static char m_szMusicPath[];
@@ -165,4 +183,4 @@ private:
#ifdef __ORBIS__
int32_t m_hBGMAudio;
#endif
};
};

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,74 @@
#include "stdafx.h"
#include "Filesystem.h"
#ifdef _WINDOWS64
#include <windows.h>
#endif // TODO: More os' filesystem handling for when the project moves away from only Windows
#include <stdio.h>
bool FileOrDirectoryExists(const char* path)
{
#ifdef _WINDOWS64
DWORD attribs = GetFileAttributesA(path);
return (attribs != INVALID_FILE_ATTRIBUTES);
#else
#error "FileOrDirectoryExists not implemented for this platform"
return false;
#endif
}
bool FileExists(const char* path)
{
#ifdef _WINDOWS64
DWORD attribs = GetFileAttributesA(path);
return (attribs != INVALID_FILE_ATTRIBUTES && !(attribs & FILE_ATTRIBUTE_DIRECTORY));
#else
#error "FileExists not implemented for this platform"
return false;
#endif
}
bool DirectoryExists(const char* path)
{
#ifdef _WINDOWS64
DWORD attribs = GetFileAttributesA(path);
return (attribs != INVALID_FILE_ATTRIBUTES && (attribs & FILE_ATTRIBUTE_DIRECTORY));
#else
#error "DirectoryExists not implemented for this platform"
return false;
#endif
}
bool GetFirstFileInDirectory(const char* directory, char* outFilePath, size_t outFilePathSize)
{
#ifdef _WINDOWS64
char searchPath[MAX_PATH];
snprintf(searchPath, MAX_PATH, "%s\\*", directory);
WIN32_FIND_DATAA findData;
HANDLE hFind = FindFirstFileA(searchPath, &findData);
if (hFind == INVALID_HANDLE_VALUE)
{
return false;
}
do
{
if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
// Found a file, copy its path to the output buffer
snprintf(outFilePath, outFilePathSize, "%s\\%s", directory, findData.cFileName);
FindClose(hFind);
return true;
}
} while (FindNextFileA(hFind, &findData) != 0);
FindClose(hFind);
return false; // No files found in the directory
#else
#error "GetFirstFileInDirectory not implemented for this platform"
return false;
#endif
}

View File

@@ -0,0 +1,6 @@
#pragma once
bool FileOrDirectoryExists(const char* path);
bool FileExists(const char* path);
bool DirectoryExists(const char* path);
bool GetFirstFileInDirectory(const char* directory, char* outFilePath, size_t outFilePathSize);

View File

@@ -1551,7 +1551,7 @@ if not exist "$(TargetDir)\savedata" mkdir "$(TargetDir)\savedata"</Command>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
@@ -1571,7 +1571,7 @@ if not exist "$(TargetDir)\savedata" mkdir "$(TargetDir)\savedata"</Command>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
<AdditionalDependencies>legacy_stdio_definitions.lib;d3d11.lib;d3dcompiler.lib;..\Minecraft.World\x64_Debug\Minecraft.World.lib;%(AdditionalDependencies);XInput9_1_0.lib;..\Minecraft.Client\Windows64\Miles\Lib\mss64.lib;wsock32.lib</AdditionalDependencies>
<AdditionalDependencies>legacy_stdio_definitions.lib;d3d11.lib;d3dcompiler.lib;..\Minecraft.World\x64_Debug\Minecraft.World.lib;%(AdditionalDependencies);XInput9_1_0.lib;wsock32.lib</AdditionalDependencies>
<ShowProgress>NotSet</ShowProgress>
<SuppressStartupBanner>false</SuppressStartupBanner>
</Link>
@@ -1617,7 +1617,7 @@ if not exist "$(TargetDir)\savedata" mkdir "$(TargetDir)\savedata"</Command>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
<AdditionalDependencies>d3d11.lib;..\Minecraft.World\ARM64EC_Debug\Minecraft.World.lib;%(AdditionalDependencies);XInput9_1_0.lib;..\Minecraft.Client\Windows64\Miles\Lib\mss64.lib;wsock32.lib</AdditionalDependencies>
<AdditionalDependencies>d3d11.lib;..\Minecraft.World\ARM64EC_Debug\Minecraft.World.lib;%(AdditionalDependencies);XInput9_1_0.lib;wsock32.lib</AdditionalDependencies>
<ShowProgress>NotSet</ShowProgress>
<SuppressStartupBanner>false</SuppressStartupBanner>
</Link>
@@ -1663,7 +1663,7 @@ if not exist "$(TargetDir)\savedata" mkdir "$(TargetDir)\savedata"</Command>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
<AdditionalDependencies>d3d11.lib;..\Minecraft.World\x64_Debug\Minecraft.World.lib;%(AdditionalDependencies);XInput9_1_0.lib;..\Minecraft.Client\Windows64\Miles\Lib\mss64.lib</AdditionalDependencies>
<AdditionalDependencies>d3d11.lib;..\Minecraft.World\x64_Debug\Minecraft.World.lib;%(AdditionalDependencies);XInput9_1_0.lib</AdditionalDependencies>
<ShowProgress>NotSet</ShowProgress>
<SuppressStartupBanner>false</SuppressStartupBanner>
</Link>
@@ -5698,7 +5698,9 @@ xcopy /q /y /i /s /e $(ProjectDir)Durango\CU $(LayoutDir)Image\Loose\CU</Comman
<ClInclude Include="Common\App_enums.h" />
<ClInclude Include="Common\App_structs.h" />
<ClInclude Include="Common\Audio\Consoles_SoundEngine.h" />
<ClInclude Include="Common\Audio\miniaudio.h" />
<ClInclude Include="Common\Audio\SoundEngine.h" />
<ClInclude Include="Common\Audio\stb_vorbis.h" />
<ClInclude Include="Common\BuildVer.h" />
<ClInclude Include="Common\Colours\ColourTable.h" />
<ClInclude Include="Common\Consoles_App.h" />
@@ -5715,6 +5717,7 @@ xcopy /q /y /i /s /e $(ProjectDir)Durango\CU $(LayoutDir)Image\Loose\CU</Comman
<ClInclude Include="Common\DLC\DLCSkinFile.h" />
<ClInclude Include="Common\DLC\DLCTextureFile.h" />
<ClInclude Include="Common\DLC\DLCUIDataFile.h" />
<ClInclude Include="Common\Filesystem\Filesystem.h" />
<ClInclude Include="Common\GameRules\AddEnchantmentRuleDefinition.h" />
<ClInclude Include="Common\GameRules\AddItemRuleDefinition.h" />
<ClInclude Include="Common\GameRules\ApplySchematicRuleDefinition.h" />
@@ -28470,6 +28473,7 @@ xcopy /q /y /i /s /e $(ProjectDir)Durango\CU $(LayoutDir)Image\Loose\CU</Comman
<ClCompile Include="Common\DLC\DLCSkinFile.cpp" />
<ClCompile Include="Common\DLC\DLCTextureFile.cpp" />
<ClCompile Include="Common\DLC\DLCUIDataFile.cpp" />
<ClCompile Include="Common\Filesystem\Filesystem.cpp" />
<ClCompile Include="Common\GameRules\AddEnchantmentRuleDefinition.cpp" />
<ClCompile Include="Common\GameRules\AddItemRuleDefinition.cpp" />
<ClCompile Include="Common\GameRules\ApplySchematicRuleDefinition.cpp" />
@@ -46300,23 +46304,6 @@ xcopy /q /y /i /s /e $(ProjectDir)Durango\CU $(LayoutDir)Image\Loose\CU</Comman
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Xbox 360'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_Vita|Xbox 360'">true</ExcludedFromBuild>
</Library>
<Library Include="Windows64\Miles\lib\mss64.lib">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Durango'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Durango'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_Vita|Durango'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ORBIS'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_Vita|ORBIS'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ORBIS'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|PS3'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|PSVita'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|PS3'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_Vita|PS3'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|PSVita'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_Vita|PSVita'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Xbox 360'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage_Vita|Xbox 360'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Xbox 360'">true</ExcludedFromBuild>
</Library>
<Library Include="Xbox\4JLibs\libs\4J_Input.lib">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ContentPackage|ARM64EC'">true</ExcludedFromBuild>

View File

@@ -729,6 +729,9 @@
<Filter Include="Windows64\Source Files\Network">
<UniqueIdentifier>{e5d7fb24-25b8-413c-84ec-974bf0d4a3d1}</UniqueIdentifier>
</Filter>
<Filter Include="Common\Source Files\Filesystem">
<UniqueIdentifier>{c79fd64d-7529-4da4-b5f3-2541e084932b}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="ReadMe.txt" />
@@ -3778,6 +3781,15 @@
<ClInclude Include="Windows64\Network\WinsockNetLayer.h">
<Filter>Windows64\Source Files\Network</Filter>
</ClInclude>
<ClInclude Include="Common\Filesystem\Filesystem.h">
<Filter>Common\Source Files\Filesystem</Filter>
</ClInclude>
<ClInclude Include="Common\Audio\miniaudio.h">
<Filter>Common\Source Files\Audio</Filter>
</ClInclude>
<ClInclude Include="Common\Audio\stb_vorbis.h">
<Filter>Common\Source Files\Audio</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
@@ -5931,6 +5943,9 @@
<ClCompile Include="Windows64\Network\WinsockNetLayer.cpp">
<Filter>Windows64\Source Files\Network</Filter>
</ClCompile>
<ClCompile Include="Common\Filesystem\Filesystem.cpp">
<Filter>Common\Source Files\Filesystem</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Library Include="Xbox\4JLibs\libs\4J_Render_d.lib">
@@ -5990,9 +6005,6 @@
<Library Include="Windows64\4JLibs\libs\4J_Input_d.lib">
<Filter>Windows64\4JLibs\libs</Filter>
</Library>
<Library Include="Windows64\Miles\lib\mss64.lib">
<Filter>Windows64\Miles Sound System\lib</Filter>
</Library>
<Library Include="Windows64\Iggy\lib\iggy_w64.lib">
<Filter>Windows64\Iggy\lib</Filter>
</Library>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,36 +0,0 @@
// This is the null header file used to remove Telemetry calls.
#define TMERR_DISABLED 1
#define tmTick(...)
#define tmPause(...)
#define tmEnter(...)
#define tmLeave(...)
#define tmThreadName(...) TMERR_DISABLED
#define tmMutexName(...) TMERR_DISABLED
#define tmTryLock(...) TMERR_DISABLED
#define tmEndTryLock(...)
#define tmSetMutexState(...)
#define tmAlloc(...)
#define tmRealloc(...)
#define tmFree(...)
#define tmPlot(...)
#define tmBlob(...) TMERR_DISABLED
#define tmBlobEx(...) TMERR_DISABLED
#define tmMessage(...)
#define tmEmitAccumulationZones(...) TMERR_DISABLED
#define tmEnterAccumulationZone(...) TMERR_DISABLED
#define tmLeaveAccumulationZone(...) TMERR_DISABLED
#define tmZone(...)
#define tmSetLockState(...)
#define tmLockName(...)
#define tmSendCallStack(...)
#define tmAllocEx(...)
#define NTELEMETRY 1
#define TM_CONTEXT_LITE(val) ((char*)(val))
#define TM_CONTEXT_FULL(val) ((char*)(val))
typedef char *HTELEMETRY;

Some files were not shown because too many files have changed in this diff Show More