Menu

GLSMWaveOut

Help
Daniel
2017-10-05
2018-09-24
  • Daniel

    Daniel - 2017-10-05

    Hey all!
    I've been using the GLSMBass soundmanager, until I know discovered that it cannot be used in a commercial product.
    So I tried to replace it with the GLSMWaveOut, but it creates errors:
    32 (GLSound.pas, line 1833)

    Any idea why I cannot replace Bass with WaveOut?

    Thanks!

     
  • Jerome.D (BeanzMaster)

    Hi Daniel I think the best it's use OpenAL. But have you a little sample for i can reproduce the error ?. What the exact error message ?

    Around line 1833 i have this

    procedure TGLBSoundEmitter.WriteToFiler(writer: TWriter);
    begin
      inherited;
      with writer do
      begin
        WriteInteger(0); // Archive Version 0
        FSource.WriteToFiler(writer);
        WriteBoolean(FPlaying);
      end;
    end;
    

    It is here ?

     
  • Daniel

    Daniel - 2017-10-07

    Hi Jerome!
    I'm very sorry, I forgot to write that I'm using GLScene 1.0.

    The error is in this procedure:

    procedure TGLSMWaveOut.UpdateSource(aSource : TGLBaseSoundSource);
    var
       i, n : Integer;
       wfx : TWaveFormatEx;
       smp : TGLSoundSample;
       wh : wavehdr;
       mmres : MMRESULT;
       hwo : hwaveout;
    begin
       // count nb of playing sources and delete done ones
       n:=0;
       for i:=Sources.Count-1 downto 0 do
          if Sources[i].ManagerTag>0 then
             Inc(n)
          else if Sources[i].ManagerTag=-1 then
    {$ifdef GLS_DELPHI_5_UP}
                Sources.Delete(i);
    {$else}
                Sources[i].Free;
    {$endif}
        // start sources if some capacity remains, and forget the others
       for i:=Sources.Count-1 downto 0 do if Sources[i].ManagerTag=0 then begin
          if n<FMaxChannels then begin
             smp:=Sources[i].Sample;
             if Assigned(smp) and (smp.Data<>nil) then begin
                wfx:=smp.Data.Sampling.WaveFormat;
    HERE -->        mmres:=waveOutOpen(@hwo, WAVE_MAPPER, @wfx,
                                   Cardinal(@_waveOutCallBack), Integer(Sources[i]),
                                   CALLBACK_FUNCTION);
    HERE -->        Assert(mmres=MMSYSERR_NOERROR, IntToStr(mmres));
                wh.dwBufferLength:=smp.LengthInBytes;
                wh.lpData:=smp.Data.PCMData;
                wh.dwLoops:=Sources[i].NbLoops;
                if wh.dwLoops>1 then
                   wh.dwFlags:=WHDR_BEGINLOOP+WHDR_ENDLOOP
                else wh.dwFlags:=0;
                wh.lpNext:=nil;
                mmres:=waveOutPrepareHeader(hwo, @wh, SizeOf(wavehdr));
                Assert(mmres=MMSYSERR_NOERROR, IntToStr(mmres));
                mmres:=waveOutWrite(hwo, @wh, SizeOf(wavehdr));
                Assert(mmres=MMSYSERR_NOERROR, IntToStr(mmres));
                Sources[i].ManagerTag:=hwo;
                Inc(n);
                end else
    {$ifdef GLS_DELPHI_5_UP}
                    Sources.Delete(i);
    {$else}
                    Sources[i].Free;
    {$endif}
            end else
    {$ifdef GLS_DELPHI_5_UP}
                Sources.Delete(i);
    {$else}
                Sources[i].Free;
    {$endif}
        end;
    end;
    
     

    Last edit: Daniel 2017-10-07
  • Jerome.D (BeanzMaster)

    Hi Daniel it seem those lines
    Assert(mmres=MMSYSERR_NOERROR, IntToStr(mmres));

    I think they will be : Assert(mmres<>MMSYSERR_NOERROR, IntToStr(mmres));
    due to the MMSYSERR_NOERROR

    Assert will not be raised when NOERROR

    If it not work. What the displayed error message you have, exactly ?

     
  • Daniel

    Daniel - 2017-10-07

    The error says: 5 (C:......\GLSound.pas, line 1842)
    Here is line 1841 anc 1842:
    mmres:=waveOutPrepareHeader(hwo, @wh, SizeOf(wavehdr));
    Assert(mmres=MMSYSERR_NOERROR, IntToStr(mmres));

    It happens when my program starts. I play sound like this:

    if rpmTOTAL_var_real = 0 then
         begin
         GLSMBASS.Sources.Items[0].pause := true;
         end
         else
         begin
         GLSMBASS.Sources.Items[0].pause := false;
         GLSMBASS.Sources.Items[0].Volume := 1 * (rpmTOTAL_var_real /250);
         GLSMBASS.Sources.Items[0].Frequency := 5000 + round(rpmTOTAL_var_real * 100);
         end;
    

    It works with GLSMBass, but not GLSMWaveOut.

     
  • Jerome.D (BeanzMaster)

    Hi have you tried change Assert(mmres=MMSYSERR_NOERROR, IntToStr(mmres)); by
    Assert(mmres<>MMSYSERR_NOERROR, IntToStr(mmres)); ?

     
  • Daniel

    Daniel - 2017-10-09

    Hi Jerome!
    Yes, then the error doesn't pop up. But the sound is not working anymore...
    Any other ideas?
    Is there a different requirement on the soundfile itself compared to the GLSMbass?
    1 channel 16 bit .wav-file should work, as with the glsmbass?

     
  • Daniel

    Daniel - 2017-10-17

    Is there any demo where the GLSMWaveOut is being used?

    The GLSMBass has a non-commercial license right?

     
  • Daniel

    Daniel - 2017-10-28

    Hi Pavel!
    Yes, I have tried the demo, same result with the above error...
    Very weird!

    In GLScene 1.0 there doesn't seem to be an GLSMopenAL component.

     
  • Jerome.D (BeanzMaster)

    Hi i checked GLSMOpenAL.pas is in folder SoundVideoApis. in the curretn SVN.

    Just a question Daniel why do you not update to the current version 1.5 ?

     
  • Daniel

    Daniel - 2017-10-30

    Hi Jerome!
    The problem is I have the old Delphi 6, from the stoneage (2001), and I cannot install any GLScene past 1.0...

     
  • Jerome.D (BeanzMaster)

    Ok, i understand. Perhaps, do you plan to test Lazarus or CodeTyphon ?

    Anyway i've checked in https://sourceforge.net/p/glscene/code/HEAD/tree/tags/GLScene%20v1.1/
    You have a package for OpenAL."GLSS_OpenAL6.dpk" You can try it

     
  • Daniel

    Daniel - 2017-10-30

    Thanks Jerome!
    I'll have a look!

     
  • Pavel Vassiliev

    Pavel Vassiliev - 2018-09-24

    Daniel,
    I fixed GLSMWaveOut parameters in the last version of GLS 1.7 so the sample in demos is working fine now
    PW

     

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.