Skip to content

Commit

Permalink
[Audio 6/?] Build Soundfonts and the Soundfont Table (#1675)
Browse files Browse the repository at this point in the history
* [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
  • Loading branch information
Thar0 authored Aug 28, 2024
1 parent 98d9571 commit 7210cfa
Show file tree
Hide file tree
Showing 28 changed files with 2,776 additions and 50 deletions.
76 changes: 72 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,20 @@ SCHC_FLAGS :=
AUDIO_EXTRACT := $(PYTHON) tools/audio_extraction.py
SAMPLECONV := tools/audio/sampleconv/sampleconv
SBC := tools/audio/sbc
SFC := tools/audio/sfc
SFPATCH := tools/audio/sfpatch
ATBLGEN := tools/audio/atblgen

SBCFLAGS := --matching
SFCFLAGS := --matching

# Command to replace $(BUILD_DIR) in some files with the build path.
# We can't use the C preprocessor for this because it won't substitute inside string literals.
BUILD_DIR_REPLACE := sed -e 's|$$(BUILD_DIR)|$(BUILD_DIR)|g'

CFLAGS += -G 0 -non_shared -Xcpluscomm -nostdinc -Wab,-r4300_mul

WARNINGS := -fullwarn -verbose -woff 624,649,838,712,516,513,596,564,594
WARNINGS := -fullwarn -verbose -woff 624,649,838,712,516,513,596,564,594,807
ASFLAGS := -march=vr4300 -32 -G0
GBI_DEFINES := -DF3DEX_GBI_2 -DF3DEX_GBI_PL -DGBI_DOWHILE
COMMON_DEFINES := -D_MIPS_SZLONG=32 $(GBI_DEFINES)
Expand Down Expand Up @@ -221,9 +224,11 @@ ASM_DIRS := $(shell find asm -type d -not -path "asm/non_matchings*") $(shell fi
ifneq ($(wildcard $(EXTRACTED_DIR)/assets/audio),)
SAMPLE_EXTRACT_DIRS := $(shell find $(EXTRACTED_DIR)/assets/audio/samples -type d)
SAMPLEBANK_EXTRACT_DIRS := $(shell find $(EXTRACTED_DIR)/assets/audio/samplebanks -type d)
SOUNDFONT_EXTRACT_DIRS := $(shell find $(EXTRACTED_DIR)/assets/audio/soundfonts -type d)
else
SAMPLE_EXTRACT_DIRS :=
SAMPLEBANK_EXTRACT_DIRS :=
SOUNDFONT_EXTRACT_DIRS :=
endif

ifneq ($(wildcard assets/audio/samples),)
Expand All @@ -238,6 +243,12 @@ else
SAMPLEBANK_DIRS :=
endif

ifneq ($(wildcard assets/audio/soundfonts),)
SOUNDFONT_DIRS := $(shell find assets/audio/soundfonts -type d)
else
SOUNDFONT_DIRS :=
endif

SAMPLE_FILES := $(foreach dir,$(SAMPLE_DIRS),$(wildcard $(dir)/*.wav))
SAMPLE_EXTRACT_FILES := $(foreach dir,$(SAMPLE_EXTRACT_DIRS),$(wildcard $(dir)/*.wav))
AIFC_FILES := $(foreach f,$(SAMPLE_FILES),$(BUILD_DIR)/$(f:.wav=.aifc)) $(foreach f,$(SAMPLE_EXTRACT_FILES:.wav=.aifc),$(f:$(EXTRACTED_DIR)/%=$(BUILD_DIR)/%))
Expand All @@ -250,6 +261,13 @@ SAMPLEBANK_BUILD_XMLS := $(foreach f,$(SAMPLEBANK_XMLS),$(BUILD_DIR)/$f) $(for
SAMPLEBANK_O_FILES := $(foreach f,$(SAMPLEBANK_BUILD_XMLS),$(f:.xml=.o))
SAMPLEBANK_DEP_FILES := $(foreach f,$(SAMPLEBANK_O_FILES),$(f:.o=.d))

SOUNDFONT_XMLS := $(foreach dir,$(SOUNDFONT_DIRS),$(wildcard $(dir)/*.xml))
SOUNDFONT_EXTRACT_XMLS := $(foreach dir,$(SOUNDFONT_EXTRACT_DIRS),$(wildcard $(dir)/*.xml))
SOUNDFONT_BUILD_XMLS := $(foreach f,$(SOUNDFONT_XMLS),$(BUILD_DIR)/$f) $(foreach f,$(SOUNDFONT_EXTRACT_XMLS),$(f:$(EXTRACTED_DIR)/%=$(BUILD_DIR)/%))
SOUNDFONT_O_FILES := $(foreach f,$(SOUNDFONT_BUILD_XMLS),$(f:.xml=.o))
SOUNDFONT_HEADERS := $(foreach f,$(SOUNDFONT_BUILD_XMLS),$(f:.xml=.h))
SOUNDFONT_DEP_FILES := $(foreach f,$(SOUNDFONT_O_FILES),$(f:.o=.d))

## Assets binaries (PNGs, JPGs, etc)
ASSET_BIN_DIRS := $(shell find assets/* -type d -not -path "assets/xml*" -not -path "assets/c/*" -not -name "c" -not -path "assets/text")
# Prevents building C files that will be #include'd
Expand Down Expand Up @@ -299,12 +317,14 @@ $(shell mkdir -p $(foreach dir, \
$(ASSET_BIN_DIRS) \
$(ASSET_BIN_DIRS_C_FILES) \
$(SAMPLE_DIRS) \
$(SAMPLEBANK_DIRS), \
$(SAMPLEBANK_DIRS) \
$(SOUNDFONT_DIRS), \
$(BUILD_DIR)/$(dir)))
ifneq ($(wildcard $(EXTRACTED_DIR)/assets),)
$(shell mkdir -p $(foreach dir, \
$(SAMPLE_EXTRACT_DIRS) \
$(SAMPLEBANK_EXTRACT_DIRS), \
$(SAMPLEBANK_EXTRACT_DIRS) \
$(SOUNDFONT_EXTRACT_DIRS), \
$(dir:$(EXTRACTED_DIR)/%=$(BUILD_DIR)/%)))
endif

Expand Down Expand Up @@ -384,7 +404,7 @@ $(ROMC): $(ROM) $(ELF) $(BUILD_DIR)/dmadata/compress_ranges.txt
$(PYTHON) -m ipl3checksum sum --cic 6105 --update $@

$(ELF): $(TEXTURE_FILES_OUT) $(ASSET_FILES_OUT) $(O_FILES) $(OVL_RELOC_FILES) $(LDSCRIPT) $(LD_FINAL_FILES) \
$(SAMPLEBANK_O_FILES)
$(SAMPLEBANK_O_FILES) $(SOUNDFONT_O_FILES)
$(LD) -T $(LDSCRIPT) -T $(LD_FINAL_FILES) --no-check-sections --accept-unknown-input-arch --emit-relocs -Map $(MAP) -o $@

## Order-only prerequisites
Expand Down Expand Up @@ -560,6 +580,10 @@ $(BUILD_DIR)/%.schl.inc: %.schl
# Audio

AUDIO_BUILD_DEBUG ?= 0
ifeq ($(AUDIO_BUILD_DEBUG),1)
# for debugging only, make soundfonts depend on samplebanks so they can be linked against
$(BUILD_DIR)/assets/audio/soundfonts/%.o: $(SAMPLEBANK_O_FILES)
endif

# first build samples...

Expand Down Expand Up @@ -610,11 +634,48 @@ ifeq ($(AUDIO_BUILD_DEBUG),1)
@cmp $(@:.o=.bin) $(patsubst $(BUILD_DIR)/assets/audio/samplebanks/%,$(EXTRACTED_DIR)/baserom_audiotest/audiotable_files/%,$(@:.o=.bin)) && echo "$(<F) OK"
endif

# also assemble the soundfonts and generate the associated headers...

$(BUILD_DIR)/assets/audio/soundfonts/%.xml: assets/audio/soundfonts/%.xml
cat $< | $(BUILD_DIR_REPLACE) > $@

$(BUILD_DIR)/assets/audio/soundfonts/%.xml: $(EXTRACTED_DIR)/assets/audio/soundfonts/%.xml
cat $< | $(BUILD_DIR_REPLACE) > $@

.PRECIOUS: $(BUILD_DIR)/assets/audio/soundfonts/%.c $(BUILD_DIR)/assets/audio/soundfonts/%.h $(BUILD_DIR)/assets/audio/soundfonts/%.name
$(BUILD_DIR)/assets/audio/soundfonts/%.c $(BUILD_DIR)/assets/audio/soundfonts/%.h $(BUILD_DIR)/assets/audio/soundfonts/%.name: $(BUILD_DIR)/assets/audio/soundfonts/%.xml | $(SAMPLEBANK_BUILD_XMLS) $(AIFC_FILES)
# This rule can be triggered for either the .c or .h file, so $@ may refer to either the .c or .h file. A simple
# substitution $(@:.c=.h) will fail ~50% of the time with -j. Instead, don't assume anything about the suffix of $@.
$(SFC) $(SFCFLAGS) --makedepend $(basename $@).d $< $(basename $@).c $(basename $@).h $(basename $@).name

-include $(SOUNDFONT_DEP_FILES)

$(BUILD_DIR)/assets/audio/soundfonts/%.o: $(BUILD_DIR)/assets/audio/soundfonts/%.c $(BUILD_DIR)/assets/audio/soundfonts/%.name #$(SAMPLEBANK_O_FILES) # (for debugging only)
# compile c to unlinked object
$(CC) -c $(CFLAGS) $(IINC) $(WARNINGS) $(C_DEFINES) $(MIPS_VERSION) $(ENDIAN) $(OPTFLAGS) -I include/audio -o $(@:.o=.tmp) $<
# partial link
$(LD) -r -T linker_scripts/soundfont.ld $(@:.o=.tmp) -o $(@:.o=.tmp2)
# patch defined symbols to be ABS symbols so that they remain file-relative offsets forever
$(SFPATCH) $(@:.o=.tmp2) $(@:.o=.tmp2)
# write start and size symbols afterwards, filename != symbolic name so source symbolic name from the .name file written by sfc
$(OBJCOPY) --add-symbol $$(cat $(<:.c=.name))_Start=.rodata:0,global --redefine-sym __LEN__=$$(cat $(<:.c=.name))_Size $(@:.o=.tmp2) $@
# cleanup temp files
@$(RM) $(@:.o=.tmp) $(@:.o=.tmp2)
$(RM_MDEBUG)
ifeq ($(AUDIO_BUILD_DEBUG),1)
$(LD) $(foreach f,$(SAMPLEBANK_O_FILES),-R $f) -T linker_scripts/soundfont.ld $@ -o $(@:.o=.elf)
$(OBJCOPY) -O binary -j.rodata $(@:.o=.elf) $(@:.o=.bin)
@(cmp $(@:.o=.bin) $(patsubst $(BUILD_DIR)/assets/audio/soundfonts/%,$(EXTRACTED_DIR)/baserom_audiotest/audiobank_files/%,$(@:.o=.bin)) && echo "$(<F) OK" || (mkdir -p NONMATCHINGS/soundfonts && cp $(@:.o=.bin) NONMATCHINGS/soundfonts/$(@F:.o=.bin)))
endif

# put together the tables

$(BUILD_DIR)/assets/audio/samplebank_table.h: $(SAMPLEBANK_BUILD_XMLS)
$(ATBLGEN) --banks $@ $^

$(BUILD_DIR)/assets/audio/soundfont_table.h: $(SOUNDFONT_BUILD_XMLS) $(SAMPLEBANK_BUILD_XMLS)
$(ATBLGEN) --fonts $@ $(SOUNDFONT_BUILD_XMLS)

# build the tables into objects, move data -> rodata

$(BUILD_DIR)/src/audio/tables/samplebank_table.o: src/audio/tables/samplebank_table.c $(BUILD_DIR)/assets/audio/samplebank_table.h
Expand All @@ -624,6 +685,13 @@ $(BUILD_DIR)/src/audio/tables/samplebank_table.o: src/audio/tables/samplebank_ta
@$(RM) $(@:.o=.tmp)
$(RM_MDEBUG)

$(BUILD_DIR)/src/audio/tables/soundfont_table.o: src/audio/tables/soundfont_table.c $(BUILD_DIR)/assets/audio/soundfont_table.h $(SOUNDFONT_HEADERS)
$(CC_CHECK_COMP) $(CC_CHECK_FLAGS) $(IINC) $(CC_CHECK_WARNINGS) $(C_DEFINES) $(MIPS_BUILTIN_DEFS) -o $(@:.o=.tmp) $<
$(CC) -c $(CFLAGS) $(IINC) $(WARNINGS) $(C_DEFINES) $(MIPS_VERSION) $(ENDIAN) $(OPTFLAGS) -o $(@:.o=.tmp) $<
$(LD) -r -T linker_scripts/audio_table_rodata.ld $(@:.o=.tmp) -o $@
@$(RM) $(@:.o=.tmp)
$(RM_MDEBUG)

-include $(DEP_FILES)

# Print target for debugging
Expand Down
9 changes: 5 additions & 4 deletions include/attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
22 changes: 17 additions & 5 deletions include/audio/soundfont.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
48 changes: 48 additions & 0 deletions include/audio/soundfont_file.h
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion include/variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
19 changes: 19 additions & 0 deletions linker_scripts/soundfont.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
OUTPUT_ARCH (mips)

/* Soundfont Linker Script, maps data into rodata and adds a file length symbol */

SECTIONS {

.rodata :
{
*(.data*)
*(.rodata*)
. = ALIGN(16);
__LEN__ = . - ADDR(.rodata);
}

/DISCARD/ :
{
*(*);
}
}
46 changes: 43 additions & 3 deletions spec
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,48 @@ endseg

beginseg
name "Audiobank"
address 0x10 # fake address to avoid map lookup inaccuracies
include "$(BUILD_DIR)/baserom/Audiobank.o"
address 0
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_0.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_1.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_2.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_3.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_4.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_5.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_6.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_7.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_8.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_9.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_10.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_11.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_12.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_13.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_14.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_15.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_16.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_17.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_18.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_19.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_20.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_21.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_22.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_23.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_24.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_25.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_26.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_27.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_28.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_29.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_30.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_31.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_32.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_33.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_34.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_35.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_36.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_37.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_38.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_39.o"
include "$(BUILD_DIR)/assets/audio/soundfonts/Soundfont_40.o"
endseg

beginseg
Expand Down Expand Up @@ -615,7 +655,7 @@ beginseg
include "$(BUILD_DIR)/src/code/jpegdecoder.o"
include_data_with_rodata "$(BUILD_DIR)/src/code/z_game_over.o"
include "$(BUILD_DIR)/src/code/z_construct.o"
include "$(BUILD_DIR)/data/code/audio_soundfont_table.rodata.o"
include "$(BUILD_DIR)/src/audio/tables/soundfont_table.o"
include "$(BUILD_DIR)/data/code/audio_sequence_font_table.rodata.o"
include "$(BUILD_DIR)/data/code/audio_sequence_table.rodata.o"
include "$(BUILD_DIR)/src/audio/tables/samplebank_table.o"
Expand Down
6 changes: 3 additions & 3 deletions src/audio/lib/heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1694,9 +1694,9 @@ void AudioHeap_InitReverb(s32 reverbIndex, ReverbSettings* settings, s32 isFirst
reverb->sample.medium = MEDIUM_RAM;
reverb->sample.size = reverb->delayNumSamples * SAMPLE_SIZE;
reverb->sample.sampleAddr = (u8*)reverb->leftReverbBuf;
reverb->loop.start = 0;
reverb->loop.count = 1;
reverb->loop.loopEnd = reverb->delayNumSamples;
reverb->loop.header.start = 0;
reverb->loop.header.count = 1;
reverb->loop.header.loopEnd = reverb->delayNumSamples;

AudioHeap_SetReverbData(reverbIndex, REVERB_DATA_TYPE_FILTER_LEFT, settings->lowPassFilterCutoffLeft, isFirstInit);
AudioHeap_SetReverbData(reverbIndex, REVERB_DATA_TYPE_FILTER_RIGHT, settings->lowPassFilterCutoffRight,
Expand Down
2 changes: 1 addition & 1 deletion src/audio/lib/load.c
Original file line number Diff line number Diff line change
Expand Up @@ -1302,7 +1302,7 @@ void AudioLoad_Init(void* heap, size_t heapSize) {

// Connect audio tables to their tables in memory
gAudioCtx.sequenceTable = (AudioTable*)gSequenceTable;
gAudioCtx.soundFontTable = (AudioTable*)gSoundFontTable;
gAudioCtx.soundFontTable = &gSoundFontTable;
gAudioCtx.sampleBankTable = &gSampleBankTable;
gAudioCtx.sequenceFontTable = gSequenceFontTable;

Expand Down
4 changes: 2 additions & 2 deletions src/audio/lib/playback.c
Original file line number Diff line number Diff line change
Expand Up @@ -861,10 +861,10 @@ void AudioPlayback_NoteInitForLayer(Note* note, SequenceLayer* layer) {
if (noteSampleState->bitField1.isSyntheticWave) {
AudioPlayback_BuildSyntheticWave(note, layer, instId);
} else if (channel->startSamplePos == 1) {
playbackState->startSamplePos = noteSampleState->tunedSample->sample->loop->start;
playbackState->startSamplePos = noteSampleState->tunedSample->sample->loop->header.start;
} else {
playbackState->startSamplePos = channel->startSamplePos;
if (playbackState->startSamplePos >= noteSampleState->tunedSample->sample->loop->loopEnd) {
if (playbackState->startSamplePos >= noteSampleState->tunedSample->sample->loop->header.loopEnd) {
playbackState->startSamplePos = 0;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/audio/lib/seqplayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ s32 AudioScript_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd) {

if (layer->delay == 0) {
if (layer->tunedSample != NULL) {
time = layer->tunedSample->sample->loop->loopEnd;
time = layer->tunedSample->sample->loop->header.loopEnd;
} else {
time = 0.0f;
}
Expand Down
Loading

0 comments on commit 7210cfa

Please sign in to comment.