locked
Which Sound API to use?

    Question

  • Hi experts,

    Seems that Windows Store apps are here to shake the world as I knew it!

    Well, I have a SIP stack that implements WMME. I found out recently that that API is not supported in Windows 8.1 Store App.

    I'm trying to add a new audio library but I'm facing a lot of problems.

    So, if I have a SIP stack that receives RTP packets and knows how to decode them to PCM 16-bits (mono or stereo) what API do you suggest for rendering that sound?

    And to capture from the microphone and encode it to PCM 16-bits (mono or stereo)?

    WASAPI? XAudio2? Other?

    Thanks

    Wednesday, March 26, 2014 9:07 PM

Answers

  • I'm saying that if you don't have a source rate conversion routine somewhere, XAudio2 is probably easiest for rendering. WASAPI is great if you are writing your own mixer, or just playing a single sound.

    For capture, you again have to handle whatever format WASAPI sends you, which is mostly just a matter of handling a wide range of potential sample rates. Again, if you don't have SRC in your code, then it's a question of what are you doing with the data. If you are just playing it back with XAudio2, it's probably not a big deal.

    Thursday, March 27, 2014 6:44 AM

All replies

  • WASAPI works fine, but it requires that your application be able to handle any Source Rate Conversions because WASAPI tells you what format to use, not vice versa. It can also be a tricky API to use for multiple sound sources.

    XAUDIO2 is good for rendering audio if you need to do real-time mixing as is common in games. In the end, it just creates a mix and sends it to WASAPI for output. For some example XAudio2 code see:

    http://code.msdn.microsoft.com/windowsapps/Basic-Audio-Sample-9a5bb0b7

    http://code.msdn.microsoft.com/XAudio2-Win32-Samples-024b3933

    http://go.microsoft.com/fwlink/?LinkId=248929

    XAUDIO2 doesn't help you do any SRC for capture, other than if you want to just play it back... That said, capture is PCM and fairly straight forward to handle even without a robust SRC implementation.



    Wednesday, March 26, 2014 9:12 PM
  • So, you are saying that, for rendering, I should use XAudio2. Right? No need for WASAPI here. Right?

    And for capturing? I must use WASAPI to capture from the microphone and then I have to deal with all possible Source Rate Conversions?

    Wednesday, March 26, 2014 9:25 PM
  • I'm saying that if you don't have a source rate conversion routine somewhere, XAudio2 is probably easiest for rendering. WASAPI is great if you are writing your own mixer, or just playing a single sound.

    For capture, you again have to handle whatever format WASAPI sends you, which is mostly just a matter of handling a wide range of potential sample rates. Again, if you don't have SRC in your code, then it's a question of what are you doing with the data. If you are just playing it back with XAudio2, it's probably not a big deal.

    Thursday, March 27, 2014 6:44 AM