locked
Capturing microphone audio in PCM format Windows Store App RRS feed

  • Question

  • I have a requirement of capturing microphone audio in PCM format.

    How it is possible in Windows Store App (Windows 8.1)

    Following is the wave format i required

    Channels = 1
    FormatTag = Pcm
    SamplesPerSecond = 8000
    BitsPerSample = 16
    BlockAlign = 2              
    AverageBytesPerSecond = 16000
    

    Thanks in advance for providing sample codes

    Friday, December 6, 2013 6:15 AM

Answers

  • Hello,

    WASAPI only supports the mix audio format specified by the device configuration. This audio format is set at the factory and cannot be changed programmatically or by the user. If you want to continue to use WASAPI you will need to do the High Pass filtering and sample rate conversion yourself. Unfortunately you can't use the sample rate conversion DMO directly from your code.

    If you choose to use the Media Engine you might be able to create a sink that will allow the sample rate conversion DMO to be automatically loaded in the topology. Going this route will greatly change your architecture.

    Supported Microsoft Media Foundation APIs for Windows Phone 8

    http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj681688%28v=vs.105%29.aspx

    I hope this helps,

    James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Tuesday, December 10, 2013 12:12 AM
    Moderator

All replies

  • You can browse and view sample code here:
    http://code.msdn.microsoft.com/windowsapps/Windows-8-Modern-Style-App-Samples

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Friday, December 6, 2013 2:11 PM
    Moderator
  • H

    I have tried the below example and i could capture pcm data. but the wave format of the captured pcm data is CD quality. when i set the above mentioned wave format, exception occurring 

    http://www.codeproject.com/Articles/525620/Recording-audio-to-WAV-with-WASAPI-in-Windows-Stor

    Is it possible to capture pcm data in 8000 samples per second ?

    Friday, December 6, 2013 5:46 PM
  • Hi All

    With the help of following example code, 
    http://www.codeproject.com/Articles/525620/Recording-audio-to-WAV-with-WASAPI-in-Windows-Stor 

    I could success to write an application for capturing microphone audio in PCM format.
    Following is the wave format of the captured PCM audio.

        Channels = 2
        FormatTag = Pcm
        SamplesPerSecond = 44100
        BitsPerSample = 32
        BlockAlign = 8           
        AverageBytesPerSecond = 352800


    I want to re sample the PCM audio to the following wave type.
        Channels = 1
        FormatTag = Pcm
        SamplesPerSecond = 8000
        BitsPerSample = 16
        BlockAlign = 2              
        AverageBytesPerSecond = 16000

    Forums saying that we can capture audio in CD quality only from windows store apps, is it true?
    How it is to possible re sample wave type of PCM audio in windows store app?

    Thanks in advanced for providing samples
    Monday, December 9, 2013 1:26 PM
  • I'll ask our media guru to respond.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Monday, December 9, 2013 3:59 PM
    Moderator
  • Hello,

    WASAPI only supports the mix audio format specified by the device configuration. This audio format is set at the factory and cannot be changed programmatically or by the user. If you want to continue to use WASAPI you will need to do the High Pass filtering and sample rate conversion yourself. Unfortunately you can't use the sample rate conversion DMO directly from your code.

    If you choose to use the Media Engine you might be able to create a sink that will allow the sample rate conversion DMO to be automatically loaded in the topology. Going this route will greatly change your architecture.

    Supported Microsoft Media Foundation APIs for Windows Phone 8

    http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj681688%28v=vs.105%29.aspx

    I hope this helps,

    James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Tuesday, December 10, 2013 12:12 AM
    Moderator