Commit 05f68139 authored by IOhannes m zmölnig's avatar IOhannes m zmölnig

prefix all library functions with "fftease_"

so there is no nameclash with incompatible Pd-exported functions (e.g. rdft())
parent f1d23dbf
......@@ -2,12 +2,12 @@
#include "PenroseOscil.h"
t_float frequencyToIncrement( t_float samplingRate, t_float frequency, int bufferLength ) {
t_float fftease_frequencyToIncrement( t_float samplingRate, t_float frequency, int bufferLength ) {
return (frequency / samplingRate) * (t_float) bufferLength;
}
void makeSineBuffer( t_float *buffer, int bufferLength ) {
void fftease_makeSineBuffer( t_float *buffer, int bufferLength ) {
int i;
......@@ -20,7 +20,7 @@ void makeSineBuffer( t_float *buffer, int bufferLength ) {
}
t_float bufferOscil( t_float *phase, t_float increment, t_float *buffer,
t_float fftease_bufferOscil( t_float *phase, t_float increment, t_float *buffer,
int bufferLength )
{
......
#include "PenroseRand.h"
float rrand(int *seed)
float fftease_rrand(int *seed)
{
int i = ((*seed = *seed * 1103515245 + 12345)>>16) & 077777;
return((float)i/16384. - 1.);
}
float prand(int *seed)
float fftease_prand(int *seed)
{
int i = ((*seed = *seed * 1103515245 + 12345)>>16) & 077777;
return((float)i/32768.);
......
float rrand(int *seed);
float prand(int *seed);
float fftease_rrand(int *seed);
float fftease_prand(int *seed);
#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,
void fftease_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;
......
......@@ -312,9 +312,9 @@ void do_bthresher(t_bthresher *x)
short inf_hold = x->inf_hold;
int i, j;
fold(fft);
rdft(fft,1);
convert(fft);
fftease_fold(fft);
fftease_rdft(fft,1);
fftease_convert(fft);
if( x->first_frame ){
for ( i = 0; i < N+2; i++ ){
composite_frame[i] = channel[i];
......@@ -364,11 +364,11 @@ void do_bthresher(t_bthresher *x)
channel[i] = composite_frame[i];
}
if(fft->obank_flag){
oscbank(fft);
fftease_oscbank(fft);
} else {
unconvert(fft);
rdft(fft,-1);
overlapadd(fft);
fftease_unconvert(fft);
fftease_rdft(fft,-1);
fftease_overlapadd(fft);
}
}
......
......@@ -271,14 +271,14 @@ void do_burrow(t_burrow *x)
/* apply hamming window and fold our window buffer into the fft buffer */
fold(fft);
fold(fft2);
fftease_fold(fft);
fftease_fold(fft2);
/* do an fft */
rdft(fft, 1);
rdft(fft2, 1);
fftease_rdft(fft, 1);
fftease_rdft(fft2, 1);
if (invert) {
......@@ -348,11 +348,11 @@ void do_burrow(t_burrow *x)
/* do an inverse fft */
rdft(fft, -1);
fftease_rdft(fft, -1);
/* dewindow our result */
overlapadd(fft);
fftease_overlapadd(fft);
}
......
......@@ -364,9 +364,9 @@ void do_cavoc27(t_cavoc27 *x)
if( x->capture_flag || (x->capture_lock && ! x->freeze)) {
fold(fft);
rdft(fft,1);
convert(fft);
fftease_fold(fft);
fftease_rdft(fft,1);
fftease_convert(fft);
for( i = 1; i < fft->N+1; i += 2){
tmpchannel[i] = channel[i];
}
......@@ -421,11 +421,11 @@ void do_cavoc27(t_cavoc27 *x)
}
if(fft->obank_flag){
oscbank(fft);
fftease_oscbank(fft);
} else {
unconvert(fft);
rdft(fft, -1);
overlapadd(fft);
fftease_unconvert(fft);
fftease_rdft(fft, -1);
fftease_overlapadd(fft);
}
x->frames_left = frames_left;
......
......@@ -351,11 +351,11 @@ void do_cavoc(t_cavoc *x)
channel[(i*2) + 1] = freqs[i];
channel[i * 2] = amps[i];
}
oscbank(fft);
fftease_oscbank(fft);
} else {
unconvert(fft);
rdft(fft, -1);
overlapadd(fft);
fftease_unconvert(fft);
fftease_rdft(fft, -1);
fftease_overlapadd(fft);
}
}
......
......@@ -125,7 +125,7 @@ void centerring_init(t_centerring *x)
x->ringPhases = (t_float *) calloc((N2 + 1), sizeof(t_float));
x->ringIncrements = (t_float *) calloc((N2 + 1), sizeof(t_float));
x->sineBuffer = (t_float *) calloc((x->bufferLength + 1), sizeof(t_float));
makeSineBuffer(x->sineBuffer, x->bufferLength);
fftease_makeSineBuffer(x->sineBuffer, x->bufferLength);
} else {
x->ringIncrements = (t_float *)realloc((void *)x->ringIncrements, (N2 + 1) * sizeof(t_float));
x->ringPhases = (t_float *)realloc((void *)x->ringPhases, (N2 + 1) * sizeof(t_float));
......@@ -157,9 +157,9 @@ void centerring_adjust( t_centerring *x ) {
for (i=0; i < N2; i++) {
*(ringIncrements+i) =
frequencyToIncrement(
fftease_frequencyToIncrement(
x->frameR,
x->baseFreq * ((rrand(&(x->seed)) * x->bandFreq) + x->constFreq ),
x->baseFreq * ((fftease_rrand(&(x->seed)) * x->bandFreq) + x->constFreq ),
x->bufferLength
);
}
......@@ -180,7 +180,7 @@ void centerring_randphases( t_centerring *x ) {
int i;
for (i=0; i < x->fft->N2; i++)
*((x->ringPhases)+i) = prand(&(x->seed)) * (float) (x->bufferLength);
*((x->ringPhases)+i) = fftease_prand(&(x->seed)) * (float) (x->bufferLength);
}
......@@ -204,8 +204,8 @@ void do_centerring(t_centerring *x)
x->recalc = 0;
fold(fft);
rdft(fft,1);
fftease_fold(fft);
fftease_rdft(fft,1);
/* convert to polar coordinates from complex values */
......@@ -224,8 +224,8 @@ void do_centerring(t_centerring *x)
for (i=0; i < N2; i++) {
even = i<<1;
*(channel + even) *= bufferOscil( ringPhases+i,
*(ringIncrements+i), sineBuffer, bufferLength );
*(channel + even) *= fftease_bufferOscil( ringPhases+i,
*(ringIncrements+i), sineBuffer, bufferLength );
}
/* convert from polar to cartesian */
......@@ -239,8 +239,8 @@ void do_centerring(t_centerring *x)
if ( i != N2 )
*(buffer + odd) = (*(channel + even)) * -sin( *(channel + odd) );
}
rdft(fft,-1);
overlapadd(fft);
fftease_rdft(fft,-1);
fftease_overlapadd(fft);
}
t_int *centerring_perform(t_int *w)
......
......@@ -172,11 +172,11 @@ void do_codepend(t_codepend *x)
if ( x->threshold != 0. )
threshold = x->threshold;
fold(fft);
fold(fft2);
fftease_fold(fft);
fftease_fold(fft2);
rdft(fft, 1);
rdft(fft2, 1);
fftease_rdft(fft, 1);
fftease_rdft(fft2, 1);
if (invert) {
......@@ -256,8 +256,8 @@ void do_codepend(t_codepend *x)
*(bufferOne+odd) = -(*(channelOne+even)) * sin( *(channelOne+odd) );
}
rdft(fft, -1);
overlapadd(fft);
fftease_rdft(fft, -1);
fftease_overlapadd(fft);
}
t_int *codepend_perform(t_int *w)
......
......@@ -12,7 +12,7 @@
to render these frequency values directly in Hz. */
void convert(t_fftease *fft)
void fftease_convert(t_fftease *fft)
{
t_float *buffer = fft->buffer;
t_float *channel = fft->channel;
......
......@@ -130,12 +130,12 @@ void do_cross(t_cross *x)
t_float ingain = 0;
t_float outgain, rescale;
t_float mymult;
fold(fft);
fold(fft2);
rdft(fft,1);
rdft(fft2,1);
fftease_fold(fft);
fftease_fold(fft2);
fftease_rdft(fft,1);
fftease_rdft(fft2,1);
/* changing algorithm for window flexibility */
if(autonorm){
ingain = 0;
......@@ -177,8 +177,8 @@ void do_cross(t_cross *x)
x->normult = mult;
//post("mymult: %f", mymult);
}
rdft(fft, -1);
overlapadd(fft);
fftease_rdft(fft, -1);
fftease_overlapadd(fft);
}
t_int *cross_perform(t_int *w)
......
......@@ -235,9 +235,9 @@ void do_dentist(t_dentist *x)
int N2 = fft->N2;
float sync = x->sync;
fold(fft);
rdft(fft,1);
leanconvert(fft);
fftease_fold(fft);
fftease_rdft(fft,1);
fftease_leanconvert(fft);
if(frames_left > 0 && ramp_frames > 0) {
// INTERPOLATE ACCORDING TO POSITION IN RAMP
......@@ -271,9 +271,9 @@ void do_dentist(t_dentist *x)
sync = 1.0;
}
leanunconvert(fft);
rdft(fft,-1);
overlapadd(fft);
fftease_leanunconvert(fft);
fftease_rdft(fft,-1);
fftease_overlapadd(fft);
x->frames_left = frames_left;
x->sync = sync;
}
......
......@@ -345,9 +345,9 @@ void do_disarrain(t_disarrain *x)
x->reset_flag = 0;
}
fold(fft);
rdft(fft,1);
leanconvert(fft);
fftease_fold(fft);
fftease_rdft(fft,1);
fftease_leanconvert(fft);
// first time for interpolation, just do last frame
......@@ -404,9 +404,9 @@ void do_disarrain(t_disarrain *x)
ival = 0.0;
}
leanunconvert(fft);
rdft(fft,-1);
overlapadd(fft);
fftease_leanunconvert(fft);
fftease_rdft(fft,-1);
fftease_overlapadd(fft);
......
......@@ -219,17 +219,17 @@ void do_disarray(t_disarray *x)
int *shuffle_in = x->shuffle_in;
int *shuffle_out = x->shuffle_out;
fold(fft);
rdft(fft,1);
leanconvert(fft);
fftease_fold(fft);
fftease_rdft(fft,1);
fftease_leanconvert(fft);
for( i = 0; i < shuffle_count ; i++){
tmp = channel[ shuffle_in[ i ] * 2 ];
channel[ shuffle_in[ i ] * 2] = channel[ shuffle_out[ i ] * 2];
channel[ shuffle_out[ i ] * 2] = tmp;
}
leanunconvert(fft);
rdft(fft,-1);
overlapadd(fft);
fftease_leanunconvert(fft);
fftease_rdft(fft,-1);
fftease_overlapadd(fft);
}
......
......@@ -126,9 +126,9 @@ void do_drown(t_drown *x)
t_float frame_peak = 0.0, local_thresh;
int N = fft->N;
fold(fft);
rdft(fft,1);
leanconvert(fft);
fftease_fold(fft);
fftease_rdft(fft,1);
fftease_leanconvert(fft);
if(x->peakflag){
for(i = 0; i < N; i += 2){
if(frame_peak < channel[i])
......@@ -142,9 +142,9 @@ void do_drown(t_drown *x)
if(channel[i] < local_thresh)
channel[i] *= drownmult;
}
leanunconvert(fft);
rdft(fft,-1);
overlapadd(fft);
fftease_leanunconvert(fft);
fftease_rdft(fft,-1);
fftease_overlapadd(fft);
}
t_int *drown_perform(t_int *w)
......
......@@ -242,10 +242,10 @@ void do_enrich(t_enrich *x)
t_fftease *fft = x->fft;
enrich_dolowfreq(x);
enrich_dohighfreq(x);
fold(fft);
rdft(fft,1);
convert(fft);
oscbank(fft);
fftease_fold(fft);
fftease_rdft(fft,1);
fftease_convert(fft);
fftease_oscbank(fft);
}
t_int *enrich_perform(t_int *w)
......
......@@ -114,10 +114,10 @@ void do_ether(t_ether *x)
t_float *channelOne = fft->channel;
t_float *channelTwo = fft2->channel;
fold(fft);
fold(fft2);
rdft(fft,1);
rdft(fft2,1);
fftease_fold(fft);
fftease_fold(fft2);
fftease_rdft(fft,1);
fftease_rdft(fft2,1);
if (invert) {
......@@ -180,8 +180,8 @@ void do_ether(t_ether *x)
if ( i != N2 )
*(bufferOne+odd) = -(*(channelOne+even)) * sin( *(channelOne+odd) );
}
rdft(fft, -1);
overlapadd(fft);
fftease_rdft(fft, -1);
fftease_overlapadd(fft);
}
t_int *ether_perform(t_int *w)
......
......@@ -7,7 +7,7 @@
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 )
void fftease_rfft( t_float *x, int N, int forward )
{
t_float c1,c2,
......@@ -23,7 +23,7 @@ void rfft( t_float *x, int N, int forward )
N2p1;
static int first = 1;
/*t_float PI, TWOPI;*/
void cfft();
void fftease_cfft();
if ( first ) {
......@@ -35,7 +35,7 @@ void cfft();
c1 = 0.5;
if ( forward ) {
c2 = -0.5;
cfft( x, N, forward );
fftease_cfft( x, N, forward );
xr = x[0];
xi = x[1];
} else {
......@@ -78,7 +78,7 @@ void cfft();
if ( forward )
x[1] = xr;
else
cfft( x, N, forward );
fftease_cfft( x, N, forward );
}
/* cfft replaces t_float array x containing NC complex values
......@@ -88,7 +88,7 @@ void cfft();
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 )
void fftease_cfft( t_float *x, int NC, int forward )
{
t_float wr,wi,
......@@ -101,10 +101,10 @@ void cfft( t_float *x, int NC, int forward )
i,j,
delta;
void bitreverse();
void fftease_bitreverse();
ND = NC<<1;
bitreverse( x, ND );
fftease_bitreverse( x, ND );
for ( mmax = 2; mmax < ND; mmax = delta ) {
delta = mmax<<1;
theta = TWOPI/( forward? mmax : -mmax );
......@@ -140,7 +140,7 @@ void bitreverse();
/* bitreverse places t_float array x containing N/2 complex values
into bit-reversed order */
void bitreverse( t_float *x, int N )
void fftease_bitreverse( t_float *x, int N )
{
t_float rtemp,itemp;
......
#include <math.h>
#include "fftease.h"
void init_rdft(int n, int *ip, t_float *w)
/* forward declarations */
static void rftsub(int n, t_float *a, int nc, t_float *c);
static void fftease_bitrv2(int n, int *ip, t_float *a);
static void fftease_cftsub(int n, t_float *a, t_float *w);
void fftease_init_rdft(int n, int *ip, t_float *w)
{
int nw,
nc;
void makewt(int nw, int *ip, t_float *w);
void makect(int nc, int *ip, t_float *c);
void fftease_makewt(int nw, int *ip, t_float *w);
void fftease_makect(int nc, int *ip, t_float *c);
nw = n >> 2;
makewt(nw, ip, w);
fftease_makewt(nw, ip, w);
nc = n >> 2;
makect(nc, ip, w + nw);
fftease_makect(nc, ip, w + nw);
return;
}
void rdft(t_fftease *fft, int isgn)
void fftease_rdft(t_fftease *fft, int isgn)
{
int n = fft->N;
t_float *a = fft->buffer;
......@@ -45,10 +49,10 @@ void rdft(t_fftease *fft, int isgn)
if (n > 4) {
rftsub(n, a, nc, w + nw);
bitrv2(n, ip + 2, a);
fftease_bitrv2(n, ip + 2, a);
}
cftsub(n, a, w);
fftease_cftsub(n, a, w);
for (j = 1; j <= n - 1; j += 2) {
a[j] = -a[j];
......@@ -58,10 +62,10 @@ void rdft(t_fftease *fft, int isgn)
else {
if (n > 4) {
bitrv2(n, ip + 2, a);
fftease_bitrv2(n, ip + 2, a);
}
cftsub(n, a, w);
fftease_cftsub(n, a, w);
if (n > 4) {
rftsub(n, a, nc, w + nw);
......@@ -74,7 +78,7 @@ void rdft(t_fftease *fft, int isgn)
}
void bitrv2(int n, int *ip, t_float *a)
void fftease_bitrv2(int n, int *ip, t_float *a)
{
int j, j1, k, k1, l, m, m2;
t_float xr, xi;
......@@ -136,7 +140,7 @@ void bitrv2(int n, int *ip, t_float *a)
}
void cftsub(int n, t_float *a, t_float *w)
void fftease_cftsub(int n, t_float *a, t_float *w)
{
int j, j1, j2, j3, k, k1, ks, l, m;
t_float wk1r, wk1i, wk2r, wk2i, wk3r, wk3i;
......@@ -259,7 +263,7 @@ void cftsub(int n, t_float *a, t_float *w)
}
void rftsub(int n, t_float *a, int nc, t_float *c)
static void rftsub(int n, t_float *a, int nc, t_float *c)
{
int j, k, kk, ks;
t_float wkr, wki, xr, xi, yr, yi;
......@@ -284,9 +288,9 @@ void rftsub(int n, t_float *a, int nc, t_float *c)
}
void makewt(int nw, int *ip, t_float *w)
void fftease_makewt(int nw, int *ip, t_float *w)
{
void bitrv2(int n, int *ip, t_float *a);
void fftease_bitrv2(int n, int *ip, t_float *a);
int nwh, j;
t_float delta, x, y;
......@@ -307,12 +311,12 @@ void makewt(int nw, int *ip, t_float *w)
w[nw - j] = y;
w[nw - j + 1] = x;
}
bitrv2(nw, ip + 2, w);
fftease_bitrv2(nw, ip + 2, w);
}
}
void makect(int nc, int *ip, t_float *c)
void fftease_makect(int nc, int *ip, t_float *c)
{
int nch, j;
t_float delta;
......
......@@ -109,32 +109,32 @@ typedef struct _fftease
void convert(t_fftease *fft);
void unconvert(t_fftease *fft);
void rfft( t_float *x, int N, int forward );
void cfft( t_float *x, int NC, int forward );
void bitreverse( t_float *x, int N );
void fold( t_fftease *fft );
void init_rdft(int n, int *ip, t_float *w);
void rdft(t_fftease *fft, int isgn);
void bitrv2(int n, int *ip, t_float *a);
void cftsub(int n, t_float *a, t_float *w);
void rftsub(int n, t_float *a, int nc, t_float *c);
void makewt(int nw, int *ip, t_float *w);
void makect(int nc, int *ip, t_float *c);
void leanconvert(t_fftease *fft);
void leanunconvert(t_fftease *fft);
void makewindows( t_float *H, t_float *A, t_float *S, int Nw, int N, int I );
void makehamming( t_float *H, t_float *A, t_float *S, int Nw, int N, int I,int odd );
void makehanning( t_float *H, t_float *A, t_float *S, int Nw, int N, int I,int odd );
void overlapadd(t_fftease *fft);
void bloscbank( t_float *S, t_float *O, int D, t_float iD, t_float *lf, t_float *la,
void fftease_convert(t_fftease *fft);
void fftease_unconvert(t_fftease *fft);
void fftease_rfft( t_float *x, int N, int forward );
void fftease_cfft( t_float *x, int NC, int forward );
void fftease_bitreverse( t_float *x, int N );
void fftease_fold( t_fftease *fft );
void fftease_init_rdft(int n, int *ip, t_float *w);
void fftease_rdft(t_fftease *fft, int isgn);
//void fftease_bitrv2(int n, int *ip, t_float *a);
//void fftease_cftsub(int n, t_float *a, t_float *w);
//void rftsub(int n, t_float *a, int nc, t_float *c);
void fftease_makewt(int nw, int *ip, t_float *w);
void fftease_makect(int nc, int *ip, t_float *c);
void fftease_leanconvert(t_fftease *fft);
void fftease_leanunconvert(t_fftease *fft);
void fftease_makewindows( t_float *H, t_float *A, t_float *S, int Nw, int N, int I );
void fftease_makehamming( t_float *H, t_float *A, t_float *S, int Nw, int N, int I,int odd );
void fftease_makehanning( t_float *H, t_float *A, t_float *S, int Nw, int N, int I,int odd );
void fftease_overlapadd(t_fftease *fft);
void fftease_bloscbank( t_float *S, t_float *O, int D, t_float iD, t_float *lf, t_float *la,
t_float *bindex, t_float *tab, int len, t_float synt, int lo, int hi );
void oscbank( t_fftease *fft );
t_float randf( t_float min, t_float max );
int randi( int min, int max );
void fftease_oscbank( t_fftease *fft );
//t_float randf( t_float min, t_float max );
//int randi( int min, int max );
int fftease_power_of_two(int test);
void limit_fftsize(int *N, int *Nw, char *OBJECT_NAME);
void fftease_limit_fftsize(int *N, int *Nw, char *OBJECT_NAME);
int fftease_fft_size(int testfft);
void fftease_free(t_fftease *fft);
void fftease_init(t_fftease *fft);
......@@ -146,14 +146,14 @@ int fftease_msp_sanity_check(t_fftease *fft, char *oname);
t_float fftease_randf(t_float min, t_float max);
void fftease_noalias(t_fftease* fft, short flag);
void fftease_oscbank_setbins(t_fftease *fft, t_float lowfreq, t_float highfreq);