Author Topic: BASS_SetDevice / BASS_STREAM_DECODE / BASS_Mixer_StreamAddChannel  (Read 678 times)

Ed1966

  • Posts: 99
Hello :)

I use mixer and want to add channel with different output device. Don't work.

Code: [Select]
{ Main start }
Result := TAudioTool17.LoadAudioSongEffect(
    AEffectFilename,
    AEffectHandle,
    SoundDriverToIndex(OutputDeviceEffect), // Correct
    SetEffectVolume,
    AFlags
);

class function TAudioTool17.LoadAudioSongEffect(AMusicFile: string; var AStream: HSTREAM;
  ADevice: DWORD; AVolume: FLOAT; AFlags: DWORD): Boolean;
begin
  Result := TAudioTool17.StreamCreateFileExt(AStream, AMusicFile, ADevice, AVolume, AFlags);
  if (Result) then begin
//    Result := BASS_SetDevice(ADevice); // No way!
//    DisplayError('BASS_ChannelSetDevice', BASS_ErrorGetCode);
    Result := BroadcastMixer17.MixerStreamAddChannel(AStream); // Add Stream.
  end;
end;

class function TAudioTool17.StreamCreateFileExt(var AStream: HSTREAM; const AInputFile: string;
  ADevice: DWORD; AVolume: FLOAT; AExtFlags: DWORD): Boolean;
begin
  BASS_StreamFree(AStream); // Free
  BASS_SetDevice(ADevice); // Here???
  AStream := BASS_StreamCreateFile(False, PChar(AInputFile), 0, 0, BASS_STREAM_DECODE or BASS_UNICODE or AExtFlags);
  //DisplayError('BASS_StreamCreateFile', BASS_ErrorGetCode);
  Result := (AStream <> 0) and (BASS_ErrorGetCode = 0);
  if (Result) then begin
    BASS_ChannelSetAttribute(AStream, BASS_ATTRIB_VOL, AVolume); // Volume hoogste
    BASS_ChannelSetPosition(AStream, 0, BASS_POS_BYTE); // Begin bij start
  end;
end;

function TBassMixerAudio.MixerStreamAddChannel(AStream: HSTREAM): Boolean;
var
  Flags: DWORD;
begin
  BASS_Mixer_ChannelRemove(AStream);
  Flags := BASS_MIXER_BUFFER or BASS_MIXER_NORAMPIN or BASS_MIXER_PAUSE;
  Result := BASS_Mixer_StreamAddChannel(FMixer, AStream, Flags);
  if (Result) then  begin
    Result := BASS_Mixer_ChannelSetPosition(AStream, 0, BASS_POS_BYTE);
  end;
end;


Why this not work?
Thank you.

Regards,
Eduard.

Ian @ un4seen

  • Administrator
  • Posts: 21329
Do you want to change the device that the mixer is outputting on? If so, you can use BASS_ChannelSetDevice on the mixer handle to do that. Make sure the new device has been initialized first via BASS_Init.

Ed1966

  • Posts: 99
Thanks.

There is only one device for every mixer possible?
I use three decoded channels in this mixer so it's not possible output to three separate devices?

Just a question and then I can go on.

Regards,
Eduard.


Ian @ un4seen

  • Administrator
  • Posts: 21329
A mixer has a single output, containing a mix of its sources. If you want to have multiple different outputs, then you will need multiple mixers, or you could just play the sources directly (without a mixer). Are you sure you need a mixer? If not, you can remove the BASS_STREAM_DECODE flag from the sources and call BASS_ChannelPlay on them.

Ed1966

  • Posts: 99
I understand. Thank you.  :)

Ed1966

  • Posts: 99
I found some bass.dll shutdown error. When I am call BASS_Free.
That's my mistake but I don't know why it happens.
Error:
exception number   : 1
exception class    : EAccessViolation
exception message  : Access violation at address 70A8CC6E in module 'bass.dll'. Read of address 70A670E0.
Address can be different.   

Let me explain.

Create Mixer and add some DECODED channels. But (i know my fault) first i use BASS_SetChannel to Soundcard #2 (Device #2 in this situation) and add the Stream.
When I play this DECODED stream no problem. But when I shutdown the application you get above error.
If I use default (Device #1) Soundcard no error when shutdown. 

Maybe you can see why?
Note that this is not happening any more because I remove BASS_SetChannel for DECODED channel.
And now use BASS_ChannelSetDevice on mixer and that works fine.

It's only to inform that there is something wrong. If you make mistake.

Regards
Eduard.








Ian @ un4seen

  • Administrator
  • Posts: 21329
Are you using the latest BASS release? If not, please first try that. If you still get the crash with that, please upload a dump file for it. You can generate a dump file using the ProcDump tool. For example, run "procdump -e -ma -x . your.exe". Then ZIP and upload the generated dump file to have a look at here:

   ftp.un4seen.com/incoming/

Ed1966

  • Posts: 99
I don't get a DUMP file. Only this.

Process:               SuperBASSMixer.exe (2012)
CPU threshold:         n/a
Performance counter:   n/a
Commit threshold:      n/a
Threshold seconds:     n/a
Hung window check:     Disabled
Log debug strings:     Disabled
Exception monitor:     Unhandled
Exception filter:      [Includes]
                       *
                       [Excludes]
Terminate monitor:     Disabled
Cloning type:          Disabled
Concurrent limit:      n/a
Avoid outage:          n/a
Number of dumps:       1
Dump folder:           .\
Dump filename/mask:    PROCESSNAME_YYMMDD_HHMMSS
Queue to WER:          Disabled
Kill after dump:       Disabled

Press Ctrl-C to end monitoring without terminating the process.

[10:41:58] Exception: C0000005.ACCESS_VIOLATION
[10:42:00] Exception: 0000071A
[10:42:00] The process has exited.
[10:42:00] Dump count not reached.

Ian @ un4seen

  • Administrator
  • Posts: 21329
That's strange. Is it a .Net program? If so, you could try adding "-g" to the procdump command-line.

Ed1966

  • Posts: 99
It's a Windows program.

Chris

  • Posts: 1860
hello
, the code looks like Delphi which Version?
Are you in Debug mode or in Release Mode?
Chris

Ed1966

  • Posts: 99
XE8 Delphi.
I eliminate FastMM4 and al debuggers. And build.
Check now and in Release mode.

Ed1966

  • Posts: 99
Please close topic for now.
I will try to reproduce error in small example.  :o