//-------------------------------------------------- void f0r_set_param_value(f0r_instance_t instance, f0r_param_t param, int param_index) { tp_inst_t* inst = (tp_inst_t*)instance; f0r_param_double* p = (f0r_param_double*) param; int chg,tmpi; float tmpf; chg=0; switch (param_index) { case 0: //type tmpf=*((double*)p); if (tmpf>=1.0) tmpi=(int)tmpf; else tmpi = map_value_forward(tmpf, 0.0, 9.9999); if ((tmpi<0)||(tmpi>9.0)) break; if (inst->type != tmpi) chg=1; inst->type = tmpi; break; case 1: //channel tmpf=*((double*)p); if (tmpf>=1.0) tmpi=(int)tmpf; else tmpi = map_value_forward(tmpf, 0.0, 7.9999); if ((tmpi<0)||(tmpi>7.0)) break; if (inst->chan != tmpi) chg=1; inst->chan = tmpi; case 2: //amplitude tmpf = map_value_forward(*((double*)p), 0.0, 1.0); if (inst->amp != tmpf) chg=1; inst->amp = tmpf; break; case 3: //linear period sweep tmpi = map_value_forward(*((double*)p), 0.0, 1.0); if (inst->linp != tmpi) chg=1; inst->linp = tmpi; break; case 4: //frequency 1 tmpf = map_value_forward(*((double*)p), 0.0, 1.0); if (inst->f1 != tmpf) chg=1; inst->f1 = tmpf; break; case 5: //frequency 2 tmpf = map_value_forward(*((double*)p), 0.0, 1.0); if (inst->f2 != tmpf) chg=1; inst->f2 = tmpf; break; case 6: //aspect type tmpf=*((double*)p); if (tmpf>=1.0) tmpi=(int)tmpf; else tmpi = map_value_forward(tmpf, 0.0, 6.9999); if ((tmpi<0)||(tmpi>6.0)) break; if (inst->aspt != tmpi) chg=1; inst->aspt = tmpi; switch (inst->aspt) //pixel aspect ratio { case 0: inst->par=1.000; break; //square pixels case 1: inst->par=1.067; break; //PAL DV case 2: inst->par=1.455; break; //PAL wide case 3: inst->par=0.889; break; //NTSC DV case 4: inst->par=1.212; break; //NTSC wide case 5: inst->par=1.333; break; //HDV case 6: inst->par=inst->mpar; break; //manual } break; case 7: //manual aspect tmpf = map_value_forward_log(*((double*)p), 0.5, 2.0); if (inst->mpar != tmpf) chg=1; inst->mpar = tmpf; if (inst->aspt==6) inst->par=inst->mpar; break; } if (chg==0) return; switch (inst->type) { case 0: //hor freq ver sweep sweep_v(inst->sl, inst->w, inst->h, 0, inst->amp, inst->linp, inst->par, 0.05, 0.7); break; case 1: //hor freq hor sweep sweep_h(inst->sl, inst->w, inst->h, 0, inst->amp, inst->linp, inst->par, 0.05, 0.7); break; case 2: //ver freq ver sweep sweep_v(inst->sl, inst->w, inst->h, 1, inst->amp, inst->linp, inst->par, 0.05, 0.7); //ver f ver sw break; case 3: //ver freq hor sweep sweep_h(inst->sl, inst->w, inst->h, 1, inst->amp, inst->linp, inst->par, 0.05, 0.7); break; case 4: // "Siemens star" radials(inst->sl, inst->w, inst->h, inst->amp, inst->par, 60.0); break; case 5: //rings outwards rings(inst->sl, inst->w, inst->h, inst->amp, inst->par, inst->linp, 0.05, 0.7); break; case 6: //rings inwards rings(inst->sl, inst->w, inst->h, inst->amp, inst->par, inst->linp, 0.7, 0.05); break; case 7: //uniform 2D spatial frequency diags(inst->sl, inst->w, inst->h, inst->amp, inst->par, inst->f1, inst->f2); break; case 8: // "Nyquist blocks" nblocks(inst->sl, inst->w, inst->h, inst->amp); break; case 9: //square bars at integer Nyquist fractions sqbars(inst->sl, inst->w, inst->h, inst->amp); break; default: break; } }
//-------------------------------------------------- void f0r_set_param_value(f0r_instance_t instance, f0r_param_t param, int param_index) { tp_inst_t* inst = (tp_inst_t*)instance; f0r_param_double* p = (f0r_param_double*) param; int chg,tmpi; float tmpf; chg=0; switch (param_index) { case 0: //type tmpf=*((double*)p); if (tmpf>=1.0) tmpi=(int)tmpf; else tmpi = map_value_forward(tmpf, 0.0, 12.9999); if ((tmpi<0)||(tmpi>12.0)) break; if (inst->type != tmpi) chg=1; inst->type = tmpi; break; case 1: //size 1 tmpi = map_value_forward(*((double*)p), 0.0, 256.0); if (inst->size1 != tmpi) chg=1; inst->size1 = tmpi; break; case 2: //size 2 tmpi = map_value_forward(*((double*)p), 0.0, 64.0); if (inst->size2 != tmpi) chg=1; inst->size2 = tmpi; break; case 3: //negative tmpi = map_value_forward(*((double*)p), 0.0, 1.0); if (inst->neg != tmpi) chg=1; inst->neg = tmpi; make_char2color_table(inst->c2c,inst->neg); break; case 4: //aspect type tmpf=*((double*)p); if (tmpf>=1.0) tmpi=(int)tmpf; else tmpi = map_value_forward(*((double*)p), 0.0, 6.9999); if ((tmpi<0)||(tmpi>6.0)) break; if (inst->aspt != tmpi) chg=1; inst->aspt = tmpi; switch (inst->aspt) //pixel aspect ratio { case 0: inst->par=1.000;break; //square pixels case 1: inst->par=1.067;break; //PAL DV case 2: inst->par=1.455;break; //PAL wide case 3: inst->par=0.889;break; //NTSC DV case 4: inst->par=1.212;break; //NTSC wide case 5: inst->par=1.333;break; //HDV case 6: inst->par=inst->mpar;break; //manual } break; case 5: //manual aspect tmpf = map_value_forward_log(*((double*)p), 0.5, 2.0); if (inst->mpar !=tmpf) chg=1; inst->mpar = tmpf; if (inst->aspt==4) inst->par=inst->mpar; break; } if (chg==0) return; switch (inst->type) { case 0: //checkerboard sah1(inst->sl, inst->w, inst->h, inst->size1, inst->par, 0); break; case 1: //checkerboard with border sah1(inst->sl, inst->w, inst->h, inst->size1, inst->par, 1); break; case 2: //horizontal lines hlines(inst->sl, inst->w, inst->h, inst->size1, inst->size2, inst->par, 1); break; case 3: //vertical lines vlines(inst->sl, inst->w, inst->h, inst->size1, inst->size2, inst->par, 1); break; case 4: //grid mreza(inst->sl, inst->w, inst->h, inst->size1, inst->size2, inst->par); break; case 5: //points pike(inst->sl, inst->w, inst->h, inst->size1, inst->size2, inst->par); break; case 6: //bullseye tarca(inst->sl, inst->w, inst->h, inst->size1, inst->size2+1, inst->par); break; case 7: //edge marks robovi(inst->sl, inst->w, inst->h); break; case 8: //color quadrants are drawn in update() break; case 9: //pixel rulers case 11: rulers(inst->sl, inst->w, inst->h, inst->alpha); break; case 10: //measurement grid case 12: grid(inst->sl, inst->w, inst->h, inst->alpha); break; default: break; } }