Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright

Stream FFT and iFFT

DSP related issues, mathematics, processing and techniques

Re: Stream FFT and iFFT

Postby digitalwhitebyte » Sun Jun 23, 2013 6:51 pm

@MyCo

I updated the code(same post), it was wrong, now working,
but the approximation seems to be not good, still too high,
in the meantime I'm trying other solutions.
User avatar
digitalwhitebyte
 
Posts: 106
Joined: Sat Jul 31, 2010 10:20 am

Re: Stream FFT and iFFT

Postby digitalwhitebyte » Mon Jun 24, 2013 12:44 pm

Code: Select all
// Range of x [0,1]
// The maximum error is about 8*10^(-10).
x = @ins[0].to_f
y = 2*x-1
atan = 0.0318159928972*y+0.950551425796+3.86835495723/(y+8.05475522951+
    39.4241153441/(y-2.08140771798-0.277672591210/(y-8.27402153865+
    95.3157060344/(y+10.5910515515))))
output 0, atan


Sounds great, except for the 4 division in the main code.
Now I try to take it in ASM, and we shall see what is suitable for the cpu.
User avatar
digitalwhitebyte
 
Posts: 106
Joined: Sat Jul 31, 2010 10:20 am

Re: Stream FFT and iFFT

Postby martinvicanek » Mon Jun 24, 2013 12:58 pm

DWB, in your last post you can rearrange the expression so you get only one division of two polynomials. May or may not be faster.
User avatar
martinvicanek
 
Posts: 1328
Joined: Sat Jun 22, 2013 8:28 pm

Re: Stream FFT and iFFT

Postby Nubeat7 » Mon Jun 24, 2013 1:02 pm

awesome what you`re doing here guys! i`m a bloody beginner in this area but you really motivate me to read and try to understand all this fourier transforming,

to bring a little part too i optimized mycos window options, maybe here and there it could be done better but most of the stuff should be optimized fine
Attachments
window optionsopt.fsm
(13.71 KiB) Downloaded 1567 times
User avatar
Nubeat7
 
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna

Re: Stream FFT and iFFT

Postby digitalwhitebyte » Mon Jun 24, 2013 2:02 pm

martinvicanek wrote:DWB, in your last post you can rearrange the expression so you get only one division of two polynomials. May or may not be faster.


here is where we see your skill. :twisted:
hehe, a little help? :mrgreen:
User avatar
digitalwhitebyte
 
Posts: 106
Joined: Sat Jul 31, 2010 10:20 am

Re: Stream FFT and iFFT

Postby MyCo » Mon Jun 24, 2013 5:22 pm

DWBs new atan code is really good. In the 0..1 range I can't measure any error. Outside of that it's not very exact. But maybe we can use trig. identities to flip any input into the 0..1 input range. This should get us very close to a real atan.

@Nubeat: Thanks for your work. I know that this wasn't any fun, that's why I avoided that.
User avatar
MyCo
 
Posts: 718
Joined: Tue Jul 13, 2010 12:33 pm
Location: Germany

Re: Stream FFT and iFFT

Postby MyCo » Mon Jun 24, 2013 6:27 pm

here is the simplified version for DWBs atan:
Code: Select all
def atan(x)
   ax = x.abs
   num = 1.93417747861 * (ax**3 - 1.3821888526*ax**2 + 1.2783790120*ax - 2.785730712)
   denum = ax**4 + 2.1451887622*ax**3 + 6.258905830*ax**2 + 3.285923272*ax + 5.86468903
   linear = 0.0636319857944*ax + 0.918735432899
   res = linear + num / denum
   
   res = -res if (x<0)
   return res
end

if (@x.abs>1)
   output(0, ((@x>0) ? 1 : -1)*Math::PI*0.5 - atan(1.0/@x))
else
   output(0, atan(@x))
end


maybe there is a little room for further optimization
User avatar
MyCo
 
Posts: 718
Joined: Tue Jul 13, 2010 12:33 pm
Location: Germany

Re: Stream FFT and iFFT

Postby MyCo » Mon Jun 24, 2013 9:37 pm

OK, here is the current setup. I converted everything that I've found into code. DWBs new one is also in there. I've used the trig. identities to make it work full range. The results from this one are the best, although it's not the fastest.

So, any ideas to optimize the code of it? Maybe there are chances to minimize the error, just by rearranging. The Ruby version doesn't have that much error, as the code version. This comes from rounding (Ruby uses double precision), so maybe this rounding error can be reduced.
Attachments
atan and atan2 compared v2 (MyCo).fsm
(20.56 KiB) Downloaded 1590 times
User avatar
MyCo
 
Posts: 718
Joined: Tue Jul 13, 2010 12:33 pm
Location: Germany

Re: Stream FFT and iFFT

Postby digitalwhitebyte » Tue Jun 25, 2013 2:52 am

Code: Select all
// Range [0,1] |error| ~ 3.2e-7
streamin x;
streamout arctan;
float num,denum;

num = 0.05030176425872175099 *
   (-6.9888366207752135 + x) *
(3.14559995508649281e-7 + x) *
        (2.84446368839622429 +
        0.826399783297673451 *
                      x + x*x);
denum = (1 + 0.1471039133652469065841349249  * x +
               0.644464067689154755092299698 * x*x);
arctan = num / denum * -1;


maybe this seems to be a good compromise between accuracy and speed.
User avatar
digitalwhitebyte
 
Posts: 106
Joined: Sat Jul 31, 2010 10:20 am

Re: Stream FFT and iFFT

Postby MyCo » Tue Jun 25, 2013 3:24 am

I've done all the conversion stuff (and code optimization) already for your other version. The error is very low, and I've added it to the stream FFT project... where I measure the error of forward and inverse conversion. The max. error there is 88dB so far.

I've attached to current status. The atan2 code is in the "To phase" module, and isn't converted into assembler right now. To test the whole thing, you have to load in a Wave or MP3 into the stream player.
Attachments
Stream FFT v7 (trogluddite, MyCo).fsm
(262.64 KiB) Downloaded 1630 times
User avatar
MyCo
 
Posts: 718
Joined: Tue Jul 13, 2010 12:33 pm
Location: Germany

PreviousNext

Return to DSP

Who is online

Users browsing this forum: No registered users and 42 guests