Skip to content

Instantly share code, notes, and snippets.

@panesofglass
Created July 12, 2013 22:29
Show Gist options
  • Save panesofglass/5988348 to your computer and use it in GitHub Desktop.
Save panesofglass/5988348 to your computer and use it in GitHub Desktop.
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