Audacity 3.2.0
TempoChange.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 TempoChange.cpp
7
8 PaulLicameli
9
10**********************************************************************/
11#include "TempoChange.h"
12#include "Channel.h"
13
14namespace {
16 ~ProjectTempo() = default;
18 { return std::make_unique<ProjectTempo>(*this); }
19
20 static ProjectTempo &Get(ChannelGroup &group);
21 static const ProjectTempo &Get(const ChannelGroup &group);
22
23 std::optional<double> mProjectTempo;
24};
25
28 [](auto &) { return std::make_unique<ProjectTempo>(); } };
29
31{
32 return group.Attachments::Get<ProjectTempo>(projectTempoDataFactory);
33}
34
36{
37 return Get(const_cast<ChannelGroup&>(group));
38}
39}
40
41void DoProjectTempoChange(ChannelGroup &group, double newTempo)
42{
43 auto &oldTempo = ProjectTempo::Get(group).mProjectTempo;
44 OnProjectTempoChange::Call(group, oldTempo, newTempo);
45 oldTempo = newTempo;
46}
47
48const std::optional<double>& GetProjectTempo(const ChannelGroup &group)
49{
50 return ProjectTempo::Get(group).mProjectTempo;
51}
52
54 return [](auto&, auto&, auto){ };
55}
Abstract class ChannelGroup with two discrete iterable dimensions, channels and intervals; subclasses...
const std::optional< double > & GetProjectTempo(const ChannelGroup &group)
Definition: TempoChange.cpp:48
void DoProjectTempoChange(ChannelGroup &group, double newTempo)
Definition: TempoChange.cpp:41
DEFINE_ATTACHED_VIRTUAL(OnProjectTempoChange)
Definition: TempoChange.cpp:53
Class template generates single-dispatch, open method registry tables.
static Return Call(This &obj, Arguments ...arguments)
Invoke the method – but only after static initialization time.
Client code makes static instance from a factory of attachments; passes it to Get or Find as a retrie...
Definition: ClientData.h:275
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:202
template struct REGISTRIES_API Cloneable<>
const ChannelGroup::Attachments::RegisteredFactory projectTempoDataFactory
Definition: TempoChange.cpp:27
A convenient base class defining abstract virtual Clone() for a given kind of pointer.
Definition: ClientData.h:50
std::unique_ptr< ClientData::Cloneable<> > Clone() const override
Definition: TempoChange.cpp:17