00001 /* 00002 * Copyright (C) 2003-2011 The Music Player Daemon Project 00003 * http://www.musicpd.org 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License along 00016 * with this program; if not, write to the Free Software Foundation, Inc., 00017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00018 */ 00019 00020 #ifndef MPD_REPLAY_GAIN_INFO_H 00021 #define MPD_REPLAY_GAIN_INFO_H 00022 00023 #include "check.h" 00024 00025 #include <stdbool.h> 00026 #include <math.h> 00027 00028 enum replay_gain_mode { 00029 REPLAY_GAIN_AUTO = -2, 00030 REPLAY_GAIN_OFF, 00031 REPLAY_GAIN_ALBUM, 00032 REPLAY_GAIN_TRACK, 00033 }; 00034 00035 struct replay_gain_tuple { 00036 float gain; 00037 float peak; 00038 }; 00039 00040 struct replay_gain_info { 00041 struct replay_gain_tuple tuples[2]; 00042 }; 00043 00044 static inline void 00045 replay_gain_tuple_init(struct replay_gain_tuple *tuple) 00046 { 00047 tuple->gain = INFINITY; 00048 tuple->peak = 0.0; 00049 } 00050 00051 static inline void 00052 replay_gain_info_init(struct replay_gain_info *info) 00053 { 00054 replay_gain_tuple_init(&info->tuples[REPLAY_GAIN_ALBUM]); 00055 replay_gain_tuple_init(&info->tuples[REPLAY_GAIN_TRACK]); 00056 } 00057 00058 static inline bool 00059 replay_gain_tuple_defined(const struct replay_gain_tuple *tuple) 00060 { 00061 return !isinf(tuple->gain); 00062 } 00063 00064 float 00065 replay_gain_tuple_scale(const struct replay_gain_tuple *tuple, float preamp, float missing_preamp, bool peak_limit); 00066 00071 void 00072 replay_gain_info_complete(struct replay_gain_info *info); 00073 00074 #endif