SectionDetails::startTime - Bug at curve different from 1?

Hi, I wrote this two code:

    edit->tempoSequence.insertTempo(2);
    edit->tempoSequence.getTempos()[0]->setBpm(120);
    edit->tempoSequence.getTempos()[1]->setBpm(30);
    edit->tempoSequence.getTempos()[0]->setCurve(1); //HERE THE DIFFERENCE
    edit->tempoSequence.getTempos()[1]->setCurve(1);
    DBG(edit->tempoSequence.getTempoSections().getReference(1).startTime);
    edit->tempoSequence.insertTempo(2);
    edit->tempoSequence.getTempos()[0]->setBpm(120);
    edit->tempoSequence.getTempos()[1]->setBpm(30);
    edit->tempoSequence.getTempos()[0]->setCurve(-1); //HERE THE DIFFERENCE
    edit->tempoSequence.getTempos()[1]->setCurve(1);
    DBG(edit->tempoSequence.getTempoSections().getReference(1).startTime);

the first code prints me 2, while the second 8, but I insert the the tempo at time 2 ( edit->tempoSequence.insertTempo(2); trorically means this, right? ). What’s about this?

also if I use the same code, but changing setCurve(0) and printing the start time of the second tempo it prints me 3.51658 … Here the code:

    edit->tempoSequence.insertTempo(2);
    edit->tempoSequence.getTempos()[0]->setBpm(120);
    edit->tempoSequence.getTempos()[1]->setBpm(30);
    edit->tempoSequence.getTempos()[0]->setCurve(0); //HERE THE DIFFERENCE
    edit->tempoSequence.getTempos()[1]->setCurve(1);
    int secondTempoRef = edit->tempoSequence.getTempoSections().size() - 1; //HERE THE DIFFERENCE
    DBG(edit->tempoSequence.getTempoSections().getReference(secondTempoRef).startTime); //HERE THE DIFFERENCE

Have you tried setting these tempos in Waveform? It might help to visualise what’s going on.
Changing the curve will change the tempo transition so the time between them will be affected.

1 Like

ok I understand now, if I change the curve after creating the next tempo the curve will affect also that, and it makes sense, but… the following code gives me strange results… I immagine that is because before creating the next tempo, the tempo[0] doesn’t take into account the curve, because it’s the last one until the creation of the next one and at the creation of this new tempo curve is calculated.

So… how can I insert a tempo exactly at a specific time ? (I think it would make sense rebuild the curve, maybe only changing it’s value, if this one is different from -1 or 1 at moment of the creation of the next tempo).

I know that in a real world program this should not be a problem (testing waveform for example this should never happen), but working with code it should be more correct and coherent (and it should give above of all more predictable results), doesn’t it?

    edit->tempoSequence.getTempos()[0]->setBpm(120);
    edit->tempoSequence.getTempos()[0]->setCurve(0);
    edit->tempoSequence.insertTempo(10);
    edit->tempoSequence.getTempos()[1]->setBpm(60);
    edit->tempoSequence.getTempos()[1]->setCurve(1);

I’m not quite sure what the question is here?
edit->tempoSequence.insertTempo(10); will insert a tempo at 10s.

As soon as you start changing the BPM and curve of points before it though, its time will move around. It’s beat position however will stay constant.

Oh, sorry :upside_down_face: not a question :relaxed: I was thinking it should be nice to add a func (because the start time change at setBpm and so add directly all at once should give the possibility really add a tempo at a precise time):
TempoSequence::insertTempo (double time, double bpm, float curve, juce::UndoManager* um, bool rebuldPreviousCurve = true)

I’m not sure what rebuldPreviousCurve would do in this instance though?

Inserting a tempo at a specific time is usually the wrong way to approach this though. You should probably be inserting tempos at a specific beat. They won’t move around in beats then.

1 Like

m… yes, I could Imagine. My way of thinking is because I’m writing an application that doesn’t take care of beats or bars, for example I add also a func setStartTime(double newStartTime) (in my timeline representation is in time not in beats and bars and with this approach all seem so strange) :upside_down_face:

But reading better the code in tracktion I understand what you mean: a tempo section takes care about both tempo settings and time signature setting, so the best approach should be setting the new bpm in timeline by adding a new time setting (in this way I could add it in time without taking care of beats and bars, because time velocity could change also inside those)?