RosettaCodeData/Task/Metronome/Mathematica/metronome.math

18 lines
348 B
Plaintext

s = Sound[Play[Sin[1000 t], {t, 0, 0.05}]];
ss = Sound[Play[Sin[2000 t], {t, 0, 0.05}]];
bpm = 180;
slp = 60/bpm;
color = White;
i = 0;
Dynamic[Graphics[{color, Disk[]}, ImageSize -> 50]]
While[True,
i = Mod[i + 1, 4, 1];
color = {Green, Red, Darker@Red, Red, Darker@Red}[[i]];
If[i == 1,
EmitSound[ss]
,
EmitSound[s]
];
Pause[slp];
]