Play multiple sounds using SoundPlayer

后端 未结 6 502
清酒与你
清酒与你 2020-11-27 22:12

I\'m making a sampler program where each key from 1 to 9 will make a different sound. Everything works fine, but when I press two (or more) sounds at the same time, the seco

6条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-27 22:56

    You could do this:

    SoundPlayer supports WAV Stream. You could

    • MIX samples you play 'by-hand' and,
    • Fake (get the WAV header from somewhere, it's not complicated).

    And provide such stream as a parameter to the SoundPlayer constructor.

    That way you won't have to use somehow complicated DirectSound libraries, and still have mixing (multiple sounds at once).

提交回复
热议问题