/// Slider travel is a presentation choice, independent of authored gain. abstract final class AudioGainScale { static const decimalPlaces = 1; static double quantizeDb(double db) => double.parse(formatDb(db)); static String formatDb(double db) { final text = db.toStringAsFixed(decimalPlaces); return text == '-0.0' ? '0.0' : text; } // Reserve 70% of travel for -24...+6 dB. Zero is a separate mute endpoint. static double dbAt(double position) { if (!position.isFinite) throw ArgumentError.value(position); final p = position.clamp(0.0, 1.0); if (p <= .01) return -90; if (p <= .2) return -90 + (p - .01) / .19 * 66; if (p <= .9) return -24 + (p - .2) / .7 * 30; return 6 + (p - .9) / .1 * 6; } static double positionAt(double db) { if (!db.isFinite) throw ArgumentError.value(db); final value = db.clamp(-90.0, 12.0); if (value <= -24) return .01 + (value + 90) / 66 * .19; if (value <= 6) return .2 + (value + 24) / 30 * .7; return .9 + (value - 6) / 6 * .1; } }