From 6060a69101c80eb580ae68134e731af2e314ba0e Mon Sep 17 00:00:00 2001 From: skal Date: Sun, 8 Feb 2026 12:29:52 +0100 Subject: feat(audio, tools): Add Task #72 and enhance Blender exporter - Add Task #72 (Audio Pipeline Streamlining) to TODO.md and PROJECT_CONTEXT.md. - Update blender_export.py to support 'EMPTY' objects for planes and export 'plane_distance'. --- PROJECT_CONTEXT.md | 5 +++++ TODO.md | 16 ++++++++++++++++ tools/blender_export.py | 15 ++++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/PROJECT_CONTEXT.md b/PROJECT_CONTEXT.md index 9b36223..663d320 100644 --- a/PROJECT_CONTEXT.md +++ b/PROJECT_CONTEXT.md @@ -50,6 +50,11 @@ Style: - Phase 3: File I/O (load .wav/.spec, export procedural_params.txt + C++ code) - See `doc/SPECTRAL_BRUSH_EDITOR.md` for complete design +- **Task #72: Audio Pipeline Streamlining** + - Optimize data flow: reduce copies and temp buffers. + - Direct additive mixing: have tracker add samples directly to output buffer. + - Precision: maintain float32 internally, clip/convert at the very end. + - **Visuals & Content** - [ ] **Task #52: Procedural SDF Font**: Minimal bezier/spline set for [A-Z, 0-9] and SDF rendering. - [ ] **Task #53: Particles Shader Polish**: Improve visual quality of particles. diff --git a/TODO.md b/TODO.md index 2400113..72d1b74 100644 --- a/TODO.md +++ b/TODO.md @@ -93,6 +93,22 @@ This file tracks prioritized tasks with detailed attack plans. --- +## Priority 2: Audio Pipeline Streamlining (Task #72) + +**Goal**: Optimize the audio pipeline to reduce memory copies and simplify the data flow by using direct additive mixing and deferred clipping. + +- [ ] **Phase 1: Direct Additive Mixing** + - Modify `Synth` and `Tracker` to accept a target output buffer for direct additive mixing instead of returning isolated voice samples. + - Eliminate temporary buffers used for individual voice rendering. +- [ ] **Phase 2: Float32 Internal Pipeline** + - Ensure the entire internal pipeline (synthesis, mixing) maintains full `float32` precision without intermediate clipping. +- [ ] **Phase 3: Final Clipping & Conversion** + - Implement a single, final stage that performs clipping (limiter/clamping) and conversion to `int16` (or other hardware-native formats) just before the audio backend delivery. +- [ ] **Phase 4: Verification** + - Verify audio quality and performance improvements with `test_demo` and existing audio tests. + +--- + ## Priority 2: 3D System Enhancements (Task #18) **Goal:** Establish a pipeline for importing complex 3D scenes to replace hardcoded geometry. diff --git a/tools/blender_export.py b/tools/blender_export.py index da7b986..c4a45ff 100644 --- a/tools/blender_export.py +++ b/tools/blender_export.py @@ -16,6 +16,7 @@ import os # quat rotation (x, y, z, w) # vec3 scale # vec4 color +# float plane_distance (if type == PLANE) # uint32_t mesh_name_len # char[] mesh_name (if type == MESH) # float mass @@ -25,7 +26,13 @@ import os def export_scene(filepath): print(f"Exporting scene to {filepath}...") - objects = [obj for obj in bpy.context.scene.objects if obj.visible_get() and obj.type == 'MESH'] + objects = [] + for obj in bpy.context.scene.objects: + if obj.visible_get(): + if obj.type == 'MESH': + objects.append(obj) + elif obj.type == 'EMPTY' and obj.name.lower().startswith('plane_'): + objects.append(obj) with open(filepath, 'wb') as f: # Header @@ -84,6 +91,12 @@ def export_scene(filepath): c = obj.active_material.diffuse_color color = (c[0], c[1], c[2], c[3]) f.write(struct.pack('<4f', *color)) + + # Plane Distance (if type == PLANE) + plane_distance = 0.0 + if obj_type == 2: # PLANE + plane_distance = obj.get('plane_distance', 0.0) + f.write(struct.pack('