home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / Xenon / ModBass / Delphi / 3dTest / D3Test.dpr < prev    next >
Encoding:
Text File  |  2000-02-24  |  2.6 KB  |  97 lines

  1. {
  2. BASS 3D Test, copyright (c) 1999-2000 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, Forms, BASS,
  11.   DTMain in 'DTMain.pas' {Form1},
  12.   DTSelect in 'DTSelect.pas' {Form2};
  13.  
  14. {$R *.RES}
  15.  
  16. var
  17.   quality, device: Integer;
  18.   c: Integer;
  19.   str: string;
  20.   name: PChar;
  21.   a3dabs, eaxon: Boolean;
  22.  
  23. begin
  24.   // initialize application
  25.   Application.Initialize;
  26.   Application.Title := 'BASS - 3D Test';
  27.  
  28.   // create device selector form
  29.   a3dabs := FALSE;
  30.   eaxon := FALSE;
  31.   Form2 := TForm2.Create(Application);
  32.   c := 0;
  33.   while BASS_GetDeviceDescription(c, name) do
  34.   begin
  35.     str := name;
  36.     // Check if the device supports A3D or EAX
  37.     if BASS_Init(c, 44100, BASS_DEVICE_A3D, Application.handle) then
  38.       str := str + ' [A3D]' // it has A3D
  39.     else if not BASS_Init(c, 44100, BASS_DEVICE_3D, Application.handle) then
  40.       str := str + ' [EAX]'; // it has EAX
  41.     BASS_Free;
  42.     Form2.ListBox1.Items.Add(str);
  43.     c := c + 1;
  44.   end;
  45.   Form2.ListBox1.ItemIndex := 0;
  46.   Form2.ShowModal;
  47.   if Form2.CheckBox1.Checked then
  48.     quality := 22050
  49.   else
  50.     quality := 44100;
  51.   device := Form2.ListBox1.ItemIndex;
  52.   Form2.Free;
  53.   // Check that BASS 0.8 was loaded
  54.   if (BASS_GetVersion <> MAKELONG(0,8)) then
  55.   begin
  56.     MessageBox(0, 'BASS version 0.8 was not loaded', 'Incorrect BASS.DLL', 0);
  57.     Halt;
  58.   end;
  59.   // Initialize the output device with A3D (syncs not used)
  60.   if not BASS_Init(device, quality, BASS_DEVICE_NOSYNC or BASS_DEVICE_A3D, Application.handle) then
  61.   begin
  62.     // no A3D, so try without...
  63.     if not BASS_Init(device, quality, BASS_DEVICE_NOSYNC or BASS_DEVICE_3D, Application.handle) then
  64.     begin
  65.       MessageBox(0, 'Can''t initialize output device', 'Error', 0);
  66.       Halt;
  67.     end;
  68.   end
  69.   else
  70.   begin
  71.     // enable A3D HF absorbtion option
  72.     BASS_SetA3DHFAbsorbtion(0.0);
  73.     a3dabs := TRUE;
  74.   end;
  75.   // Use meters as distance unit, real world rolloff, real doppler effect
  76.   BASS_Set3DFactors(1.0, 1.0, 1.0);
  77.   // Turn EAX off (volume=0.0), if error then EAX is not supported
  78.   if BASS_SetEAXParameters(-1, 0.0, -1.0, -1.0) then
  79.     eaxon := TRUE;
  80.   BASS_Start;    { Start digital output }
  81.  
  82.   // create and start the main application form
  83.   Application.CreateForm(TForm1, Form1);
  84.   with Form1 do
  85.   begin
  86.     CheckBox1.Enabled := a3dabs;
  87.     ScrollBar3.Enabled := a3dabs;
  88.     ComboBox1.Enabled := eaxon;
  89.     ComboBox1.ItemIndex := 0;
  90.   end;
  91.   Application.Run;
  92.  
  93.   BASS_Stop;
  94.   BASS_Free;
  95. end.
  96.  
  97.