package mg.dot.feufaro.midi

enum class Dynamic(val velocity: Int, val label: String, val factor: Float) {
    PPP(16,  "ppp", 0.55f),
    PP (33,  "pp",  0.66f),
    P  (49,  "p",   0.77f),
    MP (64,  "mp",  0.88f),
    MF (80,  "mf",  1.00f),
    F  (96,  "f",   1.15f),
    FF (112, "ff",  1.35f),
    FFF(126, "fff", 1.60f);

    companion object {
        fun fromVelocity(v: Int): Dynamic =
            entries.minByOrNull { kotlin.math.abs(it.velocity - v) } ?: MF
    }
}