Recent

Author Topic: BASS DLL - song titles with umlauts and/or special characters [ä, ö, ü, ´ ....]  (Read 4308 times)

RAW

  • Hero Member
  • *****
  • Posts: 871
1. Use normal Strings and use {$MODE DelphiUnicode} with or without {$Define UNICODE}.
2. Use normal Strings and use {$MODE OBJFPC}{$H+}{$J-} and {$ModeSwitch UnicodeStrings} with or without {$Define UNICODE}.
3. Use the following example... (I only checked if I can play umlauts not real unicode characters, but these should work too).

Code: Pascal  [Select][+][-]
  1. Unit uLittleBass;
  2.  {$MODE OBJFPC}{$J-}

Code: Pascal  [Select][+][-]
  1. Implementation
  2.  {$R *.LFM}
  3.  {$DEFINE UNICODE}


Callback
Code: Pascal  [Select][+][-]
  1. // CALLBACK
  2. Procedure BassCallback
  3. (hsHandle: HSync; dwChan, dwData: DWORD; ptrUser: Pointer); StdCall;
  4.  Begin
  5.   wndGUI.OnBassCallback;
  6.  End;
  7.  
  8. // ON CALLBACK
  9. Procedure TwndGUI.OnBassCallBack;
  10.  Begin
  11.   BASS_ChannelRemoveSync(hstChan, hsCallback);
  12.   BASS_StreamFree(hstChan);
  13.   PLAY;
  14.  End;


FormCreate
Code: Pascal  [Select][+][-]
  1. If Not BASS_Init(-1, 44100, 0, 0, Nil)
  2. Then ShowMessage('ERROR: BASS Initialization failed !');
  3. // put BASS.dll x64 or x86 inside main program directory
  4. // put BASS.pas inside main program directory
  5.  
  6. uslPL:= TUnicodeStrList.Create;

TLabel
Code: Pascal  [Select][+][-]
  1. labArtist.Caption:= UTF8Encode(uStr);
  2. labTitle.Caption := UTF8Encode(uStr);

PLAY (uslPL : TUnicodeStrList)
Code: Pascal  [Select][+][-]
  1. hstChan:= BASS_StreamCreateFile
  2. (False, PChar(uslPL[iCurrSong]), 0, 0, 0
  3. {$IFDEF UNICODE} or BASS_UNICODE {$ENDIF});
  4.  
  5. hsCallback:= BASS_ChannelSetSync
  6. (hstChan, BASS_SYNC_END, 0, @BassCallback, Nil);
  7.  
  8. ShowTitle(uslPL[iCurrSong]);


Load uslPL (PlayList)
Code: Pascal  [Select][+][-]
  1. uslPL.AddNotIn(UnicodeString(dlgOpen.Files[i]));


UnicodeStringlist // or use a TList with UnicodeStrings...
Code: Pascal  [Select][+][-]
  1. UNIT uUnicodeStrList; // originally by Jordan Russell
  2. {$MODE OBJFPC}{$J-}
  3. Interface
  4.  
  5.  TYPE
  6.   PArrStrList = ^TArrStrList;
  7.   TArrStrList = Array[0..50] Of UnicodeString;
  8.  
  9.   TUnicodeStrList = Class
  10.    PRIVATE
  11.     arrList: PArrStrList;
  12.     iCount, iCapacity: Integer;
  13.  
  14.     Function  GetStr      (iIndex: Integer): UnicodeString;
  15.     Procedure SetCapacity (iNewCapacity: Integer);
  16.  
  17.    PUBLIC
  18.     Destructor Destroy; Override;
  19.  
  20.     Procedure Add      (Const uStr: UnicodeString);
  21.     Procedure AddNotIn (Const uStr: UnicodeString);
  22.     Function  IndexOf  (Const uStr: UnicodeString): Integer;
  23.     Procedure Clear;
  24.  
  25.     Property Count: Integer Read iCount;
  26.     Property Items[iIndex: Integer]: UnicodeString Read GetStr; Default;
  27.   End;
  28.  
  29. Implementation
  30.  
  31.  
  32. Procedure TUnicodeStrList.Add(Const uStr: UnicodeString);
  33.  Begin
  34.   If iCount = iCapacity
  35.   Then SetCapacity(iCapacity+8);
  36.  
  37.   arrList^[iCount]:= uStr;
  38.   Inc(iCount);
  39.  End;
  40.  
  41.  
  42. Procedure TUnicodeStrList.AddNotIn(Const uStr: UnicodeString);
  43.  Begin
  44.   If IndexOf(uStr) = -1
  45.   Then Add(uStr);
  46.  End;
  47.  
  48.  
  49. Procedure TUnicodeStrList.SetCapacity(iNewCapacity: Integer);
  50.  Begin
  51.   ReAllocMem(arrList, iNewCapacity*SizeOf(Pointer));
  52.  
  53.   If iNewCapacity > iCapacity
  54.   Then FillChar(arrList^[iCapacity],
  55.         (iNewCapacity-iCapacity)*SizeOf(Pointer), 0);
  56.  
  57.   iCapacity:= iNewCapacity;
  58.  End;
  59.  
  60.  
  61. Procedure TUnicodeStrList.Clear;
  62.  Begin
  63.   If iCount <> 0
  64.   Then Finalize(arrList^[0], iCount);
  65.  
  66.   iCount:= 0;
  67.   SetCapacity(0);
  68.  End;
  69.  
  70.  
  71. Function TUnicodeStrList.GetStr(iIndex: Integer): UnicodeString;
  72.  Begin
  73.   Result:= arrList^[iIndex];
  74.  End;
  75.  
  76.  
  77. Function TUnicodeStrList.IndexOf(Const uStr: UnicodeString): Integer;
  78. // Case sensitive !
  79.   Var
  80.    i: Integer;
  81.  Begin
  82.   Result:= -1;
  83.  
  84.   For i:= 0 To iCount-1
  85.   Do
  86.    Begin
  87.     If arrList^[i] = uStr
  88.     Then
  89.      Begin
  90.       Result:= i;
  91.       Break;
  92.      End;
  93.    End;
  94.  End;
  95.  
  96.  
  97. Destructor TUnicodeStrList.Destroy;
  98.  Begin
  99.   Clear;
  100.   Inherited Destroy;
  101.  End;
  102.  
  103. END.
« Last Edit: July 12, 2019, 06:34:13 am by RAW »

 

TinyPortal © 2005-2018