Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# define melody
$melody = @(
@('g4',[Duration]::EIGHTH), @('PAUSE',[Duration]::SIXTEENTH),
@('c5',[Duration]::EIGHTH), @('PAUSE',[Duration]::SIXTEENTH),
@('c5',[Duration]::EIGHTH),
@('d5',[Duration]::EIGHTH),
@('c5',[Duration]::EIGHTH),
@('b4',[Duration]::EIGHTH),
@('a4',[Duration]::EIGHTH), @('PAUSE',[Duration]::SIXTEENTH),
@('a4',[Duration]::EIGHTH), @('PAUSE',[Duration]::SIXTEENTH),
@('a4',[Duration]::EIGHTH), @('PAUSE',[Duration]::SIXTEENTH),
@('d5',[Duration]::EIGHTH), @('PAUSE',[Duration]::SIXTEENTH),
@('d5',[Duration]::EIGHTH),
@('e5',[Duration]::EIGHTH),
@('d5',[Duration]::EIGHTH),
@('c5',[Duration]::EIGHTH),
@('b4',[Duration]::EIGHTH), @('PAUSE',[Duration]::SIXTEENTH),
@('g4',[Duration]::EIGHTH), @('PAUSE',[Duration]::SIXTEENTH)
@('g4',[Duration]::EIGHTH), @('PAUSE',[Duration]::SIXTEENTH),
@('e5',[Duration]::EIGHTH), @('PAUSE',[Duration]::SIXTEENTH),
@('e5',[Duration]::EIGHTH),
@('f5',[Duration]::EIGHTH),
@('e5',[Duration]::EIGHTH),
@('d5',[Duration]::EIGHTH),
@('c5',[Duration]::EIGHTH), @('PAUSE',[Duration]::SIXTEENTH),
@('a4',[Duration]::EIGHTH), @('PAUSE',[Duration]::SIXTEENTH),
@('g4',[Duration]::EIGHTH), @('PAUSE',[Duration]::SIXTEENTH),
@('a4',[Duration]::EIGHTH), @('PAUSE',[Duration]::SIXTEENTH),
@('d5',[Duration]::EIGHTH), @('PAUSE',[Duration]::SIXTEENTH),
@('b4',[Duration]::EIGHTH), @('PAUSE',[Duration]::SIXTEENTH),
@('c5',[Duration]::EIGHTH)
)
# play melody
foreach ($note in $melody) {
if (-not($note[0] -eq 'PAUSE')) {
(ConvertTo-NoteFrequency $note[0]).Play($note[1])
}
else {
Start-Sleep -Milliseconds $note[1]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment