Im writing a program in c++ that opens modifys and saves a wav file.
i have a function that changes the gain:
CODE
void processGain(void)
{
//variables declared
int i;
double gain;
double dB;
cout<<endl;
cout<<"GAIN"<<endl;
cout<<"Enter desired gain: ";
cin>>gain;
//into dB
dB = 20*log10(gain);
cout<<"dB gain of "<<dB<<endl;
for (i=0; i<length; i++)
{
sample[i]=(sample[i])*gain;
}
}
{
//variables declared
int i;
double gain;
double dB;
cout<<endl;
cout<<"GAIN"<<endl;
cout<<"Enter desired gain: ";
cin>>gain;
//into dB
dB = 20*log10(gain);
cout<<"dB gain of "<<dB<<endl;
for (i=0; i<length; i++)
{
sample[i]=(sample[i])*gain;
}
}
the problem with this function is: it changes the gain using a number, then displays the DB change.
i want to be able to be able to have the user enter a dB, then for the program to enter this and reduce/gain by that amount.
