- /* Handle reaply gain */
- if( p_sys->info.peak_title != 32767 )
- {
- int i_type = var_CreateGetInteger( p_demux, "mpc-replaygain-type" );
- int gain;
- int peak;
-
- if( i_type == 2 ) // album
- {
- gain = p_sys->info.gain_album;
- peak = p_sys->info.peak_album;
- }
- else if( i_type == 1 ) // title
- {
- gain = p_sys->info.gain_title;
- peak = p_sys->info.peak_title;
- }
- else
- {
- gain = 0;
- peak = 0;
- }
-
- if( gain )
- {
- double g = pow( 10, (double)gain / 2000.0 );
- double gmax = (double)32767.0 / (peak+1);
- if( g > gmax )
- g = gmax;
-
- msg_Dbg( p_demux, "Using reaply gain factor %f", g );
- mpc_decoder_scale_output( &p_sys->decoder, g );
- }
- }
-