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