metaflac: add --scan-replay-gain option
Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
This commit is contained in:
parent
15a9062609
commit
f7c52c8aa8
@ -346,6 +346,15 @@
|
||||
Calculates the title and album gains/peaks of the given FLAC files as if all the files were part of one album, then stores them as FLAC tags. The tags are the same as those used by <span class="commandname">vorbisgain</span>. Existing ReplayGain tags will be replaced. If only one FLAC file is given, the album and title gains will be the same. Since this operation requires two passes, it is always executed last, after all other operations have been completed and written to disk. All FLAC files specified must have the same resolution, sample rate, and number of channels. The sample rate must be one of 8, 11.025, 12, 16, 22.05, 24, 32, 44.1, or 48 kHz.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td nowrap="nowrap" align="right" valign="top" bgcolor="#F4F4CC">
|
||||
<a name="metaflac_shorthand_add_replay_gain_scan" />
|
||||
<span class="argument">--scan-replay-gain</span>
|
||||
</td>
|
||||
<td>
|
||||
Like <span class="argument">--add-replay-gain</span>, but only analyzes the files rather than writing them to the tags.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td nowrap="nowrap" align="right" valign="top" bgcolor="#F4F4CC">
|
||||
<a name="metaflac_shorthand_remove_replay_gain" />
|
||||
@ -517,6 +526,7 @@
|
||||
<a href="#metaflac_shorthand_remove_replay_gain"><span class="argument">--remove-replay-gain</span></a><br />
|
||||
<a href="#metaflac_shorthand_remove_tag"><span class="argument">--remove-tag</span></a><br />
|
||||
<a href="#metaflac_operations_remove"><span class="argument">--remove</span></a><br />
|
||||
<a href="#metaflac_shorthand_scan_replay_gain"><span class="argument">--scan-replay-gain</span></a><br />
|
||||
<a href="#metaflac_shorthand_set_tag_from_file"><span class="argument">--set-tag-from-file</span></a><br />
|
||||
<a href="#metaflac_shorthand_set_tag"><span class="argument">--set-tag</span></a><br />
|
||||
<a href="#metaflac_shorthand_show_bps"><span class="argument">--show-bps</span></a><br />
|
||||
|
@ -199,6 +199,10 @@ number of channels. The sample rate must be one of 8, 11.025,
|
||||
12, 16, 18.9, 22.05, 24, 28, 32, 37.8, 44.1, 48, 56, 64, 88.2,
|
||||
96, 112, 128, 144, 176.4, or 192kHz.
|
||||
.TP
|
||||
\fB--scan-replay-gain\fR
|
||||
Like --add-replay-gain, but only analyzes the files rather than
|
||||
writing them to the tags.
|
||||
.TP
|
||||
\fB--remove-replay-gain\fR
|
||||
Removes the ReplayGain tags.
|
||||
.TP
|
||||
|
@ -379,6 +379,16 @@ manpage.1: manpage.sgml
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>--scan-replay-gain</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
|
||||
Like --add-replay-gain, but only analyzes the files rather
|
||||
than writing them to the tags.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>--remove-replay-gain</option></term>
|
||||
<listitem>
|
||||
|
@ -44,7 +44,7 @@ static FLAC__bool do_major_operation__remove_all(FLAC__Metadata_Chain *chain, co
|
||||
static FLAC__bool do_shorthand_operations(const CommandLineOptions *options);
|
||||
static FLAC__bool do_shorthand_operations_on_file(const char *filename, const CommandLineOptions *options);
|
||||
static FLAC__bool do_shorthand_operation(const char *filename, FLAC__bool prefix_with_filename, FLAC__Metadata_Chain *chain, const Operation *operation, FLAC__bool *needs_write, FLAC__bool utf8_convert);
|
||||
static FLAC__bool do_shorthand_operation__add_replay_gain(char **filenames, unsigned num_files, FLAC__bool preserve_modtime);
|
||||
static FLAC__bool do_shorthand_operation__add_replay_gain(char **filenames, unsigned num_files, FLAC__bool preserve_modtime, FLAC__bool scan);
|
||||
static FLAC__bool do_shorthand_operation__add_padding(const char *filename, FLAC__Metadata_Chain *chain, unsigned length, FLAC__bool *needs_write);
|
||||
|
||||
static FLAC__bool passes_filter(const CommandLineOptions *options, const FLAC__StreamMetadata *block, unsigned block_number);
|
||||
@ -266,7 +266,9 @@ FLAC__bool do_shorthand_operations(const CommandLineOptions *options)
|
||||
if(ok && options->num_files > 0) {
|
||||
for(i = 0; i < options->ops.num_operations; i++) {
|
||||
if(options->ops.operations[i].type == OP__ADD_REPLAY_GAIN)
|
||||
ok = do_shorthand_operation__add_replay_gain(options->filenames, options->num_files, options->preserve_modtime);
|
||||
ok = do_shorthand_operation__add_replay_gain(options->filenames, options->num_files, options->preserve_modtime, false);
|
||||
else if(options->ops.operations[i].type == OP__SCAN_REPLAY_GAIN)
|
||||
ok = do_shorthand_operation__add_replay_gain(options->filenames, options->num_files, options->preserve_modtime, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -375,7 +377,8 @@ FLAC__bool do_shorthand_operation(const char *filename, FLAC__bool prefix_with_f
|
||||
ok = do_shorthand_operation__add_seekpoints(filename, chain, operation->argument.add_seekpoint.specification, needs_write);
|
||||
break;
|
||||
case OP__ADD_REPLAY_GAIN:
|
||||
/* this command is always executed last */
|
||||
case OP__SCAN_REPLAY_GAIN:
|
||||
/* these commands are always executed last */
|
||||
ok = true;
|
||||
break;
|
||||
case OP__ADD_PADDING:
|
||||
@ -390,7 +393,7 @@ FLAC__bool do_shorthand_operation(const char *filename, FLAC__bool prefix_with_f
|
||||
return ok;
|
||||
}
|
||||
|
||||
FLAC__bool do_shorthand_operation__add_replay_gain(char **filenames, unsigned num_files, FLAC__bool preserve_modtime)
|
||||
FLAC__bool do_shorthand_operation__add_replay_gain(char **filenames, unsigned num_files, FLAC__bool preserve_modtime, FLAC__bool scan)
|
||||
{
|
||||
FLAC__StreamMetadata streaminfo;
|
||||
float *title_gains = 0, *title_peaks = 0;
|
||||
@ -465,11 +468,15 @@ FLAC__bool do_shorthand_operation__add_replay_gain(char **filenames, unsigned nu
|
||||
grabbag__replaygain_get_album(&album_gain, &album_peak);
|
||||
|
||||
for(i = 0; i < num_files; i++) {
|
||||
if(0 != (error = grabbag__replaygain_store_to_file(filenames[i], album_gain, album_peak, title_gains[i], title_peaks[i], preserve_modtime))) {
|
||||
flac_fprintf(stderr, "%s: ERROR: writing tags (%s)\n", filenames[i], error);
|
||||
free(title_gains);
|
||||
free(title_peaks);
|
||||
return false;
|
||||
if(!scan) {
|
||||
if(0 != (error = grabbag__replaygain_store_to_file(filenames[i], album_gain, album_peak, title_gains[i], title_peaks[i], preserve_modtime))) {
|
||||
flac_fprintf(stderr, "%s: ERROR: writing tags (%s)\n", filenames[i], error);
|
||||
free(title_gains);
|
||||
free(title_peaks);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
flac_fprintf(stdout, "%s: %f %f %f %f\n", filenames[i], album_gain, album_peak, title_gains[i], title_peaks[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,6 +79,7 @@ struct share__option long_options_[] = {
|
||||
{ "export-picture-to", 1, 0, 0 },
|
||||
{ "add-seekpoint", 1, 0, 0 },
|
||||
{ "add-replay-gain", 0, 0, 0 },
|
||||
{ "scan-replay-gain", 0, 0, 0 },
|
||||
{ "remove-replay-gain", 0, 0, 0 },
|
||||
{ "add-padding", 1, 0, 0 },
|
||||
/* major operations */
|
||||
@ -612,6 +613,9 @@ FLAC__bool parse_option(int option_index, const char *option_argument, CommandLi
|
||||
else if(0 == strcmp(opt, "add-replay-gain")) {
|
||||
(void) append_shorthand_operation(options, OP__ADD_REPLAY_GAIN);
|
||||
}
|
||||
else if(0 == strcmp(opt, "scan-replay-gain")) {
|
||||
(void) append_shorthand_operation(options, OP__SCAN_REPLAY_GAIN);
|
||||
}
|
||||
else if(0 == strcmp(opt, "remove-replay-gain")) {
|
||||
const FLAC__byte * const tags[5] = {
|
||||
GRABBAG__REPLAYGAIN_TAG_REFERENCE_LOUDNESS,
|
||||
|
@ -65,6 +65,7 @@ typedef enum {
|
||||
OP__EXPORT_PICTURE_TO,
|
||||
OP__ADD_SEEKPOINT,
|
||||
OP__ADD_REPLAY_GAIN,
|
||||
OP__SCAN_REPLAY_GAIN,
|
||||
OP__ADD_PADDING,
|
||||
OP__LIST,
|
||||
OP__APPEND,
|
||||
|
@ -218,6 +218,8 @@ int long_usage(const char *message, ...)
|
||||
fprintf(out, " must have the same resolution, sample rate, and number\n");
|
||||
fprintf(out, " of channels. The sample rate must be one of 8, 11.025,\n");
|
||||
fprintf(out, " 12, 16, 22.05, 24, 32, 44.1, or 48 kHz.\n");
|
||||
fprintf(out, "--scan-replay-gain Like --add-replay-gain, but only analyzes the files\n");
|
||||
fprintf(out, " rather than writing them to tags.\n");
|
||||
fprintf(out, "--remove-replay-gain Removes the ReplayGain tags.\n");
|
||||
fprintf(out, "--add-seekpoint={#|X|#x|#s} Add seek points to a SEEKTABLE block\n");
|
||||
fprintf(out, " # : a specific sample number for a seek point\n");
|
||||
|
@ -274,6 +274,10 @@ run_metaflac --remove-replay-gain $flacfile
|
||||
check_flac
|
||||
metaflac_test case42 "--remove-replay-gain" "--list"
|
||||
|
||||
run_metaflac --scan-replay-gain $flacfile
|
||||
check_flac
|
||||
metaflac_test case42 "--scan-replay-gain" "--list"
|
||||
|
||||
# CUESHEET blocks
|
||||
cs_in=${top_srcdir}/test/cuesheets/good.000.cue
|
||||
cs_out=metaflac.cue
|
||||
|
@ -126,6 +126,7 @@ for ACTION in $REPLAYGAIN_FREQ ; do
|
||||
[ $MULTIPLE -eq 1 -o -n "${REPLAYGAIN_FREQ##* $RATE/*}" ] || break
|
||||
echo -n "Testing FLAC replaygain $RATE ($FREQ x $MULTIPLE) ... "
|
||||
tonegenerator $RATE $flacfile
|
||||
run_metaflac --scan-replay-gain $flacfile
|
||||
run_metaflac --add-replay-gain $flacfile
|
||||
run_metaflac --list $flacfile | grep REPLAYGAIN.*GAIN= |
|
||||
while read -r REPLAYGAIN ; do
|
||||
|
Loading…
x
Reference in New Issue
Block a user