Hi There

I’m trying to right a version of the output_mp3 plugin that will playback while it encodes, I’m doing so by using a second system that is initiated in the InitCallback, and I use the createSound with FMOD_OPENUSER to create a user created sound. I then take the WAVbuffer that I get in the Update callback and write it out in the pcmreadcallback. However, I’m having few problems with the synchronization of these 2 seemingly independent asynchronous callbacks. One of the problems that I have is with the playback time and rate. I’m trying to figure out why is the output_mp3 plugin’s rate faster then the actual playback time (the 11 seconds wave.mp3 encodes in 4-5 seconds). The documentation is a bit weak concerning these functions and will really appreciate it if you could give me some more insight about it.

Thanks, Assaf

  • You must to post comments

One more Q concernng NONREALTIME, as far as I understand it is an attribute of the system and not the plugin, is that right ? Also, in user_plugins I don’t see any explicit setting for the system to be NONLINEAR, is it the default mode of the FMOD system?

  • You must to post comments

What I was asking is what makes output_mp3 be driven by the system’s update, and how can I change it so that the UpadteCallback will be called by the FMOD’s timing thread.

  • You must to post comments

Hi Brett

Thanks for the explanations, I went a head and implemented the polling=true and got the FMOD thread to call my getPosition Callback where I’m incrementing the *pcm, but for some reason unlock and lock are not called.
Any idea why that might happen?
BTW is there any chance you could release a real-time output plugin example? I will appreciate it a lot as this is one of the FMODEX parts that are not yet very thoroughly documented

Thanks again, Assaf

  • You must to post comments

Hi Brett

OK, I’m officially clueless. I checked and double checked and I’m positive I do what I think needs to be done, however I’m obviously wrong because it doesn’t work. Is there something that should be done in the Init Callback? currently I just left it as it was.

If you can take a quick look at this code to try and see what I’m missing here I would really appreciate it:

in FMODGetOutputDescription I have the following definitions:


mp3output.update        = 0;    
mp3output.polling       = 1;
mp3output.getposition   = OutputMP3_GetPositionCallback;
mp3output.lock          = OutputMP3_LockCallback;
mp3output.unlock        = OutputMP3_UnlockCallback;


mp3output.update        = OutputMP3_UpdateCallback;
mp3output.polling       = 0;
mp3output.getposition   = 0;
mp3output.lock          = 0;
mp3output.unlock        = 0;


I also added the following functions to the output_mp3 main.c:

FMOD_RESULT F_CALLBACK OutputMP3_GetPositionCallback(FMOD_OUTPUT output, unsigned int *pcm){
mp3 = output->userdata;
printf(“PCM %d \n”,
FMOD_RESULT F_CALLBACK OutputMP3_LockCallback(FMOD_OUTPUT *output, unsigned int offset, unsigned int length, void **ptr1, void **ptr2, unsigned int *len1, unsigned int *len2){
printf(“lock \n”);
FMOD_RESULT F_CALLBACK OutputMP3_UnlockCallback(FMOD_OUTPUT *output, void *ptr1, void *ptr2, unsigned int len1, unsigned int len2){
printf(“unlock \n”);

The output I get is:

PCM 512
PCM 768
PCM 1024
PCM 1280
PCM 1536
PCM 1792
PCM 2048
PCM 2304
PCM 2560
PCM 2816
PCM 3072
PCM 3328
PCM 3584
PCM 3840
PCM 4096
PCM 4352
PCM 4608

and so on….

Never a lock or unlock

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.