Author Topic: SYNC Event for HCHANNEL  (Read 159 times)

HeartWare

  • Posts: 3
SYNC Event for HCHANNEL
« on: 28 May '21 - 20:38 »
Is it possible to get a SYNC event upon completion of playback of a HCHANNEL ?

It seems like I can only do so for HMUSIC, HSTREAM or HRECORD.

Is there a way to "convert" a HCHANNEL (or a HSAMPLE) to one of the above?

I'm using
    H:=BASS_SampleLoad(FALSE,POINTER(FileName),0,0,1,BASS_UNICODE);
and
    C:=BASS_SampleGetChannel(H,TRUE);
followed by
    BASS_ChannelPlay(C,TRUE)

to start playback...

(using Delphi 10.4 and BASS 24)

QuentinC

  • Posts: 67
Re: SYNC Event for HCHANNEL
« Reply #1 on: 31 May '21 - 18:15 »
Hello,

With the latest beta (2.4.15), you can replace:
 BASS_ChannelPlay(C,TRUE)
by:
 BASS_ChannelPlay(C,BASS_SAMCHAN_STREAM)

This will return a HSTREAM from your HSAMPLE, instead of a HCHANNEL.

As far as I know, most, if not all syncs, can't be used with HCHANNEL.

Chris

  • Posts: 1957
Re: SYNC Event for HCHANNEL
« Reply #2 on: 1 Jun '21 - 13:55 »
so should to be something like this

 
Code: [Select]
var
  H:HSample;
  FStream : HStream;
begin
  H:=BASS_SampleLoad(FALSE,POINTER(FileName),0,0,1,BASS_UNICODE);
  if H <> 0 then
  begin
     FStream := BASS_SampleGetChannel(C, BASS_SAMCHAN_STREAM);
     if FStream <> 0 then
        begin
           // Here can you set your wanted Sync
           Bass_ChannelPlay(FStream,false);
        end;
  end;
end;



Ian @ un4seen

  • Administrator
  • Posts: 23743
Re: SYNC Event for HCHANNEL
« Reply #3 on: 1 Jun '21 - 14:54 »
Just to clarify, the BASS_SAMCHAN_STREAM option isn't in the current BASS release (2.4.15) but is coming in the next release, and you can get the latest build including it here:

   www.un4seen.com/stuff/bass.zip

HeartWare

  • Posts: 3
Re: SYNC Event for HCHANNEL
« Reply #4 on: 1 Jun '21 - 15:20 »
Right now, I'm using
  BASS_ChannelSetAttribute(C,BASS_ATTRIB_VOL,Value)
to set the volume of playback.

Can I do this with a HSTREAM instead of a HCHANNEL?

If not, how do I set the volume of playback if I don't have a HCHANNEL? Or can I get both a HCHANNEL and a HSTREAM from the same HSAMPLE?

Ian @ un4seen

  • Administrator
  • Posts: 23743
Re: SYNC Event for HCHANNEL
« Reply #5 on: 1 Jun '21 - 16:15 »
Yes, the BASS_ATTRIB_VOL setting can be used on streams (HSTREAM) too.

HeartWare

  • Posts: 3
Re: SYNC Event for HCHANNEL
« Reply #6 on: 2 Jun '21 - 05:46 »
Just to clarify, the BASS_SAMCHAN_STREAM option isn't in the current BASS release (2.4.15) but is coming in the next release, and you can get the latest build including it here:

There's no .PAS file in that archive, and the 2.4 one doesn't have the BASS_SAMCHAN_STREAM constant...

If you're planning a release before/in the weekend, I can wait until the official release...
« Last Edit: 2 Jun '21 - 06:04 by HeartWare »

Ian @ un4seen

  • Administrator
  • Posts: 23743
Re: SYNC Event for HCHANNEL
« Reply #7 on: 2 Jun '21 - 13:09 »
For now, you can copy the value from the updated BASS.H file to the BASS.PAS file. It would look like this:

Code: [Select]
  // BASS_SampleGetChannel flags
  BASS_SAMCHAN_NEW = 1;
  BASS_SAMCHAN_STREAM = 2;