Author Topic: How to determine if saple ends plaing?  (Read 3493 times)

jourim

  • Guest
How to determine if saple ends plaing?
« on: 13 Jun '03 - 22:37 »
subj?
I`v use next code to play saples:
Handle = BASS_SampleLoad(FALSE,(void*)filename,0,0,1,flags);
Chanel = BASS_SamplePlay( Handle );
...

All above right, sample plays but i need to know if played sample reach its end.
How to do this?
I found the only way to do it:

   BASS_SampleGetInfo( Handle, &SampleInfo );
   if ( SampleInfo.length*10 / SampleInfo.freq == (DWORD)(BASS_ChannelBytes2Seconds(Chanel,BASS_ChannelGetPosition(Chanel))*10) )
     return false;
    else
     return true;

are where any normal ways to define if sample ends?


Ian @ un4seen

  • Administrator
  • Posts: 21991
Re: How to determine if saple ends plaing?
« Reply #1 on: 14 Jun '03 - 11:51 »
Use BASS_ChannelIsActive with the HCHANNEL handle returned when you call BASS_SamplePlay. (you can also use the HSAMPLE handle, as you're using a "max" parameter of only "1")

jourim

  • Guest
Re: How to determine if saple ends plaing?
« Reply #2 on: 14 Jun '03 - 13:30 »
Quote

Use BASS_ChannelIsActive with the HCHANNEL

This function was the first i try.
It works with streams but with samples does not.
I create a sample where i start sound (stream or sample) and write value result of xxxIsActive and position (BASS_ChannelGetPosition) to screen.
When i start application and press to "play" button:
 - with streams: value turns from 0 to 1 and position increments until EOF. After this, position stops changing and value turn to 0;
 - with samples: value turns from 0 to 1 and position starts increment; After sample stops playing (position nearly reach EOF) the value _stay_ 1 and position number _still_ varry around EOF position. It`s looks like play thread plays last buffer, reach it end, decrement position to some small value and start play once more. So sample stay playing forever.

So this is why my question.
May be this is a library bug?

I use BASS 1.8 and do the next:
BASS_Init(-1,44100,BASS_DEVICE_3D,wndHandle);
load samples with: BASS_SAMPLE_OVER_DIST|BASS_SAMPLE_3D|BASS_SAMPLE_MUTEMAX
and play it with:
BASS_SamplePlay3D( Handle,&Position,&Orientation,&Velosity )

Ian @ un4seen

  • Administrator
  • Posts: 21991
Re: How to determine if saple ends plaing?
« Reply #3 on: 14 Jun '03 - 15:07 »
I just ran a little test (using the same flags as you), and it was fine - BASS_ChannelIsActive returned 0 as soon as the sample ended.

When playing samples, BASS doesn't have to do any work (eg. decoding or buffering) - the sample data is ready to go, so BASS simply asks DirectSound to play it. And when you request the status of the sample's playback, BASS tells you exactly what DirectSound says :)

So it looks like you probably have dodgy drivers installed. What soundcard/DirectX/Windows do you have, and have you checked if there are updated drivers available?

jouri

  • Guest
Re: How to determine if saple ends plaing?
« Reply #4 on: 14 Jun '03 - 16:53 »
Quote

I just ran a little test (using the same flags as you), and it was fine - BASS_ChannelIsActive returned 0 as soon as the sample ended.

I locate the problem.
The test code i send you by EMail.
BASS does not stops if BASS_ChannelSetPosition(channel,0) used after BASS_SamplePlay3D.


Ian @ un4seen

  • Administrator
  • Posts: 21991
Re: How to determine if saple ends plaing?
« Reply #5 on: 14 Jun '03 - 17:33 »
I tried your test code (with the BASS_ChannelSetPosition uncommented) on multiple systems, and it worked fine on all of them... so I still says it's probably dodgy drivers :)

jourim

  • Guest
Re: How to determine if saple ends plaing?
« Reply #6 on: 14 Jun '03 - 17:48 »
Quote

I tried your test code (with the BASS_ChannelSetPosition uncommented) on multiple systems, and it worked fine on all of them... so I still says it's dodgy drivers :)

Okay, you win :)
I`v got a creative 5.1 on winXP and drivers from creative.
(As i know there is only one drivers pakage for XP)
Thanks.
I try to find newest drivers and run this sample on other sound systems.

Ian @ un4seen

  • Administrator
  • Posts: 21991
Re: How to determine if saple ends plaing?
« Reply #7 on: 15 Jun '03 - 13:08 »
That's strange... one of the setups I tried your code on was an SBLive/WinXP, with the latest drivers from Creative. Try reinstalling the latest drivers and DirectX.

Just as a test, you could also see what happens when you use the BASS_SAMPLE_SOFTWARE flag.