Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8167799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:18:55+00:00 2026-06-06T20:18:55+00:00

I am trying to make a program that can take an .mp3 file from

  • 0

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 IMFSourceReader into an array containing PCM values for some exciting DSP action. However, I’m having problems.

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 public ref classes which the C# code can interact with.

I can’t use MFCreateSourceReaderFromURL 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 MFCreateSourceReaderFromByteStream or MFCreateSourceReaderFromMediaSource. Now, it’s easy enough to access the music file using Windows.Storage.KnownFolders.MusicLibrary and get a Stream or an IInputStream along with a few other stream types but how can I convert this to an IMFByteStream or an IMFMediaSource or just in some way decode the mp3 to a byte array with PCM values?

I have also entertained the idea of resaving the music file in the app folder so that I can use MFCreateSourceReaderFromURL or perhaps it would be possible to bypass working with Media Foundation directly and use something like Windows.Media.Transcoding to do the conversion to PCM. I’m not sure this is what the Transcoding namespace is for though.

I have spent hours reading through the Media Foundation documentation and I found a glimmer of hope with MFCreateMFByteStreamOnStream which can convert from COM’s IStream 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?

Thanks in advance. Also apologies in advance if I have made a stupid mistake or missed some crucial aspect of working with these libraries.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T20:18:57+00:00Added an answer on June 6, 2026 at 8:18 pm

    OK everyone, I know you are all clamouring to answer this question but after 2 days of headscratching I have found a solution. You can pass an Windows::Storage::Streams::IRandomAccessStream^ object to MFCreateMFByteStreamOnStreamEx ( http://msdn.microsoft.com/en-us/library/windows/desktop/hh162754(v=vs.85).aspx ) by casting it to (IUnknown*) like so:

    ComPtr<IMFByteStream> spMFByteStream = nullptr; 
    
    MFCreateMFByteStreamOnStreamEx((IUnknown*)streamHandle, &spMFByteStream);
    
    //remember to add your own HRESULT error handling code
    
    ComPtr<IMFSourceReader> _sourceReader = nullptr;
    
    MFCreateSourceReaderFromByteStream(spMFByteStream.Get(),nullptr,&_sourceReader);
    

    With streamHandle being the IRandomAcessStream^ that you want to give to the Source Reader.
    Here is a code sample with it running

    Time for some toast.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a program that can be hosted by many peoples, like
I'm trying to make a program that, using pointers, detects lines in an image
A am trying to make a program that takes a signal from one class
I am trying to make a program that will find similar images from a
So i'm trying to make a program that can find how many pixels of
I'm trying to make a program that fetches information from this webpage, www.sio.no ,
I'm trying to make a program that can turn off the monitor with a
Im trying to make a program that retrieves an endless amount of numbers that
I'm trying to make a program that lets you input any one-step equation, and
I am trying to make a program that automatically corrects the perspective of a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.