File: legacy.c

package info (click to toggle)
pd-fftease 3.0.1-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,112 kB
  • sloc: ansic: 14,552; makefile: 208; sh: 93; cpp: 19; perl: 9
file content (83 lines) | stat: -rw-r--r-- 1,560 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "fftease.h"

void old_overlapadd( float *I, int N, float *W, float *O, int Nw, int n )

{
 int i ;
    while ( n < 0 )
    n += N ;
    n %= N ;
    for ( i = 0 ; i < Nw ; i++ ) {
    O[i] += I[n]*W[i] ;
    if ( ++n == N )
        n = 0 ;
    }
}


void old_convert(float *S, float *C, int N2, float *lastphase, float fundamental, float factor )
{
  float     phase,
        phasediff;
  int       real,
        imag,
        amp,
        freq;
  float     a,
        b;
  int       i;


    for ( i = 0; i <= N2; i++ ) {
      imag = freq = ( real = amp = i<<1 ) + 1;
      a = ( i == N2 ? S[1] : S[real] );
      b = ( i == 0 || i == N2 ? 0. : S[imag] );

      C[amp] = hypot( a, b );
      if ( C[amp] == 0. )
    phasediff = 0.;
      else {
    phasediff = ( phase = -atan2( b, a ) ) - lastphase[i];
    lastphase[i] = phase;

    while ( phasediff > PI )
      phasediff -= TWOPI;
    while ( phasediff < -PI )
      phasediff += TWOPI;
      }
      C[freq] = phasediff*factor + i*fundamental;
    }
}



void old_unconvert( float *C, float *S, int N2, float *lastphase, float fundamental, float factor )

{
  int       i,
        real,
        imag,
        amp,
        freq;
  float     mag,
        phase;
double sin(), cos();

    for ( i = 0; i <= N2; i++ ) {

    imag = freq = ( real = amp = i<<1 ) + 1;

    if ( i == N2 )
      real = 1;

    mag = C[amp];
    lastphase[i] += C[freq] - i*fundamental;
    phase = lastphase[i]*factor;
    S[real] = mag*cos( phase );

    if ( i != N2 )
      S[imag] = -mag*sin( phase );

    }

}