Skip to content

Instantly share code, notes, and snippets.

@DominicFinn
Created November 2, 2012 13:37
Show Gist options
  • Save DominicFinn/4001406 to your computer and use it in GitHub Desktop.
Save DominicFinn/4001406 to your computer and use it in GitHub Desktop.
Keyboard Thing
#r @"..\..\lib\NAudio\NAudio.dll"
#load "MiscConsts.fs"
#load "Enums.fs"
#load "WaveFunctions.fs"
#load "NAudioWaveStreamSource.fs"
#load "Player.fs"
#load "Player.net.fs"
#load "IO.fs"
open System.IO
open Undertone
open Undertone.Waves
let bpm = 90.
let crotchet = Time.noteValue bpm Time.crotchet
let quaver = Time.noteValue bpm Time.quaver
let n = Creation.makeSilence 1
let a4 = Creation.makeNote Creation.sine crotchet Note.A 4
let a5 = Creation.makeNote Creation.sine crotchet Note.A 5
let a6 = Creation.makeNote Creation.sine crotchet Note.A 6
let b4 = Creation.makeNote Creation.sine crotchet Note.B 4
let b5 = Creation.makeNote Creation.sine crotchet Note.B 5
let b6 = Creation.makeNote Creation.sine crotchet Note.B 6
let c4 = Creation.makeNote Creation.sine crotchet Note.C 4
let c5 = Creation.makeNote Creation.sine crotchet Note.C 5
let c6 = Creation.makeNote Creation.sine crotchet Note.C 6
let d4 = Creation.makeNote Creation.sine crotchet Note.D 4
let d5 = Creation.makeNote Creation.sine crotchet Note.D 5
let d6 = Creation.makeNote Creation.sine crotchet Note.D 6
let e4 = Creation.makeNote Creation.sine crotchet Note.E 4
let e5 = Creation.makeNote Creation.sine crotchet Note.E 5
let e6 = Creation.makeNote Creation.sine crotchet Note.E 6
let f4 = Creation.makeNote Creation.sine crotchet Note.F 4
let f5 = Creation.makeNote Creation.sine crotchet Note.F 5
let f6 = Creation.makeNote Creation.sine crotchet Note.F 6
let g4 = Creation.makeNote Creation.sine crotchet Note.G 4
let g5 = Creation.makeNote Creation.sine crotchet Note.G 5
let g6 = Creation.makeNote Creation.sine crotchet Note.G 6
open System
open System.Drawing
open System.Windows.Forms
let form = new Form(Text = "This is the form")
form.KeyPress.Add(fun e ->
let r = match e.KeyChar with
| 'a' -> Player.Play a5
| 's' -> Player.Play b5
| 'd' -> Player.Play c5
| 'f' -> Player.Play d5
| 'g' -> Player.Play e5
| 'h' -> Player.Play f5
| 'j' -> Player.Play g5
| 'q' -> Player.Play a6
| 'w' -> Player.Play b6
| 'e' -> Player.Play c6
| 'r' -> Player.Play d6
| 't' -> Player.Play e6
| 'y' -> Player.Play f6
| 'u' -> Player.Play g6
| 'z' -> Player.Play a4
| 'x' -> Player.Play b4
| 'c' -> Player.Play c4
| 'v' -> Player.Play d4
| 'b' -> Player.Play e4
| 'n' -> Player.Play f4
| 'm' -> Player.Play g4
| _ -> Player.Play n
())
form.Show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment