hi there.
i have extracted all the vorbis packets and get it in the array. Then,
i try to decompress data and convert it to pcm. all works fine with
Visual Studio 2003, but when i compile vorbis and my code in WindowsCE
Platform Builder under x86 VIA processor (mini-ITX MB Epia-SP) i hear
slight gaps, "speed-downs" and "speed-ups". Can anybody tell me, why?
i have such code:
//init
vorbis_synthesis_init(&vorb_dsp_state,&m_vorb_info);
vorbis_block_init(&vorb_dsp_state,&vorb_block);
offset = 0;
// go through
for (uint32 p = 3; p < m_packets_number; p++)
{
float ** pcm = NULL;
int samples;
if (vorbis_synthesis(&vorb_block,&m_packets[p],1)==0)
vorbis_synthesis_blockin(&vorb_dsp_state,&vorb_block);
// using no more than 4096
while ( (samples = vorbis_synthesis_pcmout(&vorb_dsp_state, &pcm)) > 0)
{
int bout=(samples<4096) ? samples : 4096;
float * pcm_fr[2];
for (i = 0; i < (uint32)m_vorb_info.channels; i++)
pcm_fr[i] = pcm[i];
//my own func, see below
ConvertOGGToPCM(reinterpret_cast<int16 *>(m_fake_data) + offset, pcm_fr, bout, m_vorb_info.channels);
offset += bout * m_vorb_info.channels;
vorbis_synthesis_read(&vorb_dsp_state,bout);
}
}
vorbis_block_clear(&vorb_block);
vorbis_dsp_clear(&vorb_dsp_state);
void ConvertOGGToPCM(int16 * dst, const float * const * src, uint32 sample_cnt, uint32 channels )
{
for (uint32 i = 0; i < channels; i++)
{
int16 *ptr = dst+i;
const float *mono = src[i];
for (uint32 j = 0; j < sample_cnt; j++)
{
int val = int(mono[j] * 32767.f);
if(val > 32767)
val = 32767;
if(val < -32768)
val =- 32768;
*ptr = val;
ptr += channels;
}
}
}