tests/src/temporal: avoid crash, clarify
[aubio.git] / tests / src / temporal / test-a_weighting.c
1 #include <aubio.h>
2
3 int main (void)
4 {
5   
6   aubio_filter_t * f;
7
8   uint_t rates[] = { 8000, 16000, 22050, 44100, 96000, 192000};
9   uint_t nrates = 6;
10   uint_t samplerate, i = 0;
11
12   for ( samplerate = rates[i]; i < nrates ; i++ ) {
13     f = new_aubio_filter_a_weighting (samplerate);
14     del_aubio_filter (f);
15
16     f = new_aubio_filter (7);
17     aubio_filter_set_a_weighting (f, samplerate);
18     del_aubio_filter (f);
19   }
20
21   // samplerate unknown
22   f = new_aubio_filter_a_weighting (4200);
23   if (!f) {
24     //PRINT_MSG ("failed creating A-weighting filter with samplerate=4200Hz\n");
25   }
26
27   // order to small
28   f = new_aubio_filter (2);
29   if (aubio_filter_set_a_weighting (f, samplerate) != 0) {
30     //PRINT_MSG ("failed setting filter to A-weighting\n");
31   }
32   del_aubio_filter (f);
33
34   // order to big
35   f = new_aubio_filter (12);
36   if (aubio_filter_set_a_weighting (f, samplerate) != 0) {
37     //PRINT_MSG ("failed setting filter to A-weighting\n");
38   }
39   del_aubio_filter (f);
40
41   return 0;
42 }
43