[Flac-dev] Question regarding ReplayGain

Harry Griff bg_ie at yahoo.com
Sat May 30 03:44:10 PDT 2009


Hi there,

I wish to use the regain functionality of flac.

To read samples from a wav file, I'm using the c library sndfilelib. This gives be samples between -1 and +1. I use the following code to establish the replay gain -

#define		BUFFER_LEN	4096

...

float data [BUFFER_LEN] ;
InitGainAnalysis ( 44100 );
while ((readcount = sf_read_float (infile, data, BUFFER_LEN)))
{
	int i;
	for(i = 0; i < readcount; i++)
	{
		if(i%2==0)
			l_samples[i/2] = data[i]*1.0;
		else
			r_samples[i/2] = data[i]*1.0;
	}

	int response = AnalyzeSamples ( l_samples, r_samples, readcount/2, 2 );
	std::cout << "Response: "<< GAIN_ANALYSIS_ERROR << std::endl;
}

std::cout << Recommended dB change for song: "<< GetTitleGain() << "dB" << std::endl;

which gives me a result of 64.82dB. If I multiple the samples by 10.0 (data[i]*10.0) and try again, I get the same result. If by 100.0 then I get 50.9dB, and by 1000.0 I get 30.9dB.

Obviously having my samples in the range of -1 and 1 isn't working. What range should they be within. 

Thanks for your help,

Barry




      


More information about the Flac-dev mailing list