What is the difference between clip length and end?

I’m having trouble understanding the start, end and length of a clip.

const te::EditTimeRange editTimeRange (0, edit->tempoSequence.barsBeatsToTime ({ 1, 0.0 }));
auto clip = track->insertNewClip (te::TrackItem::Type::step, "StepClip", editTimeRange, nullptr);
auto stepClip = static_cast<te::StepClip*>(clip);

DBG("stepClip->getStartBeat: " + juce::String(stepClip->getStartBeat()));
DBG("stepClip->getContentStartBeat: " + juce::String(stepClip->getContentStartBeat()));
DBG("stepClip->getLengthInBeats: " + juce::String(stepClip->getLengthInBeats()));
DBG("stepClip->getEndBeat: " + juce::String(stepClip->getEndBeat()));

DBG("stepClip->getLoopLength: " + juce::String(stepClip->getLoopLength()));
DBG("stepClip->getBeatsPerBar: " + juce::String(stepClip->getBeatsPerBar()));

DBG("stepClip->getPosition().getStart: " + juce::String(stepClip->getPosition().getStart()));
DBG("stepClip->getPosition().getEnd: " + juce::String(stepClip->getPosition().getEnd()));
DBG("stepClip->getPosition().getLength: " + juce::String(stepClip->getPosition().getLength()));

DBG("stepClip->getPattern(0).getNumNotes: " + juce::String(stepClip->getPattern(0).getNumNotes()));

DBG("stepClip->getEditTimeRange().getStart: " + juce::String(stepClip->getEditTimeRange().getStart()));
DBG("stepClip->getEditTimeRange().getLength: " + juce::String(stepClip->getEditTimeRange().getLength()));
DBG("stepClip->getEditTimeRange().getEnd: " + juce::String(stepClip->getEditTimeRange().getEnd()));

This is the result:

stepClip->getStartBeat: 0
stepClip->getContentStartBeat: 0
stepClip->getLengthInBeats: 4
stepClip->getEndBeat: 4
stepClip->getLoopLength: 0
stepClip->getBeatsPerBar: 4
stepClip->getPosition().getStart: 0
stepClip->getPosition().getEnd: 2
stepClip->getPosition().getLength: 2
stepClip->getPattern(0).getNumNotes: 16
stepClip->getEditTimeRange().getStart: 0
stepClip->getEditTimeRange().getLength: 2
stepClip->getEditTimeRange().getEnd: 2

How can I find out the length of a clip? Why are clip end and length the same?

Tracktion display it correctly:

Screenshot 2021-12-01 at 16.24.13

A clip don’t have to start at the beginning of the track. If the start is later then its end is later, too.

That sounds logical… Thanks!
My question is more about the clip length of 2 bars (stepClip->getPosition().getLength())

I thought I created a clip with 1 bar:

const te::EditTimeRange editTimeRange (0, edit->tempoSequence.barsBeatsToTime ({ **1**, 0.0 }));
auto clip = track->insertNewClip (te::TrackItem::Type::step, "StepClip", editTimeRange, nullptr);

If I set the start and end it plays only the first half of the clip:

stepClip->setStart(0.0, true, true);
stepClip->setEnd(1.0, true);

Here is the example with the StepSequencerDemo:
https://github.com/toxvox/StepSequencerDemo/blob/93fb9c4adf7759b7caffbf9997c673d71407a6a8/Source/StepSequencerDemo.h#L529

I think: at 120 BPM is 1 bar == 2.0s. When you set the end of your clip at 1.0s you got a 1/2 bar.

1 Like

Check the values of your editTimeRange above created using tempoSequence.barsBeatsToTime, that presumably is { 0.0, 2.0 }.

If you then set the end to 1.0s as @baramgb says, you’re overwriting the end position to be 1s which is only half of your clip.

1 Like

Thank you for the hints @baramgb @dave96 !