3 * sushivision copyright (C) 2006-2007 Monty <monty@xiph.org>
5 * sushivision is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * sushivision is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with sushivision; see the file COPYING. If not, write to the
17 * Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
25 #include "sushivision.h"
27 static void chirp(double *d
, double *ret
){
38 double phase_t
= (phas
+ freq
*t
*M_PI
*2 + dpha
*t
*t
);
39 double cycles
= floor(phase_t
/(M_PI
*2));
40 double norm_phase
= phase_t
- cycles
*M_PI
*2;
41 if(norm_phase
> M_PI
) norm_phase
-= M_PI
*2;
43 ret
[2] = (ampl
+ damp
*t
);
44 ret
[1] = norm_phase
/ M_PI
;
45 ret
[0] = sin(phase_t
) * (ampl
+ damp
*t
);
48 int sv_submain(int argc
, char *argv
[]){
50 sv_instance_t
*s
= sv_new(0,"chirp");
52 sv_dim_t
*d0
= sv_dim_new(s
,0,"initial Hz",SV_DIM_NO_X
);
53 sv_dim_make_scale(d0
,4,(double []){1,10,100,1000},NULL
,0);
55 sv_dim_t
*d1
= sv_dim_new(s
,1,"initial amplitude",SV_DIM_NO_X
);
56 sv_dim_make_scale(d1
,3,(double []){0,.1,1},NULL
,0);
57 sv_dim_set_value(d1
,1,1.0);
59 sv_dim_t
*d2
= sv_dim_new(s
,2,"initial phase",SV_DIM_NO_X
);
60 sv_dim_make_scale(d2
,3,(double []){-M_PI
,0,M_PI
},NULL
,0);
62 sv_dim_t
*d3
= sv_dim_new(s
,3,"delta amplitude",SV_DIM_NO_X
);
63 sv_dim_make_scale(d3
,3,(double []){0,-.1,-1},NULL
,0);
65 sv_dim_t
*d4
= sv_dim_new(s
,4,"delta frequency",SV_DIM_NO_X
);
66 sv_dim_make_scale(d4
,7,(double []){-100*M_PI
,-10*M_PI
,-M_PI
,0,M_PI
,10*M_PI
,100*M_PI
},
67 (char *[]){"-100pi","-10pi","-pi","0","pi","10pi","100pi"}, 0);
69 sv_dim_t
*d5
= sv_dim_new(s
,5,"seconds",0);
70 sv_dim_make_scale(d5
,5,(double []){0,.001,.01,.1,1},NULL
,0);
72 sv_func_t
*f
= sv_func_new(s
, 0, 3, chirp
, 0);
74 sv_obj_t
*o0
= sv_obj_new(s
,0,"sin",
78 sv_obj_make_scale(o0
, 2,(double []){-1.5, 1.5}, NULL
, 0);
80 sv_obj_t
*o1
= sv_obj_new(s
,1,"phase",
84 sv_obj_make_scale(o1
, 2,(double []){-1.0, 1.0}, NULL
, 0);
86 sv_obj_t
*o2
= sv_obj_new(s
,2,"amplitude",
90 sv_obj_make_scale(o2
, 2,(double []){-1.0, 1.0}, NULL
, 0);
92 sv_panel_new_1d(s
,2,"chirp",
93 s
->objective_list
[0]->scale
,
94 (sv_obj_t
*[]){o0
,o1
,o2
,NULL
},
95 (sv_dim_t
*[]){d0
,d1
,d2
,d3
,d4
,d5
,NULL
},