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

Ed1966

  • Posts: 113
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: 21456
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: 113
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: 21456
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: 113
Re: Mixer, Stream and BASS_SPEAKER_REAR
« Reply #4 on: 5 Nov '18 - 14:48 »
Very nice. Thank you  ;D

Ed1966

  • Posts: 113
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: 21456
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: 113
Re: Mixer, Stream and BASS_SPEAKER_REAR
« Reply #7 on: 12 Nov '18 - 16:07 »
Value was 2.  Now 8. That was mistake. Thanks.

Ed1966

  • Posts: 113
Re: Mixer, Stream and BASS_SPEAKER_REAR
« Reply #8 on: 20 Dec '18 - 08:56 »
Hello,

A small addition to this question.

I put a VST on the Mixer but if I use BASS_SPEAKER_REAR as Channel (BASS_Mixer_StreamAddChannel) there is no sound and VST does not work.

This is what I use: VSTHandle := BASS_VST_ChannelSetDSP(GetStream(OutputKind), PChar(VSTEffect), BASS_UNICODE, Priority);

I tried: BASS_UNICODE or BASS_DEVICE_SPEAKERS but no results.

Is this even possible and what must I do?

Regards,
Eduard.


Ian @ un4seen

  • Administrator
  • Posts: 21456
Re: Mixer, Stream and BASS_SPEAKER_REAR
« Reply #9 on: 20 Dec '18 - 15:16 »
When you say you used "BASS_SPEAKER_REAR as Channel", do you mean you set the "channel" parameter to BASS_SPEAKER_REAR in a BASS_Mixer_StreamAddChannel call? If so, that indeed won't work (BASS_ERROR_HANDLE error) as BASS_SPEAKER_REAR isn't a BASS channel handle, eg. a stream handle. BASS_SPEAKER_REAR should only be used in the "flags" parameter.

Ed1966

  • Posts: 113
Re: Mixer, Stream and BASS_SPEAKER_REAR
« Reply #10 on: 20 Dec '18 - 15:30 »
Sorry for translation.

No, I mean when using BASS_SPEAKER_REAR flag in BASS_Mixer_StreamAddChannel the BASS_VST_ChannelSetDSP is not working and stops sound.
When I free VST sound is back.
There is no Error and when I use BASS_SPEAKER_FRONT everything is fine.

So this is a VST problem but I don't know where to find solution.
It seems VST can not handle BASS_SPEAKER_REAR  flags?
Is this true?

Ian @ un4seen

  • Administrator
  • Posts: 21456
Re: Mixer, Stream and BASS_SPEAKER_REAR
« Reply #11 on: 20 Dec '18 - 17:31 »
That's strange. I don't think SPEAKER flags should affect VST. What handle are you using in the BASS_VST_ChannelSetDSP call? Is it a source handle or the mixer? If the mixer, presumably that is more than stereo (created with chans>2) and perhaps the VST doesn't support more than stereo?

Ed1966

  • Posts: 113
Re: Mixer, Stream and BASS_SPEAKER_REAR
« Reply #12 on: 20 Dec '18 - 18:05 »
I use the Mixer handle and 8 channels!
That's why VST is not working?
Solution?

Ian @ un4seen

  • Administrator
  • Posts: 21456
Re: Mixer, Stream and BASS_SPEAKER_REAR
« Reply #13 on: 21 Dec '18 - 14:24 »
Are you sure the VST needs to be applied to the mixer instead of the source? If so, and the VST only supports stereo, you will need to split the 8 channel mixer into 4 stereo streams for the VST and then recombine them after. Here's an old post on doing the same thing for the BASS_FX tempo processing (which was limited to stereo at the time):

   www.un4seen.com/forum/?topic=14730.msg102383#msg102383

Ed1966

  • Posts: 113
Re: Mixer, Stream and BASS_SPEAKER_REAR
« Reply #14 on: 21 Dec '18 - 15:53 »
I have three sources (PlayerLeft, PlayerRight, Effects) into one Mixer for VST. I don't know how else to do that.

If you say VST is only stereo, you mean that bass_vst itself can handle more then stereo?
I use vst_stereo_tool.

I wil look at old posting this weekend.
« Last Edit: 21 Dec '18 - 15:56 by Ed1966 »

Ian @ un4seen

  • Administrator
  • Posts: 21456
Re: Mixer, Stream and BASS_SPEAKER_REAR
« Reply #15 on: 21 Dec '18 - 16:50 »
I have three sources (PlayerLeft, PlayerRight, Effects) into one Mixer for VST. I don't know how else to do that.

I guess "PlayerLeft" and "PlayerRight" are mono sources going to the left and right channels, and "Effects" goes to both channels? If so, you only need a 2 channel (not 8) mixer for that, and a stereo VST would then be able to work with it.

If you say VST is only stereo, you mean that bass_vst itself can handle more then stereo?
I use vst_stereo_tool.

That VST's name certainly suggests its processing is stereo!

I have never actually used BASS_VST myself but looking at its source code, it doesn't appear to be limiting to stereo. The source code is available here:

   https://github.com/r10s/BASS_VST

Ed1966

  • Posts: 113
Re: Mixer, Stream and BASS_SPEAKER_REAR
« Reply #16 on: 21 Dec '18 - 17:25 »
Quote
I guess "PlayerLeft" and "PlayerRight" are mono sources going to the left and right channels, and "Effects" goes to both channels? If so, you only need a 2 channel (not 8) mixer for that, and a stereo VST would then be able to work with it.

Actually Left, Right, Effect are stereo channels. I need at least 6 channels because output soundcard SPEAKERS plugged  into real hardware Mixer and then you can adjust your volume yourself.
Output hardware Mixer plugged into input soundcard and broadcast for DJ purpose.
 
Quote
That VST's name certainly suggests its processing is stereo!

I think you are right. I should take a closer look at that.

If I downmix Mixer from 8 to 2 channels I think SPEAKER FLAGS are not working anymore?
Problem is that I don't use BASS_STREAM_DECODE Mixer.

Regards,
Eduard.

Ed1966

  • Posts: 113
Re: Mixer, Stream and BASS_SPEAKER_REAR
« Reply #17 on: 22 Dec '18 - 11:50 »
It will be difficult because DOWNMIX will no longer pass the SPEAKERS. Then it is simply standard SPEAKER_FRONT. I do not want that.
Then I will have to put the same VST on the source mixer and that is three times. Also not convenient.
Is it not possible that the writer of the VST for BASS can build a kind of DOWNMIX flag?
More VST plugins have the same problem if more then Stereo. .

Regards,
Eduard.

Ian @ un4seen

  • Administrator
  • Posts: 21456
Re: Mixer, Stream and BASS_SPEAKER_REAR
« Reply #18 on: 27 Dec '18 - 17:46 »
Once multi-channel sound is downmixed to stereo, it isn't possible to separate the channels back again. So BASS_VST automatically downmixing wouldn't be a solution. I see 3 possible solutions: you can set the VST on each source individually, or you can create a stereo mixer for each speaker pair and set the VST on each of them, or you can split a multi-channel mixer into stereo streams and then recombine after applying the VST (as in the link I posted earlier).

Ed1966

  • Posts: 113
Re: Mixer, Stream and BASS_SPEAKER_REAR
« Reply #19 on: 28 Dec '18 - 09:19 »
First option. Clear as far as VST DOWNMIX is concerned.

Second option here is easy because I know the source streams. Does the VST plugin settings have to be the same or does that happen automatically? I do not think so myself and should therefore first to setup this and then connect all stream?

Third option is the same as the second?
I do not use DECODE Mixers.

Think for me second option?

Regards,
Eduard.





Ian @ un4seen

  • Administrator
  • Posts: 21456
Re: Mixer, Stream and BASS_SPEAKER_REAR
« Reply #20 on: 28 Dec '18 - 15:45 »
The 2nd and 3rd options are a bit different. In the 2nd option, you would have 4x stereo mixers and you would plug each source into the mixer that corresponds with the output you want it on. In the 3rd option, you would have a single 8 channel mixer that you would plug all sources into, and you would then split it into stereo streams for the VST and recombine after (see the linked post). The part that is the same in both cases is that you would need a VST effect for each stereo output. I haven't tried it myself but I would assume that each VST effect instance will have its own parameters and so you would need to apply the wanted parameters to each of them.

The main advantage of the 3rd option is that it allows a source to be played on multiple outputs via matrix mixing. If you don't need that then I would suggest the 2nd option as it is simpler.

Ed1966

  • Posts: 113
Re: Mixer, Stream and BASS_SPEAKER_REAR
« Reply #21 on: 29 Dec '18 - 07:37 »
Thank you for the assistance  :)

Regards,
Eduard.