mirror of
https://github.com/izzy2lost/Ghostship.git
synced 2026-06-19 01:17:03 -07:00
Fucking fixed audio <3
This commit is contained in:
+3
-4
@@ -7,7 +7,7 @@
|
||||
#include "synthesis.h"
|
||||
#include "seqplayer.h"
|
||||
#include "effects.h"
|
||||
#include <lib/src/osAi.h>
|
||||
#include "port/Globals.h"
|
||||
|
||||
#define ALIGN16(val) (((val) + 0xF) & ~0xF)
|
||||
|
||||
@@ -1161,8 +1161,7 @@ void audio_reset_session(void) {
|
||||
remainingDmas = gCurrAudioFrameDmaCount;
|
||||
while (remainingDmas > 0) {
|
||||
for (i = 0; i < gCurrAudioFrameDmaCount; i++) {
|
||||
if (osRecvMesg(&gCurrAudioFrameDmaQueue, NULL, OS_MESG_NOBLOCK) == 0)
|
||||
remainingDmas--;
|
||||
remainingDmas--;
|
||||
}
|
||||
}
|
||||
gCurrAudioFrameDmaCount = 0;
|
||||
@@ -1219,7 +1218,7 @@ void audio_reset_session(void) {
|
||||
#endif
|
||||
#else
|
||||
reverbWindowSize = preset->reverbWindowSize;
|
||||
gAiFrequency = osAiSetFrequency(preset->frequency);
|
||||
gAiFrequency = GameEngine_GetSampleRate();
|
||||
gMaxSimultaneousNotes = preset->maxSimultaneousNotes;
|
||||
gSamplesPerFrameTarget = ALIGN16(gAiFrequency / 60);
|
||||
gReverbDownsampleRate = preset->reverbDownsampleRate;
|
||||
|
||||
+4
-13
@@ -113,7 +113,7 @@ ALSeqFile *get_audio_file_header(s32 arg0);
|
||||
* Performs an immediate DMA copy
|
||||
*/
|
||||
void audio_dma_copy_immediate(uintptr_t devAddr, void *vAddr, size_t nbytes) {
|
||||
printf("Romcopy %x -> %x ,size %x\n", devAddr, vAddr, nbytes);
|
||||
eu_stubbed_printf_3("Romcopy %x -> %x ,size %x\n", devAddr, vAddr, nbytes);
|
||||
osInvalDCache(vAddr, nbytes);
|
||||
osPiStartDma(&gAudioDmaIoMesg, OS_MESG_PRI_HIGH, OS_READ, devAddr, vAddr, nbytes,
|
||||
&gAudioDmaMesgQueue);
|
||||
@@ -939,10 +939,7 @@ void audio_init() {
|
||||
gUnused80226E98[i] = 0;
|
||||
}
|
||||
|
||||
lim2 = gAudioHeapSize;
|
||||
for (i = 0; i <= lim2 / 8 - 1; i++) {
|
||||
((u64 *) gAudioHeap)[i] = 0;
|
||||
}
|
||||
memset(gAudioHeap, 0, gAudioHeapSize);
|
||||
|
||||
|
||||
#else
|
||||
@@ -993,9 +990,7 @@ void audio_init() {
|
||||
gAudioResetStatus = 1;
|
||||
audio_shut_down_and_reset_step();
|
||||
#else
|
||||
printf("Crashes Here?\n");
|
||||
audio_reset_session(&gAudioSessionPresets[0]);
|
||||
printf("Nope\n");
|
||||
#endif
|
||||
|
||||
// Not sure about these prints
|
||||
@@ -1014,11 +1009,9 @@ void audio_init() {
|
||||
#else
|
||||
size = ALIGN16(gSequenceCount * sizeof(ALSeqData) + 4);
|
||||
#endif
|
||||
printf("Crashes Here?\n");
|
||||
gSeqFileHeader = soundAlloc(&gAudioInitPool, size);
|
||||
audio_dma_copy_immediate((uintptr_t) data, gSeqFileHeader, size);
|
||||
alSeqFileNew(gSeqFileHeader, data);
|
||||
printf("Nope\n");
|
||||
|
||||
// Load header for CTL (instrument metadata)
|
||||
gAlCtlHeader = (ALSeqFile *) buf;
|
||||
@@ -1041,10 +1034,8 @@ void audio_init() {
|
||||
alSeqFileNew(gAlTbl, gSoundDataRaw);
|
||||
|
||||
// Load bank sets for each sequence
|
||||
printf("Crashes Here on bank sets?\n");
|
||||
gAlBankSets = soundAlloc(&gAudioInitPool, 0x100);
|
||||
audio_dma_copy_immediate((uintptr_t) gBankSetsData, gAlBankSets, 0x100);
|
||||
printf("Nope\n");
|
||||
gAlBankSets = soundAlloc(&gAudioInitPool, 0xA0);
|
||||
audio_dma_copy_immediate((uintptr_t) gBankSetsData, gAlBankSets, 0xA0);
|
||||
init_sequence_players();
|
||||
gAudioLoadLock = AUDIO_LOCK_NOT_LOADING;
|
||||
// Should probably contain the sizes of the data banks, but those aren't
|
||||
|
||||
+5
-5
@@ -4,8 +4,8 @@
|
||||
#include <Fast3D/gfx_pc.h>
|
||||
#include "Globals.h"
|
||||
|
||||
#define SAMPLES_HIGH 544
|
||||
#define SAMPLES_LOW 528
|
||||
#define SAMPLES_HIGH 752
|
||||
#define SAMPLES_LOW 720
|
||||
#define AUDIO_FRAMES_PER_UPDATE 2
|
||||
#define NUM_AUDIO_CHANNELS 2
|
||||
|
||||
@@ -20,10 +20,10 @@ u32 gNumVblanks = 0;
|
||||
s8 gNmiResetBarsTimer = 0;
|
||||
u64 osClockRate = 62500000;
|
||||
|
||||
s8 sAudioEnabled = FALSE;
|
||||
s8 sAudioEnabled = TRUE;
|
||||
s8 gShowProfiler = FALSE;
|
||||
s8 gShowDebugText = FALSE;
|
||||
s8 gDebugLevelSelect = FALSE;
|
||||
s8 gDebugLevelSelect = TRUE;
|
||||
|
||||
OSIoMesg gDmaIoMesg;
|
||||
OSMesg gMainReceivedMesg;
|
||||
@@ -36,7 +36,7 @@ void set_vblank_handler(s32 index, VblankHandler *handler, OSMesgQueue *queue, O
|
||||
void dispatch_audio_sptask(SPTask *spTask) {}
|
||||
|
||||
void alloc_pool(void) {
|
||||
static u64 pool[0x165000 * sizeof(void *)];
|
||||
static u64 pool[1024 * 1024 * 4];
|
||||
main_pool_init(pool, pool + sizeof(pool) / sizeof(pool[0]));
|
||||
gEffectsMemoryPool = mem_pool_init(0x4000, MEMORY_POOL_LEFT);
|
||||
}
|
||||
|
||||
@@ -31,4 +31,17 @@ void GameEngine_RunCommands(Gfx* Commands) {
|
||||
|
||||
void GameEngine_ProcessFrame(void (*run_one_game_iter)(void)) {
|
||||
GameEngine::Instance->context->GetWindow()->MainLoop(run_one_game_iter);
|
||||
}
|
||||
|
||||
extern "C" uint32_t GameEngine_GetSampleRate(void) {
|
||||
auto audio = LUS::Context::GetInstance()->GetAudio()->GetAudioPlayer();
|
||||
if (audio == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!audio->IsInitialized()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return audio->GetSampleRate();
|
||||
}
|
||||
+6
-2
@@ -1,10 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <vector>
|
||||
#include <Context.h>
|
||||
|
||||
class GameEngine {
|
||||
public:
|
||||
public:
|
||||
static GameEngine* Instance;
|
||||
|
||||
std::shared_ptr<LUS::Context> context;
|
||||
@@ -17,4 +18,7 @@ public:
|
||||
void GameEngine_Create(void);
|
||||
void GameEngine_StartFrame(void);
|
||||
void GameEngine_RunCommands(Gfx* Commands);
|
||||
void GameEngine_ProcessFrame(void (*run_one_game_iter)(void));
|
||||
void GameEngine_ProcessFrame(void (*run_one_game_iter)(void));
|
||||
#else
|
||||
uint32_t GameEngine_GetSampleRate(void);
|
||||
#endif
|
||||
Reference in New Issue
Block a user