OpenGL Library for Delphi,
maintained by Eric Grange,
based on Mike Lischke's GLScene.

 

Oldest known version of this page was edited on 2007-01-04 23:38:40 by DintHer []
Page view:

Tips - How to use 3D sounds with TGLSMBASS component


The existing sound demos in GLScene may give the impression that you always need to use a TGLSoundEmitter behavious attached to an object in order to get 3D sound implemented but there is a simpler way to use 3D sound. The code fragment below shows how you can create sounds samples and sound sources at run-time. The code below assumes GLSphere1 to be the source of the sound (origin) while the TGLSMBASS component on your form will define which glscene object the listener is. The BASS api will work out the 3D sound stage.


procedure TForm1.FormCreate(Sender: TObject);
var
  lSoundSample: TGLSoundSample;
  lSoundSource: TGLSoundSource;
begin
  lSoundSample := GLSoundLibrary1.Samples.Add;
  lSoundSample.LoadFromFile('C:\library\GLScene\Demos\media\drumloop.wav');
  lSoundSample.Name := 'test';

  lSoundSource := GLSMBASS1.Sources.Add;
  lSoundSource.Origin := GLSphere1;
  lSoundSource.Frequency := 22000;
  lSoundSource.NbLoops := 999;
  lSoundSource.SoundLibrary := GLSoundLibrary1;
  lSoundSource.SoundName := 'test';

  GLSMBASS1.Active := True;

end;
Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by Wikka Wakka Wiki 1.1.6.2
Page was generated in 0.0461 seconds