Audacity 3.2.0
NoteTrackEditing.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 NoteTrackEditing.cpp
7
8 PaulLicameli
9
10**********************************************************************/
11#include "WrapAllegro.h"
12#include "NoteTrack.h"
13#include "TempoChange.h"
14
17 return [](NoteTrack &track,
18 const std::optional<double> &oldTempo, double newTempo)
19 {
20 if (!oldTempo.has_value())
21 return;
22 const auto ratio = *oldTempo / newTempo;
23 auto& seq = track.GetSeq();
24 seq.convert_to_beats();
25 const auto b1 = seq.get_dur();
26 seq.convert_to_seconds();
27 const auto newDuration = seq.get_dur() * ratio;
28 seq.stretch_region(0, b1, newDuration);
29 seq.set_real_dur(newDuration);
30 };
31}
DEFINE_ATTACHED_VIRTUAL_OVERRIDE(OnNoteTrackProjectTempoChange)
A Track that is used for Midi notes. (Somewhat old code).
Definition: NoteTrack.h:78
Alg_seq & GetSeq() const
Definition: NoteTrack.cpp:158
For defining overrides of the method.