開発環境 | メモ帳 |
実行環境 | Windows 7 Home Premium (32bit) |
using System;
using System.Runtime.InteropServices;
namespace beep
{
class Program
{
[DllImport("kernel32.dll")]
private extern static bool Beep(uint dwFreq, uint dwDuration);
static void Main(string[] args)
{
int[] scale = { 0, 2, 4, 5, 7, 9, 11, 12 };
uint dwFreq;
for (int i = 0; i < scale.Length; i++ )
{
dwFreq = (uint)(440.0 * Math.Pow(2.0, (scale[i] + 3) / 12.0));
Beep(dwFreq, 500);
}
}
}
}