Skip to content

Pan

Functions

(Functions that are not associated with a Struct)

fn pan2

Simple constant power panning function.

Signature

def pan2(samples: Float64, pan: Float64) -> SIMD[DType.float64, 2]

Arguments

Name Type Default Description
samples Float64 Float64 - Mono input sample.
pan Float64 Float64 - Pan value from -1.0 (left) to 1.0 (right).

Returns

Type: SIMD[DType.float64, 2] Stereo output as MFloat[2].

fn pan_stereo

Simple constant power panning function for stereo samples.

Signature

def pan_stereo(samples: SIMD[DType.float64, 2], pan: Float64) -> SIMD[DType.float64, 2]

Arguments

Name Type Default Description
samples SIMD[DType.float64, 2] MFloat[2] - Stereo input sample.
pan Float64 Float64 - Pan value from -1.0 (left) to 1.0 (right).

Returns

Type: SIMD[DType.float64, 2] Stereo output as MFloat[2].

fn splay

Splay multiple input channels into stereo output.

There are multiple versions of splay to handle different input types. It can take a List or InlineArray of SIMD vectors, a VariadicList of SIMD, or a single 1 or many channel SIMD vector. In the case of a list of SIMD vectors, each channel within the vector is treated separately and panned individually.

Signature

def splay[num_simd: Int](*input: SIMD[DType.float64, num_simd], *, world: UnsafePointer[MMMWorld, MutUntrackedOrigin]) -> SIMD[DType.float64, 2]

Parameters

Name Type Description
num_simd Int Number of channels in each SIMD input.

Arguments

Name Type Default Description
*input SIMD[DType.float64, num_simd] VariadicList of input samples from multiple channels.
world UnsafePointer[MMMWorld, MutUntrackedOrigin] Pointer to MMMWorld containing the pan_window.

Returns

Type: SIMD[DType.float64, 2] Stereo output as MFloat[2].



fn splay

Splay multiple input channels into stereo output.

There are multiple versions of splay to handle different input types. It can take a List or InlineArray of SIMD vectors, a VariadicList of SIMD, or a single 1 or many channel SIMD vector. In the case of a list of SIMD vectors, each channel within the vector is treated separately and panned individually.

Signature

def splay[num_simd: Int](input: Span[SIMD[DType.float64, num_simd]], world: UnsafePointer[MMMWorld, MutUntrackedOrigin]) -> SIMD[DType.float64, 2]

Parameters

Name Type Description
num_simd Int Number of channels in each SIMD input.

Arguments

Name Type Default Description
input Span[SIMD[DType.float64, num_simd]] VariadicList of input samples from multiple channels.
world UnsafePointer[MMMWorld, MutUntrackedOrigin] Pointer to MMMWorld containing the pan_window.

Returns

Type: SIMD[DType.float64, 2] Stereo output as MFloat[2].

fn splay

Splay multiple input channels into stereo output.

There are multiple versions of splay to handle different input types. It can take a List or InlineArray of SIMD vectors, a VariadicList of SIMD, or a single 1 or many channel SIMD vector. In the case of a list of SIMD vectors, each channel within the vector is treated separately and panned individually.

Signature

def splay[num_input_channels: Int](input: SIMD[DType.float64, num_input_channels], world: UnsafePointer[MMMWorld, MutUntrackedOrigin]) -> SIMD[DType.float64, 2]

Parameters

Name Type Description
num_input_channels Int Number of input channels.

Arguments

Name Type Default Description
input SIMD[DType.float64, num_input_channels] VariadicList of input samples from multiple channels.
world UnsafePointer[MMMWorld, MutUntrackedOrigin] Pointer to MMMWorld containing the pan_window.

Returns

Type: SIMD[DType.float64, 2] Stereo output as MFloat[2].

fn make_mul_list

Signature

def make_mul_list[num_speakers: Int, simd_out_size: Int, pan_points: Int]() -> InlineArray[SIMD[DType.float64, simd_out_size], pan_points]

Parameters

Name Type Description
num_speakers Int
simd_out_size Int
pan_points Int

Returns

Type: InlineArray[SIMD[DType.float64, simd_out_size], pan_points]

fn splay_n

Splay multiple input channels into an arbitrary number of output channels.

Signature

def splay_n[simd_in_width: Int, num_speakers: Int, simd_out_size: Int, pan_points: Int](input: Span[SIMD[DType.float64, simd_in_width]], world: UnsafePointer[MMMWorld, MutUntrackedOrigin]) -> SIMD[DType.float64, simd_out_size]

Parameters

Name Type Description
simd_in_width Int Number of channels in each SIMD input.
num_speakers Int Number of output speakers. Must be less than or equal to simd_out_size.
simd_out_size Int Number of channels of the SIMD output vector. Must be a power of two that is at least as large as num_speakers.
pan_points Int Number of discrete pan points to calculate for the panning algorithm. More pan points will increase the resolution of the pan but also increase CPU usage. 100 is usually sufficient for smooth panning.

Arguments

Name Type Default Description
input Span[SIMD[DType.float64, simd_in_width]] Span of input samples from multiple channels, where each channel is a SIMD vector.
world UnsafePointer[MMMWorld, MutUntrackedOrigin] Pointer to MMMWorld containing the pan_window.

Returns

Type: SIMD[DType.float64, simd_out_size] MFloat[simd_out_size]: The panned output with one speaker per channel. Extra SIMD channels will be filled with zeros.

fn pan_az

Pan a mono sample to N speakers arranged in a circle around the listener using azimuth panning.

Signature

def pan_az[simd_out_size: Int = 2](sample: Float64, pan: Float64, num_speakers: Int, width: Float64 = 2, orientation: Float64 = 0.5) -> SIMD[DType.float64, simd_out_size]

Parameters

Name Type Description
simd_out_size Int Number of output channels (speakers). Must be a power of two that is at least as large as num_speakers.

Arguments

Name Type Default Description
sample Float64 Mono input sample.
pan Float64 Pan position from 0.0 to 1.0.
num_speakers Int Number of speakers to pan to.
width Float64 2 Width of the speaker array (default is 2.0).
orientation Float64 0.5 Orientation offset of the speaker array (default is 0.5).

Returns

Type: SIMD[DType.float64, simd_out_size] MFloat[simd_out_size]: The panned output sample for each speaker.




fn pan_az

Pan a mono sample to N speakers arranged in a circle around the listener using azimuth panning. This version fixes the number of speakers, width, and orientation at compile time for better performance.

Signature

def pan_az[num_speakers: Int = 2, simd_out_size: Int = 2, width: Float64 = 2, orientation: Float64 = 0.5](sample: Float64, pan: Float64) -> SIMD[DType.float64, simd_out_size]

Parameters

Name Type Description
num_speakers Int Number of output speakers. Can be any integer, but must be less than or equal to simd_out_size.
simd_out_size Int Number of channels of the SIMD output vector. Must be a power of two that is at least as large as num_speakers.
width Float64 Width of the speaker array (default is 2.0).
orientation Float64 Orientation offset of the speaker array (default is 0.5).

Arguments

Name Type Default Description
sample Float64 Mono input sample.
pan Float64 Pan position from 0.0 to 1.0.

Returns

Type: SIMD[DType.float64, simd_out_size] MFloat[simd_out_size]: The panned output sample for each speaker.

fn dbap2D

Implements DBAP (Distance Based Amplitude Panning). Pans a mono sample to N speakers of arbitrary positions in meters. For more on DBAP see the paper written by Trond Lossius, Pascal Baltazar, and Theo de la Hague. https://jamoma.org/publications/attachments/icmc2009-dbap-rev1.pdf .

Signature

def dbap2D[num_speakers: Int, simd_out_size: Int, speaker_positions: InlineArray[SIMD[DType.float64, 2], num_speakers], weights: InlineArray[Float64, num_speakers]](sample: Float64, pos: SIMD[DType.float64, 2], blur: Float64 = 0.10000000000000001, rolloff: Float64 = Float64("6")) -> SIMD[DType.float64, simd_out_size]

Parameters

Name Type Description
num_speakers Int The number of speakers as an integer.
simd_out_size Int Must be a power of 2 and greater than num_speakers.
speaker_positions InlineArray[SIMD[DType.float64, 2], num_speakers] The speaker positions as an InlineArray of MFloat[2] x/y pairs in meters from a center position.
weights InlineArray[Float64, num_speakers] An InlineArray of Float64s (between 0.0 and 1.0) defining speaker weights for DBAP. Speaker weights allow for a source to be restricted to a subset of speakers. Speaker weights of 0.0 will disallow a source from playing through that speaker.

Arguments

Name Type Default Description
sample Float64 Mono input sample.
pos SIMD[DType.float64, 2] X/Y position of the source from center in meters as an MFloat[2].
blur Float64 0.10000000000000001 Blurs the source, causing it to spread to more speakers. Values must be greater than or equal to 0, with 0 being the most localizable and values > 0 becoming less and less localizable. There is no limit to the amount of blur but values over 5 have diminishing returns.
rolloff Float64 Float64("6") The amplitude rolloff in dB, this must be > 0.0. 6.0 equals the inverse distance law for sound in an open field. Lower values will decrease the attenuation of the signal over distance, while larger values will increase this attenuation.

Returns

Type: SIMD[DType.float64, simd_out_size] MFloat[simd_out_size]: The panned output sample for each speaker.

fn vbap2D

An implementation of VBAP (Vector Base Amplitude Panning). Pans a mono sample to a 2D array of N speakers of arbitrary positions in radians that are equidistant from the listener. For more on VBAP see the paper written by Ville Pulkki: https://www.audiolabs-erlangen.de/media/pages/resources/aps-w23/papers/935eb793db-1663358804/sap_Pulkki1997.pdf .

Signature

def vbap2D[num_speakers: Int, simd_out_size: Int, speaker_positions: InlineArray[Float64, num_speakers]](sample: Float64, az: Float64, offset: Float64 = 0) -> SIMD[DType.float64, simd_out_size]

Parameters

Name Type Description
num_speakers Int The number of speakers as an integer.
simd_out_size Int Must be a power of 2 and greater than num_speakers.
speaker_positions InlineArray[Float64, num_speakers] The speaker positions as an InlineArray of Float64 azimuth angles in radians.

Arguments

Name Type Default Description
sample Float64 The mono signal to be panned.
az Float64 The angle of the source in radians.
offset Float64 0 An offset in radians. This rotates the entire speaker array. Is this needed?

Returns

Type: SIMD[DType.float64, simd_out_size] MFloat[simd_out_size]: The panned output sample for each speaker.

fn variance_of_dists

Signature

def variance_of_dists[comp_num_speakers: Int, comp_speaker_positions: InlineArray[SIMD[DType.float64, 2], comp_num_speakers]]() -> Float64

Parameters

Name Type Description
comp_num_speakers Int
comp_speaker_positions InlineArray[SIMD[DType.float64, 2], comp_num_speakers]

Returns

Type: Float64

fn calc_speaker_unit_vectors

Signature

def calc_speaker_unit_vectors[num_speakers: Int, speaker_positions: InlineArray[Float64, num_speakers], //]() -> InlineArray[SIMD[DType.float64, 2], num_speakers]

Parameters

Name Type Description
num_speakers Int
speaker_positions InlineArray[Float64, num_speakers]

Returns

Type: InlineArray[SIMD[DType.float64, 2], num_speakers]

fn calc_inverse_base

Signature

def calc_inverse_base[num_speakers: Int, //, speaker_pairs: InlineArray[InlineArray[Int, 2], num_speakers], speaker_vectors: InlineArray[SIMD[DType.float64, 2], num_speakers]]() -> InlineArray[InlineArray[SIMD[DType.float64, 2], 2], num_speakers]

Parameters

Name Type Description
num_speakers Int
speaker_pairs InlineArray[InlineArray[Int, 2], num_speakers]
speaker_vectors InlineArray[SIMD[DType.float64, 2], num_speakers]

Returns

Type: InlineArray[InlineArray[SIMD[DType.float64, 2], 2], num_speakers]

fn index_of

Signature

def index_of(array: InlineArray[Float64], element: Float64) -> Int

Arguments

Name Type Default Description
array InlineArray[Float64]
element Float64

Returns

Type: Int

fn calc_speaker_pairs

Signature

def calc_speaker_pairs[num_speakers: Int, //, speaker_az: InlineArray[Float64, num_speakers]]() -> InlineArray[InlineArray[Int, 2], num_speakers]

Parameters

Name Type Description
num_speakers Int
speaker_az InlineArray[Float64, num_speakers]

Returns

Type: InlineArray[InlineArray[Int, 2], num_speakers]

fn calc_gain_factors

Signature

def calc_gain_factors[num_speakers: Int, speaker_positions: InlineArray[Float64, num_speakers], //](source_vec: SIMD[DType.float64, 2], mut active_pair: InlineArray[Int, 2], mut active_gains: SIMD[DType.float64, 2], source_az: Float64)

Parameters

Name Type Description
num_speakers Int
speaker_positions InlineArray[Float64, num_speakers]

Arguments

Name Type Default Description
source_vec SIMD[DType.float64, 2]
active_pair InlineArray[Int, 2]
active_gains SIMD[DType.float64, 2]
source_az Float64

Documentation generated with mojo doc from Mojo version 1.0.0b2