locked
WAVE_FORMAT_IEEE_FLOAT to WAVE_FORMAT_PCM transform RRS feed

  • Question

  • Does Media Foundation include any built-in capabilities for converting from WAVE_FORMAT_IEEE_FLOAT to WAVE_FORMAT_PCM. I would like to be able to create a source reader that takes WAVE_FORMAT_IEEE_FLOAT from a microphone and converts to WAVE_FORMAT_PCM suitable for input into a voice encoder. I was hoping Media Foundation would have a built-in transform that would accomplish this automatically within the source reader. However, this doesn’t appear to be the case because I receive the MF_E_TOPO_CODEC_NOT_FOUND error when trying to set the reader’s current media type to WAVE_FORMAT_PCM (the source’s native type is WAVE_FORMAT_IEEE_FLOAT).

    Thanks,

    Scott

    Tuesday, November 24, 2009 11:25 PM

Answers

  • The rule of thumb with Media Foundation Transforms is if you are trying to convert an uncompressed format into another uncompressed format, you have to do the conversions yourself. I'm not sure about audio conversions but I know that MF has some highly optimised Colour Space conversion functions.

    With your scenario in particular, all you need to do is take you IEEE float samples, clamp them between -1.0 and 1.0 then multiply the value by the resolution of PCM audio you are using. For example, if you are using 16bit PCM, you multiply the clamped float value by 32767(2^15). 8Bit you multiply by 127(2^7) etc etc.

    The only problems you'll run into are if the sample rate of the source differs from the sample rate you are pumping into your voice encoder. You'll then need to manage sample duplication/dropping.
    • Marked as answer by The March Hare Thursday, December 17, 2009 6:15 PM
    Sunday, November 29, 2009 9:00 PM
  • The Audio Resampler DSP can do conversions from float to PCM.  Unfortunately, the source reader does not support insertion of a resampler.  You would need to instantiate the transform and feed samples through it yourself to perform the conversion.
    • Marked as answer by The March Hare Thursday, December 17, 2009 6:15 PM
    Monday, November 30, 2009 11:19 PM

All replies

  • The rule of thumb with Media Foundation Transforms is if you are trying to convert an uncompressed format into another uncompressed format, you have to do the conversions yourself. I'm not sure about audio conversions but I know that MF has some highly optimised Colour Space conversion functions.

    With your scenario in particular, all you need to do is take you IEEE float samples, clamp them between -1.0 and 1.0 then multiply the value by the resolution of PCM audio you are using. For example, if you are using 16bit PCM, you multiply the clamped float value by 32767(2^15). 8Bit you multiply by 127(2^7) etc etc.

    The only problems you'll run into are if the sample rate of the source differs from the sample rate you are pumping into your voice encoder. You'll then need to manage sample duplication/dropping.
    • Marked as answer by The March Hare Thursday, December 17, 2009 6:15 PM
    Sunday, November 29, 2009 9:00 PM
  • The Audio Resampler DSP can do conversions from float to PCM.  Unfortunately, the source reader does not support insertion of a resampler.  You would need to instantiate the transform and feed samples through it yourself to perform the conversion.
    • Marked as answer by The March Hare Thursday, December 17, 2009 6:15 PM
    Monday, November 30, 2009 11:19 PM