Skip to content

05_16_06_memory_variants

Memory-Optimized Audio Processing Variants

Status: ⏸️ NOT STARTED Priority: MEDIUM Dependencies: TAREA 0 (Variant Framework) Estimated Effort: 2 weeks


🎯 Purpose

Memory variants optimize for different memory access patterns and constraints: - In-place processing: No extra memory allocation - Zero-copy: Avoid buffer copies - Small memory footprint: For embedded/mobile - Memory pooling: Reuse allocations


πŸ“‹ Planned Features

1. In-Place Processing

class InPlaceGainVariant : public IVariant {
public:
    bool process(float* buffer, size_t numSamples);
    // Same buffer for input/output (saves 50% memory)
};

2. Zero-Copy Variants

class ZeroCopyVariant : public IVariant {
public:
    bool process(const float* input, float* output, size_t numSamples) override;
    // No internal buffer copies
};

3. Memory Pool Management

class PooledVariant : public IVariant {
public:
    bool process(const float* input, float* output, size_t numSamples) override;

private:
    MemoryPool& pool_;  // Reuse allocations
};

4. Circular Buffer Variants

class CircularBufferVariant : public IVariant {
public:
    bool process(const float* input, float* output, size_t numSamples) override;
    // Efficient for delays/reverbs

private:
    CircularBuffer<float> buffer_;
};

πŸ“Š Performance Targets

Variant Memory Usage Allocation Overhead Speed
In-Place 0.5x 0 1.05x (cache benefit)
Zero-Copy 1x 0 1.0x
Pooled 1x (reused) 0.95x 1.0x
Circular 1x + delay 0 (preallocated) 1.0x

Status: ⏸️ Useful for embedded/mobile Priority: MEDIUM