int main(int argc, char **argv) { GError *error = NULL; #ifdef HAVE_LOCALE_H /* initialize locale */ setlocale(LC_CTYPE,""); #endif if (argc != 2) { g_printerr("Usage: read_rva2 FILE\n"); return 1; } const char *path = argv[1]; struct id3_tag *tag = tag_id3_load(path, &error); if (tag == NULL) { if (error != NULL) { g_printerr("%s\n", error->message); g_error_free(error); } else g_printerr("No ID3 tag found\n"); return EXIT_FAILURE; } struct replay_gain_info replay_gain; replay_gain_info_init(&replay_gain); bool success = tag_rva2_parse(tag, &replay_gain); id3_tag_delete(tag); if (!success) { g_printerr("No RVA2 tag found\n"); return EXIT_FAILURE; } const struct replay_gain_tuple *tuple = &replay_gain.tuples[REPLAY_GAIN_ALBUM]; if (replay_gain_tuple_defined(tuple)) g_printerr("replay_gain[album]: gain=%f peak=%f\n", tuple->gain, tuple->peak); tuple = &replay_gain.tuples[REPLAY_GAIN_TRACK]; if (replay_gain_tuple_defined(tuple)) g_printerr("replay_gain[track]: gain=%f peak=%f\n", tuple->gain, tuple->peak); return EXIT_SUCCESS; }
/** * Recalculates the new volume after a property was changed. */ static void replay_gain_filter_update(struct replay_gain_filter *filter) { if (filter->mode != REPLAY_GAIN_OFF) { const struct replay_gain_tuple *tuple = &filter->info.tuples[filter->mode]; float scale = replay_gain_tuple_defined(tuple) ? replay_gain_tuple_scale(tuple, replay_gain_preamp) : replay_gain_missing_preamp; g_debug("scale=%f\n", (double)scale); filter->volume = pcm_float_to_volume(scale); } else filter->volume = PCM_VOLUME_1; if (filter->mixer != NULL) { /* update the hardware mixer volume */ unsigned volume = (filter->volume * filter->base) / PCM_VOLUME_1; if (volume > 100) volume = 100; GError *error = NULL; if (!mixer_set_volume(filter->mixer, volume, &error)) { g_warning("Failed to update hardware mixer: %s", error->message); g_error_free(error); } } }
float decoder_replay_gain(G_GNUC_UNUSED struct decoder *decoder, const struct replay_gain_info *replay_gain_info) { const struct replay_gain_tuple *tuple = &replay_gain_info->tuples[REPLAY_GAIN_ALBUM]; if (replay_gain_tuple_defined(tuple)) g_printerr("replay_gain[album]: gain=%f peak=%f\n", tuple->gain, tuple->peak); tuple = &replay_gain_info->tuples[REPLAY_GAIN_TRACK]; if (replay_gain_tuple_defined(tuple)) g_printerr("replay_gain[track]: gain=%f peak=%f\n", tuple->gain, tuple->peak); return 0.0; }