Menu

OpenAL and Lazarus 2.0

Help
Daniel
2020-01-15
2020-01-31
  • Daniel

    Daniel - 2020-01-15

    Hi everyone!

    Has anyone been experiencing problems with Lazarus 2.0 and OpenAL?
    I have been getting crashes since I updated, but I havn't really figured out what is the cause yet.

    Cheers!

     
  • Daniel

    Daniel - 2020-01-29

    Hi again!

    I get the crash when I create two different sounds on two different emitters at the same time.
    Like this:

    with TGLBSoundEmitter.Create(maingunACube.Behaviours) do begin
            source.SoundLibrary:=SoundLib1;
            source.SoundName:='WaterSplash1SFX';
            source.MaxDistance := 100;
            source.ConeOutsideVolume := 0.5;
            Playing:=True;
            end;
    
           with TGLBSoundEmitter.Create(maingunBCube.Behaviours) do begin
            source.SoundLibrary:=SoundLib1;
            source.SoundName:='MainGuns1SFX';
            source.MaxDistance := 100;
            source.ConeOutsideVolume := 0.5;
            Playing:=True;
            end;
    

    What can I add in the code to prevent it from calling an error?

    Kind regards,
    Daniel

     
  • Jerome.D (BeanzMaster)

    Hi Daniel, i've take look quick (i said GLSMOpenAL is heavey buggy (in Delphi to) this unit need more rewriting. So in, change procedure TGLSMOpenAL.KillSource(aSource : TGLBaseSoundSource); by the following code

    procedure TGLSMOpenAL.KillSource(aSource : TGLBaseSoundSource);
    var
      i, currentBufferTag, bufferCount:integer;
    begin
      if aSource.ManagerTag<>0 then
      begin
        alSourceStop(ASource.ManagerTag);
        alDeleteSources(1, PALuint(@ASource.ManagerTag));
        ASource.ManagerTag:=0;
    
        // We can't just delete buffer, because other sources may be using it
        // so we count how many sources are using, then delete if it's the only one
        // using.
        // Same for ASource.Sample.ManagerTag, we set to zero once it's no longer
        // being used by any other sources
        if Assigned(ASource.Sample) then
        begin
          currentBufferTag:=ASource.Sample.ManagerTag;
          bufferCount:=0;
          if currentBufferTag<>0 then
          begin
            for i := 0 to Sources.Count - 1 do
            begin
              if Assigned(Sources[i]) then
                if Assigned(Sources[i].Sample) then if Sources[i].Sample.ManagerTag = currentBufferTag then
                begin
                  bufferCount:=bufferCount+1;
                end;
            end;
            if bufferCount>=1 then
            begin
              alDeleteBuffers(1, PALuint(@ASource.Sample.ManagerTag));
              ASource.Sample.ManagerTag := 0;
            end;
          end;
        end;
      end;
    end;             
    

    It's not a nice patch but it will do the job.

    For information i'm currently coding a new library partially based on GLScene , i hope i'll can make avaible soon as possible (max in two montth) But actually any 3D openGL available yet, it's in a "wip" in waiting, take look a those samples

    ONLY AND TOTALLY IN SOFTWARE RENDERING, NO OPENGL, NO DIRECTX, NO SDL, NO VULKAN ;)

    https://www.youtube.com/watch?v=1ytUbSiUvjk
    https://www.youtube.com/watch?v=NexLqs3Rie0
    https://www.youtube.com/watch?v=VZX4RmzpwTU
    https://www.youtube.com/watch?v=x7QYA2ZebPk
    https://www.youtube.com/watch?v=dU6iDJcLJUg (with a new sound engine based on OpenAL yeah !!! )

    Cheers

    See you soon

     
  • Daniel

    Daniel - 2020-01-29

    Thanks again! I will try it out!

    Yes, I know you are working on it Waiting eagerly to try it out.
    The 2D bumpmapping looks amazing!!

     
  • Daniel

    Daniel - 2020-01-29

    Sadly it did not work. I still get an exception:

     
  • Jerome.D (BeanzMaster)

    Hi Daniel

    Do you put GLSoundLibrary on form or do you create it at runtime ?
    Do you load sound in IDE or by code ?

    I've no exception with the 3DSoundOpenAl sample i've tested yesterday

     
  • Daniel

    Daniel - 2020-01-30

    What happens if you change the button1.click code to this:

    procedure TForm1.Button1Click(Sender: TObject);
    begin
       with TGLBSoundEmitter.Create(Sphere.Behaviours) do begin
          Source.SoundLibrary:=GLSoundLibrary;
          Source.SoundName:='chimes.wav';
          Playing:=True;
       end;
       with TGLBSoundEmitter.Create(mickey.Behaviours) do begin
          Source.SoundLibrary:=GLSoundLibrary;
          Source.SoundName:='howl.mp3';
          Playing:=True;
       end;
    end;  
    

    Do you get an exception then?

    Cheers

     
  • Jerome.D (BeanzMaster)

    Hi Daniel yes but before i deleted the behaviour of mickey object in scene editor. Remember MP3 is not supported by OpenAL with current code in GLScene. just WAV at this stage

    so :

    procedure TForm1.Button1Click(Sender: TObject);
    begin
       with TGLBSoundEmitter.Create(Sphere.Behaviours) do begin
          Source.SoundLibrary:=GLSoundLibrary;
          Source.SoundName:='chimes.wav';
          Playing:=True;
       end;
       with TGLBSoundEmitter.Create(mickey.Behaviours) do begin
          Source.SoundLibrary:=GLSoundLibrary;
          Source.SoundName:='drumloop.wav';
          Playing:=True;
       end;
    end; 
    

    will work

    Cheers

     
  • Daniel

    Daniel - 2020-01-31

    Yeah, that works!
    That was a bad mistake from my part.
    Thansk Jerome!

     
  • Daniel

    Daniel - 2020-01-31

    Still having some random crashes in my main program....
    I am trying to install the winOnly package so I can try the waveOut.
    But when I compile and install it, the components doesn't show.
    I am using Lazarus 2.0 and GlScene 7125

    Have you got waveOut working on Lazarus?

     
  • Daniel

    Daniel - 2020-01-31

    I tried rolling back to Lazarus 1.8.4....
    I have only tested my main program a little, but so far, it seems to have stopped the exceptions!?!
    I am clueless on this one....

    edit: Naah, now it happend again....

     

    Last edit: Daniel 2020-01-31

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.