Exponential increasing a frequency output help

I'm using an ESP32, I would like to output a frequency to an amplifier to make a sound like a camera flash charging. Here's an example of the sound
The frequency should start at 5000Hz and increase to 12000Hz over a duration of 1500ms (I'll tweak these after I get something functional), the frequency should increase exponentially.

I'm considering using "tone()" as you can set a frequency and duration. I can't find a good way to do an exponential function to adjust the frequency (or time?)
I can add an exponentially increasing number to the initial frequency, but the output would be quite stepped. Do I "map()" between the steps giving a more linear change?
There must be a better way to do this?

  for (int i = 1; i < 9000; sq(i)) {
    tone(pin, 5000 + i, 10)
  }

Can you even detect a tone change that is only one frequency for 10ms? How many cycles will you have output in 10ms?

Rather than adding "i" to the frequency, you could add an exponentially increasing value. The functions to calculate exponential values, pow() or exp(), are handy for that.

  for (float freq = 5000.0; freq <= 12000.0, freq *= 1.05) {
    tone(pin, (int)freq, STEPTIME);
  }

Adjust the 1.05 to get the desired effect (1.05 means about 18 frequencies in the loop.)

(I guess the key takeaway is that the increase is exponential WRT time, not WRT the original value. The loop does startFreq * exp(time, n))

If my math is right
50 cycles @500Hz in 10ms
120 cycles @1200Hz in 10ms
Maybe the stepping won't be noticeable?

Hi jremington. I'm squaring the "i" value added to the frequency. Doesn't that make the change from 5000 to 12000 exponential?

Hi westfw. Graphing 5000x1.05 seems to give a very linear result unless I'm misunderstanding what you're doing?

It is one approach, although most people would call that a "quadratic increase".

Graphing 5000x1.05 seems to give a very linear result

Yes, but that is not what was proposed. Rather, try the code posted in the reply, which calculates freq = freq*1.05; with each loop iteration.

import matplotlib.pyplot as plt
import numpy as np

xp = []
yp = []
t = 0.0
freq = 5000
while (freq <= 12000.0):
    xp.append(t)
    yp.append(freq)
    t = t+1
    freq = freq * 1.05
    
xpoints = np.array(xp)
ypoints = np.array(yp)

plt.plot(xpoints, ypoints)
plt.show()

PS: I'm not sure that the whine of a charging photoflash capacitor IS an exponential frequency increase.

Thanks. I'll assemble a circuit and see what the real world results are like.

I think if you study this link, you will see the real use of the exponential expression for the capacitor current which is also the frequency of the high voltage circuit you hear.

  for (int i = 1; i < 84) 
  {
    tone(pin, 5000 + (i * i), 18)
  }

That's not exponential. @westfw provided the correct form back in Post #4. In the limit of smaller and smaller step size, it becomes exp(k * t) where k is a constant.

https://dictionary.cambridge.org/dictionary/english/exponential

void setup() {
  Serial.begin(115200);
  for (int i = 1; i < 84; i++)
  {
    //tone(pin, 5000 + (i * i), 18)
    Serial.println( 5000 + (i * i));
  }
}

void loop()
{


}

graph

Hi guys
Thanks for all the input. After examining the sample sound with some better tools than just my ears it looks like it's more of a logarithmic curve (with a few harmonics I'll ignore for now), westfw was right

Experimenting last night I found some new issues. Duration set in tone has no effect on the for loop. I'm experimenting with adding a delay to give the tone some time to play before the loop continues. Currently it's not sounding very consistent, the tone melody example suggests a delay of 130% the tone duration.
The output is also sounding very stepped. I wasn't sure it would be noticeable.
I'll continue to experiment tonight

Don't forget that human pitch perception is logarithmic.

True, but given that I have a sample to emulate, it should sound the same to a human if I output something similar.

Here is westfw's code output with an added delay, and no duration (the click at before the sound is me pressing a button to trigger it)
https://jumpshare.com/s/P6t7QWQxHKF1esNtE8X8

for (float freq = 5000.0; freq <= 12000.0, freq *= 1.05) {
    tone(TonePin, (int)freq);
    delay(15);
  }
   noTone(TonePin);

I can hear the steps in the curve. I tried a linear ramp to make sure it wasn't a hardware or code problem.

    for (float freq = 4000; freq <= 13000; freq += 100) {
      tone(fTonePin, (int)freq);
      delay(20);
    }
    noTone(fTonePin);

here's the output from that
https://jumpshare.com/s/UxzeigGZCChxto5rb6Yx
It sounds quite good, it doesn't have quite the same rising curve (logarithmic?) feel as a flash charge

Remember, the brain will fill-in to make the sound appear smooth. An oscilloscope will not do that.

Are you saying you hear this as a smooth transition?
https://jumpshare.com/s/P6t7QWQxHKF1esNtE8X8