Commit f33c3adb authored by IOhannes m zmölnig's avatar IOhannes m zmölnig

convert CR to LF

parent 5d1f146e
#include "fftease.h" void bloscbank( t_float *S, t_float *O, int D, t_float iD, t_float *lf, t_float *la, t_float *index, t_float *tab, int len, t_float synt, int lo, int hi ) { int amp,freq,chan, i; t_float a,ainc,f,finc,address; for ( chan = lo; chan < hi; chan++ ) { freq = ( amp = ( chan << 1 ) ) + 1; if ( S[amp] > synt ){ finc = ( S[freq] - ( f = lf[chan] ) )* iD; ainc = ( S[amp] - ( a = la[chan] ) )* iD; address = index[chan]; for ( i = 0; i < D ; i++ ) { O[i] += a*tab[ (int) address ]; address += f; while ( address >= len ) address -= len; while ( address < 0 ) address += len; a += ainc; f += finc; } lf[chan] = S[freq]; la[chan] = S[amp]; index[chan] = address; } } }
\ No newline at end of file
#include "fftease.h"
void bloscbank( t_float *S, t_float *O, int D, t_float iD, t_float *lf, t_float *la, t_float *index, t_float *tab,
int len, t_float synt, int lo, int hi )
{
int amp,freq,chan, i;
t_float a,ainc,f,finc,address;
for ( chan = lo; chan < hi; chan++ ) {
freq = ( amp = ( chan << 1 ) ) + 1;
if ( S[amp] > synt ){
finc = ( S[freq] - ( f = lf[chan] ) )* iD;
ainc = ( S[amp] - ( a = la[chan] ) )* iD;
address = index[chan];
for ( i = 0; i < D ; i++ ) {
O[i] += a*tab[ (int) address ];
address += f;
while ( address >= len )
address -= len;
while ( address < 0 )
address += len;
a += ainc;
f += finc;
}
lf[chan] = S[freq];
la[chan] = S[amp];
index[chan] = address;
}
}
}
\ No newline at end of file
#include "fftease.h" /* If forward is true, rfft replaces 2*N real data points in x with N complex values representing the positive frequency half of their Fourier spectrum, with x[1] replaced with the real part of the Nyquist frequency value. If forward is false, rfft expects x to contain a positive frequency spectrum arranged as before, and replaces it with 2*N real values. N MUST be a power of 2. */ void rfft( t_float *x, int N, int forward ) { t_float c1,c2, h1r,h1i, h2r,h2i, wr,wi, wpr,wpi, temp, theta; t_float xr,xi; int i, i1,i2,i3,i4, N2p1; static int first = 1;/*t_float PI, TWOPI;*/ void cfft(); if ( first ) { first = 0; } theta = PI/N; wr = 1.; wi = 0.; c1 = 0.5; if ( forward ) { c2 = -0.5; cfft( x, N, forward ); xr = x[0]; xi = x[1]; } else { c2 = 0.5; theta = -theta; xr = x[1]; xi = 0.; x[1] = 0.; } wpr = -2.*pow( sin( 0.5*theta ), 2. ); wpi = sin( theta ); N2p1 = (N<<1) + 1; for ( i = 0; i <= N>>1; i++ ) { i1 = i<<1; i2 = i1 + 1; i3 = N2p1 - i2; i4 = i3 + 1; if ( i == 0 ) { h1r = c1*(x[i1] + xr ); h1i = c1*(x[i2] - xi ); h2r = -c2*(x[i2] + xi ); h2i = c2*(x[i1] - xr ); x[i1] = h1r + wr*h2r - wi*h2i; x[i2] = h1i + wr*h2i + wi*h2r; xr = h1r - wr*h2r + wi*h2i; xi = -h1i + wr*h2i + wi*h2r; } else { h1r = c1*(x[i1] + x[i3] ); h1i = c1*(x[i2] - x[i4] ); h2r = -c2*(x[i2] + x[i4] ); h2i = c2*(x[i1] - x[i3] ); x[i1] = h1r + wr*h2r - wi*h2i; x[i2] = h1i + wr*h2i + wi*h2r; x[i3] = h1r - wr*h2r + wi*h2i; x[i4] = -h1i + wr*h2i + wi*h2r; } wr = (temp = wr)*wpr - wi*wpi + wr; wi = wi*wpr + temp*wpi + wi; } if ( forward ) x[1] = xr; else cfft( x, N, forward ); } /* cfft replaces t_float array x containing NC complex values (2*NC t_float values alternating real, imagininary, etc.) by its Fourier transform if forward is true, or by its inverse Fourier transform if forward is false, using a recursive Fast Fourier transform method due to Danielson and Lanczos. NC MUST be a power of 2. */ void cfft( t_float *x, int NC, int forward ) { t_float wr,wi, wpr,wpi, theta, scale; int mmax, ND, m, i,j, delta; void bitreverse(); ND = NC<<1; bitreverse( x, ND ); for ( mmax = 2; mmax < ND; mmax = delta ) { delta = mmax<<1; theta = TWOPI/( forward? mmax : -mmax ); wpr = -2.*pow( sin( 0.5*theta ), 2. ); wpi = sin( theta ); wr = 1.; wi = 0.; for ( m = 0; m < mmax; m += 2 ) { register t_float rtemp, itemp; for ( i = m; i < ND; i += delta ) { j = i + mmax; rtemp = wr*x[j] - wi*x[j+1]; itemp = wr*x[j+1] + wi*x[j]; x[j] = x[i] - rtemp; x[j+1] = x[i+1] - itemp; x[i] += rtemp; x[i+1] += itemp; } wr = (rtemp = wr)*wpr - wi*wpi + wr; wi = wi*wpr + rtemp*wpi + wi; } } /* scale output */ scale = forward ? 1./ND : 2.; { register t_float *xi=x, *xe=x+ND; while ( xi < xe ) *xi++ *= scale; } } /* bitreverse places t_float array x containing N/2 complex values into bit-reversed order */ void bitreverse( t_float *x, int N ) { t_float rtemp,itemp; int i,j, m; for ( i = j = 0; i < N; i += 2, j += m ) { if ( j > i ) { rtemp = x[j]; itemp = x[j+1]; /* complex exchange */ x[j] = x[i]; x[j+1] = x[i+1]; x[i] = rtemp; x[i+1] = itemp; } for ( m = N>>1; m >= 2 && j >= m; m >>= 1 ) j -= m; } }
\ No newline at end of file
#include "fftease.h"
/* If forward is true, rfft replaces 2*N real data points in x with
N complex values representing the positive frequency half of their
Fourier spectrum, with x[1] replaced with the real part of the Nyquist
frequency value. If forward is false, rfft expects x to contain a
positive frequency spectrum arranged as before, and replaces it with
2*N real values. N MUST be a power of 2. */
void rfft( t_float *x, int N, int forward )
{
t_float c1,c2,
h1r,h1i,
h2r,h2i,
wr,wi,
wpr,wpi,
temp,
theta;
t_float xr,xi;
int i,
i1,i2,i3,i4,
N2p1;
static int first = 1;
/*t_float PI, TWOPI;*/
void cfft();
if ( first ) {
first = 0;
}
theta = PI/N;
wr = 1.;
wi = 0.;
c1 = 0.5;
if ( forward ) {
c2 = -0.5;
cfft( x, N, forward );
xr = x[0];
xi = x[1];
} else {
c2 = 0.5;
theta = -theta;
xr = x[1];
xi = 0.;
x[1] = 0.;
}
wpr = -2.*pow( sin( 0.5*theta ), 2. );
wpi = sin( theta );
N2p1 = (N<<1) + 1;
for ( i = 0; i <= N>>1; i++ ) {
i1 = i<<1;
i2 = i1 + 1;
i3 = N2p1 - i2;
i4 = i3 + 1;
if ( i == 0 ) {
h1r = c1*(x[i1] + xr );
h1i = c1*(x[i2] - xi );
h2r = -c2*(x[i2] + xi );
h2i = c2*(x[i1] - xr );
x[i1] = h1r + wr*h2r - wi*h2i;
x[i2] = h1i + wr*h2i + wi*h2r;
xr = h1r - wr*h2r + wi*h2i;
xi = -h1i + wr*h2i + wi*h2r;
} else {
h1r = c1*(x[i1] + x[i3] );
h1i = c1*(x[i2] - x[i4] );
h2r = -c2*(x[i2] + x[i4] );
h2i = c2*(x[i1] - x[i3] );
x[i1] = h1r + wr*h2r - wi*h2i;
x[i2] = h1i + wr*h2i + wi*h2r;
x[i3] = h1r - wr*h2r + wi*h2i;
x[i4] = -h1i + wr*h2i + wi*h2r;
}
wr = (temp = wr)*wpr - wi*wpi + wr;
wi = wi*wpr + temp*wpi + wi;
}
if ( forward )
x[1] = xr;
else
cfft( x, N, forward );
}
/* cfft replaces t_float array x containing NC complex values
(2*NC t_float values alternating real, imagininary, etc.)
by its Fourier transform if forward is true, or by its
inverse Fourier transform if forward is false, using a
recursive Fast Fourier transform method due to Danielson
and Lanczos. NC MUST be a power of 2. */
void cfft( t_float *x, int NC, int forward )
{
t_float wr,wi,
wpr,wpi,
theta,
scale;
int mmax,
ND,
m,
i,j,
delta;
void bitreverse();
ND = NC<<1;
bitreverse( x, ND );
for ( mmax = 2; mmax < ND; mmax = delta ) {
delta = mmax<<1;
theta = TWOPI/( forward? mmax : -mmax );
wpr = -2.*pow( sin( 0.5*theta ), 2. );
wpi = sin( theta );
wr = 1.;
wi = 0.;
for ( m = 0; m < mmax; m += 2 ) {
register t_float rtemp, itemp;
for ( i = m; i < ND; i += delta ) {
j = i + mmax;
rtemp = wr*x[j] - wi*x[j+1];
itemp = wr*x[j+1] + wi*x[j];
x[j] = x[i] - rtemp;
x[j+1] = x[i+1] - itemp;
x[i] += rtemp;
x[i+1] += itemp;
}
wr = (rtemp = wr)*wpr - wi*wpi + wr;
wi = wi*wpr + rtemp*wpi + wi;
}
}
/* scale output */
scale = forward ? 1./ND : 2.;
{ register t_float *xi=x, *xe=x+ND;
while ( xi < xe )
*xi++ *= scale;
}
}
/* bitreverse places t_float array x containing N/2 complex values
into bit-reversed order */
void bitreverse( t_float *x, int N )
{
t_float rtemp,itemp;
int i,j,
m;
for ( i = j = 0; i < N; i += 2, j += m ) {
if ( j > i ) {
rtemp = x[j]; itemp = x[j+1]; /* complex exchange */
x[j] = x[i]; x[j+1] = x[i+1];
x[i] = rtemp; x[i+1] = itemp;
}
for ( m = N>>1; m >= 2 && j >= m; m >>= 1 )
j -= m;
}
}
#include "fftease.h" void leanconvert(t_fftease *fft) { int real, imag, amp, phase; t_float a, b; int i; t_float *buffer = fft->buffer; t_float *channel = fft->channel; int N2 = fft->N2; for ( i = 0; i <= N2; i++ ) { imag = phase = ( real = amp = i<<1 ) + 1; a = ( i == N2 ? buffer[1] : buffer[real] ); b = ( i == 0 || i == N2 ? 0. : buffer[imag] ); channel[amp] = hypot( a, b ); channel[phase] = -atan2( b, a ); } }
\ No newline at end of file
#include "fftease.h"
void leanconvert(t_fftease *fft)
{
int real, imag, amp, phase;
t_float a, b;
int i;
t_float *buffer = fft->buffer;
t_float *channel = fft->channel;
int N2 = fft->N2;
for ( i = 0; i <= N2; i++ ) {
imag = phase = ( real = amp = i<<1 ) + 1;
a = ( i == N2 ? buffer[1] : buffer[real] );
b = ( i == 0 || i == N2 ? 0. : buffer[imag] );
channel[amp] = hypot( a, b );
channel[phase] = -atan2( b, a );
}
}
#include "fftease.h" extern void post(const char *fmt, ...); void limit_fftsize(int *N, int *Nw, char *OBJECT_NAME) { if(*N > MAX_N){ // post("%s: N set to maximum FFT size of %d",OBJECT_NAME,MAX_N); *N = MAX_N; } if(*Nw > MAX_Nw){ // post("%s: Nw set to maximum window size of %d",OBJECT_NAME,MAX_Nw); *Nw = MAX_Nw; } } int fftease_FFT_size( int testfft ) { int test = 2; if( testfft <= 0 ) return DEFAULT_FFTEASE_FFTSIZE; while( test < testfft && test < FFTEASE_MAX_FFTSIZE){ test *= 2; } if( test != testfft ){ post("incorrect FFT size specified, using %d", test); } if( test == FFTEASE_MAX_FFTSIZE){ post("fftsize capped at maximum: %d", test); } return test; }
\ No newline at end of file
#include "fftease.h"
extern void post(const char *fmt, ...);
void limit_fftsize(int *N, int *Nw, char *OBJECT_NAME)
{
if(*N > MAX_N){
// post("%s: N set to maximum FFT size of %d",OBJECT_NAME,MAX_N);
*N = MAX_N;
}
if(*Nw > MAX_Nw){
// post("%s: Nw set to maximum window size of %d",OBJECT_NAME,MAX_Nw);
*Nw = MAX_Nw;
}
}
int fftease_FFT_size( int testfft )
{
int test = 2;
if( testfft <= 0 )
return DEFAULT_FFTEASE_FFTSIZE;
while( test < testfft && test < FFTEASE_MAX_FFTSIZE){
test *= 2;
}
if( test != testfft ){
post("incorrect FFT size specified, using %d", test);
}
if( test == FFTEASE_MAX_FFTSIZE){
post("fftsize capped at maximum: %d", test);
}
return test;
}
\ No newline at end of file
#include "fftease.h" void makewindows( t_float *H, t_float *A, t_float *S, int Nw, int N, int I ) { int i ; t_float sum ; for ( i = 0 ; i < Nw ; i++ ) H[i] = A[i] = S[i] = 0.54 - 0.46*cos( TWOPI*i/(Nw - 1) ) ; if ( Nw > N ) { t_float x ; x = -(Nw - 1)/2. ; for ( i = 0 ; i < Nw ; i++, x += 1. ) if ( x != 0. ) { A[i] *= N*sin( PI*x/N )/(PI*x) ; if ( I ) S[i] *= I*sin( PI*x/I )/(PI*x) ; } } for ( sum = i = 0 ; i < Nw ; i++ ) sum += A[i] ; for ( i = 0 ; i < Nw ; i++ ) { t_float afac = 2./sum ; t_float sfac = Nw > N ? 1./afac : afac ; A[i] *= afac ; S[i] *= sfac ; } if ( Nw <= N && I ) { for ( sum = i = 0 ; i < Nw ; i += I ) sum += S[i]*S[i] ; for ( sum = 1./sum, i = 0 ; i < Nw ; i++ ) S[i] *= sum ; } } void makehamming( t_float *H, t_float *A, t_float *S, int Nw, int N, int I, int odd ) { int i; t_float sum ; if (odd) { for ( i = 0 ; i < Nw ; i++ ) H[i] = A[i] = S[i] = sqrt(0.54 - 0.46*cos( TWOPI*i/(Nw - 1) )); } else { for ( i = 0 ; i < Nw ; i++ ) H[i] = A[i] = S[i] = 0.54 - 0.46*cos( TWOPI*i/(Nw - 1) ); } if ( Nw > N ) { t_float x ; x = -(Nw - 1)/2. ; for ( i = 0 ; i < Nw ; i++, x += 1. ) if ( x != 0. ) { A[i] *= N*sin( PI*x/N )/(PI*x) ; if ( I ) S[i] *= I*sin( PI*x/I )/(PI*x) ; } } for ( sum = i = 0 ; i < Nw ; i++ ) sum += A[i] ; for ( i = 0 ; i < Nw ; i++ ) { t_float afac = 2./sum ; t_float sfac = Nw > N ? 1./afac : afac ; A[i] *= afac ; S[i] *= sfac ; } if ( Nw <= N && I ) { for ( sum = i = 0 ; i < Nw ; i += I ) sum += S[i]*S[i] ; for ( sum = 1./sum, i = 0 ; i < Nw ; i++ ) S[i] *= sum ; } } void makehanning( t_float *H, t_float *A, t_float *S, int Nw, int N, int I, int odd ) { int i; t_float sum ; if (odd) { for ( i = 0 ; i < Nw ; i++ ) H[i] = A[i] = S[i] = sqrt(0.5 * (1. + cos(PI + TWOPI * i / (Nw - 1)))); } else { for ( i = 0 ; i < Nw ; i++ ) H[i] = A[i] = S[i] = 0.5 * (1. + cos(PI + TWOPI * i / (Nw - 1))); } if ( Nw > N ) { t_float x ; x = -(Nw - 1)/2. ; for ( i = 0 ; i < Nw ; i++, x += 1. ) if ( x != 0. ) { A[i] *= N*sin( PI*x/N )/(PI*x) ; if ( I ) S[i] *= I*sin( PI*x/I )/(PI*x) ; } } for ( sum = i = 0 ; i < Nw ; i++ ) sum += A[i] ; for ( i = 0 ; i < Nw ; i++ ) { t_float afac = 2./sum ; t_float sfac = Nw > N ? 1./afac : afac ; A[i] *= afac ; S[i] *= sfac ; } if ( Nw <= N && I ) { for ( sum = i = 0 ; i < Nw ; i += I ) sum += S[i]*S[i] ; for ( sum = 1./sum, i = 0 ; i < Nw ; i++ ) S[i] *= sum ; } }
\ No newline at end of file
#include "fftease.h"
void makewindows( t_float *H, t_float *A, t_float *S, int Nw, int N, int I )
{
int i ;
t_float sum ;
for ( i = 0 ; i < Nw ; i++ )
H[i] = A[i] = S[i] = 0.54 - 0.46*cos( TWOPI*i/(Nw - 1) ) ;
if ( Nw > N ) {
t_float x ;
x = -(Nw - 1)/2. ;
for ( i = 0 ; i < Nw ; i++, x += 1. )
if ( x != 0. ) {
A[i] *= N*sin( PI*x/N )/(PI*x) ;
if ( I )
S[i] *= I*sin( PI*x/I )/(PI*x) ;
}
}
for ( sum = i = 0 ; i < Nw ; i++ )
sum += A[i] ;
for ( i = 0 ; i < Nw ; i++ ) {
t_float afac = 2./sum ;
t_float sfac = Nw > N ? 1./afac : afac ;
A[i] *= afac ;
S[i] *= sfac ;
}
if ( Nw <= N && I ) {
for ( sum = i = 0 ; i < Nw ; i += I )
sum += S[i]*S[i] ;
for ( sum = 1./sum, i = 0 ; i < Nw ; i++ )
S[i] *= sum ;
}
}
void makehamming( t_float *H, t_float *A, t_float *S, int Nw, int N, int I, int odd )
{
int i;
t_float sum ;
if (odd) {
for ( i = 0 ; i < Nw ; i++ )
H[i] = A[i] = S[i] = sqrt(0.54 - 0.46*cos( TWOPI*i/(Nw - 1) ));
}
else {
for ( i = 0 ; i < Nw ; i++ )
H[i] = A[i] = S[i] = 0.54 - 0.46*cos( TWOPI*i/(Nw - 1) );
}
if ( Nw > N ) {
t_float x ;
x = -(Nw - 1)/2. ;
for ( i = 0 ; i < Nw ; i++, x += 1. )
if ( x != 0. ) {
A[i] *= N*sin( PI*x/N )/(PI*x) ;
if ( I )
S[i] *= I*sin( PI*x/I )/(PI*x) ;
}
}
for ( sum = i = 0 ; i < Nw ; i++ )
sum += A[i] ;
for ( i = 0 ; i < Nw ; i++ ) {
t_float afac = 2./sum ;
t_float sfac = Nw > N ? 1./afac : afac ;
A[i] *= afac ;
S[i] *= sfac ;
}
if ( Nw <= N && I ) {
for ( sum = i = 0 ; i < Nw ; i += I )
sum += S[i]*S[i] ;
for ( sum = 1./sum, i = 0 ; i < Nw ; i++ )
S[i] *= sum ;
}
}
void makehanning( t_float *H, t_float *A, t_float *S, int Nw, int N, int I, int odd )
{
int i;
t_float sum ;
if (odd) {
for ( i = 0 ; i < Nw ; i++ )
H[i] = A[i] = S[i] = sqrt(0.5 * (1. + cos(PI + TWOPI * i / (Nw - 1))));
}
else {
for ( i = 0 ; i < Nw ; i++ )
H[i] = A[i] = S[i] = 0.5 * (1. + cos(PI + TWOPI * i / (Nw - 1)));
}
if ( Nw > N ) {
t_float x ;
x = -(Nw - 1)/2. ;
for ( i = 0 ; i < Nw ; i++, x += 1. )
if ( x != 0. ) {
A[i] *= N*sin( PI*x/N )/(PI*x) ;
if ( I )
S[i] *= I*sin( PI*x/I )/(PI*x) ;
}
}
for ( sum = i = 0 ; i < Nw ; i++ )
sum += A[i] ;
for ( i = 0 ; i < Nw ; i++ ) {
t_float afac = 2./sum ;
t_float sfac = Nw > N ? 1./afac : afac ;
A[i] *= afac ;
S[i] *= sfac ;
}
if ( Nw <= N && I ) {
for ( sum = i = 0 ; i < Nw ; i += I )
sum += S[i]*S[i] ;
for ( sum = 1./sum, i = 0 ; i < Nw ; i++ )
S[i] *= sum ;
}
}
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment