Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. can anyone suggest how to convert matlab code into c code..for resampling function

can anyone suggest how to convert matlab code into c code..for resampling function

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
14 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mybm1
    wrote on last edited by
    #1

    Quote:

    can anyone suggest how to convert matlab code into c code..for resampling function

    L C J 3 Replies Last reply
    0
    • M mybm1

      Quote:

      can anyone suggest how to convert matlab code into c code..for resampling function

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      This question is impossible to answer. Code conversion is mostly a manual task. If you want an automated conversion tool then you should use Google to find suggestions.

      M 1 Reply Last reply
      0
      • L Lost User

        This question is impossible to answer. Code conversion is mostly a manual task. If you want an automated conversion tool then you should use Google to find suggestions.

        M Offline
        M Offline
        mybm1
        wrote on last edited by
        #3

        what is this catalysis MCS tool..

        L 1 Reply Last reply
        0
        • M mybm1

          what is this catalysis MCS tool..

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          maibam debina wrote:

          what is this catalysis MCS tool.

          Sorry, I have no idea.

          M 1 Reply Last reply
          0
          • L Lost User

            maibam debina wrote:

            what is this catalysis MCS tool.

            Sorry, I have no idea.

            M Offline
            M Offline
            mybm1
            wrote on last edited by
            #5

            actually in matlab the function is available for resample but in c for me its hard so can u suggest some.

            L 1 Reply Last reply
            0
            • M mybm1

              actually in matlab the function is available for resample but in c for me its hard so can u suggest some.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Sorry, but I do not know matlab, you would probably get better response by going to a dedicateed forum.

              M 1 Reply Last reply
              0
              • L Lost User

                Sorry, but I do not know matlab, you would probably get better response by going to a dedicateed forum.

                M Offline
                M Offline
                mybm1
                wrote on last edited by
                #7

                but i know u r master in c program..so leaving matlab aside do u know how to represent in c code for resampling..

                L 1 Reply Last reply
                0
                • M mybm1

                  but i know u r master in c program..so leaving matlab aside do u know how to represent in c code for resampling..

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  maibam debina wrote:

                  c code for resampling

                  I have no idea what you mean by resampling. If you have a specific coding issue then put the details here and people will try to help you. But it is unlikely that anyone has the time to write your code, or convert from one language to another.

                  1 Reply Last reply
                  0
                  • M mybm1

                    Quote:

                    can anyone suggest how to convert matlab code into c code..for resampling function

                    C Offline
                    C Offline
                    Chris Losinger
                    wrote on last edited by
                    #9

                    what kind of resampling (bilinear, bicubic, trilinear, spline, sinc, etc)? and for what (audio, video, statistical, etc.) ?

                    image processing toolkits | batch image processing

                    M 1 Reply Last reply
                    0
                    • M mybm1

                      Quote:

                      can anyone suggest how to convert matlab code into c code..for resampling function

                      J Offline
                      J Offline
                      jschell
                      wrote on last edited by
                      #10

                      Steps - Analyze matlab code to understand it. This might involve researching matlab provided methods. - Learn C - Use the above to write C code. Researching existing C libraries might also be helpful.

                      A 1 Reply Last reply
                      0
                      • C Chris Losinger

                        what kind of resampling (bilinear, bicubic, trilinear, spline, sinc, etc)? and for what (audio, video, statistical, etc.) ?

                        image processing toolkits | batch image processing

                        M Offline
                        M Offline
                        mybm1
                        wrote on last edited by
                        #11

                        audio and do please guide how to find the time duration of the .wave file?

                        E 1 Reply Last reply
                        0
                        • M mybm1

                          audio and do please guide how to find the time duration of the .wave file?

                          E Offline
                          E Offline
                          enhzflep
                          wrote on last edited by
                          #12

                          Here's some code that does re-sampling of audio. No idea if it'll be of any use to you - googling for how to do it it was not much easier than implementing it. It was used for up-sampling 8363 samples/sec sound into 44100 samples/sec sound. It was used for working with the audio samples as found in .XM files (somewhat similar to Amiga .mod files, or less-so, .MIDI files) There's bound to be a bunch of code here that's useless to you, but I've no idea which format your .WAV files are, so I'll leave it to you to use that which you need. You're also on-your-own when it comes to reading the samples from a WAV file - in my instance, the header of the samples is different to the .WAV file header - my data also came with a single header - the wav file contains a number of chunks, each of these has its own header. The re-sampling is of the linear variety. You can determine the play-time of the WAV file by looking at a number of the chunk headers inside it. Don't ask me how, as I haven't bothered to do it, and don't know. (nor am I interested) This page seems to be an easier read than the Wikipedia WAV page - http://www.sonicspot.com/guide/wavefiles.html[^]

                          float *convert8tofloat(char *input, int numSamples)
                          {
                          float *result = new float[numSamples];
                          int i;
                          for (i=0; i<numSamples; i++)
                          {
                          result[i] = input[i] / 128.0; //(((input[i]+128)/255.0) - 0.5) * 2.0;
                          }
                          return result;
                          }

                          float *convert16tofloat(short *input, int numSamples)
                          {
                          float *result = new float[numSamples];
                          int i;
                          for (i=0; i<numSamples; i++)
                          {
                          result[i] = (int)input[i] / 32768.0; //(((input[i]+128)/255.0) - 0.5) * 2.0;
                          }
                          return result;
                          }

                          // t in range [0..1]
                          char interpolate8(char val1, char val2, float t)
                          {
                          short difference;
                          difference = val2 - val1;
                          return val1 + t*difference;
                          }
                          // t in range [0..1]
                          short interpolate16(short val1, short val2, float t)
                          {
                          int difference;
                          difference = val2 - val1;
                          return val1 + t*difference;
                          }
                          // t in range [0..1]
                          float interpolateFloat32(float val1, float val2, float t)
                          {
                          float difference;
                          difference = val2 - val1;
                          return val1 + t*difference;
                          }

                          char *resample8Interp(char *input, int numSamplesIn, int numSamplesOut)
                          {
                          char *output;
                          output = new char[numSamplesOut];
                          float curIndex, pr

                          M 1 Reply Last reply
                          0
                          • E enhzflep

                            Here's some code that does re-sampling of audio. No idea if it'll be of any use to you - googling for how to do it it was not much easier than implementing it. It was used for up-sampling 8363 samples/sec sound into 44100 samples/sec sound. It was used for working with the audio samples as found in .XM files (somewhat similar to Amiga .mod files, or less-so, .MIDI files) There's bound to be a bunch of code here that's useless to you, but I've no idea which format your .WAV files are, so I'll leave it to you to use that which you need. You're also on-your-own when it comes to reading the samples from a WAV file - in my instance, the header of the samples is different to the .WAV file header - my data also came with a single header - the wav file contains a number of chunks, each of these has its own header. The re-sampling is of the linear variety. You can determine the play-time of the WAV file by looking at a number of the chunk headers inside it. Don't ask me how, as I haven't bothered to do it, and don't know. (nor am I interested) This page seems to be an easier read than the Wikipedia WAV page - http://www.sonicspot.com/guide/wavefiles.html[^]

                            float *convert8tofloat(char *input, int numSamples)
                            {
                            float *result = new float[numSamples];
                            int i;
                            for (i=0; i<numSamples; i++)
                            {
                            result[i] = input[i] / 128.0; //(((input[i]+128)/255.0) - 0.5) * 2.0;
                            }
                            return result;
                            }

                            float *convert16tofloat(short *input, int numSamples)
                            {
                            float *result = new float[numSamples];
                            int i;
                            for (i=0; i<numSamples; i++)
                            {
                            result[i] = (int)input[i] / 32768.0; //(((input[i]+128)/255.0) - 0.5) * 2.0;
                            }
                            return result;
                            }

                            // t in range [0..1]
                            char interpolate8(char val1, char val2, float t)
                            {
                            short difference;
                            difference = val2 - val1;
                            return val1 + t*difference;
                            }
                            // t in range [0..1]
                            short interpolate16(short val1, short val2, float t)
                            {
                            int difference;
                            difference = val2 - val1;
                            return val1 + t*difference;
                            }
                            // t in range [0..1]
                            float interpolateFloat32(float val1, float val2, float t)
                            {
                            float difference;
                            difference = val2 - val1;
                            return val1 + t*difference;
                            }

                            char *resample8Interp(char *input, int numSamplesIn, int numSamplesOut)
                            {
                            char *output;
                            output = new char[numSamplesOut];
                            float curIndex, pr

                            M Offline
                            M Offline
                            mybm1
                            wrote on last edited by
                            #13

                            thank you fren....

                            1 Reply Last reply
                            0
                            • J jschell

                              Steps - Analyze matlab code to understand it. This might involve researching matlab provided methods. - Learn C - Use the above to write C code. Researching existing C libraries might also be helpful.

                              A Offline
                              A Offline
                              Albert Holguin
                              wrote on last edited by
                              #14

                              Best answer really... I have yet to see a "code converter" that did a good job without generating cluttered, hard to read code (that can run slow compared to if you have just done the conversion manually).

                              1 Reply Last reply
                              0
                              Reply
                              • Reply as topic
                              Log in to reply
                              • Oldest to Newest
                              • Newest to Oldest
                              • Most Votes


                              • Login

                              • Don't have an account? Register

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • World
                              • Users
                              • Groups