void amp_experiment(struct AEXP *aexp, MODEL *model, char *arg) { int m,i; memcpy(&aexp->model_uq[2], model, sizeof(MODEL)); if (strcmp(arg, "qn") == 0) { add_quant_noise(aexp, model, 1, model->L, 1); update_snr_calc(aexp, &aexp->model_uq[2], model); } /* print training samples that can be > train.txt for training VQ */ if (strcmp(arg, "train") == 0) print_sparse_amp_error(aexp, model, 00.0); /* VQ of amplitudes, no interpolation (ie 10ms rate) */ if (strcmp(arg, "vq") == 0) { sparse_vq_amp(aexp, model); vq_interp(aexp, model, 0); update_snr_calc(aexp, &aexp->model_uq[1], model); } /* VQ of amplitudes, interpolation (ie 20ms rate) */ if (strcmp(arg, "vqi") == 0) { sparse_vq_amp(aexp, model); vq_interp(aexp, model, 1); update_snr_calc(aexp, &aexp->model_uq[1], model); } /* gain/shape VQ of amplitudes, 10ms rate (doesn't work that well) */ if (strcmp(arg, "gsvq") == 0) { gain_shape_sparse_vq_amp(aexp, model); vq_interp(aexp, model, 0); update_snr_calc(aexp, &aexp->model_uq[1], model); } if (strcmp(arg, "smooth") == 0) { smooth_samples(aexp, model, 0); update_snr_calc(aexp, &aexp->model_uq[2], model); } if (strcmp(arg, "smoothtrain") == 0) { smooth_samples(aexp, model, 1); //update_snr_calc(aexp, &aexp->model_uq[2], model); } if (strcmp(arg, "smoothvq") == 0) { smooth_samples(aexp, model, 2); update_snr_calc(aexp, &aexp->model_uq[2], model); } if (strcmp(arg, "smoothamp") == 0) { smooth_amp(aexp, model); update_snr_calc(aexp, &aexp->model_uq[2], model); } /* update states */ for(m=1; m<=model->L; m++) aexp->A_prev[m] = model->A[m]; aexp->frames++; for(i=0; i<3; i++) aexp->model_uq[i] = aexp->model_uq[i+1]; }
void phase_experiment(struct PEXP *pexp, MODEL *model, char *arg) { int m; float before[MAX_AMP], best_Wo; assert(pexp != NULL); memcpy(before, &model->phi[0], sizeof(float)*MAX_AMP); if (strcmp(arg,"q3") == 0) { quant_phases(model, 1, model->L, 3); update_snr_calc(pexp, model, before); update_variance_calc(pexp, model, before); } if (strcmp(arg,"dec2") == 0) { if ((pexp->frames % 2) != 0) { predict_phases(pexp, model, 1, model->L); update_snr_calc(pexp, model, before); update_variance_calc(pexp, model, before); } } if (strcmp(arg,"repeat") == 0) { if ((pexp->frames % 2) != 0) { repeat_phases(pexp, model); update_snr_calc(pexp, model, before); update_variance_calc(pexp, model, before); } } if (strcmp(arg,"vq") == 0) { sparse_vq_pred_error(pexp, model); update_snr_calc(pexp, model, before); update_variance_calc(pexp, model, before); } if (strcmp(arg,"pred") == 0) predict_phases_state(pexp, model, 1, model->L); if (strcmp(arg,"pred1k") == 0) predict_phases(pexp, model, 1, model->L/4); if (strcmp(arg,"smooth") == 0) { smooth_phase(pexp, model,0); update_snr_calc(pexp, model, before); } if (strcmp(arg,"smoothtrain") == 0) smooth_phase(pexp, model,1); if (strcmp(arg,"smoothvq") == 0) { smooth_phase(pexp, model,2); update_snr_calc(pexp, model, before); } if (strcmp(arg,"smooth2") == 0) smooth_phase2(pexp, model); if (strcmp(arg,"smooth3") == 0) smooth_phase3(pexp, model); if (strcmp(arg,"smooth4") == 0) smooth_phase4(model); if (strcmp(arg,"vqsmooth3") == 0) { sparse_vq_pred_error(pexp, model); smooth_phase3(pexp, model); } if (strcmp(arg,"cb1") == 0) { cb_phase1(pexp, model); update_snr_calc(pexp, model, before); } if (strcmp(arg,"top") == 0) { //top_amp(pexp, model, 1, model->L/4, 4, 1); //top_amp(pexp, model, model->L/4, model->L/3, 4, 1); //top_amp(pexp, model, model->L/3+1, model->L/2, 4, 1); //top_amp(pexp, model, model->L/2, model->L, 6, 1); //rand_phases(model, model->L/2, 3*model->L/4); //struct_phases(pexp, model, model->L/2, 3*model->L/4); //update_snr_calc(pexp, model, before); } if (strcmp(arg,"pred23") == 0) { predict_phases2(pexp, model, model->L/2, model->L); update_snr_calc(pexp, model, before); } if (strcmp(arg,"struct23") == 0) { struct_phases(pexp, model, model->L/2, 3*model->L/4 ); update_snr_calc(pexp, model, before); } if (strcmp(arg,"addnoise") == 0) { int m; float max; max = 0; for(m=1; m<=model->L; m++) if (model->A[m] > max) max = model->A[m]; max = 20.0*log10(max); for(m=1; m<=model->L; m++) if (20.0*log10(model->A[m]) < (max-20)) { model->phi[m] += (PI/4)*(1.0 -2.0*rand()/RAND_MAX); //printf("m %d\n", m); } } /* normalise phases */ for(m=1; m<=model->L; m++) model->phi[m] = atan2(sin(model->phi[m]), cos(model->phi[m])); /* update states */ //best_Wo = refine_Wo(pexp, model, model->L/2, model->L); pexp->phi1 += N*model->Wo; for(m=1; m<=model->L; m++) pexp->phi_prev[m] = model->phi[m]; pexp->Wo_prev = model->Wo; pexp->frames++; pexp->prev_model = *model; }