Author Topic: How to initialize a device from the listbox?  (Read 329 times)

Vitaliy

  • Guest
Code: [Select]
d:=ListBox3.ItemIndex;
 BASS_SetDevice(d);

if bass_init(1, 44100, 0, handle, nil)=false then

Don't work, device does not switch.

Code: [Select]
d:=ListBox3.ItemIndex;
 BASS_SetDevice(d);

if bass_init(-1, 44100, 0, handle, nil)=false then

Don't work, device does not switch.

Code: [Select]
d:=ListBox3.ItemIndex;
 

if bass_init(-1, 44100, 0, handle, nil)=false then...
...
BASS_SetDevice(d);

Don't work, device does not switch.

Code: [Select]
BASS_SetDevice(1); //or (2); or (3); or (4); etc.

if bass_init(1, 44100, 0, handle, nil)=false then

Don't work, device does not switch.

Wishmaster

  • Posts: 162
Re: How to initialize a device from the listbox?
« Reply #1 on: 9 Dec '17 - 19:14 »
first you have to initialize existing device(s). before you can use BASS_SetDevice()
I just posted an Delphi code

Code: [Select]
function Bass_Init_AllDevices(Freq : Cardinal = 44100) : Boolean;
var
 DevInfo : BASS_DEVICEINFO;
 Device : Integer;
 Flag : Cardinal;
begin
  Result:= False;

 (* Free all Devices *)
   Device:= 0;
  while (BASS_GetDeviceInfo(Device, DevInfo) <> False) do
   begin
    if BASS_SetDevice(Device) then
     begin
      BASS_Free();
     end;
    Inc(Device);
   end;


 (* Init Devices *)
   Flag:= 0; // BASS_DEVICE_LATENCY

   Device:= 0;
  while (BASS_GetDeviceInfo(Device, DevInfo) <> False) do
   begin
    if not BASS_Init(Device, Freq, Flag, AppHWND, nil) then
     begin

     end;

    Inc(Device);
   end;


 Result:= True;
end;


//device The device to use... 0 = no sound, 1 = first real output device. 
BASS_SetDevice(device : DWORD);






or


Code: [Select]

function Bass_Init_Device(Device : Integer; Freq : Cardinal; CalLatency : Boolean) : Boolean;
var
 Flag : Cardinal;
begin
  Result:= False;

 (* Free Device *)
 if BASS_SetDevice(Device) then
  BASS_Free();

  Flag:= 0;
 if CalLatency then
  Flag:= Flag or BASS_DEVICE_LATENCY;

  Result:= BASS_Init(Device, Freq, Flag, AppHWND, Nil);
 if not Result then
  begin
   // Error
  end;

end;






check error messages

Error codes
BASS_ERROR_DEVICE device is invalid. 
BASS_ERROR_INIT The device has not been initialized. 


« Last Edit: 9 Dec '17 - 19:22 by Wishmaster »

Vitaliy

  • Guest
Re: How to initialize a device from the listbox?
« Reply #2 on: 19 Dec '17 - 06:46 »
Thank you very much, the code works. Could you write the same code for BASS_ASIO_INIT and BASS_ASIO_SetDevice. Please  :)

Wishmaster

  • Posts: 162
Re: How to initialize a device from the listbox?
« Reply #3 on: 21 Dec '17 - 01:55 »
I do't quite understand what the problem is
although I had nothing to do with BASSASIO, not yet anyway. but when I look at the functions in the BASSASIO documentation
they look just like the ones from the bass.dll documentation.

did you try to write it your self? What exactly is the problem?

Vitaliy

  • Posts: 20
Re: How to initialize a device from the listbox?
« Reply #4 on: 21 Dec '17 - 06:23 »
already wrote. Thank you