Get in the Christmas spirit with PowerShell

Inspired by Jeffrey Hicks Christmas prompts [#1,#2] for PowerShell, I thought I’d do my part to give some Christmas spirit as well. 

UPDATE! I have added a PowerShell-v2-compatible version at the bottom of the post.

Combining Jeffreys prompts with my code should take you a long way towards getting in the right Christmas mood. Note, that although I’m not a total beginner when it comes to music, working with Console.Beep is kind of restricting, so take it for what it is.

While writing my little Christmas melody, I tried to keep with the PowerShell best practices as well. I started out hard-coding the note frequencies in an array, but scrapped it and created a function to automatically convert a note name to it’s corresponding frequency instead. While I were at it, I added the MIDI note number as well, in case anyone might need that. And to top it of, I added a method that let you play the note.

I’d like to challenge my fellow PowerShell scripters to create more cool PowerShell music! If you do make something, please leave me a comment below so I can have a listen 🙂

Merry Christmas!

One comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s