Repository navigation
Silence
James Brundage edited this page Oct 23, 2026
·
1 revision
System.Double[]
Parameters
The duration to generate.
| required | type | position | pipeline | wildcard | aliases |
|---|---|---|---|---|---|
| false | TimeSpan | 1 | false | false |
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 |
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
) )
If you like making waves, please star this repo and consider sponsoring