嘿那里=)我也在考虑这个,所以我在网上搜索但找不到任何东西。我自己做了一点工作并想出了这个=)。它工作得很好!
我在“公共部分类 Form1:Form”中创建了 1 个随机数(int)生成器,因此它将加载 @start。
代码 :
private Random randomgen = new Random();
下面我为 8 种不同的声音制作了整数,为不同的速度制作了 8 个整数。
下面代码中的“beepgen1”直到“8”是声音的频率 37-7000 赫兹有关“Console.Beep(FREQUENCY, MILISEC)”的更多信息,请参见此链接
示例 将此代码放在一个按钮下,您的电脑将发出 1000 赫兹和 100 米秒长的哔声。
“Console.Beep(1000, 100)”
int beepgen1, beepgen2, beepgen3, beepgen4, beepgen5, beepgen6, beepgen7, beepgen8, beepgenn1, beepgenn2, beepgenn3, beepgenn4, beepgenn5, beepgenn6, beepgenn7, beepgenn8;
beepgen1 = (randomgen.Next(37, 7000));
beepgen2 = (randomgen.Next(37, 6000));
beepgen3 = (randomgen.Next(37, 6000));
beepgen4 = (randomgen.Next(37, 7000));
beepgen5 = (randomgen.Next(37, 8000));
beepgen6 = (randomgen.Next(37, 7000));
beepgen7 = (randomgen.Next(37, 7000));
beepgen8 = (randomgen.Next(37, 5000));
beepgenn1 = (randomgen.Next(50, 200));
beepgenn2 = (randomgen.Next(50, 250));
beepgenn3 = (randomgen.Next(50, 300));
beepgenn4 = (randomgen.Next(50, 200));
beepgenn5 = (randomgen.Next(50, 250));
beepgenn6 = (randomgen.Next(50, 200));
beepgenn7 = (randomgen.Next(50, 300));
beepgenn8 = (randomgen.Next(50, 250));
Console.Beep(beepgen1, beepgenn1);
Console.Beep(beepgen2, beepgenn2);
Console.Beep(beepgen3, beepgenn3);
Console.Beep(beepgen4, beepgenn4);
Console.Beep(beepgen5, beepgenn5);
Console.Beep(beepgen6, beepgenn6);
Console.Beep(beepgen7, beepgenn7);
Console.Beep(beepgen8, beepgenn8);