1*600f14f4SXin Li /* grabbag - Convenience lib for various routines common to several tools 2*600f14f4SXin Li * Copyright (C) 2002-2009 Josh Coalson 3*600f14f4SXin Li * Copyright (C) 2011-2023 Xiph.Org Foundation 4*600f14f4SXin Li * 5*600f14f4SXin Li * This library is free software; you can redistribute it and/or 6*600f14f4SXin Li * modify it under the terms of the GNU Lesser General Public 7*600f14f4SXin Li * License as published by the Free Software Foundation; either 8*600f14f4SXin Li * version 2.1 of the License, or (at your option) any later version. 9*600f14f4SXin Li * 10*600f14f4SXin Li * This library is distributed in the hope that it will be useful, 11*600f14f4SXin Li * but WITHOUT ANY WARRANTY; without even the implied warranty of 12*600f14f4SXin Li * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13*600f14f4SXin Li * Lesser General Public License for more details. 14*600f14f4SXin Li * 15*600f14f4SXin Li * You should have received a copy of the GNU Lesser General Public 16*600f14f4SXin Li * License along with this library; if not, write to the Free Software 17*600f14f4SXin Li * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18*600f14f4SXin Li */ 19*600f14f4SXin Li 20*600f14f4SXin Li /* 21*600f14f4SXin Li * This wraps the replaygain_analysis lib, which is LGPL. This wrapper 22*600f14f4SXin Li * allows analysis of different input resolutions by automatically 23*600f14f4SXin Li * scaling the input signal 24*600f14f4SXin Li */ 25*600f14f4SXin Li 26*600f14f4SXin Li /* This .h cannot be included by itself; #include "share/grabbag.h" instead. */ 27*600f14f4SXin Li 28*600f14f4SXin Li #ifndef GRABBAG__REPLAYGAIN_H 29*600f14f4SXin Li #define GRABBAG__REPLAYGAIN_H 30*600f14f4SXin Li 31*600f14f4SXin Li #include "FLAC/metadata.h" 32*600f14f4SXin Li 33*600f14f4SXin Li #ifdef __cplusplus 34*600f14f4SXin Li extern "C" { 35*600f14f4SXin Li #endif 36*600f14f4SXin Li 37*600f14f4SXin Li extern const uint32_t GRABBAG__REPLAYGAIN_MAX_TAG_SPACE_REQUIRED; 38*600f14f4SXin Li 39*600f14f4SXin Li extern const FLAC__byte * const GRABBAG__REPLAYGAIN_TAG_REFERENCE_LOUDNESS; /* = "REPLAYGAIN_REFERENCE_LOUDNESS" */ 40*600f14f4SXin Li extern const FLAC__byte * const GRABBAG__REPLAYGAIN_TAG_TITLE_GAIN; /* = "REPLAYGAIN_TRACK_GAIN" */ 41*600f14f4SXin Li extern const FLAC__byte * const GRABBAG__REPLAYGAIN_TAG_TITLE_PEAK; /* = "REPLAYGAIN_TRACK_PEAK" */ 42*600f14f4SXin Li extern const FLAC__byte * const GRABBAG__REPLAYGAIN_TAG_ALBUM_GAIN; /* = "REPLAYGAIN_ALBUM_GAIN" */ 43*600f14f4SXin Li extern const FLAC__byte * const GRABBAG__REPLAYGAIN_TAG_ALBUM_PEAK; /* = "REPLAYGAIN_ALBUM_PEAK" */ 44*600f14f4SXin Li 45*600f14f4SXin Li FLAC__bool grabbag__replaygain_is_valid_sample_frequency(uint32_t sample_frequency); 46*600f14f4SXin Li 47*600f14f4SXin Li FLAC__bool grabbag__replaygain_init(uint32_t sample_frequency); 48*600f14f4SXin Li 49*600f14f4SXin Li /* 'bps' must be valid for FLAC, i.e. >=4 and <= 32 */ 50*600f14f4SXin Li FLAC__bool grabbag__replaygain_analyze(const FLAC__int32 * const input[], FLAC__bool is_stereo, uint32_t bps, uint32_t samples); 51*600f14f4SXin Li 52*600f14f4SXin Li void grabbag__replaygain_get_album(float *gain, float *peak); 53*600f14f4SXin Li void grabbag__replaygain_get_title(float *gain, float *peak); 54*600f14f4SXin Li 55*600f14f4SXin Li /* These three functions return an error string on error, or NULL if successful */ 56*600f14f4SXin Li const char *grabbag__replaygain_analyze_file(const char *filename, float *title_gain, float *title_peak); 57*600f14f4SXin Li const char *grabbag__replaygain_store_to_vorbiscomment(FLAC__StreamMetadata *block, float album_gain, float album_peak, float title_gain, float title_peak); 58*600f14f4SXin Li const char *grabbag__replaygain_store_to_vorbiscomment_reference(FLAC__StreamMetadata *block); 59*600f14f4SXin Li const char *grabbag__replaygain_store_to_vorbiscomment_album(FLAC__StreamMetadata *block, float album_gain, float album_peak); 60*600f14f4SXin Li const char *grabbag__replaygain_store_to_vorbiscomment_title(FLAC__StreamMetadata *block, float title_gain, float title_peak); 61*600f14f4SXin Li const char *grabbag__replaygain_store_to_file(const char *filename, float album_gain, float album_peak, float title_gain, float title_peak, FLAC__bool preserve_modtime); 62*600f14f4SXin Li const char *grabbag__replaygain_store_to_file_reference(const char *filename, FLAC__bool preserve_modtime); 63*600f14f4SXin Li const char *grabbag__replaygain_store_to_file_album(const char *filename, float album_gain, float album_peak, FLAC__bool preserve_modtime); 64*600f14f4SXin Li const char *grabbag__replaygain_store_to_file_title(const char *filename, float title_gain, float title_peak, FLAC__bool preserve_modtime); 65*600f14f4SXin Li 66*600f14f4SXin Li FLAC__bool grabbag__replaygain_load_from_vorbiscomment(const FLAC__StreamMetadata *block, FLAC__bool album_mode, FLAC__bool strict, double *reference, double *gain, double *peak); 67*600f14f4SXin Li double grabbag__replaygain_compute_scale_factor(double peak, double gain, double preamp, FLAC__bool prevent_clipping); 68*600f14f4SXin Li 69*600f14f4SXin Li #ifdef __cplusplus 70*600f14f4SXin Li } 71*600f14f4SXin Li #endif 72*600f14f4SXin Li 73*600f14f4SXin Li #endif 74