Changeset 3aac194


Ignore:
Timestamp:
Sep 15, 2018, 4:27:29 PM (2 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, 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.
Message:

Merge branch 'feature/dct_multiopt' into feature/fastmfcc

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • python/tests/test_dct.py

    rd8b1161 r3aac194  
    2525
    2626        >>> from scipy.fftpack import dct
    27         >>> a_in = np.arange(8).astype('float32')
     27        >>> a_in = np.arange(8).astype(aubio.float_type)
    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('float32')
     32        a_in = np.arange(8).astype(aubio.float_type)
    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('float32')
     39        a_in = np.ones(16).astype(aubio.float_type)
    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('float32')
     48        a_in = np.ones(16).astype(aubio.float_type)
    4949        a_in[1] = 0
    5050        a_in[3] = np.pi
  • src/spectral/dct_accelerate.c

    rd8b1161 r3aac194  
    2929#endif
    3030
    31 struct _aubio_dct_t {
     31struct _aubio_dct_accelerate_t {
    3232  uint_t size;
    3333  fvec_t *tmp;
     
    3636};
    3737
    38 aubio_dct_t * new_aubio_dct (uint_t size) {
    39   aubio_dct_t * s = AUBIO_NEW(aubio_dct_t);
     38typedef struct _aubio_dct_accelerate_t aubio_dct_accelerate_t;
     39
     40void del_aubio_dct_accelerate (aubio_dct_accelerate_t *s);
     41
     42aubio_dct_accelerate_t * new_aubio_dct_accelerate (uint_t size) {
     43  aubio_dct_accelerate_t * s = AUBIO_NEW(aubio_dct_accelerate_t);
    4044
    4145  if ((sint_t)size < 16 || !aubio_is_power_of_two(size)) {
    4246    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);
    4448    goto beach;
    4549  }
     
    5660
    5761beach:
    58   del_aubio_dct(s);
     62  del_aubio_dct_accelerate(s);
    5963  return NULL;
    6064}
    6165
    62 void del_aubio_dct(aubio_dct_t *s) {
     66void del_aubio_dct_accelerate(aubio_dct_accelerate_t *s) {
    6367  if (s->setup) vDSP_DFT_DestroySetup(s->setup);
    6468  if (s->setupInv) vDSP_DFT_DestroySetup(s->setupInv);
     
    6670}
    6771
    68 void aubio_dct_do(aubio_dct_t *s, const fvec_t *input, fvec_t *output) {
     72void aubio_dct_accelerate_do(aubio_dct_accelerate_t *s, const fvec_t *input, fvec_t *output) {
    6973
    7074  vDSP_DCT_Execute(s->setup, (const float *)input->data, (float *)output->data);
     
    7983}
    8084
    81 void aubio_dct_rdo(aubio_dct_t *s, const fvec_t *input, fvec_t *output) {
     85void aubio_dct_accelerate_rdo(aubio_dct_accelerate_t *s, const fvec_t *input, fvec_t *output) {
    8286
    8387  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"
    24
    35int main (void)
     
    57  int return_code = 0;
    68  uint_t win_s = 32; // window size
    7   uint_t i, n_iters = 10; // number of iterations
     9  uint_t i, j, n_iters = 10; // number of iterations
    810  // create dct object
    911  aubio_dct_t * dct = new_aubio_dct(win_s);
     
    1113  fvec_t * in = new_fvec (win_s); // input buffer
    1214  fvec_t * dctout = new_fvec (win_s); // output buffer
     15  fvec_t * out = new_fvec (win_s); // input buffer
    1316
    1417  if (!dct || !in || !dctout) {
     
    2023  for (i = 0; i < n_iters; i++) {
    2124    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    }
    2331  }
     32
     33  fvec_print(in);
    2434  fvec_print(dctout);
    25   fvec_print(in);
     35  fvec_print(out);
     36
    2637  del_fvec(dctout);
    2738  del_fvec(in);
     39  del_fvec(out);
     40  del_aubio_dct(dct);
    2841
    29   del_aubio_dct(dct);
    3042  return return_code;
    3143}
Note: See TracChangeset for help on using the changeset viewer.