Author Topic: 3D Sound System looping  (Read 9073 times)

Offline floyd

  • byte
  • *
  • Posts: 10
    • View Profile
3D Sound System looping
« on: November 07, 2011, 05:49:20 PM »
Hi,

I use the 3D Sound System from this page in my current game.
It's easy and it works, thats very cool.

Unfortunately I have one problem with it: The looping doesn't work exact... I have a file which I know that its perfectly loopable, but with the 3D Sound System there is always this little silence gap...

This is the code I use:

Code: [Select]
SoundSystemConfig.addLibrary(LibraryLWJGLOpenAL.class);
SoundSystemConfig.setCodec("ogg", CodecJOrbis.class);
soundSystem = new SoundSystem();
soundSystem.newStreamingSource(true, id, url, url.getFile(), true, 0, 0, 0, SoundSystemConfig.ATTENUATION_NONE, 0);
soundSystem.play(id);

Do you have any suggestions? I could provide the ogg file if necessary.
Thanks in advance!

Stefan

/edit: I hope this is the right forum to ask...

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3495
  • Developer
    • View Profile
    • PaulsCode.Com
Re: 3D Sound System looping
« Reply #1 on: November 07, 2011, 06:13:18 PM »
Yes, could you provide the .ogg file?  My first impression is that the delay is caused by JOrbis being particularly slow at decoding, but I thought I had corrected for this by beginning to read the first chunk immediately after the last one begins playing, rather than waiting for the stream to end.  It's been a while since I looked at this part of the code, though.
Device: Samsung Galaxy Nexus i515
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: omni-4.4.4-20141014-toro-FML KitKat 4.4.4, rooted

Device: Eee PC 1015PEM
CPU: Intel Atom N550, 1.5 GHz (dual core, x86)
GPU: Intel GMA 3150, 200 MHz (dual core)
RAM: 2GB
Resolution: 1024 x 600
Rom: android-x86-4.3-20130725 Jelly Bean 4.3, rooted

Offline floyd

  • byte
  • *
  • Posts: 10
    • View Profile
Re: 3D Sound System looping
« Reply #2 on: November 07, 2011, 08:27:34 PM »
Here one of the ogg files where the prob occurs:
http://www.genialix-spiele.de:81/281-wasser-02.ogg

Thanks for helping!

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3495
  • Developer
    • View Profile
    • PaulsCode.Com
Re: 3D Sound System looping
« Reply #3 on: November 07, 2011, 09:04:33 PM »
I don't hear the delay on my computer, but it could just be that it runs faster on my system in my particular test.  Could you try running a couple tests for me, and let me know if they also have the delay?  This will give me an idea where to look for the problem

Test #1:
Code: [Select]
SoundSystemConfig.addLibrary(LibraryLWJGLOpenAL.class);
SoundSystemConfig.setCodec("ogg", CodecJOrbis.class);
soundSystem = new SoundSystem();
soundSystem.newStreamingSource(true, id, url, url.getFile(), true, 0, 0, 0, SoundSystemConfig.ATTENUATION_NONE, 0);
soundSystem.queueSound(  id, url, url.getFile() );
soundSystem.queueSound(  id, url, url.getFile() );
soundSystem.queueSound(  id, url, url.getFile() );
soundSystem.play(id);

Test #2:
Code: [Select]
SoundSystemConfig.addLibrary(LibraryLWJGLOpenAL.class);
SoundSystemConfig.setCodec("ogg", CodecJOrbis.class);
SoundSystemConfig.setStreamQueueFormatsMatch( true );
soundSystem = new SoundSystem();
soundSystem.newStreamingSource(true, id, url, url.getFile(), true, 0, 0, 0, SoundSystemConfig.ATTENUATION_NONE, 0);
soundSystem.play(id);
Device: Samsung Galaxy Nexus i515
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: omni-4.4.4-20141014-toro-FML KitKat 4.4.4, rooted

Device: Eee PC 1015PEM
CPU: Intel Atom N550, 1.5 GHz (dual core, x86)
GPU: Intel GMA 3150, 200 MHz (dual core)
RAM: 2GB
Resolution: 1024 x 600
Rom: android-x86-4.3-20130725 Jelly Bean 4.3, rooted

Offline floyd

  • byte
  • *
  • Posts: 10
    • View Profile
Re: 3D Sound System looping
« Reply #4 on: November 08, 2011, 07:48:54 AM »
I did test #1, same problem here...

I could'nt execute test #2, because in my release the SoundSystemConfig class doesn't have a static method called "setStreamQueueFormatsMatch()"... neither in this javadoc: http://www.paulscode.com/docs/SoundSystem/

Did I miss something?

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3495
  • Developer
    • View Profile
    • PaulsCode.Com
Re: 3D Sound System looping
« Reply #5 on: November 08, 2011, 04:14:47 PM »
Aha, I bet that's the problem.  I must not have released the official build after I worked on the delay bug.  I'll post the updated version later this evening.
Device: Samsung Galaxy Nexus i515
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: omni-4.4.4-20141014-toro-FML KitKat 4.4.4, rooted

Device: Eee PC 1015PEM
CPU: Intel Atom N550, 1.5 GHz (dual core, x86)
GPU: Intel GMA 3150, 200 MHz (dual core)
RAM: 2GB
Resolution: 1024 x 600
Rom: android-x86-4.3-20130725 Jelly Bean 4.3, rooted

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3495
  • Developer
    • View Profile
    • PaulsCode.Com
Re: 3D Sound System looping
« Reply #6 on: November 08, 2011, 05:28:36 PM »
I posted the updated version.  Let me know if it works out.  The setStreamQueueFormatsMatch() will provide the best optimization for looping streams, but if you use the queuing or fade in/out features make sure all the sounds playing on a single stream all decode to the same format (including channels, sample rate, and sample size).
Device: Samsung Galaxy Nexus i515
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: omni-4.4.4-20141014-toro-FML KitKat 4.4.4, rooted

Device: Eee PC 1015PEM
CPU: Intel Atom N550, 1.5 GHz (dual core, x86)
GPU: Intel GMA 3150, 200 MHz (dual core)
RAM: 2GB
Resolution: 1024 x 600
Rom: android-x86-4.3-20130725 Jelly Bean 4.3, rooted

Offline floyd

  • byte
  • *
  • Posts: 10
    • View Profile
Re: 3D Sound System looping
« Reply #7 on: November 10, 2011, 05:01:41 PM »
That's it!

With your update AND   SoundSystemConfig.setStreamQueueFormatsMatch(true);   the looping is fine..

Thank you very much!!

Offline floyd

  • byte
  • *
  • Posts: 10
    • View Profile
Re: 3D Sound System looping
« Reply #8 on: December 07, 2011, 04:34:01 PM »
I'm really really sorry, but I have another issue with the looping :(

This problem with the little sound gap from my initial post in this thread is in fact solved. But now It seems that some milliseconds from the sound sample is deleted or skipped for some reason.

I have attached an ogg file for testing...  There you can hopefully see that the constant rythm of the song is broken every loop. I tested the looping of the file in an sound editing program and it loops perfectly.

Thanks again in advance for your help :)

Kind regards,
Stefan

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3495
  • Developer
    • View Profile
    • PaulsCode.Com
Re: 3D Sound System looping
« Reply #9 on: December 07, 2011, 04:57:30 PM »
Does this happen with every file, or just specific ones? Try some .wav files to see if they have the same problem.  Also try the CodecJOgg plug-in to see if it has the problem.  This should help narrow down if the problem is in the codec or somewhere else.
Device: Samsung Galaxy Nexus i515
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: omni-4.4.4-20141014-toro-FML KitKat 4.4.4, rooted

Device: Eee PC 1015PEM
CPU: Intel Atom N550, 1.5 GHz (dual core, x86)
GPU: Intel GMA 3150, 200 MHz (dual core)
RAM: 2GB
Resolution: 1024 x 600
Rom: android-x86-4.3-20130725 Jelly Bean 4.3, rooted

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3495
  • Developer
    • View Profile
    • PaulsCode.Com
Re: 3D Sound System looping
« Reply #10 on: December 07, 2011, 05:21:38 PM »
Never mind, I ran the aformentioned tests, and it affects every codec plug-in.  The problem seems to be in the ChannelLWJGLOpenAL class (I am getting "Invalid enumerated parameter value" errors from this class, which I assume is related).  It only seems to occur when the setStreamQueueFormatsMatch speed hack, and it only affects looping sources(queued samples play in sequence just fine, which is possibly why I missed the problem).  I won't have time to look into this for a few days - I'll try and fix it next week.
Device: Samsung Galaxy Nexus i515
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: omni-4.4.4-20141014-toro-FML KitKat 4.4.4, rooted

Device: Eee PC 1015PEM
CPU: Intel Atom N550, 1.5 GHz (dual core, x86)
GPU: Intel GMA 3150, 200 MHz (dual core)
RAM: 2GB
Resolution: 1024 x 600
Rom: android-x86-4.3-20130725 Jelly Bean 4.3, rooted

Offline floyd

  • byte
  • *
  • Posts: 10
    • View Profile
Re: 3D Sound System looping
« Reply #11 on: December 07, 2011, 05:40:41 PM »
Thanks again, I'm looking forward to the fix.

Offline gouessej

  • byte
  • *
  • Posts: 17
    • View Profile
    • TUER (first person shooter written in Java by Julien Gouesse)
Re: 3D Sound System looping
« Reply #12 on: December 08, 2011, 03:04:08 AM »
The problem seems to be in the ChannelLWJGLOpenAL class
Please can you fix it in the JOAL plugin too?

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3495
  • Developer
    • View Profile
    • PaulsCode.Com
Re: 3D Sound System looping
« Reply #13 on: December 08, 2011, 04:14:44 AM »
Yes, it seems to have the exact same issue (both library plug-ins share most of the same code, so this isn't a surprise).
Device: Samsung Galaxy Nexus i515
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: omni-4.4.4-20141014-toro-FML KitKat 4.4.4, rooted

Device: Eee PC 1015PEM
CPU: Intel Atom N550, 1.5 GHz (dual core, x86)
GPU: Intel GMA 3150, 200 MHz (dual core)
RAM: 2GB
Resolution: 1024 x 600
Rom: android-x86-4.3-20130725 Jelly Bean 4.3, rooted

Offline floyd

  • byte
  • *
  • Posts: 10
    • View Profile
Re: 3D Sound System looping
« Reply #14 on: December 20, 2011, 01:44:49 PM »
Hey there!

Anything new here?