Tiny MML
Posted feedbacks - OCaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | #light
open System
open System.Runtime.InteropServices
open System.Threading
[<DllImport("kernel32.dll")>]
let Beep (dwFreq:int) (dwDuration:int) :bool = failwith ""
let toNum = function
| 'c' -> 262
| 'd' -> 294
| 'e' -> 330
| 'f' -> 349
| 'g' -> 392
| 'a' -> 440
| 'b' -> 494
| _ -> 0
let play (s:string) =
for c in s do
if (toNum c) = 0 then Thread.Sleep( 500 )
else Beep (toNum c) 500 |> (fun b -> ())
done
do play "cdefedcrefgagfercrcrcrcrcdefedcr"
|



にしお
#3387()
Rating0/0=0.00
入力はcがド、dがレ、eがミ、fがファ、gがソ、aがラ、bがシ、rが休符とします。この8文字以外の文字は入力に含まれていないと仮定して構いません。おのおのの音符・休符は八分音符・八分休符とします。
オクターブや音の長さの変更、同時発音などの機能は不要です。
サンプル入力(カエルの歌)
[ reply ]