Created
July 12, 2013 22:29
-
-
Save panesofglass/5988348 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Tone = | |
| Rest = 0 | |
| GbelowC = 196 | |
| A = 220 | |
| Asharp = 233 | |
| B = 247 | |
| C = 262 | |
| Csharp = 277 | |
| D = 294 | |
| E = 330 | |
| F = 349 | |
| Fsharp = 370 | |
| G = 392 | |
| Gsharp = 415 | |
type Duration = | |
| Whole = 1600 | |
| Half = 800 | |
| Quarter = 400 | |
| Eigth = 200 | |
| Sixteenth = 100 | |
type Note = Tone * Duration | |
let play (tune: seq<Note>) = | |
for tone, duration in tune do | |
match tone with | |
| Tone.Rest -> System.Threading.Thread.Sleep(int duration) | |
| _ -> System.Console.Beep(int tone, int duration) | |
let tune = [ | |
Tone.B, Duration.Quarter | |
Tone.A, Duration.Quarter | |
Tone.GbelowC, Duration.Quarter | |
Tone.A, Duration.Quarter | |
Tone.B, Duration.Quarter | |
Tone.B, Duration.Quarter | |
Tone.B, Duration.Half | |
Tone.A, Duration.Quarter | |
Tone.A, Duration.Quarter | |
Tone.A, Duration.Half | |
Tone.B, Duration.Quarter | |
Tone.D, Duration.Quarter | |
Tone.D, Duration.Half | |
] | |
play tune |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment