Jump to content



Photo

Question regarding ducking_callback

altsound pinmame

  • Please log in to reply
2 replies to this topic

#1 MrGrynch

MrGrynch

    Enthusiast

  • Members
  • PipPipPip
  • 127 posts

  • Flag: United States of America

  • Favorite Pinball: Blood Machines, Fish Tales, Attack from Mars

Posted 01 May 2023 - 08:25 PM

In the PinMame altsound code (snd_alt.h) there is a function called "ducking_callback"

void CALLBACK ducking_callback(HSYNC handle, DWORD channel, DWORD data, void *user)
{

It is included in preparation to play a channel sound

BASS_ChannelSetSync(channel_1, BASS_SYNC_END | BASS_SYNC_ONETIME, 0, ducking_callback, 0);

My question is, when does this callback happen?  The section of the code that makes this call proceeds to call to play the channel sound:

BASS_ChannelPlay(channel_1, 0);

Then proceeds to set the ducking value for channel 0:

if (psd.ducking[idx] > 0 && psd.ducking[idx] < min_ducking) {
    float new_val;
    min_ducking = psd.ducking[idx];
    new_val = channel_0_vol*(float)((double)psd.ducking[idx] / 100.);
    if (channel_0_vol != new_val)
        BASS_ChannelSetAttribute(channel_0, BASS_ATTRIB_VOL, new_val);
}

What confuses me here is that we have a ducking_callback function which will modify the volume for channel 0, at some point, and we are also modifying it here after telling the driver to play a sound on channel 1.  Depending on when that callback happens, this could be problematic.  Is the above call to BASS_ChannelPlay() a blocking call?  I'm assuming not, otherwise the ducking code right below it wouldn't affect music playing on channel 0 until AFTER the SFX has finished playing, and that callback would seem unnecessary

 

I appreciate any insight!

 -G

 

 



#2 sdivodul

sdivodul

    Hobbyist

  • Members
  • PipPip
  • 39 posts
  • Location:NY

  • Flag: United States of America

  • Favorite Pinball: Indiana Jones PB Adventure

Posted 02 May 2023 - 02:15 PM

The call to ducking_callback() most likely happens inside the BASS_ChannelSetSync() function.

 

I would look for Bass library documentation for details on how to use these functions and what they do.



#3 MrGrynch

MrGrynch

    Enthusiast

  • Members
  • PipPipPip
  • 127 posts

  • Flag: United States of America

  • Favorite Pinball: Blood Machines, Fish Tales, Attack from Mars

Posted 03 May 2023 - 04:02 AM

The call to ducking_callback() most likely happens inside the BASS_ChannelSetSync() function.

 

I would look for Bass library documentation for details on how to use these functions and what they do.

Yeah, I think the DWORD that is OR'd together answers my question here: BASS_SYNC_END | BASS_SYNC_ONETIME

 

Thanks!

-G