Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > a228190325affd3a38a9ed14c6aaa02a > files > 77

ocaml-mm-devel-0.2.1-3.mga4.x86_64.rpm

let total_duration = 5

let () =
  let channels = 2 in
  let sample_rate = 44100 in
  let oss = new MMOSS.writer channels sample_rate in
  let wav = new Audio.IO.Writer.to_wav_file channels sample_rate "out.wav" in
  let blen = 1024 in
  let buf = Audio.create channels blen in
  let sine = new Audio.Generator.of_mono (new Audio.Mono.Generator.sine sample_rate 440.) in
  for i = 0 to sample_rate / blen * total_duration - 1 do
    sine#fill buf 0 blen;
    wav#write buf 0 blen;
    oss#write buf 0 blen
  done;
  wav#close;
  oss#close