Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Audio 10/10] Loose ends #2337

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ SBC := tools/audio/sbc
SFC := tools/audio/sfc
SFPATCH := tools/audio/sfpatch
ATBLGEN := tools/audio/atblgen
AFILE_SIZES := tools/audio/afile_sizes
# We want linemarkers in sequence assembly files for better assembler error messages
SEQ_CPP := $(CPP) -x assembler-with-cpp -fno-dollars-in-identifiers
SEQ_CPPFLAGS := -D_LANGUAGE_ASEQ -DMML_VERSION=MML_VERSION_OOT $(CPP_DEFINES) -I include -I include/audio -I include/tables/sfx -I $(BUILD_DIR)/assets/audio/soundfonts
Expand Down Expand Up @@ -844,7 +845,8 @@ $(BUILD_DIR)/assets/audio/soundfonts/%.o: $(BUILD_DIR)/assets/audio/soundfonts/%
# 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) $@
# also write a .note.name section containing the symbolic name of the soundfont
$(OBJCOPY) --add-symbol $$(cat $(<:.c=.name) | head -c -1)_Start=.rodata:0,global --redefine-sym __LEN__=$$(cat $(<:.c=.name) | head -c -1)_Size --add-section .note.name=$(<:.c=.name) $(@:.o=.tmp2) $@
# cleanup temp files
@$(RM) $(@:.o=.tmp) $(@:.o=.tmp2)
ifeq ($(AUDIO_BUILD_DEBUG),1)
Expand Down Expand Up @@ -904,6 +906,16 @@ endif
$(BUILD_DIR)/assets/audio/sequence_font_table.o: $(BUILD_DIR)/assets/audio/sequence_font_table.s
$(AS) $(ASFLAGS) $< -o $@

# make headers with file sizes and amounts

$(BUILD_DIR)/src/audio/session_config.o: $(BUILD_DIR)/assets/audio/soundfont_sizes.h $(BUILD_DIR)/assets/audio/sequence_sizes.h

$(BUILD_DIR)/assets/audio/soundfont_sizes.h: $(SOUNDFONT_O_FILES)
$(AFILE_SIZES) $@ NUM_SOUNDFONTS SOUNDFONT_SIZES .rodata $^

$(BUILD_DIR)/assets/audio/sequence_sizes.h: $(SEQUENCE_O_FILES)
$(AFILE_SIZES) $@ NUM_SEQUENCES SEQUENCE_SIZES .data $^

# Extra audiobank padding that doesn't belong to any soundfont file
$(BUILD_DIR)/assets/audio/audiobank_padding.o:
echo ".section .rodata; .fill 0x20" | $(AS) $(ASFLAGS) -o $@
Expand Down
77 changes: 77 additions & 0 deletions docs/audio/Samplebank_XML.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Samplebank XML Format Specification

Samplebank XMLs describe a samplebank file that contains compressed waveform data. It specifies which sample files to include as well as certain global properties such as the index of this samplebank.

---

```xml
<SampleBank
Name="<C Indentifier>"
Index="<uint>"
Medium="<Medium>"
CachePolicy="<CachePolicy>"
BufferBug="[bool]"
>
```
Begins a new samplebank.

**Attributes**

- **Name**: The name of the samplebank.
- **Index**: The index of the samplebank for the samplebank table. Must be a unique index for all samplebanks and pointers.
- **Medium**: The storage medium, from the `SampleMedium` enum.
- **CachePolicy**: The cache policy, from the `AudioCacheLoadType` enum.
- <ins>[Optional]</ins> **BufferBug**: Whether this samplebank suffers from a buffer clearing bug present in the original audio tools. For matching only.

**Tags**

-
```xml
<Pointer
Index="<uint>"
/>
```
Create an alternate index that refers to this samplebank.

**Attributes**

- **Index**: The alternative index, must be unique among all samplebanks and pointers.

---

-
```xml
<Sample
Name="<C Identifier>"
Path="<Path>"
/>
```
Adds a **compressed** sample file to the samplebank. The sample should be single-channel and big-endian, in a format that is recognizable by the audio driver such as: pcm16, vadpcm, or half-frame vadpcm.

**Attributes**

- **Name**: Name of this sample. Must be a valid C language identifier.
- **Path**: Path to aifc file relative to the project root (typically in `$(BUILD_DIR)/assets/audio/samples/`)

---

-
```xml
<Blob
Name="<C Identifier>"
Path="<Path>"
/>
```
Adds a binary blob to the samplebank. Intended for matching only when data cannot be identified.

**Attributes**

- **Name**: Name of this blob. Must be a valid C language identifier.
- **Path**: Path to binary file, relative to the project root (typically in `$(BUILD_DIR)/assets/audio/samples/`)

---

```xml
</SampleBank>
```
---
Loading