Jump to content

Opusmodus 3.0.28930 Update


Recommended Posts

New function: FFTH, FFTW
Brownian motion functions are rewritten. If you used them before please check the documents.

Improvement to probability functions.

FFTH

num-of-harmonics step-resolution points &key type quantize coeff ambitus

 

The function FFTH calculates the Fast Fourier Transform (FFT) of a given list of points. The FFT is a mathematical algorithm that transforms a function of time (a signal) into a function of frequency. In the context of digital signal processing, the FFT algorithm is used to identify the frequencies present in a discrete signal.

 

The computation involves the following steps:

Initialization: Arrays for amplitude, phase, harmonics-matrix, and fftx are initialized.

 

Coefficient calculation: The function then calculates coefficients for the FFT, looping over the input data points. This is done using a complex number, where amplitude corresponds to the real part and phase to the imaginary part.

 

FFT curve computation: After the coefficients have been calculated, the function uses them to calculate the FFT curve by looping over a set of x-values and summing up the contributions from each coefficient.

 

Transformation of the results based on the type of output specified: If type is 'integer, the function rounds the FFT output to the nearest integer. If it's 'pitch, it converts the FFT output to pitches, quantizes them, and limits them to the specified ambitus. If no type is specified, the raw data points of the FFT curve are returned.

 

Examples:

 

(ffth 8 0.05 '(44 52 22 68 6 22 9 73 28 68))

  image.png

 

(ffth 8 0.05 '(44 52 22 68 6 22 9 73 28 68)
       :type 'pitch :ambitus '(c3 c5))

image.png

 

(ffth 3 0.05 '(44 52 22 68 6 22 9 73 28 68)
       :type 'pitch :coeff 1.0 :ambitus '(c3 c5))

image.png

 

(ffth 8 0.05 '(44 52 22 68 6 22 9 73 28 68)
       :type 'pitch :ambitus '(c3 c5) :quantize 1/4)

image.png

 

 

FFTW

data &key window normalize coefficients scale-factor phase

 

This function performs a Fast Fourier Transform (FFT) on the input data. The FFT is a widely-used algorithm for computing the Discrete Fourier Transform, which decomposes a sequence of numbers into components of different frequencies.

 

If a windowing function is provided via the window keyword parameter, this function is used to create a "window" that is applied to the input data before performing the FFT. Windowing can help to reduce "leakage" and "picket fence" effects (artifacts caused by the finite length of the input data).

 

If the normalize keyword parameter is true (the default), the FFT results are normalized by dividing each component by the length of the input data. This makes the results independent of the length of the input data and can make them easier to interpret.

 

The coefficient parameter in the FFTW function serves to modify the amplitude of the output data. Each output value of the FFT is multiplied by this coefficient, effectively scaling the amplitude of the frequency components.

 

The implementation of this FFT function is recursive, meaning it repeatedly breaks down the problem into smaller parts until it reaches a base case where the FFT can be computed directly. This makes it efficient for large datasets.

 

Note that this function requires the length of the input data to be a power of 2. If the length of the input data is not a power of 2, it is padded with zeros up to the next power of 2. This is because the FFT algorithm is most efficient when the length of the input data is a power of 2.

 

If you only care about the magnitudes of the frequency components, you can take the absolute value of each number in the result:

 

(setf data '(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15))

image.png

 

If you also care about the phase information, you can use the phase option to extract the phase of each number:

 

(fftw data :phase t)

image.png

 

Examples:

In this example, a Blackman-Harris window is applied to the input data:

 

(fftw data :window 'blackman-harris-window)

image.png

 

No normalization is performed:

 

(fftw data :window 'blackman-harris-window :normalize nil)

image.png

 

Compute FFT with Gaussian window:

 

(fftw data :window 'gaussian-window)

image.png

 

Compute FFT with Ultraspherical window:

 

(fftw data :window 'ultraspherical-window)

image.png

 

Examples with all available window functions:

(fftw data :window 'bartlett-hann-window)
(fftw data :window 'bartlett-window)
(fftw data :window 'blackman-harris-window)
(fftw data :window 'blackman-nuttall-window)
(fftw data :window 'blackman-window)
(fftw data :window 'bohman-window)
(fftw data :window 'cauchy-window)
(fftw data :window 'connes-window)
(fftw data :window 'cosine-window)
(fftw data :window 'exponential-window)
(fftw data :window 'flat-top-window)
(fftw data :window 'gaussian-window)
(fftw data :window 'hamming-window)
(fftw data :window 'hann-poisson-window)
(fftw data :window 'hanning-window)
(fftw data :window 'kaiser-window)
(fftw data :window 'nuttall-window)
(fftw data :window 'parzen-window)
(fftw data :window 'planck-taper-window)
(fftw data :window 'rectangular-window)
(fftw data :window 'riemann-window)
(fftw data :window 'triangular-window)
(fftw data :window 'tukey-window)
(fftw data :window 'ultraspherical-window)
(fftw data :window 'welch-window)

 

Best wishes,

Janusz

Link to comment
Share on other sites

  • opmo changed the title to Opusmodus 3.0.28930 Update
×
×
  • Create New...

Important Information

Terms of Use Privacy Policy