Chris@1: /* replaygain_synthesis - Routines for applying ReplayGain to a signal Chris@1: * Copyright (C) 2002,2003,2004,2005,2006,2007 Josh Coalson Chris@1: * Chris@1: * This library is free software; you can redistribute it and/or Chris@1: * modify it under the terms of the GNU Lesser General Public Chris@1: * License as published by the Free Software Foundation; either Chris@1: * version 2.1 of the License, or (at your option) any later version. Chris@1: * Chris@1: * This library is distributed in the hope that it will be useful, Chris@1: * but WITHOUT ANY WARRANTY; without even the implied warranty of Chris@1: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Chris@1: * Lesser General Public License for more details. Chris@1: * Chris@1: * You should have received a copy of the GNU Lesser General Public Chris@1: * License along with this library; if not, write to the Free Software Chris@1: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Chris@1: */ Chris@1: Chris@1: #ifndef FLAC__SHARE__REPLAYGAIN_SYNTHESIS_H Chris@1: #define FLAC__SHARE__REPLAYGAIN_SYNTHESIS_H Chris@1: Chris@1: #include /* for size_t */ Chris@1: #include "FLAC/ordinals.h" Chris@1: Chris@1: #define FLAC_SHARE__MAX_SUPPORTED_CHANNELS 2 Chris@1: Chris@1: typedef enum { Chris@1: NOISE_SHAPING_NONE = 0, Chris@1: NOISE_SHAPING_LOW = 1, Chris@1: NOISE_SHAPING_MEDIUM = 2, Chris@1: NOISE_SHAPING_HIGH = 3 Chris@1: } NoiseShaping; Chris@1: Chris@1: typedef struct { Chris@1: const float* FilterCoeff; Chris@1: FLAC__uint64 Mask; Chris@1: double Add; Chris@1: float Dither; Chris@1: float ErrorHistory [FLAC_SHARE__MAX_SUPPORTED_CHANNELS] [16]; /* 16th order Noise shaping */ Chris@1: float DitherHistory [FLAC_SHARE__MAX_SUPPORTED_CHANNELS] [16]; Chris@1: int LastRandomNumber [FLAC_SHARE__MAX_SUPPORTED_CHANNELS]; Chris@1: unsigned LastHistoryIndex; Chris@1: NoiseShaping ShapingType; Chris@1: } DitherContext; Chris@1: Chris@1: void FLAC__replaygain_synthesis__init_dither_context(DitherContext *dither, int bits, int shapingtype); Chris@1: Chris@1: /* scale = (float) pow(10., (double)replaygain * 0.05); */ Chris@1: size_t FLAC__replaygain_synthesis__apply_gain(FLAC__byte *data_out, FLAC__bool little_endian_data_out, FLAC__bool unsigned_data_out, const FLAC__int32 * const input[], unsigned wide_samples, unsigned channels, const unsigned source_bps, const unsigned target_bps, const double scale, const FLAC__bool hard_limit, FLAC__bool do_dithering, DitherContext *dither_context); Chris@1: Chris@1: #endif