0
0

I am trying to rip a piece from a CD and then encode that piece of data. The problem is that the piece of data that is sent to the call back function (newbuffer) is bigger than the encoder can handle. It works fine if I use the code below (I chopped some pieces out to make it shorter, but I am sure you get the idea) but it is a terrible piece of coding, opening and closing the file takes up far too much time. I just could not think of any other solution. Any suggestions?

fileWav = fopen(“temp.wav”, “wb”);
fwrite(newbuffer, 1, length << 2, fileWav);
fclose(fileWav);
fileWav = fopen(“temp.wav”, “rb”);

do
{
// Put PCM samples into buffer
dwRead = fread(pWAVBuffer, sizeof(SHORT), dwSamples, fileWav);
// Encode samples
err = beEncodeChunk(hbeStream, dwRead, pWAVBuffer, pMP3Buffer, &dwWrite);
// Check encoding result
if(err != BE_ERR_SUCCESSFUL)
{
beCloseStream(hbeStream);
chkEnc = false;
}
// Write dwWrite bytes that are returned in the pMP3Buffer to disk
if(fwrite(pMP3Buffer, 1, dwWrite, fileMP3) != dwWrite)
chkEnc = false;
} while (dwRead != 0);
fclose(fileWav);

  • You must to post comments
0
0

I post the same question ad hydrogen audio forums about beencodechuck.
Lame accepts any size of input and sizes his buffer accordingly. Just do:[code:3shjzuyz]
beEncodeChunk(hbeStream, length*2, newbuffer, pMP3Buffer, &dwWrite);
[/code:3shjzuyz]
and lame will encode the file correctly 😉

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.