[英]How can I play multiple frequencies of sound at once in c#?
I am trying to make a simple program that plays different frequencies of sound based on what colors are put in from of a camera.我正在尝试制作一个简单的程序,根据从相机输入的颜色播放不同频率的声音。 I need to play multiple sine waves at once in sound.
我需要在声音中一次播放多个正弦波。 Console.Beep works for just one frequency.
Console.Beep 仅适用于一种频率。 I also need it to be generated at run time.
我还需要在运行时生成它。 I have tried using the .wav generator in NAudio but I am not sure how the .wav format works in that context to create multiple frequencies.
我曾尝试在 NAudio 中使用 .wav 生成器,但我不确定 .wav 格式如何在该上下文中工作以创建多个频率。 Converting a random byte array to a .wav just shows static because of samples.
由于样本,将随机字节数组转换为 .wav 仅显示静态。 Any help would be appreciated.
任何帮助,将不胜感激。
By default, c# runs a single thread.默认情况下,c# 运行单个线程。 This means that there is only one thing happening at any one time inside the code.
这意味着在代码中的任何时间只发生一件事。 Therefore, you need multithreading for simultaneous actions.
因此,您需要多线程同时操作。 Also,m I'd look into delegates in C#, that could call multiple methods from a single event.
另外,我会研究 C# 中的委托,它可以从单个事件调用多个方法。 This will allow you to trigger multiple actions from a single trigger.
这将允许您从单个触发器触发多个操作。
https://www.tutorialspoint.com/csharp/csharp_multithreading.htm https://www.tutorialspoint.com/csharp/csharp_multithreading.htm
https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/delegates/ https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/delegates/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.