Is it possible to generate a constant sound in C# while adjusting its frequency?

后端 未结 2 499
面向向阳花
面向向阳花 2021-01-12 05:52

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

I tried something like this:

for (int i = 500; i < 1500         


        
2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-12 06:56

    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).

    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.

    Edit: 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.

提交回复
热议问题