locked
Realtime processing of sound in Universal Apps(W 8.1/ WP 8.1)

    Question

  • I want to get an input from the microphone of the device and process it in realtime. I found that for capturing audio in Universal apps, I need to use MediaCapture class but it seems that I can't do what I want with that class since the methods I need are done async. Is there a way to do this in C# and also, which data I can get from the stream?

    Friday, November 21, 2014 9:36 PM

Answers

All replies

  • Hi DjoleR,

    In general you can't since MediaCapture is a async method an you can only get the stream after the method is finished.

    However if you would like to apply some sound affect, AddEffectAsync | addEffectAsync method could be a good idea, you may need to pass some IMFAttributes/IPropertySet to the method, and you would like to see it from a similar post: https://social.msdn.microsoft.com/Forums/windowsapps/en-US/f140c786-032a-4892-b502-baae0127a5cb/how-to-pass-imfattributesipropertyset-to-mediacaptureaddeffectasync-or?forum=winappswithcsharp

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Marked as answer by Đorđe Relić Tuesday, November 25, 2014 10:31 PM
    Monday, November 24, 2014 3:25 AM
    Moderator
  • Hi James,

    I have read the thread you mentioned and I have seen that example but I failed to find what I was looking for. The AddEffectAsync methods are no good for me because they are defined by API and I cannot change them. I have done some video processing but I ended up copying the code from the MediaCapture (Grayscale filter) example and it had far more code/features than I needed so I am trying now to write my own code and to learn that exactly is happening along the way.

    Current app that I am developing is similar with guitar tuning apps: I get an input from the mic and I display some visuals that are dependant on the audio input. For the purpose of this app, I can do the audio processing in real time (a better option) or first to record the audio with MediaCapture instance and then process the stream (it'll-do-the-job option).

    Now, as I've wrote more details about the app, do you have some advice/code samples on how to do that?

    --

    Đorđe

    Monday, November 24, 2014 8:58 AM
  • Hi Dorde,

    As I understand from the documentation: How to add video stabilization effect to captured video

    effectActivationID - The class identifier of the activatable runtime class that implements the effect. The runtime class must implement the IMediaExtension interface.  The Windows.Media namespace provides a VideoEffects class.

    Besides the effect provided by system, you can also wrote your own effect which will implement IMediaExtension interface.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Tuesday, November 25, 2014 10:37 AM
    Moderator
  • Hi James,

    I now see that I missed the key part about changing the filter, I meant "...I cannot change them using C# solemnly." For the purpose of the other project, we changed the filter and adopted it to our needs, but now I am trying to avoid writing VC++ and do whole work in C#.

    I guess that I'll have to do some VC++ after all, if I want everything to be done in real time.

    Thanks for the time you took answering!

    --

    Đorđe

    Tuesday, November 25, 2014 10:31 PM