Fourier Transforms

This is a sample screen of the Fourier Transform done in RapidQ with a FreeBasic DLL. The top left form shows the original data, which is actually a bunch of sinewaves added together. The middle (lower) form shows the decomposition of the original wave into  the individual sinewaves of a specific frequency (amplitude spectrum). Note, the graph does not plot their phases (relative timing of the sine waves). The last graph on the right is a reconstruction of the spectrum back into the original waveform.  The code uses the "discrete Fourier transform" or DFT, which is slower but takes any length data. The Fast Fourier Transform (FFT) is much faster but requires the data length be an integer power of 2 (256, 512, etc.)

Why is the Fourier Transform important? Many reasons, compression of data into simpler components, transmitting information over radio waves, analyzing a complex waveform, determining the output of a system, even understanding MPEG movies, and the list goes on and on..

This code is a great example of how to improve computation speed of RapidQ using a DLL constructed in FreeBasic.

RapidQ Source  code:
RapidQ FFT header  include file:
FreeBasic Source code:
RapidQ Qchart include file:

The code comes from several sources on the web, some has been adapted to run with FreeBasic or RapidQ. It is not optimized code (even has GOTO statements), but is useful nonetheless.
Quick Bitmap rescaling

I was frustrated with my graphics programs when all I wanted to do was rescale a bitmap image to fit onto another bitmap. The standard PAINT and Paint Shop Pro programs make you do a dialog box with set dimensions. But what if you don't know what dimensions to set ahead of time?

So I wrote this little program. Run it, paste an image from the clipboard into it, resize the form, copy it to the clipboard and paste it to the image for an overlay. The size of the bitmap you see on the form will be the size in clipboard. Since the form is small you can see how big you need the image on top of another image. Note, you can also click on the form and load an image too.
RapidQ Source  code:

The code automatically loads and extracts a dynamic library called JPEG.DLL -- a small and powerful library for reading JPG, GIF, and other formats. You don't need it if you only work with BMP files. Get JPEG.DLL by searching the web, getting the RapidQ2 distribution, or joining the yahoo group/rapidq and download from the files section. Joining this group does not automatically mean more junk email!
DirectShow example

This this little program runs a directShow video player in a form. It demonstrates how to run COM (component object module) code in RapidQ, which inherently does not support virtual tables and C++ interfaces. The entire DirectShow API is not included! Just click the form and it opens a file dialog box so you can pick .mpg, AVI, and other  video streaming files.

RapidQ Source code:
OLE include file:

The code is a collaboration between several RapidQ coders (Jacques Phillip, Don Geo97, and myself). The idea for the code comes from a PowerBasic V.Shulakov.
Using Zlib Compression

Zlib is an free, open source library for compressing data and files into much smaller size. It makes files with the .gz extension. The library is used for general C/C++ compilers, but can be very useful in  RapidQ if you add the right Zlib DLL. Because RapidQ has a memory component that can be used with Zlib to compress bitmaps, data, User defined Types, arrays, strings, files, or just about any other data you can think of.

RapidQ test  code:
RapidQ include File:
Zlib DLL:(right click-> Save target as..)

This version is for Windows only. Since RapidQ calls DLLs by the STDCALL method, the alternate zlib DLL is included in this project.
Made with Nvu