Changeset 3aac194
- Timestamp:
- Sep 15, 2018, 4:27:29 PM (6 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master
- Children:
- c9ca2608
- Parents:
- d8b1161 (diff), 95e3cba (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
python/tests/test_dct.py
rd8b1161 r3aac194 25 25 26 26 >>> from scipy.fftpack import dct 27 >>> a_in = np.arange(8).astype( 'float32')27 >>> a_in = np.arange(8).astype(aubio.float_type) 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( 'float32')32 a_in = np.arange(8).astype(aubio.float_type) 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( 'float32')39 a_in = np.ones(16).astype(aubio.float_type) 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( 'float32')48 a_in = np.ones(16).astype(aubio.float_type) 49 49 a_in[1] = 0 50 50 a_in[3] = np.pi -
src/spectral/dct_accelerate.c
rd8b1161 r3aac194 29 29 #endif 30 30 31 struct _aubio_dct_ t {31 struct _aubio_dct_accelerate_t { 32 32 uint_t size; 33 33 fvec_t *tmp; … … 36 36 }; 37 37 38 aubio_dct_t * new_aubio_dct (uint_t size) { 39 aubio_dct_t * s = AUBIO_NEW(aubio_dct_t); 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); 40 44 41 45 if ((sint_t)size < 16 || !aubio_is_power_of_two(size)) { 42 46 AUBIO_ERR("dct: can only create with sizes greater than 16 and" 43 " that are powers of two, requested %d\n", size);47 " that are powers of two, requested %d\n", size); 44 48 goto beach; 45 49 } … … 56 60 57 61 beach: 58 del_aubio_dct (s);62 del_aubio_dct_accelerate(s); 59 63 return NULL; 60 64 } 61 65 62 void del_aubio_dct (aubio_dct_t *s) {66 void del_aubio_dct_accelerate(aubio_dct_accelerate_t *s) { 63 67 if (s->setup) vDSP_DFT_DestroySetup(s->setup); 64 68 if (s->setupInv) vDSP_DFT_DestroySetup(s->setupInv); … … 66 70 } 67 71 68 void aubio_dct_ do(aubio_dct_t *s, const fvec_t *input, fvec_t *output) {72 void aubio_dct_accelerate_do(aubio_dct_accelerate_t *s, const fvec_t *input, fvec_t *output) { 69 73 70 74 vDSP_DCT_Execute(s->setup, (const float *)input->data, (float *)output->data); … … 79 83 } 80 84 81 void aubio_dct_ rdo(aubio_dct_t *s, const fvec_t *input, fvec_t *output) {85 void aubio_dct_accelerate_rdo(aubio_dct_accelerate_t *s, const fvec_t *input, fvec_t *output) { 82 86 83 87 output->data[0] = input->data[0] / SQRT(1./s->size); -
tests/src/spectral/test-dct.c
rd8b1161 r3aac194 1 #include <aubio.h> 1 #include <math.h> 2 #include "aubio.h" 3 #include "utils_tests.h" 2 4 3 5 int main (void) … … 5 7 int return_code = 0; 6 8 uint_t win_s = 32; // window size 7 uint_t i, n_iters = 10; // number of iterations9 uint_t i, j, n_iters = 10; // number of iterations 8 10 // create dct object 9 11 aubio_dct_t * dct = new_aubio_dct(win_s); … … 11 13 fvec_t * in = new_fvec (win_s); // input buffer 12 14 fvec_t * dctout = new_fvec (win_s); // output buffer 15 fvec_t * out = new_fvec (win_s); // input buffer 13 16 14 17 if (!dct || !in || !dctout) { … … 20 23 for (i = 0; i < n_iters; i++) { 21 24 aubio_dct_do (dct, in, dctout); 22 aubio_dct_rdo (dct, dctout, in); 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 } 23 31 } 32 33 fvec_print(in); 24 34 fvec_print(dctout); 25 fvec_print(in); 35 fvec_print(out); 36 26 37 del_fvec(dctout); 27 38 del_fvec(in); 39 del_fvec(out); 40 del_aubio_dct(dct); 28 41 29 del_aubio_dct(dct);30 42 return return_code; 31 43 }
Note: See TracChangeset
for help on using the changeset viewer.