The written note chooses a base duration. The rhythm modifier then changes that base. Keeping those two decisions separate makes the formula reviewable and lets reverse conversion identify exactly what a measured millisecond value represents.
Straight keeps the base duration
The straight multiplier is 1. At 120 BPM an eighth note is exactly 250 ms and a sixteenth is exactly 125 ms.
A dot adds half the note
Multiply the straight duration by 3/2. A 250 ms eighth note becomes a 375 ms dotted eighth. The dot lengthens the chosen note; it does not mean three notes.
A triplet fits three into two
Multiply the straight duration by 2/3. At 120 BPM an eighth-note triplet is 500/3 ms, displayed as approximately 166.667 ms while the internal fraction remains exact.
Reverse mode needs both choices
375 ms means 160 BPM if it is a straight quarter, 120 BPM if it is a dotted eighth, and another tempo for a triplet. Milliseconds alone do not identify BPM without note value and rhythm.