Note that there are some explanatory texts on larger screens.

plurals
  1. POWindows 8 passing a Stream to a MFSourceReader
    text
    copied!<p>I am trying to make a program that can take an .mp3 file from the user's Music Library, and convert it using the Windows Media Foundation's <code>IMFSourceReader</code> into an array containing PCM values for some exciting DSP action. However, I'm having problems.</p> <p>My solution has two projects; a C#/XAML one containing UI code and a C++ Library containing some native code for working with Media Foundation and XAudio2 plus some <code>public ref</code> classes which the C# code can interact with.</p> <p>I can't use <code>MFCreateSourceReaderFromURL</code> because it returns an ACCESS DENIED HRESULT even if you have the Music Library capability in the app manifest. So it looks like I'm going to have to use either <code>MFCreateSourceReaderFromByteStream</code> or <code>MFCreateSourceReaderFromMediaSource</code>. Now, it's easy enough to access the music file using <code>Windows.Storage.KnownFolders.MusicLibrary</code> and get a <code>Stream</code> or an <code>IInputStream</code> along with a few other stream types but how can I convert this to an <code>IMFByteStream</code> or an <code>IMFMediaSource</code> or just in some way decode the mp3 to a byte array with PCM values?</p> <p>I have also entertained the idea of resaving the music file in the app folder so that I can use <code>MFCreateSourceReaderFromURL</code> or perhaps it would be possible to bypass working with Media Foundation directly and use something like <code>Windows.Media.Transcoding</code> to do the conversion to PCM. I'm not sure this is what the Transcoding namespace is for though.</p> <p>I have spent hours reading through the Media Foundation documentation and I found a glimmer of hope with <code>MFCreateMFByteStreamOnStream</code> which can convert from COM's <code>IStream</code> to a byte stream but I will need to find/write a wrapper to convert my .net stream to an IStream. Before I set off on this task I just want to make sure that I am going in the right direction or is there a better way to do this?</p> <p>Thanks in advance. Also apologies in advance if I have made a stupid mistake or missed some crucial aspect of working with these libraries.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload