From fc79632df87bfd11796cc7ca34b41d44e01319fc Mon Sep 17 00:00:00 2001 From: Tharo <17233964+Thar0@users.noreply.github.com> Date: Sun, 11 Aug 2024 16:41:33 +0100 Subject: [PATCH] [Audio 3/?] Set up building samples (#2024) * [Audio 3/?] Set up building samples * AIFF -> SAMPLE --- Makefile | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/Makefile b/Makefile index 8b630079d5..4a7ec5ac8b 100644 --- a/Makefile +++ b/Makefile @@ -233,6 +233,7 @@ SPEC_REPLACE_VARS := sed -e 's|$$(BUILD_DIR)|$(BUILD_DIR)|g' # Audio tools AUDIO_EXTRACT := $(PYTHON) tools/audio_extraction.py +SAMPLECONV := tools/audio/sampleconv/sampleconv CFLAGS += $(CPP_DEFINES) CPPFLAGS += $(CPP_DEFINES) @@ -298,6 +299,22 @@ else SRC_DIRS := $(shell find src -type d) endif +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)/%)) + # create extracted directories $(shell mkdir -p $(EXTRACTED_DIR) $(EXTRACTED_DIR)/assets $(EXTRACTED_DIR)/text) @@ -644,6 +661,30 @@ $(BUILD_DIR)/assets/%.jpg.inc.c: assets/%.jpg $(BUILD_DIR)/assets/%.jpg.inc.c: $(EXTRACTED_DIR)/assets/%.jpg $(ZAPD) bren -eh -i $< -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 $(