Audacity 3.2.0
MirFakes.h
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 MirFakes.h
7
8 Matthieu Hodgkinson
9
10**********************************************************************/
11#pragma once
12
13#include "MirProjectInterface.h"
14#include "MirTypes.h"
15
16namespace MIR
17{
18
20{
21 double GetSampleRate() const override
22 {
23 return 0;
24 }
25 long long GetNumSamples() const override
26 {
27 return 0;
28 }
29 void
30 ReadFloats(float* buffer, long long start, size_t numFrames) const override
31 {
32 }
33};
34
36{
37 const int period = 8;
38
39 double GetSampleRate() const override
40 {
41 return 10;
42 }
43 long long GetNumSamples() const override
44 {
45 return period * 10;
46 }
47 void
48 ReadFloats(float* buffer, long long where, size_t numFrames) const override
49 {
50 for (size_t i = 0; i < numFrames; ++i)
51 buffer[i] = (where + i) % period < period / 2 ? 1.f : -1.f;
52 }
53};
54
56{
57public:
59 : projectTempo { tempo }
60 {
61 }
62 ~FakeProjectInterface() override = default;
63
65 bool isBeatsAndMeasures = false;
68
69 bool wasReconfigured = false;
70
71 bool ViewIsBeatsAndMeasures() const override
72 {
73 return isBeatsAndMeasures;
74 }
75
77 double newTempo, std::optional<MIR::TimeSignature> timeSignature) override
78 {
79 projectTempo = newTempo;
80 isBeatsAndMeasures = true;
81 wasReconfigured = true;
82 }
83
84 double GetTempo() const override
85 {
86 return projectTempo;
87 }
88
89 bool ShouldBeReconfigured(double qpm, bool isSingleFileImport) override
90 {
92 }
93
94 void OnClipsSynchronized() override
95 {
97 }
98};
99
101{
102public:
103 struct Params
104 {
105 const double tempo;
107 };
108
109 FakeAnalyzedAudioClip(std::optional<Params> params)
110 : syncInfo { params.has_value() ? std::make_optional<ProjectSyncInfo>(
111 { params->tempo, params->method }) :
112 std::nullopt }
113 {
114 }
115
116 ~FakeAnalyzedAudioClip() override = default;
117
118 const std::optional<MIR::ProjectSyncInfo> syncInfo;
119 std::optional<double> rawAudioTempo;
120 bool synchronizeCalled = false;
121
122 const std::optional<MIR::ProjectSyncInfo>& GetSyncInfo() const override
123 {
124 return syncInfo;
125 }
126
127 void SetRawAudioTempo(double tempo) override
128 {
129 rawAudioTempo = tempo;
130 }
131
132 void Synchronize() override
133 {
134 synchronizeCalled = true;
135 }
136};
137
138} // namespace MIR
EffectDistortionSettings params
long long GetNumSamples() const override
Definition: MirFakes.h:25
double GetSampleRate() const override
Definition: MirFakes.h:21
void ReadFloats(float *buffer, long long start, size_t numFrames) const override
Definition: MirFakes.h:30
const std::optional< MIR::ProjectSyncInfo > & GetSyncInfo() const override
Definition: MirFakes.h:122
std::optional< double > rawAudioTempo
Definition: MirFakes.h:119
FakeAnalyzedAudioClip(std::optional< Params > params)
Definition: MirFakes.h:109
void SetRawAudioTempo(double tempo) override
Definition: MirFakes.h:127
void Synchronize() override
Definition: MirFakes.h:132
const std::optional< MIR::ProjectSyncInfo > syncInfo
Definition: MirFakes.h:118
~FakeAnalyzedAudioClip() override=default
double GetTempo() const override
Definition: MirFakes.h:84
~FakeProjectInterface() override=default
bool ShouldBeReconfigured(double qpm, bool isSingleFileImport) override
Definition: MirFakes.h:89
bool ViewIsBeatsAndMeasures() const override
Definition: MirFakes.h:71
void OnClipsSynchronized() override
Definition: MirFakes.h:94
void ReconfigureMusicGrid(double newTempo, std::optional< MIR::TimeSignature > timeSignature) override
Definition: MirFakes.h:76
FakeProjectInterface(double tempo)
Definition: MirFakes.h:58
double GetSampleRate() const override
Definition: MirFakes.h:39
void ReadFloats(float *buffer, long long where, size_t numFrames) const override
Definition: MirFakes.h:48
long long GetNumSamples() const override
Definition: MirFakes.h:43
TempoObtainedFrom
How the tempo was obtained:
Definition: MirTypes.h:60
STL namespace.
const TempoObtainedFrom method
Definition: MirFakes.h:106