From b2861116666be67314a1c30bb796ee179cd0a0c2 Mon Sep 17 00:00:00 2001 From: Tharo <17233964+Thar0@users.noreply.github.com> Date: Sun, 11 Aug 2024 16:41:38 +0100 Subject: [PATCH] [Audio 3/?] Set up building samples (#1671) * [Audio 3/?] Set up building samples * AIFF -> SAMPLE --- Makefile | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/Makefile b/Makefile index f8357736ee..e75aac5f6e 100644 --- a/Makefile +++ b/Makefile @@ -161,6 +161,7 @@ SCHC_FLAGS := # Audio tools AUDIO_EXTRACT := $(PYTHON) tools/audio_extraction.py +SAMPLECONV := tools/audio/sampleconv/sampleconv # Command to replace path variables in the spec file. We can't use the C # preprocessor for this because it won't substitute inside string literals. @@ -213,6 +214,24 @@ $(shell mkdir -p asm data extracted) SRC_DIRS := $(shell find src -type d) ASM_DIRS := $(shell find asm -type d -not -path "asm/non_matchings*") $(shell find data -type d) +ifneq ($(wildcard $(EXTRACTED_DIR)/assets/audio),) + SAMPLE_EXTRACT_DIRS := $(shell find $(EXTRACTED_DIR)/assets/audio/samples -type d) +else + SAMPLE_EXTRACT_DIRS := +endif + +ifneq ($(wildcard assets/audio/samples),) + SAMPLE_DIRS := $(shell find assets/audio/samples -type d) +else + SAMPLE_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)/%)) +SAMPLE_BLOBS_IN := $(foreach dir,$(SAMPLE_EXTRACT_DIRS),$(wildcard $(dir)/*.bin)) +SAMPLE_BLOBS := $(foreach f,$(SAMPLE_BLOBS_IN),$(f:$(EXTRACTED_DIR)/%=$(BUILD_DIR)/%)) + ## 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 @@ -505,6 +524,30 @@ $(BUILD_DIR)/assets/%.jpg.inc.c: assets/%.jpg $(BUILD_DIR)/%.schl.inc: %.schl $(SCHC) $(SCHC_FLAGS) -o $@ $< +# Audio + +AUDIO_BUILD_DEBUG ?= 0 + +# first build samples... + +$(BUILD_DIR)/assets/audio/samples/%.half.aifc: assets/audio/samples/%.half.wav + $(SAMPLECONV) vadpcm-half $< $@ + +$(BUILD_DIR)/assets/audio/samples/%.half.aifc: $(EXTRACTED_DIR)/assets/audio/samples/%.half.wav + $(SAMPLECONV) vadpcm-half $< $@ +ifeq ($(AUDIO_BUILD_DEBUG),1) + @(cmp $(