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