Compare commits
3 Commits
01812e6bf9
...
120d7c1d25
Author | SHA1 | Date | |
---|---|---|---|
120d7c1d25 | |||
64c75263bf | |||
5092f9bafc |
|
@ -1,7 +1,7 @@
|
||||||
[*]
|
[*]
|
||||||
end_of_line = lf
|
end_of_line = lf
|
||||||
charset = utf-8
|
charset = utf-8
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = true
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
indent_style = space
|
indent_style = space
|
||||||
indent_size = 4
|
indent_size = 4
|
||||||
|
|
3
.github/workflows/windows.yml
vendored
3
.github/workflows/windows.yml
vendored
|
@ -45,9 +45,6 @@ jobs:
|
||||||
git clone -q https://invent.kde.org/frameworks/kcodecs.git dependencies_src/kcodecs
|
git clone -q https://invent.kde.org/frameworks/kcodecs.git dependencies_src/kcodecs
|
||||||
cmake .\dependencies_src\kcodecs -Bbuild_dependencies/kcodecs -DCMAKE_INSTALL_PREFIX="dependencies_bin" -DBUILD_TESTING=OFF || goto :error
|
cmake .\dependencies_src\kcodecs -Bbuild_dependencies/kcodecs -DCMAKE_INSTALL_PREFIX="dependencies_bin" -DBUILD_TESTING=OFF || goto :error
|
||||||
cmake --build build_dependencies/kcodecs --config Release --target=install || goto :error
|
cmake --build build_dependencies/kcodecs --config Release --target=install || goto :error
|
||||||
:: ===== pkg-config =====
|
|
||||||
choco install pkgconfiglite
|
|
||||||
set PKG_CONFIG_PATH=%PWD%/dependencies_bin/lib/pkgconfig
|
|
||||||
:: ===== taglib =====
|
:: ===== taglib =====
|
||||||
git clone --recurse-submodules -q https://github.com/taglib/taglib.git dependencies_src/taglib
|
git clone --recurse-submodules -q https://github.com/taglib/taglib.git dependencies_src/taglib
|
||||||
cmake .\dependencies_src\taglib -Bbuild_dependencies/taglib -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX="dependencies_bin" || goto :error
|
cmake .\dependencies_src\taglib -Bbuild_dependencies/taglib -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX="dependencies_bin" || goto :error
|
||||||
|
|
|
@ -3,7 +3,8 @@ cmake_minimum_required(VERSION 3.12)
|
||||||
project(pineapple-music LANGUAGES CXX)
|
project(pineapple-music LANGUAGES CXX)
|
||||||
|
|
||||||
include (GNUInstallDirs)
|
include (GNUInstallDirs)
|
||||||
include (FeatureSummary)
|
include (FeatureSummary)
|
||||||
|
include(FetchContent)
|
||||||
|
|
||||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
|
|
||||||
|
@ -17,23 +18,24 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
option(USE_QTEXTCODEC "Use QTextCodec instead of QStringConverter, in case Qt is not built with ICU" OFF)
|
option(USE_QTEXTCODEC "Use QTextCodec instead of QStringConverter, in case Qt is not built with ICU" OFF)
|
||||||
|
|
||||||
find_package(Qt6 6.6 COMPONENTS Widgets Multimedia Network LinguistTools REQUIRED)
|
find_package(Qt6 6.6 COMPONENTS Widgets Multimedia Network LinguistTools REQUIRED)
|
||||||
find_package(KF6Codecs 6.1.0)
|
find_package(TagLib 2.0.0)
|
||||||
find_package(PkgConfig)
|
find_package(KF6Codecs 6.1.0)
|
||||||
|
|
||||||
option(KISSFFT_PKGCONFIG OFF)
|
FetchContent_Declare(
|
||||||
option(KISSFFT_STATIC ON)
|
kissfft
|
||||||
option(KISSFFT_TEST OFF)
|
GIT_REPOSITORY https://github.com/mborgerding/kissfft.git
|
||||||
option(KISSFFT_TOOLS OFF)
|
GIT_TAG f5f2a3b2f2cd02bf80639adb12cbeed125bdf420
|
||||||
add_subdirectory(kissfft EXCLUDE_FROM_ALL)
|
)
|
||||||
|
set(KISSFFT_PKGCONFIG OFF CACHE BOOL "dep(kissfft): pkgconfig support")
|
||||||
|
set(KISSFFT_STATIC ON CACHE BOOL "dep(kissfft): static linking")
|
||||||
|
set(KISSFFT_TEST OFF CACHE BOOL "dep(kissfft): enable testing")
|
||||||
|
set(KISSFFT_TOOLS OFF CACHE BOOL "dep(kissfft): build tools")
|
||||||
|
FetchContent_MakeAvailable(kissfft)
|
||||||
|
|
||||||
if (USE_QTEXTCODEC)
|
if (USE_QTEXTCODEC)
|
||||||
find_package(Qt6 6.6 COMPONENTS Core5Compat REQUIRED)
|
find_package(Qt6 6.6 COMPONENTS Core5Compat REQUIRED)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (PKG_CONFIG_FOUND)
|
|
||||||
pkg_check_modules(TagLib taglib IMPORTED_TARGET)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
set (PMUSIC_CPP_FILES
|
set (PMUSIC_CPP_FILES
|
||||||
main.cpp
|
main.cpp
|
||||||
mainwindow.cpp
|
mainwindow.cpp
|
||||||
|
@ -84,7 +86,7 @@ endif ()
|
||||||
if (NOT TagLib_FOUND)
|
if (NOT TagLib_FOUND)
|
||||||
target_compile_definitions(${EXE_NAME} PRIVATE NO_TAGLIB=1)
|
target_compile_definitions(${EXE_NAME} PRIVATE NO_TAGLIB=1)
|
||||||
else ()
|
else ()
|
||||||
target_link_libraries(${EXE_NAME} PRIVATE PkgConfig::TagLib)
|
target_link_libraries(${EXE_NAME} PRIVATE TagLib::tag)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (TARGET KF6::Codecs)
|
if (TARGET KF6::Codecs)
|
||||||
|
|
15
README.md
15
README.md
|
@ -2,12 +2,23 @@
|
||||||
|
|
||||||
Since **I** just need a simple player which *just works* right now, so I did many things in a dirty way. Don't feel so weird if you saw something I did in this project is using a bad approach.
|
Since **I** just need a simple player which *just works* right now, so I did many things in a dirty way. Don't feel so weird if you saw something I did in this project is using a bad approach.
|
||||||
|
|
||||||
### Feature Notice
|
### Features
|
||||||
|
|
||||||
|
We have the following features:
|
||||||
|
|
||||||
|
- [Sidecar](https://en.wikipedia.org/wiki/Sidecar_file) lyrics file (`.lrc`) support with an optional desktop lyrics bar widget
|
||||||
|
- Auto-load all audio files in the same folder of the file that you attempted to play, into a playlist
|
||||||
|
|
||||||
|
But these features are not available, some of them are TBD and others are not planned:
|
||||||
|
|
||||||
- File format support will be limited by the [FFmpeg version that Qt 6 uses](https://doc.qt.io/qt-6/qtmultimedia-attribution-ffmpeg.html).
|
- File format support will be limited by the [FFmpeg version that Qt 6 uses](https://doc.qt.io/qt-6/qtmultimedia-attribution-ffmpeg.html).
|
||||||
- ...which if you use Qt's official binary, only contains the LGPLv2.1+ part. (already good enough, tho)
|
- ...which if you use Qt's official binary, only contains the LGPLv2.1+ part. (already good enough, tho)
|
||||||
- No music library management support and there won't be one!
|
- No music library management support and there won't be one!
|
||||||
- It'll auto-load music files in the same folder of the file that you attempted to play, so organize your music files on a folder-basis.
|
- It'll auto-load music files in the same folder of the file that you attempted to play, so organize your music files on a folder-basis.
|
||||||
|
- Limited system integration:
|
||||||
|
- No [SMTC](https://learn.microsoft.com/en-us/uwp/api/windows.media.systemmediatransportcontrols) support under Windows for now
|
||||||
|
- No [MPRIS](https://www.freedesktop.org/wiki/Specifications/mpris-spec/) support under Linux desktop for now
|
||||||
|
- No "playback progress on taskbar icon" and "taskbar thumbnail buttons" support whatever on Windows or Linux desktop for now
|
||||||
- Limited lyrics (`.lrc`) loading support:
|
- Limited lyrics (`.lrc`) loading support:
|
||||||
- Currently no `.tlrc` (for translated lyrics) or `.rlrc` (for romanized lyrics) support.
|
- Currently no `.tlrc` (for translated lyrics) or `.rlrc` (for romanized lyrics) support.
|
||||||
- Multi-line lyrics and duplicated timestamps are not supported
|
- Multi-line lyrics and duplicated timestamps are not supported
|
||||||
|
@ -20,7 +31,7 @@ Current state, we need:
|
||||||
- `cmake` as the build system.
|
- `cmake` as the build system.
|
||||||
- `qt6` with `qt6-multimedia` since we use it for playback.
|
- `qt6` with `qt6-multimedia` since we use it for playback.
|
||||||
- `taglib` to get the audio file properties.
|
- `taglib` to get the audio file properties.
|
||||||
- `pkg-config` to find the installed taglib.
|
- `kissfft` for FFT support (will be downloaded at configure-time by `cmake`).
|
||||||
|
|
||||||
Then we can build it with any proper c++ compiler like g++ or msvc.
|
Then we can build it with any proper c++ compiler like g++ or msvc.
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ image:
|
||||||
environment:
|
environment:
|
||||||
CMAKE_INSTALL_ROOT: C:\projects\cmake
|
CMAKE_INSTALL_ROOT: C:\projects\cmake
|
||||||
PACKAGE_INSTALL_ROOT: C:\projects\pir
|
PACKAGE_INSTALL_ROOT: C:\projects\pir
|
||||||
PKG_CONFIG_PATH: C:\projects\pir\lib\pkgconfig
|
|
||||||
matrix:
|
matrix:
|
||||||
- build_name: mingw1120_64_qt6_7
|
- build_name: mingw1120_64_qt6_7
|
||||||
QTPATH: C:\Qt\6.7\mingw_64
|
QTPATH: C:\Qt\6.7\mingw_64
|
||||||
|
@ -23,7 +22,6 @@ build_script:
|
||||||
- mkdir 3rdparty
|
- mkdir 3rdparty
|
||||||
- choco install ninja
|
- choco install ninja
|
||||||
- choco install gperf
|
- choco install gperf
|
||||||
- choco install pkgconfiglite
|
|
||||||
- cd 3rdparty
|
- cd 3rdparty
|
||||||
# install ECM
|
# install ECM
|
||||||
- git clone -q https://invent.kde.org/frameworks/extra-cmake-modules.git
|
- git clone -q https://invent.kde.org/frameworks/extra-cmake-modules.git
|
||||||
|
|
|
@ -5,15 +5,20 @@
|
||||||
#include "fftspectrum.h"
|
#include "fftspectrum.h"
|
||||||
|
|
||||||
#include <QAudioBuffer>
|
#include <QAudioBuffer>
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
|
||||||
#include <QAudioBufferOutput>
|
#include <QAudioBufferOutput>
|
||||||
|
#endif // QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
#include <kissfft.hh>
|
#include <kissfft.hh>
|
||||||
|
|
||||||
FFTSpectrum::FFTSpectrum(QWidget* parent)
|
FFTSpectrum::FFTSpectrum(QWidget* parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
|
||||||
, m_audioBufferOutput(new QAudioBufferOutput(this))
|
, m_audioBufferOutput(new QAudioBufferOutput(this))
|
||||||
|
#endif // #if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
|
||||||
{
|
{
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
|
||||||
connect(this, &FFTSpectrum::mediaPlayerChanged, this, [=]() {
|
connect(this, &FFTSpectrum::mediaPlayerChanged, this, [=]() {
|
||||||
if (m_mediaPlayer) {
|
if (m_mediaPlayer) {
|
||||||
m_mediaPlayer->setAudioBufferOutput(m_audioBufferOutput);
|
m_mediaPlayer->setAudioBufferOutput(m_audioBufferOutput);
|
||||||
|
@ -21,25 +26,59 @@ FFTSpectrum::FFTSpectrum(QWidget* parent)
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(m_audioBufferOutput, &QAudioBufferOutput::audioBufferReceived, this, [=](const QAudioBuffer& buffer) {
|
connect(m_audioBufferOutput, &QAudioBufferOutput::audioBufferReceived, this, [=](const QAudioBuffer& buffer) {
|
||||||
const QAudioFormat&& fmt = buffer.format();
|
const QAudioFormat& fmt = buffer.format();
|
||||||
const QAudioFormat::SampleFormat sampleFormat = fmt.sampleFormat();
|
const QAudioFormat::SampleFormat sampleFormat = fmt.sampleFormat();
|
||||||
int channelCount = fmt.channelCount();
|
QAudioFormat::ChannelConfig channelConfig = fmt.channelConfig();
|
||||||
|
const QFlags supportedChannelConfig({ QAudioFormat::ChannelConfigMono, QAudioFormat::ChannelConfigStereo });
|
||||||
const int frameCount = buffer.frameCount();
|
const int frameCount = buffer.frameCount();
|
||||||
kissfft<float> fft(frameCount, false);
|
kissfft<float> fft(frameCount, false);
|
||||||
std::vector<kissfft<float>::cpx_t> samples(frameCount);
|
std::vector<kissfft<float>::cpx_t> samples(frameCount);
|
||||||
std::vector<kissfft<float>::cpx_t> mass(frameCount);
|
std::vector<kissfft<float>::cpx_t> mass(frameCount);
|
||||||
if (sampleFormat == QAudioFormat::Int16 && channelCount == 1) {
|
if (sampleFormat == QAudioFormat::Int16 && supportedChannelConfig.testFlag(channelConfig)) {
|
||||||
const QAudioBuffer::S16M* data = buffer.constData<QAudioBuffer::S16M>();
|
if (channelConfig == QAudioFormat::ChannelConfigMono) {
|
||||||
for (int i = 0; i < frameCount; ++i) {
|
const QAudioBuffer::S16M* data = buffer.constData<QAudioBuffer::S16M>();
|
||||||
samples[i].real(data[i].value(QAudioFormat::FrontCenter) / float(32768));
|
for (int i = 0; i < frameCount; ++i) {
|
||||||
samples[i].imag(0);
|
samples[i].real(data[i].value(QAudioFormat::FrontCenter) / float(32768));
|
||||||
|
samples[i].imag(0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const QAudioBuffer::S16S* data = buffer.constData<QAudioBuffer::S16S>();
|
||||||
|
for (int i = 0; i < frameCount; ++i) {
|
||||||
|
samples[i].real(data[i].value(QAudioFormat::FrontLeft) / float(32768));
|
||||||
|
samples[i].imag(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (sampleFormat == QAudioFormat::Float && channelCount == 2) {
|
} else if (sampleFormat == QAudioFormat::Int32 && supportedChannelConfig.testFlag(channelConfig)) {
|
||||||
const QAudioBuffer::F32S* data = buffer.constData<QAudioBuffer::F32S>();
|
if (channelConfig == QAudioFormat::ChannelConfigMono) {
|
||||||
for (int i = 0; i < frameCount; ++i) {
|
const QAudioBuffer::S32M* data = buffer.constData<QAudioBuffer::S32M>();
|
||||||
samples[i].real(data[i].value(QAudioFormat::FrontLeft));
|
for (int i = 0; i < frameCount; ++i) {
|
||||||
samples[i].imag(0);
|
samples[i].real(data[i].value(QAudioFormat::FrontCenter) / float(2147483647));
|
||||||
|
samples[i].imag(0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const QAudioBuffer::S32S* data = buffer.constData<QAudioBuffer::S32S>();
|
||||||
|
for (int i = 0; i < frameCount; ++i) {
|
||||||
|
samples[i].real(data[i].value(QAudioFormat::FrontLeft) / float(2147483647));
|
||||||
|
samples[i].imag(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else if (sampleFormat == QAudioFormat::Float && supportedChannelConfig.testFlag(channelConfig)) {
|
||||||
|
if (channelConfig == QAudioFormat::ChannelConfigMono) {
|
||||||
|
const QAudioBuffer::F32M* data = buffer.constData<QAudioBuffer::F32M>();
|
||||||
|
for (int i = 0; i < frameCount; ++i) {
|
||||||
|
samples[i].real(data[i].value(QAudioFormat::FrontCenter));
|
||||||
|
samples[i].imag(0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const QAudioBuffer::F32S* data = buffer.constData<QAudioBuffer::F32S>();
|
||||||
|
for (int i = 0; i < frameCount; ++i) {
|
||||||
|
samples[i].real(data[i].value(QAudioFormat::FrontLeft));
|
||||||
|
samples[i].imag(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
qWarning() << "Unsupported format or channel config:" << sampleFormat << channelConfig;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
fft.transform(samples.data(), mass.data());
|
fft.transform(samples.data(), mass.data());
|
||||||
m_freq.resize(frameCount);
|
m_freq.resize(frameCount);
|
||||||
|
@ -49,11 +88,10 @@ FFTSpectrum::FFTSpectrum(QWidget* parent)
|
||||||
for (auto& val : m_freq) {
|
for (auto& val : m_freq) {
|
||||||
val = log10(val + 1);
|
val = log10(val + 1);
|
||||||
}
|
}
|
||||||
qDebug() << m_freq.size() << "updated";
|
qDebug() << m_freq.size() << "updated" << sampleFormat << channelConfig;
|
||||||
update();
|
update();
|
||||||
qDebug() << sampleFormat << channelCount;
|
|
||||||
});
|
});
|
||||||
|
#endif // QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
|
||||||
resize(490, 420);
|
resize(490, 420);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,17 +109,14 @@ void FFTSpectrum::setMediaPlayer(QMediaPlayer* player)
|
||||||
void FFTSpectrum::paintEvent(QPaintEvent* e)
|
void FFTSpectrum::paintEvent(QPaintEvent* e)
|
||||||
{
|
{
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
painter.fillRect(rect(), Qt::black);
|
|
||||||
|
|
||||||
if (!m_freq.empty()) {
|
if (!m_freq.empty()) {
|
||||||
int width = this->width();
|
int width = this->width();
|
||||||
int height = this->height();
|
int height = this->height();
|
||||||
int barWidth = std::max(1ULL, width / m_freq.size());
|
int barWidth = std::max(1ULL, width / m_freq.size());
|
||||||
qDebug() << m_freq.size() << barWidth << m_freq << "freq";
|
|
||||||
|
|
||||||
for (int i = 0; i < m_freq.size(); i++) {
|
for (int i = 0; i < m_freq.size(); i++) {
|
||||||
int barHeight = static_cast<int>(m_freq[i] * height);
|
int barHeight = static_cast<int>(sqrt(m_freq[i]) * height * 0.5);
|
||||||
painter.fillRect(i * barWidth, height - barHeight, barWidth, barHeight, Qt::green);
|
painter.fillRect(i * barWidth, height - barHeight, barWidth, barHeight, QColor(70, 130, 180, (int)(140 * m_freq[i]) + 90));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
#include <QMediaPlayer>
|
#include <QMediaPlayer>
|
||||||
#include <QMediaMetaData>
|
#include <QMediaMetaData>
|
||||||
#include <QAudioOutput>
|
#include <QAudioOutput>
|
||||||
#include <QAudioBuffer>
|
|
||||||
#include <QPropertyAnimation>
|
#include <QPropertyAnimation>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
|
@ -442,7 +441,8 @@ void MainWindow::initConnections()
|
||||||
setAudioMetadataForDisplay(metadata.stringValue(QMediaMetaData::Title),
|
setAudioMetadataForDisplay(metadata.stringValue(QMediaMetaData::Title),
|
||||||
metadata.stringValue(QMediaMetaData::Author),
|
metadata.stringValue(QMediaMetaData::Author),
|
||||||
metadata.stringValue(QMediaMetaData::AlbumTitle));
|
metadata.stringValue(QMediaMetaData::AlbumTitle));
|
||||||
setAudioPropertyInfoForDisplay(-1, metadata.value(QMediaMetaData::AudioBitRate).toInt() / 1000, -1, metadata.stringValue(QMediaMetaData::FileFormat));
|
setAudioPropertyInfoForDisplay(-1, metadata.value(QMediaMetaData::AudioBitRate).toInt() / 1000,
|
||||||
|
-1, metadata.stringValue(QMediaMetaData::FileFormat));
|
||||||
#endif // NO_TAGLIB
|
#endif // NO_TAGLIB
|
||||||
QVariant coverArt(metadata.value(QMediaMetaData::ThumbnailImage));
|
QVariant coverArt(metadata.value(QMediaMetaData::ThumbnailImage));
|
||||||
if (!coverArt.isNull()) {
|
if (!coverArt.isNull()) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user