Skip to content

Conversation

barkholt
Copy link
Contributor

@barkholt barkholt commented Aug 1, 2016

Has to be enabled in GwtApplicationConfiguration for now. It removes the dependency on SoundManager2, and has the following benefits:

  1. Low latency sound on all browsers, including mobile
  2. Simultaneous playback of multiple sounds on all browsers, including mobile
  3. Support for pitch and pan on the GWT backend
  4. Support for pausing audio when switching tabs

To test it using the gdx-tests, remember to alter your GwtTestStarter to enable the new code:
gwtApplicationConfiguration.preferWebAudioAPI = true;
gwtApplicationConfiguration.autoMuteOnPause = true;

I hope this, a modified version of this, or some other implementation of the Web Audio API can get merged, since the old SoundManager2 system is inadequate on mobile, in my experience.

Anyone adopting it should/could then go ahead and remove the inclusion of the SoundManager2 javascript files from the HTML pages.

Depending on whether this stuff can somehow be merged, I hope to follow up with better handling of preloading of sound/music on the GWT backend so we can get complete feature parity with the native platforms.

@intrigus
Copy link
Contributor

intrigus commented Aug 5, 2016

Looks like disposing a sound doesn't stop it.
Try SoundTest.java with a minor change.
Change this line to sound = Gdx.audio.newSound(Gdx.files.getFileHandle("data/8.12.mp3", FileType.Internal));
so it's easier to hear.
Start the sound, than press ESC. This disposes the sound but the sound isn't stopping.
My browser is Google Chrome Version 51.0.2704.103 (64-bit).

@barkholt barkholt force-pushed the gwtaudio_webaudio branch from 7ae2436 to d48f180 Compare August 7, 2016 23:49
@barkholt
Copy link
Contributor Author

barkholt commented Aug 7, 2016

@intrigus , Thanks for catching that problem. I fixed the issue, and updated the commit with the changed line.

@xpenatan
Copy link
Contributor

Nice, I may use this in dragome backend.

@MonsterOfCookie
Copy link

This looks awesome, I have merged this into my fork :)

@barkholt
Copy link
Contributor Author

Thanks for the feedback @xpenatan and @MonsterOfCookie. Maintaining a multitude of patches against the GWT backend is tiresome, I really hope we can get some stuff merged, in order to improve the quality of the backend. It's almost at the point where a game done with the GWT backend can't be distinguished from native - but not quite.

@MonsterOfCookie
Copy link

One thing I have noticed, something in there is still causing the browser to request the js files for SoundManager.

Is this something you see @barkholt ? Or could it be in my project somewhere.

@barkholt
Copy link
Contributor Author

The new sound backend is (for now?) only optional, thus I have not changed anything in regards to the HTML page hosting the app. You just have to remove the SoundManager includes from your host HTML page to get rid of the requests.

@MonsterOfCookie
Copy link

I have. That's what makes it interesting.

@barkholt
Copy link
Contributor Author

Oh, seems like it is being injected as a dependency by gdx_backends_gwt.gwt.xml at compile time. You'll have to remove it there as well. Sorry.

Whenever the project migrates away from SoundManager2 this will of course have to be fixed.

@barkholt
Copy link
Contributor Author

barkholt commented Nov 6, 2016

@intrigus Do you have any other thoughts on this new audio backed? Would you prefer a version where SoundManager2 has been completely removed?

I am keen to get a better audio backend for GWT merged, since the current one has so many problems on mobile (IMO).

@intrigus
Copy link
Contributor

intrigus commented Nov 6, 2016

Will look into it soon, but I'm going to have a busy week.

SpexGuy and others added 17 commits January 11, 2017 07:58
…fer#put is a lot faster than using BufferUtils on desktop JVMs. Fixed issue in BaseShader, returned attribute locations array was to big
* Add useful method

* Update Matcher.java

* Initialize string builder with string size
fix app crashed by call window()
[general]
- Updated moe-core and moe-ios jars to ones from MOE 1.3.0-beta-2
- Minor code cleanup
- Updated MOE versions to 1.3.0-beta-2
- Fixed bug in SharedLibraryLoader caused by change in MOE

[gdx-setup]
- Updated project files in GdxSetup.java
- Template build.gradle was updated and now properly handles resources via "ASSET_PATH"
- Deprecated files were removed
- Default and Icon images were moved to the appropriate location (Xcode target's folder)
- Updated Xcode project's layout

[test]
- Updated MOE test project
- Test now runs BulletTestCollection
Tom-Ski and others added 7 commits January 25, 2017 10:55
This makes it easier for subclasses of ParticleEffect to create custom
emitters.
+ Added button code for pressing in thumbsticks
+ Fixed typo where bumpers were referred to as axis, instead of triggers
@CraigLangford
Copy link

Do you need any help with this @barkholt? Getting this merged would be a huge step for the sound for GWT on mobile.

@barkholt
Copy link
Contributor Author

@CraigLangford I have not been made aware of any further problems with the patch (fixed the one reported earlier in this thread). So I am not sure what is blocking, or how to get anyones attention. I was considering resubmitting the patch against the current version of libGDX just to see if that would help.

I have a good handful of projects that uses this code, and I would very much love to stop having to patch my stuff all the time manually.

If you have any suggestions, I am all ears.

@CraigLangford
Copy link

@barkholt, I'm not sure. Mabe @badlogic might have some suggestions?

@barkholt
Copy link
Contributor Author

barkholt commented Jul 2, 2018

Since there was never any real movement towards getting this merged, I will close it. I hope to bring the feature up-to-date again, fix any issues I can and attempt to get it merged again.

I really think it is a much better sound backend for HTML5 than the existing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.