Two main standards exist:
MIDI = 12 × (octave + 1) + note_index (C=0, C♯=1… B=11).Octave = floor((MIDI_note - 12) / 12) (for SPN where C is the octave boundary).
Example: MIDI 60 (C4) → (60-12)/12 = 4. MIDI 59 (B3) → (59-12)/12 = 3.9 → floor 3 (B3).
On an 88-key piano, count white keys from A0: each group of 7 white keys (C–B) = one octave. C4 is the 4th C from the bottom.