Author Topic: BASS Delphi units and Delphi 2009  (Read 12344 times)

3delite

  • Posts: 932
BASS Delphi units and Delphi 2009
« on: 8 Jan '09 - 23:47 »
Hi!

Ian, please update the Delphi .pas files everywhere PChar to PANSIChar where ansi string is returned for compatiblity with Delphi 2009, and only keep PChar where the BASS_UNICODE flag can be present.

Thanx!

Can I ask when is BASS 2.5 scheduled for release?

Regards
3delite

JM-DG

  • Posts: 112
Re: BASS Delphi units and Delphi 2009
« Reply #1 on: 9 Jan '09 - 02:35 »
What about the guys who still use delphi 7 ?? :-\
Like me... :) ???
Edit : Will this changes cause problems??

3delite

  • Posts: 932
Re: BASS Delphi units and Delphi 2009
« Reply #2 on: 9 Jan '09 - 10:04 »
No! :)

Everybody should have used PANSIChar in the first place (I didn't too in my projects).
It will work with Delphi 7 and Delphi 2009 too, that way.

Regards
3delite

Ian @ un4seen

  • Administrator
  • Posts: 21358
Re: BASS Delphi units and Delphi 2009
« Reply #3 on: 9 Jan '09 - 16:30 »
Ian, please update the Delphi .pas files everywhere PChar to PANSIChar where ansi string is returned for compatiblity with Delphi 2009, and only keep PChar where the BASS_UNICODE flag can be present.

Some of them are already updated (as new versions were released), but I'm still not entirely sure what to do with the parameters that can take either Ansi or Unicode strings (with the BASS_UNICODE flag). Will Delphi 2009 automatically convert a Unicode string to Ansi for a "PAnsiChar" parameter? And if so, can that conversion be overridden in case the user wants to use the BASS_UNICODE flag? If the answer is yes, maybe that would be the safest solution, as existing code should still work (without having to add BASS_UNICODE flags) when switching to Delphi 2009 then?

Can I ask when is BASS 2.5 scheduled for release?

There isn't really any schedule for it yet. It's still at the ideas gathering phase :)

Xire

  • Posts: 279
Re: BASS Delphi units and Delphi 2009
« Reply #4 on: 9 Jan '09 - 18:20 »
In D2009 everything works fine with PAnsiChar (with and w/o UNICODE flag).

JM-DG

  • Posts: 112
Re: BASS Delphi units and Delphi 2009
« Reply #5 on: 9 Jan '09 - 21:30 »
Thank you for the info 3Delite!! :)
Cheers! ;)

3delite

  • Posts: 932
Re: BASS Delphi units and Delphi 2009
« Reply #6 on: 10 Jan '09 - 12:08 »
s
Some of them are already updated (as new versions were released), but I'm still not entirely sure what to do with the parameters that can take either Ansi or Unicode strings (with the BASS_UNICODE flag). Will Delphi 2009 automatically convert a Unicode string to Ansi for a "PAnsiChar" parameter? And if so, can that conversion be overridden in case the user wants to use the BASS_UNICODE flag? If the answer is yes, maybe that would be the safest solution, as existing code should still work (without having to add BASS_UNICODE flags) when switching to Delphi 2009 then?

If it takes ansi or unicode use PChar. If it takes only ansi use PAnsiChar.

I would do as the following: For example:
BASS_CD_GetInfo() structure returns ansi strings. So the structure should be changed to explicit ansi string:

Code: [Select]
type
  BASS_CD_INFO = record
    vendor: PANSIChar;      // manufacturer
    product: PANSIChar;     // model
    rev: PANSIChar;         // revision
    letter: Integer;    // drive letter
rwflags: DWORD;     // read/write capability flags
canopen: BOOL;      // BASS_CD_DOOR_OPEN/CLOSE is supported?
canlock: BOOL;      // BASS_CD_DOOR_LOCK/UNLOCK is supported?
maxspeed: DWORD;    // max read speed (KB/s)
cache: DWORD;       // cache size (KB)
cdtext: BOOL;       // can read CD-TEXT
  end;

BASS_StreamCreateFile() can accept a unicode string, that is have a BASS_UNICODE flag. This should stay as it is that is: PChar.

This way it will work seamlesly with Delphi 7 and Delphi 2009 too.

Users who use Delphi 2009 should always use BASS_UNICODE flag (it will then be more compatible, the (international) users can specify unicode file names).

And one more thing. If a function accepts or return only unicode string, then it should be PWideChar (this will also work ok with Delphi 7 and Delphi 2009).

Thank you for the info on BASS 2.5, I am updating my project to unicode so I think I won't wait for a new BASS version for the relaese.

Regards
3delite
« Last Edit: 10 Jan '09 - 12:14 by 3delite »

Ian @ un4seen

  • Administrator
  • Posts: 21358
Re: BASS Delphi units and Delphi 2009
« Reply #7 on: 11 Jan '09 - 14:23 »
Yep, the structure members should certainly be updated; it was just the function parameters that allow both Ansi and Unicode that I wasn't sure about. I guess what I'll do is leave the parameters that can take Unicode as "PChar", as you suggest, and add a note for Delphi 2009 users to use the BASS_UNICODE flag in those cases.

Please let me know if/how the Delphi examples need updating too :)

3delite

  • Posts: 932
Re: BASS Delphi units and Delphi 2009
« Reply #8 on: 11 Jan '09 - 17:18 »
Ok! Thanx!

Regards
3delite

Ian @ un4seen

  • Administrator
  • Posts: 21358
Re: BASS Delphi units and Delphi 2009
« Reply #9 on: 12 Jan '09 - 14:22 »
I think all of the affected Delphi APIs are updated now (updated packages are on the BASS page). Please let me know if there are still any problems. In particular, I wasn't entirely sure what to do with the dynamic API's Load_BASSDLL function. I guess the examples may also need updating to support Delphi 2009?

3delite

  • Posts: 932
Re: BASS Delphi units and Delphi 2009
« Reply #10 on: 12 Jan '09 - 15:36 »
I report here if find something wrong, for a quick test I'd suggest the following:

BASS_CHANNELINFO filename should be PChar:

Code: [Select]
  // Channel info structure
  BASS_CHANNELINFO = record
    freq: DWORD;        // default playback rate
    chans: DWORD;       // channels
    flags: DWORD;       // BASS_SAMPLE/STREAM/MUSIC/SPEAKER flags
    ctype: DWORD;       // type of channel
    origres: DWORD;     // original resolution
    plugin: HPLUGIN;    // plugin
    sample: HSAMPLE;    // sample
    filename: PChar; // filename
  end;

And bass_dynamic.pas's load routine (does not compile the old way with Delphi 2009) should be:

Code: [Select]
Function Load_BASSDLL (const dllfilename:string) :boolean;
const szBassDll = 'bass.dll' + #0;
var
  oldmode:integer;
  P: PChar;
  s: string;
  dllfile: array[0..MAX_PATH + 1] of Char;
begin
  Result := False;
  if BASS_Handle<>0 then result:=true {is it already there ?}
  else begin {go & load the dll}
    s := dllfilename;
    if Length(s) = 0 then begin
      P := nil;
      if SearchPath(nil, PChar(szBassDll), nil, MAX_PATH, dllfile, P) > 0 then
        s := StrPas(dllfile)
      else exit;
      end;
    oldmode:=SetErrorMode($8001);
    s := s + #0;
    BASS_Handle:=LoadLibrary(PChar(s)); // obtain the handle we want
    SetErrorMode(oldmode);
    if BASS_Handle<>0 then
       begin {now we tie the functions to the VARs from above}
    ...

It works with both Delphi 7 and Delphi 2009 this way.

Regards
3delite
« Last Edit: 12 Jan '09 - 16:37 by 3delite »

Ian @ un4seen

  • Administrator
  • Posts: 21358
Re: BASS Delphi units and Delphi 2009
« Reply #11 on: 14 Jan '09 - 15:23 »
BASS_CHANNELINFO filename should be PChar:

That has now been changed, but note that URLs will still be Ansi (BASS_StreamCreateURL doesn't currently support the UNICODE flag).

And bass_dynamic.pas's load routine (does not compile the old way with Delphi 2009) should be:

Should the GetProcAddress calls use "PChar" too?

3delite

  • Posts: 932
Re: BASS Delphi units and Delphi 2009
« Reply #12 on: 14 Jan '09 - 18:04 »
Ok. But the programmers will have to change it to PWideChar if they use it for file streams or they get a single character only.

Yes the GetProcAddress calls are good.

Regards
3delite

Ian @ un4seen

  • Administrator
  • Posts: 21358
Re: BASS Delphi units and Delphi 2009
« Reply #13 on: 14 Jan '09 - 18:49 »
Just to be sure, do you mean the GetProcAddress calls are fine as they are now (using "PAnsiChar"), or they would be fine with "PChar"? :)

3delite

  • Posts: 932
Re: BASS Delphi units and Delphi 2009
« Reply #14 on: 14 Jan '09 - 19:24 »
They are good with PAnsiChar, but it would be good with PChar too.  :)

Just tried to be sure and compiles ok, with both Delphi 7 and 2009.

Regards
3delite

Math

  • Posts: 17
Re: BASS Delphi units and Delphi 2009
« Reply #15 on: 21 Jun '09 - 05:15 »
...and add a note for Delphi 2009 users to use the BASS_UNICODE flag in those cases.

Hello Ian
i'm a bit confused. What does that mean exactly? "Where" and "how" do i have to set this flag?

ex.: to get started i compiled the BassTest example with Delphi 2009. If executing the program e.g. "Adding" a MOD-File is causing an error (code 2) while loading the music. Maybe theres also something with the Unicode-Thing ?

regards
Martin

3delite

  • Posts: 932
Re: BASS Delphi units and Delphi 2009
« Reply #16 on: 21 Jun '09 - 11:42 »
You have to add the BASS_UNICODE flag for the stream creation functions, like:

Code: [Select]
mods[modc] := BASS_MusicLoad(False, f, 0, 0, BASS_MUSIC_RAMP OR BASS_UNICODE, 0);

also for streams, and it should work.

Regards
3delite

Math

  • Posts: 17
Re: BASS Delphi units and Delphi 2009
« Reply #17 on: 21 Jun '09 - 14:55 »
THANKS !

regards and greetings from Munich/Germany
Martin

Math

  • Posts: 17
Re: BASS Delphi units and Delphi 2009
« Reply #18 on: 22 Jun '09 - 04:52 »
Hmm there must be something else.

I've tried this with the BassTest example (added "OR BASS_UNICODE" to the flag, and also "tried" using PAnsiChar instead of PChar )
-> loading of the Music/Sample now is fine w/o errors, BUT
-> the music/samples do not play.....just silence

is there anything else that needs to be changed on the BassTest example-code?

regards
Martin



Math

  • Posts: 17
Re: BASS Delphi units and Delphi 2009
« Reply #19 on: 26 Jun '09 - 08:33 »
Please ignore my last question, "the error sometimes seats in front of the computer" ;)

reason: i forgot to "select the Sample in the Listbox" which was already
so the procedure to play was exitted before BASS_ChannelPlay Routine was called

everything's working fine now

Thanks again
Martin