HoaMatrixDecoder:
Filter:
Classes (extension) | Libraries > Ambisonic Toolkit > Matrix & Kernel > HOA

HoaMatrixDecoder : HoaMatrix : AtkMatrix : Object
ExtensionExtension

Higher Order Ambisonic (HOA) matrix decoders
Source: HoaMatrix.sc

Description

Generate matrix decoders required by the Ambisonic Toolkit's Higher Order Ambisonic (HOA) decoder, HoaDecodeMatrix.

Matrix decoding is offered via four different methods:

  1. projection
  2. mode matching
  3. beamforming
  4. format exchange

The first two, projection and mode matching, are suitable for designing decoders for loudspeaker arrays and apply a simple HOA degree truncation where the number of desired outputs is less than the number required for an input Ambisonic order.

The third, beamforming, returns (projection) spatial windows of the input Ambisonic order, without applying degree truncation. This decoding method is suitable for spherical decomposition and beamforming for signal processing.

Format exchange decoding offers interfacing with other Ambisonic formats and systems.

Class Methods

HoaMatrixDecoder.newProjection(directions, beamShape: 'basic', match: 'amp', order)

Decode a Higher Order Ambisonic signal (HOA) via the projection method.

Arguments:

directions

An array of directions. Specify in radians.

Rank 1 arrays return pantophonic, while rank 2 arrays return periphonic. E.g.,

beamShape

Keyword argument for beam shape. See discussion below.

match

Keyword argument for gain matching. See discussion below.

order

Ambisonic order.

Discussion:

Also known as Simple Ambisonic Decoding, aka SAD.

NOTE: In order to return a valid reconstruction decoder, directions should be evenly distributed.

HoaMatrixDecoder.newModeMatch(directions, beamShape: 'basic', match: 'amp', order)

Decode a Higher Order Ambisonic signal (HOA) via the mode matching method.

Arguments:

directions

An array of directions. Specify in radians.

Rank 1 arrays return pantophonic, while rank 2 arrays return periphonic. E.g.,

beamShape

Keyword argument for beam shape. See discussion below.

match

Keyword argument for gain matching. See discussion below.

order

Ambisonic order.

Discussion:

Also known as Pseudoinverse Decoding, aka Pinv.

NOTE: Comprehensive modal discarding is not applied. More evely distributed directions will return a more stable decoder.

HoaMatrixDecoder.newDiametric(directions, beamShape: 'basic', match: 'amp', order)

Decode a Higher Order Ambisonic signal (HOA) via the mode matching method, given diametrically matched loudspeaker pairs. Gerzon's classic diametric decoder.1

Arguments:

directions

An array of directions for half of the loudspeaker feeds for the desired decoder. Specify in radians.

Rank 1 arrays return pantophonic, while rank 2 arrays return periphonic. E.g.,

beamShape

Keyword argument for beam shape. See discussion below.

match

Keyword argument for gain matching. See discussion below.

order

Ambisonic order.

Discussion:

Also known as Diametric Decoding.

directions specifies only half of the loudspeakers for the resulting array, the remaining loudspeakers are diametrically opposite (through the origin). -directions may be used to query resulting loudspeaker directions.

HoaMatrixDecoder.newPanto(numChans: 4, orientation: 'flat', beamShape: 'basic', match: 'amp', order)

Decode a Higher Order Ambisonic signal (HOA) via the projection method to a Pantophonic (2D) regular polygon array.

Arguments:

numChans

number of outputs

orientation

\vertex or \side

beamShape

Keyword argument for beam shape. See discussion below.

match

Keyword argument for gain matching. See discussion below.

order

Ambisonic order.

Discussion:

The outputs are in anti-clockwise order. The position of the first speaker is either centre or left of centre. -directions may be used to query resulting loudspeaker directions.

Used in conjunction with HoaDecodeMatrix the resulting decoder is equivalent to DecodeB2 (SuperCollider's inbuilt decoder), albeit with the addition of variable beam shape and gain matching. DecodeB2 is a controlled opposites decoder.

HoaMatrixDecoder.newSphericalDesign(design, beamShape: 'basic', order)

Beamform into a Higher Order Ambisonic signal (HOA), returning multiple beams evenly distributed in a SphericalDesign.

Arguments:

design

SphericalDesign instance

beamShape

Keyword argument for beam shape. See discussion below.

order

Ambisonic order.

Discussion:

A-format decoding, aka spherical decomposition, is offered by *newSphericalDesign.

Gain is matched to maximum beam amplitude.

NOTE: Matching spherical (re-)composition is provided by HoaMatrixEncoder: *newSphericalDesign.

HoaMatrixDecoder.newDirection(theta: 0, phi: 0, beamShape, order)

Beamform into a Higher Order Ambisonic signal (HOA), returning a single beam.

Arguments:

theta

Azimuth, in radians.

phi

Elevation, in radians.

beamShape

Keyword argument for beam shape. See discussion below.

order

Ambisonic order.

Discussion:

Returns a single beam, and can be used to "listen in" to the soundfield at the specified azimuth and elevation. Gain is matched to the beam. See discussion below

HoaMatrixDecoder.newDirections(directions, beamShape, match, order)

Beamform into a Higher Order Ambisonic signal (HOA), returning multiple beams.

Arguments:

directions

An array of directions. Specify in radians.

Rank 1 arrays return pantophonic, while rank 2 arrays return periphonic. E.g.,

beamShape

Keyword argument for beam shape. See discussion below.

match

Keyword argument for gain matching. See discussion below.

order

Ambisonic order.

Discussion:

Returns a collection of beams, and can be used to "listen in" to the soundfield at the specified azimuths and elevations.

WARNING: As a projection beamformer, does not return a valid reconstruction decoder for arbitrary loudspeaker directions. Similarly, Ambisonic order is not truncated given an insufficient number of loudspeakers or distribution of directions.

HoaMatrixDecoder.newFormat(format: 'atk', order)

An Ambisonic format exchange decoder. Decodes from ACN-N3D to a variety of formats.

Arguments:

format

An array of kewords designating component ordering and normalisation.

E.g., target output format ACN-SN3D is expressed [ \acn, \sn3d ]. See discussion below.

order

Ambisonic order.

Discussion:

A variety of component ordering and normalisation schemes are supported. These are:

ordering

\acnAmbisonic Channel Number (ACN)
\sidSingle Index Designation (SID)
\fumaFurse-Malham (FuMa)

normalisation

\n3dOrthonormal basis for 3D decomposition (N3D)
\sn3dSemi-normalised basis for 3D decomposition (SN3D)
\n2dOrthonormal basis for 2D decomposition (N2D)
\sn2dSemi-normalised basis for 2D decomposition (SN2D)
\maxNMaximum normalisation (maxN)
\MaxNGerzon / Furse-Malham (MaxN)
\fumaSynonym for MaxN (FuMa)

Additionally, a number of common formats are available as a single keyword:

\atkAmbisonic Toolkit (ATK)
\ambixAmbisonics Exchangeable (AmbiX)
\fumaFurse-Malham (FuMa)

Matrix & File

HoaMatrixDecoder.newFromMatrix(matrix, directions, order)

From superclass: HoaMatrix

Create an instance from a raw 2D Matrix.

Arguments:

matrix

A Matrix in the form of

directions

An array of directions. Specify in radians.

Rank 1 arrays return pantophonic, while rank 2 arrays return periphonic. E.g.,

order

Ambisonic order.

HoaMatrixDecoder.newFromFile(filePathOrName, searchExtensions: true, order)

From superclass: HoaMatrix

Create an instance by loading a matrix from a file.

Arguments:

filePathOrName

Can be a path relative to your /extensions/matrices/decoders folder:

Otherwise a full path to your matrix file.

searchExtensions

Search extension paths.

order

Ambisonic order.

Discussion:

See the Guide to ATK Matrix Files for more information.

Beam shape

Three standard beam shapes are offered:

keywordbeam shapelocalisation vectorvirtual microphone
\basicstrict soundfieldmaximum velocity rVHyper-cardioid
\energyenergy optimisedmaximum energy rESuper-cardioid
\controlledcontrolled oppositesminimum diametric energyCardioid
NOTE: For large-scale concert presentation, the authors advise choosing the energy optimised beam shape.

Gain match

Decoder gains can be normalised, aka matched, via various criteria:

keywordmatching criteriavalid decoding methods
\beammaximum beam amplitudebeamforming only
\amppressure (loudspeaker sum)all methods
\rmsspherical harmonic energyprojection & mode matching only
\energyloudspeaker energyprojection & mode matching only

Normalising gain to the beam amplitude is appropriate for a virtual microphone or spherical decomposition context. In this case, maximum amplitude of each returned beam is normalised to 0dB.

The other three criteria, pressure, total spherical harmonic energy, and total loudspeaker energy, are preferred for building decoders for loudspeaker audition.

Inherited class methods

Instance Methods

Information

.info

From superclass: AtkMatrix

A convenience method to post the properties of the matrix, including metadata if the matrix was loaded from a .yml file.

.order

From superclass: AtkMatrix

Ambisonic order.

.set

From superclass: HoaMatrix

Describes both the signal set and the tool set, encompassing the Ambisonic order, as well as channel ordering and normalisation.

Ambisonic Toolkit designation indicating Ambisonic order and encoding format. E.g., \FOA, \HOA3.

For instance, \HOA3:

Ambisonic OrderComponent OrderingComponent Normalisation
3rdAmbisonic Channel Number (ACN)Full 3-D normalisation (N3D)

.type

From superclass: HoaMatrix

Ambisonic Toolkit soundfield operation designation. E.g., \encode, \xform, \decode.

.op

From superclass: AtkMatrix

Answers 'matrix', i.e. the type of operation used to compute the resulting signals.

.kind

From superclass: AtkMatrix

Answers the kind.

.dim

From superclass: HoaMatrix

Answers the number of encoder dimensions: 2D or 3D.

.numChannels

From superclass: HoaMatrix

Answers the number of input or output channels, depending on -type.

.directions

From superclass: HoaMatrix

Answers the directions of input or output channels, depending on -type.

.numInputs

From superclass: AtkMatrix

Number of inputs.

.dirInputs

From superclass: HoaMatrix

A convenience method providing polymorphism with -directions, depending on -type.

.numOutputs

From superclass: AtkMatrix

Number of outputs.

.dirOutputs

From superclass: HoaMatrix

A convenience method providing polymorphism with -directions, depending on -type.

Matrix

.matrix

From superclass: AtkMatrix

Returns the raw coefficient Matrix.

.thresh2(thresh)

From superclass: HoaMatrix

Bilateral thresholding in place.

Arguments:

thresh

When the input.abs < thresh, the output is forced to 0. Should be a positive value.

.asArray

From superclass: AtkMatrix

Returns the matrix as a new Array of rows.

File handling

.fileName

From superclass: AtkMatrix

Answers the name of the file used to create the instance, or nil if not created by loading a matrix from a file.

.filePath

From superclass: AtkMatrix

Answers the path of the file used to create the instance, or nil if not created by loading a matrix from a file.

.fileParse

From superclass: AtkMatrix

If the instance was created by loading a .yml file, this method returns the IdentityDictionary containing the parsed metadata. This can be useful if anything was stored in the metadata that can be subsequently used once reloaded, such as encoding directions, rotations, etc.

NOTE: For simply a quick glance at the metadata, it's recommended to use -info.

.writeToFile(fileNameOrPath, note, attributeDictionary, overwrite: false)

From superclass: AtkMatrix

Write the matrix to a file

Arguments:

fileNameOrPath

A String of the file name. The file extension determines the format:

  • .yml allows for additional user-specified metadata (recommended).
  • .txt writes the matrix coefficients only, in rows.
  • .mosl.txt creates basic matrix files compatible with the ATK for Reaper, a set of JSFX plugins for the Reaper DAW.

You may provide a full path if you would like to save the file somewhere other than the default location in the Atk extensions folder. See the Discussion below for more information.

note

A String that is a short description or bit of info about the matrix to store for future reference.

attributeDictionary

A Dictionary containing any information that's useful to store in key:value pairs. Keys that match getters in the AtkMatrix will take precedence over the defaults. See the Discussion for more details.

overwrite

A boolean specifying whether you'd like to force overwriting an existing file of the same name and extension.

Discussion:

The Guide to ATK Matrix Files offers examples and more discussion regarding writing and reading matrices and metadata, including how to generate matrices for use in Reaper.

Analysis

.analyzeAverage

Return an average analysis of decoder amplitude and energies.

Returns:

Analysis is returned in an IdentityDictionary, with the following keys:

keywordanalysis
\amppressure (loudspeaker sum)
\rmsspherical harmonic energy
\energyloudspeaker (angular) energy
\meanEdecoder reduced energy
\matchWeightdecoder matching weights (a Dictionary)

The required weights for gain matching are returned in the \matchWeight Dictionary:

keywordanalysis
\ampmatch weight for pressure (loudspeaker sum)
\rmsmatch weight for spherical harmonic energy
\energymatch weight for loudspeaker energy

Discussion:

Offers a convenient way to check whether designed decoders meet the theoretical performance predicted by HoaOrder.

A regular array, evenly distributed loudspeakers:

Unevenly distributed loudspeakers:

.analyzeDirections(directions)

Return a directional analysis of decoder performance.

Arguments:

directions

A single azimuth value, or an array of test directions. Specify in radians.

Rank 1 arrays return pantophonic, while rank 2 arrays return periphonic. E.g.,

Returns:

Analysis is returned in a an IdentityDictionary, with the following keys:

keywordanalysis
\amppressure (loudspeaker sum)
\rmsspherical harmonic energy
\energyloudspeaker energy
\spreadEenergy spread (a Dictionary)
\rVvelocity localisation vector, rV (a Dictionary)
\rEenergy localisation vector, rE (a Dictionary)

Two measures of energy spread are offered in the \spreadE Dictionary:

keywordanalysis
\cosroll-off to ~-3dB, in radians
\hvcroll-off to ~-6dB, in radians

Information regarding rV, the velocity localisation vector, is returned in the \rV Dictionary:

keywordanalysis
\magnitudesvector magnitudes
\directionsvector directions, in radians
\warpangle distortion from test directions, in radians
\rEwarpangle distortion from rE, in radians
\xyzrV, in cartesian coordinates

Similarly, information regarding rE, the energy localisation vector, is returned in the \rE Dictionary:

keywordanalysis
\magnitudesvector magnitudes
\directionsvector directions, in radians
\warpangle distortion from test directions, in radians
\rVwarpangle distortion from rV, in radians
\xyzrE, in cartesian coordinates

Offers detailed analysis of decoder performance.

A regular array, evenly distributed loudspeakers:

Unevenly distributed loudspeakers:

Inherited instance methods

Examples

Designs

Analysis & plotting

A few functions useful for visualizing decoder performance.

Equatorial rV & rE

A function to plot the velocity and energy localisation vectors in the equatorial plane:

Equatorial rV & rE error

A function to plot velocity and energy localisation vector error in the equatorial plane:

NOTE: Center of table is front center of the array.

Equatorial energy spread

A function to plot energy spread in the equatorial plane:

NOTE: Center of table is front center of the array.

Equatorial amplitude and energy

A function to plot amplitude and energy in the equatorial plane:

NOTE: Center of table is front center of the array.

[1] - See: M. A. Gerzon, "Practical Periphony: The Reproduction of Full-Sphere Sound," in Proceedings of the 65th Audio Engineering Engineering Society Convention, London, 1980, p. 10.