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.
24 #include "sushivision.h"
27 #define todB(x) ((x)==0?-400.f:log((x)*(x))*4.34294480f)
29 /* time, blocksz, amp_0, amp_del, freq_0, phase_0, phase_del */
32 static void fourier_objective(double *d
, double *ret
){
38 for(i
=0;i
<funcsize
;i
++){
39 im_obj
+= function
[i
] * sin(i
*d
[4]*2*M_PI
);
40 re_obj
+= function
[i
] * cos(i
*d
[4]*2*M_PI
);
46 obj
= sqrt(im_obj
*im_obj
+ re_obj
*re_obj
);
52 static double objective(double *d){
59 static int time_callback(sushiv_dimension_t
*d
){
62 return 1; // indicate that default processing chain should continue
65 static int blocksize_callback(sushiv_dimension_t
*d
){
68 return 1; // indicate that default processing chain should continue
71 int sushiv_submain(int argc
, char *argv
[]){
75 double phasechirp
= 0;
78 for(i
=0;i
<funcsize
;i
++){
82 function
[i
]=sin(phi
)*.1;
86 s
=sushiv_new_instance();
88 sushiv_new_dimension(s
,0,"time",
89 4,(double []){0,1024,2048,4096},
91 SUSHIV_DIM_NO_X
|SUSHIV_DIM_NO_Y
);
92 sushiv_new_dimension(s
,1,"blocksize",
93 8,(double []){64,128,256,512,1024,2048,4096,8192},
95 SUSHIV_DIM_NO_X
|SUSHIV_DIM_NO_Y
);
97 sushiv_new_dimension(s
,2,"amplitude",
98 9,(double []){-96,-84,-72,-60,-48,-36,-24,-12,0},
100 sushiv_new_dimension(s
,3,"amplitude delta",
101 9,(double []){-96,-48,-24,-12,0,12,24,48,96},
103 sushiv_new_dimension(s
,4,"frequency",
104 6,(double []){0,.1,.2,.3,.4,.5},
106 sushiv_new_dimension(s
,5,"phase",
107 3,(double []){-.5,0,.5},
109 sushiv_new_dimension(s
,6,"phase delta",
110 3,(double []){-10,0,10},
113 sushiv_new_objective(s
,0,"fourier",
114 8,(double []){-96,-48,-36,-24,-12,-6,0,6},
115 fourier_objective
,0);
116 //sushiv_new_objective(s,1,"fit",fit_objective,0);
117 //sushiv_new_objective(s,2,"waveform",fourier_objective,0);
119 sushiv_new_panel_2d(s
,0,"fourier objective",
121 (int []){2,3,4,5,6,-1},
124 /*sushiv_linked_panel_1d(s,1,"fourier x slice",8,
125 (double []){-96,-48,-36,-24,-12,-6,0,6},
128 sushiv_linked_panel_1d(s,2,"fourier y slice",8,
129 (double []){-96,-48,-36,-24,-12,-6,0,6},
132 sushiv_new_panel_1d(s,3,"input block",8,
133 (double []){-96,-48,-36,-24,-12,-6,0,6},