dbapgains
Distance-Based Amplitude Panning gain vector generator.
dbapgains implements the same algorithm as dbap, including the optional soft-limited spread control, but instead of applying the spatialization to an input audio signal, it outputs only the vector of per-loudspeaker gains.
Syntax
Initialization
mode -- Coordinate interpretation mode. Specifies how loudspeaker coordinates are interpreted: 0 = cartesian coordinates (x, y, z); 1 = polar coordinates in degrees (rho, phi, theta or phi, theta); 2 = polar coordinates in radians (rho, phi, theta or phi, theta).
lpos:i[][]/lpos:i -- Loudspeaker position definition. Defines the loudspeaker layout. It can be either: a 2D i-rate array of size n x 2 or n 3 (where n is the number of loudspeakers), or a function table containing the same data sequentially. Depending on coordinate mode arg, each loudspeaker can be defines in two- (x, y or phi, theta) or three-dimension (x, y, z or rho, phi, theta).
rloff -- rolloff coefficient controlling amplitude decay as a function of distance. Higher values produce a steeper attenuation with distance, increasing localization sharpness, while lower values result in a more diffuse spatial distribution.
ldim -- Dimension of loudspeaker position (2 or 3). This argument is only required when a function table is used to define the loudspeaker positions, indicating whether the data represents a 2D or 3D layout.
wgts:i[][]/wgets:i -- (optional) per-loudspeaker weighting factors. If provided, the array or GEN function must contain one value per loudspeaker. Each weight w_i scales the corresponding gain.
Performance
sprd:k -- spread factor (>= 0) controlling spatial focus. The gain for each loudspeaker is computed as
where The exponential term introduces a soft decay: Increasing sprd results in tighter spatial focus. When sprd = 0, the algorithm reduces to the classical DBAP formulation.Examples
Here is an example of the dbap opcode. It uses the file dbapgains.csd.
See also
Panning and Spatialization: Distance Based Amplitude Panning
Credits
Author: Pasquale Mainolfi
Italy
New in Csound version 7.0
February 2026.