// PRE-GENERATED (design session). Pure logic.
using System.Collections.Generic;
using System.Linq;

namespace DansoriEQ.Core.Eq;

/// <summary>Full EQ state: a preamp plus an ordered list of bands.</summary>
public sealed class EqState
{
    public double PreampDb { get; set; } = 0;
    public List<Filter> Filters { get; set; } = new();

    public EqState Clone() => new()
    {
        PreampDb = PreampDb,
        Filters = Filters.Select(f => f.Clone()).ToList()
    };

    /// <summary>Total EQ gain (dB) at frequency f, including preamp.</summary>
    public double GainDbAt(double f, double fs = FrequencyResponse.DefaultSampleRate)
    {
        double sum = PreampDb;
        foreach (var band in Filters)
            sum += band.GainDbAt(f, fs);
        return sum;
    }
}
