mirror of
https://github.com/zeldaret/mm.git
synced 2026-07-08 21:34:48 -04:00
[Audio 6/?] Build Soundfonts and the Soundfont Table (#1675)
* [Audio 6/?] Build Soundfonts and the Soundfont Table * Fix bss * Maybe fix warnings * Improve lots of error messages * Suggested changes from OoT PR * Suggested changes * Make soundfont_table.h generation depend on the samplebank xmls since they are read, report from which soundfont the invalid pointer indirect warning originates from
This commit is contained in:
@@ -8,9 +8,10 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define UNUSED __attribute__((unused))
|
||||
#define FALLTHROUGH __attribute__((fallthrough))
|
||||
#define NORETURN __attribute__((noreturn))
|
||||
#define NO_REORDER __attribute__((no_reorder))
|
||||
#define UNUSED __attribute__((unused))
|
||||
#define FALLTHROUGH __attribute__((fallthrough))
|
||||
#define NORETURN __attribute__((noreturn))
|
||||
#define NO_REORDER __attribute__((no_reorder))
|
||||
#define SECTION_DATA __attribute__((section(".data")))
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,22 +5,34 @@
|
||||
|
||||
struct EnvelopePoint;
|
||||
|
||||
typedef struct AdpcmLoop {
|
||||
typedef struct AdpcmLoopHeader {
|
||||
/* 0x00 */ u32 start;
|
||||
/* 0x04 */ u32 loopEnd; // numSamples position into the sample where the loop ends
|
||||
/* 0x04 */ u32 loopEnd; // s16 sample position where the loop ends
|
||||
/* 0x08 */ u32 count; // The number of times the loop is played before the sound completes. Setting count to -1 indicates that the loop should play indefinitely.
|
||||
/* 0x0C */ u32 sampleEnd; // total number of s16-samples in the sample audio clip
|
||||
} AdpcmLoopHeader; // size = 0x10
|
||||
|
||||
typedef struct AdpcmLoop {
|
||||
/* 0x00 */ AdpcmLoopHeader header;
|
||||
/* 0x10 */ s16 predictorState[16]; // only exists if count != 0. 8-byte aligned
|
||||
} AdpcmLoop; // size = 0x30 (or 0x10)
|
||||
|
||||
typedef struct AdpcmBookHeader {
|
||||
/* 0x0 */ s32 order;
|
||||
/* 0x4 */ s32 numPredictors;
|
||||
} AdpcmBookHeader; // size = 0x8
|
||||
|
||||
/**
|
||||
* A table of prediction coefficients that the coder selects from to optimize sound quality.
|
||||
*
|
||||
* The procedure used to design the codeBook is based on an adaptive clustering algorithm.
|
||||
* The size of the codeBook is (8 * order * numPredictors) and is 8-byte aligned
|
||||
*/
|
||||
typedef s16 AdpcmBookData[];
|
||||
|
||||
typedef struct AdpcmBook {
|
||||
/* 0x0 */ s32 order;
|
||||
/* 0x4 */ s32 numPredictors;
|
||||
/* 0x8 */ s16 codeBook[1]; // a table of prediction coefficients that the coder selects from to optimize sound quality.
|
||||
/* 0x0 */ AdpcmBookHeader header;
|
||||
/* 0x8 */ AdpcmBookData codeBook;
|
||||
} AdpcmBook; // size >= 0x8
|
||||
|
||||
typedef enum SampleCodec {
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
#ifndef SOUNDFONT_FILE_H
|
||||
#define SOUNDFONT_FILE_H
|
||||
|
||||
#include "libc/stdbool.h"
|
||||
#include "alignment.h"
|
||||
#include "attributes.h"
|
||||
#include "effects.h"
|
||||
#include "load.h"
|
||||
#include "soundfont.h"
|
||||
|
||||
// Envelope definitions
|
||||
|
||||
#define ENVELOPE_POINT(delay, target) { (delay), (target) }
|
||||
#define ENVELOPE_DISABLE() { ADSR_DISABLE, 0 }
|
||||
#define ENVELOPE_HANG() { ADSR_HANG, 0 }
|
||||
#define ENVELOPE_GOTO(index) { ADSR_GOTO, (index) }
|
||||
#define ENVELOPE_RESTART() { ADSR_RESTART, 0 }
|
||||
|
||||
// Instrument definitions
|
||||
|
||||
#define INSTR_SAMPLE_NONE { NULL, 0.0f }
|
||||
#define INSTR_SAMPLE_LO_NONE 0
|
||||
#define INSTR_SAMPLE_HI_NONE 127
|
||||
|
||||
// Explicit padding is sometimes required where soundfont data was padded to 0x10 bytes (possibly due to source file
|
||||
// splits in the original soundfonts?)
|
||||
// It's less convenient for us to emit multiple files per soundfont, so instead we fill in the padding manually.
|
||||
|
||||
#ifndef GLUE
|
||||
#define GLUE(a,b) a##b
|
||||
#endif
|
||||
#ifndef GLUE2
|
||||
#define GLUE2(a,b) GLUE(a,b)
|
||||
#endif
|
||||
|
||||
#ifdef __sgi
|
||||
// For IDO, we have to add explicit padding arrays
|
||||
#define SF_PAD4() static u8 GLUE2(_pad, __LINE__) [] = { 0,0,0,0 }
|
||||
#define SF_PAD8() static u8 GLUE2(_pad, __LINE__) [] = { 0,0,0,0,0,0,0,0 }
|
||||
#define SF_PADC() static u8 GLUE2(_pad, __LINE__) [] = { 0,0,0,0,0,0,0,0,0,0,0,0 }
|
||||
#else
|
||||
// For other compilers, the soundfont compiler (sfc) emits alignment attributes that handle this automatically
|
||||
#define SF_PAD4()
|
||||
#define SF_PAD8()
|
||||
#define SF_PADC()
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+1
-1
@@ -38,7 +38,7 @@ extern AudioSpec gAudioSpecs[21];
|
||||
extern const u16 gAudioEnvironmentalSfx[];
|
||||
extern const s16 gAudioTatumInit[];
|
||||
extern const AudioHeapInitSizes gAudioHeapInitSizes;
|
||||
extern u8 gSoundFontTable[];
|
||||
extern AudioTable gSoundFontTable;
|
||||
extern u8 gSequenceFontTable[];
|
||||
extern u8 gSequenceTable[];
|
||||
extern AudioTable gSampleBankTable;
|
||||
|
||||
Reference in New Issue
Block a user