[CLOSED] Experimental AudioPlus Plugin (+Unloading Audio)

Post your work in progress addons and get feedback

Post » Tue Jan 17, 2017 3:11 pm

Image

MUST READ:
Audio Unloading features have been added for Construct 2 releases starting from r242,
it's highly recommended to use the official plugin instead of this one!


Description:
The AudioPlus object plays back audio just like the official plugin does but it also
comes with a set of highly requested enhancements, more details can be found below.


Plugin Download & Example:
The AudioPlus Plugin: Download | The AudioPlus Example: Download

Features:
<Action> Unload all sounds
Clears the buffer of all preloaded sounds.
<Action> Unload sound
Clears the buffer of a single audio file.
<Action> Unload by name
Clears the buffer of an audio file by name.
<Action> Unload by tag
Clears the buffer of audio files by tag.

How It Works & Limitations:
Releasing/Unloading audio files from memory isn't as easy as you would expect it to be.¹
Javascript is using something called "Garbage Collector" to release not needed (not used anymore) data from memory.
In order to release audio from memory, we're required to basically mark the audio files that
we would like to release as "garbage" and wait for the Garbage Collector to do the work.
What this means for C2 developers is that releasing audio from memory will never happen
instantly and will always come with a delay, the delay varies and can take up to 10 seconds.


Advice & Best Practices:
"Unload All Sounds" will unload all sounds from memory by using a single action.
You can also simply select specific soundfiles that you would like to unload from a dropdown list.
It's also possible to unload specific sounds by using a tag or the actual filename.
The AudioPlus plugin will automatically stop the playback of the audiofiles before unloading them.
Please keep in mind, even with the implemented stopping mechanism which stops the active playback
of audio files, it's recommended not to unload audio files which will still be used in the next layout.
Basically only unload audio files which are not required anytime soon!


Credits & References:
¹Detailed information about JS memory management (Mozilla-Memory Management)
Plugin by @BackendFreak (Toby R. Wtfgamesgroup)
Stuff by @TheRealDannyyy (TheRealDannyyyIsCool.jk)
Last edited by TheRealDannyyy on Fri Jan 20, 2017 6:33 pm, edited 9 times in total.
B
60
S
22
G
78
Posts: 646
Reputation: 44,730

Post » Tue Jan 17, 2017 3:14 pm

* moved to a more relevant section. If you consider this plugin complete then let me know and I'll move it to the Completed section.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
134
S
30
G
84
Posts: 5,375
Reputation: 58,432

Post » Tue Jan 17, 2017 3:19 pm

zenox98 wrote:* moved to a more relevant section. If you consider this plugin complete then let me know and I'll move it to the Completed section.

Surething do as you like @zenox98, it's finished/complete. (Sorry for posting it in the wrong section.)
We've just called it experimental for testing purposes but private tests were all positive with next to no bugs found.

@Ashley Sorry if I'm tagging you too much but here it is, feel free to share feedback.
ImageImageImage
B
60
S
22
G
78
Posts: 646
Reputation: 44,730

Post » Tue Jan 17, 2017 4:17 pm

Thanks for the great and detailed wrap-up of the plugin @TheRealDannyyy!

BTW: here's a short test of sound unloading I made with @TheRealDannyyy 's tool (so you could see how much memory it can save): https://www.youtube.com/watch?v=vn9t3g8kgeo

@Ashley I saw you said:
Ashley wrote:I'll try and get audio unloading in the next build...


That's awesome. I know you can handle this yourself, still if you find the snippets from AudioPlus plugin useful you're obviously free to put them in the official plugin. I've used a lot of official code anyway.

One additional thing. Because of unloading features, the common approach will be now to not preload all sounds and startup but load them selectively. Therefore I was planning to add On sound preloaded condition. But as you're planning to add it to the official one, I'll pass with this one. Still it would be great if you could implement such condition to the plugin so C2 devs could make nice visual preloaders.

Thanks

EDIT - Updated YT URL above, now it has much better quality.
ImageImageImage
B
27
S
16
G
73
Posts: 976
Reputation: 41,171

Post » Tue Jan 17, 2017 8:20 pm

awesome plugin! but im not sure if wold be good as clearing the "garbage" or buffer cache wold basically make people redownload the buffer each time the same song/sound plays therefor increasing lagging/buffering time... the normal audio seems more suited for games.. while this plugins seem something you wold use in a particular project.. where clearing buffer wold increase performance and then never to use the particular sound again.


great job! but not for me! :)
B
75
S
22
G
68
Posts: 1,335
Reputation: 43,267

Post » Tue Jan 17, 2017 9:03 pm

gamecorpstudio wrote:awesome plugin! but im not sure if wold be good as clearing the "garbage" or buffer cache wold basically make people redownload the buffer each time the same song/sound plays therefor increasing lagging/buffering time... the normal audio seems more suited for games.. while this plugins seem something you wold use in a particular project.. where clearing buffer wold increase performance and then never to use the particular sound again.

great job! but not for me! :)


Of course it is pointless to release the buffer of the audio which you will use later in game. This feature is for bigger projects which have many unique audios per level.
ImageImageImage
B
27
S
16
G
73
Posts: 976
Reputation: 41,171

Post » Wed Jan 18, 2017 5:21 pm

This type of plugin is really bad for compatibility for all the reasons described here.

I know people need these features, and sometimes people need them sooner than we provide them. However if it is remotely possible, the plugin should be minimal code to patch code in to another plugin. It's not always possible, but when you take this "copy and paste" approach and copy the entire plugin wholesale, you can easily create worse problems than the plugin aims to solve.
Scirra Founder
B
395
S
232
G
88
Posts: 24,368
Reputation: 193,746

Post » Wed Jan 18, 2017 6:32 pm

Ashley wrote:This type of plugin is really bad for compatibility for all the reasons described here.

I know people need these features, and sometimes people need them sooner than we provide them. However if it is remotely possible, the plugin should be minimal code to patch code in to another plugin. It's not always possible, but when you take this "copy and paste" approach and copy the entire plugin wholesale, you can easily create worse problems than the plugin aims to solve.


I totally agree. That's why we ask you to add those extra features to the official Audio plugin. AudioPlus is not released as a completed addon. It's experimental just to test the possibilities of releasing the memory. I am not keen (and I'm not about) to maintain this or keep it as my official plugin for obvious reasons (like those listed in your article).

But as far as I am aware those features were requested over a year ago. Still official Audio doesn't have releasing memory implemented and that's why I gave it a try to see if it's really that problematic to implement. It looks like it works, added just few functions. For some projects this feature is an absolute must-have, so even tho this is an experimental addon, I would personally rather to launch my game with such plugin than not be able to launch my game at all.

Anyway, it's here and it works and we ask you to implement those into the official plugin. I know you're a busy man so I hope my code will save you some time if you decide to use it, and we (C2 devs) will have it in Audio plugin.
ImageImageImage
B
27
S
16
G
73
Posts: 976
Reputation: 41,171

Post » Wed Jan 18, 2017 6:42 pm

"sometimes people need them sooner than we provide them"
The problem is that no one knows when sooner or later is.
We dont even know if Scirra is working on it, will ever work on it or has even heared of problem x y.

It would be really great to know what is worked on and whats in the queue not only for c2 but also for the website the learning resources etc.
It doesn't have to be maintained only by Scirra either, we are a great helpfull community here and there are plenty of people around that would help maintaining a Trello page for example.

Godot has a trello roadmap https://trello.com/b/Vl7OgSuq/godot-engine-2-1
Unreal Engine 4 has a trello roadmap https://trello.com/b/gHooNW9I/ue4-roadmap
Unity has a roadmap https://unity3d.com/de/unity/roadmap

There is probably something like this in place internally to keep track of what has to be done but it would make a big difference if it was open for the c2 community
B
68
S
28
G
7
Posts: 85
Reputation: 7,496

Post » Thu Jan 19, 2017 12:06 am

@Ashley

I agree with you.
However, programmer only could "copy and paste" official plugin into a 3rd party plugin, because that it is the only one way to solve this issue.
- Can programmer add behavior (plugin) for audio plugin? No, only sprite-like plugin could have behavior plugin, but even behavior plugin could not solve this issue either.
- Can programmer control the behavior of audio plugin? No, even programmer could reuse the ACE of audio plugin. ( I know you don't like it, either)
B
108
S
26
G
267
Posts: 4,456
Reputation: 149,747

Next

Return to Work in Progress Addons

Who is online

Users browsing this forum: No registered users and 0 guests