jMonkeyEngine / jmonkeyengine

A complete 3-D game development suite written in Java.
http://jmonkeyengine.org
BSD 3-Clause "New" or "Revised" License
3.8k stars 1.12k forks source link

Make AudioNode constructors less confusing #342

Open shadowislord opened 9 years ago

shadowislord commented 9 years ago

Currently we have constructors taking a name, name + boolean, or name + two booleans. There's no need for this complexity. Its best to just have a single constructor specifying the asset manager, the name of the audio file, and whether its buffered or streamed. The documentation should clearly specify what are the differences between buffered or streamed sources and when to use either.

E.g.

audioNode = new AudioNode(assetManager, "Music/Song123.ogg", Type.Streaming)

or

audioNode = new AudioNode(assetManager, "Sound/Misc/Hit.ogg", Type.Buffered)

Also the streamCache option should always be true, since it is unknown whether the user wants the sound to be looping, its best not to guess and assume it should support looping always.

MeFisto94 commented 8 years ago

Should the AudioType be added as a field to the AudioNode so one can use

audioNode.getType() == AudioType.Streaming

Also, should the underlying AudioKey be changed aswell or should it remain in the "two-boolean" style? And the third thing: Should the Type be an inner-class enum such as the old Status or rather an AudioType.java external file?

MeFisto94 commented 7 years ago

I am reopening this issue because of https://hub.jmonkeyengine.org/t/solved-ogg-memory-usage/38547/3 and https://hub.jmonkeyengine.org/t/solved-ogg-memory-usage/38547/5

Maybe we should rename the enum to Uncompressed and Compressed, since it's buffered either way and not really streamed anymore (or say it's only streamed the first time, then it's buffered). The Problem is though that we can't easily change the names without having another deprecation state again.

Does anyone know a good way to re-word the javadoc in order to clarify this?

@pspeed42