嘿=)我想這個也一樣,所以我在網上搜索,但沒有發現任何東西。 有點自己工作,並提出了這個=)。 它的工作非常好!
我在「public partial class Form1:Form」中創建了一個隨機數(int)生成器,所以它會加載@start。
代碼:
private Random randomgen = new Random();
下面在這裏,我提出了8個不同的聲音整數,8不同的速度。
「beepgen1」,直到「8」在下面的代碼是聲音 37-7000赫茲的頻率見關於this鏈接的詳細信息「Console.Beep(頻率,以毫秒爲單位)」
示例將此代碼放置在一個按鈕下,您的電腦將發出1000Hertz和100Milisec的嗶聲@ 。
「控制檯。蜂鳴(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);
人類語音和音樂是一個很大數量的頻率,其強度迅速變化隨着時間的混合。Console.Beep()能夠都不是,它永遠不會聽起來更好比R2D2。 –