#include "ampexp.h"
#include "phaseexp.h"
-void synth_one_frame(kiss_fft_cfg fft_inv_cfg, short buf[], MODEL *model, float Sn_[], float Pn[], int prede, float *de_mem);
+void synth_one_frame(kiss_fft_cfg fft_inv_cfg, short buf[], MODEL *model, float Sn_[], float Pn[], int prede, float *de_mem, float gain);
void print_help(const struct option *long_options, int num_opts, char* argv[]);
#endif
struct PEXP *pexp = NULL;
struct AEXP *aexp = NULL;
+ float gain = 1.0;
char* opt_string = "ho:";
struct option long_options[] = {
{ "sq_pitch_e", no_argument, &scalar_quant_Wo_e, 1 },
{ "vq_pitch_e", no_argument, &vector_quant_Wo_e, 1 },
{ "rate", required_argument, NULL, 0 },
+ { "gain", required_argument, NULL, 0 },
#ifdef DUMP
{ "dump", required_argument, &dump, 1 },
#endif
strcpy(phaseexp_arg, optarg);
} else if(strcmp(long_options[option_index].name, "ampexp") == 0) {
strcpy(ampexp_arg, optarg);
+ } else if(strcmp(long_options[option_index].name, "gain") == 0) {
+ gain = atof(optarg);
} else if(strcmp(long_options[option_index].name, "rate") == 0) {
if(strcmp(optarg,"3200") == 0) {
lpc_model = 1; order = 10;
order);
if (postfilt)
postfilter(&interp_model, &bg_est);
- synth_one_frame(fft_inv_cfg, buf, &interp_model, Sn_, Pn, prede, &de_mem);
+ synth_one_frame(fft_inv_cfg, buf, &interp_model, Sn_, Pn, prede, &de_mem, gain);
//printf(" buf[0] %d\n", buf[0]);
if (fout != NULL)
fwrite(buf,sizeof(short),N,fout);
phase_synth_zero_order(fft_fwd_cfg, &model, ak, ex_phase, order);
if (postfilt)
postfilter(&model, &bg_est);
- synth_one_frame(fft_inv_cfg, buf, &model, Sn_, Pn, prede, &de_mem);
+ synth_one_frame(fft_inv_cfg, buf, &model, Sn_, Pn, prede, &de_mem, gain);
//printf(" buf[0] %d\n", buf[0]);
if (fout != NULL)
fwrite(buf,sizeof(short),N,fout);
if (postfilt)
postfilter(&model, &bg_est);
- synth_one_frame(fft_inv_cfg, buf, &model, Sn_, Pn, prede, &de_mem);
+ synth_one_frame(fft_inv_cfg, buf, &model, Sn_, Pn, prede, &de_mem, gain);
if (fout != NULL) fwrite(buf,sizeof(short),N,fout);
}
return 0;
}
-void synth_one_frame(kiss_fft_cfg fft_inv_cfg, short buf[], MODEL *model, float Sn_[], float Pn[], int prede, float *de_mem)
+void synth_one_frame(kiss_fft_cfg fft_inv_cfg, short buf[], MODEL *model, float Sn_[], float Pn[], int prede, float *de_mem, float gain)
{
int i;
de_emp(Sn_, Sn_, de_mem, N);
for(i=0; i<N; i++) {
+ Sn_[i] *= gain;
if (Sn_[i] > 32767.0)
buf[i] = 32767;
else if (Sn_[i] < -32767.0)