A newer version of Max is available. Click here to access the latest version of the Max documentation

pfft~

Spectral processing manager for patchers

Description

The pfft~ object is designed to simplify spectral audio processing using the Fast Fourier Transform (FFT). In addition to performing the FFT and the Inverse Fast Fourier Transform (IFFT), pfft~ (with the help of its companion fftin~ and fftout~ objects) manages the necessary signal windowing, overlapping and adding needed to create a real-time Short Term Fourier Transform (STFT) analysis/resynthesis system.

Examples

pfft~ loads subpatchers specially designed for frequency domain processing

Discussion

The number of inlets on the pfft~ object is determined by the number of fftin~ and/or in objects in the enclosed subpatch. Patchers loaded into a pfft~ object can only be given signal inlets by fftin~ objects within the patch. See fftin~ and in for details.

Arguments

subpatch-name [symbol]

Name of patcher to load

FFT-size [int]

Optional
Unitssamples

Specifies the FFT size, in samples, of the overlapped windows which are transformed to and from the spectral domain by the FFT/IFFT. The window size must be a power of 2, and defaults to 512. (Note: The size of the spectral "frames" processed by the pfft~ object's subpatch will be half this size, as the 2nd half of the spectrum is a mirror of the first and thus redundant, unless the full-spectrum-flag is present.)

overlap-factor (hop-size-denominator) [int]

Optional

The third argument determines the overlap factor for FFT analysis and resynthesis windows. The hop size (number of samples between each successive FFT window) of Fast Fourier transforms performed is equal to the size of the Fast Fourier transform divided by this overlap factor. (e.g. if the frame size is 512 and the overlap is set to 4 then the hop size is 128 samples). The value must be a power of 2 and defaults to 2. A value of 4 is recommended for most applications.

start-onset [int]

Optional
Unitssamples

The fourth argument specifies the start onset in samples for the Fast Fourier transform. It must be a multiple of the current signal vector size and defaults to 0.

full-spectrum-flag (0 or nonzero) [int]

Optional

A non-zero fifth argument may be used to specify "full-spectrum mode". In this mode, the pfft~ object will internally compute a complex FFT and process full DC to SR mirrored spectra (instead of simply eliminating the redundant half of the spectrum). This takes extra computing power but may be potentially useful in some of the more esoteric spectral processing applications.

Attributes

Common Box Attributes

annotation [symbol]

Sets the text that will be displayed in the Clue window when the user moves the mouse over the object.

background [int] (default: 0)

Adds or removes the object from the patcher's background layer. background 1 adds the object to the background layer, background 0 removes it. Objects in the background layer are shown behind all objects in the default foreground layer.

color [4 floats]

Sets the color for the object box outline.

fontface [int]

Sets the type style used by the object. The options are:

plain
bold
italic
bold italic

Possible values:

0 = 'regular'
1 = 'bold'
2 = 'italic'
3 = 'bold italic'

fontname [symbol]

Sets the object's font.

fontsize [float]

Sets the object's font size (in points).

Possible values:

'8'
'9'
'10'
'11'
'12'
'13'
'14'
'16'
'18'
'20'
'24'
'30'
'36'
'48'
'64'
'72'

hidden [int] (default: 0)

Toggles whether an object is hidden when the patcher is locked.

hint [symbol]

Sets the text that will be displayed in as a pop-up hint when the user moves the mouse over the object in a locked patcher.

ignoreclick [int] (default: 0)

Toggles whether an object ignores mouse clicks in a locked patcher.

patching_rect [4 floats] (default: 0. 0. 100. 0.)

Sets the position and size of the object in the patcher window.

position [2 floats]

g/s(set)

Sets the object's x and y position in both patching and presentation modes (if the object belongs to its patcher's presentation), leaving its size unchanged.

presentation [int] (default: 0)

Sets whether an object belongs to the patcher's presentation.

presentation_rect [4 floats] (default: 0. 0. 0. 0.)

Sets the x and y position and width and height of the object in the patcher's presentation, leaving its patching position unchanged.

rect [4 floats]

g/s(set)

Sets the x and y position and width and height of the object in both patching and presentation modes (if the object belongs to its patcher's presentation).

size [2 floats]

g/s(set)

Sets the object's width and height in both patching and presentation modes (if the object belongs to its patcher's presentation), leaving its position unchanged.

textcolor [float]

Sets the color for the object's text in RGBA format.

textjustification [int]

Text Justification

Possible values:

0 = 'left'
1 = 'center'
2 = 'right'

varname [symbol]

Sets the patcher's scripting name, which can be used to address the object by name in pattr, scripting messages to thispatcher, and the js object.

Messages

bang

Patchers loaded into a pfft~ object can only accept bang messages by in objects within the patch. The number of inputs is determined by the in objects in the enclosed subpatch. See in for details.

int

Arguments

input [int]
Integer values sent to the pfft~ object cause the object to act according to the user-defined functionality within it.

float

Arguments

input [float]
Floating-point values sent to the pfft~ object cause the object to act according to the user-defined functionality within it.

list

Arguments

input [list]
Lists sent to the pfft~ object cause the object to act according to the user-defined functionality within it.

anything

Arguments

input [list]
Messages sent to the pfft~ object cause the object to act according to the user-defined functionality within it.

(mouse)

Double-clicking with the mouse on the pfft~ object opens a Max patcher window containing the patcher loaded by the object.

clear

Clears all of the pfft~ object's internal buffers.

mute

Arguments

mute-flag (0 or 1) [int]
The word mute, followed by a 1 or 0, will mute or unmute the pfft~, turning off signal processing within the enclosed subpatch.

open

Arguments

subpatch-filename [int]
The word open will open the subpatch loaded into the pfft~ object.

wclose

Arguments

subpatch-filename [int]
Closes the enclosed subpatch if it is open.

Output

message

Any messages received by an out object in a loaded patcher appear at the message outlet of the pfft~ object which corresponds to the number argument of the out object. The message outlets of a pfft~ object appear to the right of the rightmost signal outlet.

signal

The output is the result of the FFT-based signal processing subpatch. As with the fft~ and ifft~ objects, pfft~ introduces a slight delay from input to output (although it is less than half the delay than with an fft~ / ifft~ combination). The I/ O delay is equal to the window size minus the hop size (e.g., for a 1024-sample FFT window with an overlap factor of 4, the hop size is equal to 256, and the overall delay from input to output is 768 samples). The number of outlets is determined by the number of fftout~ and/or out objects in the loaded subpatcher. Patchers loaded into a pfft~ object can be given outlets by fftout~ or out objects within the patch. See fftout~ and out for details.

See Also

Name Description
Spectral Processing Spectral Processing
Sound Processing Techniques Sound Processing Techniques
cartopol Convert cartesian to polar coordinates
cartopol~ Signal Cartesian to Polar coordinate conversion
fft~ Fast Fourier transform
fftin~ Input for a patcher loaded by pfft~
fftinfo~ Report information about a patcher loaded by pfft~
fftout~ Output for a patcher loaded by pfft~
frameaccum~ Compute "running phase" of successive phase deviation frames
framedelta~ Compute phase deviation between successive FFT frames
ifft~ Inverse fast Fourier transform
in Message input for a patcher loaded by poly~ or pfft~
out Message output for a patcher loaded by poly~ or pfft~
poltocar Convert polar to cartesian coordinates
poltocar~ Signal Polar to Cartesian coordinate conversion
vectral~ Vector-based envelope follower
MSP Analysis Tutorial 3: Using the FFT MSP Analysis Tutorial 3: Using the FFT
MSP Analysis Tutorial 4: Signal Processing with pfft~ MSP Analysis Tutorial 4: Signal Processing with pfft~