locked
Decode Mp3 in c++/cx (Universal app)

    Question

  • I'm new to C++/CX so the scenario is next:

    I have a universal app windows 8.1 with c#, so I'd like to decode an mp3 from c#. Well I know that I can Use SharpDx, but I just not what to use it, my idea is really simple: using c++/cx and media foundation to decode mp3, and return a stream to c# so for example

    from c#

    Stream stream = GetMp3Stream("some.mp3"); //a custom method in c#
    var audioEng = new AudioEng();   //c++/cx class
    var streamOut = audioEng.DecodeMp3(stream);

    so my problems are:

    1. I dunno how using stream in c++/cx
    2. I dunno how decode mp3 in c++/cx

    I have found some example in cpp using ComPtr but I'd like to use c++/cx not c++

    Tuesday, July 15, 2014 2:42 PM

Answers

All replies

  • What do you mean by decoding an MP3?

    Depending on what you mean there are several audio API you can use. Take a look at the MediaElement, WASAPI, and XAudio2.

    Tuesday, July 15, 2014 3:48 PM
    Owner
  • Sorry, yes you right, well

    I mean transform to raw audio to MediaPlayer object via stream, because between raw audio and mediaplayer I'd like to apply some filters, well I'd like to use MediaPlayer because I want to use BackgroundMediaPlayer, to achive background player in windows phone 8.1, since in the last release support decoding.

    So I should use MediaFoundation (supported now in wp8.1 http://msdn.microsoft.com/en-us/library/windows/apps/dn632424.aspx), to decode mp3 with decoding class in windows api.

    thanks again


    Tuesday, July 15, 2014 6:16 PM
  • Hello,

    Media Foundation allows you to write plug-ins to transform the audio (i.e. DSP). These plug-ins must be written in C++. Currently we do not support audio or video transforms directly from C#. There are a number of reasons for this but nondeterministic finalization is at the top of the list.

    You can use the MediaElement (C#) to play the audio and add your plug-in (C++) to the underlying MF topology using AddAudioEffect.

    MediaElement.AddAudioEffect

    http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.mediaelement.addaudioeffect.aspx

    Writing a Custom MFT

    http://msdn.microsoft.com/en-us/library/windows/desktop/dd940441(v=vs.85).aspx

    I hope this helps,

    James


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

    • Marked as answer by My Disco Gr Saturday, August 09, 2014 2:23 PM
    Saturday, August 09, 2014 12:38 AM
    Moderator