Skip to content

PowerShell-Fun!

One of the best games in the history of console gaming (since Deus Ex is obviously the best game of all time ever) is undoubtedly Zelda - Ocarina of Time. What has this got to do with the PowerShell?



The answer to this question is a simple .NET-Method: Console.Beep. The Beep-Method accepts a tone frequency in kHz and a time value in ms. Throw everything together, and you get:


[Console]::Beep("440","500") #A4 concert pitch, 500ms
[Console]::Beep("293.228","1000") #D4, 1s
[Console]::Beep("349.228","500") #F4, 500ms
[Console]::Beep("440","500") #A4 concert pitch, 500ms
[Console]::Beep("293.228","1000") #D4, 1s
[Console]::Beep("349.228","500") #F4, 500ms
[Console]::Beep("440","250") #A4 concert pitch, 250ms
[Console]::Beep("523.251","250") #C5, 250ms
[Console]::Beep("493.833","500") #B4, 500ms
[Console]::Beep("391.995","500") #G4, 500ms
[Console]::Beep("349.228","250") #F4, 250ms
[Console]::Beep("391.995","250") #G4, 250ms
[Console]::Beep("440","500") #A4 concert pitch, 500ms
[Console]::Beep("293.228","500") #D4, 500ms
[Console]::Beep("261.626","250") #C4, 250ms
[Console]::Beep("329.628","250") #E4, 250ms
[Console]::Beep("293.665","2500") #D4, 2.5s



Voila! The song of time.



You could also write the whole suite of music in a module like this:


function Get-SongOfTime()
{
[Console]::Beep("440","500") #Kammerton a, 0,5s
[Console]::Beep("293.228","1000")
[Console]::Beep("349.228","500")
[Console]::Beep("440","500")
[Console]::Beep("293.228","1000")
[Console]::Beep("349.228","500")
[Console]::Beep("440","250")
[Console]::Beep("523.251","250")
[Console]::Beep("493.833","500")
[Console]::Beep("391.995","500")
[Console]::Beep("349.228","250")
[Console]::Beep("391.995","250")
[Console]::Beep("440","500")
[Console]::Beep("293.228","500")
[Console]::Beep("261.626","250")
[Console]::Beep("329.628","250")
[Console]::Beep("293.665","2500")
}

function Get-EponasSong()
{
[Console]::Beep("587.330","250")
[Console]::Beep("493.883","250")
[Console]::Beep("440","1000")
[Console]::Beep("587.330","250")
[Console]::Beep("493.883","250")
[Console]::Beep("440","1000")
[Console]::Beep("587.330","250")
[Console]::Beep("493.883","250")
[Console]::Beep("440","500")
[Console]::Beep("493.883","500")
[Console]::Beep("440","2000")
}

function Get-SongOfStorms()
{
[Console]::Beep("293.228","250")
[Console]::Beep("349.228","250")
[Console]::Beep("587.330","1000")
[Console]::Beep("293.228","250")
[Console]::Beep("349.228","250")
[Console]::Beep("587.330","1000")
[Console]::Beep("659.255","750")
[Console]::Beep("698.456","250")
[Console]::Beep("659.255","250")
[Console]::Beep("698.456","250")
[Console]::Beep("659.255","250")
[Console]::Beep("523.251","250")
[Console]::Beep("440","1000")
[Console]::Beep("293.228","250")
[Console]::Beep("349.228","250")
[Console]::Beep("587.330","1000")
[Console]::Beep("293.228","250")
[Console]::Beep("349.228","250")
[Console]::Beep("587.330","1000")
[Console]::Beep("659.255","750")
[Console]::Beep("698.456","250")
[Console]::Beep("659.255","250")
[Console]::Beep("698.456","250")
[Console]::Beep("659.255","250")
[Console]::Beep("523.251","250")
[Console]::Beep("440","1000")
[Console]::Beep("440","500")
[Console]::Beep("293.665","500")
[Console]::Beep("349.228","250")
[Console]::Beep("391.995","250")
[Console]::Beep("440","1000")
[Console]::Beep("440","500")
[Console]::Beep("293.665","1000")

}



Enjoy!

Trackbacks

Keine Trackbacks

Kommentare

Ansicht der Kommentare: Linear | Verschachtelt

Noch keine Kommentare

Die Kommentarfunktion wurde vom Besitzer dieses Blogs in diesem Eintrag deaktiviert.

Kommentar schreiben

Umschließende Sterne heben ein Wort hervor (*wort*), per _wort_ kann ein Wort unterstrichen werden.
Standard-Text Smilies wie :-) und ;-) werden zu Bildern konvertiert.
Formular-Optionen