For a sinusoidal signal $x(t) = B\sin(\omega t + \theta)$, the envelope of the AM signal
has maximum and minimum values
$$A_{\max} = A_c(1+mB), \qquad A_{\min} = A_c(1-mB)\tag{1}$$ where $m \leq B^{-1}$ to ensure that
$A_{\min} \geq 0$, and the modulation index (commonly expressed as a percentage)
is $M = 100mB\%$. It follows straightforwardly that
$$A_c = \frac{A_\max + A_\min}{2}, \qquad mB = \frac{A_\max -A_\min}{A_\max + A_\min}.
\tag{2}$$
If $x(t)$ is a sum of sinusoids, then $(1)$ and $(2)$ still apply with the obvious
change that $B$ is replaced by $x_\max$, the maximum value of $x(t)$. Note that
$x_\min = -B$.
The above is all fine and dandy for the typical modulating
signals that are encountered in AM applications.
However, things get more complicated if we consider arbitrary
(not necessarily sums-of-sinusoids) signals $x(t)$
as modulating signals. If $x(t)$ has a DC component,
then there is effectively an increase (or perhaps worse, a decrease)
in the nominal carrier amplitude and carrier power. Similarly,
if $x_\max \neq |x_\min|$,
or $x_\max < 0$ or $x_\min > 0$ (note that the last two cases
also mean that $x(t)$ has a DC component), the meaning of modulation
index is less clear. Note also that for arbitrary signals, it is not
necessarily true that the DC component has value $\frac{x_\max+x_\min}{2}$,
and so measuring just $A_\max$ and $A_\min$ is not necessarily
going to provide all the information needed to determine the modulation
index.