I have various audio loops that need to change pitch when I change the tempo. The relationship is not linear, so it must be exponential, but I don't know what the equation would be.
There is an online calculator that does individual changes, but I need to have it automatically change the pitch when I change the Beats Per Minute.
For instance:
If I gradually go from 123 beats per minute (tempo) down to 112 BPM, the overall pitch change is -1.62.
From 85 BPM to 111 BPM, the pitch change is 4.62
And from 176 BPM TO 137 BPM, the pitch change is -4.34
From these examples, is it possible to find exponent?
The formula is $$ pitchchange=-12\log_2(tempo_1/tempo_2) $$ where $tempo_1$ denotes the tempo before the change and $tempo_2$ the tempo after the change.
The theory behind this is that when the frequency of a tone is doubled, the pitch changes 12 chromatic steps (also known as one octave), so we have the (exponential) relationship $$ y=2^{x/12} $$ where $y$ denotes the frequency and $x$ denotes the number of chromatic steps. Dividing two known frequencies $y_1$ and $y_2$ and then solving for the pitch change $k$ from $x_1$ to $x_1+k$ then yields: $$ y_2/y_1=\frac{2^{(x_1+k)/12}}{2^{x_1/12}}\\ \iff\\ y_2/y_1=2^{k/12}\\ \iff\\ k=12\log_2(y_2/y_1)=-12\log(y_1/y_2) $$ and scaling the tempo of an audio sample by a factor corresponds to scaling all its frequencies by that factor, which is why the same principle applies to ratios of tempos.
BONUS: To calculate $\log_2(x)$ you can use any logarithm $\log$ and calculate $\log_2(x)=\log(x)/\log(2)$.