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{
18 return [](LabelTrack& track, const std::optional<double>& oldTempo,
19 double newTempo) {
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 {
26 auto label = *track.GetLabel(ii);
27 label.selectedRegion.setTimes(
28 label.getT0() * ratio, label.getT1() * ratio);
29 track.SetLabel(ii, label);
30 }
31 };
32}
DEFINE_ATTACHED_VIRTUAL_OVERRIDE(OnLabelTrackProjectTempoChange)
TranslatableString label
Definition: TagsEditor.cpp:165
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:98
int GetNumLabels() const
const LabelStruct * GetLabel(int index) const
void SetLabel(size_t iLabel, const LabelStruct &newLabel)
Definition: LabelTrack.cpp:183
For defining overrides of the method.