locked
Time-stretch an audio file with C# RRS feed

  • Question

  • Hello,

     

    I have been all over the web, and I am having trouble finding an answer to this question. Is there a managed code library that I can use to time-stretch a WAV file (or some other audio format for that matter)? I have found quite a bit about the LAME encoder, but it's not easily integrated into a C# program. I simply need a way to play a WAV file at faster or slower speed while maintaining pitch. I have tried DirectSound, but I don't think it's possible with the methods available. If I stretch the time (modify frequency), the pitch changes. Any help would be greatly appreciated.

     

    Thanks

     

    Wednesday, November 14, 2007 3:01 AM

Answers

  • Since you're asking this question on the Media Foundation forum, I'll give you a Media Foundation answer; however, you may also want to try this on the DirectShow forum (http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=129&SiteID=1)

     

    When you play audio at rates other than 1.0x in MF, the audio renderer applies pitch correction to the audio, which is what you want.  There are three "but"s:

    1. MF is not managed, and you say you want C#.  There is a (non-Microsoft) managed wrapper on MF written by one of our MVPs (his handle is LimeGreenSocks) called MF.net out there.
    2. WAV is not a natively-supported format; however the Windows SDK does include a WAV Media Source as one of its code samples.

    Your best bet for writing a player application (unmanaged) on MF is to look at the Basic Playback code sample in the Windows SDK.  You should also look at IMFRateSupport and IMFRateControl in the documentation.

     

    Hope that helps...

     

    Becky

    Monday, November 19, 2007 3:33 PM