MCPcopy Create free account
hub / github.com/audacity/audacity / OffsetSequenceTime

Method OffsetSequenceTime

src/ProjectAudioManager.cpp:196–231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

194}
195
196double CutPreviewPlaybackPolicy::OffsetSequenceTime(
197 PlaybackSchedule &schedule, double offset )
198{
199 // Compute new time by applying the offset, jumping over the gap
200 auto time = schedule.GetSequenceTime();
201 if (offset >= 0) {
202 auto space = std::clamp(mGapLeft - time, 0.0, offset);
203 time += space;
204 offset -= space;
205 if (offset > 0)
206 time = std::max(time, mGapLeft + mGapLength) + offset;
207 }
208 else {
209 auto space = std::clamp(mGapLeft + mGapLength - time, offset, 0.0);
210 time += space;
211 offset -= space;
212 if (offset < 0)
213 time = std::min(time, mGapLeft) + offset;
214 }
215 time = std::clamp(time, std::min(mStart, mEnd), std::max(mStart, mEnd));
216
217 // Reset the durations
218 mDiscontinuity = false;
219 mDuration1 = mInitDuration1;
220 mDuration2 = mInitDuration2;
221 if (AtOrBefore(time, GapStart()))
222 mDuration1 = std::max(0.0,
223 mDuration1 - fabs(schedule.ComputeWarpedLength(mStart, time)));
224 else {
225 mDuration1 = 0;
226 mDuration2 = std::max(0.0,
227 mDuration2 - fabs(schedule.ComputeWarpedLength(GapEnd(), time)));
228 }
229
230 return time;
231}
232
233PlaybackSlice CutPreviewPlaybackPolicy::GetPlaybackSlice(
234 PlaybackSchedule &, size_t available)

Callers

nothing calls this directly

Calls 3

maxFunction · 0.85
minFunction · 0.50
ComputeWarpedLengthMethod · 0.45

Tested by

no test coverage detected