Introduction
Introduction Statistics Contact Development Disclaimer Help
Proper tab indents - warvox - VoIP based wardialing tool, forked from rapid7/wa…
Log
Files
Refs
README
---
commit d4667d876810a4f359f266dd7e39818a1533c00e
parent 904c63b1c40e453f98816f6e1b912ed8087d55ea
Author: HD Moore <[email protected]>
Date: Wed, 25 Feb 2009 06:24:25 +0000
Proper tab indents
Diffstat:
M src/ruby-kissfft/main.c | 82 ++++++++++++++++-------------…
1 file changed, 41 insertions(+), 41 deletions(-)
---
diff --git a/src/ruby-kissfft/main.c b/src/ruby-kissfft/main.c
@@ -26,7 +26,7 @@ static VALUE rb_cKissFFT;
static VALUE
rbkiss_s_version(VALUE class)
{
- return rb_str_new2(KISS_VERSION);
+ return rb_str_new2(KISS_VERSION);
}
#define CHECKNULL(p) if ( (p)==NULL ) do { fprintf(stderr,"CHECKNULL failed @ …
@@ -34,48 +34,48 @@ rbkiss_s_version(VALUE class)
static VALUE
rbkiss_s_fftr(VALUE class, VALUE r_nfft, VALUE r_rate, VALUE r_buckets, VALUE …
{
- kiss_fftr_cfg cfg=NULL;
- kiss_fft_scalar *tbuf;
- kiss_fft_cpx *fbuf;
- float *mag2buf;
- int i;
- int n;
+ kiss_fftr_cfg cfg=NULL;
+ kiss_fft_scalar *tbuf;
+ kiss_fft_cpx *fbuf;
+ float *mag2buf;
+ int i;
+ int n;
int sidx;
- int avgctr=0;
+ int avgctr=0;
int remove_dc=0;
int nrows=0;
float * vals=NULL;
int stereo=0;
-
+
int nfft;
int rate;
int navg;
int nfreqs;
-
+
int inp_len;
int inp_idx;
-
+
// Result set
VALUE res;
VALUE tmp;
VALUE set;
res = rb_ary_new();
-
+
if(TYPE(r_nfft) != T_FIXNUM) {
return Qnil;
}
nfft=NUM2INT(r_nfft);
-
+
if(TYPE(r_rate) != T_FIXNUM) {
return Qnil;
}
rate=NUM2INT(r_rate);
-
+
if(TYPE(r_buckets) != T_FIXNUM) {
return Qnil;
}
navg=NUM2INT(r_buckets);
-
+
if(TYPE(r_data) != T_ARRAY) {
return Qnil;
}
@@ -83,27 +83,27 @@ rbkiss_s_fftr(VALUE class, VALUE r_nfft, VALUE r_rate, VALU…
if(RARRAY(r_data)->len == 0) {
return Qnil;
}
-
+
if(TYPE(RARRAY(r_data)->ptr[0]) != T_FIXNUM ) {
return Qnil;
}
-
+
nfreqs=nfft/2+1;
- CHECKNULL( cfg=kiss_fftr_alloc(nfft,0,0,0) );
- CHECKNULL( tbuf=(kiss_fft_scalar*)malloc(sizeof(kiss_fft_scalar)*nfft ) );
- CHECKNULL( fbuf=(kiss_fft_cpx*)malloc(sizeof(kiss_fft_cpx)*nfreqs ) );
- CHECKNULL( mag2buf=(float*)malloc(sizeof(float)*nfreqs ) );
-
+ CHECKNULL( cfg=kiss_fftr_alloc(nfft,0,0,0) );
+ CHECKNULL( tbuf=(kiss_fft_scalar*)malloc(sizeof(kiss_fft_scalar)*nfft …
+ CHECKNULL( fbuf=(kiss_fft_cpx*)malloc(sizeof(kiss_fft_cpx)*nfreqs ) );
+ CHECKNULL( mag2buf=(float*)malloc(sizeof(float)*nfreqs ) );
+
memset(mag2buf,0,sizeof(mag2buf)*nfreqs);
inp_len = RARRAY(r_data)->len;
inp_idx = 0;
-
+
while(inp_idx < inp_len) {
-
+
// Fill tbuf with nfft samples
- for(i=0;i<nfft;i++) {
+ for(i=0;i<nfft;i++) {
if(inp_idx + i >= inp_len) {
tbuf[i] = 0;
} else {
@@ -114,7 +114,7 @@ rbkiss_s_fftr(VALUE class, VALUE r_nfft, VALUE r_rate, VALU…
}
}
}
-
+
// Handle DC
if (remove_dc) {
float avg = 0;
@@ -122,23 +122,23 @@ rbkiss_s_fftr(VALUE class, VALUE r_nfft, VALUE r_rate, VA…
avg /= nfft;
for (i=0;i<nfft;++i) tbuf[i] -= (kiss_fft_scalar)avg;
}
-
- /* do FFT */
- kiss_fftr(cfg,tbuf,fbuf);
- for (i=0;i<nfreqs;++i) {
- mag2buf[i] += fbuf[i].r * fbuf[i].r + fbuf[i].i * fbuf[i].i;
+ /* do FFT */
+ kiss_fftr(cfg,tbuf,fbuf);
+
+ for (i=0;i<nfreqs;++i) {
+ mag2buf[i] += fbuf[i].r * fbuf[i].r + fbuf[i].i * fbuf…
}
-
+
if (++avgctr == navg) {
avgctr=0;
++nrows;
vals = (float*)realloc(vals,sizeof(float)*nrows*nfreqs…
float eps = 1;
-
+
set = rb_ary_new();
// RESULTS
- for (i=0;i<nfreqs;++i) {
+ for (i=0;i<nfreqs;++i) {
vals[(nrows - 1) * nfreqs + i] = 10 * log10( m…
tmp = rb_ary_new();
@@ -148,15 +148,15 @@ rbkiss_s_fftr(VALUE class, VALUE r_nfft, VALUE r_rate, VA…
}
rb_ary_push(res, set);
memset(mag2buf,0,sizeof(mag2buf[0])*nfreqs);
- }
+ }
inp_idx += nfft;
}
-
-cleanup:
- free(cfg);
- free(tbuf);
- free(fbuf);
- free(mag2buf);
+
+ cleanup:
+ free(cfg);
+ free(tbuf);
+ free(fbuf);
+ free(mag2buf);
return(res);
}
You are viewing proxied material from jay.scot. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.