Module: Cowboy
- Defined in:
- lib/cowboy.rb,
lib/cowboy/fft.rb,
lib/cowboy/version.rb,
ext/cowboy/cowboy.c
Defined Under Namespace
Classes: CowboyArray, Frequencies, Hamming
Constant Summary
collapse
- VERSION =
"0.0.2"
Class Method Summary
collapse
Class Method Details
.fft(arr, w = Hamming, n = 29) ⇒ Object
34
35
36
37
38
39
40
41
42
|
# File 'lib/cowboy/fft.rb', line 34
def Cowboy::fft(arr, w=Hamming, n=29)
if !w.nil?
window = w.new(n)
input = window.convolve(arr)
fft_1d(input)
else
fft_1d(arr)
end
end
|
.fft_1d(v) ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'ext/cowboy/cowboy.c', line 5
VALUE fft_1d(VALUE m, VALUE v) {
fftw_complex *in, *out;
fftw_plan fp;
int n;
n = (int) size_of_val(v);
if (n == 0) {
rb_raise(rb_eException, "Can't use empty set of samples");
}
in = allocate_fftw_complex(n);
out = allocate_fftw_complex(n);
fp = fftw_plan_dft_1d(n, in, out, FFTW_FORWARD, FFTW_ESTIMATE);
cast_val_to_complex(in, v);
fftw_execute(fp);
free(in);
fftw_destroy_plan(fp);
return ca_wrap_struct_class(out, n);
}
|