feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change
on this file since 172b1fe was
5d10ac1,
checked in by Paul Brossier <piem@piem.org>, 11 years ago
|
src/cvec.h: clean up cvec api
|
-
Property mode set to
100644
|
File size:
1.3 KB
|
Rev | Line | |
---|
[4e9101e] | 1 | #include <aubio.h> |
---|
[7e35b37] | 2 | #include "utils_tests.h" |
---|
[4e9101e] | 3 | |
---|
[7e35b37] | 4 | int main () |
---|
| 5 | { |
---|
| 6 | uint_t i, window_size = 16; // window size |
---|
| 7 | utils_init_random(); |
---|
| 8 | cvec_t * complex_vector = new_cvec (window_size); // input buffer |
---|
| 9 | uint_t rand_times = 4; |
---|
[4e9101e] | 10 | |
---|
[7e35b37] | 11 | while (rand_times -- ) { |
---|
| 12 | // fill with random phas and norm |
---|
| 13 | for ( i = 0; i < complex_vector->length; i++ ) { |
---|
| 14 | complex_vector->norm[i] = ( 2. / RAND_MAX * random() - 1. ); |
---|
| 15 | complex_vector->phas[i] = ( 2. / RAND_MAX * random() - 1. ) * M_PI; |
---|
| 16 | } |
---|
| 17 | // print the vector |
---|
| 18 | cvec_print(complex_vector); |
---|
| 19 | } |
---|
| 20 | |
---|
| 21 | // set all vector elements to `0` |
---|
[5d10ac1] | 22 | cvec_norm_zeros(complex_vector); |
---|
[7e35b37] | 23 | for ( i = 0; i < complex_vector->length; i++ ) { |
---|
| 24 | assert( complex_vector->norm[i] == 0. ); |
---|
| 25 | // assert( complex_vector->phas[i] == 0 ); |
---|
| 26 | } |
---|
| 27 | cvec_print(complex_vector); |
---|
[4e9101e] | 28 | |
---|
[7e35b37] | 29 | // set all vector elements to `1` |
---|
[5d10ac1] | 30 | cvec_norm_ones(complex_vector); |
---|
[7e35b37] | 31 | for ( i = 0; i < complex_vector->length; i++ ) { |
---|
| 32 | assert( complex_vector->norm[i] == 1. ); |
---|
| 33 | // assert( complex_vector->phas[i] == 0 ); |
---|
| 34 | } |
---|
| 35 | cvec_print(complex_vector); |
---|
[39a7b26] | 36 | |
---|
| 37 | cvec_zeros(complex_vector); |
---|
[5d10ac1] | 38 | cvec_phas_zeros(complex_vector); |
---|
| 39 | cvec_norm_zeros(complex_vector); |
---|
| 40 | cvec_norm_ones(complex_vector); |
---|
| 41 | cvec_phas_ones(complex_vector); |
---|
[39a7b26] | 42 | cvec_copy(complex_vector, complex_vector); |
---|
| 43 | |
---|
[7e35b37] | 44 | // destroy it |
---|
| 45 | del_cvec(complex_vector); |
---|
| 46 | return 0; |
---|
| 47 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.