0
0

I’m recording to mp3 using a variant on the record2disk program
using LAME and following code to write out encoded MP3 data.
I’m playing back as I record.

[code:1nj01bku]
DWORD byteswritten=0;

if (ptr1 && len1)
{
    g_Lame.beEncodeChunk(g_Lame.hbeStream,(short)len1/sizeof(short),(short*)ptr1,g_Lame.pMP3Buffer,&byteswritten);
    g_datalen += fwrite(g_Lame.pMP3Buffer, 1, byteswritten, fout);
}
if (ptr2 && len2)
{
    g_Lame.beEncodeChunk(g_Lame.hbeStream,len2/sizeof(short),(short*)ptr2,g_Lame.pMP3Buffer,&byteswritten);
    g_datalen += fwrite(g_Lame.pMP3Buffer, 1, byteswritten, fout);
}
return;

[/code:1nj01bku]

when recording the playback is smooth, however when I playback the recorded stream either using one of my own programs or something like WMP I get the odd jump. Only 1 or 2 but enough to make a difference.

What would be causing this. and how do I fix it.

Mark

  • You must to post comments
0
0

I did some tests.

I removed the playback code, but I still got jumps in recorded stream.

I also compared it with an earlier program which converts streams into
MP3 using the output_mp3 output plugin ( which uses similar logic to the
program above ). In this case the record stream was perfect.

?

  • You must to post comments
0
0

this is the code that I’m using in my main loop.
as you mentioned, it polls for the position of the recorded sound,
but I’m not sure how it would miss any position changes since it
always compares it to lastrecordpos.

forive my ignorance but could enlighten me as to how to correct the
following code with respect to the problem. I’ve already increased the
buffer size to 10seconds with no effect.

[code:2uyyzq8v]
{
res = g_pFMODSystem->getRecordPosition(&recordpos);
if ( recordpos != lastrecordpos )
{
void *ptr1=NULL;
void *ptr2=NULL;
unsigned int len1=0;
unsigned int len2=0;
int blocklen=0;

            blocklen = (int)recordpos - (int)lastrecordpos;
            if ( blocklen < 0 )
            {
                blocklen += soundlength;
            }

            //lock recorded sound and write it to disk
            g_pSound->lock(lastrecordpos * g_soundexInfo.numchannels * 2,
                            blocklen * g_soundexInfo.numchannels * 2,
                            &ptr1,
                            &ptr2,
                            &len1,
                            &len2);

            WriteMP3(g_fout,ptr1,len1,ptr2,len2);

            g_pSound->unlock(ptr1, ptr2, len1, len2);

        }
        lastrecordpos = recordpos;

        g_pFMODSystem->update();
    }

[/code:2uyyzq8v]

Mark

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.