Author Topic: Mixer situation  (Read 158 times)

Ed1966

  • Posts: 68
Mixer situation
« on: 9 May '18 - 10:11 »
Hi there,

Translate default Stream to DECODED and MIXER for every player.
Later I want to put them all together to a MasterMixer. Possible? And no Play in child MIXERS?
Is there a audible sound if I do?

SYNC problem with use of 'BASS_Mixer_ChannelGetData'
I Called: SENDMESSAGE and system dropped down when calling 'BASS_Mixer_ChannelGetData' when fading.
No problem before mixer.
Now I use POSTMESSAGE and it works :) But why?

Thank you.

Ian @ un4seen

  • Administrator
  • Posts: 20764
Re: Mixer situation
« Reply #1 on: 9 May '18 - 13:50 »
Translate default Stream to DECODED and MIXER for every player.
Later I want to put them all together to a MasterMixer. Possible? And no Play in child MIXERS?
Is there a audible sound if I do?

Yes, you can plug a mixer into another mixer.

SYNC problem with use of 'BASS_Mixer_ChannelGetData'
I Called: SENDMESSAGE and system dropped down when calling 'BASS_Mixer_ChannelGetData' when fading.
No problem before mixer.
Now I use POSTMESSAGE and it works :) But why?

SendMessage waits for the message to be handled before returning, while PostMessage does not wait. I'm guessing you had a deadlock in the SendMessage case, ie. it was waiting for another thread (probably the main thread) to handle the message and that other thread was waiting for the SendMessage call's thread. You should avoid waiting for other threads in a "mixtime" SYNCPROC callback (or STREAMPROC/DSPPROC).

Ed1966

  • Posts: 68
Re: Mixer situation
« Reply #2 on: 15 May '18 - 13:32 »
Thanks so far...
I must do a complete rewrite to DECODED and MIXER situation.
Can I use BASS_SPEAKER_REAR and other SPEAKER flags, like this:

Code: [Select]
FMixerLeft := BASS_Mixer_StreamCreate(AFreq, AChans, BASS_UNICODE);
FStream := BASS_StreamCreateFile(False, PChar(AMusicFile), 0, 0, BASS_STREAM_DECODE or BASS_UNICODE or BASS_SPEAKER_REAR);
Result := BASS_Mixer_StreamAddChannel(FMixerLeft, FStream, BASS_MIXER_BUFFER or BASS_MIXER_NORAMPIN or BASS_MIXER_PAUSE);

This FMixerLeft and other FMixerRight wil be pluged into a master Mixer at later time.
(I don't loose de SPEAKER flag?)

Regards,
Eduard.

Ian @ un4seen

  • Administrator
  • Posts: 20764
Re: Mixer situation
« Reply #3 on: 15 May '18 - 14:13 »
When playing through a mixer, you would move the BASS_SPEAKER flags from the BASS_StreamCreateFile call to the BASS_Mixer_StreamAddChannel call:

Code: [Select]
FMixerLeft := BASS_Mixer_StreamCreate(AFreq, AChans, 0);
FStream := BASS_StreamCreateFile(False, PChar(AMusicFile), 0, 0, BASS_STREAM_DECODE or BASS_UNICODE);
Result := BASS_Mixer_StreamAddChannel(FMixerLeft, FStream, BASS_MIXER_BUFFER or BASS_MIXER_NORAMPIN or BASS_MIXER_PAUSE or BASS_SPEAKER_REAR);

Ed1966

  • Posts: 68
Re: Mixer situation
« Reply #4 on: 15 May '18 - 16:15 »
 :D Thank you Ian.

Ed1966

  • Posts: 68
Re: Mixer situation
« Reply #5 on: 18 May '18 - 09:06 »
I want to add 'BASS_FX_TempoCreate' for stream:

Code: [Select]
function TBassMixerAudio18.LoadAudio(AMusicFile: string; AVolume: FLOAT; ASpeakerFlag: DWORD): Boolean;
var
  Flags: DWORD;
begin
  FPlayingTime := 0.0;
  FEndPoint := 0.0;
  FTotalBytes := 0;
  FStartPoint := 0.0;
  FInputFile := AMusicFile;
  FVolume := AVolume;
  BASS_StreamFree(FStream);
  SetChannelMode(BASS_ACTIVE_STOPPED);
  FStream := BASS_StreamCreateFile(False, PChar(AMusicFile), 0, 0, BASS_STREAM_DECODE or BASS_UNICODE);
  Result := (FStream <> 0) and (BASS_ErrorGetCode = 0);
  if (Result) then
  begin
    { Ready }
    FTotalBytes := BASS_ChannelGetLength(FStream, BASS_POS_BYTE);
    FPlayingTime := BASS_ChannelBytes2Seconds(FStream, FTotalBytes);
    FEndPoint := FPlayingTime;
    BASS_ChannelSetAttribute(FStream, BASS_ATTRIB_VOL, AVolume);
    BASS_ChannelSetPosition(FStream, 0, BASS_POS_BYTE);
    { Creates a resampling stream }
    FStream := BASS_FX_TempoCreate(FStream, BASS_STREAM_DECODE);
    Result := (FStream <> 0) and (BASS_ErrorGetCode = 0);
    if (Result) then
    begin
      { Setup Mixer }
      BASS_Mixer_ChannelRemove(FStream);
      { Speaker Flags must be here and not at StreamCreate }
      Flags := BASS_MIXER_BUFFER or BASS_MIXER_NORAMPIN or BASS_MIXER_PAUSE or ASpeakerFlag;
      Result := BASS_Mixer_StreamAddChannel(FMixer, FStream, Flags);
      if (Result) then ;
    end;
  end;
  ErrorCode := BASS_ErrorGetCode;
end;

And before shutdown:

Code: [Select]
  BASS_PluginFree(0);
  UnLoad_BASSDLL;
  Unload_BASSFXDLL;
  Unload_WASAPIDLL;
  Unload_BASSENCDLL;
  Unload_BASSMIXDLL;

But now I get:
---------------------------
Debugger Exception Notification
---------------------------
Project FinalPlayer.exe raised exception class $C0000005 with message 'access violation at 0x628fdeab: read of address 0x1000f04c'.
---------------------------

Is there something wrong with position:
FStream := BASS_FX_TempoCreate(FStream, BASS_STREAM_DECODE);
If I remove everything is fine.

By start program:
Code: [Select]
   if (FileExists(AddBS(LibraryFolderPath) + 'Win32\bass_fx.dll')) then begin
      Load_BASSFXDLL(AddBS(LibraryFolderPath) + 'Win32\bass_fx.dll');
   end else begin
      MessageDlg('library\Win32\bass_fx.dll not found; Incorrect file/path', mtError, [mbOK, mbCancel], 0);
      Exit;
   end;

   { Check the correct BASS_FX was loaded }
   BASS_FX_VERSION := BASS_FX_GetVersion();
   BASS_FX_VERSION_TEXT := GetBassVersionInfo(BASS_FX_VERSION);
   if (HiWord(BASS_FX_VERSION) <> BASSVERSION) then begin
     MessageDlg('An incorrect version of BASS_FX.DLL was loaded (2.4 is required)', mtError, [mbOK, mbCancel], 0);
     Exit;
   end;


Regards,
Eduard.
« Last Edit: 18 May '18 - 09:14 by Ed1966 »

Chris

  • Posts: 1827
Re: Mixer situation
« Reply #6 on: 18 May '18 - 09:18 »
Hi
$C0000005 will mean in Delphi Invalide Handle.
By the way

Quote
BASS_PluginFree(0);
  UnLoad_BASSDLL;
  Unload_BASSFXDLL;
  Unload_WASAPIDLL;
  Unload_BASSENCDLL;
  Unload_BASSMIXDLL;

should be

Code: [Select]
BASS_PluginFree(0);
  Unload_BASSFXDLL;
  Unload_WASAPIDLL;
  Unload_BASSENCDLL;
  Unload_BASSMIXDLL;
  UnLoad_BASSDLL;

Unload Bass as last not as first

Ed1966

  • Posts: 68
Re: Mixer situation
« Reply #7 on: 18 May '18 - 12:08 »
Changed, but problem the same as before?

Chris

  • Posts: 1827
Re: Mixer situation
« Reply #8 on: 18 May '18 - 16:46 »
does the Exception occurs if you close your application?
or does it come during a call ?
normally you can see it inside the debugger from where the crash comes.

Ian @ un4seen

  • Administrator
  • Posts: 20764
Re: Mixer situation
« Reply #9 on: 18 May '18 - 17:36 »
Yes, try running the code under the debugger and check the callstack when the crash happens. If that doesn't show what call the crash happened in then try placing a breakpoint on the BASS_FX_TempoCreate call and then step over that call to confirm whether the crash is happening in it.

Ed1966

  • Posts: 68
Re: Mixer situation
« Reply #10 on: 20 May '18 - 06:34 »
Solved. I forgot to FREE the Mixer and Stream when shutdown project.
BASS_StreamFree(FStream) and FMixer := BASS_Mixer_StreamCreate(AFreq, AChans, BASS_UNICODE or BASS_STREAM_AUTOFREE);
It went well for a while but apparently due to more code the error became visible.

Regards,
Eduard.