Repository navigation
Gain
James Brundage edited this page Oct 23, 2026
·
1 revision
A positive gain will multiply each sample by that number A negative gain will divide each sample by that number
A gain multiplies each sample in the wave by a ratio, increasing overall loudness.
Applying a Gain of 1 would leave the audio unchanged.
Applying a Gain of 0.5 would half the loudness of the audio.
Applying a Gain of 1.05 would be 5% louder.
Applying a Gain of 2 would double the loudness of the audio.
Please do not provide high values to this function.
The speakers and eardrums you save may be your own.
Parameters
By default, applys a 5% gain
| required | type | position | pipeline | wildcard | aliases |
|---|---|---|---|---|---|
| false | Double | 1 | false | false |
View Source
<#
.SYNOPSIS
Wave Gain
.DESCRIPTION
Gains volume in a wave.
A positive gain will multiply each sample by that number
A negative gain will divide each sample by that number
A gain multiplies each sample in the wave by a ratio,
increasing overall loudness.
Applying a Gain of 1 would leave the audio unchanged.
Applying a Gain of 0.5 would half the loudness of the audio.
Applying a Gain of 1.05 would be 5% louder.
Applying a Gain of 2 would double the loudness of the audio.
Please do not provide high values to this function.
The speakers and eardrums you save may be your own.
#>
param(
# By default, applys a 5% gain
[double]
$Gain = 1.05
)
# Collect our samples
[double[]]$Samples = $this.Samples
# If gain is negative, make it the reciprocal
if ($gain -lt 0) {
$gain = 1/[Math]::Abs($Gain)
}
# Apply the gain
[double[]]$Gained = for ($index = 0 ; $index -lt $samples.Length; $index++) {
$samples[$index] * $gain
}
$waveFormat = $this.WaveFormat
wave @waveFormat -Samples $Gained
If you like making waves, please star this repo and consider sponsoring