getTempoSection

There’s something in Tracktion that gives me the corresponding tempo section that match a specific time or a specific beat? something like “getTempoSection( double atBeat)” “getTempoSection(double atTime)”?

I wrote this but I think it could be write better from Tracktion programmers and it should be a great idea to add something like these funcs in framework:

TempoSequence::SectionDetails getMatchingTempoSection(int const beat) const 
    {
        auto sections = edit.tempoSequence.getTempoSections();
        TempoSequence::SectionDetails section;
        for (int i = 0; i < sections.size(); ++i)
        {
            if (sections.getReference(i).startBeatInEdit > beat) { break; }
            section = sections.getReference(i);
        }
        return section;
    }

What info do you actually need? Usually you’d use TempoSequence::getTempoAtBeat and then use the TempoSetting for the relevant info.

Or you’d use a TempoSequencePosition, set it to the appropriate time and use getCurrentTempo on it to get the section details.

1 Like

I’m trying to get corresponding absolutepixel in a timeline from a certain time (but in my case I need to take care about various tempos in tempo sequence because playhead has not constant velocity as for example in cubase timeline)

That must mean you have constant beats then?

So if you know the beat at the left of the screen, and the beat at the right, you can use a beat within them to find the pixel?