yyc12345
This commit is contained in:
parent
044bb34390
commit
f0c07f0b30
7
.editorconfig
Normal file
7
.editorconfig
Normal file
|
@ -0,0 +1,7 @@
|
|||
[*]
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
indent_style = space
|
||||
indent_size = 4
|
|
@ -20,6 +20,12 @@ find_package(Qt6 6.6 COMPONENTS Widgets Multimedia Network LinguistTools REQUIRE
|
|||
find_package(KF6Codecs 6.1.0)
|
||||
find_package(PkgConfig)
|
||||
|
||||
option(KISSFFT_PKGCONFIG OFF)
|
||||
option(KISSFFT_STATIC ON)
|
||||
option(KISSFFT_TEST OFF)
|
||||
option(KISSFFT_TOOLS OFF)
|
||||
add_subdirectory(kissfft EXCLUDE_FROM_ALL)
|
||||
|
||||
if (USE_QTEXTCODEC)
|
||||
find_package(Qt6 6.6 COMPONENTS Core5Compat REQUIRED)
|
||||
endif()
|
||||
|
@ -84,7 +90,7 @@ if (TARGET KF6::Codecs)
|
|||
target_link_libraries (${EXE_NAME} PRIVATE KF6::Codecs)
|
||||
endif ()
|
||||
|
||||
target_link_libraries(${EXE_NAME} PRIVATE Qt::Widgets Qt::Multimedia Qt::Network)
|
||||
target_link_libraries(${EXE_NAME} PRIVATE Qt::Widgets Qt::Multimedia Qt::Network kissfft::kissfft)
|
||||
|
||||
if (USE_QTEXTCODEC)
|
||||
target_compile_definitions(${EXE_NAME} PRIVATE USE_QTEXTCODEC=1)
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#include <QMediaPlayer>
|
||||
#include <QMediaMetaData>
|
||||
#include <QAudioOutput>
|
||||
#include <QAudioBuffer>
|
||||
#include <QAudioBufferOutput>
|
||||
#include <QPropertyAnimation>
|
||||
#include <QFileDialog>
|
||||
#include <QTime>
|
||||
|
@ -32,6 +34,8 @@
|
|||
#include <QMessageBox>
|
||||
#include <QStringBuilder>
|
||||
|
||||
#include <kissfft.hh>
|
||||
|
||||
constexpr QSize miniSize(490, 160);
|
||||
constexpr QSize fullSize(490, 420);
|
||||
|
||||
|
@ -41,14 +45,16 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
, m_mediaDevices(new QMediaDevices(this))
|
||||
, m_mediaPlayer(new QMediaPlayer(this))
|
||||
, m_audioOutput(new QAudioOutput(this))
|
||||
, m_audioBufferOutput(new QAudioBufferOutput(this))
|
||||
, m_lrcbar(new LrcBar(nullptr))
|
||||
, m_playlistManager(new PlaylistManager(this))
|
||||
{
|
||||
ui->setupUi(this);
|
||||
m_playlistManager->setAutoLoadFilterSuffixes({
|
||||
"*.mp3", "*.wav", "*.aiff", "*.ape", "*.flac", "*.ogg", "*.oga", "*.mpga", "*.aac"
|
||||
"*.mp3", "*.wav", "*.aiff", "*.ape", "*.flac", "*.ogg", "*.oga", "*.mpga", "*.aac", "*.tta"
|
||||
});
|
||||
m_mediaPlayer->setAudioOutput(m_audioOutput);
|
||||
m_mediaPlayer->setAudioBufferOutput(m_audioBufferOutput);
|
||||
m_mediaPlayer->setLoops(QMediaPlayer::Infinite);
|
||||
ui->playlistView->setModel(m_playlistManager->model());
|
||||
|
||||
|
@ -400,6 +406,19 @@ void MainWindow::initConnections()
|
|||
m_audioOutput->setDevice(m_mediaDevices->defaultAudioOutput());
|
||||
});
|
||||
|
||||
connect(m_audioBufferOutput, &QAudioBufferOutput::audioBufferReceived, this, [=](const QAudioBuffer& buffer) {
|
||||
const QAudioFormat&& fmt = buffer.format();
|
||||
QAudioFormat::SampleFormat sampleFormat = fmt.sampleFormat();
|
||||
int channelCount = fmt.channelCount();
|
||||
if (sampleFormat == QAudioFormat::Int16 && channelCount == 2) {
|
||||
const QAudioBuffer::S16S * data = buffer.constData<QAudioBuffer::S16S>();
|
||||
for (int i = 0; i < buffer.sampleCount(); ++i) {
|
||||
// ...?
|
||||
}
|
||||
}
|
||||
// TODO: draw spectrum
|
||||
});
|
||||
|
||||
connect(m_mediaPlayer, &QMediaPlayer::sourceChanged, this, [=](){
|
||||
QUrl fileUrl(m_mediaPlayer->source());
|
||||
|
||||
|
@ -438,6 +457,7 @@ void MainWindow::initConnections()
|
|||
setAudioMetadataForDisplay(metadata.stringValue(QMediaMetaData::Title),
|
||||
metadata.stringValue(QMediaMetaData::Author),
|
||||
metadata.stringValue(QMediaMetaData::AlbumTitle));
|
||||
setAudioPropertyInfoForDisplay(-1, metadata.value(QMediaMetaData::AudioBitRate).toInt() / 1000, -1, metadata.stringValue(QMediaMetaData::FileFormat));
|
||||
#endif // NO_TAGLIB
|
||||
QVariant coverArt(metadata.value(QMediaMetaData::ThumbnailImage));
|
||||
if (!coverArt.isNull()) {
|
||||
|
|
|
@ -14,6 +14,7 @@ namespace Ui { class MainWindow; }
|
|||
class QMediaDevices;
|
||||
class QMediaPlayer;
|
||||
class QAudioOutput;
|
||||
class QAudioBufferOutput;
|
||||
class QPropertyAnimation;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
@ -92,6 +93,7 @@ private:
|
|||
QMediaDevices *m_mediaDevices;
|
||||
QMediaPlayer *m_mediaPlayer;
|
||||
QAudioOutput *m_audioOutput;
|
||||
QAudioBufferOutput *m_audioBufferOutput;
|
||||
LrcBar *m_lrcbar;
|
||||
QPropertyAnimation *m_fadeOutAnimation;
|
||||
PlaylistManager *m_playlistManager;
|
||||
|
|
Loading…
Reference in New Issue
Block a user