2012-04-23 22:30:06 +02:00
|
|
|
/*
|
2013-07-26 12:09:17 +02:00
|
|
|
* Copyright (C) 2003-2013 The Music Player Daemon Project
|
2012-04-23 22:30:06 +02:00
|
|
|
* http://www.musicpd.org
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
2013-09-04 23:46:20 +02:00
|
|
|
#include "tag/TagId3.hxx"
|
|
|
|
#include "tag/TagRva2.hxx"
|
2013-10-02 12:22:12 +02:00
|
|
|
#include "ReplayGainInfo.hxx"
|
2013-09-05 08:47:10 +02:00
|
|
|
#include "ConfigGlobal.hxx"
|
2013-08-10 18:02:44 +02:00
|
|
|
#include "util/Error.hxx"
|
2013-10-26 15:14:54 +02:00
|
|
|
#include "fs/Path.hxx"
|
2013-12-24 14:44:08 +01:00
|
|
|
#include "Log.hxx"
|
2012-04-23 22:30:06 +02:00
|
|
|
|
|
|
|
#include <id3tag.h>
|
|
|
|
|
|
|
|
#ifdef HAVE_LOCALE_H
|
|
|
|
#include <locale.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
const char *
|
2013-01-30 17:52:51 +01:00
|
|
|
config_get_string(gcc_unused enum ConfigOption option,
|
|
|
|
const char *default_value)
|
2012-04-23 22:30:06 +02:00
|
|
|
{
|
|
|
|
return default_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_LOCALE_H
|
|
|
|
/* initialize locale */
|
|
|
|
setlocale(LC_CTYPE,"");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (argc != 2) {
|
2013-12-24 14:44:08 +01:00
|
|
|
fprintf(stderr, "Usage: read_rva2 FILE\n");
|
|
|
|
return EXIT_FAILURE;
|
2012-04-23 22:30:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *path = argv[1];
|
|
|
|
|
2013-08-10 18:02:44 +02:00
|
|
|
Error error;
|
2013-10-26 15:14:54 +02:00
|
|
|
struct id3_tag *tag = tag_id3_load(Path::FromFS(path), error);
|
2012-04-23 22:30:06 +02:00
|
|
|
if (tag == NULL) {
|
2013-08-10 18:02:44 +02:00
|
|
|
if (error.IsDefined())
|
2013-12-24 14:44:08 +01:00
|
|
|
LogError(error);
|
2013-08-10 18:02:44 +02:00
|
|
|
else
|
2013-12-24 14:44:08 +01:00
|
|
|
fprintf(stderr, "No ID3 tag found\n");
|
2012-04-23 22:30:06 +02:00
|
|
|
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2013-10-25 19:09:22 +02:00
|
|
|
ReplayGainInfo replay_gain;
|
2013-10-25 19:05:49 +02:00
|
|
|
replay_gain.Clear();
|
2012-04-23 22:30:06 +02:00
|
|
|
|
2013-10-25 19:09:22 +02:00
|
|
|
bool success = tag_rva2_parse(tag, replay_gain);
|
2012-04-23 22:30:06 +02:00
|
|
|
id3_tag_delete(tag);
|
|
|
|
|
|
|
|
if (!success) {
|
2013-12-24 14:44:08 +01:00
|
|
|
fprintf(stderr, "No RVA2 tag found\n");
|
2012-04-23 22:30:06 +02:00
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2013-10-25 19:09:22 +02:00
|
|
|
const ReplayGainTuple *tuple = &replay_gain.tuples[REPLAY_GAIN_ALBUM];
|
2013-10-25 19:05:49 +02:00
|
|
|
if (tuple->IsDefined())
|
2013-12-24 14:44:08 +01:00
|
|
|
fprintf(stderr, "replay_gain[album]: gain=%f peak=%f\n",
|
|
|
|
tuple->gain, tuple->peak);
|
2012-04-23 22:30:06 +02:00
|
|
|
|
|
|
|
tuple = &replay_gain.tuples[REPLAY_GAIN_TRACK];
|
2013-10-25 19:05:49 +02:00
|
|
|
if (tuple->IsDefined())
|
2013-12-24 14:44:08 +01:00
|
|
|
fprintf(stderr, "replay_gain[track]: gain=%f peak=%f\n",
|
|
|
|
tuple->gain, tuple->peak);
|
2012-04-23 22:30:06 +02:00
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|