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
|
@ -418,12 +418,12 @@ void OTRGlobals::Initialize() {
|
||||||
RESOURCE_FORMAT_BINARY, "AudioSoundFont",
|
RESOURCE_FORMAT_BINARY, "AudioSoundFont",
|
||||||
static_cast<uint32_t>(SOH::ResourceType::SOH_AudioSoundFont), 2);
|
static_cast<uint32_t>(SOH::ResourceType::SOH_AudioSoundFont), 2);
|
||||||
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryXMLSoundFontV0>(), RESOURCE_FORMAT_XML,
|
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryXMLSoundFontV0>(), RESOURCE_FORMAT_XML,
|
||||||
"SoundFont", static_cast<uint32_t>(SOH::ResourceType::SOH_AudioSoundFont), 0);
|
"SoundFont", static_cast<uint32_t>(SOH::ResourceType::SOH_AudioSoundFont), 0);
|
||||||
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinaryAudioSequenceV2>(),
|
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinaryAudioSequenceV2>(),
|
||||||
RESOURCE_FORMAT_BINARY, "AudioSequence",
|
RESOURCE_FORMAT_BINARY, "AudioSequence",
|
||||||
static_cast<uint32_t>(SOH::ResourceType::SOH_AudioSequence), 2);
|
static_cast<uint32_t>(SOH::ResourceType::SOH_AudioSequence), 2);
|
||||||
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryXMLAudioSequenceV0>(), RESOURCE_FORMAT_XML,
|
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryXMLAudioSequenceV0>(), RESOURCE_FORMAT_XML,
|
||||||
"Sequence", static_cast<uint32_t>(SOH::ResourceType::SOH_AudioSequence), 0);
|
"Sequence", static_cast<uint32_t>(SOH::ResourceType::SOH_AudioSequence), 0);
|
||||||
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinaryBackgroundV0>(), RESOURCE_FORMAT_BINARY,
|
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinaryBackgroundV0>(), RESOURCE_FORMAT_BINARY,
|
||||||
"Background", static_cast<uint32_t>(SOH::ResourceType::SOH_Background), 0);
|
"Background", static_cast<uint32_t>(SOH::ResourceType::SOH_Background), 0);
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,18 +6,18 @@
|
||||||
|
|
||||||
namespace SOH {
|
namespace SOH {
|
||||||
class ResourceFactoryBinaryAudioSampleV2 final : public Ship::ResourceFactoryBinary {
|
class ResourceFactoryBinaryAudioSampleV2 final : public Ship::ResourceFactoryBinary {
|
||||||
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:
|
||||||
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;
|
||||||
|
|
||||||
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
|
||||||
|
|
|
@ -6,15 +6,15 @@
|
||||||
|
|
||||||
namespace SOH {
|
namespace SOH {
|
||||||
class ResourceFactoryBinaryAudioSequenceV2 final : public Ship::ResourceFactoryBinary {
|
class ResourceFactoryBinaryAudioSequenceV2 final : public Ship::ResourceFactoryBinary {
|
||||||
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
|
||||||
|
|
|
@ -7,24 +7,24 @@
|
||||||
|
|
||||||
namespace SOH {
|
namespace SOH {
|
||||||
class ResourceFactoryBinaryAudioSoundFontV2 final : public Ship::ResourceFactoryBinary {
|
class ResourceFactoryBinaryAudioSoundFontV2 final : public Ship::ResourceFactoryBinary {
|
||||||
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:
|
||||||
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;
|
||||||
static int8_t MediumStrToInt(const char* str, const char* file);
|
static int8_t MediumStrToInt(const char* str, const char* file);
|
||||||
static int8_t CachePolicyToInt(const char* str, const char* file);
|
static int8_t CachePolicyToInt(const char* str, const char* file);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ParseDrums(AudioSoundFont* soundFont, tinyxml2::XMLElement* element);
|
void ParseDrums(AudioSoundFont* soundFont, tinyxml2::XMLElement* element);
|
||||||
void ParseInstruments(AudioSoundFont* soundFont, tinyxml2::XMLElement* element);
|
void ParseInstruments(AudioSoundFont* soundFont, tinyxml2::XMLElement* element);
|
||||||
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) {
|
|
||||||
delete[] sample.sampleAddr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Sample* AudioSample::GetPointer() {
|
if (sample.sampleAddr != nullptr) {
|
||||||
return &sample;
|
delete[] sample.sampleAddr;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
Sample* AudioSample::GetPointer() {
|
||||||
|
return &sample;
|
||||||
|
}
|
||||||
|
|
||||||
size_t AudioSample::GetPointerSize() {
|
size_t AudioSample::GetPointerSize() {
|
||||||
return sizeof(Sample);
|
return sizeof(Sample);
|
||||||
}
|
}
|
||||||
} // namespace SOH
|
} // namespace SOH
|
|
@ -5,56 +5,56 @@
|
||||||
#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;
|
||||||
/* 0x0 */ u32 codec : 4; // The state of compression or decompression, See `SampleCodec`
|
/* 0x0 */ u32 codec : 4; // The state of compression or decompression, See `SampleCodec`
|
||||||
/* 0x0 */ u32 medium : 2; // Medium where sample is currently stored. See `SampleMedium`
|
/* 0x0 */ u32 medium : 2; // Medium where sample is currently stored. See `SampleMedium`
|
||||||
/* 0x0 */ u32 unk_bit26 : 1;
|
/* 0x0 */ u32 unk_bit26 : 1;
|
||||||
/* 0x0 */ u32 isRelocated : 1; // Has the sample header been relocated (offsets to pointers)
|
/* 0x0 */ u32 isRelocated : 1; // Has the sample header been relocated (offsets to pointers)
|
||||||
};
|
|
||||||
u32 asU32;
|
|
||||||
};
|
};
|
||||||
/* 0x1 */ u32 size; // Size of the sample
|
u32 asU32;
|
||||||
u32 fileSize;
|
|
||||||
/* 0x4 */ u8* sampleAddr; // Raw sample data. Offset from the start of the sample bank or absolute address to either
|
|
||||||
// rom or ram
|
|
||||||
/* 0x8 */ AdpcmLoop*
|
|
||||||
loop; // Adpcm loop parameters used by the sample. Offset from the start of the sound font / pointer to ram
|
|
||||||
/* 0xC */ AdpcmBook*
|
|
||||||
book; // Adpcm book parameters used by the sample. Offset from the start of the sound font / pointer to ram
|
|
||||||
} Sample; // size = 0x10
|
|
||||||
|
|
||||||
class AudioSample : public Ship::Resource<Sample> {
|
|
||||||
public:
|
|
||||||
using Resource::Resource;
|
|
||||||
|
|
||||||
AudioSample() : Resource(std::shared_ptr<Ship::ResourceInitData>()) {
|
|
||||||
}
|
|
||||||
~AudioSample();
|
|
||||||
|
|
||||||
Sample* GetPointer();
|
|
||||||
size_t GetPointerSize();
|
|
||||||
|
|
||||||
Sample sample;
|
|
||||||
AdpcmLoop loop;
|
|
||||||
AdpcmBook book;
|
|
||||||
// Only applies to streamed audio
|
|
||||||
float tuning = -1.0f;
|
|
||||||
};
|
};
|
||||||
|
/* 0x1 */ u32 size; // Size of the sample
|
||||||
|
u32 fileSize;
|
||||||
|
/* 0x4 */ u8* sampleAddr; // Raw sample data. Offset from the start of the sample bank or absolute address to either
|
||||||
|
// rom or ram
|
||||||
|
/* 0x8 */ AdpcmLoop*
|
||||||
|
loop; // Adpcm loop parameters used by the sample. Offset from the start of the sound font / pointer to ram
|
||||||
|
/* 0xC */ AdpcmBook*
|
||||||
|
book; // Adpcm book parameters used by the sample. Offset from the start of the sound font / pointer to ram
|
||||||
|
} Sample; // size = 0x10
|
||||||
|
|
||||||
|
class AudioSample : public Ship::Resource<Sample> {
|
||||||
|
public:
|
||||||
|
using Resource::Resource;
|
||||||
|
|
||||||
|
AudioSample() : Resource(std::shared_ptr<Ship::ResourceInitData>()) {
|
||||||
|
}
|
||||||
|
~AudioSample();
|
||||||
|
|
||||||
|
Sample* GetPointer();
|
||||||
|
size_t GetPointerSize();
|
||||||
|
|
||||||
|
Sample sample;
|
||||||
|
AdpcmLoop loop;
|
||||||
|
AdpcmBook book;
|
||||||
|
// Only applies to streamed audio
|
||||||
|
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,27 +5,27 @@
|
||||||
|
|
||||||
namespace SOH {
|
namespace SOH {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char* seqData;
|
char* seqData;
|
||||||
uint32_t seqDataSize;
|
uint32_t seqDataSize;
|
||||||
uint16_t seqNumber;
|
uint16_t seqNumber;
|
||||||
uint8_t medium;
|
uint8_t medium;
|
||||||
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;
|
||||||
|
|
||||||
AudioSequence() : Resource(std::shared_ptr<Ship::ResourceInitData>()) {
|
AudioSequence() : Resource(std::shared_ptr<Ship::ResourceInitData>()) {
|
||||||
}
|
}
|
||||||
~AudioSequence();
|
~AudioSequence();
|
||||||
|
|
||||||
Sequence* GetPointer();
|
Sequence* GetPointer();
|
||||||
size_t GetPointerSize();
|
size_t GetPointerSize();
|
||||||
|
|
||||||
Sequence sequence;
|
Sequence sequence;
|
||||||
};
|
};
|
||||||
}; // namespace SOH
|
}; // namespace SOH
|
|
@ -2,27 +2,27 @@
|
||||||
|
|
||||||
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;
|
||||||
delete i;
|
delete i;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto d : drumAddresses) {
|
|
||||||
if (d != nullptr) {
|
|
||||||
delete[] d->envelope;
|
|
||||||
delete d;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundFont* AudioSoundFont::GetPointer() {
|
for (auto d : drumAddresses) {
|
||||||
return &soundFont;
|
if (d != nullptr) {
|
||||||
|
delete[] d->envelope;
|
||||||
|
delete d;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
size_t AudioSoundFont::GetPointerSize() {
|
SoundFont* AudioSoundFont::GetPointer() {
|
||||||
return sizeof(SoundFont);
|
return &soundFont;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t AudioSoundFont::GetPointerSize() {
|
||||||
|
return sizeof(SoundFont);
|
||||||
|
}
|
||||||
} // namespace SOH
|
} // namespace SOH
|
|
@ -8,74 +8,74 @@
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
/* 0x00 */ u8 loaded;
|
|
||||||
/* 0x01 */ u8 normalRangeLo;
|
|
||||||
/* 0x02 */ u8 normalRangeHi;
|
|
||||||
/* 0x03 */ u8 releaseRate;
|
|
||||||
/* 0x04 */ AdsrEnvelope* envelope;
|
|
||||||
/* 0x08 */ SoundFontSound lowNotesSound;
|
|
||||||
/* 0x10 */ SoundFontSound normalNotesSound;
|
|
||||||
/* 0x18 */ SoundFontSound highNotesSound;
|
|
||||||
} Instrument; // size = 0x20
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
/* 0x00 */ u8 releaseRate;
|
|
||||||
/* 0x01 */ u8 pan;
|
|
||||||
/* 0x02 */ u8 loaded;
|
|
||||||
/* 0x04 */ SoundFontSound sound;
|
|
||||||
/* 0x14 */ AdsrEnvelope* envelope;
|
|
||||||
} Drum; // size = 0x14
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
/* 0x00 */ u8 numInstruments;
|
|
||||||
/* 0x01 */ u8 numDrums;
|
|
||||||
/* 0x02 */ u8 sampleBankId1;
|
|
||||||
/* 0x03 */ u8 sampleBankId2;
|
|
||||||
/* 0x04 */ u16 numSfx;
|
|
||||||
/* 0x08 */ Instrument** instruments;
|
|
||||||
/* 0x0C */ Drum** drums;
|
|
||||||
/* 0x10 */ SoundFontSound* soundEffects;
|
|
||||||
s32 fntIndex;
|
|
||||||
} SoundFont; // size = 0x14
|
|
||||||
|
|
||||||
class AudioSoundFont : public Ship::Resource<SoundFont> {
|
|
||||||
public:
|
|
||||||
using Resource::Resource;
|
|
||||||
|
|
||||||
AudioSoundFont() : Resource(std::shared_ptr<Ship::ResourceInitData>()) {
|
|
||||||
}
|
|
||||||
~AudioSoundFont();
|
|
||||||
|
|
||||||
SoundFont* GetPointer();
|
|
||||||
size_t GetPointerSize();
|
|
||||||
|
|
||||||
int8_t medium;
|
|
||||||
int8_t cachePolicy;
|
|
||||||
uint16_t data1;
|
|
||||||
uint16_t data2;
|
|
||||||
uint16_t data3;
|
|
||||||
|
|
||||||
std::vector<Drum*> drumAddresses;
|
|
||||||
std::vector<std::vector<AdsrEnvelope>> drumEnvelopeArrays;
|
|
||||||
|
|
||||||
std::vector<Instrument*> instrumentAddresses;
|
|
||||||
|
|
||||||
std::vector<SoundFontSound> soundEffects;
|
|
||||||
|
|
||||||
SoundFont soundFont;
|
|
||||||
};
|
};
|
||||||
|
} SoundFontSound; // size = 0x8
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
/* 0x00 */ u8 loaded;
|
||||||
|
/* 0x01 */ u8 normalRangeLo;
|
||||||
|
/* 0x02 */ u8 normalRangeHi;
|
||||||
|
/* 0x03 */ u8 releaseRate;
|
||||||
|
/* 0x04 */ AdsrEnvelope* envelope;
|
||||||
|
/* 0x08 */ SoundFontSound lowNotesSound;
|
||||||
|
/* 0x10 */ SoundFontSound normalNotesSound;
|
||||||
|
/* 0x18 */ SoundFontSound highNotesSound;
|
||||||
|
} Instrument; // size = 0x20
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
/* 0x00 */ u8 releaseRate;
|
||||||
|
/* 0x01 */ u8 pan;
|
||||||
|
/* 0x02 */ u8 loaded;
|
||||||
|
/* 0x04 */ SoundFontSound sound;
|
||||||
|
/* 0x14 */ AdsrEnvelope* envelope;
|
||||||
|
} Drum; // size = 0x14
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
/* 0x00 */ u8 numInstruments;
|
||||||
|
/* 0x01 */ u8 numDrums;
|
||||||
|
/* 0x02 */ u8 sampleBankId1;
|
||||||
|
/* 0x03 */ u8 sampleBankId2;
|
||||||
|
/* 0x04 */ u16 numSfx;
|
||||||
|
/* 0x08 */ Instrument** instruments;
|
||||||
|
/* 0x0C */ Drum** drums;
|
||||||
|
/* 0x10 */ SoundFontSound* soundEffects;
|
||||||
|
s32 fntIndex;
|
||||||
|
} SoundFont; // size = 0x14
|
||||||
|
|
||||||
|
class AudioSoundFont : public Ship::Resource<SoundFont> {
|
||||||
|
public:
|
||||||
|
using Resource::Resource;
|
||||||
|
|
||||||
|
AudioSoundFont() : Resource(std::shared_ptr<Ship::ResourceInitData>()) {
|
||||||
|
}
|
||||||
|
~AudioSoundFont();
|
||||||
|
|
||||||
|
SoundFont* GetPointer();
|
||||||
|
size_t GetPointerSize();
|
||||||
|
|
||||||
|
int8_t medium;
|
||||||
|
int8_t cachePolicy;
|
||||||
|
uint16_t data1;
|
||||||
|
uint16_t data2;
|
||||||
|
uint16_t data3;
|
||||||
|
|
||||||
|
std::vector<Drum*> drumAddresses;
|
||||||
|
std::vector<std::vector<AdsrEnvelope>> drumEnvelopeArrays;
|
||||||
|
|
||||||
|
std::vector<Instrument*> instrumentAddresses;
|
||||||
|
|
||||||
|
std::vector<SoundFontSound> soundEffects;
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
|
@ -853,27 +853,26 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS
|
||||||
s5 = samplesLenAdjusted;
|
s5 = samplesLenAdjusted;
|
||||||
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;
|
nSamplesProcessed += samplesLenAdjusted;
|
||||||
nSamplesProcessed += samplesLenAdjusted;
|
|
||||||
|
|
||||||
if (((synthState->samplePosInt * 2) + (samplesLenAdjusted)*2) < audioFontSample->size) {
|
if (((synthState->samplePosInt * 2) + (samplesLenAdjusted)*2) < audioFontSample->size) {
|
||||||
bytesToRead = (samplesLenAdjusted)*2;
|
bytesToRead = (samplesLenAdjusted)*2;
|
||||||
} else {
|
} else {
|
||||||
bytesToRead = audioFontSample->size - (synthState->samplePosInt * 2);
|
bytesToRead = audioFontSample->size - (synthState->samplePosInt * 2);
|
||||||
}
|
}
|
||||||
// 2S2H [Port] [Custom audio] Handle decoding OPUS data
|
// 2S2H [Port] [Custom audio] Handle decoding OPUS data
|
||||||
if (audioFontSample->codec == CODEC_OPUS) {
|
if (audioFontSample->codec == CODEC_OPUS) {
|
||||||
aOPUSdecImpl(sampleAddr, DMEM_UNCOMPRESSED_NOTE, bytesToRead, &synthState->opusFile,
|
aOPUSdecImpl(sampleAddr, DMEM_UNCOMPRESSED_NOTE, bytesToRead, &synthState->opusFile,
|
||||||
synthState->samplePosInt, audioFontSample->fileSize);
|
synthState->samplePosInt, audioFontSample->fileSize);
|
||||||
} else {
|
} else {
|
||||||
aLoadBuffer(cmd++, sampleAddr + (synthState->samplePosInt * 2), DMEM_UNCOMPRESSED_NOTE,
|
aLoadBuffer(cmd++, sampleAddr + (synthState->samplePosInt * 2), DMEM_UNCOMPRESSED_NOTE,
|
||||||
bytesToRead);
|
bytesToRead);
|
||||||
}
|
}
|
||||||
|
|
||||||
goto skip;
|
goto skip;
|
||||||
case CODEC_REVERB:
|
case CODEC_REVERB:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue