Page 1 of 1

Ruby Complex FFT CPU speed

Posted: Fri Jan 17, 2020 1:13 pm
by chackl
Hi!

The last days i made some tests about doing FFTs and iFFTs in ruby.

I've tested those FFT codes in ruby:
https://github.com/CompScienceClub/ruby-fft
https://rosettacode.org/wiki/Fast_Fouri ... sform#Ruby
http://www.gregfjohnson.com/fftruby/

All seem pretty to be the same - the fist is a little faster because it creates a storage-map
Both are also reversible - so calculating an iFFT brings up most the original signal.

BUT:
If i run the for example for rate 44100 as a buffer of 512 signals (so i need to do 44100/512 FFTs) results in taking about 3-4 seconds for 1 second of a signal (mono).

So i found this here (Something that i've seen impossible in SynthMaker times):
viewtopic.php?f=4&t=1510&start=0
And this thing is pretty fast :)

So just a question to the ruby-freaks here if there is a better code for ruby?

The goal is to read a wav-file in ruby, do some fft operations and write it to another wav-file. This already worked but with speeds that are quite sad.
(As i multithreaded the script it is just for testing proposes loaded in FlowStone)

kind regards, chackl

Re: Ruby Complex FFT CPU speed

Posted: Fri Jan 17, 2020 1:46 pm
by martinvicanek
This may be related to your project
viewtopic.php?f=2&t=3972&p=22927&hilit=Clone#p22958
Fft of an entire track, performance is acceptable.

Re: Ruby Complex FFT CPU speed

Posted: Fri Jan 17, 2020 4:35 pm
by trogluddite
I doubt that the Ruby could be made to run much faster; it's just inherent in Ruby being an interpreted language that it can't process such huge chunks of data at "real-time" like speeds. I could be done using a Ruby C-extension (i.e. C++ code using the Ruby API to create a new Ruby "primitive"), but if you were going to do that, the FS DLL component might be the easier route.

The main issue with the ASM FFT that you linked to is that it's designed to work in real-time from a stream rather than off-line. I think that the code could possibly be adapted to work off-line by using Ruby Frames created from your file reader (the code essentially makes its own equivalent of Frames internally) - but that might need some help from MyCo, as he upgraded my original FFT ASM code in some very clever ways that I'm not sure I quite understand! Unless MV's solution already works for what you need, of course.

Re: Ruby Complex FFT CPU speed

Posted: Fri Jan 17, 2020 7:49 pm
by chackl
Hi!

Thanks.
In the link there is now this code:
https://blog.mro.name/2011/04/simple-ru ... transform/

I just implimented it at it realy runs much faster than the rosetta-code FFT.

The problem is that i realy do not understand asm in any case if i have no debugger that is able to do step by step.

This code fits my needs for the moment.