This is a Ruby wrapper for FFTW3. It currently only supports 1-dimension transforms, but I'll be adding support for multiple dimensions soon.
FFTW3 is required. You can generally get it from
your OS's package manager (e.g.
sudo port install fftw3).
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install cowboy
After installing, you can call
Cowboy::fft_1d with a 1d array of
real numbers. This will return an array of complex numbers. Note that
your input array will be blanked out.
Cowboy::fft will do some windowing before calling
currently behaves somewhat unintelligently and discards points around
the end of the array (for window size N, it discards N/2 from the
beginning and N/2 from the end) to allow for a full window at every
The default is to use a
with a window size of 29. This is configurable as the second and third
Cowboy::fft(my_array, my_windowing_func, 12))
Cowboy::Frequencies is a class that, initialized an array of complex
numbers (ideally the output of a call to
fft), will shift them to
their correct order (e.g.
[-nyquist, +nyquist]). There is also a
buckets that will give you the frequency buckets in order.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Added some feature')
- Push to the branch (
git push origin my-new-feature)
- Create new Pull Request