是否有可能产生在C#中不断完善的同时,调整它的频率? [英] Is it possible to generate a constant sound in C# while adjusting its frequency?

查看:163
本文介绍了是否有可能产生在C#中不断完善的同时,调整它的频率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能产生在C#中不断健全和操纵它的频率一回事呢?

Is it possible to generate a constant sound in C# and manipulate its frequency as it goes?

我想是这样的:

for (int i = 500; i < 15000; i += 1)
{
    Console.Beep(i, 500));
}

不过是同步的,循环等待每次哔声来完成。所以,我想这样的:

But being synchronous, the loop waits for each beep to finish. So I tried this:

for (int i = 500; i < 15000; i += 1)
{
    new Thread(x => Console.Beep(i, 500)).Start();
}

我认为这将是一个开始走向产生恒定的声音,不断提高的频率。但是,它仍然口吃,因为它去。有没有办法做到这一点,但更顺利?

I would think this would be a start toward generating a constant sound that is ever increasing in frequency. However, it still stutters as it goes. Is there a way to accomplish this but more smoothly?

推荐答案

如果你想这样做,实时(即改变频率动态地响应用户输入),这将是非常困难的,并会带来你的写作软件合成。在这种情况下,你可能想尝试使用库如 n音讯(虽然我不是100 %确定n音讯做实时合成)。

If you want to do this in real-time (i.e. change the frequency dynamically in response to user input), this would be incredibly difficult and would entail your writing a software synthesizer. In that case, you might want to try using a library like NAudio (although I'm not 100% sure NAudio does realtime synthesis).

在另一方面,如果你只是想pre-产生了持续上升的音WAV文件,然后进行播放,这是令人难以置信的容易。

On the other hand, if you just want to pre-generate a WAV file with a continuously ascending tone and then play it, that's incredibly easy.

编辑:第三个选择是玩的 MIDI 声音并发送控制变更信息的MIDI设备逐渐应用于旅行皮箱到演奏音符。这也很容易,但你不能确定它究竟会怎么听起来别人的计算机上的缺点。

a third alternative is to play a MIDI sound and send control change messages to the MIDI device to gradually apply portmanteau to a playing note. This is also easy, but has the disadvantage that you can't be sure exactly how it will sound on somebody else's computer.

这篇关于是否有可能产生在C#中不断完善的同时,调整它的频率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆