// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later

package space.rcmd.android.sizzle.model

/**
 * Factory presets for the [ToolboxType.MIX_TIGHTENER] effect — genre- and
 * instrument-targeted "channel strip in a box" settings. Each preset is a sparse
 * map of the effect's hidden per-band parameters (EQ / crossover / 3-band
 * compressor / limiter / output); anything omitted falls back to the DSP's
 * defaults in `MixTightener`. Only the single **Strength** control is exposed in
 * the editor — these presets are the "under the hood" tuning it morphs toward.
 *
 * Parameter keys (all optional, dB / Hz / ms):
 *   strength                                     0..1 morph amount (default 1)
 *   eqLoFreq eqLoGain                            low shelf
 *   eqMidFreq eqMidGain eqMidQ                   mid peak
 *   eqHiFreq eqHiGain                            high shelf
 *   xLo xHi                                      band crossover frequencies
 *   cLoThr cLoRatio cLoAtk cLoRel cLoMk          low-band compressor
 *   cMidThr cMidRatio cMidAtk cMidRel cMidMk     mid-band compressor
 *   cHiThr cHiRatio cHiAtk cHiRel cHiMk          high-band compressor
 *   limCeil limRel                               peak limiter
 *   outGain                                      make-up at the output
 */
object MixTightenerPresets {

    class Preset(val name: String, val params: Map<String, String>)

    /** Apply [preset]'s overrides onto an already-[ToolboxSlot.fill]ed slot. */
    fun apply(slot: ToolboxSlot, preset: Preset) {
        preset.params.forEach { (k, v) -> slot.set(k, v) }
    }

    val FACTORY: List<Preset> = listOf(
        // ---------------- Drums & percussion ----------------
        Preset("808 Crisp", mapOf(
            "eqLoFreq" to "70", "eqLoGain" to "4", "eqMidFreq" to "450", "eqMidGain" to "-2",
            "eqHiFreq" to "9000", "eqHiGain" to "4", "xLo" to "120", "xHi" to "3000",
            "cLoThr" to "-22", "cLoRatio" to "4", "cLoAtk" to "8", "cLoRel" to "140", "cLoMk" to "3",
            "cMidThr" to "-20", "cMidRatio" to "2.5", "cMidMk" to "1",
            "cHiThr" to "-24", "cHiRatio" to "3", "cHiAtk" to "3", "cHiRel" to "80", "cHiMk" to "2",
            "limCeil" to "-0.3", "limRel" to "80", "outGain" to "2",
        )),
        Preset("Boom-Bap Kit", mapOf(
            "eqLoFreq" to "90", "eqLoGain" to "2", "eqHiFreq" to "10000", "eqHiGain" to "1.5",
            "xLo" to "160", "xHi" to "2500",
            "cLoThr" to "-20", "cLoRatio" to "3", "cLoAtk" to "12", "cLoRel" to "160", "cLoMk" to "2",
            "cMidThr" to "-18", "cMidRatio" to "2.5", "cMidMk" to "1",
            "limCeil" to "-0.5", "outGain" to "1.5",
        )),
        Preset("Trap Hats", mapOf(
            "eqMidFreq" to "4000", "eqMidGain" to "1", "eqHiFreq" to "11000", "eqHiGain" to "5", "xHi" to "4000",
            "cLoRatio" to "1.5", "cMidRatio" to "2",
            "cHiThr" to "-26", "cHiRatio" to "4", "cHiAtk" to "2", "cHiRel" to "60", "cHiMk" to "2",
            "limCeil" to "-0.3", "outGain" to "2",
        )),
        Preset("Industrial Drums", mapOf(
            "eqLoFreq" to "80", "eqLoGain" to "3", "eqMidFreq" to "2200", "eqMidGain" to "3", "eqMidQ" to "1.2",
            "eqHiFreq" to "8000", "eqHiGain" to "2", "xLo" to "150", "xHi" to "2000",
            "cLoThr" to "-18", "cLoRatio" to "5", "cLoAtk" to "6", "cLoRel" to "120", "cLoMk" to "3",
            "cMidThr" to "-16", "cMidRatio" to "4", "cMidAtk" to "8", "cMidRel" to "120", "cMidMk" to "3",
            "cHiThr" to "-20", "cHiRatio" to "3", "cHiMk" to "2",
            "limCeil" to "-0.2", "limRel" to "60", "outGain" to "3",
        )),
        Preset("Techno Kick", mapOf(
            "eqLoFreq" to "60", "eqLoGain" to "3", "eqMidFreq" to "700", "eqMidGain" to "-2",
            "xLo" to "120", "xHi" to "3000",
            "cLoThr" to "-16", "cLoRatio" to "6", "cLoAtk" to "4", "cLoRel" to "100", "cLoMk" to "3",
            "cMidRatio" to "2", "cHiRatio" to "1.5",
            "limCeil" to "-0.2", "outGain" to "2.5",
        )),
        Preset("House Groove", mapOf(
            "strength" to "0.85",
            "eqLoFreq" to "90", "eqLoGain" to "1.5", "eqHiFreq" to "9000", "eqHiGain" to "1.5",
            "xLo" to "180", "xHi" to "2600",
            "cLoThr" to "-22", "cLoRatio" to "2.5", "cLoMk" to "1.5",
            "cMidThr" to "-20", "cMidRatio" to "2", "cMidMk" to "1",
            "cHiThr" to "-22", "cHiRatio" to "2", "cHiMk" to "1",
            "limCeil" to "-0.5", "outGain" to "1.5",
        )),
        Preset("DnB Breaks", mapOf(
            "eqLoFreq" to "80", "eqLoGain" to "2", "eqMidFreq" to "2500", "eqMidGain" to "1.5",
            "eqHiFreq" to "9000", "eqHiGain" to "2", "xLo" to "150", "xHi" to "2500",
            "cLoThr" to "-18", "cLoRatio" to "4", "cLoAtk" to "3", "cLoRel" to "90", "cLoMk" to "2",
            "cMidThr" to "-18", "cMidRatio" to "3", "cMidAtk" to "4", "cMidRel" to "90", "cMidMk" to "2",
            "cHiThr" to "-22", "cHiRatio" to "3", "cHiAtk" to "2", "cHiRel" to "60", "cHiMk" to "2",
            "limCeil" to "-0.3", "limRel" to "50", "outGain" to "2",
        )),
        Preset("Lo-Fi Kit", mapOf(
            "strength" to "0.8",
            "eqLoFreq" to "100", "eqLoGain" to "2", "eqMidFreq" to "500", "eqMidGain" to "1",
            "eqHiFreq" to "6000", "eqHiGain" to "-4", "xLo" to "200", "xHi" to "2200",
            "cLoThr" to "-22", "cLoRatio" to "2.5", "cLoMk" to "1", "cMidRatio" to "2", "cHiRatio" to "1.5",
            "limCeil" to "-1", "outGain" to "1",
        )),
        Preset("Snare Crack", mapOf(
            "eqLoFreq" to "200", "eqLoGain" to "-2", "eqMidFreq" to "2000", "eqMidGain" to "3", "eqMidQ" to "1.5",
            "eqHiFreq" to "8000", "eqHiGain" to "3", "xLo" to "250", "xHi" to "1800",
            "cLoRatio" to "1.5",
            "cMidThr" to "-18", "cMidRatio" to "4", "cMidAtk" to "3", "cMidRel" to "100", "cMidMk" to "2",
            "cHiThr" to "-22", "cHiRatio" to "3", "cHiAtk" to "2", "cHiRel" to "70", "cHiMk" to "2",
            "limCeil" to "-0.3", "outGain" to "2",
        )),
        Preset("Clap Snap", mapOf(
            "eqMidFreq" to "1500", "eqMidGain" to "2", "eqHiFreq" to "9000", "eqHiGain" to "4", "xHi" to "3000",
            "cLoRatio" to "1.5",
            "cMidRatio" to "3", "cMidAtk" to "3", "cMidMk" to "1",
            "cHiRatio" to "3", "cHiAtk" to "2", "cHiMk" to "2", "outGain" to "2",
        )),
        Preset("Cymbal Sheen", mapOf(
            "strength" to "0.75",
            "eqMidFreq" to "3000", "eqMidGain" to "-1", "eqHiFreq" to "12000", "eqHiGain" to "4", "xHi" to "5000",
            "cHiThr" to "-26", "cHiRatio" to "2.5", "cHiAtk" to "5", "cHiRel" to "120", "cHiMk" to "1",
            "limCeil" to "-0.5", "outGain" to "1.5",
        )),
        Preset("Percussion Tight", mapOf(
            "eqMidFreq" to "2500", "eqMidGain" to "1.5", "eqHiFreq" to "8000", "eqHiGain" to "2",
            "xLo" to "200", "xHi" to "2500",
            "cLoRatio" to "2", "cLoMk" to "1",
            "cMidRatio" to "3", "cMidAtk" to "4", "cMidMk" to "1.5",
            "cHiRatio" to "2.5", "cHiMk" to "1", "outGain" to "1.5",
        )),

        // ---------------- Bass ----------------
        Preset("EBM Bass", mapOf(
            "eqLoFreq" to "80", "eqLoGain" to "3", "eqMidFreq" to "800", "eqMidGain" to "2", "eqMidQ" to "1.2",
            "eqHiFreq" to "9000", "eqHiGain" to "-2", "xLo" to "150", "xHi" to "1500",
            "cLoThr" to "-18", "cLoRatio" to "4", "cLoAtk" to "10", "cLoRel" to "130", "cLoMk" to "3",
            "cMidThr" to "-18", "cMidRatio" to "3", "cMidAtk" to "12", "cMidRel" to "130", "cMidMk" to "2",
            "cHiRatio" to "1.5", "limCeil" to "-0.3", "outGain" to "2.5",
        )),
        Preset("Reese Bass", mapOf(
            "eqLoFreq" to "70", "eqLoGain" to "2", "eqMidFreq" to "500", "eqMidGain" to "2",
            "xLo" to "140", "xHi" to "1200",
            "cLoThr" to "-16", "cLoRatio" to "5", "cLoAtk" to "8", "cLoRel" to "120", "cLoMk" to "3",
            "cMidThr" to "-18", "cMidRatio" to "3", "cMidMk" to "2", "cHiRatio" to "1.5",
            "limCeil" to "-0.3", "outGain" to "2",
        )),
        Preset("Acid 303", mapOf(
            "eqLoFreq" to "90", "eqLoGain" to "1", "eqMidFreq" to "1200", "eqMidGain" to "3", "eqMidQ" to "1.5",
            "xLo" to "160", "xHi" to "1800",
            "cLoRatio" to "3", "cLoMk" to "2",
            "cMidThr" to "-18", "cMidRatio" to "4", "cMidAtk" to "6", "cMidRel" to "110", "cMidMk" to "2",
            "cHiRatio" to "2", "limCeil" to "-0.4", "outGain" to "2",
        )),
        Preset("Sub Bass Tame", mapOf(
            "strength" to "0.9",
            "eqLoFreq" to "55", "eqLoGain" to "2", "eqMidFreq" to "900", "eqMidGain" to "-2",
            "xLo" to "120", "xHi" to "2000",
            "cLoThr" to "-14", "cLoRatio" to "6", "cLoAtk" to "12", "cLoRel" to "150", "cLoMk" to "3",
            "cMidRatio" to "2", "cHiRatio" to "1.2", "limCeil" to "-0.5", "outGain" to "2",
        )),
        Preset("FM Bass Punch", mapOf(
            "eqLoFreq" to "90", "eqLoGain" to "2", "eqMidFreq" to "1000", "eqMidGain" to "1.5",
            "xLo" to "160", "xHi" to "2200",
            "cLoThr" to "-18", "cLoRatio" to "4", "cLoAtk" to "6", "cLoRel" to "110", "cLoMk" to "2",
            "cMidThr" to "-18", "cMidRatio" to "3", "cMidMk" to "1.5", "cHiRatio" to "2",
            "limCeil" to "-0.3", "outGain" to "2",
        )),
        Preset("Goth Bass", mapOf(
            "strength" to "0.9",
            "eqLoFreq" to "75", "eqLoGain" to "3", "eqMidFreq" to "600", "eqMidGain" to "-1",
            "eqHiFreq" to "8000", "eqHiGain" to "-2", "xLo" to "140", "xHi" to "1600",
            "cLoThr" to "-18", "cLoRatio" to "4", "cLoAtk" to "10", "cLoRel" to "140", "cLoMk" to "3",
            "cMidRatio" to "2.5", "cMidMk" to "1", "cHiRatio" to "1.5", "limCeil" to "-0.5", "outGain" to "2",
        )),
        Preset("Synthwave Bass", mapOf(
            "eqLoFreq" to "80", "eqLoGain" to "2.5", "eqMidFreq" to "900", "eqMidGain" to "1",
            "eqHiFreq" to "7000", "eqHiGain" to "1", "xLo" to "150", "xHi" to "2000",
            "cLoThr" to "-20", "cLoRatio" to "3", "cLoAtk" to "10", "cLoRel" to "130", "cLoMk" to "2",
            "cMidRatio" to "2.5", "cMidMk" to "1", "cHiRatio" to "2",
            "limCeil" to "-0.5", "outGain" to "1.8",
        )),

        // ---------------- Synths, leads & pads ----------------
        Preset("Synthwave Lead", mapOf(
            "strength" to "0.85",
            "eqLoFreq" to "200", "eqLoGain" to "-1", "eqMidFreq" to "2000", "eqMidGain" to "1.5",
            "eqHiFreq" to "9000", "eqHiGain" to "4", "xLo" to "300", "xHi" to "3000",
            "cLoRatio" to "1.5",
            "cMidThr" to "-20", "cMidRatio" to "2.5", "cMidAtk" to "12", "cMidRel" to "150", "cMidMk" to "1.5",
            "cHiThr" to "-22", "cHiRatio" to "2", "cHiMk" to "1.5", "limCeil" to "-0.5", "outGain" to "2",
        )),
        Preset("Cutting Lead", mapOf(
            "eqLoFreq" to "200", "eqLoGain" to "-2", "eqMidFreq" to "3000", "eqMidGain" to "3", "eqMidQ" to "1.2",
            "eqHiFreq" to "8000", "eqHiGain" to "2", "xLo" to "300", "xHi" to "3500",
            "cLoRatio" to "1.5",
            "cMidThr" to "-18", "cMidRatio" to "3", "cMidAtk" to "8", "cMidRel" to "130", "cMidMk" to "2",
            "cHiRatio" to "2", "cHiMk" to "1", "limCeil" to "-0.4", "outGain" to "2",
        )),
        Preset("Darkwave Pad", mapOf(
            "strength" to "0.7",
            "eqLoFreq" to "150", "eqLoGain" to "1", "eqMidFreq" to "1000", "eqMidGain" to "0.5",
            "eqHiFreq" to "8000", "eqHiGain" to "-2", "xLo" to "250", "xHi" to "2500",
            "cLoRatio" to "2", "cLoMk" to "1",
            "cMidThr" to "-24", "cMidRatio" to "2", "cMidAtk" to "20", "cMidRel" to "200", "cMidMk" to "1",
            "cHiRatio" to "2", "limCeil" to "-1", "outGain" to "1",
        )),
        Preset("Ambient Wash", mapOf(
            "strength" to "0.6",
            "eqLoFreq" to "120", "eqLoGain" to "1", "eqHiFreq" to "10000", "eqHiGain" to "1",
            "xLo" to "300", "xHi" to "3000",
            "cMidThr" to "-26", "cMidRatio" to "1.8", "cMidAtk" to "30", "cMidRel" to "250", "cMidMk" to "0.5",
            "limCeil" to "-1.5", "outGain" to "0.5",
        )),
        Preset("Pluck Tight", mapOf(
            "eqMidFreq" to "2500", "eqMidGain" to "2", "eqHiFreq" to "9000", "eqHiGain" to "3",
            "xLo" to "300", "xHi" to "3000", "cLoRatio" to "1.5",
            "cMidThr" to "-18", "cMidRatio" to "3", "cMidAtk" to "3", "cMidRel" to "100", "cMidMk" to "1.5",
            "cHiThr" to "-22", "cHiRatio" to "2.5", "cHiAtk" to "2", "cHiRel" to "70", "cHiMk" to "1.5",
            "outGain" to "1.5",
        )),
        Preset("Arp Sparkle", mapOf(
            "strength" to "0.8",
            "eqMidFreq" to "3000", "eqMidGain" to "1", "eqHiFreq" to "11000", "eqHiGain" to "4", "xHi" to "4000",
            "cMidRatio" to "2", "cMidMk" to "1",
            "cHiThr" to "-24", "cHiRatio" to "2.5", "cHiAtk" to "4", "cHiMk" to "1.5",
            "limCeil" to "-0.5", "outGain" to "1.5",
        )),
        Preset("Chip Lead", mapOf(
            "eqLoFreq" to "150", "eqLoGain" to "-3", "eqMidFreq" to "2500", "eqMidGain" to "2.5", "eqMidQ" to "1.2",
            "eqHiFreq" to "8000", "eqHiGain" to "2", "xLo" to "350", "xHi" to "3000",
            "cLoRatio" to "1.2",
            "cMidThr" to "-18", "cMidRatio" to "3", "cMidMk" to "2", "cHiRatio" to "2", "cHiMk" to "1",
            "limCeil" to "-0.4", "outGain" to "2",
        )),
        Preset("Bell Clarity", mapOf(
            "strength" to "0.75",
            "eqMidFreq" to "1800", "eqMidGain" to "1.5", "eqHiFreq" to "10000", "eqHiGain" to "3", "xHi" to "4000",
            "cMidRatio" to "2", "cMidAtk" to "6", "cMidMk" to "1",
            "cHiRatio" to "2", "cHiAtk" to "4", "cHiMk" to "1", "limCeil" to "-0.5", "outGain" to "1",
        )),
        Preset("Keys Clarity", mapOf(
            "strength" to "0.8",
            "eqLoFreq" to "200", "eqLoGain" to "-1", "eqMidFreq" to "2500", "eqMidGain" to "1.5",
            "eqHiFreq" to "9000", "eqHiGain" to "2", "xLo" to "250", "xHi" to "3000",
            "cLoRatio" to "1.8",
            "cMidThr" to "-22", "cMidRatio" to "2.5", "cMidAtk" to "10", "cMidRel" to "150", "cMidMk" to "1",
            "cHiRatio" to "2", "cHiMk" to "1", "limCeil" to "-0.5", "outGain" to "1.5",
        )),

        // ---------------- Bus / master ----------------
        Preset("Mix Glue", mapOf(
            "strength" to "0.7",
            "eqLoFreq" to "100", "eqLoGain" to "0.5", "eqHiFreq" to "10000", "eqHiGain" to "1",
            "xLo" to "200", "xHi" to "2500",
            "cLoThr" to "-22", "cLoRatio" to "2", "cLoAtk" to "20", "cLoRel" to "200", "cLoMk" to "1",
            "cMidThr" to "-22", "cMidRatio" to "2", "cMidAtk" to "25", "cMidRel" to "200", "cMidMk" to "1",
            "cHiThr" to "-22", "cHiRatio" to "2", "cHiAtk" to "15", "cHiRel" to "180", "cHiMk" to "1",
            "limCeil" to "-0.8", "outGain" to "1",
        )),
        Preset("Loudness Max", mapOf(
            "eqLoFreq" to "90", "eqLoGain" to "1", "eqHiFreq" to "9000", "eqHiGain" to "2",
            "xLo" to "180", "xHi" to "2800",
            "cLoThr" to "-20", "cLoRatio" to "3", "cLoMk" to "2",
            "cMidThr" to "-18", "cMidRatio" to "3", "cMidMk" to "2",
            "cHiThr" to "-20", "cHiRatio" to "3", "cHiMk" to "2",
            "limCeil" to "-0.1", "limRel" to "40", "outGain" to "4",
        )),
    )
}
