Gary Wang
cf90e2d70c
The final goal is actually still clone ShadowPlayer's spectrum visualization, tho.
32 lines
700 B
C++
32 lines
700 B
C++
// SPDX-FileCopyrightText: 2024 Gary Wang <git@blumia.net>
|
|
//
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
#pragma once
|
|
|
|
#include <QWidget>
|
|
#include <QMediaPlayer>
|
|
|
|
class QAudioBufferOutput;
|
|
class FFTSpectrum : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
Q_PROPERTY(QMediaPlayer * mediaPlayer MEMBER m_mediaPlayer WRITE setMediaPlayer NOTIFY mediaPlayerChanged)
|
|
public:
|
|
explicit FFTSpectrum(QWidget* parent);
|
|
~FFTSpectrum();
|
|
|
|
void setMediaPlayer(QMediaPlayer* player);
|
|
|
|
signals:
|
|
void mediaPlayerChanged();
|
|
|
|
protected:
|
|
void paintEvent(QPaintEvent* e) override;
|
|
|
|
private:
|
|
QMediaPlayer* m_mediaPlayer = nullptr;
|
|
QAudioBufferOutput* m_audioBufferOutput = nullptr;
|
|
std::vector<float> m_freq;
|
|
};
|