From 66d6bc3d52f9901ec4cdc48b0c3e3d9ee0b5d7bd Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Thu, 25 Jan 2024 13:58:06 +0100 Subject: [PATCH] Updated some play-* scripts --- scripts/play-imperial-march.ps1 | 46 +++--- scripts/play-jingle-bells.ps1 | 233 ++++++++++++++-------------- scripts/play-mission-impossible.ps1 | 102 ++++++------ 3 files changed, 200 insertions(+), 181 deletions(-) diff --git a/scripts/play-imperial-march.ps1 b/scripts/play-imperial-march.ps1 index f63311b8..c81db814 100755 --- a/scripts/play-imperial-march.ps1 +++ b/scripts/play-imperial-march.ps1 @@ -4,29 +4,35 @@ .DESCRIPTION This PowerShell script plays the Imperial March used in the Star Wars film series. .EXAMPLE - PS> ./play-imperial-march + PS> ./play-imperial-march.ps1 + (listen and enjoy) .LINK https://github.com/fleschutz/PowerShell .NOTES Author: Markus Fleschutz | License: CC0 #> -[System.Console]::beep(440, 500) -[System.Console]::beep(440, 500) -[System.Console]::beep(440, 500) -[System.Console]::beep(349, 350) -[System.Console]::beep(523, 150) -[System.Console]::beep(440, 500) -[System.Console]::beep(349, 350) -[System.Console]::beep(523, 150) -[System.Console]::beep(440, 1000) -[System.Console]::beep(659, 500) -[System.Console]::beep(659, 500) -[System.Console]::beep(659, 500) -[System.Console]::beep(698, 350) -[System.Console]::beep(523, 150) -[System.Console]::beep(415, 500) -[System.Console]::beep(349, 350) -[System.Console]::beep(523, 150) -[System.Console]::beep(440, 1000) -exit 0 # success +try { + [System.Console]::beep(440, 500) + [System.Console]::beep(440, 500) + [System.Console]::beep(440, 500) + [System.Console]::beep(349, 350) + [System.Console]::beep(523, 150) + [System.Console]::beep(440, 500) + [System.Console]::beep(349, 350) + [System.Console]::beep(523, 150) + [System.Console]::beep(440, 1000) + [System.Console]::beep(659, 500) + [System.Console]::beep(659, 500) + [System.Console]::beep(659, 500) + [System.Console]::beep(698, 350) + [System.Console]::beep(523, 150) + [System.Console]::beep(415, 500) + [System.Console]::beep(349, 350) + [System.Console]::beep(523, 150) + [System.Console]::beep(440, 1000) + exit 0 # success +} catch { + "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} diff --git a/scripts/play-jingle-bells.ps1 b/scripts/play-jingle-bells.ps1 index 5ea597ec..df16bf5c 100755 --- a/scripts/play-jingle-bells.ps1 +++ b/scripts/play-jingle-bells.ps1 @@ -4,7 +4,8 @@ .DESCRIPTION This PowerShell script plays the famous Jingle Bells song. .EXAMPLE - PS> ./play-jingle-bells + PS> ./play-jingle-bells.ps1 + (listen and enjoy) .LINK https://github.com/fleschutz/PowerShell .NOTES @@ -46,115 +47,121 @@ $Duration = New-Object -TypeName psobject -Property @{ EIGHTH = 200 SIXTEENTH = 100 } -[System.Console]::Beep($Notes.C, $Duration.EIGHTH ) -[System.Console]::Beep($Notes.C, $Duration.EIGHTH ) -[System.Console]::Beep($Notes.C, $Duration.QUARTER) -[System.Console]::Beep($Notes.AA, $Duration.QUARTER) -[System.Console]::Beep($Notes.G, $Duration.QUARTER) -[System.Console]::Beep($Notes.F, $Duration.QUARTER) -[System.Console]::Beep($Notes.C, $Duration.HALF ) -[System.Console]::Beep($Notes.C, $Duration.EIGHTH ) -[System.Console]::Beep($Notes.C, $Duration.EIGHTH ) -[System.Console]::Beep($Notes.C, $Duration.QUARTER) -[System.Console]::Beep($Notes.AA, $Duration.QUARTER) -[System.Console]::Beep($Notes.G, $Duration.QUARTER) -[System.Console]::Beep($Notes.F, $Duration.QUARTER) -[System.Console]::Beep($Notes.D, $Duration.HALF ) -Start-Sleep -m $Duration.EIGHTH -[System.Console]::Beep($Notes.D, $Duration.EIGHTH ) -[System.Console]::Beep($Notes.E, $Duration.QUARTER) -[System.Console]::Beep($Notes.BB, $Duration.QUARTER) -[System.Console]::Beep($Notes.AA, $Duration.QUARTER) -[System.Console]::Beep($Notes.G, $Duration.QUARTER) -[System.Console]::Beep($Notes.E, $Duration.HALF) -Start-Sleep -m $Duration.EIGHTH -[System.Console]::Beep($Notes.E, $Duration.EIGHTH) -[System.Console]::Beep($Notes.CC, $Duration.QUARTER) -[System.Console]::Beep($Notes.CC, $Duration.QUARTER) -[System.Console]::Beep($Notes.BB, $Duration.QUARTER) -[System.Console]::Beep($Notes.G, $Duration.QUARTER) -[System.Console]::Beep($Notes.AA, $Duration.HALF) -[System.Console]::Beep($Notes.C, $Duration.EIGHTH ) -[System.Console]::Beep($Notes.C, $Duration.EIGHTH ) -[System.Console]::Beep($Notes.C, $Duration.QUARTER) -[System.Console]::Beep($Notes.AA, $Duration.QUARTER) -[System.Console]::Beep($Notes.G, $Duration.QUARTER) -[System.Console]::Beep($Notes.F, $Duration.QUARTER) -[System.Console]::Beep($Notes.C, $Duration.HALF ) -[System.Console]::Beep($Notes.C, $Duration.EIGHTH ) -[System.Console]::Beep($Notes.C, $Duration.EIGHTH ) -[System.Console]::Beep($Notes.C, $Duration.QUARTER) -[System.Console]::Beep($Notes.AA, $Duration.QUARTER) -[System.Console]::Beep($Notes.G, $Duration.QUARTER) -[System.Console]::Beep($Notes.F, $Duration.QUARTER) -[System.Console]::Beep($Notes.D, $Duration.HALF ) -Start-Sleep -m $Duration.QUARTER -[System.Console]::Beep($Notes.D, $Duration.EIGHTH ) -[System.Console]::Beep($Notes.E, $Duration.QUARTER) -[System.Console]::Beep($Notes.BB, $Duration.QUARTER) -[System.Console]::Beep($Notes.AA, $Duration.QUARTER) -[System.Console]::Beep($Notes.G, $Duration.QUARTER) -[System.Console]::Beep($Notes.CC, $Duration.QUARTER) -[System.Console]::Beep($Notes.CC, $Duration.QUARTER) -[System.Console]::Beep($Notes.CC, $Duration.QUARTER) -[System.Console]::Beep($Notes.CC, $Duration.EIGHTH) -[System.Console]::Beep($Notes.DD, $Duration.QUARTER) -[System.Console]::Beep($Notes.CC, $Duration.QUARTER) -[System.Console]::Beep($Notes.BB, $Duration.QUARTER) -[System.Console]::Beep($Notes.G, $Duration.QUARTER) -[System.Console]::Beep($Notes.F, $Duration.HALF) -[System.Console]::Beep($Notes.CC, $Duration.HALF) -[System.Console]::Beep($Notes.AA, $Duration.QUARTER) -[System.Console]::Beep($Notes.AA, $Duration.QUARTER) -[System.Console]::Beep($Notes.AA, $Duration.HALF) -[System.Console]::Beep($Notes.AA, $Duration.QUARTER) -[System.Console]::Beep($Notes.AA, $Duration.QUARTER) -[System.Console]::Beep($Notes.AA, $Duration.HALF) -[System.Console]::Beep($Notes.AA, $Duration.QUARTER) -[System.Console]::Beep($Notes.CC, $Duration.QUARTER) -[System.Console]::Beep($Notes.F, $Duration.QUARTER) -[System.Console]::Beep($Notes.G, $Duration.EIGHTH) -[System.Console]::Beep($Notes.AA, $Duration.HALF) -Start-Sleep -m $Duration.EIGHTH -[System.Console]::Beep($Notes.BB, $Duration.QUARTER) -[System.Console]::Beep($Notes.BB, $Duration.QUARTER) -[System.Console]::Beep($Notes.BB, $Duration.QUARTER) -[System.Console]::Beep($Notes.BB, $Duration.EIGHTH) -[System.Console]::Beep($Notes.BB, $Duration.QUARTER) -[System.Console]::Beep($Notes.AA, $Duration.QUARTER) -[System.Console]::Beep($Notes.AA, $Duration.QUARTER) -[System.Console]::Beep($Notes.AA, $Duration.EIGHTH) -[System.Console]::Beep($Notes.AA, $Duration.EIGHTH) -[System.Console]::Beep($Notes.AA, $Duration.QUARTER) -[System.Console]::Beep($Notes.G, $Duration.QUARTER) -[System.Console]::Beep($Notes.G, $Duration.QUARTER) -[System.Console]::Beep($Notes.AA, $Duration.QUARTER) -[System.Console]::Beep($Notes.G, $Duration.HALF) -[System.Console]::Beep($Notes.CC, $Duration.HALF) -[System.Console]::Beep($Notes.AA, $Duration.QUARTER) -[System.Console]::Beep($Notes.AA, $Duration.QUARTER) -[System.Console]::Beep($Notes.AA, $Duration.HALF) -[System.Console]::Beep($Notes.AA, $Duration.QUARTER) -[System.Console]::Beep($Notes.AA, $Duration.QUARTER) -[System.Console]::Beep($Notes.AA, $Duration.HALF) -[System.Console]::Beep($Notes.AA, $Duration.QUARTER) -[System.Console]::Beep($Notes.CC, $Duration.QUARTER) -[System.Console]::Beep($Notes.F, $Duration.QUARTER) -[System.Console]::Beep($Notes.G, $Duration.EIGHTH) -[System.Console]::Beep($Notes.AA, $Duration.HALF) -Start-Sleep -m $Duration.EIGHTH -[System.Console]::Beep($Notes.CC, $Duration.QUARTER) -[System.Console]::Beep($Notes.CC, $Duration.QUARTER) -[System.Console]::Beep($Notes.CC, $Duration.QUARTER) -[System.Console]::Beep($Notes.CC, $Duration.EIGHTH) -[System.Console]::Beep($Notes.CC, $Duration.QUARTER) -[System.Console]::Beep($Notes.AA, $Duration.QUARTER) -[System.Console]::Beep($Notes.AA, $Duration.QUARTER) -[System.Console]::Beep($Notes.AA, $Duration.EIGHTH) -[System.Console]::Beep($Notes.AA, $Duration.EIGHTH) -[System.Console]::Beep($Notes.CC, $Duration.QUARTER) -[System.Console]::Beep($Notes.CC, $Duration.QUARTER) -[System.Console]::Beep($Notes.BB, $Duration.QUARTER) -[System.Console]::Beep($Notes.G, $Duration.QUARTER) -[System.Console]::Beep($Notes.F, $Duration.HALF) -exit 0 # success + +try { + [System.Console]::Beep($Notes.C, $Duration.EIGHTH ) + [System.Console]::Beep($Notes.C, $Duration.EIGHTH ) + [System.Console]::Beep($Notes.C, $Duration.QUARTER) + [System.Console]::Beep($Notes.AA, $Duration.QUARTER) + [System.Console]::Beep($Notes.G, $Duration.QUARTER) + [System.Console]::Beep($Notes.F, $Duration.QUARTER) + [System.Console]::Beep($Notes.C, $Duration.HALF ) + [System.Console]::Beep($Notes.C, $Duration.EIGHTH ) + [System.Console]::Beep($Notes.C, $Duration.EIGHTH ) + [System.Console]::Beep($Notes.C, $Duration.QUARTER) + [System.Console]::Beep($Notes.AA, $Duration.QUARTER) + [System.Console]::Beep($Notes.G, $Duration.QUARTER) + [System.Console]::Beep($Notes.F, $Duration.QUARTER) + [System.Console]::Beep($Notes.D, $Duration.HALF ) + Start-Sleep -m $Duration.EIGHTH + [System.Console]::Beep($Notes.D, $Duration.EIGHTH ) + [System.Console]::Beep($Notes.E, $Duration.QUARTER) + [System.Console]::Beep($Notes.BB, $Duration.QUARTER) + [System.Console]::Beep($Notes.AA, $Duration.QUARTER) + [System.Console]::Beep($Notes.G, $Duration.QUARTER) + [System.Console]::Beep($Notes.E, $Duration.HALF) + Start-Sleep -m $Duration.EIGHTH + [System.Console]::Beep($Notes.E, $Duration.EIGHTH) + [System.Console]::Beep($Notes.CC, $Duration.QUARTER) + [System.Console]::Beep($Notes.CC, $Duration.QUARTER) + [System.Console]::Beep($Notes.BB, $Duration.QUARTER) + [System.Console]::Beep($Notes.G, $Duration.QUARTER) + [System.Console]::Beep($Notes.AA, $Duration.HALF) + [System.Console]::Beep($Notes.C, $Duration.EIGHTH ) + [System.Console]::Beep($Notes.C, $Duration.EIGHTH ) + [System.Console]::Beep($Notes.C, $Duration.QUARTER) + [System.Console]::Beep($Notes.AA, $Duration.QUARTER) + [System.Console]::Beep($Notes.G, $Duration.QUARTER) + [System.Console]::Beep($Notes.F, $Duration.QUARTER) + [System.Console]::Beep($Notes.C, $Duration.HALF ) + [System.Console]::Beep($Notes.C, $Duration.EIGHTH ) + [System.Console]::Beep($Notes.C, $Duration.EIGHTH ) + [System.Console]::Beep($Notes.C, $Duration.QUARTER) + [System.Console]::Beep($Notes.AA, $Duration.QUARTER) + [System.Console]::Beep($Notes.G, $Duration.QUARTER) + [System.Console]::Beep($Notes.F, $Duration.QUARTER) + [System.Console]::Beep($Notes.D, $Duration.HALF ) + Start-Sleep -m $Duration.QUARTER + [System.Console]::Beep($Notes.D, $Duration.EIGHTH ) + [System.Console]::Beep($Notes.E, $Duration.QUARTER) + [System.Console]::Beep($Notes.BB, $Duration.QUARTER) + [System.Console]::Beep($Notes.AA, $Duration.QUARTER) + [System.Console]::Beep($Notes.G, $Duration.QUARTER) + [System.Console]::Beep($Notes.CC, $Duration.QUARTER) + [System.Console]::Beep($Notes.CC, $Duration.QUARTER) + [System.Console]::Beep($Notes.CC, $Duration.QUARTER) + [System.Console]::Beep($Notes.CC, $Duration.EIGHTH) + [System.Console]::Beep($Notes.DD, $Duration.QUARTER) + [System.Console]::Beep($Notes.CC, $Duration.QUARTER) + [System.Console]::Beep($Notes.BB, $Duration.QUARTER) + [System.Console]::Beep($Notes.G, $Duration.QUARTER) + [System.Console]::Beep($Notes.F, $Duration.HALF) + [System.Console]::Beep($Notes.CC, $Duration.HALF) + [System.Console]::Beep($Notes.AA, $Duration.QUARTER) + [System.Console]::Beep($Notes.AA, $Duration.QUARTER) + [System.Console]::Beep($Notes.AA, $Duration.HALF) + [System.Console]::Beep($Notes.AA, $Duration.QUARTER) + [System.Console]::Beep($Notes.AA, $Duration.QUARTER) + [System.Console]::Beep($Notes.AA, $Duration.HALF) + [System.Console]::Beep($Notes.AA, $Duration.QUARTER) + [System.Console]::Beep($Notes.CC, $Duration.QUARTER) + [System.Console]::Beep($Notes.F, $Duration.QUARTER) + [System.Console]::Beep($Notes.G, $Duration.EIGHTH) + [System.Console]::Beep($Notes.AA, $Duration.HALF) + Start-Sleep -m $Duration.EIGHTH + [System.Console]::Beep($Notes.BB, $Duration.QUARTER) + [System.Console]::Beep($Notes.BB, $Duration.QUARTER) + [System.Console]::Beep($Notes.BB, $Duration.QUARTER) + [System.Console]::Beep($Notes.BB, $Duration.EIGHTH) + [System.Console]::Beep($Notes.BB, $Duration.QUARTER) + [System.Console]::Beep($Notes.AA, $Duration.QUARTER) + [System.Console]::Beep($Notes.AA, $Duration.QUARTER) + [System.Console]::Beep($Notes.AA, $Duration.EIGHTH) + [System.Console]::Beep($Notes.AA, $Duration.EIGHTH) + [System.Console]::Beep($Notes.AA, $Duration.QUARTER) + [System.Console]::Beep($Notes.G, $Duration.QUARTER) + [System.Console]::Beep($Notes.G, $Duration.QUARTER) + [System.Console]::Beep($Notes.AA, $Duration.QUARTER) + [System.Console]::Beep($Notes.G, $Duration.HALF) + [System.Console]::Beep($Notes.CC, $Duration.HALF) + [System.Console]::Beep($Notes.AA, $Duration.QUARTER) + [System.Console]::Beep($Notes.AA, $Duration.QUARTER) + [System.Console]::Beep($Notes.AA, $Duration.HALF) + [System.Console]::Beep($Notes.AA, $Duration.QUARTER) + [System.Console]::Beep($Notes.AA, $Duration.QUARTER) + [System.Console]::Beep($Notes.AA, $Duration.HALF) + [System.Console]::Beep($Notes.AA, $Duration.QUARTER) + [System.Console]::Beep($Notes.CC, $Duration.QUARTER) + [System.Console]::Beep($Notes.F, $Duration.QUARTER) + [System.Console]::Beep($Notes.G, $Duration.EIGHTH) + [System.Console]::Beep($Notes.AA, $Duration.HALF) + Start-Sleep -m $Duration.EIGHTH + [System.Console]::Beep($Notes.CC, $Duration.QUARTER) + [System.Console]::Beep($Notes.CC, $Duration.QUARTER) + [System.Console]::Beep($Notes.CC, $Duration.QUARTER) + [System.Console]::Beep($Notes.CC, $Duration.EIGHTH) + [System.Console]::Beep($Notes.CC, $Duration.QUARTER) + [System.Console]::Beep($Notes.AA, $Duration.QUARTER) + [System.Console]::Beep($Notes.AA, $Duration.QUARTER) + [System.Console]::Beep($Notes.AA, $Duration.EIGHTH) + [System.Console]::Beep($Notes.AA, $Duration.EIGHTH) + [System.Console]::Beep($Notes.CC, $Duration.QUARTER) + [System.Console]::Beep($Notes.CC, $Duration.QUARTER) + [System.Console]::Beep($Notes.BB, $Duration.QUARTER) + [System.Console]::Beep($Notes.G, $Duration.QUARTER) + [System.Console]::Beep($Notes.F, $Duration.HALF) + exit 0 # success +} catch { + "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} diff --git a/scripts/play-mission-impossible.ps1 b/scripts/play-mission-impossible.ps1 index 9e96d716..30c77c16 100755 --- a/scripts/play-mission-impossible.ps1 +++ b/scripts/play-mission-impossible.ps1 @@ -4,57 +4,63 @@ .DESCRIPTION This PowerShell script plays the Mission Impossible theme. .EXAMPLE - PS> ./play-mission-impossible + PS> ./play-mission-impossible.ps1 + (listen and enjoy) .LINK https://github.com/fleschutz/PowerShell .NOTES Author: Markus Fleschutz | License: CC0 #> -[System.Console]::Beep(784,150) -Start-Sleep -m 300 -[System.Console]::Beep(784,150) -Start-Sleep -m 300 -[System.Console]::Beep(932,150) -Start-Sleep -m 150 -[System.Console]::Beep(1047,150) -Start-Sleep -m 150 -[System.Console]::Beep(784,150) -Start-Sleep -m 300 -[System.Console]::Beep(784,150) -Start-Sleep -m 300 -[console]::Beep(699,150) -Start-Sleep -m 150 -[System.Console]::Beep(740,150) -Start-Sleep -m 150 -[System.Console]::Beep(784,150) -Start-Sleep -m 300 -[System.Console]::Beep(784,150) -Start-Sleep -m 300 -[System.Console]::Beep(932,150) -Start-Sleep -m 150 -[System.Console]::Beep(1047,150) -Start-Sleep -m 150 -[System.Console]::Beep(784,150) -Start-Sleep -m 300 -[System.Console]::Beep(784,150) -Start-Sleep -m 300 -[System.Console]::Beep(699,150) -Start-Sleep -m 150 -[System.Console]::Beep(740,150) -Start-Sleep -m 150 -[System.Console]::Beep(932,150) -[System.Console]::Beep(784,150) -[System.Console]::Beep(587,1200) -Start-Sleep -m 75 -[System.Console]::Beep(932,150) -[System.Console]::Beep(784,150) -[System.Console]::Beep(554,1200) -Start-Sleep -m 75 -[System.Console]::Beep(932,150) -[System.Console]::Beep(784,150) -[System.Console]::Beep(523,1200) -Start-Sleep -m 150 -[System.Console]::Beep(466,150) -[System.Console]::Beep(523,150) -exit 0 # success +try { + [System.Console]::Beep(784,150) + Start-Sleep -m 300 + [System.Console]::Beep(784,150) + Start-Sleep -m 300 + [System.Console]::Beep(932,150) + Start-Sleep -m 150 + [System.Console]::Beep(1047,150) + Start-Sleep -m 150 + [System.Console]::Beep(784,150) + Start-Sleep -m 300 + [System.Console]::Beep(784,150) + Start-Sleep -m 300 + [console]::Beep(699,150) + Start-Sleep -m 150 + [System.Console]::Beep(740,150) + Start-Sleep -m 150 + [System.Console]::Beep(784,150) + Start-Sleep -m 300 + [System.Console]::Beep(784,150) + Start-Sleep -m 300 + [System.Console]::Beep(932,150) + Start-Sleep -m 150 + [System.Console]::Beep(1047,150) + Start-Sleep -m 150 + [System.Console]::Beep(784,150) + Start-Sleep -m 300 + [System.Console]::Beep(784,150) + Start-Sleep -m 300 + [System.Console]::Beep(699,150) + Start-Sleep -m 150 + [System.Console]::Beep(740,150) + Start-Sleep -m 150 + [System.Console]::Beep(932,150) + [System.Console]::Beep(784,150) + [System.Console]::Beep(587,1200) + Start-Sleep -m 75 + [System.Console]::Beep(932,150) + [System.Console]::Beep(784,150) + [System.Console]::Beep(554,1200) + Start-Sleep -m 75 + [System.Console]::Beep(932,150) + [System.Console]::Beep(784,150) + [System.Console]::Beep(523,1200) + Start-Sleep -m 150 + [System.Console]::Beep(466,150) + [System.Console]::Beep(523,150) + exit 0 # success +} catch { + "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +}