can anyone suggest how to convert matlab code into c code..for resampling function
-
actually in matlab the function is available for resample but in c for me its hard so can u suggest some.
-
Sorry, but I do not know matlab, you would probably get better response by going to a dedicateed forum.
-
but i know u r master in c program..so leaving matlab aside do u know how to represent in c code for resampling..
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.
-
what kind of resampling (bilinear, bicubic, trilinear, spline, sinc, etc)? and for what (audio, video, statistical, etc.) ?
-
what kind of resampling (bilinear, bicubic, trilinear, spline, sinc, etc)? and for what (audio, video, statistical, etc.) ?
-
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 -
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 -
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.
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).