DCSIMG
PowerShell Popcorn - Shay Levy

Shay Levy

If you repeat it, PowerShell it!

PowerShell Popcorn

 

My son heard all the alien beeps and asked me for this one, the Popcorn tune. I couldn't say no :)

 

1..2  | % {
    
    1..2 | % {900,800,900,700,550,700,450 | % { [console]::beep($_,50); sleep -m 150}; sleep -m 250}
    
    900,1000,1050,1000,1050,1000,1050,900,1000,900,1000,800,900,800,900 | % { [console]::beep($_,50); sleep -m 150}
    sleep -m 250
    
    1..2 | % {900,800,900,700,550,700,450 | % { [console]::beep($_,50); sleep -m 150}; sleep -m 250}
    
    900,1000,1050,1000,1050,1000,1050,900,1000,900,1000,800,900,1000,1050 | % { [console]::beep($_,50); sleep -m 150}
    sleep -m 250    

    1..2 | % {
        1..2 | % {1350,1250,1350,1050,800,1050,680 | % { [console]::beep($_,50); sleep -m 150}; sleep -m 250}
        1350,1500,1600,1500,1600,1500,1600,1350,1500,1350,1500,1200,1350,1200,1350 | % { [console]::beep($_,50); sleep -m 150}
        sleep -m 250
    }
}

Comments

Jakob Bindslet said:

Very cool use of PowerShell :-)

Where did you find the required information to recompose popcorn for PowerShell?

# July 14, 2008 9:58 AM

ScriptFanatic said:

Trial and error, from hearing and with a little help from my guitar :)

# July 14, 2008 1:54 PM

Jimmy Johansson said:

If you want to get the exact frequencies for each tone, try my PowerShell-script:

# Name: tone2hz.ps1

# Function: Enter a tone with an octave and it will give you the frequency back

# Language: Windows PowerShell

# Author: Jimmy Johansson

# Creation: 2008-07-30

# Example: "./tone2hz A# 5" will give you the frequency for A sharp in the fifth octave.

# If no octave is given, the fourth is assumed, octaves are valid from 2 to 7.

$args[0] = $args[0].ToUpper()

if ($args[0][0] -eq "A") {

if ($args[0][1] -eq "#") { $n = 1 }

elseif ($args[0][1] -eq "B") { $n = -1 }

else { $n = 0 }

}

if ($args[0][0] -eq "B") {

if ($args[0][1] -eq "B") { $n = 1 }

else { $n = 2 }

}

if ($args[0][0] -eq "C") {

if ($args[0][1] -eq "#") { $n = -8 }

else { $n = -9 }

}

if ($args[0][0] -eq "D") {

if ($args[0][1] -eq "#") { $n = -6 }

elseif ($args[0][1] -eq "B") { $n = -8 }

else { $n = -7 }

}

if ($args[0][0] -eq "E") {

if ($args[0][1] -eq "B") { $n = -6 }

else { $n = -5 }

}

if ($args[0][0] -eq "F") {

if ($args[0][1] -eq "#") { $n = -3 } else { $n = -4 }

}

if ($args[0][0] -eq "G") {

if ($args[0][1] -eq "#") { $n = -1 }

elseif ($args[0][1] -eq "B") { $n = -3 }

else { $n = -2 }

}

$p = $n / 12

$hz = [math]::round(([math]::pow(2,$p)) * 440, 3)

if ($args[1] -le 1) { $oct = 4 } else { $oct = $args[1] }

if ($oct -ne 4) {

if ($oct -le 3) { $hz = $hz / 2 }

if ($oct -le 2) { $hz = $hz / 2 }

if ($oct -ge 5) { $hz = $hz * 2 }

if ($oct -ge 6) { $hz = $hz * 2 }

if ($oct -ge 7) { $hz = $hz * 2 }

}

write-host

write-host "$hz Hz (Octave: $oct)"

write-host

[console]::beep($hz,500)

# July 30, 2008 9:11 AM

Jimmy Johansson, SE said:

Can also be used to tune your guitar when you do not have a phone or another instrument nearby :-)

# July 30, 2008 9:43 AM

ScriptFanatic said:

Awesome script Jimmy, thanks!

# July 30, 2008 10:45 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Enter the numbers above: