Upsampling algorithm
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Upsampling algorithm

  1. #1
    Join Date
    Feb 2010
    Posts
    5

    Upsampling algorithm

    Hey, I need to find an algorithm that will upsample from 11.025 kHz to 16.0 kHz. I am having trouble writing one. Does anyone have any insight or has anyone done this before?

    Regards,
    Dave

  2. #2
    Join Date
    Oct 2005
    Location
    Minnesota, U.S.A.
    Posts
    680

    Re: Upsampling algorithm

    What you need to do is upsample 11.025 kHz to the lowest common denominator (*16 = 176.4 KHz), then downsample to 16 kHz.

    If you go the oppisite direction, don't forget to run a FIR on the result.

    -Erik

    P.S. You may have to upsample to a higher value (*5) since 11.025 is not a whole number.
    Last edited by egawtry; February 2nd, 2010 at 06:34 PM.

  3. #3
    Join Date
    Feb 2010
    Posts
    5

    Re: Upsampling algorithm

    I see, I am not a proficient coder however, and am having trouble writing the actual interpolation algorithm.

    I could also upsample 11025 by 4x to 44100, interpolate to 48000, then downsample by 3x to get 16000, I am just having trouble with the actual coding of the interpolation part.

    It needs to eventually be in C++, but I'm currently working in Matlab (similar to C, C++).

  4. #4
    Join Date
    Oct 2005
    Location
    Minnesota, U.S.A.
    Posts
    680

    Re: Upsampling algorithm

    Quote Originally Posted by dosilegecko View Post
    I could also upsample 11025 by 4x to 44100, interpolate to 48000, then downsample by 3x to get 16000, I am just having trouble with the actual coding of the interpolation part.
    Isn't that the same as the original problem?

    There is a mathmatical way of doing this, but I don't really have the time to figure it out.

    1. Allocate an array 640X the length of your input. (7056K samples)
    2. Copy in the 11.025KHz signal, each Hz put in 640 samples.
    3. Read a Hz every 441 samples.

    You can reduce this by playing with the numbers a bit. You can put a counter in and offset the sample by 1 every third read if you divide by 3, for instance.

    If you are into DSP, you can interpolate it to your 44100 by padding with zeros, then use a FIR to reduce it to 16KHz.

    -Erik
    Last edited by egawtry; February 4th, 2010 at 11:51 AM.

  5. #5
    Join Date
    Feb 2010
    Posts
    5

    Re: Upsampling algorithm

    Thank you, that works just fine. I avoided interpolation this way by simply up-then-down converting.

    I may work on the implementation using interpolation in case upsampling by 640 and downsampling by 441 is too many operations.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center