  Scaling black holes are solutions of supergravity with multiple black hole
singularities, which can be adiabatically connected to a single center black
hole solution. We develop techniques to determine partition functions for such
scaling black holes, if each constituent carries a non-vanishing magnetic
charge corresponding to a D4-brane in string theory, or equivalently M5-brane
in M-theory. For three constituents, we demonstrate that the partition function
is a mock modular form of depth two, and we determine the appropriate
non-holomorphic completion using generalized error functions. From the
four-dimensional perspective, the modular parameter is the axion-dilaton, and
our results show that $S$-duality leaves this subset of the spectrum invariant.
From the five-dimensional perspective, the modular parameter is the complex
structure of a torus $T^2$, and the scaling black holes are dual to states in
the dimensional reduction of the M5-brane worldvolume theory to $T^2$. As a
case study, we specialize the compactification manifold to a K3 fibration, and
explicitly evaluate holomorphic parts of partition functions.
