Changes in / [3aac194:d8b1161]
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
python/tests/test_dct.py
r3aac194 rd8b1161 25 25 26 26 >>> from scipy.fftpack import dct 27 >>> a_in = np.arange(8).astype( aubio.float_type)27 >>> a_in = np.arange(8).astype('float32') 28 28 >>> precomputed = dct(a_in, norm='ortho') 29 29 """ 30 30 N = len(precomputed_arange) 31 31 a_dct = aubio.dct(8) 32 a_in = np.arange(8).astype( aubio.float_type)32 a_in = np.arange(8).astype('float32') 33 33 a_expected = aubio.fvec(precomputed_arange) 34 34 assert_almost_equal(a_dct(a_in), a_expected, decimal=6) … … 37 37 """ test that dct(somevector) is computed correctly """ 38 38 a_dct = aubio.dct(16) 39 a_in = np.ones(16).astype( aubio.float_type)39 a_in = np.ones(16).astype('float32') 40 40 a_in[1] = 0 41 41 a_in[3] = np.pi … … 46 46 """ test that some_ones vector can be recontructed """ 47 47 a_dct = aubio.dct(16) 48 a_in = np.ones(16).astype( aubio.float_type)48 a_in = np.ones(16).astype('float32') 49 49 a_in[1] = 0 50 50 a_in[3] = np.pi -
src/spectral/dct_accelerate.c
r3aac194 rd8b1161 29 29 #endif 30 30 31 struct _aubio_dct_ accelerate_t {31 struct _aubio_dct_t { 32 32 uint_t size; 33 33 fvec_t *tmp; … … 36 36 }; 37 37 38 typedef struct _aubio_dct_accelerate_t aubio_dct_accelerate_t; 39 40 void del_aubio_dct_accelerate (aubio_dct_accelerate_t *s); 41 42 aubio_dct_accelerate_t * new_aubio_dct_accelerate (uint_t size) { 43 aubio_dct_accelerate_t * s = AUBIO_NEW(aubio_dct_accelerate_t); 38 aubio_dct_t * new_aubio_dct (uint_t size) { 39 aubio_dct_t * s = AUBIO_NEW(aubio_dct_t); 44 40 45 41 if ((sint_t)size < 16 || !aubio_is_power_of_two(size)) { 46 42 AUBIO_ERR("dct: can only create with sizes greater than 16 and" 47 " 43 "that are powers of two, requested %d\n", size); 48 44 goto beach; 49 45 } … … 60 56 61 57 beach: 62 del_aubio_dct _accelerate(s);58 del_aubio_dct(s); 63 59 return NULL; 64 60 } 65 61 66 void del_aubio_dct _accelerate(aubio_dct_accelerate_t *s) {62 void del_aubio_dct(aubio_dct_t *s) { 67 63 if (s->setup) vDSP_DFT_DestroySetup(s->setup); 68 64 if (s->setupInv) vDSP_DFT_DestroySetup(s->setupInv); … … 70 66 } 71 67 72 void aubio_dct_ accelerate_do(aubio_dct_accelerate_t *s, const fvec_t *input, fvec_t *output) {68 void aubio_dct_do(aubio_dct_t *s, const fvec_t *input, fvec_t *output) { 73 69 74 70 vDSP_DCT_Execute(s->setup, (const float *)input->data, (float *)output->data); … … 83 79 } 84 80 85 void aubio_dct_ accelerate_rdo(aubio_dct_accelerate_t *s, const fvec_t *input, fvec_t *output) {81 void aubio_dct_rdo(aubio_dct_t *s, const fvec_t *input, fvec_t *output) { 86 82 87 83 output->data[0] = input->data[0] / SQRT(1./s->size); -
tests/src/spectral/test-dct.c
r3aac194 rd8b1161 1 #include <math.h> 2 #include "aubio.h" 3 #include "utils_tests.h" 1 #include <aubio.h> 4 2 5 3 int main (void) … … 7 5 int return_code = 0; 8 6 uint_t win_s = 32; // window size 9 uint_t i, j,n_iters = 10; // number of iterations7 uint_t i, n_iters = 10; // number of iterations 10 8 // create dct object 11 9 aubio_dct_t * dct = new_aubio_dct(win_s); … … 13 11 fvec_t * in = new_fvec (win_s); // input buffer 14 12 fvec_t * dctout = new_fvec (win_s); // output buffer 15 fvec_t * out = new_fvec (win_s); // input buffer16 13 17 14 if (!dct || !in || !dctout) { … … 23 20 for (i = 0; i < n_iters; i++) { 24 21 aubio_dct_do (dct, in, dctout); 25 aubio_dct_rdo (dct, dctout, out); 26 for (j = 0; j < in->length; j++) { 27 if (fabsf(in->data[j] - out->data[j]) > 10.e-4) { 28 fprintf(stderr, "dct reconstruction failed\n"); 29 } 30 } 22 aubio_dct_rdo (dct, dctout, in); 31 23 } 32 24 fvec_print(dctout); 33 25 fvec_print(in); 34 fvec_print(dctout);35 fvec_print(out);36 37 26 del_fvec(dctout); 38 27 del_fvec(in); 39 del_fvec(out); 28 40 29 del_aubio_dct(dct); 41 42 30 return return_code; 43 31 }
Note: See TracChangeset
for help on using the changeset viewer.