mirror of
https://github.com/HarbourMasters/Starship.git
synced 2025-01-23 21:45:00 +03:00
Its loading without issues finally! But its still broken
This commit is contained in:
parent
94bc6486eb
commit
2a8ac4891e
@ -1196,7 +1196,7 @@ extern SequenceLayer gSeqLayers[64];
|
||||
extern SequenceChannel gSeqChannelNone;
|
||||
extern AudioListItem gLayerFreeList;
|
||||
extern NotePool gNoteFreeLists;
|
||||
extern Sample* gUsedSamples[128];
|
||||
extern Sample* gUsedSamples[2048];
|
||||
extern AudioPreloadReq gPreloadSampleStack[128];
|
||||
extern s32 gNumUsedSamples;
|
||||
extern s32 gPreloadSampleStackTop;
|
||||
|
@ -46,7 +46,7 @@ SequenceLayer gSeqLayers[64];
|
||||
SequenceChannel gSeqChannelNone;
|
||||
AudioListItem gLayerFreeList;
|
||||
NotePool gNoteFreeLists;
|
||||
Sample* gUsedSamples[128];
|
||||
Sample* gUsedSamples[2048];
|
||||
AudioPreloadReq gPreloadSampleStack[128];
|
||||
s32 gNumUsedSamples;
|
||||
s32 gPreloadSampleStackTop;
|
||||
@ -144,91 +144,91 @@ ReverbSettings D_800C76A8[] = {
|
||||
{ 1, 0x30, 0x4FFF, 0, 0 },
|
||||
};
|
||||
AudioSpec gAudioSpecs[] = {
|
||||
/* 0 */ { 44100, 2, 22, ARRAY_COUNT(D_800C74D0), D_800C74D0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
/* 0 */ { 32000, 2, 22, ARRAY_COUNT(D_800C74D0), D_800C74D0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
0x35000 },
|
||||
/* 1 */
|
||||
{ 44100, 2, 22, ARRAY_COUNT(D_800C74E0), D_800C74E0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
{ 32000, 2, 22, ARRAY_COUNT(D_800C74E0), D_800C74E0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
0x35000 },
|
||||
/* 2 */
|
||||
{ 44100, 2, 22, ARRAY_COUNT(D_800C74F0), D_800C74F0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
{ 32000, 2, 22, ARRAY_COUNT(D_800C74F0), D_800C74F0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
0x35000 },
|
||||
/* 3 */
|
||||
{ 44100, 2, 22, ARRAY_COUNT(D_800C7500), D_800C7500, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
{ 32000, 2, 22, ARRAY_COUNT(D_800C7500), D_800C7500, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
0x35000 },
|
||||
/* 4 */
|
||||
{ 44100, 2, 22, ARRAY_COUNT(D_800C7510), D_800C7510, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
{ 32000, 2, 22, ARRAY_COUNT(D_800C7510), D_800C7510, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
0x35000 },
|
||||
/* 5 */
|
||||
{ 44100, 2, 22, ARRAY_COUNT(D_800C7520), D_800C7520, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
{ 32000, 2, 22, ARRAY_COUNT(D_800C7520), D_800C7520, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
0x35000 },
|
||||
/* 6 */
|
||||
{ 44100, 2, 22, ARRAY_COUNT(D_800C7530), D_800C7530, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
{ 32000, 2, 22, ARRAY_COUNT(D_800C7530), D_800C7530, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
0x35000 },
|
||||
/* 7 */
|
||||
{ 44100, 2, 22, ARRAY_COUNT(D_800C7540), D_800C7540, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
{ 32000, 2, 22, ARRAY_COUNT(D_800C7540), D_800C7540, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
0x35000 },
|
||||
/* 8 */
|
||||
{ 44100, 2, 22, ARRAY_COUNT(D_800C7550), D_800C7550, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
{ 32000, 2, 22, ARRAY_COUNT(D_800C7550), D_800C7550, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
0x35000 },
|
||||
/* 9 */
|
||||
{ 44100, 2, 22, ARRAY_COUNT(D_800C7560), D_800C7560, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
{ 32000, 2, 22, ARRAY_COUNT(D_800C7560), D_800C7560, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
0x35000 },
|
||||
/* 10 */
|
||||
{ 44100, 2, 22, ARRAY_COUNT(D_800C7570), D_800C7570, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
{ 32000, 2, 22, ARRAY_COUNT(D_800C7570), D_800C7570, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
0x35000 },
|
||||
/* 11 */
|
||||
{ 44100, 2, 22, ARRAY_COUNT(D_800C7580), D_800C7580, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
{ 32000, 2, 22, ARRAY_COUNT(D_800C7580), D_800C7580, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
0x35000 },
|
||||
/* 12 */
|
||||
{ 44100, 1, 22, ARRAY_COUNT(D_800C7590), D_800C7590, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x2B000,
|
||||
{ 32000, 1, 22, ARRAY_COUNT(D_800C7590), D_800C7590, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x2B000,
|
||||
0x35000 },
|
||||
/* 13 */
|
||||
{ 44100, 2, 22, ARRAY_COUNT(D_800C75A0), D_800C75A0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
{ 32000, 2, 22, ARRAY_COUNT(D_800C75A0), D_800C75A0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
0x35000 },
|
||||
/* 14 */
|
||||
{ 44100, 2, 22, ARRAY_COUNT(D_800C75B0), D_800C75B0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
{ 32000, 2, 22, ARRAY_COUNT(D_800C75B0), D_800C75B0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
0x35000 },
|
||||
/* 15 */
|
||||
{ 44100, 2, 22, ARRAY_COUNT(D_800C75C0), D_800C75C0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
{ 32000, 2, 22, ARRAY_COUNT(D_800C75C0), D_800C75C0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
0x34000 },
|
||||
/* 16 */
|
||||
{ 44100, 2, 22, ARRAY_COUNT(D_800C75D8), D_800C75D8, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
{ 32000, 2, 22, ARRAY_COUNT(D_800C75D8), D_800C75D8, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
0x35000 },
|
||||
/* 17 */
|
||||
{ 44100, 2, 22, ARRAY_COUNT(D_800C75E8), D_800C75E8, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
{ 32000, 2, 22, ARRAY_COUNT(D_800C75E8), D_800C75E8, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
0x35000 },
|
||||
/* 18 */
|
||||
{ 44100, 2, 22, ARRAY_COUNT(D_800C75F8), D_800C75F8, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
{ 32000, 2, 22, ARRAY_COUNT(D_800C75F8), D_800C75F8, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
0x35000 },
|
||||
/* 19 */
|
||||
{ 44100, 2, 22, ARRAY_COUNT(D_800C7608), D_800C7608, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
{ 32000, 2, 22, ARRAY_COUNT(D_800C7608), D_800C7608, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
0x35000 },
|
||||
/* 20 */
|
||||
{ 44100, 2, 22, ARRAY_COUNT(D_800C7618), D_800C7618, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
{ 32000, 2, 22, ARRAY_COUNT(D_800C7618), D_800C7618, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
0x35000 },
|
||||
/* 21 */
|
||||
{ 44100, 2, 32, ARRAY_COUNT(D_800C7628), D_800C7628, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
{ 32000, 2, 32, ARRAY_COUNT(D_800C7628), D_800C7628, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
0x00000 },
|
||||
/* 22 */
|
||||
{ 44100, 1, 32, ARRAY_COUNT(D_800C7638), D_800C7638, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
{ 32000, 1, 32, ARRAY_COUNT(D_800C7638), D_800C7638, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
0x00000 },
|
||||
/* 23 */
|
||||
{ 44100, 1, 32, ARRAY_COUNT(D_800C7648), D_800C7648, 0x7FFF, 0x1200, 0xA000, 0, 0x5B00, 0x1D00, 0, 0x00000,
|
||||
{ 32000, 1, 32, ARRAY_COUNT(D_800C7648), D_800C7648, 0x7FFF, 0x1200, 0xA000, 0, 0x5B00, 0x1D00, 0, 0x00000,
|
||||
0x00000 },
|
||||
/* 24 */
|
||||
{ 44100, 1, 22, ARRAY_COUNT(D_800C7658), D_800C7658, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x00000,
|
||||
{ 32000, 1, 22, ARRAY_COUNT(D_800C7658), D_800C7658, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x00000,
|
||||
0x60000 },
|
||||
/* 25 */
|
||||
{ 44100, 2, 22, ARRAY_COUNT(D_800C7668), D_800C7668, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
{ 32000, 2, 22, ARRAY_COUNT(D_800C7668), D_800C7668, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
0x00000 },
|
||||
/* 26 */
|
||||
{ 44100, 2, 22, ARRAY_COUNT(D_800C7678), D_800C7678, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
{ 32000, 2, 22, ARRAY_COUNT(D_800C7678), D_800C7678, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
0x00000 },
|
||||
/* 27 */
|
||||
{ 44100, 2, 32, ARRAY_COUNT(D_800C7688), D_800C7688, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
{ 32000, 2, 32, ARRAY_COUNT(D_800C7688), D_800C7688, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
0x00000 },
|
||||
/* 28 */
|
||||
{ 44100, 2, 22, ARRAY_COUNT(D_800C74D0), D_800C74D0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
{ 32000, 2, 22, ARRAY_COUNT(D_800C74D0), D_800C74D0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
|
||||
0x35000 },
|
||||
};
|
||||
s32 D_800C7C28 = 0x20000000; // unused?
|
||||
|
@ -222,7 +222,7 @@ f32 func_80013B90(AdsrState* adsr) {
|
||||
adsr->delay = 1;
|
||||
}
|
||||
|
||||
adsr->target = (s16)BE16SWAP(adsr->envelope[adsr->envIndex].arg) / 32767.0f;
|
||||
adsr->target = (s16)BSWAP16(adsr->envelope[adsr->envIndex].arg) / 32767.0f;
|
||||
adsr->target = SQ(adsr->target);
|
||||
adsr->velocity = (adsr->target - adsr->current) / adsr->delay;
|
||||
adsr->state = ADSR_STATE_FADE;
|
||||
|
@ -648,9 +648,12 @@ void AudioHeap_Init(void) {
|
||||
|
||||
gSampleDmaCount = 0;
|
||||
gAudioBufferParams.samplingFrequency = spec->samplingFrequency;
|
||||
gAudioBufferParams.aiSamplingFrequency = osAiSetFrequency(gAudioBufferParams.samplingFrequency);
|
||||
gAudioBufferParams.aiSamplingFrequency = 32000;
|
||||
gAudioBufferParams.samplesPerFrameTarget = ALIGN16(gAudioBufferParams.samplingFrequency / gRefreshRate);
|
||||
|
||||
printf("aiSamplingFrequency %d\n", gAudioBufferParams.aiSamplingFrequency);
|
||||
printf("samplesPerFrameTarget %d\n", gAudioBufferParams.samplesPerFrameTarget);
|
||||
|
||||
gAudioBufferParams.minAiBufferLength = gAudioBufferParams.samplesPerFrameTarget - 0x10;
|
||||
gAudioBufferParams.maxAiBufferLength = gAudioBufferParams.samplesPerFrameTarget + 0x10;
|
||||
|
||||
|
@ -520,6 +520,7 @@ void* AudioLoad_SyncLoad(u32 tableType, u32 id, s32* didAllocate) {
|
||||
return Audio_LoadBlob(gAudioSeq, table->entries[id].romAddr);
|
||||
case FONT_TABLE:
|
||||
gFontLoadStatus[id] = LOAD_STATUS_COMPLETE;
|
||||
printf("fontId: %d\n", id);
|
||||
return Audio_LoadFont(table->entries[id]);
|
||||
case SAMPLE_TABLE:
|
||||
loadStatus = 0;
|
||||
@ -604,6 +605,7 @@ void AudioLoad_RelocateFont(s32 fontId, uintptr_t fontBaseAddr, SampleBankRelocI
|
||||
// }
|
||||
// }
|
||||
AudioTable* table = AudioLoad_GetLoadTable(FONT_TABLE);
|
||||
printf("fontId: %d\n", fontId);
|
||||
SoundFont* font = Audio_LoadFont(table->entries[fontId]);
|
||||
|
||||
gSoundFontList[fontId].drums = font->drums;
|
||||
@ -707,6 +709,7 @@ void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData,
|
||||
return Audio_LoadBlob(gAudioSeq, table->entries[id].romAddr);
|
||||
case FONT_TABLE:
|
||||
gFontLoadStatus[id] = LOAD_STATUS_COMPLETE;
|
||||
printf("fontId: %d\n", id);
|
||||
return Audio_LoadFont(table->entries[id]);
|
||||
case SAMPLE_TABLE:
|
||||
gSampleFontLoadStatus[id] = LOAD_STATUS_COMPLETE;
|
||||
@ -1259,7 +1262,7 @@ s32 AudioLoad_RelocateFontAndPreloadSamples(s32 fontId, uintptr_t fontDataAddr,
|
||||
s32 inProgress;
|
||||
isAsync = 0;
|
||||
|
||||
printf("Relocating font %d\n", fontId);
|
||||
// printf("Relocating font %d\n", fontId);
|
||||
inProgress = false;
|
||||
if (gPreloadSampleStackTop != 0) {
|
||||
inProgress = true;
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "sys.h"
|
||||
#include "sf64audio_provisional.h"
|
||||
#include "port/resource/loaders/AudioLoader.h"
|
||||
|
||||
static const char devstr00[] = "Audio: setvol: volume minus %f\n";
|
||||
static const char devstr01[] = "Audio: setvol: volume overflow %f\n";
|
||||
@ -168,6 +169,11 @@ TunedSample* func_80011D10(Instrument* instrument, s32 arg1) {
|
||||
Instrument* Audio_GetInstrument(s32 fontId, s32 instId) {
|
||||
Instrument* instrument;
|
||||
|
||||
// LTODO: Remove this
|
||||
if(gSoundFontList[fontId].instruments == NULL){
|
||||
gSoundFontList[fontId] = *Audio_LoadFont(gSoundFontTable->entries[fontId]);
|
||||
}
|
||||
|
||||
if ((gFontLoadStatus[fontId] < 2) != 0) {
|
||||
D_80155D88 = fontId + 0x10000000;
|
||||
return NULL;
|
||||
@ -187,6 +193,11 @@ Instrument* Audio_GetInstrument(s32 fontId, s32 instId) {
|
||||
Drum* Audio_GetDrum(s32 fontId, s32 drumId) {
|
||||
Drum* drum;
|
||||
|
||||
// LTODO: Remove this
|
||||
if(gSoundFontList[fontId].drums == NULL){
|
||||
gSoundFontList[fontId] = *Audio_LoadFont(gSoundFontTable->entries[fontId]);
|
||||
}
|
||||
|
||||
if ((gFontLoadStatus[fontId] < 2) != 0) {
|
||||
D_80155D88 = fontId + 0x10000000;
|
||||
return NULL;
|
||||
@ -195,9 +206,9 @@ Drum* Audio_GetDrum(s32 fontId, s32 drumId) {
|
||||
D_80155D88 = (fontId << 8) + drumId + 0x04000000;
|
||||
return NULL;
|
||||
}
|
||||
if ((u32) gSoundFontList[fontId].drums < AUDIO_RELOCATED_ADDRESS_START) {
|
||||
return NULL;
|
||||
}
|
||||
// if ((u32) gSoundFontList[fontId].drums < AUDIO_RELOCATED_ADDRESS_START) {
|
||||
// return NULL;
|
||||
// }
|
||||
drum = gSoundFontList[fontId].drums[drumId];
|
||||
if (gSoundFontList[fontId].drums[drumId] == NULL) {
|
||||
D_80155D88 = (fontId << 8) + drumId + 0x05000000;
|
||||
|
@ -644,12 +644,12 @@ Acmd* func_80009B64(Acmd* aList, s32* cmdCount, s16* aiBufStart, s32 aiBufLen) {
|
||||
}
|
||||
|
||||
aiBufPtr = (s32*) aiBufStart;
|
||||
for (i = gAudioBufferParams.ticksPerUpdate; i > 0; i--) {
|
||||
for (i = gAudioBufferParams.ticksPerUpdate - 1; i > 0; i--) {
|
||||
if (i == 1) {
|
||||
chunkLen = aiBufLen;
|
||||
} else if ((aiBufLen / i) >= gAudioBufferParams.samplesPerTickMax) {
|
||||
chunkLen = gAudioBufferParams.samplesPerTickMax;
|
||||
} else if ((aiBufLen / i) <= gAudioBufferParams.samplesPerTickMin) {
|
||||
} else if (gAudioBufferParams.samplesPerTickMin >= (aiBufLen / i)) {
|
||||
chunkLen = gAudioBufferParams.samplesPerTickMin;
|
||||
} else {
|
||||
chunkLen = gAudioBufferParams.samplesPerTick;
|
||||
@ -1003,12 +1003,13 @@ Acmd* func_8000A700(s32 noteIndex, NoteSubEu* noteSub, NoteSynthesisState* synth
|
||||
aligned = ALIGN16(nFramesToDecode * frameSize + 0x10);
|
||||
addr = 0x990 - aligned;
|
||||
if (nFramesToDecode != 0) {
|
||||
// LTODO: Validate this
|
||||
// bookSample->medium = 0;
|
||||
|
||||
frameIndex = (synthState->samplePosInt + skipInitialSamples - nFirstFrameSamplesToIgnore) / 16;
|
||||
sampleDataOffset = frameIndex * frameSize;
|
||||
// LTODO: Validate this
|
||||
bookSample->medium = 0;
|
||||
if (bookSample->medium == 0) {
|
||||
sampleData = sampleAddr + sampleDataOffset; //sampleDmaStart + sampleAddr;
|
||||
sampleData = sampleDmaStart + sampleDataOffset + sampleAddr;
|
||||
} else {
|
||||
sampleData = AudioLoad_DmaSampleData(sampleDmaStart + sampleDataOffset + sampleAddr, aligned,
|
||||
flags, &synthState->sampleDmaIndex, bookSample->medium);
|
||||
|
@ -47,8 +47,8 @@ void AudioThread_CreateNextAudioBuffer(s16 *samples, u32 num_samples) {
|
||||
OSMesg msg;
|
||||
|
||||
gCurAudioFrameDmaCount = 0;
|
||||
// AudioLoad_DecreaseSampleDmaTtls();
|
||||
// AudioLoad_ProcessLoads(gAudioResetStep);
|
||||
AudioLoad_DecreaseSampleDmaTtls();
|
||||
AudioLoad_ProcessLoads(gAudioResetStep);
|
||||
|
||||
if (MQ_GET_MESG(gAudioSpecQueue, &specId)) {
|
||||
if (gAudioResetStep == 0) {
|
||||
|
@ -200,10 +200,10 @@ u8 gDefaultShortNoteGateTimeTable[] = {
|
||||
};
|
||||
|
||||
EnvelopePoint gDefaultEnvelope[] = {
|
||||
{ 4, 32000 },
|
||||
{ 1000, 32000 },
|
||||
{ ADSR_HANG, 0 },
|
||||
{ ADSR_DISABLE, 0 },
|
||||
{ BE16SWAP_CONST(4), BE16SWAP_CONST(32000) },
|
||||
{ BE16SWAP_CONST(1000), BE16SWAP_CONST(32000) },
|
||||
{ BE16SWAP_CONST(ADSR_HANG), 0 },
|
||||
{ BE16SWAP_CONST(ADSR_DISABLE), 0 },
|
||||
};
|
||||
|
||||
NoteSubEu gZeroNoteSub = { 0 };
|
||||
|
@ -66,7 +66,7 @@ GameEngine::GameEngine() {
|
||||
}
|
||||
}
|
||||
|
||||
this->context = Ship::Context::CreateInstance("Starship", "ship", "starship.cfg.json", OTRFiles, {}, 3, { 44100, 1024, 2480 });
|
||||
this->context = Ship::Context::CreateInstance("Starship", "ship", "starship.cfg.json", OTRFiles, {}, 3, { 32000, 512, 1100 });
|
||||
|
||||
auto loader = context->GetResourceManager()->GetResourceLoader();
|
||||
loader->RegisterResourceFactory(std::make_shared<SF64::ResourceFactoryBinaryAnimV0>(), RESOURCE_FORMAT_BINARY, "Animation", static_cast<uint32_t>(SF64::ResourceType::AnimData), 0);
|
||||
|
@ -6,10 +6,11 @@
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <filesystem>
|
||||
#include "test.c"
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
Ship::BinaryReader Audio_MakeReader(const char* resource, u32 offset = 0){
|
||||
Ship::BinaryReader Audio_MakeReader(const char* resource, u32 offset){
|
||||
auto data = (char*)ResourceGetDataByName(resource);
|
||||
auto size = ResourceGetSizeByName(resource);
|
||||
|
||||
@ -59,20 +60,21 @@ extern "C" SoundFont* Audio_LoadFont(AudioTableEntry entry) {
|
||||
font->instruments = memallocn(Instrument*, font->numInstruments);
|
||||
font->drums = memallocn(Drum*, font->numDrums);
|
||||
|
||||
uint32_t drumBaseAddr = entry.romAddr + reader.ReadUInt32();
|
||||
uint32_t drumBaseAddr = reader.ReadUInt32();
|
||||
uint32_t instBaseAddr = 4;
|
||||
|
||||
if(font->drums != nullptr && drumBaseAddr != 0){
|
||||
reader.Seek(drumBaseAddr, Ship::SeekOffsetType::Start);
|
||||
reader.Seek(entry.romAddr + drumBaseAddr, Ship::SeekOffsetType::Start);
|
||||
for(size_t i = 0; i < font->numDrums; i++){
|
||||
font->drums[i] = Audio_LoadDrum(entry.romAddr + reader.ReadUInt32(), entry.romAddr, font->sampleBankId1);
|
||||
font->drums[i] = Audio_LoadDrum(reader.ReadUInt32(), entry, font->sampleBankId1);
|
||||
}
|
||||
}
|
||||
|
||||
if(font->instruments != nullptr){
|
||||
reader.Seek(instBaseAddr, Ship::SeekOffsetType::Start);
|
||||
for(size_t i = 1; i < font->numInstruments; i++){
|
||||
font->instruments[i] = Audio_LoadInstrument(reader.ReadUInt32(), font->sampleBankId1);
|
||||
reader.Seek(entry.romAddr + instBaseAddr, Ship::SeekOffsetType::Start);
|
||||
for(size_t i = 0; i < font->numInstruments; i++){
|
||||
u32 instAddr = reader.ReadUInt32();
|
||||
font->instruments[i] = Audio_LoadInstrument(instAddr, entry, font->sampleBankId1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -119,19 +121,22 @@ extern "C" AdpcmBook* Audio_LoadBook(uint32_t addr) {
|
||||
return book;
|
||||
}
|
||||
|
||||
Sample* Audio_LoadSample(uint32_t sampleAddr, uint32_t baseAddr = 0, uint32_t sampleBankID = 0) {
|
||||
auto reader = Audio_MakeReader(gAudioBank, sampleAddr);
|
||||
Sample* Audio_LoadSample(uint32_t sampleAddr, AudioTableEntry entry, uint32_t sampleBankID) {
|
||||
auto reader = Audio_MakeReader(gAudioBank, entry.romAddr + sampleAddr);
|
||||
|
||||
Sample* sample = memalloc(Sample);
|
||||
sample->size = reader.ReadUInt32();
|
||||
uint32_t flags = reader.ReadUInt32();
|
||||
sample->codec = (flags >> 28) & 0x0F;
|
||||
sample->medium = MEDIUM_RAM; // (flags >> 24) & 0x03;
|
||||
sample->unk_bit26 = (flags >> 22) & 0x01;
|
||||
sample->size = flags;
|
||||
uint32_t addr = reader.ReadUInt32();
|
||||
sample->loop = Audio_LoadLoop(baseAddr + reader.ReadUInt32());
|
||||
sample->book = Audio_LoadBook(baseAddr + reader.ReadUInt32());
|
||||
|
||||
sample->loop = Audio_LoadLoop(entry.romAddr + reader.ReadUInt32());
|
||||
sample->book = Audio_LoadBook(entry.romAddr + reader.ReadUInt32());
|
||||
sample->isRelocated = 1;
|
||||
sample->sampleAddr = (uint8_t*) Audio_LoadBlob(gAudioTable, gSampleBankTable->entries[sampleBankID].romAddr + addr);
|
||||
|
||||
std::filesystem::path path{ "dumps/" + std::to_string(sampleAddr) + ".raw" };
|
||||
std::filesystem::path path{ "dumps/" + std::to_string(addr) + ".raw" };
|
||||
std::ofstream ofs(path);
|
||||
ofs.write(reinterpret_cast<const char*>(sample->sampleAddr), sample->size);
|
||||
ofs.close();
|
||||
@ -140,8 +145,8 @@ Sample* Audio_LoadSample(uint32_t sampleAddr, uint32_t baseAddr = 0, uint32_t sa
|
||||
return sample;
|
||||
}
|
||||
|
||||
TunedSample Audio_LoadTunedSample(uint32_t addr, uint32_t baseAddr = 0, uint32_t sampleBankID = 0) {
|
||||
auto reader = Audio_MakeReader(gAudioBank, addr);
|
||||
TunedSample Audio_LoadTunedSample(uint32_t addr, AudioTableEntry entry, uint32_t sampleBankID) {
|
||||
auto reader = Audio_MakeReader(gAudioBank, entry.romAddr + addr);
|
||||
auto sampleAddr = reader.ReadUInt32();
|
||||
auto tuning = reader.ReadFloat();
|
||||
|
||||
@ -151,39 +156,34 @@ TunedSample Audio_LoadTunedSample(uint32_t addr, uint32_t baseAddr = 0, uint32_t
|
||||
}
|
||||
|
||||
return {
|
||||
.sample = Audio_LoadSample(baseAddr + sampleAddr, baseAddr, sampleBankID),
|
||||
.sample = Audio_LoadSample(sampleAddr, entry, sampleBankID),
|
||||
.tuning = tuning
|
||||
};
|
||||
}
|
||||
|
||||
extern "C" Instrument* Audio_LoadInstrument(uint32_t addr, uint32_t sampleBankID) {
|
||||
extern "C" Instrument* Audio_LoadInstrument(uint32_t addr, AudioTableEntry entry, uint32_t sampleBankID) {
|
||||
if (addr == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto reader = Audio_MakeReader(gAudioBank, addr);
|
||||
auto reader = Audio_MakeReader(gAudioBank, entry.romAddr + addr);
|
||||
|
||||
Instrument* instrument = memalloc(Instrument);
|
||||
instrument->isRelocated = reader.ReadUByte();
|
||||
instrument->normalRangeLo = reader.ReadUByte();
|
||||
instrument->normalRangeHi = reader.ReadUByte();
|
||||
instrument->adsrDecayIndex = reader.ReadUByte();
|
||||
instrument->envelope = Audio_LoadEnvelope(reader.ReadUInt32());
|
||||
instrument->lowPitchTunedSample = Audio_LoadTunedSample(addr + 8, 0, sampleBankID);
|
||||
instrument->normalPitchTunedSample = Audio_LoadTunedSample(addr + 16, 0, sampleBankID);
|
||||
instrument->highPitchTunedSample = Audio_LoadTunedSample(addr + 24, 0, sampleBankID);
|
||||
instrument->envelope = Audio_LoadEnvelope(entry.romAddr + reader.ReadUInt32());
|
||||
instrument->lowPitchTunedSample = Audio_LoadTunedSample(addr + 8, entry, sampleBankID);
|
||||
instrument->normalPitchTunedSample = Audio_LoadTunedSample(addr + 16, entry, sampleBankID);
|
||||
instrument->highPitchTunedSample = Audio_LoadTunedSample(addr + 24, entry, sampleBankID);
|
||||
instrument->isRelocated = 1;
|
||||
|
||||
return instrument;
|
||||
}
|
||||
|
||||
extern "C" Drum* Audio_LoadDrum(uint32_t addr, uint32_t baseAddr, uint32_t sampleBankID) {
|
||||
|
||||
if(baseAddr != 0 && addr >= baseAddr){
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto reader = Audio_MakeReader(gAudioBank, addr);
|
||||
extern "C" Drum* Audio_LoadDrum(uint32_t addr, AudioTableEntry entry, uint32_t sampleBankID) {
|
||||
auto reader = Audio_MakeReader(gAudioBank, entry.romAddr + addr);
|
||||
Drum* drum = memalloc(Drum);
|
||||
|
||||
drum->adsrDecayIndex = reader.ReadInt8();
|
||||
@ -192,10 +192,9 @@ extern "C" Drum* Audio_LoadDrum(uint32_t addr, uint32_t baseAddr, uint32_t sampl
|
||||
reader.ReadUByte();
|
||||
drum->isRelocated = 1;
|
||||
|
||||
|
||||
drum->tunedSample = Audio_LoadTunedSample(addr + 4, baseAddr, sampleBankID);
|
||||
drum->tunedSample = Audio_LoadTunedSample(addr + 4, entry, sampleBankID);
|
||||
reader.Seek(0x8, Ship::SeekOffsetType::Current);
|
||||
drum->envelope = Audio_LoadEnvelope(reader.ReadUInt32());
|
||||
drum->envelope = Audio_LoadEnvelope(entry.romAddr + reader.ReadUInt32());
|
||||
|
||||
return drum;
|
||||
}
|
@ -10,9 +10,9 @@ extern "C" {
|
||||
char* Audio_LoadBlob(const char* resource, u32 offset);
|
||||
AdpcmBook* Audio_LoadBook(uint32_t addr);
|
||||
AdpcmLoop* Audio_LoadLoop(uint32_t addr);
|
||||
Instrument* Audio_LoadInstrument(uint32_t addr, uint32_t sampleBankID);
|
||||
Drum* Audio_LoadDrum(uint32_t addr, uint32_t baseAddr, uint32_t sampleBankID);
|
||||
Sample* Audio_LoadSample(uint32_t addr, uint32_t sampleBankID);
|
||||
Instrument* Audio_LoadInstrument(uint32_t addr, AudioTableEntry entry, uint32_t sampleBankID);
|
||||
Drum* Audio_LoadDrum(uint32_t addr, AudioTableEntry entry, uint32_t sampleBankID);
|
||||
Sample* Audio_LoadSample(uint32_t addr, AudioTableEntry entry, uint32_t sampleBankID);
|
||||
SoundFont* Audio_LoadFont(AudioTableEntry entry);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
3
src/port/resource/loaders/test.c
Normal file
3
src/port/resource/loaders/test.c
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user