|
sa1988
Posts: 14
|
 |
« on: 16 Sep '11 - 11:19 » |
Quote
|
I have created loop functionality using This code. BASS_ChannelSetSync(mainStream, BASS_SYNC_POS|BASS_SYNC_MIXTIME, BASS_ChannelSeconds2Bytes(mainStream, timeForLoopOut), &MySyncProc,self);
And my callback function is:- void CALLBACK MySyncProc(HSYNC handle, DWORD channel, DWORD data, void *user) { BASS_ChannelSetPosition(channel, BASS_ChannelSeconds2Bytes(channel, timeForLoopIn),BASS_POS_BYTE); }
But callback function called early not on the time of loop-out.
Is there any way to callback on exact time of loop out? I am using iOS version of bass.
|
|
|
|
« Last Edit: 16 Sep '11 - 11:22 by sagar »
|
Logged
|
|
|
|
|
Ian @ un4seen
Administrator
Posts: 15259
|
 |
« Reply #1 on: 16 Sep '11 - 15:19 » |
Quote
|
When you say the SYNCPROC is called early, do you mean that BASS_ChannelGetPosition reports an earlier position? If so, that will be because it is reporting the position being heard, not the position being decoded. You can use the BASS_POS_DECODE flag to get the decoding position, which should match the sync's position.
Note the BASS_SYNC_MIXTIME flag will mean that your SYNCPROC is called when the decoder reaches the position, not when playback does (which will be later due to buffering).
|
|
|
|
|
Logged
|
|
|
|
|
sa1988
Posts: 14
|
 |
« Reply #2 on: 19 Sep '11 - 07:57 » |
Quote
|
Is there any way to convert position BASS_POS_BYTE position to BASS_POS_DECODE position? I had used time of loop-out which is returned by this code: loopOutTime=BASS_ChannelBytes2Seconds(mainStream,BASS_ChannelGetPosition(mainStream,BASS_POS_BYTE));
And i need to convert it to time which is taken using flag BASS_POS_DECODE. Because callback function uses position BASS_POS_DECODE and i had set position using flag BASS_POS_BYTE . when loop-out pressed i have to set time of stream which is user hearing not the position of decoding.
|
|
|
|
« Last Edit: 19 Sep '11 - 08:01 by sagar »
|
Logged
|
|
|
|
|
Ian @ un4seen
Administrator
Posts: 15259
|
 |
« Reply #3 on: 19 Sep '11 - 14:19 » |
Quote
|
If you want to set the sync at the position currently being heard, then that "loopOutTime" calculation looks fine (you don't want the BASS_POS_DECODE flag there). If it isn't working as expected, please confirm what sort of channel "mainStream" is, eg. post the code you're using to create it. If it's a mixer source, then you should use BASS_Mixer_ChannelGetPosition (instead of BASS_ChannelGetPosition) to get the position being heard.
|
|
|
|
|
Logged
|
|
|
|
|
sa1988
Posts: 14
|
 |
« Reply #4 on: 22 Sep '11 - 07:16 » |
Quote
|
Hi
I am creating my stream using this code:-
BASS_Init(-1, 44100, 0, 0, NULL); BASS_SetConfig(BASS_CONFIG_BUFFER, 5); BASS_SetConfig(BASS_CONFIG_UPDATEPERIOD, 5);
middleStream = BASS_StreamCreateFile(FALSE,[pathStr UTF8String],0,0,BASS_SAMPLE_FLOAT|BASS_STREAM_PRESCAN|BASS_STREAM_DECODE); reverseStream=BASS_FX_ReverseCreate(middleStream, 1,BASS_STREAM_DECODE); mainStream= BASS_FX_TempoCreate(reverseStream,BASS_FX_FREESOURCE | BASS_SAMPLE_FLOAT ); BASS_ChannelSetAttribute(reverseStream, BASS_ATTRIB_REVERSE_DIR, (float)BASS_FX_RVS_FORWARD);
I want callback of setSync on position is being heard not decoded. Thanks in advance.
|
|
|
|
« Last Edit: 22 Sep '11 - 07:19 by sagar »
|
Logged
|
|
|
|
|
Ian @ un4seen
Administrator
Posts: 15259
|
 |
« Reply #5 on: 22 Sep '11 - 14:57 » |
Quote
|
OK. Please try setting the BASS_SYNC_POS sync on the source stream ("middleStream") instead of the playback/tempo stream ("mainStream"). You would still use the latter in the "loopOutTime" calculation.
|
|
|
|
|
Logged
|
|
|
|
|
sa1988
Posts: 14
|
 |
« Reply #6 on: 23 Sep '11 - 07:16 » |
Quote
|
Cool !!!
Works for me.
Another question is how to check is BASS_ChannelSetSync is removed or not? I want to remove it conditionally. Means i want to call removeSync if stream is already synced.
Thanks
|
|
|
|
« Last Edit: 23 Sep '11 - 14:15 by sagar »
|
Logged
|
|
|
|
|
radio42
Posts: 4012
|
 |
« Reply #7 on: 23 Sep '11 - 14:23 » |
Quote
|
BASS_ChannelSetSync returns a handle to the sync. This handle can/must be used in a BASS_ChannelRemoveSync call to remove it. As such you need to 'know/remember' yourself if you have set a sync on a channel or not. A SYNC is also automatically freed, if you free the underlying stream.
|
|
|
|
|
Logged
|
|
|
|
|