Changes in / [3aac194:d8b1161]


Ignore:
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • python/tests/test_dct.py

    r3aac194 rd8b1161  
    2525
    2626        >>> from scipy.fftpack import dct
    27         >>> a_in = np.arange(8).astype(aubio.float_type)
     27        >>> a_in = np.arange(8).astype('float32')
    2828        >>> precomputed = dct(a_in, norm='ortho')
    2929        """
    3030        N = len(precomputed_arange)
    3131        a_dct = aubio.dct(8)
    32         a_in = np.arange(8).astype(aubio.float_type)
     32        a_in = np.arange(8).astype('float32')
    3333        a_expected = aubio.fvec(precomputed_arange)
    3434        assert_almost_equal(a_dct(a_in), a_expected, decimal=6)
     
    3737        """ test that dct(somevector) is computed correctly """
    3838        a_dct = aubio.dct(16)
    39         a_in = np.ones(16).astype(aubio.float_type)
     39        a_in = np.ones(16).astype('float32')
    4040        a_in[1] = 0
    4141        a_in[3] = np.pi
     
    4646        """ test that some_ones vector can be recontructed """
    4747        a_dct = aubio.dct(16)
    48         a_in = np.ones(16).astype(aubio.float_type)
     48        a_in = np.ones(16).astype('float32')
    4949        a_in[1] = 0
    5050        a_in[3] = np.pi
  • src/spectral/dct_accelerate.c

    r3aac194 rd8b1161  
    2929#endif
    3030
    31 struct _aubio_dct_accelerate_t {
     31struct _aubio_dct_t {
    3232  uint_t size;
    3333  fvec_t *tmp;
     
    3636};
    3737
    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);
     38aubio_dct_t * new_aubio_dct (uint_t size) {
     39  aubio_dct_t * s = AUBIO_NEW(aubio_dct_t);
    4440
    4541  if ((sint_t)size < 16 || !aubio_is_power_of_two(size)) {
    4642    AUBIO_ERR("dct: can only create with sizes greater than 16 and"
    47         " that are powers of two, requested %d\n", size);
     43        "that are powers of two, requested %d\n", size);
    4844    goto beach;
    4945  }
     
    6056
    6157beach:
    62   del_aubio_dct_accelerate(s);
     58  del_aubio_dct(s);
    6359  return NULL;
    6460}
    6561
    66 void del_aubio_dct_accelerate(aubio_dct_accelerate_t *s) {
     62void del_aubio_dct(aubio_dct_t *s) {
    6763  if (s->setup) vDSP_DFT_DestroySetup(s->setup);
    6864  if (s->setupInv) vDSP_DFT_DestroySetup(s->setupInv);
     
    7066}
    7167
    72 void aubio_dct_accelerate_do(aubio_dct_accelerate_t *s, const fvec_t *input, fvec_t *output) {
     68void aubio_dct_do(aubio_dct_t *s, const fvec_t *input, fvec_t *output) {
    7369
    7470  vDSP_DCT_Execute(s->setup, (const float *)input->data, (float *)output->data);
     
    8379}
    8480
    85 void aubio_dct_accelerate_rdo(aubio_dct_accelerate_t *s, const fvec_t *input, fvec_t *output) {
     81void aubio_dct_rdo(aubio_dct_t *s, const fvec_t *input, fvec_t *output) {
    8682
    8783  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>
    42
    53int main (void)
     
    75  int return_code = 0;
    86  uint_t win_s = 32; // window size
    9   uint_t i, j, n_iters = 10; // number of iterations
     7  uint_t i, n_iters = 10; // number of iterations
    108  // create dct object
    119  aubio_dct_t * dct = new_aubio_dct(win_s);
     
    1311  fvec_t * in = new_fvec (win_s); // input buffer
    1412  fvec_t * dctout = new_fvec (win_s); // output buffer
    15   fvec_t * out = new_fvec (win_s); // input buffer
    1613
    1714  if (!dct || !in || !dctout) {
     
    2320  for (i = 0; i < n_iters; i++) {
    2421    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);
    3123  }
    32 
     24  fvec_print(dctout);
    3325  fvec_print(in);
    34   fvec_print(dctout);
    35   fvec_print(out);
    36 
    3726  del_fvec(dctout);
    3827  del_fvec(in);
    39   del_fvec(out);
     28
    4029  del_aubio_dct(dct);
    41 
    4230  return return_code;
    4331}
Note: See TracChangeset for help on using the changeset viewer.