BASS library, with UNICODE enabled

Share your advanced PureBasic knowledge/code with the community.
Perkin
Enthusiast
Enthusiast
Posts: 504
Joined: Thu Jul 03, 2008 10:13 pm
Location: Kent, UK

BASS library, with UNICODE enabled

Post by Perkin »

I've been using BASS library to play songs etc, but needed to enable Unicode strings, but doing so caused the BASS lib to not play anything because of the filenames were expected to be in Ascii. I couldn't find a simple command to do it, so here's a quick solution.
(Somebody will now tell me it's easier than this :) )

Code: Select all

Global *BASS_Filename

Procedure SetBASSFilename(filename.s)
  If *BASS_Filename
    FreeMemory (*BASS_Filename)
  EndIf
  *BASS_FILENAME=AllocateMemory(Len(filename)+1)
  PokeS(*BASS_FILENAME,filename,-1,#PB_Ascii)
EndProcedure
Then when needed before creating the stream channel.

Code: Select all

  SetBASSFilename(songname)
  Handle = BASS_StreamCreateFile(0, *BASS_Filename, 0, 0, 0)

You could also use this for any strings that need to be in Ascii.
%101010 = $2A = 42