Is there a way to compute FFT in AHK?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
balawi28
Posts: 29
Joined: 09 Mar 2021, 13:53
Contact:

Is there a way to compute FFT in AHK?

Post by balawi28 » 03 May 2022, 11:20

Hello there, I'm working on a project regarding a stream of audio, and I'm looking for a way to convert the time domain array to the frequency domain.

Input = [0.1,0.2,0.3,0.4,0.5 ...] (array representing amplitudes of an audio stream) (increasing amplitude audio)
output = [200,500,4000,8000,9000 ...] (array representing frequency components of that audio stream) (frequency components)

Is there any implementation of FFT in the AHK language? I'm running low on options and I'm not in favor of re-implementing the algorithm from the ground up.

Thanks for your time.
datavectors
Posts: 6
Joined: 25 Apr 2022, 05:56

Re: Is there a way to compute FFT in AHK?

Post by datavectors » 03 May 2022, 15:40

Why choose AHK? What is the logic?
You did not search deeply.
AHK is not on this list ..
https://rosettacode.org/wiki/Fast_Fourier_transform

Here is a general purpose maths engine.

https://www.wolframalpha.com/input/?i=Fast+Fourier+Transform&assumption=%7B%22C%22%2C+%22Fast+Fourier+Transform%22%7D+-%3E+%7B%22MathWorld%22%7D

But there is Python.
User avatar
Chunjee
Posts: 1499
Joined: 18 Apr 2014, 19:05
Contact:

Re: Is there a way to compute FFT in AHK?

Post by Chunjee » 03 May 2022, 15:41

I searched Google and best I could find was in the German forum: viewtopic.php?p=440669&sid=1cc29100ca0e8a5c968af9c76f131202#p440669

If there is a simple math equation to do; you can apply it to every element in the array with https://biga-ahk.github.io/biga.ahk/#/?id=map
Rohwedder
Posts: 7770
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Is there a way to compute FFT in AHK?

Post by Rohwedder » 04 May 2022, 07:11

Hallo, the mathematical method requires calculating with complex numbers!
DFT.png
DFT.png (18.49 KiB) Viewed 872 times
With Excel it is easier and certainly faster.
User avatar
balawi28
Posts: 29
Joined: 09 Mar 2021, 13:53
Contact:

Re: Is there a way to compute FFT in AHK?

Post by balawi28 » 05 May 2022, 10:21

datavectors wrote:
03 May 2022, 15:40
Why choose AHK? What is the logic?
You did not search deeply.
AHK is not on this list ..
https://rosettacode.org/wiki/Fast_Fourier_transform

Here is a general purpose maths engine.

https://www.wolframalpha.com/input/?i=Fast+Fourier+Transform&assumption=%7B%22C%22%2C+%22Fast+Fourier+Transform%22%7D+-%3E+%7B%22MathWorld%22%7D

But there is Python.
Thanks for your reply, as I said earlier, I'm working on a project in AHK, and I want it to stay in one script and in one language, I'm not in favor of calling python from inside AHK just to apply a function.
You might ask why not do the whole project in python, this is because it involves contact with windows APIs which AHK excels at.
User avatar
balawi28
Posts: 29
Joined: 09 Mar 2021, 13:53
Contact:

Re: Is there a way to compute FFT in AHK?

Post by balawi28 » 05 May 2022, 10:29

Chunjee wrote:
03 May 2022, 15:41
I searched Google and best I could find was in the German forum: viewtopic.php?p=440669&sid=1cc29100ca0e8a5c968af9c76f131202#p440669

If there is a simple math equation to do; you can apply it to every element in the array with https://biga-ahk.github.io/biga.ahk/#/?id=map
Thanks! your input is highly appreciated, both links are good resources.
I will dig into that forum and if I didn't find anything useful, then I'll implement a simple FT myself.
User avatar
balawi28
Posts: 29
Joined: 09 Mar 2021, 13:53
Contact:

Re: Is there a way to compute FFT in AHK?

Post by balawi28 » 05 May 2022, 10:31

Rohwedder wrote:
04 May 2022, 07:11
Hallo, the mathematical method requires calculating with complex numbers!
DFT.png
With Excel it is easier and certainly faster.
Thanks for your reply, as I said earlier, I'm working on a project in AHK, and I want it to stay in one script and in one language, that's why I'm sticking with AHK.
You might ask why not do the whole project in python, this is because it involves contact with windows APIs which AHK excels at.
User avatar
tank
Posts: 3130
Joined: 28 Sep 2013, 22:15
Location: CarrolltonTX
Contact:

Re: Is there a way to compute FFT in AHK?

Post by tank » 05 May 2022, 11:53

I strongly disagree with your reasoning that suggests "hey here is this thing that works perfectly as-is, lets throw it away and start over"
balawi28 wrote:
05 May 2022, 10:31
stay in one script and in one language
And this.
balawi28 wrote:
05 May 2022, 10:31
You might ask why ...
The fact that you can use API's from other interpreters including JavaScript, .NET within AHK makes the whole thing moot, in my opinion.
balawi28 wrote:
05 May 2022, 10:31
involves contact with windows APIs
WHERE

There is a .NET DLL to handle Complex numbers. there are scripting libraries... but none of them are windows API per se`

I would have expected that you google the subject of "autohotkey and complex numbers".

viewtopic.php?t=35809

(edited)
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Telegram is the best way to reach me
https://t.me/ttnnkkrr
If you have forum suggestions please submit a
Check Out WebWriter
User avatar
balawi28
Posts: 29
Joined: 09 Mar 2021, 13:53
Contact:

Re: Is there a way to compute FFT in AHK?

Post by balawi28 » 06 May 2022, 05:42

tank wrote:
05 May 2022, 11:53
I strongly disagree with your reasoning that suggests "hey here is this thing that works perfectly as-is, lets throw it away and start over"
balawi28 wrote:
05 May 2022, 10:31
stay in one script and in one language
And this.
balawi28 wrote:
05 May 2022, 10:31
You might ask why ...
The fact that you can use API's from other interpreters including JavaScript, .NET within AHK makes the whole thing moot, in my opinion.
balawi28 wrote:
05 May 2022, 10:31
involves contact with windows APIs
WHERE

There is a .NET DLL to handle Complex numbers. there are scripting libraries... but none of them are windows API per se`

I would have expected that you google the subject of "autohotkey and complex numbers".

viewtopic.php?t=35809

(edited)
Thanks for your reply, I stated previously in my post that I'm against the idea of reimplementing the algorithm or neglecting any resource on that subject (that is why I'm asking for help in the first place), I'm totally cool with calling APIs from other interpreters, as long as they don't require adding any additional files or require some installations on the end-users side, I would like to keep it simple for the user, that is all.

I did already searched for complex numbers implementation in AHK and found the link you pointed me to previously. My last option is to reimplement the algorithm using the help of existing AHK libraries, but first I said to myself "why not ask if someone has a better way", but it looks like there isn't.
Post Reply

Return to “Ask for Help (v1)”