Changeset 8701ec3 for tests


Ignore:
Timestamp:
Nov 7, 2007, 5:33:28 PM (17 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
5316012
Parents:
18a82b3
Message:

removed old test-fft.c, moved mfft to new fft

Location:
tests/src
Files:
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • tests/src/Makefile.am

    r18a82b3 r8701ec3  
    77bin_PROGRAMS = \
    88        test-fft \
    9         test-mfft \
    109        test-hist \
    1110        test-scale \
  • tests/src/test-fft.c

    r18a82b3 r8701ec3  
    1 #include <stdlib.h>
    2 #include <math.h>
    3 #include <complex.h>
     1
    42#include <aubio.h>
    53
    6 #define NEW_ARRAY(_t,_n)                (_t*)malloc((_n)*sizeof(_t))
    7 
    8 
    94int main(){
    10         uint_t i,j;
    11         uint_t win_s      = 1024;                       // window size
    12         uint_t channels   = 1;                          // number of channel
    13         fvec_t * in       = new_fvec (win_s, channels); // input buffer
    14         cvec_t * fftgrain = new_cvec (win_s, channels); // fft norm and phase
    15         fvec_t * out      = new_fvec (win_s, channels); // output buffer
    16  
    17         // allocate fft and other memory space
    18         aubio_fft_t * fft      = new_aubio_fft(win_s);    // fft interface
    19         smpl_t * w             = NEW_ARRAY(smpl_t,win_s); // window
    20         // complex spectral data
    21         fft_data_t ** spec     = NEW_ARRAY(fft_data_t*,channels);
    22         for (i=0; i < channels; i++)
    23                 spec[i] = NEW_ARRAY(fft_data_t,win_s);
    24         // initialize the window (see mathutils.c)
    25         aubio_window(w,win_s,aubio_win_hanningz);
    26  
    27         // fill input with some data
    28         in->data[0][win_s/2] = 1;
    29  
    30         // execute stft
    31         for (i=0; i < channels; i++) {
    32                 aubio_fft_do (fft,in->data[i],spec[i],win_s);
    33                 // put norm and phase into fftgrain
    34                 aubio_fft_getnorm(fftgrain->norm[i], spec[i], win_s/2+1);
    35                 aubio_fft_getphas(fftgrain->phas[i], spec[i], win_s/2+1);
    36         }
    37  
    38         // execute inverse fourier transform
    39         for (i=0; i < channels; i++) {
    40                 for (j=0; j<win_s/2+1; j++) {
    41                         spec[i][j]  = cexp(I*aubio_unwrap2pi(fftgrain->phas[i][j]));
    42                         spec[i][j] *= fftgrain->norm[i][j];
    43                 }
    44                 aubio_fft_rdo(fft,spec[i],out->data[i],win_s);
    45         }
    46 
     5        /* allocate some memory */
     6        uint_t win_s      = 4096;                       /* window size        */
     7        uint_t channels   = 100;                        /* number of channels */
     8        fvec_t * in       = new_fvec (win_s, channels); /* input buffer       */
     9        cvec_t * fftgrain = new_cvec (win_s, channels); /* fft norm and phase */
     10        fvec_t * out      = new_fvec (win_s, channels); /* output buffer      */
     11        /* allocate fft and other memory space */
     12        aubio_fft_t * fft = new_aubio_fft(win_s,channels);
     13        /* fill input with some data */
     14        //printf("initialised\n");
     15        /* execute stft */
     16        aubio_fft_do (fft,in,fftgrain);
     17        //printf("computed forward\n");
     18        /* execute inverse fourier transform */
     19        aubio_fft_rdo(fft,fftgrain,out);
     20        //printf("computed backard\n");
     21        del_aubio_fft(fft);
    4722        del_fvec(in);
     23        del_cvec(fftgrain);
    4824        del_fvec(out);
    49         del_cvec(fftgrain);
    50         free(w);
    51         del_aubio_fft(fft);
    52         for (i=0; i < channels; i++)
    53                 free(spec[i]);
    54         free(spec);
     25        //printf("memory freed\n");
    5526        aubio_cleanup();
    5627        return 0;
Note: See TracChangeset for help on using the changeset viewer.