Created
June 6, 2010 23:41
-
-
Save pcwalton/428037 to your computer and use it in GitHub Desktop.
This file contains 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
(* square wave test *) | |
let freq = 44100 in | |
(* A, 440 Hz *) | |
let a440 = | |
let out = IO.output_string() in | |
let period = freq / 440 in | |
for i = 0 to period / 2 - 1 do IO.write_i16 out 32767 done; | |
for i = period / 2 to period - 1 do IO.write_i16 out (-32768) done; | |
IO.close_out out | |
in | |
Std.print a440; | |
let driver = Ao.open_live ~bits:16 ~rate:freq ~channels:1 () in | |
Std.finally (fun() -> Ao.close driver) begin | |
fun() -> while true do Ao.play driver a440 done | |
end ();; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment