feat(Windows64): miniaudio

This commit is contained in:
2026-08-13 19:06:02 -04:00
parent 4fc62dad24
commit d8540e02ef
492 changed files with 103237 additions and 14199 deletions
@@ -2,21 +2,17 @@
#include "..\..\..\Minecraft.World\SoundTypes.h"
#ifdef _XBOX
#elif defined (__PS3__)
#ifdef __PS3__
#undef __in
#undef __out
#include "..\..\PS3\Miles\include\mss.h"
#elif defined (__PSVITA__)
#elif __PSVITA__
#include "..\..\PSVITA\Miles\include\mss.h"
#elif defined _DURANGO
#elif _DURANGO
// 4J Stu - Temp define to get Miles to link, can likely be removed when we get a new version of Miles
#define _SEKRIT
#include "..\..\Durango\Miles\include\mss.h"
#elif defined _WINDOWS64
#include "..\..\windows64\Miles\include\mss.h"
#else // PS4
#elif __ORBIS__
// 4J Stu - Temp define to get Miles to link, can likely be removed when we get a new version of Miles
#define _SEKRIT2
#include "..\..\Orbis\Miles\include\mss.h"
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,166 @@
#pragma once
class Mob;
class Options;
using namespace std;
#include "../../Minecraft.World/SoundTypes.h"
#include "miniaudio.h"
const float SFX_3D_MIN_DISTANCE = 1.0f;
const float SFX_3D_MAX_DISTANCE = 16.0f;
const float SFX_3D_ROLLOFF = 0.5f;
const float SFX_VOLUME_MULTIPLIER = 1.5f;
const float SFX_MAX_GAIN = 1.5f;
enum eMUSICFILES
{
eStream_Overworld_Calm1 = 0,
eStream_Overworld_Calm2,
eStream_Overworld_Calm3,
eStream_Overworld_hal1,
eStream_Overworld_hal2,
eStream_Overworld_hal3,
eStream_Overworld_hal4,
eStream_Overworld_nuance1,
eStream_Overworld_nuance2,
eStream_Overworld_piano1,
eStream_Overworld_piano2,
eStream_Overworld_piano3,
// Nether
eStream_Nether1,
eStream_Nether2,
eStream_Nether3,
eStream_Nether4,
// The End
eStream_end_dragon,
eStream_end_end,
eStream_CD_1,
eStream_CD_2,
eStream_CD_3,
eStream_CD_4,
eStream_CD_5,
eStream_CD_6,
eStream_CD_7,
eStream_CD_8,
eStream_CD_9,
eStream_CD_10,
eStream_CD_11,
eStream_CD_12,
eStream_Max,
};
enum eMUSICTYPE
{
eMusicType_None,
eMusicType_Game,
eMusicType_CD,
};
enum MUSIC_STREAMSTATE
{
eMusicStreamState_Idle=0,
eMusicStreamState_Stop,
eMusicStreamState_Stopping,
eMusicStreamState_Opening,
eMusicStreamState_OpeningCancel,
eMusicStreamState_Play,
eMusicStreamState_Playing,
eMusicStreamState_Completed
};
typedef struct
{
float x,y,z,volume,pitch;
int iSound;
bool bIs3D;
bool bUseSoundsPitchVal;
#ifdef _DEBUG
char chName[64];
#endif
}
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
public:
SoundEngine();
void destroy() override;
#ifdef _DEBUG
void GetSoundName(char *szSoundName,int iSound);
#endif
void play(int iSound, float x, float y, float z, float volume, float pitch) override;
void playStreaming(const wstring& name, float x, float y , float z, float volume, float pitch, bool bMusicDelay=true) override;
void playUI(int iSound, float volume, float pitch) override;
void playMusicTick() override;
void updateMusicVolume(float fVal) override;
void updateSystemMusicPlaying(bool isPlaying) override;
void updateSoundEffectVolume(float fVal) override;
void init(Options *) override;
void tick(shared_ptr<Mob> *players, float a) override; // 4J - updated to take array of local players rather than single one
void add(const wstring& name, File *file) override;
void addMusic(const wstring& name, File *file) override;
void addStreaming(const wstring& name, File *file) override;
char *ConvertSoundPathToName(const wstring& name, bool bConvertSpaces=false) override;
bool isStreamingWavebankReady(); // 4J Added
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 updateMiniAudio();
void playMusicUpdate();
private:
float getMasterMusicVolume();
int initAudioHardware(int iMinSpeakers) override
{ return iMinSpeakers;}
int GetRandomishTrack(int iStart,int iEnd);
ma_engine m_engine;
ma_engine_config m_engineConfig;
ma_sound m_musicStream;
bool m_musicStreamActive;
static char m_szSoundPath[];
static char m_szMusicPath[];
static char m_szRedistName[];
static const char *m_szStreamFileA[eStream_Max];
AUDIO_LISTENER m_ListenerA[MAX_LOCAL_PLAYERS];
int m_validListenerCount;
Random *random;
int m_musicID;
int m_iMusicDelay;
int m_StreamState;
int m_MusicType;
AUDIO_INFO m_StreamingAudioInfo;
wstring m_CDMusic;
BOOL m_bSystemMusicPlaying;
float m_MasterMusicVolume;
float m_MasterEffectsVolume;
C4JThread *m_openStreamThread;
static int OpenStreamThreadProc( void* lpParameter );
char m_szStreamName[255];
int CurrentSoundsPlaying[eSoundType_MAX+eSFX_MAX];
// streaming music files - will be different for mash-up packs
int m_iStream_Overworld_Min,m_iStream_Overworld_Max;
int m_iStream_Nether_Min,m_iStream_Nether_Max;
int m_iStream_End_Min,m_iStream_End_Max;
int m_iStream_CD_1;
bool *m_bHeardTrackA;
};
@@ -14,11 +14,6 @@
#include <audioout.h>
#endif
#ifdef _WINDOWS64
#include "..\..\Minecraft.Client\Windows64\Windows64_App.h"
#include "..\..\Minecraft.Client\Windows64\Miles\include\imssapi.h"
#endif
#ifdef __ORBIS__
#include <audioout.h>
//#define __DISABLE_MILES__ // MGH disabled for now as it crashes if we call sceNpMatching2Initialize
@@ -1,4 +1,7 @@
#pragma once
#ifdef _WINDOWS64
#include "Common/Audio/Miniaudio_SoundEngine.h"
#else
class Mob;
class Options;
using namespace std;
@@ -126,14 +129,25 @@ private:
int GetRandomishTrack(int iStart,int iEnd);
#ifndef _WINDOWS64
HMSOUNDBANK m_hBank;
HDIGDRIVER m_hDriver;
HSTREAM m_hStream;
#endif
#ifdef _WINDOWS64
public:
static char m_szSoundPath[];
static char m_szMusicPath[];
static char m_szRedistName[];
static char *m_szStreamFileA[eStream_Max];
private:
#else
static char m_szSoundPath[];
static char m_szMusicPath[];
static char m_szRedistName[];
static char *m_szStreamFileA[eStream_Max];
#endif
AUDIO_LISTENER m_ListenerA[MAX_LOCAL_PLAYERS];
int m_validListenerCount;
@@ -166,3 +180,4 @@ private:
int32_t m_hBGMAudio;
#endif
};
#endif
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -29,7 +29,7 @@ $folderCopies = @(
@{ Source = "Durango\Sound"; Dest = "Sound" },
@{ Source = "DurangoMedia\DLC"; Dest = "DLC" },
@{ Source = "DurangoMedia\Tutorial"; Dest = "Tutorial" },
@{ Source = "music"; Dest = "music" },
@{ Source = "music\Miles"; Dest = "music" },
@{ Source = "Durango\DLCImages"; Dest = "DLCImages" },
@{ Source = "Durango\CU"; Dest = "CU" }
)
@@ -22,7 +22,7 @@ foreach ($dir in $directories) {
}
$folderCopies = @(
@{ Source = "music"; Dest = "PS4_GAME\music" },
@{ Source = "music\Miles"; Dest = "PS4_GAME\music" },
@{ Source = "Common\Media"; Dest = "PS4_GAME\Common\Media" },
@{ Source = "Common\res"; Dest = "PS4_GAME\Common\res" },
@{ Source = "Orbis\Sound"; Dest = "PS4_GAME\Orbis\Sound" },
@@ -20,12 +20,12 @@ foreach ($dir in $directories) {
}
$folderCopies = @(
@{ Source = "music"; Dest = "PS3_GAME\USRDIR\music" },
@{ Source = "music\Miles"; Dest = "PS3_GAME\USRDIR\music" },
@{ Source = "Common\Media"; Dest = "PS3_GAME\USRDIR\Common\Media" },
@{ Source = "Common\res"; Dest = "PS3_GAME\USRDIR\Common\res" },
@{ Source = "PS3Media\DLC"; Dest = "PS3_GAME\USRDIR\DLC" },
@{ Source = "PS3\Sound"; Dest = "PS3_GAME\USRDIR\PS3\Sound" },
#@{ Source = "PSVita\Tutorial"; Dest = "PS3_GAME\USRDIR\PS3\Tutorial" }, # str1k3r - softlocks game
#@{ Source = "PSVita\Tutorial"; Dest = "PS3_GAME\USRDIR\PS3\Tutorial" }, # str1k3r - softlocks game
@{ Source = Join-Path $PSScriptRoot "Contents\PS3\PS3_GAME\LICDIR"; Dest = "PS3_GAME\LICDIR" },
@{ Source = Join-Path $PSScriptRoot "Contents\PS3\PS3_GAME\TROPDIR"; Dest = "PS3_GAME\TROPDIR" }
)
@@ -20,7 +20,7 @@ foreach ($dir in $directories) {
}
$folderCopies = @(
@{ Source = "music"; Dest = "PSVITA_GAME\music" },
@{ Source = "music\Miles"; Dest = "PSVITA_GAME\music" },
@{ Source = "Common\Media"; Dest = "PSVITA_GAME\Common\Media" },
@{ Source = "Common\res"; Dest = "PSVITA_GAME\Common\res" },
@{ Source = "PSVita\Sound"; Dest = "PSVITA_GAME\PSVita\Sound" },
@@ -19,14 +19,12 @@ foreach ($dir in $directories) {
}
$folderCopies = @(
@{ Source = "music"; Dest = "music" },
@{ Source = "music\Miniaudio"; Dest = "music" },
@{ Source = "Common\Media"; Dest = "Common\Media" },
@{ Source = "Common\res"; Dest = "Common\res" },
@{ Source = "DurangoMedia"; Dest = "Windows64Media" },
@{ Source = "Windows64Media"; Dest = "Windows64Media" },
@{ Source = "Windows64Media\DLC"; Dest = "Windows64Media\DLC" },
#@{ Source = "PSVita\Tutorial"; Dest = "Windows64Media\Tutorial" }, # str1k3r - doesnt even work bru
@{ Source = "Windows64\Sound"; Dest = "Windows64Media\Sound" },
@{ Source = Join-Path $PSScriptRoot "Contents\Windows64\redist64"; Dest = "redist64" }
@{ Source = "Windows64Media\Sound"; Dest = "Windows64Media\Sound" }
)
foreach ($copy in $folderCopies) {
@@ -40,8 +38,7 @@ foreach ($copy in $folderCopies) {
$fileCopies = @(
@{ Source = Join-Path $ProjectDir "Windows64\4JLibs\4J_Input\Windows64\vendor\SDL\lib\x64\SDL3.dll"; Dest = "SDL3.dll" },
@{ Source = Join-Path $PSScriptRoot "Contents\Windows64\iggy_w64.dll"; Dest = "iggy_w64.dll" },
@{ Source = Join-Path $PSScriptRoot "Contents\Windows64\mss64.dll"; Dest = "mss64.dll" }
@{ Source = Join-Path $PSScriptRoot "Contents\Windows64\iggy_w64.dll"; Dest = "iggy_w64.dll" }
)
foreach ($copy in $fileCopies) {
@@ -0,0 +1,54 @@
#include "stdafx.h"
#include "Filesystem.h"
#include <windows.h>
#include <stdio.h>
bool FileOrDirectoryExists(const char* path)
{
DWORD attribs = GetFileAttributesA(path);
return (attribs != INVALID_FILE_ATTRIBUTES);
}
bool FileExists(const char* path)
{
DWORD attribs = GetFileAttributesA(path);
return (attribs != INVALID_FILE_ATTRIBUTES && !(attribs & FILE_ATTRIBUTE_DIRECTORY));
}
bool DirectoryExists(const char* path)
{
DWORD attribs = GetFileAttributesA(path);
return (attribs != INVALID_FILE_ATTRIBUTES && (attribs & FILE_ATTRIBUTE_DIRECTORY));
}
bool GetFirstFileInDirectory(const char* directory, char* outFilePath, size_t outFilePathSize)
{
char searchPath[MAX_PATH];
printf(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
printf(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
}
//str1k3r - credits to the smartCMD repo for this file
@@ -0,0 +1,8 @@
#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);
//str1k3r - credits to the smartCMD repo for this file
+14 -13
View File
@@ -254,11 +254,11 @@ UIController::UIController()
}
#ifdef _WINDOWS64
if(!ms_bControllerPollCSInitialised)
{
InitializeCriticalSection(&ms_controllerPollCS);
ms_bControllerPollCSInitialised = true;
}
//if(!ms_bControllerPollCSInitialised)
//{
// InitializeCriticalSection(&ms_controllerPollCS);
// ms_bControllerPollCSInitialised = true;
//}
#endif
}
@@ -313,8 +313,8 @@ void UIController::postInit()
m_LastControllerType = UNKNOWN;
m_bControllerTypeChanged = false;
m_controllerPollThread = new C4JThread(controllerPollThreadProc, (void*)this, "Controller poll thread");
m_controllerPollThread->Run();
//m_controllerPollThread = new C4JThread(controllerPollThreadProc, (void*)this, "Controller poll thread");
//m_controllerPollThread->Run();
#endif
for(unsigned int i = 0; i < eUIGroup_COUNT; ++i)
@@ -525,11 +525,12 @@ void UIController::tick()
}
#ifdef _WINDOWS64
fetchControlTooltipSWF();
//fetchControlTooltipSWF();
#endif
}
#ifdef _WINDOWS64
/*
int UIController::controllerPollThreadProc(void* lpParam)
{
UIController *controller = (UIController *)lpParam;
@@ -598,9 +599,9 @@ UIController::EControllerType UIController::GetControllerType(const char* contro
if (strcmp(controllerType, "STANDARD") == 0) return EControllerType::STANDARD;
return EControllerType::UNKNOWN;
}
}*/
void UIController::fetchControlTooltipSWF()
/*void UIController::fetchControlTooltipSWF()
{
if (!m_bControllerTypeChanged)
return;
@@ -626,7 +627,7 @@ void UIController::fetchControlTooltipSWF()
skinName = (m_fScreenHeight >= 1080.0f) ? L"skinControlTooltipsHD.swf" : L"skinControlTooltips.swf";
reloadSingleSkin(eLibrary_ControlTooltips, controlTooltipsPath, skinName);
}
}*/
#endif
void UIController::loadSkins()
@@ -641,12 +642,12 @@ void UIController::loadSkins()
if(m_fScreenWidth >= 1920.0f)
{
platformSkinPath = L"skinHDWin.swf";
controlTooltipsPath = GetControlTooltipsPath();
controlTooltipsPath = L"ControlTooltips\\HD\\Windows64HDControls.swf";
}
else
{
platformSkinPath = L"skinWin.swf";
controlTooltipsPath = GetControlTooltipsPath();
controlTooltipsPath = L"ControlTooltips\\Windows64Controls.swf";
}
#elif defined _DURANGO
if(m_fScreenHeight==1080.0f)