i have a soundplayer class with all the essential stuff inside. also i have a method to set a syncpoint callback. callbacks firing very well.

so, i have two objects sndplayer_A and sndplayer_B. i would like to play sndplayer_B from sndplayer_A (or vice versa) its callback method. i struggle getting it work. i guess i have to get somehow the correct channel, isn’t it? how do i manage this?

would appreciate any help. :)

  • You must to post comments

Hi clubmusician,

Could you post the code from your callback so we can take a look?

  • You must to post comments

in the meantime i made it, but not the way i want to do it.

here is my code:
FMOD_RESULT F_CALLBACK mycallback(FMOD_CHANNEL * channel, FMOD_CHANNEL_CALLBACKTYPE type, void* commanddata1, void* commanddata2)

    FMOD_SOUNDGROUP *  soundgroup;

    int numsounds;

    printf(" numsounds %i \n", numsounds);

    FMOD_SOUND *  thesound;
    FMOD_SoundGroup_GetSound(soundgroup,1, &thesound); //get the sound of sndplayer_B

  printf( "\nGot a sync point callback!\n" );
    printf( "index %i", (int)commanddata1 );

    FMOD_SOUND * currentsound = 0;
    FMOD_Channel_GetCurrentSound(channel, &currentsound);

    char name[5];
    unsigned int offset = 0;

    printf(" name: %c", name[0]); for (int i = 1; i<5; i++) printf("%c", name[i]);
    printf("\noffset: %u\n", offset);

    FMOD_BOOL playing;
    if (!playing)
        FMOD_System_PlaySound(sys, FMOD_CHANNEL_FREE, thesound, false, &channelotherdeck);
return FMOD_OK;


so, the deck is finally playing from the callback. however some information is lost which i set before for the sndplayer_B like volume and tempo ..

is there a way to access the sndplayer_B object from sndplayer_A ?

or do i have to reconsider my architecture? maybe it would be simplier if both decks are in one object, isn’t it?
however i would prefer smaller changes in my code..

  • You must to post comments

solved it by putting the callback into the main where i use the sndplayer_A and sndplayer_B. from there i can access both inside the callback.

one issue remains: i detected some delay. how can i fix it?

the thing is, when i play both sndplayer ( A & B ) at the same time, the beat is matched almost perfectly. however, playing a sndplayer from a syncpoint callback some little delay occurs, the beats aren’t "perfect" matched. what should i do?

thx :)

  • You must to post comments

When you call playsound there is some unavoidable latency, that is the price of doing business. :) The only way to match up sounds in a sample-accurate way is to schedule it in advance using setDelay. If you want to start a sounds exactly on a sync point of another sound then you should be able to do that using Sound::getSyncPointInfo. Schedule both sounds using Channel::setDelay, for the second sound add the offset of the syncpoint to it’s delay.

  • You must to post comments

Thank you. I will try to understand this! I think the following is a good guideline => [url=http://fmod.org/forum/viewtopic.php?f=18&t=14630&p=49815&hilit=setdelay#p49815:15bivow8]link[/url:15bivow8]

  • You must to post comments
Showing 5 results
Your Answer

Please first to submit.