Making music with Powershell

Kenneth Fisher, 2017-12-20

Happy holidays everyone! Ok, this isn’t even remotely related to SQL Server but it sounded fun. I found someone playing music using Powershell (I lost the link, sorry) and thought Christmas Music! (Yes, I’m Jewish and I probably should have done The Dreidel Song or something but I didn’t think of it until it was too late.) So without further ado here is Jingle Bells done in Powershell.

$Notes = New-Object -TypeName psobject -Property @{
    REST    = 0
    GbelowC = 196
    A       = 220
    Asharp  = 233
    B       = 247
    C       = 262
    Csharp  = 277
    D       = 294
    Dsharp  = 311
    E       = 330
    F       = 349
    Fsharp  = 370
    G       = 392
    Gsharp  = 415
    AA      = 440
    AAsharp = 466
    BB      = 493
    CC      = 523
    CCsharp = 554
    DD      = 587
    DDsharp = 622
    EE      = 659
    FF      = 698
    FFsharp = 740
    GG      = 784
    GGsharp = 830
    }
$Duration = New-Object -TypeName psobject -Property @{
    WHOLE     = 1600
    HALF      = 800
    QUARTER   = 400
    EIGHTH    = 200
    SIXTEENTH = 100
    }
[console]::beep($Notes.C, $Duration.EIGHTH )
[console]::beep($Notes.C, $Duration.EIGHTH )
[console]::beep($Notes.C, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.G, $Duration.QUARTER)
[console]::beep($Notes.F, $Duration.QUARTER)
[console]::beep($Notes.C, $Duration.HALF   )
[console]::beep($Notes.C, $Duration.EIGHTH )
[console]::beep($Notes.C, $Duration.EIGHTH )
[console]::beep($Notes.C, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.G, $Duration.QUARTER)
[console]::beep($Notes.F, $Duration.QUARTER)
[console]::beep($Notes.D, $Duration.HALF   )
Start-Sleep -m $Duration.EIGHTH
[console]::beep($Notes.D, $Duration.EIGHTH )
[console]::beep($Notes.E, $Duration.QUARTER)
[console]::beep($Notes.BB, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.G, $Duration.QUARTER)
[console]::beep($Notes.E, $Duration.HALF)
Start-Sleep -m $Duration.EIGHTH
[console]::beep($Notes.E, $Duration.EIGHTH)
[console]::beep($Notes.CC, $Duration.QUARTER)
[console]::beep($Notes.CC, $Duration.QUARTER)
[console]::beep($Notes.BB, $Duration.QUARTER)
[console]::beep($Notes.G, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.HALF)
[console]::beep($Notes.C, $Duration.EIGHTH )
[console]::beep($Notes.C, $Duration.EIGHTH )
[console]::beep($Notes.C, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.G, $Duration.QUARTER)
[console]::beep($Notes.F, $Duration.QUARTER)
[console]::beep($Notes.C, $Duration.HALF   )
[console]::beep($Notes.C, $Duration.EIGHTH )
[console]::beep($Notes.C, $Duration.EIGHTH )
[console]::beep($Notes.C, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.G, $Duration.QUARTER)
[console]::beep($Notes.F, $Duration.QUARTER)
[console]::beep($Notes.D, $Duration.HALF   )
Start-Sleep -m $Duration.QUARTER
[console]::beep($Notes.D, $Duration.EIGHTH )
[console]::beep($Notes.E, $Duration.QUARTER)
[console]::beep($Notes.BB, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.G, $Duration.QUARTER)
[console]::beep($Notes.CC, $Duration.QUARTER)
[console]::beep($Notes.CC, $Duration.QUARTER)
[console]::beep($Notes.CC, $Duration.QUARTER)
[console]::beep($Notes.CC, $Duration.EIGHTH)
[console]::beep($Notes.DD, $Duration.QUARTER)
[console]::beep($Notes.CC, $Duration.QUARTER)
[console]::beep($Notes.BB, $Duration.QUARTER)
[console]::beep($Notes.G, $Duration.QUARTER)
[console]::beep($Notes.F, $Duration.HALF)
[console]::beep($Notes.CC, $Duration.HALF)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.HALF)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.HALF)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.CC, $Duration.QUARTER)
[console]::beep($Notes.F, $Duration.QUARTER)
[console]::beep($Notes.G, $Duration.EIGHTH)
[console]::beep($Notes.AA, $Duration.HALF)
Start-Sleep -m $Duration.EIGHTH
[console]::beep($Notes.BB, $Duration.QUARTER)
[console]::beep($Notes.BB, $Duration.QUARTER)
[console]::beep($Notes.BB, $Duration.QUARTER)
[console]::beep($Notes.BB, $Duration.EIGHTH)
[console]::beep($Notes.BB, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.EIGHTH)
[console]::beep($Notes.AA, $Duration.EIGHTH)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.G, $Duration.QUARTER)
[console]::beep($Notes.G, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.G, $Duration.HALF)
[console]::beep($Notes.CC, $Duration.HALF)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.HALF)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.HALF)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.CC, $Duration.QUARTER)
[console]::beep($Notes.F, $Duration.QUARTER)
[console]::beep($Notes.G, $Duration.EIGHTH)
[console]::beep($Notes.AA, $Duration.HALF)
Start-Sleep -m $Duration.EIGHTH
[console]::beep($Notes.CC, $Duration.QUARTER)
[console]::beep($Notes.CC, $Duration.QUARTER)
[console]::beep($Notes.CC, $Duration.QUARTER)
[console]::beep($Notes.CC, $Duration.EIGHTH)
[console]::beep($Notes.CC, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.QUARTER)
[console]::beep($Notes.AA, $Duration.EIGHTH)
[console]::beep($Notes.AA, $Duration.EIGHTH)
[console]::beep($Notes.CC, $Duration.QUARTER)
[console]::beep($Notes.CC, $Duration.QUARTER)
[console]::beep($Notes.BB, $Duration.QUARTER)
[console]::beep($Notes.G, $Duration.QUARTER)
[console]::beep($Notes.F, $Duration.HALF)

And here is where I got the frequencies for the notes, the sheet music etc.

List of frequencies

Sheet music

Console.Beep

Rate

Share

Share

Rate

Related content

Database Mirroring FAQ: Can a 2008 SQL instance be used as the witness for a 2005 database mirroring setup?

Question: Can a 2008 SQL instance be used as the witness for a 2005 database mirroring setup? This question was sent to me via email. My reply follows. Can a 2008 SQL instance be used as the witness for a 2005 database mirroring setup? Databases to be mirrored are currently running on 2005 SQL instances but will be upgraded to 2008 SQL in the near future.

Robert Davis

2009-02-23

1,567 reads

Networking – Part 4

You may want to read Part 1 , Part 2 , and Part 3 before continuing. This time around I’d like to talk about social networking. We’ll start with social networking. Facebook, MySpace, and Twitter are all good examples of using technology to let…

Andy Warren

2009-02-17

1,530 reads

Speaking at Community Events – More Thoughts

Last week I posted Speaking at Community Events – Time to Raise the Bar?, a first cut at talking about to what degree we should require experience for speakers at events like SQLSaturday as well as when it might be appropriate to add additional focus/limitations on the presentations that are accepted. I’ve got a few more thoughts on the topic this week, and I look forward to your comments.

Andy Warren

2009-02-13

360 reads