Audacity 3.2.0
MirTypes.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 MirTypes.h
7
8 Matthieu Hodgkinson
9
10**********************************************************************/
11#pragma once
12
13#include <array>
14#include <functional>
15#include <memory>
16#include <optional>
17#include <string>
18#include <unordered_map>
19#include <vector>
20#include "PowerSpectrumGetter.h"
21
22namespace MIR
23{
25{
26 Strict,
27 Lenient,
28};
29
30enum class TimeSignature
31{
32 TwoTwo,
36 _count
37};
38
40{
41 constexpr std::array<int, static_cast<int>(TimeSignature::_count)>
42 numerators = { 2, 4, 3, 6 };
43 return numerators[static_cast<int>(ts)];
44}
45
47{
48 constexpr std::array<int, static_cast<int>(TimeSignature::_count)>
49 denominators = { 2, 4, 4, 8 };
50 return denominators[static_cast<int>(ts)];
51}
52
60{
61 Header,
62 Title,
63 Signal,
64};
65
67{
68 const double bpm;
69 const std::optional<TimeSignature> timeSignature;
70};
71
73{
74 double error = 0.;
75 int lag = 0;
76 int numDivisions = 0;
77};
78
83{
87 const double rawAudioTempo;
88
93
97 const std::optional<TimeSignature> timeSignature;
98
103 const double stretchMinimizingPowOfTwo = 1.;
104
111};
112
114{
115public:
116 virtual double GetSampleRate() const = 0;
117 virtual long long GetNumSamples() const = 0;
118 virtual void
119 ReadFloats(float* buffer, long long where, size_t numFrames) const = 0;
120 double GetDuration() const
121 {
122 return GetSampleRate() == 0 ? 0. : GetNumSamples() / GetSampleRate();
123 }
124 virtual ~MirAudioReader() = default;
125};
126
128{
129public:
130 virtual const std::optional<MIR::ProjectSyncInfo>& GetSyncInfo() const = 0;
131 virtual void SetRawAudioTempo(double tempo) = 0;
132 virtual void Synchronize() = 0;
133 virtual ~AnalyzedAudioClip() = default;
134};
135
137{
139 double bpm = 0;
140 std::optional<TimeSignature> timeSignature;
141 double score = 0.;
142 std::vector<PffftFloatVector> postProcessedStft;
143 std::vector<float> rawOdf;
144 std::vector<float> movingAverage;
145 std::vector<float> odf;
146 double odfSr = 0.;
147 double audioFileDuration = 0.;
148 std::vector<int> odfPeakIndices;
149 std::vector<float> odfAutoCorr;
150 std::vector<int> odfAutoCorrPeakIndices;
151};
152} // namespace MIR
A string pair, representing HTTP header.
virtual const std::optional< MIR::ProjectSyncInfo > & GetSyncInfo() const =0
virtual void Synchronize()=0
virtual void SetRawAudioTempo(double tempo)=0
virtual ~AnalyzedAudioClip()=default
double GetDuration() const
Definition: MirTypes.h:120
virtual void ReadFloats(float *buffer, long long where, size_t numFrames) const =0
virtual long long GetNumSamples() const =0
virtual double GetSampleRate() const =0
virtual ~MirAudioReader()=default
int GetNumerator(TimeSignature ts)
Definition: MirTypes.h:39
TimeSignature
Definition: MirTypes.h:31
int GetDenominator(TimeSignature ts)
Definition: MirTypes.h:46
FalsePositiveTolerance
Definition: MirTypes.h:25
TempoObtainedFrom
How the tempo was obtained:
Definition: MirTypes.h:60
const std::optional< TimeSignature > timeSignature
Definition: MirTypes.h:69
const double bpm
Definition: MirTypes.h:68
const std::optional< TimeSignature > timeSignature
Definition: MirTypes.h:97
const double stretchMinimizingPowOfTwo
Definition: MirTypes.h:103
const double excessDurationInQuarternotes
Definition: MirTypes.h:110
const double rawAudioTempo
Definition: MirTypes.h:87
const TempoObtainedFrom usedMethod
Definition: MirTypes.h:92
std::vector< float > odf
Definition: MirTypes.h:145
OnsetQuantization tatumQuantization
Definition: MirTypes.h:138
std::vector< float > odfAutoCorr
Definition: MirTypes.h:149
std::optional< TimeSignature > timeSignature
Definition: MirTypes.h:140
std::vector< float > rawOdf
Definition: MirTypes.h:143
std::vector< int > odfPeakIndices
Definition: MirTypes.h:148
std::vector< float > movingAverage
Definition: MirTypes.h:144
std::vector< PffftFloatVector > postProcessedStft
Definition: MirTypes.h:142
std::vector< int > odfAutoCorrPeakIndices
Definition: MirTypes.h:150