aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/General/rgscan/rgscandialog.cpp45
-rw-r--r--src/plugins/General/rgscan/rgscandialog.h7
-rw-r--r--src/plugins/General/rgscan/rgscanner.cpp10
3 files changed, 54 insertions, 8 deletions
diff --git a/src/plugins/General/rgscan/rgscandialog.cpp b/src/plugins/General/rgscan/rgscandialog.cpp
index 03be8abae..c925611e3 100644
--- a/src/plugins/General/rgscan/rgscandialog.cpp
+++ b/src/plugins/General/rgscan/rgscandialog.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2013-2015 by Ilya Kotov *
+ * Copyright (C) 2013-2016 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -35,6 +35,7 @@
#include <taglib/wavpackfile.h>
#include <taglib/id3v2tag.h>
#include <taglib/textidentificationframe.h>
+#include <taglib/mp4file.h>
#include "rgscanner.h"
#include "gain_analysis.h"
#include "rgscandialog.h"
@@ -65,13 +66,18 @@ RGScanDialog::RGScanDialog(QList <PlayListTrack *> tracks, QWidget *parent) : Q
//skip duplicates
if(paths.contains(track->url()))
continue;
+ //skip unsupported files
+ if(!MetaDataManager::instance()->supports(track->url()))
+ continue;
QString ext = track->url().section(".", -1).toLower();
- if(ext == "mp3" || //mpeg 1 layer 3
+
+ if((ext == "mp3") || //mpeg 1 layer 3
ext == "flac" || //native flac
ext == "oga" || //ogg flac
ext == "ogg" || //ogg vorbis
- ext == "wv") //wavpack
+ ext == "wv" || //wavpack
+ ext == "m4a") //aac (mp4 container)
{
paths.append(track->url());
QString name = formatter.format(track);
@@ -288,6 +294,16 @@ TagLib::String RGScanDialog::peakToString(double value)
return QStringToTString_qt4(QString("%1").arg(value, 0, 'f', 6));
}
+TagLib::StringList RGScanDialog::gainToStringList(double value)
+{
+ return TagLib::StringList (gainToString(value));
+}
+
+TagLib::StringList RGScanDialog::peakToStringList(double value)
+{
+ return TagLib::StringList (peakToString(value));
+}
+
void RGScanDialog::writeAPETag(TagLib::APE::Tag *tag, ReplayGainInfoItem *item)
{
if(m_ui.trackCheckBox->isChecked())
@@ -353,6 +369,24 @@ void RGScanDialog::writeVorbisComment(TagLib::Ogg::XiphComment *tag, ReplayGainI
}
}
+void RGScanDialog::writeMP4Tag(TagLib::MP4::Tag *tag, ReplayGainInfoItem *item)
+{
+ if(m_ui.trackCheckBox->isChecked())
+ {
+ tag->setItem("----:com.apple.iTunes:replaygain_track_gain",
+ gainToStringList(item->info[Qmmp::REPLAYGAIN_TRACK_GAIN]));
+ tag->setItem("----:com.apple.iTunes:replaygain_track_peak",
+ gainToStringList(item->info[Qmmp::REPLAYGAIN_TRACK_PEAK]));
+ }
+ if(m_ui.albumCheckBox->isChecked())
+ {
+ tag->setItem("----:com.apple.iTunes:replaygain_album_gain",
+ gainToStringList(item->info[Qmmp::REPLAYGAIN_ALBUM_GAIN]));
+ tag->setItem("----:com.apple.iTunes:replaygain_album_peak",
+ gainToStringList(item->info[Qmmp::REPLAYGAIN_ALBUM_PEAK]));
+ }
+}
+
void RGScanDialog::on_writeButton_clicked()
{
if(m_replayGainItemList.isEmpty())
@@ -395,5 +429,10 @@ void RGScanDialog::on_writeButton_clicked()
writeAPETag(file.APETag(true), item);
file.save();
}
+ else if(ext == "m4a")
+ {
+ TagLib::MP4::File file(qPrintable(item->url));
+ writeMP4Tag(file.tag(), item);
+ }
}
}
diff --git a/src/plugins/General/rgscan/rgscandialog.h b/src/plugins/General/rgscan/rgscandialog.h
index fe7132107..5451b8239 100644
--- a/src/plugins/General/rgscan/rgscandialog.h
+++ b/src/plugins/General/rgscan/rgscandialog.h
@@ -47,6 +47,10 @@ namespace TagLib
{
class XiphComment;
}
+ namespace MP4
+ {
+ class Tag;
+ }
}
/**
@@ -71,9 +75,12 @@ private:
QString getAlbumName(const QString &url);
TagLib::String gainToString(double value);
TagLib::String peakToString(double value);
+ TagLib::StringList gainToStringList(double value);
+ TagLib::StringList peakToStringList(double value);
void writeAPETag(TagLib::APE::Tag *tag, ReplayGainInfoItem *item);
void writeID3v2Tag(TagLib::ID3v2::Tag *tag, ReplayGainInfoItem *item);
void writeVorbisComment(TagLib::Ogg::XiphComment *tag, ReplayGainInfoItem *item);
+ void writeMP4Tag(TagLib::MP4::Tag *tag, ReplayGainInfoItem *item);
Ui::RGScanDialog m_ui;
QList<RGScanner *> m_scanners;
QList<ReplayGainInfoItem*> m_replayGainItemList;
diff --git a/src/plugins/General/rgscan/rgscanner.cpp b/src/plugins/General/rgscan/rgscanner.cpp
index 7e5692398..2c50c9fd7 100644
--- a/src/plugins/General/rgscan/rgscanner.cpp
+++ b/src/plugins/General/rgscan/rgscanner.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2013-2015 by Ilya Kotov *
+ * Copyright (C) 2013-2016 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -98,7 +98,7 @@ bool RGScanner::prepare(const QString &url)
}
if(decoder->audioParameters().channels() > 2)
{
- qWarning("RGScanner: [%s] unsupported channel count: %d",
+ qWarning("RGScanner: [%s] unsupported channel number: %d",
qPrintable(name),
decoder->audioParameters().channels());
delete source;
@@ -182,8 +182,8 @@ void RGScanner::run()
//buffers
double out_left[BUFFER_FRAMES], out_right[BUFFER_FRAMES]; //replay gain buffers
float float_buf[BUFFER_FRAMES*ap.channels()]; //float buffer
- qint64 char_buf_size = BUFFER_FRAMES*ap.channels()*ap.sampleSize();
- unsigned char char_buf[char_buf_size]; //char buffer
+ qint64 buf_size = BUFFER_FRAMES*ap.channels()*ap.sampleSize();
+ unsigned char char_buf[buf_size]; //char buffer
//counters
@@ -198,7 +198,7 @@ void RGScanner::run()
forever
{
- len = m_decoder->read(char_buf, char_buf_size);
+ len = m_decoder->read(char_buf, buf_size);
if(len < 0)
{