Audacity 3.2.0
LabelTrackEditing.cpp
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*!********************************************************************
3
4 Audacity: A Digital Audio Editor
5
6 @file LabelTrackEditing.cpp
7
8 PaulLicameli
9
10**********************************************************************/
11#include "LabelTrack.h"
12#include "TempoChange.h"
13
17 return [](LabelTrack &track,
18 const std::optional<double> &oldTempo, double newTempo)
19 {
20 if (!oldTempo.has_value())
21 return;
22 const auto ratio = *oldTempo / newTempo;
23 const size_t nn = track.GetNumLabels();
24 for (size_t ii = 0; ii < nn; ++ii) {
25 auto label = *track.GetLabel(ii);
26 label.selectedRegion.setTimes(
27 label.getT0() * ratio, label.getT1() * ratio);
28 track.SetLabel(ii, label);
29 }
30 };
31}
DEFINE_ATTACHED_VIRTUAL_OVERRIDE(OnLabelTrackProjectTempoChange)
TranslatableString label
Definition: TagsEditor.cpp:165
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:95
int GetNumLabels() const
const LabelStruct * GetLabel(int index) const
void SetLabel(size_t iLabel, const LabelStruct &newLabel)
Definition: LabelTrack.cpp:169
For defining overrides of the method.