Higher-Order Ambisonic (HOA) Encoder — User Guide

Spatial audio encoding: converts mono source into ambisonic B-format with 1st, 2nd, or 3rd order spherical harmonic decomposition. Supports 3D positioning (azimuth, elevation, distance) with visualization and distance attenuation.

Author: Shai Cohen Affiliation: Department of Music, Bar-Ilan University, Israel

What this does

This script encodes a mono sound source into ambisonic B-format — a full-sphere surround sound format based on spherical harmonics. Position source in 3D space (azimuth 0-360°, elevation -90° to +90°, distance in meters), choose ambisonic order (1st=4 channels, 2nd=9 channels, 3rd=16 channels), and script generates individual ambisonic channels (W, X, Y, Z...) with spherical harmonic weighting. Includes distance attenuation and top-down visualization. Output requires ambisonic decoder for playback on speakers or headphones.

Ambisonic coordinate system (top view): Front (0°) | N | Left ------+------ Right (270°) | (90°) S | Back (180°) Elevation: -90° (below) to +90° (above) Distance: Meters from origin (listener position)

Quick start

  1. Select one Sound object in Praat (mono or stereo — will convert to mono).
  2. Run script… → Load HOA Encoder script.
  3. Choose Position_preset (10 presets) or select "Custom" for manual positioning.
  4. If Custom: Set Azimuth (0-360°), Elevation (-90 to 90°), Distance (meters).
  5. Set Reference_distance (1.0m default) for distance attenuation calculation.
  6. Choose Ambisonic_order: 1st (4ch), 2nd (9ch), or 3rd (16ch).
  7. Enable Normalize_output and Show_visualization.
  8. Click OK — encoding instant, individual channels appear in Objects list, visualization in Picture window.
Quick tip: Start with Front center preset and 1st order to understand basics. Enable visualization to see source position graphically. Output channels (W, X, Y, Z...) appear as separate Sound objects — use ambisonic decoder to render to speakers.

Ambisonic Theory

What are Ambisonics?

Spatial audio format based on spherical harmonics:

Ambisonic Orders

OrderChannelsResolutionUse Case
1st order4 (W,X,Y,Z)Low spatial resolutionBasic 3D audio, mobile, VR
2nd order9Medium resolutionBetter localization, planetariums
3rd order16High resolutionProfessional spatial audio, cinema

Channel count formula: (order + 1)² channels

Coordinate System

Azimuth (Horizontal Angle)

Azimuth: 0° to 360° (horizontal plane) 0° = Front (straight ahead) 90° = Right 180° = Back (behind) 270° = Left 360° = Front (same as 0°) Mathematical convention: Measured clockwise from front when viewed from above

Elevation (Vertical Angle)

Elevation: -90° to +90° (vertical plane) +90° = Directly above (zenith) 0° = Horizontal plane (same height as listener) -90° = Directly below (nadir) Most common: 0° (horizontal plane sources)

Distance (Radial)

Distance: Meters from origin (listener position) Distance attenuation formula: gain = reference_distance / distance Example: distance=2m, reference=1m gain = 1/2 = 0.5 (-6 dB) Example: distance=0.5m, reference=1m gain = 1/0.5 = 2.0 (+6 dB) Inverse distance law: Sound pressure decreases with distance

Position Presets

PresetAzimuthElevationDistanceDescription
Front center1.5mStraight ahead, close
Front left315°2m45° left of center
Left270°2mDirectly left
Rear left225°3m45° behind, left
Rear center180°3mDirectly behind
Rear right135°3m45° behind, right
Right90°2mDirectly right
Front right45°2m45° right of center
Above+90°2.5mDirectly overhead
Below-90°2.5mDirectly underneath

Ambisonic Channels

1st Order (4 Channels)

Channel 0 (W): Omnidirectional (0th order) Formula: W = 1.0 Pressure component, equal in all directions Channel 1 (Y): Figure-8 left-right (1st order) Formula: Y = cos(el) × sin(az) Positive = right, negative = left Channel 2 (Z): Figure-8 up-down (1st order) Formula: Z = sin(el) Positive = up, negative = down Channel 3 (X): Figure-8 front-back (1st order) Formula: X = cos(el) × cos(az) Positive = front, negative = back

2nd Order (5 Additional Channels)

Adds channels V, T, R, S, U (channels 4-8)

3rd Order (7 Additional Channels)

Adds channels Q, O, M, K, L, N, P (channels 9-15)

Parameters

ParameterTypeDefaultDescription
Position_presetchoiceCustom10 position presets or manual
AzimuthrealHorizontal angle (0-360°)
ElevationrealVertical angle (-90° to +90°)
Distancereal1.0mRadial distance from origin
Reference_distancereal1.0mDistance for 0 dB attenuation
Ambisonic_orderchoice1st orderSpatial resolution (1st/2nd/3rd)
Normalize_outputbooleanyesScale all channels to 0.99 peak
Show_visualizationbooleanyesDraw top-down position diagram

Output

Individual channel objects in Objects list:

Info window displays:

Picture window (if visualization enabled):

Important: Output channels are B-format ambisonic signals, not playable audio. Requires ambisonic decoder to render to speakers or headphones. Use specialized ambisonic tools/plugins for playback (IEM Plug-in Suite, Ambix, Reaper ReaPlugs, etc.).

Typical Workflow

Step-by-step ambisonic production:

  1. Encode sources: Run script for each mono source at different positions
  2. Mix channels: Combine corresponding ambisonic channels (all W, all X, etc.)
  3. Export B-format: Create multi-channel file with channel order (W,X,Y,Z...)
  4. Decode: Use ambisonic decoder for target speaker configuration
  5. Playback: Render to specific setup (stereo, 5.1, binaural, dome, etc.)
Channel mixing example: Two sources (A at front, B at left)
  • Mix: A_W + B_W → combined W channel
  • Mix: A_X + B_X → combined X channel
  • Mix: A_Y + B_Y → combined Y channel
  • Mix: A_Z + B_Z → combined Z channel
  • Result: Single 4-channel B-format with both sources

Applications

Immersive audio production:

Spatial composition:

Research:

Post-production:

Technical Notes

Spherical Harmonic Functions

Ambisonic encoding uses orthogonal spherical harmonics:

Distance Attenuation

Inverse distance law: gain = reference_distance / distance Examples: distance=1m, ref=1m: gain=1.0 (0 dB) distance=2m, ref=1m: gain=0.5 (-6 dB) distance=4m, ref=1m: gain=0.25 (-12 dB) distance=0.5m, ref=1m: gain=2.0 (+6 dB) Each doubling of distance = -6 dB

Normalization Schemes

This script uses N3D (Schmidt semi-normalized):

Limitations

  • Mono input only: Stereo automatically converted to mono
  • Static positioning: No motion/trajectory support (encode multiple times for animation)
  • No near-field compensation: Distance affects amplitude only, not frequency
  • Decoder required: Cannot play B-format directly on standard speakers
  • No Doppler effect: Moving sources need external processing
  • Single source per run: Mix multiple encoded sources for complex scenes

Further Resources

Ambisonic decoders:

Learning resources: