Author Topic: Mixer, Stream and BASS_SPEAKER_REAR  (Read 227 times)

Ed1966

  • Posts: 99
Mixer, Stream and BASS_SPEAKER_REAR
« on: 2 Nov '18 - 06:36 »
Hi there!

Question SpeakerFlag.
I want to add two streams in Mixer and listen when Mixer playing to two separate ouputs.
Is this posible? (Lot's of work to rewrite that's why I ask here before changing)
 
Check: BASS_SPEAKER_FRONT and BASS_SPEAKER_REAR

Code: [Select]
FStream1 := BASS_StreamCreateFile(False, PChar(AMusicFile1), 0, 0, BASS_STREAM_DECODE or BASS_UNICODE or BASS_SAMPLE_FLOAT or BASS_SPEAKER_FRONT);
FStream2 := BASS_StreamCreateFile(False, PChar(AMusicFile2), 0, 0, BASS_STREAM_DECODE or BASS_UNICODE or BASS_SAMPLE_FLOAT or BASS_SPEAKER_REAR);
BASS_Mixer_StreamAddChannel(FMixer, FStream1, Flags);
BASS_Mixer_StreamAddChannel(FMixer, FStream2, Flags);
BASS_ChannelPlay(FMixer, ARestart);

Or must I put it only on the Mixer, and so just one output?
(This tested but same channel sound output)

Code: [Select]
BASS_ChannelFlags(FMixer, BASS_SPEAKER_REAR, BASS_SPEAKER_REAR);
Kind regards,
Eduard.
« Last Edit: 2 Nov '18 - 08:31 by Ed1966 »

Ian @ un4seen

  • Administrator
  • Posts: 21329
Re: Mixer, Stream and BASS_SPEAKER_REAR
« Reply #1 on: 2 Nov '18 - 15:03 »
Are the 2 separate outputs on the same soundcard, eg. "front" and "rear" pairs? If so, you could create a 4 channel mixer and use the BASS_SPEAKER_FRONT/REAR flags in the BASS_Mixer_StreamAddChannel calls. You would use BASS_Mixer_ChannelFlags when you want to change a source's SPEAKER flags.

Ed1966

  • Posts: 99
Re: Mixer, Stream and BASS_SPEAKER_REAR
« Reply #2 on: 3 Nov '18 - 03:37 »
Thank you.
If I understand correctly, this is the solution:

Code: [Select]
FStream1 := BASS_StreamCreateFile(False, PChar(AMusicFile1), 0, 0, BASS_STREAM_DECODE or BASS_UNICODE or BASS_SAMPLE_FLOAT);
FStream2 := BASS_StreamCreateFile(False, PChar(AMusicFile2), 0, 0, BASS_STREAM_DECODE or BASS_UNICODE or BASS_SAMPLE_FLOAT);
BASS_Mixer_StreamAddChannel(FMixer, FStream1, Flags or BASS_SPEAKER_FRONT);
BASS_Mixer_StreamAddChannel(FMixer, FStream2, Flags or BASS_SPEAKER_REAR);
BASS_ChannelPlay(FMixer, ARestart);

And for normal use this is only necessary:

Code: [Select]
BASS_Mixer_ChannelFlags(FMixer, BASS_SPEAKER_REAR, BASS_SPEAKER_REAR);

Do the latter replace the first code?
(That I do not accidentally use it.)

Thank you so far...  :)

Ian @ un4seen

  • Administrator
  • Posts: 21329
Re: Mixer, Stream and BASS_SPEAKER_REAR
« Reply #3 on: 5 Nov '18 - 12:39 »
Yes, that is correct. You can use BASS_Mixer_ChannelFlags to change the SPEAKER flags that were set in the BASS_Mixer_StreamAddChannel call.

Ed1966

  • Posts: 99
Re: Mixer, Stream and BASS_SPEAKER_REAR
« Reply #4 on: 5 Nov '18 - 14:48 »
Very nice. Thank you  ;D

Ed1966

  • Posts: 99
Re: Mixer, Stream and BASS_SPEAKER_REAR
« Reply #5 on: 12 Nov '18 - 13:08 »
Just tried but no sound comes out and song does not play either. Have we overlooked something?

Code: [Select]

BASS_Init(-1, BASS_CONFIG_FREQUENTIE or BASS_DEVICE_SPEAKERS or BASS_DEVICE_LATENCY, 0, AHandle, nil);

FMixer := BASS_Mixer_StreamCreate(AFreq, AChans, BASS_UNICODE or BASS_STREAM_AUTOFREE);
BASS_ChannelSetAttribute(FMixer, BASS_ATTRIB_VOL, 1.0);

FStream := BASS_StreamCreateFile(False, PChar(AMusicFile), 0, 0, BASS_STREAM_DECODE or BASS_UNICODE or BASS_SAMPLE_FLOAT);

Flags := BASS_MIXER_PAUSE or BASS_MIXER_BUFFER or BASS_MIXER_NORAMPIN or BASS_SPEAKER_REAR;
Result := BASS_Mixer_StreamAddChannel(FMixer, FStream, Flags);

BASS_Mixer_ChannelFlags(FStream, 0, BASS_MIXER_PAUSE);


Note:
I get error 'Unavailable speaker', // 42   BASS_ERROR_SPEAKER
(BASS_Mixer_StreamAddChannel)

But with old version program without mixer and the same Soundcard it works well and I hear sound?

Regards,
Eduard.
« Last Edit: 12 Nov '18 - 13:17 by Ed1966 »

Ian @ un4seen

  • Administrator
  • Posts: 21329
Re: Mixer, Stream and BASS_SPEAKER_REAR
« Reply #6 on: 12 Nov '18 - 13:38 »
What is the value of "AChans" in the BASS_Mixer_StreamCreate call? It would need to be at least 4 for BASS_SPEAKER_REAR to work in the BASS_Mixer_StreamAddChannel call.

Ed1966

  • Posts: 99
Re: Mixer, Stream and BASS_SPEAKER_REAR
« Reply #7 on: 12 Nov '18 - 16:07 »
Value was 2.  Now 8. That was mistake. Thanks.