I am writing a music creation program where the user is allowed to change the tempo throughout the track.
If the user had a set tempo or only changed the tempo at discrete intervals I could easily calculate the time by taking the tempo, and the beat range occupied by that tempo, and dividing the range by the beats per second tempo value. If the tempo changed at some point I would apply the same thing to the next part and add that time on to the first part.
However, I'm struggling to wrap my head around how I would do this with interpolated tempo values. Say for the example the user wants a linear interpolated increase from beat 1.0 to beat 3.0 from 120 BPM to 140 BPM. How do I calculate exactly how long a linear change in tempo would take?
I know that at a steady 120 BPM (2 BPS), this would take a second. At 140 BPM (2.33 BPS) it would take just under that. But how do I work out how long it would take with a linear increase in tempo during that time from the first value to the second?
And what if I was to allow for different interpolation methods, such as some sort of fade in or fade out interpolation? Would things become more complicated?