I am writing a program that generates a WAV file that contains a smoothly changing sound from the frequency seq1 to seq1 , the sample rate sampleRate = 44100 and a length of n seconds. It is necessary to find a formula by which to calculate the frequency of the current segment with a length of one complete oscillation of sound, as well as the total number of segments of the frame.
The current frequency is seq = k1 * x + seq1 , where k1 is the growth rate of the frequency, x is the ordinal number of the segment into one complete oscillation;
The number of samples per segment is spt = sampleRate/seq = sampleRate/(k1*x+b);
PS In principle, it can be simplified by discarding the initial frequency, and calculated by the formula spt=(sampleRate/k1)/x
As I understand it, the number of segments and the frequency increment from segment to segment should be derived from the equation

But I'm not exactly sure.
Please help extract the number of segments and the rate of increase in frequency.
int main() { ofstream out("test.wav", ios::binary); int time = 30; waveHeaderInit(2, 44100, 16, time); waveData = new char[waveHeader.subchunk2Size]; int sequence = 100; volatile float phase; volatile int16_t sample; int maxAmplitude = pow(2, waveHeader.bitsPerSample - 1) - 1; for (int i = 0; i < time * waveHeader.sampleRate; i++) { int spt = waveHeader.sampleRate / sequence; phase = (i % spt) / float(spt); sample = sin(PI*phase)*maxAmplitude; for (int channel = 0; channel < waveHeader.numChannels; channel++) { ((int16_t*)waveData)[i*waveHeader.numChannels + channel] = sample; } } out.write((char*)&waveHeader, sizeof(waveHeader)); out.write(waveData, waveHeader.subchunk2Size); out.close(); return 0; }