Download lame Source code
Header File
#include "armffmpeg/lame/include/lame.h"
Variables
int pcm_samples_2d[2][RAWBUFSIZE];
lame_global_flags *mp3;
numBytes = RAWBUFSIZE;
Init lame flags.
mp3 = lame_init();
if(!mp3) {
printf("Unable to initialize mp3 object.");
} else {
printf("Able to initialize mp3 object.\n");
}
/* set other parameters.*/
lame_set_num_channels(mp3, 1);
/*lame_set_num_samples(mp3, (nSecondsAudio * sampleRate));*/
lame_set_in_samplerate(mp3, gAudSampleRate);
lame_set_quality(mp3, 5); /* set for high speed and good quality. */
lame_set_mode(mp3, 3); /* the input audio is mono */
lame_set_out_samplerate(mp3, gAudSampleRate);
lame_set_VBR(mp3, vbr_default);
printf("Able to set a number of parameters too.");
framesize = lame_get_framesize(mp3);
printf("Framesize = %d\n", framesize);
/* set more internal variables. check for failure.*/
if(lame_init_params(mp3) == -1) {
printf("Something failed in setting internal parameters.");
}
Encode mp3 From RAW Data
memset(pcm_samples_2d[1], 0, (numBytes/2) * sizeof(int));
memset(pcm_samples_2d[0], 0, (numBytes/2) * sizeof(int));
i = 0;
for(i = 0; i < (numBytes/2); i++) {
pcm_samples_2d[0][i] = *((int *)InAudioBuf + i);
}
encodedBufferSize = lame_encode_buffer(mp3, (const short int *)pcm_samples_2d[0], (const short int *)pcm_samples_2d[1],
numBytes/2, OutAudioBuf, numBytes/2);
Close Lame module
lame_close(mp3);
Header File
#include "armffmpeg/lame/include/lame.h"
Variables
int pcm_samples_2d[2][RAWBUFSIZE];
lame_global_flags *mp3;
numBytes = RAWBUFSIZE;
Init lame flags.
mp3 = lame_init();
if(!mp3) {
printf("Unable to initialize mp3 object.");
} else {
printf("Able to initialize mp3 object.\n");
}
/* set other parameters.*/
lame_set_num_channels(mp3, 1);
/*lame_set_num_samples(mp3, (nSecondsAudio * sampleRate));*/
lame_set_in_samplerate(mp3, gAudSampleRate);
lame_set_quality(mp3, 5); /* set for high speed and good quality. */
lame_set_mode(mp3, 3); /* the input audio is mono */
lame_set_out_samplerate(mp3, gAudSampleRate);
lame_set_VBR(mp3, vbr_default);
printf("Able to set a number of parameters too.");
framesize = lame_get_framesize(mp3);
printf("Framesize = %d\n", framesize);
/* set more internal variables. check for failure.*/
if(lame_init_params(mp3) == -1) {
printf("Something failed in setting internal parameters.");
}
Encode mp3 From RAW Data
memset(pcm_samples_2d[1], 0, (numBytes/2) * sizeof(int));
memset(pcm_samples_2d[0], 0, (numBytes/2) * sizeof(int));
i = 0;
for(i = 0; i < (numBytes/2); i++) {
pcm_samples_2d[0][i] = *((int *)InAudioBuf + i);
}
encodedBufferSize = lame_encode_buffer(mp3, (const short int *)pcm_samples_2d[0], (const short int *)pcm_samples_2d[1],
numBytes/2, OutAudioBuf, numBytes/2);
Close Lame module
lame_close(mp3);
No comments:
Post a Comment