mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-22 14:23:44 -07:00
Format and fix mixer for Windows
This commit is contained in:
parent
d35b1605ec
commit
630c814f0c
14 changed files with 234 additions and 237 deletions
|
@ -16,7 +16,6 @@
|
||||||
#define ROUND_UP_8(v) (((v) + 7) & ~7)
|
#define ROUND_UP_8(v) (((v) + 7) & ~7)
|
||||||
#define ROUND_DOWN_16(v) ((v) & ~0xf)
|
#define ROUND_DOWN_16(v) ((v) & ~0xf)
|
||||||
|
|
||||||
|
|
||||||
#define DMEM_BUF_SIZE (0x1000 - 0x3C0 - 0x40)
|
#define DMEM_BUF_SIZE (0x1000 - 0x3C0 - 0x40)
|
||||||
#define BUF_U8(a) (rspa.buf.as_u8 + ((a)-0x3C0))
|
#define BUF_U8(a) (rspa.buf.as_u8 + ((a)-0x3C0))
|
||||||
#define BUF_S16(a) (rspa.buf.as_s16 + ((a)-0x3C0) / sizeof(int16_t))
|
#define BUF_S16(a) (rspa.buf.as_s16 + ((a)-0x3C0) / sizeof(int16_t))
|
||||||
|
@ -38,7 +37,7 @@ static struct {
|
||||||
uint16_t filter_count;
|
uint16_t filter_count;
|
||||||
int16_t filter[8];
|
int16_t filter[8];
|
||||||
|
|
||||||
__attribute__((aligned(16))) union {
|
union {
|
||||||
int16_t as_s16[DMEM_BUF_SIZE / sizeof(int16_t)];
|
int16_t as_s16[DMEM_BUF_SIZE / sizeof(int16_t)];
|
||||||
uint8_t as_u8[DMEM_BUF_SIZE];
|
uint8_t as_u8[DMEM_BUF_SIZE];
|
||||||
} buf;
|
} buf;
|
||||||
|
|
|
@ -346,8 +346,7 @@ uint8_t ResourceFactoryXMLAudioSampleV0::CodecStrToInt(const char* str, const ch
|
||||||
return CODEC_S16;
|
return CODEC_S16;
|
||||||
} else {
|
} else {
|
||||||
char buff[2048];
|
char buff[2048];
|
||||||
snprintf(buff, 2048,
|
snprintf(buff, 2048, "Invalid codec in %s. Got %s, expected ADPCM, S8, S16MEM, ADPCMSMALL, REVERB, S16.", file,
|
||||||
"Invalid codec in %s. Got %s, expected ADPCM, S8, S16MEM, ADPCMSMALL, REVERB, S16.", file,
|
|
||||||
str);
|
str);
|
||||||
throw std::runtime_error(buff);
|
throw std::runtime_error(buff);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ class ResourceFactoryBinaryAudioSampleV2 final : public Ship::ResourceFactoryBin
|
||||||
public:
|
public:
|
||||||
std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file,
|
std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file,
|
||||||
std::shared_ptr<Ship::ResourceInitData> initData) override;
|
std::shared_ptr<Ship::ResourceInitData> initData) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ResourceFactoryXMLAudioSampleV0 final : public Ship::ResourceFactoryXML {
|
class ResourceFactoryXMLAudioSampleV0 final : public Ship::ResourceFactoryXML {
|
||||||
public:
|
public:
|
||||||
|
@ -18,6 +18,6 @@ class ResourceFactoryBinaryAudioSampleV2 final : public Ship::ResourceFactoryBin
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static uint8_t CodecStrToInt(const char* str, const char* file);
|
static uint8_t CodecStrToInt(const char* str, const char* file);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace SOH
|
} // namespace SOH
|
||||||
|
|
|
@ -9,12 +9,12 @@ class ResourceFactoryBinaryAudioSequenceV2 final : public Ship::ResourceFactoryB
|
||||||
public:
|
public:
|
||||||
std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file,
|
std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file,
|
||||||
std::shared_ptr<Ship::ResourceInitData> initData) override;
|
std::shared_ptr<Ship::ResourceInitData> initData) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ResourceFactoryXMLAudioSequenceV0 final : public Ship::ResourceFactoryXML {
|
class ResourceFactoryXMLAudioSequenceV0 final : public Ship::ResourceFactoryXML {
|
||||||
public:
|
public:
|
||||||
std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file,
|
std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file,
|
||||||
std::shared_ptr<Ship::ResourceInitData> initData) override;
|
std::shared_ptr<Ship::ResourceInitData> initData) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace SOH
|
} // namespace SOH
|
||||||
|
|
|
@ -10,7 +10,7 @@ class ResourceFactoryBinaryAudioSoundFontV2 final : public Ship::ResourceFactory
|
||||||
public:
|
public:
|
||||||
std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file,
|
std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file,
|
||||||
std::shared_ptr<Ship::ResourceInitData> initData) override;
|
std::shared_ptr<Ship::ResourceInitData> initData) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ResourceFactoryXMLSoundFontV0 final : public Ship::ResourceFactoryXML {
|
class ResourceFactoryXMLSoundFontV0 final : public Ship::ResourceFactoryXML {
|
||||||
public:
|
public:
|
||||||
|
@ -25,6 +25,6 @@ class ResourceFactoryBinaryAudioSoundFontV2 final : public Ship::ResourceFactory
|
||||||
void ParseSfxTable(AudioSoundFont* soundFont, tinyxml2::XMLElement* element);
|
void ParseSfxTable(AudioSoundFont* soundFont, tinyxml2::XMLElement* element);
|
||||||
std::vector<AdsrEnvelope> ParseEnvelopes(AudioSoundFont* soundFont, tinyxml2::XMLElement* element,
|
std::vector<AdsrEnvelope> ParseEnvelopes(AudioSoundFont* soundFont, tinyxml2::XMLElement* element,
|
||||||
unsigned int* count);
|
unsigned int* count);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace SOH
|
} // namespace SOH
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
#include "AudioSample.h"
|
#include "AudioSample.h"
|
||||||
|
|
||||||
namespace SOH {
|
namespace SOH {
|
||||||
AudioSample::~AudioSample() {
|
AudioSample::~AudioSample() {
|
||||||
if (sample.book != nullptr && sample.book->book != nullptr) {
|
if (sample.book != nullptr && sample.book->book != nullptr) {
|
||||||
delete[] sample.book->book;
|
delete[] sample.book->book;
|
||||||
}
|
}
|
||||||
if (sample.sampleAddr != nullptr) {
|
if (sample.sampleAddr != nullptr) {
|
||||||
delete[] sample.sampleAddr;
|
delete[] sample.sampleAddr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Sample* AudioSample::GetPointer() {
|
Sample* AudioSample::GetPointer() {
|
||||||
return &sample;
|
return &sample;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t AudioSample::GetPointerSize() {
|
size_t AudioSample::GetPointerSize() {
|
||||||
return sizeof(Sample);
|
return sizeof(Sample);
|
||||||
}
|
}
|
||||||
} // namespace SOH
|
} // namespace SOH
|
|
@ -5,21 +5,21 @@
|
||||||
#include <libultraship/libultra/types.h>
|
#include <libultraship/libultra/types.h>
|
||||||
|
|
||||||
namespace SOH {
|
namespace SOH {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* 0x00 */ u32 start;
|
/* 0x00 */ u32 start;
|
||||||
/* 0x04 */ u32 end;
|
/* 0x04 */ u32 end;
|
||||||
/* 0x08 */ u32 count;
|
/* 0x08 */ u32 count;
|
||||||
/* 0x0C */ char unk_0C[0x4];
|
/* 0x0C */ char unk_0C[0x4];
|
||||||
/* 0x10 */ s16 state[16]; // only exists if count != 0. 8-byte aligned
|
/* 0x10 */ s16 state[16]; // only exists if count != 0. 8-byte aligned
|
||||||
} AdpcmLoop; // size = 0x30 (or 0x10)
|
} AdpcmLoop; // size = 0x30 (or 0x10)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* 0x00 */ s32 order;
|
/* 0x00 */ s32 order;
|
||||||
/* 0x04 */ s32 npredictors;
|
/* 0x04 */ s32 npredictors;
|
||||||
/* 0x08 */ s16* book; // size 8 * order * npredictors. 8-byte aligned
|
/* 0x08 */ s16* book; // size 8 * order * npredictors. 8-byte aligned
|
||||||
} AdpcmBook; // s
|
} AdpcmBook; // s
|
||||||
|
|
||||||
typedef struct Sample {
|
typedef struct Sample {
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
///* 0x0 */ u32 unk_0 : 1;
|
///* 0x0 */ u32 unk_0 : 1;
|
||||||
|
@ -38,9 +38,9 @@ namespace SOH {
|
||||||
loop; // Adpcm loop parameters used by the sample. Offset from the start of the sound font / pointer to ram
|
loop; // Adpcm loop parameters used by the sample. Offset from the start of the sound font / pointer to ram
|
||||||
/* 0xC */ AdpcmBook*
|
/* 0xC */ AdpcmBook*
|
||||||
book; // Adpcm book parameters used by the sample. Offset from the start of the sound font / pointer to ram
|
book; // Adpcm book parameters used by the sample. Offset from the start of the sound font / pointer to ram
|
||||||
} Sample; // size = 0x10
|
} Sample; // size = 0x10
|
||||||
|
|
||||||
class AudioSample : public Ship::Resource<Sample> {
|
class AudioSample : public Ship::Resource<Sample> {
|
||||||
public:
|
public:
|
||||||
using Resource::Resource;
|
using Resource::Resource;
|
||||||
|
|
||||||
|
@ -56,5 +56,5 @@ namespace SOH {
|
||||||
AdpcmBook book;
|
AdpcmBook book;
|
||||||
// Only applies to streamed audio
|
// Only applies to streamed audio
|
||||||
float tuning = -1.0f;
|
float tuning = -1.0f;
|
||||||
};
|
};
|
||||||
}; // namespace SOH
|
}; // namespace SOH
|
|
@ -2,17 +2,17 @@
|
||||||
|
|
||||||
namespace SOH {
|
namespace SOH {
|
||||||
|
|
||||||
Sequence* AudioSequence::GetPointer() {
|
Sequence* AudioSequence::GetPointer() {
|
||||||
return &sequence;
|
return &sequence;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t AudioSequence::GetPointerSize() {
|
size_t AudioSequence::GetPointerSize() {
|
||||||
return sizeof(Sequence);
|
return sizeof(Sequence);
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioSequence::~AudioSequence() {
|
AudioSequence::~AudioSequence() {
|
||||||
delete[] sequence.seqData;
|
delete[] sequence.seqData;
|
||||||
sequence.seqData = nullptr;
|
sequence.seqData = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace SOH
|
} // namespace SOH
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
namespace SOH {
|
namespace SOH {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char* seqData;
|
char* seqData;
|
||||||
uint32_t seqDataSize;
|
uint32_t seqDataSize;
|
||||||
uint16_t seqNumber;
|
uint16_t seqNumber;
|
||||||
|
@ -13,9 +13,9 @@ namespace SOH {
|
||||||
uint8_t cachePolicy;
|
uint8_t cachePolicy;
|
||||||
uint32_t numFonts;
|
uint32_t numFonts;
|
||||||
uint8_t fonts[16];
|
uint8_t fonts[16];
|
||||||
} Sequence;
|
} Sequence;
|
||||||
|
|
||||||
class AudioSequence : public Ship::Resource<Sequence> {
|
class AudioSequence : public Ship::Resource<Sequence> {
|
||||||
public:
|
public:
|
||||||
using Resource::Resource;
|
using Resource::Resource;
|
||||||
|
|
||||||
|
@ -27,5 +27,5 @@ namespace SOH {
|
||||||
size_t GetPointerSize();
|
size_t GetPointerSize();
|
||||||
|
|
||||||
Sequence sequence;
|
Sequence sequence;
|
||||||
};
|
};
|
||||||
}; // namespace SOH
|
}; // namespace SOH
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace SOH {
|
namespace SOH {
|
||||||
|
|
||||||
AudioSoundFont::~AudioSoundFont() {
|
AudioSoundFont::~AudioSoundFont() {
|
||||||
for (auto i : instrumentAddresses) {
|
for (auto i : instrumentAddresses) {
|
||||||
if (i != nullptr) {
|
if (i != nullptr) {
|
||||||
delete[] i->envelope;
|
delete[] i->envelope;
|
||||||
|
@ -16,13 +16,13 @@ namespace SOH {
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundFont* AudioSoundFont::GetPointer() {
|
SoundFont* AudioSoundFont::GetPointer() {
|
||||||
return &soundFont;
|
return &soundFont;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t AudioSoundFont::GetPointerSize() {
|
size_t AudioSoundFont::GetPointerSize() {
|
||||||
return sizeof(SoundFont);
|
return sizeof(SoundFont);
|
||||||
}
|
}
|
||||||
} // namespace SOH
|
} // namespace SOH
|
|
@ -8,20 +8,20 @@
|
||||||
|
|
||||||
namespace SOH {
|
namespace SOH {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* 0x0 */ s16 delay;
|
/* 0x0 */ s16 delay;
|
||||||
/* 0x2 */ s16 arg;
|
/* 0x2 */ s16 arg;
|
||||||
} AdsrEnvelope; // size = 0x4
|
} AdsrEnvelope; // size = 0x4
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* 0x00 */ Sample* sample;
|
/* 0x00 */ Sample* sample;
|
||||||
/* 0x04 */ union {
|
/* 0x04 */ union {
|
||||||
u32 tuningAsU32;
|
u32 tuningAsU32;
|
||||||
f32 tuning; // frequency scale factor
|
f32 tuning; // frequency scale factor
|
||||||
};
|
};
|
||||||
} SoundFontSound; // size = 0x8
|
} SoundFontSound; // size = 0x8
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* 0x00 */ u8 loaded;
|
/* 0x00 */ u8 loaded;
|
||||||
/* 0x01 */ u8 normalRangeLo;
|
/* 0x01 */ u8 normalRangeLo;
|
||||||
/* 0x02 */ u8 normalRangeHi;
|
/* 0x02 */ u8 normalRangeHi;
|
||||||
|
@ -30,17 +30,17 @@ namespace SOH {
|
||||||
/* 0x08 */ SoundFontSound lowNotesSound;
|
/* 0x08 */ SoundFontSound lowNotesSound;
|
||||||
/* 0x10 */ SoundFontSound normalNotesSound;
|
/* 0x10 */ SoundFontSound normalNotesSound;
|
||||||
/* 0x18 */ SoundFontSound highNotesSound;
|
/* 0x18 */ SoundFontSound highNotesSound;
|
||||||
} Instrument; // size = 0x20
|
} Instrument; // size = 0x20
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* 0x00 */ u8 releaseRate;
|
/* 0x00 */ u8 releaseRate;
|
||||||
/* 0x01 */ u8 pan;
|
/* 0x01 */ u8 pan;
|
||||||
/* 0x02 */ u8 loaded;
|
/* 0x02 */ u8 loaded;
|
||||||
/* 0x04 */ SoundFontSound sound;
|
/* 0x04 */ SoundFontSound sound;
|
||||||
/* 0x14 */ AdsrEnvelope* envelope;
|
/* 0x14 */ AdsrEnvelope* envelope;
|
||||||
} Drum; // size = 0x14
|
} Drum; // size = 0x14
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* 0x00 */ u8 numInstruments;
|
/* 0x00 */ u8 numInstruments;
|
||||||
/* 0x01 */ u8 numDrums;
|
/* 0x01 */ u8 numDrums;
|
||||||
/* 0x02 */ u8 sampleBankId1;
|
/* 0x02 */ u8 sampleBankId1;
|
||||||
|
@ -50,9 +50,9 @@ namespace SOH {
|
||||||
/* 0x0C */ Drum** drums;
|
/* 0x0C */ Drum** drums;
|
||||||
/* 0x10 */ SoundFontSound* soundEffects;
|
/* 0x10 */ SoundFontSound* soundEffects;
|
||||||
s32 fntIndex;
|
s32 fntIndex;
|
||||||
} SoundFont; // size = 0x14
|
} SoundFont; // size = 0x14
|
||||||
|
|
||||||
class AudioSoundFont : public Ship::Resource<SoundFont> {
|
class AudioSoundFont : public Ship::Resource<SoundFont> {
|
||||||
public:
|
public:
|
||||||
using Resource::Resource;
|
using Resource::Resource;
|
||||||
|
|
||||||
|
@ -77,5 +77,5 @@ namespace SOH {
|
||||||
std::vector<SoundFontSound> soundEffects;
|
std::vector<SoundFontSound> soundEffects;
|
||||||
|
|
||||||
SoundFont soundFont;
|
SoundFont soundFont;
|
||||||
};
|
};
|
||||||
}; // namespace SOH
|
}; // namespace SOH
|
||||||
|
|
|
@ -892,7 +892,7 @@ AudioTable* AudioLoad_GetLoadTable(s32 tableType) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioLoad_RelocateFont(s32 fontId, SoundFontData* mem, RelocInfo* relocInfo) {
|
void AudioLoad_RelocateFont(s32 fontId, SoundFontData* mem, RelocInfo* relocInfo) {
|
||||||
return;
|
return;
|
||||||
uintptr_t reloc;
|
uintptr_t reloc;
|
||||||
uintptr_t reloc2;
|
uintptr_t reloc2;
|
||||||
Instrument* inst;
|
Instrument* inst;
|
||||||
|
@ -1354,7 +1354,7 @@ void AudioLoad_Init(void* heap, size_t heapSize) {
|
||||||
int customSeqListSize = 0;
|
int customSeqListSize = 0;
|
||||||
char** seqList = ResourceMgr_ListFiles("audio/sequences*", &seqListSize);
|
char** seqList = ResourceMgr_ListFiles("audio/sequences*", &seqListSize);
|
||||||
char** customSeqList = ResourceMgr_ListFiles("custom/music/*", &customSeqListSize);
|
char** customSeqList = ResourceMgr_ListFiles("custom/music/*", &customSeqListSize);
|
||||||
sequenceMapSize = (size_t)(seqListSize + customSeqListSize );
|
sequenceMapSize = (size_t)(seqListSize + customSeqListSize);
|
||||||
sequenceMap = malloc((sequenceMapSize + 0xF) * sizeof(char*));
|
sequenceMap = malloc((sequenceMapSize + 0xF) * sizeof(char*));
|
||||||
|
|
||||||
gAudioContext.seqLoadStatus = malloc(sequenceMapSize);
|
gAudioContext.seqLoadStatus = malloc(sequenceMapSize);
|
||||||
|
|
|
@ -854,8 +854,7 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS
|
||||||
goto skip;
|
goto skip;
|
||||||
case CODEC_S16:
|
case CODEC_S16:
|
||||||
case CODEC_OPUS:
|
case CODEC_OPUS:
|
||||||
AudioSynth_ClearBuffer(cmd++, DMEM_UNCOMPRESSED_NOTE,
|
AudioSynth_ClearBuffer(cmd++, DMEM_UNCOMPRESSED_NOTE, (samplesLenAdjusted + 16) * 2);
|
||||||
(samplesLenAdjusted + 16) * 2);
|
|
||||||
flags = A_CONTINUE;
|
flags = A_CONTINUE;
|
||||||
skipBytes = 0;
|
skipBytes = 0;
|
||||||
size_t bytesToRead;
|
size_t bytesToRead;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue