Author Topic: SynProc fires too early with decoded stream  (Read 347 times)

martin71

  • Posts: 34
I am using BASS_Mixer_ChannelSetSync with the BASS_SYNC_POS and BASS_SYNC_MIXTIME flags to mix another song at a specific point.

It works always perfect. But when I decode the Mixer stream, the SyncProc is called too early. Is there a way to solve this so I can save the mix to a wave file without playing?

Ian @ un4seen

  • Administrator
  • Posts: 21325
Re: SynProc fires too early with decoded stream
« Reply #1 on: 2 Jul '18 - 13:20 »
A "mixtime" BASS_SYNC_POS sync is called when the decoder reaches the specified position, so it should be exactly the same for normal playback and decoding channels. Please show what your BASS_Mixer_ChannelSetSync call and SYNCPROC callback function looks like.

martin71

  • Posts: 34
Re: SynProc fires too early with decoded stream
« Reply #2 on: 2 Jul '18 - 15:25 »
Hi Ian,

Good to know. I just made a small program to test it again (sorry, I should have done that before posting here) and it works indeed. So something must be wrong in the code of my (larger) application so I will check again if I can find the bug. Thanks!

Martin

martin71

  • Posts: 34
Re: SynProc fires too early with decoded stream
« Reply #3 on: 2 Jul '18 - 21:05 »
I think I am using a too big buffer with BASS_ChannelGetData.

BASS_ChannelGetData(Mixer, @Buffer(), 20000) will call the setsync callback too early.

So now I'm using  BASS_ChannelGetData(Mixer, @Buffer(), 1024). This works perfect but the decoding goes extremely slow.  :(

Ian @ un4seen

  • Administrator
  • Posts: 21325
Re: SynProc fires too early with decoded stream
« Reply #4 on: 3 Jul '18 - 15:08 »
That sounds like something in the SYNCPROC is sensitive to the amount of data you're requesting in the BASS_ChannelGetData call. Perhaps you're calling BASS_Mixer_StreamAddChannel in there? If so, the new source will begin in the mixer output at the position at the start of the BASS_ChannelGetData call, eg. if you're always requesting 20000 bytes then the new source will start on a 20000 byte boundary.

When using BASS_SYNC_POS syncs to add/remove mixer sources, it is generally best to set the syncs on the mixer rather than the sources, so that they get triggered when the mixer reaches specific positions.

martin71

  • Posts: 34
Re: SynProc fires too early with decoded stream
« Reply #5 on: 3 Jul '18 - 20:37 »
You are right, BASS_Mixer_StreamAddChannel  is in the callback. And I was using BASS_Mixer_ChannelSetSync with the channel source.

If I use BASS_ChannelSetSync with the mixer source instead, then it works fine. Thanks for helping me out!