Author Topic: Speaker assignment flags  (Read 562 times)

Eazis - Thomas

  • Posts: 16
Speaker assignment flags
« on: 24 Jun '19 - 14:13 »
Hello,

I want to test something with speaker assignment flags.
In my setup i have used a Terratec Aureon 7.1 USB soundcard.
I have tried with the Delphi Speaker example, then i get 6 speakers as output.
But when it plays it only goes to 1 output, so i hear 3 sources to one output.

What i'm doing wrong?

Ian @ un4seen

  • Administrator
  • Posts: 22244
Re: Speaker assignment flags
« Reply #1 on: 24 Jun '19 - 16:28 »
The Delphi examples are not always up-to-date with the C example, so please see if you can reproduce the problem with the pre-compiled SPEAKERS.EXE example (in the C\BIN folder). Also confirm what Windows version you are using, and what speaker setup is configured for the device in the control panel.

Eazis - Thomas

  • Posts: 16
Re: Speaker assignment flags
« Reply #2 on: 26 Jun '19 - 08:58 »
I have just tested with the pre-compiled C example, but the same happends. All 3 channels goes to one output (front)

Windows version: Windows 10 Pro (64 bit) [Version 10.0.18362.175]
DLL version: 2.4.14.0
Compiler: Rad Studio 10.3

Speaker setup please see attachment.

Eazis - Thomas

  • Posts: 16
Re: Speaker assignment flags
« Reply #3 on: 26 Jun '19 - 14:21 »
Ok we have found out the problem a little bit more.
You need to set the speaker setup in the software from the soundcard and in windows aswell. So the example works perfect now.

Now i want to implementate in the our own player but we use some more flags.

Code: [Select]
          ch[1] := BASS_StreamCreateFile(true,pl1memstream1.memory,0, pl1memstream1.size, BASS_SPEAKER_REAR or BASS_STREAM_DECODE or BASS_SAMPLE_LOOP or BASS_SAMPLE_SOFTWARE {$IFDEF UNICODE} or BASS_UNICODE {$ENDIF});

After this my stream = 0. If i remove the BASS_STREAM_DECODE flag then there is a stream.
But i need this flag to create the BASS_FX_ReverseCreate.

Code: [Select]
          ch[1] := BASS_FX_ReverseCreate(ch[1], 0.25, BASS_STREAM_DECODE or BASS_FX_FREESOURCE);
          ch[1] := BASS_FX_TempoCreate(ch[1], BASS_SAMPLE_LOOP or BASS_FX_FREESOURCE);

If i remove the BASS_STREAM_DECODE then there is no stream after BASS_FX_ReverseCreate.
Any advice to resolve this?

Thanks in advance.

Ian @ un4seen

  • Administrator
  • Posts: 22244
Re: Speaker assignment flags
« Reply #4 on: 26 Jun '19 - 14:33 »
The BASS_SPEAKER_REAR flag needs to be used in the BASS_FX_TempoCreate call instead, as it doesn't apply to decoding channels (can't be combined with BASS_STREAM_DECODE). The same goes for the BASS_SAMPLE_SOFTWARE flag too, but that flag only has effect on old Windows (XP and older) anyway.

Eazis - Thomas

  • Posts: 16
Re: Speaker assignment flags
« Reply #5 on: 26 Jun '19 - 15:08 »
Ok thanks, it works for now.
But i must create a separate stream for it. I will try to explain it a little bit in code

Code: [Select]
      try
        if (magwel1=true) then       //OR BASS_STREAM_PRESCAN
         ch[1] := BASS_StreamCreateFile(true,pl1memstream1.memory,0, pl1memstream1.size, BASS_SPEAKER_REAR {$IFDEF UNICODE} or BASS_UNICODE {$ENDIF});
         ch[10] := BASS_StreamCreateFile(true,pl1memstream1.memory,0, pl1memstream1.size, BASS_STREAM_DECODE or BASS_SAMPLE_LOOP or BASS_SAMPLE_SOFTWARE {$IFDEF UNICODE} or BASS_UNICODE {$ENDIF});
      except
        Log(FLM(8, 'Error ch[1]: ' + IntToStr(BASS_ErrorGetCode())));
      end;

After this i create a stream for scanning peaks

Code: [Select]
        try
          ch[16] := BASS_StreamCreateFile(true,pl1memstream1.memory,0, pl1memstream1.size, BASS_STREAM_DECODE {$IFDEF UNICODE} or BASS_UNICODE {$ENDIF});
          TScanThread.Create(ch[16]); // start scanning peaks in a new thread}
        except
          Log(FLM(8, 'Error TScanThread1'));
        end;

After the scanthread is created the tempo and reserve will be created

Code: [Select]
          ch[1] := BASS_FX_ReverseCreate(ch[10], 0.25, BASS_STREAM_DECODE or BASS_FX_FREESOURCE);
          ch[1] := BASS_FX_TempoCreate(ch[10], BASS_SPEAKER_REAR or BASS_SAMPLE_LOOP or BASS_FX_FREESOURCE );

Can you give me any advice to do this on more effective way?
Many thanks.

Ian @ un4seen

  • Administrator
  • Posts: 22244
Re: Speaker assignment flags
« Reply #6 on: 26 Jun '19 - 16:22 »
It doesn't look like the "ch[1] := BASS_StreamCreateFile" call is needed. In fact, it looks like that stream is leaked as ch[1] is overwritten by the reverse/tempo streams, or is it used and freed elsewhere in the meantime?

Eazis - Thomas

  • Posts: 16
Re: Speaker assignment flags
« Reply #7 on: 27 Jun '19 - 08:17 »
No, the stream ch[1] is used for playing the file.
So in fact it's only needed to add the SPEAKER flag on the end of the BASS_FX_TempoCreate?

I have changed to code on this

Code: [Select]
      try
        if (magwel1=true) then
         ch[1] := BASS_StreamCreateFile(true,pl1memstream1.memory,0, pl1memstream1.size, BASS_STREAM_DECODE or BASS_SAMPLE_LOOP or BASS_SAMPLE_SOFTWARE {$IFDEF UNICODE} or BASS_UNICODE {$ENDIF});
      except
        Log(FLM(8, 'Error ch[1]: ' + IntToStr(BASS_ErrorGetCode())));
      end;

and this

Code: [Select]
        try
          ch[16] := BASS_StreamCreateFile(true,pl1memstream1.memory,0, pl1memstream1.size, BASS_STREAM_DECODE {$IFDEF UNICODE} or BASS_UNICODE {$ENDIF});
          TScanThread.Create(ch[16]); // start scanning peaks in a new thread
        except
          Log(FLM(8, 'Error TScanThread1'));
        end;

and...

Code: [Select]
          ch[1] := BASS_FX_ReverseCreate(ch[1], 0.25, BASS_STREAM_DECODE or BASS_FX_FREESOURCE);
          ch[1] := BASS_FX_TempoCreate(ch[1], BASS_SPEAKER_REAR or BASS_SAMPLE_LOOP or BASS_FX_FREESOURCE );

I think this better?

Ian @ un4seen

  • Administrator
  • Posts: 22244
Re: Speaker assignment flags
« Reply #8 on: 27 Jun '19 - 13:44 »
Yes, that looks fine. You can remove the BASS_SAMPLE_SOFTWARE flag though, as it doesn't do doing anything on decoding channels (including on old Windows).