2bf890b49215f44ccadf4c93feeb39daa323311c
[platform/upstream/flac.git] / include / share / grabbag / replaygain.h
1 /* grabbag - Convenience lib for various routines common to several tools
2  * Copyright (C) 2002,2003  Josh Coalson
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17  */
18
19 /*
20  * This wraps the replaygain_analysis lib, which is LGPL.  This wrapper
21  * allows analysis of different input resolutions by automatically
22  * scaling the input signal
23  */
24
25 /* This .h cannot be included by itself; #include "share/grabbag.h" instead. */
26
27 #ifndef GRABBAG__REPLAYGAIN_H
28 #define GRABBAG__REPLAYGAIN_H
29
30 #include "FLAC/metadata.h"
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 extern const unsigned GRABBAG__REPLAYGAIN_MAX_TAG_SPACE_REQUIRED;
37
38 FLAC__bool grabbag__replaygain_is_valid_sample_frequency(unsigned sample_frequency);
39
40 FLAC__bool grabbag__replaygain_init(unsigned sample_frequency);
41
42 /* 'bps' must be valid for FLAC, i.e. >=4 and <= 32 */
43 FLAC__bool grabbag__replaygain_analyze(const FLAC__int32 * const input[], FLAC__bool is_stereo, unsigned bps, unsigned samples);
44
45 void grabbag__replaygain_get_album(float *gain, float *peak);
46 void grabbag__replaygain_get_title(float *gain, float *peak);
47
48 /* These three functions return an error string on error, or NULL if successful */
49 const char *grabbag__replaygain_analyze_file(const char *filename, float *title_gain, float *title_peak);
50 const char *grabbag__replaygain_store_to_vorbiscomment(FLAC__StreamMetadata *block, float album_gain, float album_peak, float title_gain, float title_peak);
51 const char *grabbag__replaygain_store_to_vorbiscomment_album(FLAC__StreamMetadata *block, float album_gain, float album_peak);
52 const char *grabbag__replaygain_store_to_vorbiscomment_title(FLAC__StreamMetadata *block, float title_gain, float title_peak);
53 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);
54 const char *grabbag__replaygain_store_to_file_album(const char *filename, float album_gain, float album_peak, FLAC__bool preserve_modtime);
55 const char *grabbag__replaygain_store_to_file_title(const char *filename, float title_gain, float title_peak, FLAC__bool preserve_modtime);
56
57 FLAC__bool grabbag__replaygain_load_from_vorbiscomment(const FLAC__StreamMetadata *block, FLAC__bool album_mode, double *gain, double *peak);
58 double grabbag__replaygain_compute_scale_factor(double peak, double gain, double preamp, FLAC__bool prevent_clipping);
59
60 #ifdef __cplusplus
61 }
62 #endif
63
64 #endif