Author Topic: Don't work 'BASS_GetDeviceInfo' 64bit  (Read 147 times)

Vitaliy

  • Guest
Don't work 'BASS_GetDeviceInfo' 64bit
« on: 8 Dec '17 - 16:12 »
Hello. Don't work 'BASS_GetDeviceInfo' in Lazarus 64bit:
Code: [Select]
implementation

{$R *.lfm}

{ TForm5 }
 procedure TForm5.FormCreate(Sender: TObject);
 var
  i: Integer;
  ADeviceInfo: BASS_DEVICEINFO;

 begin
   Device1:=Booltostr(BASS_GetDeviceInfo(1,ADeviceInfo));
i := 1;
while BASS_GetDeviceInfo(i, ADeviceInfo) do
begin
ListBox3.Items.Add(ADeviceInfo.name);
i := i + 1;

end;
 
   end;

procedure TForm5.Button1Click(Sender: TObject);
begin
  Form5.Close;
end;

procedure TForm5.Button2Click(Sender: TObject);
begin
showmessage(Device1);
end;

end.
Listbox is empty, 'showmessage' too.
Why does not it work?

Ian @ un4seen

  • Administrator
  • Posts: 20499
Re: Don't work 'BASS_GetDeviceInfo' 64bit
« Reply #1 on: 8 Dec '17 - 17:40 »
I'm not a Lazarus user myself, but I guess it may be using Unicode strings by default? If so, you will probably need to convert the "ADeviceInfo.name" string, perhaps something like this:

Code: [Select]
ListBox3.Items.Add(String(AnsiString(ADeviceInfo.name)));

Vitaliy

  • Guest
Re: Don't work 'BASS_GetDeviceInfo' 64bit
« Reply #2 on: 8 Dec '17 - 18:56 »
Don't work.

Vitaliy

  • Guest
Re: Don't work 'BASS_GetDeviceInfo' 64bit
« Reply #3 on: 8 Dec '17 - 19:13 »
Code: [Select]
showmessage(booltostr(Device1));return '0'

Vitaliy

  • Guest
Re: Don't work 'BASS_GetDeviceInfo' 64bit
« Reply #4 on: 8 Dec '17 - 19:25 »
how to apply?
"BASS_SetConfig(BASS_CONFIG_UNICODE,BOOL unicode);"

Vitaliy

  • Guest
Re: Don't work 'BASS_GetDeviceInfo' 64bit
« Reply #5 on: 8 Dec '17 - 20:30 »
Code: [Select]
BASS_SetConfig(BASS_CONFIG_UNICODE,1);
    ListBox3.Items.Add(Pchar(UTF8ToUTF16(ADeviceInfo.name)));
    i := i + 1;

Do not work. :_(

Vitaliy

  • Guest
Re: Don't work 'BASS_GetDeviceInfo' 64bit
« Reply #6 on: 8 Dec '17 - 21:16 »
Windows language is russia. maybe it matters.

Chris

  • Posts: 1814
Re: Don't work 'BASS_GetDeviceInfo' 64bit
« Reply #7 on: 8 Dec '17 - 21:42 »
the BASS_DEVICEINFO.name is a PAnsiChar
so the correct call should be looks like

Code: [Select]
i := 1;
while BASS_GetDeviceInfo(i, ADeviceInfo) do
begin
  ListBox3.Items.Add(string(ADeviceInfo.name));
  inc(i);
end;

if ( ListBox3.Items.count = 0) {looks like something wrong} then
ShowMessage(Inttostr(Bass_ErrorGetCode));
// you can find in the Bass Delphi header the Numeric Codes for the Error(s)
« Last Edit: 8 Dec '17 - 21:53 by Chris »

Vitaliy

  • Guest
Re: Don't work 'BASS_GetDeviceInfo' 64bit
« Reply #8 on: 8 Dec '17 - 22:13 »
the BASS_DEVICEINFO.name is a PAnsiChar
so the correct call should be looks like

Code: [Select]
i := 1;
while BASS_GetDeviceInfo(i, ADeviceInfo) do
begin
  ListBox3.Items.Add(string(ADeviceInfo.name));
  inc(i);
end;
This code is work, thank you. But cyrilic symbols looks like "??????".

Vitaliy

  • Guest
Re: Don't work 'BASS_GetDeviceInfo' 64bit
« Reply #9 on: 9 Dec '17 - 01:15 »
And I do not understand how to initialize a device from the listbox.

Vitaliy

  • Guest
Re: Don't work 'BASS_GetDeviceInfo' 64bit
« Reply #10 on: 9 Dec '17 - 01:32 »
Code: [Select]
d:=ListBox3.ItemIndex;
 BASS_SetDevice(d);

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



When I run the program shows an error:  "Access violation".
And if
Code: [Select]
bass_init(-1,.. then 
Code: [Select]
BASS_SetDevice(d); is not work, BASS_SetDevice(0)=(1)=(2)=(3) - no difference.

Chris

  • Posts: 1814
Re: Don't work 'BASS_GetDeviceInfo' 64bit
« Reply #11 on: 10 Dec '17 - 17:12 »
somethink like that
Code: [Select]
procedure TForm1.FormCreate(Sender: TObject);
var
 Dev:integer;
 ADeviceInfo:Bass_DeviceInfo;
begin
  dev:=1;
   while (BASS_GetDeviceInfo(dev, ADeviceInfo)<> false) do
   begin
     ListBox1.Items.Add(string(ADeviceInfo.name));
     inc(Dev);
     Bass_init(Dev, 44100, 0, handle, Nil);
    end;
end;


about the listbox stuff

Code: [Select]
  if Not Bass_SetDevice(ListBox3.ItemIndex+1)then
     ShowMessage(Inttostr(Bass_ErrorGetCode));
// the first index in a listbox is allways 0 so it must then (ListBox3.ItemIndex+1)
//1 is first real output device
about your cryllic symbols
read that
http://wiki.freepascal.org/Unicode_Support_in_Lazarus#What_about_ModeSwitch_UnicodeStrings.3FF   

i did a quick test in Lazarus 1.8.0/FPC 3.0.4. will showing correct the device names
« Last Edit: 11 Dec '17 - 12:03 by Chris »