Skip to content
James Brundage edited this page Oct 23, 2026 · 1 revision

Pan

Pans a Wave

Pans a wave between even and odd samples.

Notes

A pan is effectively a selective gain.

If we provide a ratio of 0, we will multiply each even sample by 0, and each odd sample by 1.

This will give us the left channel in stereo.

Alternatively, if we provide a ratio of 1, we will multiply each odd sample by 0, and each even sample by 1.

This will give us the right channel in stereo.

Parameters

Ratio

The pan ratio. Providing values greater than zero or less than one will alternate the phase of the opposite channel.

required type position pipeline wildcard aliases
false Double 1 false false
View Source
<#
.SYNOPSIS
    Pans a Wave
.DESCRIPTION
    Pans a wave between even and odd samples.    
.NOTES
    A pan is effectively a selective gain.

    If we provide a ratio of 0, 
    we will multiply each even sample by 0, 
    and each odd sample by 1.

    This will give us the left channel in stereo.

    Alternatively, if we provide a ratio of 1,
    we will multiply each odd sample by 0, 
    and each even sample by 1.

    This will give us the right channel in stereo.
#>
param(
# The pan ratio.
# Providing values greater than zero or less 
# than one will alternate the phase of the opposite channel.
[double]
$Ratio
)

# Collect our samples
[double[]]$Samples = $this.Samples

# Generate our pan
[double[]]$Panned = for ($index = 0 ; $index -lt $samples.Length; $index++) {
    $odd = $index % 2
    if ($odd) {
        $samples[$index] * $ratio
    } else {
        $samples[$index] * (1 - $ratio)
    }    
}

$waveFormat = $this.WaveFormat
wave @waveFormat -Samples $Panned

Clone this wiki locally