0
0

I’m trying to write a plugin using Game_Music_Emu from Blargg. It handles a lot of video game formats.

I however have a problem, my read callback looks like this:
[code:3escn98i]

static int v = 0;
FMOD_RESULT F_CALLBACK nsfread(FMOD_CODEC_STATE codec, void *buffer, unsigned int size, unsigned int *read)
{
gameplugin
gp = (gameplugin)codec->plugindata;
gp->emu->play(size,(signed short
)buffer);
*read=size;
return FMOD_OK;
}
[/code:3escn98i]
but the song plays about twice as fast and stutters.

If I do like this, and only call the playfunction every other time:
[code:3escn98i]
FMOD_RESULT F_CALLBACK myread(FMOD_CODEC_STATE codec, void *buffer, unsigned int size, unsigned int *read)
{
gameplugin
gp = (gameplugin*)codec->plugindata;

if(v==0)
{
    gp->emu->play(size,(signed short*)buffer);

    v=2;
}
*read=size;
v--;
//printf( "%i\n",gp->gpwaveformat.blockalign );

return FMOD_OK;

}
[/code:3escn98i]
It sounds almost fine, just some small stuttering. So any ideas how to fix this for real?

I may add that I set up the plugin like this:
[code:3escn98i]
gp->gpwaveformat.format = FMOD_SOUND_FORMAT_PCM16;
gp->gpwaveformat.channels = 2;
gp->gpwaveformat.frequency = 44100;
gp->gpwaveformat.blockalign = (16 >> 3) * gp->gpwaveformat.channels;
gp->gpwaveformat.lengthpcm = 0xffffffff; //inifite length
[/code:3escn98i]
and also set the frequency to 44100 for the emu player

  • You must to post comments
0
0

Well…the solution was
[code:7j39t3ue]
gp->emu->play(size/2,(signed short*)buffer);
[/code:7j39t3ue]

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.