Skip to content

Silence

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

Silence

Silence Generator

Generates a Silence for a -Duration

Outputs

System.Double[]

Parameters

Duration

The duration to generate.

required type position pipeline wildcard aliases
false TimeSpan 1 false false

SampleRate

The sample rate. Will default to the .SampleRate of $this wave. If there is no $this wave, will default to 44100

required type position pipeline wildcard aliases
false UInt32 2 false false

channelCount

The channel count. Will default to the .ChannelCount of $this wave. If there is no $this wave, will default to 1 (mono).

required type position pipeline wildcard aliases
false UInt16 3 false false
View Source
<#
.SYNOPSIS
    Silence Generator
.DESCRIPTION
    Generates a Silence for a `-Duration`
#>
[OutputType([double[]])]
param(
# The duration to generate.
[Timespan]$Duration = $(
    if ($this.BPM -is [TimeSpan]) {$this.BPM} 
    else { [TimeSpan]::FromSeconds(60/128) }
),
# The sample rate.
# Will default to the `.SampleRate` of `$this` wave.
# If there is no `$this` wave, will default to 44100
[uint32]$SampleRate = $(
    if ($this.SampleRate) { $this.SampleRate } else { 44100 }
),

# The channel count.
# Will default to the `.ChannelCount` of `$this` wave.
# If there is no `$this` wave, will default to 1 (mono).
[uint16]$channelCount = $(
    if ($this.ChannelCount) { $this.ChannelCount } else { 1 }
)
)

# Silence is nothing
$silence = @(0)

# An array of silence is nothing times the number of samples
return ,[double[]]$($silence * [Math]::Round(    
    $Duration.TotalSeconds * $SampleRate * $channelCount
) )

Clone this wiki locally