View Full Version : Fast Fourier Transform in TBASS

Petr Schreiber
16-09-2009, 14:10
Thanks to Eros new TBASS exposes TBASS_ChannelGetData.
It allows to retrieve FFT (fast fourier transformation) of the channel played.

It can be used in many ways - from music visualisation, sound analysis to some more abstract things.

This little script shows you how to visualise FFT data from played sound in realtime.

Latest beta (http://community.thinbasic.com/index.php?topic=2899.msg21972#msg21972) required.

16-09-2009, 16:09
That is great Petr :shock:

16-09-2009, 16:31
yes very nice Petr! And only with a few lines of code :lol:

Eros, are you also still working on BassFX?

16-09-2009, 16:59
Eros, are you also still working on BassFX?

Of course yes. And that DLL is already embedded inside TBASS module but you cannot see at the moment because BASS and BASSFX libraries are exploded in memory when TBASS module is loaded.

My delay (and I'm sorry about that) is related to the fact I had to recover thinAir situation and continuous GPF. Now it seems I'm on the right road, the most important part is done, I just need to tune some important points on thinAir code and than I will go back to BASSFX and on ODBC for which I promised to produce some examples on how to manage tables with primaries keys and auto increment fields.


16-09-2009, 17:15
I am happy to hear that Eros. It's completely understandable that you focus first on the things with high priority. Looking forward to the ODBX examples as well!


17-09-2009, 04:07
Petr, it is giving an error. I did download the latest thinBasic from the link you provided.
Here is a screenshot of what it says. I am running Windows 7.

I do hear the music and after I close the error box, I see the window frame empty for just a second till Windows exits out from the program.

17-09-2009, 07:49

are other TBASS script examples working?
Can you check you do not have other "thinBasic_TBASS.dll" around in your computer?

The error you are having seems TBASS module is not correct and is an old version vecause TBASS_ChannelGetData is a new function present only in latest thinBasic beta 1.7.10


Petr Schreiber
17-09-2009, 10:28
Hi Kent,

could you try to uninstall thinBASIC, clear your browser cache, install thinBASIC beta from provided link please? As Eros said, the functionality is new in the latest preview. The error you get is defintely caused by old DLL - there are some other TBASS commands before TBASS_ChannelGetData, and they ran fine on your PC.


Michael Hartlef
17-09-2009, 19:24
Hi Petr, now that is very cool! I like it. :eusaclap:

17-09-2009, 21:09
Ok, this is strange. I uninstalled thinBasic and in the uninstall list it showed it as version
I went ahead and uninstalled it.
I then went to drive C and deleted the thinBasic folder.

I installed the new version again.
I tried the TBASS examples in the samplescripts folder. They all worked except for the two that played
from memory.
Also Petr's newest must play from memory too and so it too didn't work.

Hope this helps trace what could be the problem.

Petr Schreiber
17-09-2009, 21:21

Well, on my PC the TBASS_SampleFromMemory.tbasic and TBASS_MusicFromMemory.tbasic does not work, but the script I posted here does work without any problem (it does not play anything from memory).

I get for them error 41 aka "BASS_ERROR_FILEFORM".

Kent, do you think you could try to mod my code to use console to print out code returned by TBASS_ErrorGetCode on your PC?
Thank you very much!

I might be wrong, but (T)BASS is DirectX based, maybe DX 11(?) in W7 makes some trouble?


17-09-2009, 21:55
Well, on my PC the TBASS_SampleFromMemory.tbasic and TBASS_MusicFromMemory.tbasic does not work, but the script I posted here does work without any problem (it does not play anything from memory).

That scripts do not work here too so there must be something wrong . I will check in next days.
But FFT example works fine in all OS I tested including Windows Vista. I didn't check under Windows 7 but I will try to setup a virtual machine in next days (hopefully)

18-09-2009, 07:24
This command is not known in my install: TBASS_ChannelGetData
When I comment it out and the lines afterward the music plays fine and I see the black window.

Petr, there is an error routine in the code, I tried sending the output from the call, but it doesn't come back
from TBASS_ChannelGetData.

Also the TBASS_ChannelGetData is not keyword color highlighted, whereas the other TBASS commands are.

20-09-2009, 11:33
I'm installed a VM with an old Windows 7 version (I do not have the latest)

TBASS_ChanelGetData seems working fine under Windows 7

So Kent problems seems something else other the operating system or TBASS.
Kent, I still think there is an old thinBasic_TBASS.dll module around. Check and show system/hidden files in \thinBasic\SampleScripts\TBASS\ directory to be sure there are no old versions there.


21-09-2009, 08:12
Eros, if as Petr wrote, it is based on DirectX, then having DX11 on my computer could be messing it up.
I am just guessing that your VM doesn't have DirectX 11 installed and that is perhaps why there is a difference.

21-09-2009, 10:57
i have two windows xp in my computer, every one is installed in a separate primary partition,
in the first winxp, i got error message just to run (uses "tbass") as in the following picture using tb v1.7.10:
this is not the case with the older version 1.7.8
running the command dxdiag from start->run give me info that i have directx 9.0c as in this pic:
strangely when using the second winxp i have run the Petr example above , and after it gives me about 3 error messages like the above pictures, i have tried the mp3 player example, and it is running okay, after that somehow the Petr example run okay, and now it is running without errors, this is a contradictory behaviour, the dx version on the second windxp is the same dx9.0c.

any way surly there is a tricky hidden trap between the tbass in v1.7.10 and 1.7.8

21-09-2009, 11:45

can you be so kind to let us know how DEP (http://support.microsoft.com/kb/875352/en-us) is configured in your systems?
Use the following method:

Click Start, right-click My Computer, and then click Properties.
Click the Advanced tab, and then click Settings under the Startup and Recovery field.
In the System startup field, click Edit. The Boot.ini file opens in Notepad.

See what is configured at "/noexecute=" (if present)

TBASS in thinBasic 1.7.10 uses a method to load DLL from memory instead that from file remapping all dll exported function.
If DEP is always active (AlwaysOn) it can be the reason why it GPF.
Default Windows configuration is "/noexecute=optin"


21-09-2009, 12:11
Hi Eros
the boot.ini is as follows:
[boot loader]
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /noexecute=optin /fastdetect
also i have checked the boot.ini in the partition of the second winxp and it is the same
my first winxp is full of programs with hundreds or even thousands of programs, while the second winxp have just a small number of programs installed. but even so in the second winxp experiment i wonder too much why it gives errors the first about 3 times, while now it is okay.
a note if may be related, i have 4 GB on my system, but it shows a 3 GB because my asus motherboard do not detect 4 gb, as i have learned from searching the web regarding my specific motherboard.


21-09-2009, 12:27
i have deleted the /noexecute=optin /fastdetect from the boot.ini and rebooted the computer, but still the same problem. it is surely a memory problem

21-09-2009, 12:35

that option was correct so please leave is as it was.

Instead, when you have the GPF, can you please click on the blue "Click here" link.
It should give you more info on the exact dll that produced the GPF. Info should be in the upper part of the appearing dialog.

Thank you.

21-09-2009, 13:10
here is the info:
i have clicked also in the "to view technical information about the error click here" they issue a text file about the error i attach it
i have also clicked on the debug, but it launched the vc++6 which seems does not understand the error, the assemply code are full of question marks.
you may delay investigating the problem of tbass until the new version of thinbasic released.

Michael Hartlef
21-09-2009, 19:18
Eros, if as Petr wrote, it is based on DirectX, then having DX11 on my computer could be messing it up.
I am just guessing that your VM doesn't have DirectX 11 installed and that is perhaps why there is a difference.


a keyword not being present has nothing to do what DX version you have installed. Like Eros said, there must be an
old version of TBass somewhere in the path TB is looking for it. I would bet money on it thta it has nothing to do with DX11.
Only if a command is not working like it should. But you said, that TB doesn't know the command.