-
Notifications
You must be signed in to change notification settings - Fork 0
/
play_notes.ps1
58 lines (51 loc) · 1.21 KB
/
play_notes.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# based off https://learn.microsoft.com/en-us/dotnet/api/system.console.beep?view=net-6.0
$duration = @{
"WHOLE" = 1600;
"HALF" = 800;
"QUARTER" = 400;
"EIGHTH" = 200;
"SIXTEENTH" = 100
}
$note = @{
"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
}
function playNote($n,$d){
if($n -eq 'REST'){
Start-Sleep -Milliseconds $d
}else{
[console]::beep($note[$n],$d)
}
}
$song = @(
"G;"+$duration["QUARTER"]
"B;"+$duration["QUARTER"]
"E;"+$duration["QUARTER"]
"G;"+$duration["QUARTER"]
"E;"+$duration["QUARTER"]
"B;"+$duration["QUARTER"]
"B;"+$duration["HALF"]
"A;"+$duration["QUARTER"]
"A;"+$duration["QUARTER"]
"A;"+$duration["HALF"]
"B;"+$duration["QUARTER"]
"D;"+$duration["QUARTER"]
"D;"+$duration["QUARTER"]
)
foreach($z in $song){
$not = $z.Split(";")[0]
$dur = $z.Split(";")[1]
playNote $not $dur
}