Changeset 5c6b264


Ignore:
Timestamp:
Dec 23, 2013, 2:29:12 AM (10 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:
4087d54, 634c12f
Parents:
3a00b1e7
Message:

src/spectral/ooura_fft8g.c: use float when double is not needed

Location:
src/spectral
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/spectral/fft.c

    r3a00b1e7 r5c6b264  
    8585#else                         // using OOURA
    8686// let's use ooura instead
    87 extern void rdft(int, int, double *, int *, double *);
     87extern void rdft(int, int, smpl_t *, int *, smpl_t *);
    8888
    8989#endif /* HAVE_ACCELERATE */
     
    110110#endif
    111111#else                         // using OOURA
    112   double *in, *out;
    113   double *w;
     112  smpl_t *in, *out;
     113  smpl_t *w;
    114114  int *ip;
    115115#endif /* HAVE_ACCELERATE */
     
    171171  s->fft_size = winsize / 2 + 1;
    172172  s->compspec = new_fvec(winsize);
    173   s->in    = AUBIO_ARRAY(double, s->winsize);
    174   s->out   = AUBIO_ARRAY(double, s->winsize);
     173  s->in    = AUBIO_ARRAY(smpl_t, s->winsize);
     174  s->out   = AUBIO_ARRAY(smpl_t, s->winsize);
    175175  s->ip    = AUBIO_ARRAY(int   , s->fft_size);
    176   s->w     = AUBIO_ARRAY(double, s->fft_size);
     176  s->w     = AUBIO_ARRAY(smpl_t, s->fft_size);
    177177  s->ip[0] = 0;
    178178#endif /* HAVE_ACCELERATE */
  • src/spectral/ooura_fft8g.c

    r3a00b1e7 r5c6b264  
     1// 2 modifications made for aubio:
     2//  - replace all 'double' with 'smpl_t'
     3//  - include "aubio_priv.h" (for config.h and types.h)
     4
     5#include "aubio_priv.h"
     6
    17/*
    28Fast Fourier/Cosine/Sine Transform
     
    1521    dfst: Sine Transform of RDFT (Real Anti-symmetric DFT)
    1622function prototypes
    17     void cdft(int, int, double *, int *, double *);
    18     void rdft(int, int, double *, int *, double *);
    19     void ddct(int, int, double *, int *, double *);
    20     void ddst(int, int, double *, int *, double *);
    21     void dfct(int, double *, double *, int *, double *);
    22     void dfst(int, double *, double *, int *, double *);
     23    void cdft(int, int, smpl_t *, int *, smpl_t *);
     24    void rdft(int, int, smpl_t *, int *, smpl_t *);
     25    void ddct(int, int, smpl_t *, int *, smpl_t *);
     26    void ddst(int, int, smpl_t *, int *, smpl_t *);
     27    void dfct(int, smpl_t *, smpl_t *, int *, smpl_t *);
     28    void dfst(int, smpl_t *, smpl_t *, int *, smpl_t *);
    2329
    2430
     
    4046        2*n            :data length (int)
    4147                        n >= 1, n = power of 2
    42         a[0...2*n-1]   :input/output data (double *)
     48        a[0...2*n-1]   :input/output data (smpl_t *)
    4349                        input data
    4450                            a[2*j] = Re(x[j]),
     
    5359                            2+(1<<(int)(log(n+0.5)/log(2))/2).
    5460                        ip[0],ip[1] are pointers of the cos/sin table.
    55         w[0...n/2-1]   :cos/sin table (double *)
     61        w[0...n/2-1]   :cos/sin table (smpl_t *)
    5662                        w[],ip[] are initialized if ip[0] == 0.
    5763    [remark]
     
    8591        n              :data length (int)
    8692                        n >= 2, n = power of 2
    87         a[0...n-1]     :input/output data (double *)
     93        a[0...n-1]     :input/output data (smpl_t *)
    8894                        <case1>
    8995                            output data
     
    102108                            2+(1<<(int)(log(n/2+0.5)/log(2))/2).
    103109                        ip[0],ip[1] are pointers of the cos/sin table.
    104         w[0...n/2-1]   :cos/sin table (double *)
     110        w[0...n/2-1]   :cos/sin table (smpl_t *)
    105111                        w[],ip[] are initialized if ip[0] == 0.
    106112    [remark]
     
    131137        n              :data length (int)
    132138                        n >= 2, n = power of 2
    133         a[0...n-1]     :input/output data (double *)
     139        a[0...n-1]     :input/output data (smpl_t *)
    134140                        output data
    135141                            a[k] = C[k], 0<=k<n
     
    140146                            2+(1<<(int)(log(n/2+0.5)/log(2))/2).
    141147                        ip[0],ip[1] are pointers of the cos/sin table.
    142         w[0...n*5/4-1] :cos/sin table (double *)
     148        w[0...n*5/4-1] :cos/sin table (smpl_t *)
    143149                        w[],ip[] are initialized if ip[0] == 0.
    144150    [remark]
     
    170176        n              :data length (int)
    171177                        n >= 2, n = power of 2
    172         a[0...n-1]     :input/output data (double *)
     178        a[0...n-1]     :input/output data (smpl_t *)
    173179                        <case1>
    174180                            input data
     
    187193                            2+(1<<(int)(log(n/2+0.5)/log(2))/2).
    188194                        ip[0],ip[1] are pointers of the cos/sin table.
    189         w[0...n*5/4-1] :cos/sin table (double *)
     195        w[0...n*5/4-1] :cos/sin table (smpl_t *)
    190196                        w[],ip[] are initialized if ip[0] == 0.
    191197    [remark]
     
    210216        n              :data length - 1 (int)
    211217                        n >= 2, n = power of 2
    212         a[0...n]       :input/output data (double *)
     218        a[0...n]       :input/output data (smpl_t *)
    213219                        output data
    214220                            a[k] = C[k], 0<=k<=n
    215         t[0...n/2]     :work area (double *)
     221        t[0...n/2]     :work area (smpl_t *)
    216222        ip[0...*]      :work area for bit reversal (int *)
    217223                        length of ip >= 2+sqrt(n/4)
     
    220226                            2+(1<<(int)(log(n/4+0.5)/log(2))/2).
    221227                        ip[0],ip[1] are pointers of the cos/sin table.
    222         w[0...n*5/8-1] :cos/sin table (double *)
     228        w[0...n*5/8-1] :cos/sin table (smpl_t *)
    223229                        w[],ip[] are initialized if ip[0] == 0.
    224230    [remark]
     
    246252        n              :data length + 1 (int)
    247253                        n >= 2, n = power of 2
    248         a[0...n-1]     :input/output data (double *)
     254        a[0...n-1]     :input/output data (smpl_t *)
    249255                        output data
    250256                            a[k] = S[k], 0<k<n
    251257                        (a[0] is used for work area)
    252         t[0...n/2-1]   :work area (double *)
     258        t[0...n/2-1]   :work area (smpl_t *)
    253259        ip[0...*]      :work area for bit reversal (int *)
    254260                        length of ip >= 2+sqrt(n/4)
     
    257263                            2+(1<<(int)(log(n/4+0.5)/log(2))/2).
    258264                        ip[0],ip[1] are pointers of the cos/sin table.
    259         w[0...n*5/8-1] :cos/sin table (double *)
     265        w[0...n*5/8-1] :cos/sin table (smpl_t *)
    260266                        w[],ip[] are initialized if ip[0] == 0.
    261267    [remark]
     
    276282
    277283
    278 void cdft(int n, int isgn, double *a, int *ip, double *w)
    279 {
    280     void makewt(int nw, int *ip, double *w);
    281     void bitrv2(int n, int *ip, double *a);
    282     void bitrv2conj(int n, int *ip, double *a);
    283     void cftfsub(int n, double *a, double *w);
    284     void cftbsub(int n, double *a, double *w);
     284void cdft(int n, int isgn, smpl_t *a, int *ip, smpl_t *w)
     285{
     286    void makewt(int nw, int *ip, smpl_t *w);
     287    void bitrv2(int n, int *ip, smpl_t *a);
     288    void bitrv2conj(int n, int *ip, smpl_t *a);
     289    void cftfsub(int n, smpl_t *a, smpl_t *w);
     290    void cftbsub(int n, smpl_t *a, smpl_t *w);
    285291   
    286292    if (n > (ip[0] << 2)) {
     
    301307
    302308
    303 void rdft(int n, int isgn, double *a, int *ip, double *w)
    304 {
    305     void makewt(int nw, int *ip, double *w);
    306     void makect(int nc, int *ip, double *c);
    307     void bitrv2(int n, int *ip, double *a);
    308     void cftfsub(int n, double *a, double *w);
    309     void cftbsub(int n, double *a, double *w);
    310     void rftfsub(int n, double *a, int nc, double *c);
    311     void rftbsub(int n, double *a, int nc, double *c);
     309void rdft(int n, int isgn, smpl_t *a, int *ip, smpl_t *w)
     310{
     311    void makewt(int nw, int *ip, smpl_t *w);
     312    void makect(int nc, int *ip, smpl_t *c);
     313    void bitrv2(int n, int *ip, smpl_t *a);
     314    void cftfsub(int n, smpl_t *a, smpl_t *w);
     315    void cftbsub(int n, smpl_t *a, smpl_t *w);
     316    void rftfsub(int n, smpl_t *a, int nc, smpl_t *c);
     317    void rftbsub(int n, smpl_t *a, int nc, smpl_t *c);
    312318    int nw, nc;
    313     double xi;
     319    smpl_t xi;
    314320   
    315321    nw = ip[0];
     
    348354
    349355
    350 void ddct(int n, int isgn, double *a, int *ip, double *w)
    351 {
    352     void makewt(int nw, int *ip, double *w);
    353     void makect(int nc, int *ip, double *c);
    354     void bitrv2(int n, int *ip, double *a);
    355     void cftfsub(int n, double *a, double *w);
    356     void cftbsub(int n, double *a, double *w);
    357     void rftfsub(int n, double *a, int nc, double *c);
    358     void rftbsub(int n, double *a, int nc, double *c);
    359     void dctsub(int n, double *a, int nc, double *c);
     356void ddct(int n, int isgn, smpl_t *a, int *ip, smpl_t *w)
     357{
     358    void makewt(int nw, int *ip, smpl_t *w);
     359    void makect(int nc, int *ip, smpl_t *c);
     360    void bitrv2(int n, int *ip, smpl_t *a);
     361    void cftfsub(int n, smpl_t *a, smpl_t *w);
     362    void cftbsub(int n, smpl_t *a, smpl_t *w);
     363    void rftfsub(int n, smpl_t *a, int nc, smpl_t *c);
     364    void rftbsub(int n, smpl_t *a, int nc, smpl_t *c);
     365    void dctsub(int n, smpl_t *a, int nc, smpl_t *c);
    360366    int j, nw, nc;
    361     double xr;
     367    smpl_t xr;
    362368   
    363369    nw = ip[0];
     
    407413
    408414
    409 void ddst(int n, int isgn, double *a, int *ip, double *w)
    410 {
    411     void makewt(int nw, int *ip, double *w);
    412     void makect(int nc, int *ip, double *c);
    413     void bitrv2(int n, int *ip, double *a);
    414     void cftfsub(int n, double *a, double *w);
    415     void cftbsub(int n, double *a, double *w);
    416     void rftfsub(int n, double *a, int nc, double *c);
    417     void rftbsub(int n, double *a, int nc, double *c);
    418     void dstsub(int n, double *a, int nc, double *c);
     415void ddst(int n, int isgn, smpl_t *a, int *ip, smpl_t *w)
     416{
     417    void makewt(int nw, int *ip, smpl_t *w);
     418    void makect(int nc, int *ip, smpl_t *c);
     419    void bitrv2(int n, int *ip, smpl_t *a);
     420    void cftfsub(int n, smpl_t *a, smpl_t *w);
     421    void cftbsub(int n, smpl_t *a, smpl_t *w);
     422    void rftfsub(int n, smpl_t *a, int nc, smpl_t *c);
     423    void rftbsub(int n, smpl_t *a, int nc, smpl_t *c);
     424    void dstsub(int n, smpl_t *a, int nc, smpl_t *c);
    419425    int j, nw, nc;
    420     double xr;
     426    smpl_t xr;
    421427   
    422428    nw = ip[0];
     
    466472
    467473
    468 void dfct(int n, double *a, double *t, int *ip, double *w)
    469 {
    470     void makewt(int nw, int *ip, double *w);
    471     void makect(int nc, int *ip, double *c);
    472     void bitrv2(int n, int *ip, double *a);
    473     void cftfsub(int n, double *a, double *w);
    474     void rftfsub(int n, double *a, int nc, double *c);
    475     void dctsub(int n, double *a, int nc, double *c);
     474void dfct(int n, smpl_t *a, smpl_t *t, int *ip, smpl_t *w)
     475{
     476    void makewt(int nw, int *ip, smpl_t *w);
     477    void makect(int nc, int *ip, smpl_t *c);
     478    void bitrv2(int n, int *ip, smpl_t *a);
     479    void cftfsub(int n, smpl_t *a, smpl_t *w);
     480    void rftfsub(int n, smpl_t *a, int nc, smpl_t *c);
     481    void dctsub(int n, smpl_t *a, int nc, smpl_t *c);
    476482    int j, k, l, m, mh, nw, nc;
    477     double xr, xi, yr, yi;
     483    smpl_t xr, xi, yr, yi;
    478484   
    479485    nw = ip[0];
     
    562568
    563569
    564 void dfst(int n, double *a, double *t, int *ip, double *w)
    565 {
    566     void makewt(int nw, int *ip, double *w);
    567     void makect(int nc, int *ip, double *c);
    568     void bitrv2(int n, int *ip, double *a);
    569     void cftfsub(int n, double *a, double *w);
    570     void rftfsub(int n, double *a, int nc, double *c);
    571     void dstsub(int n, double *a, int nc, double *c);
     570void dfst(int n, smpl_t *a, smpl_t *t, int *ip, smpl_t *w)
     571{
     572    void makewt(int nw, int *ip, smpl_t *w);
     573    void makect(int nc, int *ip, smpl_t *c);
     574    void bitrv2(int n, int *ip, smpl_t *a);
     575    void cftfsub(int n, smpl_t *a, smpl_t *w);
     576    void rftfsub(int n, smpl_t *a, int nc, smpl_t *c);
     577    void dstsub(int n, smpl_t *a, int nc, smpl_t *c);
    572578    int j, k, l, m, mh, nw, nc;
    573     double xr, xi, yr, yi;
     579    smpl_t xr, xi, yr, yi;
    574580   
    575581    nw = ip[0];
     
    654660#include <math.h>
    655661
    656 void makewt(int nw, int *ip, double *w)
    657 {
    658     void bitrv2(int n, int *ip, double *a);
     662void makewt(int nw, int *ip, smpl_t *w)
     663{
     664    void bitrv2(int n, int *ip, smpl_t *a);
    659665    int j, nwh;
    660     double delta, x, y;
     666    smpl_t delta, x, y;
    661667   
    662668    ip[0] = nw;
     
    690696
    691697
    692 void makect(int nc, int *ip, double *c)
     698void makect(int nc, int *ip, smpl_t *c)
    693699{
    694700    int j, nch;
    695     double delta;
     701    smpl_t delta;
    696702   
    697703    ip[1] = nc;
     
    712718
    713719
    714 void bitrv2(int n, int *ip, double *a)
     720void bitrv2(int n, int *ip, smpl_t *a)
    715721{
    716722    int j, j1, k, k1, l, m, m2;
    717     double xr, xi, yr, yi;
     723    smpl_t xr, xi, yr, yi;
    718724   
    719725    ip[0] = 0;
     
    812818
    813819
    814 void bitrv2conj(int n, int *ip, double *a)
     820void bitrv2conj(int n, int *ip, smpl_t *a)
    815821{
    816822    int j, j1, k, k1, l, m, m2;
    817     double xr, xi, yr, yi;
     823    smpl_t xr, xi, yr, yi;
    818824   
    819825    ip[0] = 0;
     
    921927
    922928
    923 void cftfsub(int n, double *a, double *w)
    924 {
    925     void cft1st(int n, double *a, double *w);
    926     void cftmdl(int n, int l, double *a, double *w);
     929void cftfsub(int n, smpl_t *a, smpl_t *w)
     930{
     931    void cft1st(int n, smpl_t *a, smpl_t *w);
     932    void cftmdl(int n, int l, smpl_t *a, smpl_t *w);
    927933    int j, j1, j2, j3, l;
    928     double x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i;
     934    smpl_t x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i;
    929935   
    930936    l = 2;
     
    973979
    974980
    975 void cftbsub(int n, double *a, double *w)
    976 {
    977     void cft1st(int n, double *a, double *w);
    978     void cftmdl(int n, int l, double *a, double *w);
     981void cftbsub(int n, smpl_t *a, smpl_t *w)
     982{
     983    void cft1st(int n, smpl_t *a, smpl_t *w);
     984    void cftmdl(int n, int l, smpl_t *a, smpl_t *w);
    979985    int j, j1, j2, j3, j4, j5, j6, j7, l;
    980     double wn4r, x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i,
     986    smpl_t wn4r, x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i,
    981987        y0r, y0i, y1r, y1i, y2r, y2i, y3r, y3i,
    982988        y4r, y4i, y5r, y5i, y6r, y6i, y7r, y7i;
     
    10901096
    10911097
    1092 void cft1st(int n, double *a, double *w)
     1098void cft1st(int n, smpl_t *a, smpl_t *w)
    10931099{
    10941100    int j, k1;
    1095     double wn4r, wtmp, wk1r, wk1i, wk2r, wk2i, wk3r, wk3i,
     1101    smpl_t wn4r, wtmp, wk1r, wk1i, wk2r, wk2i, wk3r, wk3i,
    10961102        wk4r, wk4i, wk5r, wk5i, wk6r, wk6i, wk7r, wk7i;
    1097     double x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i,
     1103    smpl_t x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i,
    10981104        y0r, y0i, y1r, y1i, y2r, y2i, y3r, y3i,
    10991105        y4r, y4i, y5r, y5i, y6r, y6i, y7r, y7i;
     
    13051311
    13061312
    1307 void cftmdl(int n, int l, double *a, double *w)
     1313void cftmdl(int n, int l, smpl_t *a, smpl_t *w)
    13081314{
    13091315    int j, j1, j2, j3, j4, j5, j6, j7, k, k1, m;
    1310     double wn4r, wtmp, wk1r, wk1i, wk2r, wk2i, wk3r, wk3i,
     1316    smpl_t wn4r, wtmp, wk1r, wk1i, wk2r, wk2i, wk3r, wk3i,
    13111317        wk4r, wk4i, wk5r, wk5i, wk6r, wk6i, wk7r, wk7i;
    1312     double x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i,
     1318    smpl_t x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i,
    13131319        y0r, y0i, y1r, y1i, y2r, y2i, y3r, y3i,
    13141320        y4r, y4i, y5r, y5i, y6r, y6i, y7r, y7i;
     
    15481554
    15491555
    1550 void rftfsub(int n, double *a, int nc, double *c)
     1556void rftfsub(int n, smpl_t *a, int nc, smpl_t *c)
    15511557{
    15521558    int j, k, kk, ks, m;
    1553     double wkr, wki, xr, xi, yr, yi;
     1559    smpl_t wkr, wki, xr, xi, yr, yi;
    15541560   
    15551561    m = n >> 1;
     
    15731579
    15741580
    1575 void rftbsub(int n, double *a, int nc, double *c)
     1581void rftbsub(int n, smpl_t *a, int nc, smpl_t *c)
    15761582{
    15771583    int j, k, kk, ks, m;
    1578     double wkr, wki, xr, xi, yr, yi;
     1584    smpl_t wkr, wki, xr, xi, yr, yi;
    15791585   
    15801586    a[1] = -a[1];
     
    16001606
    16011607
    1602 void dctsub(int n, double *a, int nc, double *c)
     1608void dctsub(int n, smpl_t *a, int nc, smpl_t *c)
    16031609{
    16041610    int j, k, kk, ks, m;
    1605     double wkr, wki, xr;
     1611    smpl_t wkr, wki, xr;
    16061612   
    16071613    m = n >> 1;
     
    16211627
    16221628
    1623 void dstsub(int n, double *a, int nc, double *c)
     1629void dstsub(int n, smpl_t *a, int nc, smpl_t *c)
    16241630{
    16251631    int j, k, kk, ks, m;
    1626     double wkr, wki, xr;
     1632    smpl_t wkr, wki, xr;
    16271633   
    16281634    m = n >> 1;
Note: See TracChangeset for help on using the changeset viewer.