bpmdetect 0.8.11
Automatic BPM detection tool
Loading...
Searching...
No Matches
track.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
3#pragma once
4
5#include <QtCore/QSpan>
6#include <STTypes.h>
7
9#include "utils.h"
10
11class QAudioDecoder;
12
14class Track : public QObject {
16#ifdef TESTING
17 friend class DlgBpmDetectTest;
18 friend class TrackTest;
19#endif
20
21public:
27
33 Track(const QString &fileName, QAudioDecoder *decoder, QObject *parent = nullptr);
39 Track(const QString &fileName, QObject *parent = nullptr);
40#ifdef TESTING
45 explicit Track(QObject *parent = nullptr);
46#endif
47 ~Track() override;
49 static bpmtype correctBpm(bpmtype dBpm);
54 static void setMinimumBpm(bpmtype dMin);
59 static void setMaximumBpm(bpmtype dMax);
61 static bpmtype minimumBpm();
63 static bpmtype maximumBpm();
65 void clearBpm();
69 void saveBpm();
71 void printBpm() const;
73 void setBpm(bpmtype dBpm);
75 bpmtype bpm() const;
77 QString formatted() const;
79 QString formatted(const QString &format) const;
81 QString fileName() const;
83 qlonglong length() const;
87 bool isValid() const;
89 QString artist() const;
91 QString title() const;
93 void setFormat(const QString &format = QStringLiteral("0.00"));
95 QString format() const;
97 void stop();
99 void readTags();
101 void setDetector(AbstractBpmDetector *detector);
103 bool hasValidBpm() const;
105 bool hasSavedBpm() const;
107 QString hostFileName() const;
108
122 void finished();
123
124protected:
126 void storeBpm(const QString &sBpm);
128 void removeBpm();
129
130private:
131 void setupDecoder();
132
133 AbstractBpmDetector *detector_ = nullptr;
134 QAudioDecoder *decoder_ = nullptr;
135 QString artist_;
136 QString bpmFormat_ = QStringLiteral("0.00");
137 QString fileName_;
138 QString title_;
139 bool hasSavedBpm_ = false;
140 bool isValidFile_ = false;
141 bool opened_ = false;
142 bool stopped_ = false;
143 bpmtype dBpm_ = 0;
144 qlonglong length_ = 0;
145
146 static bpmtype _dMaxBpm;
147 static bpmtype _dMinBpm;
148};
Definition abstractbpmdetector.h:8
Definition track.h:14
QString hostFileName() const
Definition track.cpp:153
void setDetector(AbstractBpmDetector *detector)
Definition track.cpp:221
bool isValid() const
Definition track.cpp:175
void setFormat(const QString &format=QStringLiteral("0.00"))
Definition track.cpp:179
QString formattedLength() const
Definition track.cpp:195
static void setMaximumBpm(bpmtype dMax)
Definition track.cpp:112
QString formatted() const
Definition track.cpp:130
void clearBpm()
Definition track.cpp:216
DetectionState
Definition track.h:23
@ Detecting
Currently detecting BPM.
Definition track.h:24
@ Error
Error occurred.
Definition track.h:25
void hasBpm(bpmtype bpm)
void printBpm() const
Definition track.cpp:240
qlonglong length() const
Definition track.cpp:283
void stop()
Definition track.cpp:272
QString fileName() const
Definition track.cpp:149
Track(const QString &fileName, QAudioDecoder *decoder, QObject *parent=nullptr)
Definition track.cpp:25
void readTags()
Definition track.cpp:138
QString artist() const
Definition track.cpp:204
void saveBpm()
Definition track.cpp:212
static bpmtype maximumBpm()
Definition track.cpp:126
void setBpm(bpmtype dBpm)
Definition track.cpp:187
void removeBpm()
Definition track.cpp:268
static bpmtype correctBpm(bpmtype dBpm)
Definition track.cpp:225
bool hasValidBpm() const
Definition track.cpp:279
bool hasSavedBpm() const
Definition track.cpp:264
void finished()
QString format() const
Definition track.cpp:183
static bpmtype minimumBpm()
Definition track.cpp:122
void storeBpm(const QString &sBpm)
Definition track.cpp:260
QString title() const
Definition track.cpp:208
DetectionState detectBpm()
Definition track.cpp:245
void progress(qint64 pos, qint64 length)
bpmtype bpm() const
Definition track.cpp:191
static void setMinimumBpm(bpmtype dMin)
Definition track.cpp:102
QObject(QObject *parent)
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
QObject * parent() const const
long long qint64
double bpmtype
Definition utils.h:24