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

Method ExpandCutLine

libraries/lib-wave-track/WaveTrackUtilities.cpp:305–350  ·  view source on GitHub ↗

Expand cut line (that is, re-insert audio, then DELETE audio saved in cut line) Can't yet promise strong exception safety for a pair of channels together

Source from the content-addressed store, hash-verified

303// Expand cut line (that is, re-insert audio, then DELETE audio saved in cut line)
304// Can't yet promise strong exception safety for a pair of channels together
305void WaveTrackUtilities::ExpandCutLine(WaveTrack &track,
306 double cutLinePosition, double* cutlineStart,
307 double* cutlineEnd)
308{
309 const bool editClipCanMove = GetEditClipsCanMove();
310
311 // Find clip which contains this cut line
312 double start = 0, end = 0;
313 const auto &clips = track.Intervals();
314 const auto pEnd = clips.end();
315 const auto pClip = std::find_if(clips.begin(), pEnd,
316 [&](const auto &clip) {
317 return clip->FindCutLine(cutLinePosition, &start, &end); });
318 if (pClip != pEnd) {
319 auto &&clip = *pClip;
320 if (!editClipCanMove) {
321 // We are not allowed to move the other clips, so see if there
322 // is enough room to expand the cut line
323 for (const auto &clip2: clips)
324 if (clip2->GetPlayStartTime() > clip->GetPlayStartTime() &&
325 clip->GetPlayEndTime() + end - start > clip2->GetPlayStartTime())
326 // Strong-guarantee in case of this path
327 throw SimpleMessageBoxException{
328 ExceptionType::BadUserAction,
329 XO("There is not enough room available to expand the cut line"),
330 XO("Warning"),
331 "Error:_Insufficient_space_in_track"
332 };
333 }
334
335 clip->ExpandCutLine(cutLinePosition);
336
337 // Strong-guarantee provided that the following gives No-fail-guarantee
338
339 if (cutlineStart)
340 *cutlineStart = start;
341 if (cutlineEnd)
342 *cutlineEnd = end;
343
344 // Move clips which are to the right of the cut line
345 if (editClipCanMove)
346 for (const auto &clip2 : clips)
347 if (clip2->GetPlayStartTime() > clip->GetPlayStartTime())
348 clip2->ShiftBy(end - start);
349 }
350}
351
352bool WaveTrackUtilities::HasHiddenData(const WaveTrack &track)
353{

Callers

nothing calls this directly

Calls 8

GetEditClipsCanMoveFunction · 0.85
IntervalsMethod · 0.80
FindCutLineMethod · 0.80
endMethod · 0.45
beginMethod · 0.45
GetPlayStartTimeMethod · 0.45
GetPlayEndTimeMethod · 0.45
ShiftByMethod · 0.45

Tested by

no test coverage detected