#

**1**
Forum Advisor

**1,515,**

**538**

Join Date: Jan 2013

Last Activity: 18 June 2019, 5:10 PM EDT

Location: Loughborough

Posts: 1,515

Thanks Given: 626

Thanked 538 Times in 384 Posts

**Slow FFT in ksh93 and awk, ARexx and pure awk.**

Well i set myself a challenge to have an FFT function using nothing but ksh93 and awk.

It took some serious jiggery pokery and concentration with all the brackets and '$' characters but here is the result. It is RADIX 2 only, but hey, show me another UNIX shell script that does it. It IS SLOW but is ideal for my needs.

It uses ksh's floating point arithmetic and awk to obtain the SINE and COSINE requirements although even awk is not needed for this as typical Taylor series for these could have been created.

This was a learning curve primarily because ksh has a few minor differences to bash; however this is the result.

(For those that know the AMIGA, I am now thinking of porting this to ARexx although it has no SINE, COSINE or SQRT. I have already done SINE and SQRT for ARexx so COSINE is just a simple SINE change.)

This is in the Public Domain, CC0, here and hopefully there will be some interest from outside our community.

The results of the code below:

The script:

Enjoy all.

Snippets like these are what keep me from going insane.

------ Post updated at 07:31 PM ------

Hi bakunin...

My suggestion is to first do it in Assembler. Doing it in Python (or any other interpreted language, except probably FORTH) is like trying to build a race car - out of Lego. And, second, to do it on a DSP. I am not up to date with the latest DSPs any more, but i suggest to take a look at the C66x series from Texas Instruments or the ADSP-SC57x series from Analog Devices. Both are RT-capable floating-point DSPs and from my personal experience (TI32C80 from TI, i can't remember the name of the AD machine) both manufacturers made great procs. You might also try the still available 56k-series by Motorola. I used these (especially the 56001) a lot back in the days.
Thank you for the info but......

I do bizarre things like this to expand my knowledge on the limits of languages, not the limits of HW.

I even got my USB Arduino Diecimila board to talk to my AMIGA with minor HW mods, uploaded to AMINET, using BWBasic purely as a challenge, that's right BWBasic. It has had hundreds of DLs which shows people ARE interested in esoteric stuff like mine.

Real time applications are of no interest at the moment as AudioScope.sh is by definition slow as is its builtin Spec-An using Python 2.7.x with module imports of scipy and scipy.IO. As these ARE dependencies then I have written FFT code that works from Python 2.0.1 to the current 3.7.0. I now have since modified code to work from Python 1.4.0, the only version to work on a stock AMIGA A1200, also up to 3.7.0. Boy how, Python has changed. These mods can be seriously difficult to work around but now I have my building blocks to work with to adapt into AudioScope.sh for AudioScope.sh's Spec-An section without the need for dependencies.

ATM FFT on ksh was a new baby to see how easy it would be, difficult? YES; impossible? NO. I really do get enjoyment out of stretching languages to strange esoteric limits.

Can I do it in AWK? Dunno, I am not good with AWK but ARexx for the AMIGA WILL be serious fun as it does have basic floating point arithmetic but NO SINE, COSINE, SQRT, etc...

It took some serious jiggery pokery and concentration with all the brackets and '$' characters but here is the result. It is RADIX 2 only, but hey, show me another UNIX shell script that does it. It IS SLOW but is ideal for my needs.

It uses ksh's floating point arithmetic and awk to obtain the SINE and COSINE requirements although even awk is not needed for this as typical Taylor series for these could have been created.

This was a learning curve primarily because ksh has a few minor differences to bash; however this is the result.

(For those that know the AMIGA, I am now thinking of porting this to ARexx although it has no SINE, COSINE or SQRT. I have already done SINE and SQRT for ARexx so COSINE is just a simple SINE change.)

This is in the Public Domain, CC0, here and hopefully there will be some interest from outside our community.

The results of the code below:

The script:

Enjoy all.

Snippets like these are what keep me from going insane.

------ Post updated at 07:31 PM ------

Hi bakunin...

Quote:

Quote:

Originally Posted by wisecracker

I am an AMIGA fanatic still and was searching for a basic FFT routine for Python 1.4.0 for the AMIGA.

I am an AMIGA fanatic still and was searching for a basic FFT routine for Python 1.4.0 for the AMIGA.

I do bizarre things like this to expand my knowledge on the limits of languages, not the limits of HW.

I even got my USB Arduino Diecimila board to talk to my AMIGA with minor HW mods, uploaded to AMINET, using BWBasic purely as a challenge, that's right BWBasic. It has had hundreds of DLs which shows people ARE interested in esoteric stuff like mine.

Real time applications are of no interest at the moment as AudioScope.sh is by definition slow as is its builtin Spec-An using Python 2.7.x with module imports of scipy and scipy.IO. As these ARE dependencies then I have written FFT code that works from Python 2.0.1 to the current 3.7.0. I now have since modified code to work from Python 1.4.0, the only version to work on a stock AMIGA A1200, also up to 3.7.0. Boy how, Python has changed. These mods can be seriously difficult to work around but now I have my building blocks to work with to adapt into AudioScope.sh for AudioScope.sh's Spec-An section without the need for dependencies.

ATM FFT on ksh was a new baby to see how easy it would be, difficult? YES; impossible? NO. I really do get enjoyment out of stretching languages to strange esoteric limits.

Can I do it in AWK? Dunno, I am not good with AWK but ARexx for the AMIGA WILL be serious fun as it does have basic floating point arithmetic but NO SINE, COSINE, SQRT, etc...

*Last edited by wisecracker; 09-14-2018 at 07:49 AM.. Reason: (Attached itself to this post.) Now title changed.*

**This User Gave Thanks to wisecracker For This Post:**