Skip to content
Extraits de code Groupes Projets
Valider 30a0caf2 rédigé par Elliu's avatar Elliu
Parcourir les fichiers

Use quint64 for audioLength, in milliseconds

parent b58c9f59
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!14Draft: improve the audio vizualiser
Ce commit fait partie de la requête de fusion !14. Les commentaires créés ici seront créés dans le contexte de cette requête de fusion.
...@@ -296,11 +296,11 @@ AudioContext::Stream::getBitRate() const noexcept ...@@ -296,11 +296,11 @@ AudioContext::Stream::getBitRate() const noexcept
return codecContext->bit_rate; return codecContext->bit_rate;
} }
qreal quint64
AudioContext::Stream::getLength() const noexcept AudioContext::Stream::getLength() const noexcept
{ {
// The whole file duration, not individual streams. // The whole file duration, not individual streams.
return qreal(std::chrono::duration<qreal,std::ratio<1,1>>(std::chrono::microseconds(dataFormat->duration)).count()); return quint64(std::chrono::duration<qreal,std::ratio<1,1000>>(std::chrono::microseconds(dataFormat->duration)).count());
} }
// Get the information about the decoded state of this stream // Get the information about the decoded state of this stream
......
...@@ -88,7 +88,7 @@ public: ...@@ -88,7 +88,7 @@ public:
qint64 getBitRate() const noexcept; qint64 getBitRate() const noexcept;
// Get audio context length, if a stream is translated putting the length // Get audio context length, if a stream is translated putting the length
// on the `Stream` can pose some problems. // on the `Stream` can pose some problems.
qreal getLength() const noexcept; quint64 getLength() const noexcept;
// Get the index from the audio context // Get the index from the audio context
int getStreamIndex() const noexcept; int getStreamIndex() const noexcept;
......
...@@ -74,7 +74,7 @@ AudioVisualizer::AudioVisualizer(AudioContext::StreamPtr stream, QWidget *parent ...@@ -74,7 +74,7 @@ AudioVisualizer::AudioVisualizer(AudioContext::StreamPtr stream, QWidget *parent
} }
void void
AudioVisualizer::printSpectrum(QImage pixmap, qreal audioLength) noexcept AudioVisualizer::printSpectrum(QImage pixmap, quint64 audioLength) noexcept
{ {
TimingView *timer = new TimingView(pixmap, audioLength, this); TimingView *timer = new TimingView(pixmap, audioLength, this);
QHBoxLayout *layout = new QHBoxLayout; QHBoxLayout *layout = new QHBoxLayout;
......
...@@ -37,7 +37,7 @@ public: ...@@ -37,7 +37,7 @@ public:
~AudioVisualizer() noexcept = default; ~AudioVisualizer() noexcept = default;
public slots: public slots:
void printSpectrum(QImage, qreal) noexcept; void printSpectrum(QImage, quint64) noexcept;
}; };
} }
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
using namespace Vivy; using namespace Vivy;
TimingAxis::TimingAxis(qreal audioLength_, int x0_, int x1_, int y_) noexcept TimingAxis::TimingAxis(quint64 audioLength_, int x0_, int x1_, int y_) noexcept
: QGraphicsObject(), : QGraphicsObject(),
audioLength(audioLength_), audioLength(audioLength_),
x0(x0_), x0(x0_),
...@@ -36,7 +36,7 @@ void TimingAxis::refreshTicks() { ...@@ -36,7 +36,7 @@ void TimingAxis::refreshTicks() {
QGraphicsScene *parentScene = scene(); QGraphicsScene *parentScene = scene();
if (parentScene != nullptr){ if (parentScene != nullptr){
for (minorTicksIndex = 0; minorTicksIndex < nbAvailableTicks; minorTicksIndex++){ for (minorTicksIndex = 0; minorTicksIndex < nbAvailableTicks; minorTicksIndex++){
if (parentScene->width() / (audioLength * availableTicks[minorTicksIndex]) < minBetweenMinor){ if (parentScene->width() / (qreal(audioLength) * availableTicks[minorTicksIndex]) < minBetweenMinor){
minorTicksIndex = minorTicksIndex == 0 ? 0 : minorTicksIndex - 1; minorTicksIndex = minorTicksIndex == 0 ? 0 : minorTicksIndex - 1;
break; break;
} }
......
...@@ -16,7 +16,7 @@ class TimingAxis final : public QGraphicsObject { ...@@ -16,7 +16,7 @@ class TimingAxis final : public QGraphicsObject {
Q_OBJECT Q_OBJECT
public: public:
explicit TimingAxis(qreal audioLength, int x0, int x1, int y) noexcept; explicit TimingAxis(quint64 audioLength, int x0, int x1, int y) noexcept;
~TimingAxis() noexcept = default; ~TimingAxis() noexcept = default;
QRectF boundingRect() const override; QRectF boundingRect() const override;
...@@ -25,13 +25,13 @@ public: ...@@ -25,13 +25,13 @@ public:
private: private:
static inline constexpr QColor axisColour = QColor(0, 0, 127); static inline constexpr QColor axisColour = QColor(0, 0, 127);
QVector<qreal> availableTicks = { 0.01, 0.1, 1, 10, 60, 3600, 86400 }; QVector<qreal> availableTicks = { 10, 100, 1000, 10000, 60000, 3600000, 86400000 };
qreal minBetweenMinor{ 5 }; qreal minBetweenMinor{ 5 };
qreal minorTicks; qreal minorTicks;
qreal majorTicks; qreal majorTicks;
qreal penWidth{ 1 }; qreal penWidth{ 1 };
qreal audioLength{ 0 }; quint64 audioLength{ 0 };
int x0{ 0 }; int x0{ 0 };
int x1{ 0 }; int x1{ 0 };
int y { 0 }; int y { 0 };
......
...@@ -20,7 +20,7 @@ TimingScene::TimingScene(QWidget *parent) noexcept ...@@ -20,7 +20,7 @@ TimingScene::TimingScene(QWidget *parent) noexcept
{ {
} }
TimingScene::TimingScene(QImage img_, qreal soundLength_, QWidget *parent) noexcept TimingScene::TimingScene(QImage img_, quint64 soundLength_, QWidget *parent) noexcept
: QGraphicsScene(parent) : QGraphicsScene(parent)
, img(img_) , img(img_)
, soundLength(soundLength_) , soundLength(soundLength_)
...@@ -74,7 +74,7 @@ TimingScene::timeFromPos(qreal x) ...@@ -74,7 +74,7 @@ TimingScene::timeFromPos(qreal x)
qCritical() << "Try avoid possible divide by zero in the time from position"; qCritical() << "Try avoid possible divide by zero in the time from position";
return 0; return 0;
} else { } else {
return x * soundLength / w; return x * qreal(soundLength) / w;
} }
} }
......
...@@ -27,13 +27,13 @@ public: ...@@ -27,13 +27,13 @@ public:
static inline constexpr QColor endColour = QColor(0, 127, 0); static inline constexpr QColor endColour = QColor(0, 127, 0);
explicit TimingScene(QWidget *parent = nullptr) noexcept; explicit TimingScene(QWidget *parent = nullptr) noexcept;
explicit TimingScene(QImage, qreal, QWidget * = nullptr) noexcept; explicit TimingScene(QImage, quint64, QWidget * = nullptr) noexcept;
~TimingScene() noexcept = default; ~TimingScene() noexcept = default;
private: private:
QGraphicsPixmapItem *backgroundImg{ nullptr }; QGraphicsPixmapItem *backgroundImg{ nullptr };
QImage img; QImage img;
qreal soundLength{ 0 }; quint64 soundLength{ 0 };
Ass::LineWeakPtr currentLine{}; Ass::LineWeakPtr currentLine{};
TimingMode timingMode{ TimingMode::Line }; TimingMode timingMode{ TimingMode::Line };
TimingAxis* ax; TimingAxis* ax;
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
using namespace Vivy; using namespace Vivy;
TimingView::TimingView(QImage img, qreal soundLength, QWidget *parent) noexcept TimingView::TimingView(QImage img, quint64 soundLength, QWidget *parent) noexcept
: QGraphicsView(parent) : QGraphicsView(parent)
{ {
currentScene = new TimingScene(img, soundLength, this); currentScene = new TimingScene(img, soundLength, this);
......
...@@ -26,7 +26,7 @@ public: ...@@ -26,7 +26,7 @@ public:
static inline constexpr QColor startColour = QColor(127, 0, 127); static inline constexpr QColor startColour = QColor(127, 0, 127);
static inline constexpr QColor endColour = QColor(0, 127, 0); static inline constexpr QColor endColour = QColor(0, 127, 0);
explicit TimingView(QImage, qreal, QWidget * = nullptr) noexcept; explicit TimingView(QImage, quint64, QWidget * = nullptr) noexcept;
~TimingView() noexcept = default; ~TimingView() noexcept = default;
TimingScene* getTimingScene() const; TimingScene* getTimingScene() const;
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter