Distance-Based Amplitude Panning (DBAP) — User Guide
Applies Distance-Based Amplitude Panning (DBAP) to a multi-channel Sound object by calculating gain for each channel based on the spatial relationship between an audio source and multiple speaker positions.
What this does
This Praat script implements Distance-Based Amplitude Panning (DBAP), a common spatial audio technique. DBAP determines the gain for each channel (speaker) by calculating the inverse distance between the virtual audio source position and each virtual speaker position. This process simulates the natural decay of sound amplitude over distance.
The core process involves:
- Setup: Defining the 2D coordinates for a sound source and a number of speakers (channels).
- Distance Calculation: Computing the Euclidean distance between the source coordinates and each speaker's coordinates.
- Gain Calculation: Calculating the gain for each speaker ($G_i$) using the inverse of the distance raised to a power (distance exponent): $G_i \propto \frac{1}{\text{distance}_i^{\text{exponent}}}$.
- Normalization: Optionally normalizing all gains to maintain a consistent perceived loudness (equal energy cross-fade, if exponent = 2.0).
- Application: Applying the calculated gain factor to each respective channel (speaker) of the selected multi-channel Sound object.
DBAP Theory
DBAP is a technique for positioning virtual sound sources in a loudspeaker array by calculating amplitude gains. It is highly flexible and works well with non-standard or irregular speaker setups, unlike traditional vector-based amplitude panning (VBAP).
The key parameters are:
- Distance Exponent: Controls the decay rate. A value of $1.0$ means gain is proportional to $1/\text{distance}$ (linear decay). A value of $2.0$ simulates the inverse square law of acoustic intensity decay.
- Normalization: Ensures that the sum of the squared gains is constant ($\sum G_i^2 = 1$). This is crucial for maintaining overall energy and preventing clicks when panning dynamically (though this script only sets static gains).
Quick start
- In Praat, select exactly one multi-channel Sound object. The number of channels must match the number of speakers in the chosen preset.
- Run script… →
Distance-Based Amplitude Panning (DBAP).praat. - Select a Preset (e.g., "Quad Setup").
- Set the Source X and Source Y coordinates (if using "Custom Coordinates" or if the preset allows modification).
- Click OK.
- The output object, named
[OriginalName]_DBAP_[PresetName], is created and plays automatically.
Parameters (form fields)
| Name (GUI) | Type | Default | Description |
|---|---|---|---|
| preset | optionmenu | Default Midpoint | Selects a predefined speaker configuration, source position, and number of speakers. |
| normalize\_gains | boolean | 1 (checked) | If checked, the gains are normalized so the total acoustic power is preserved. Highly recommended. |
| distance\_exponent | real | 1.0 | Controls the rate of amplitude decay over distance. A value of 1.0 (linear inverse distance) or 2.0 (inverse square law) are common values. |
| minimum\_distance | real | 0.01 | A small value used to prevent a division-by-zero error if the source is exactly on top of a speaker. |
| show\_gain\_values | boolean | 0 (unchecked) | If checked, prints the calculated gain for each speaker to the Info window. |
| source\_x / source\_y | real | 0.5 / 0.5 | The virtual X and Y coordinates of the sound source. Used with the 'Custom Coordinates' preset. |
| number\_of\_speakers | natural | 2 | The number of channels/speakers to process. This value is overwritten by the chosen preset unless 'Custom Coordinates' is selected. |
| speaker\_1\_x... speaker\_6\_y | real | Various | The virtual X and Y coordinates for up to 6 speakers. These values are overwritten by the chosen preset. |
Presets and Channel Requirements
The script includes several presets that pre-configure the source and speaker coordinates. It is critical that the number of channels in the selected Sound object matches the channel requirement of the chosen preset.
| Preset Name | Channels | Description |
|---|---|---|
| Default Midpoint | 2 | Source positioned centrally (0.5, 0.5) between two speakers at (0, 0) and (1, 0). |
| Close to Speaker 1 | 2 | Source slightly off-center near speaker 1, with speakers at (0, 0) and (2, 0). |
| Triangle Setup | 3 | Source centered inside a triangular array of speakers. |
| Quad Setup | 4 | Source centered inside a rectangular quad array of speakers. |
| Surround 5.1 | 6 | Simulates a standard 5.1-like layout (6 speakers). |
| Hexagon Array | 6 | Speakers arranged in a hexagonal pattern around the source. |
| Custom Coordinates | 2-6 | Allows manual input of source and speaker coordinates. The number of speakers (up to 6) is set by the number_of_speakers field. |
| Hard Left / Hard Right | 2 | Extreme source positions for hard panning effects in stereo. |
| Ultra Wide | 2 | Stereo panning where the speakers are virtually placed outside the standard range. |
| Nearfield Center | 2 | Source placed centrally (0.5, 0.2) in a close-range stereo setup. |
Outputs
- Object name:
[OriginalName]_DBAP_[PresetName] - Type: Sound (multi-channel, same as input)
- Playback: The final sound plays automatically.
- Requirement: The number of channels in the input sound must exactly match the number of speakers required by the selected preset.