home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 November / CDVD1105.ISO / Software / Freeware / programare / bass / Delphi / 3dTest / D3Test.dpr next >
Encoding:
Text File  |  2005-09-14  |  2.3 KB  |  87 lines

  1. {
  2. BASS 3D Test, copyright (c) 1999-2004 Ian Luck.
  3. ===============================================
  4. Other source: DTMain.pas, DTMain.dfm, DTSelect.pas, DTSelect.dfm
  5. Delphi version by Titus Miloi (titus.a.m@t-online.de)
  6. }
  7. program D3Test;
  8.  
  9. uses
  10.   Windows,
  11.   Forms,
  12.   SysUtils,
  13.   DTMain in 'DTMain.pas' {Form1},
  14.   DTSelect in 'DTSelect.pas' {Form2},
  15.   Bass in '..\Bass.pas';
  16.  
  17. var
  18.   device: Integer;
  19.   c: Integer;
  20.   str: string;
  21.   name: PChar;
  22.   eaxon: Boolean;
  23.   env : Cardinal;
  24.   vol, decay, dump : Single;
  25. begin
  26.   // initialize application
  27.   Application.Initialize;
  28.   Application.Title := 'BASS - 3D Test';
  29.  
  30.   // Check that BASS 2.2 was loaded
  31.   if (BASS_GetVersion <> DWORD(MAKELONG(2,2))) then
  32.   begin
  33.     MessageBox(0, 'BASS version 2.2 was not loaded', 'Incorrect BASS.DLL', 0);
  34.     Halt;
  35.   end;
  36.  
  37.   Application.CreateForm(TForm1, Form1);
  38.   Form1.Visible := True;
  39.   // create device selector form
  40.   eaxon := FALSE;
  41.   Form2 := TForm2.Create(Application);
  42.   c := 0;
  43.   while (BASS_GetDeviceDescription(c) <> nil) do
  44.   begin
  45.     name := BASS_GetDeviceDescription(c);
  46.     str := name;
  47.     // Check if the device supports 3D
  48.     if BASS_Init(c, 44100, BASS_DEVICE_3D, Application.handle, nil) then
  49.     begin
  50.       if BASS_GetEAXParameters(env,vol, decay, dump) then
  51.       begin
  52.         str := str + ' [EAX]'; // it has EAX
  53.       end;
  54.       Form2.ListBox1.Items.Add(str);
  55.       Form2.lstDevices.Add(IntToStr(c));
  56.       BASS_Free;
  57.     end;
  58.     c := c + 1;
  59.   end;
  60.   Form2.ListBox1.ItemIndex := 0;
  61.   Form2.ShowModal;
  62.   device := StrToInt(Form2.lstDevices[Form2.ListBox1.ItemIndex]);
  63.   Form2.Free;
  64.   // Initialize the output device with 3D
  65.   if not BASS_Init(device, 44100, BASS_DEVICE_3D, Application.handle, nil) then
  66.   begin
  67.     MessageBox(0, 'Can''t initialize output device', 'Error', 0);
  68.     Halt;
  69.   end;
  70.   // Use meters as distance unit, real world rolloff, real doppler effect
  71.   BASS_Set3DFactors(1.0, 1.0, 1.0);
  72.   // Turn EAX off (volume=0.0), if error then EAX is not supported
  73.   if BASS_SetEAXParameters(-1, 0.0, -1.0, -1.0) then
  74.     eaxon := TRUE;
  75.  
  76.   // create and start the main application form
  77.   with Form1 do
  78.   begin
  79.     ComboBox1.Enabled := eaxon;
  80.     ComboBox1.ItemIndex := 0;
  81.   end;
  82.   Application.Run;
  83.  
  84.   BASS_Free;
  85. end.
  86.  
  87.