Author Topic: BASS_ChannelSetPosition problem  (Read 2541 times)

gabor

  • Posts: 2
BASS_ChannelSetPosition problem
« on: 1 Mar '03 - 10:20 »
hello,

i am trying to replay a MOD file, but i would like to specify the pattern orders
on the fly. my idea was to set a synchronizer to the first row of all patterns:

BASS_ChannelSetSync(mod, BASS_SYNC_POS, (QWORD)MAKELONG(-1, 0), &sync_patternstart , (DWORD)mod);

and in sync_patternstart callback i set the position
using BASS_ChannelSetPosition:

void CALLBACK sync_patternstart(HSYNC handle, DWORD channel, DWORD data, DWORD user)
{
     BASS_ChannelSetPosition(mod, (QWORD)MAKEWORD(current_order, 0));
}

my problem is a small click that can be heard at each pattern start, because
the original order is played for a moment and after a small delay the playback
continues at the currently set position.

i have tried to use BASS_SYNC_MIXTIME as a flag when setting the synchronizer,
because i thought that the sync call could be generated a bit earlier reducing
the annoying effect.
but when the position is set to (QWORD)MAKELONG(-1, 0) the BASS_ChannelSetPosition
sync call generates a stack overflow independently of the stack size. changing
the position to any other non-zero number does not cause the overflow.

i am using version 1.7 with openwatcom compiler, but i don't think it matters.

any help would be greatly appreciated.

gabor

Ian @ un4seen

  • Administrator
  • Posts: 20393
Re: BASS_ChannelSetPosition problem
« Reply #1 on: 1 Mar '03 - 14:16 »
The problem is caused by the sync being recalled when you set the position because it's a "mixtime" sync... so eventually you get a stack fault as it keeps calling itself.

What you need to do is check the current position, to determine if you actually need to change the position. For example...
Code: [Select]
void CALLBACK sync_patternstart(HSYNC handle, DWORD channel, DWORD data, DWORD user)
{
     if (LOWORD(data)!=current_order)
           BASS_ChannelSetPosition(channel, (QWORD)MAKELONG(current_order, 0));
}


Also, note it should really be "MAKELONG" (not "MAKEWORD"), but I guess that was just a typo :)

gabor

  • Posts: 2
Re: BASS_ChannelSetPosition problem
« Reply #2 on: 10 Mar '03 - 19:13 »
thank you for your help. everything works fine now.