Scirra cog

About Us

We're a London based startup that develops Construct 2, software that lets you make your own computer games!

Archives

Browse all our blog posts

Latest Blog Entries

We love brains!

Join us! Joiiinnn ussss! Mooooree brains!

Opus audio in Construct 3

by Ashley | 6th, September 2017

Audio codec support has been a thorn in our side for years. It was a problem when we first got going in 2011, and six years later, browser support is not a whole lot better. Construct 2 still uses two audio formats to support all browsers, MPEG-4 AAC (.m4a) and Ogg Vorbis (.ogg). AAC is a patent-encumbered format and distributing encoders incurs a fee, which would make the Free Edition uneconomical. In Construct 2 we use a clever workaround: Windows 7+ has an AAC encoder built-in which we use when importing audio, and thus we avoid having to ship an encoder ourselves. However the encoder cannot be accessed from a browser, and is not available on all other operating systems anyway. So for Construct 3 this posed a problem: how do we support Safari and Edge, which don't support Ogg Vorbis?

Looking to an Opus future

We've been keeping an eye on Opus, a modern new audio codec with excellent compression while maintaining very high quality. Chrome and Firefox have supported Opus in a WebM container for a while now, and Edge almost supports it — it can use it in some scenarios, but not Web Audio yet from what we can tell. Presumably the decoder's there in the browser so it should be possible to enable it for Web Audio too.

Assuming Edge eventually fully supports it that only leaves Safari, which is working on WebRTC support, which also commonly uses Opus. So it's plausible it could eventually be supported in all major browsers, making WebM Opus the most likely candidate for full cross-browser support.

Opus in Construct 3

Consequently in Construct 3, importing audio encodes it to WebM Opus. By the way, this is done entirely in the browser using an asm.js compiled encoder — no need for any extra tools or uploading to servers.

However, Edge and Safari today still don't have built-in Opus support. To cover them, the runtime also provides its own WebM Opus decoder which Iain has been working on for some time. It's compiled with asm.js for native-like performance, and as of r50, thanks to Iain's latest efforts, also has an alternative WebAssembly version for maximum performance. Safari and Edge get WebAssembly support later this year and this will help ensure decoding is done optimally. Both asm.js and WebAssembly versions are scheduled to run across multiple CPUs for maximum performance, allowing multiple audio files to be decoded in parallel.

In the end, this means in browsers without native support we decode WebM Opus ourselves, and can then play back the decoded versions with the Web Audio API. It does use a bit more memory than having native support, but it's very similar to the workaround we've been using for some time in WKWebView (for iOS apps) without ill effect. This means your WebM Opus audio files can play in all modern browsers. As soon as either Safari or Edge gets support for built-in decoding of WebM Opus, the runtime will automatically detect this and switch over to the browser's decoder. Ultimately if both Safari and Edge have built-in support for WebM Opus we'll probably eventually remove our own decoder, but that could take some time; our own decoder will fill in until then.

The only browser left out is Internet Explorer: it neither supports WebM Opus nor has the Web Audio API, so there aren't really any sensible workarounds left. However IE has a falling market share as it is steadily being replaced by Edge, and for some exporters IE support is irrelevant (like Cordova and NW.js). Additionally you can still encode .m4a or .mp3 versions of audio files yourself and import them to C3, and audio will work again on IE.

One format after all

So we're hoping in the long term, this finally leaves us with just one audio format that works everywhere: WebM Opus! This will make managing audio easier, reduce the size of your exported games, simplify deploying to the web, and make use of the latest codec with the best quality and compression available. The only browser left out is Internet Explorer, but those who need to cover old browsers can use a separate encoder to create their .m4a or .mp3 files and import them to Construct 3, where it will fall back to using them just like in Construct 2.

So if you were wondering why Construct 3 has started creating .webm files when you import audio, that's why!

Now follow us and share this

Tags:

Comments

5
uzumiapps 2,676 rep

My games are progressive story telling games so this would really help to have one audio export and a smaller file size

Wednesday, September 06, 2017 at 2:09:05 PM
5
gamecorpstudio 43.3k rep

so this is all good, but since you have two software pieces, and easy to say, C2 still generates the most of the revenue! wouldn't be good to implement some of this features in the old dusty C2 as well? considering probably 50% of the users are still using it? would love to have a good audio format for C2 as well, is a problem we (community) discussed for years now, and response was along the line of a maybe? so since C3 has it sorted out on this issue atleast... wouldn't this be logical to transfer in C2 as well?

Wednesday, September 06, 2017 at 4:12:56 PM
4
Ashley 193.8k rep

Sorry, this took several weeks to develop, and as we've said before we are focusing all new features on Construct 3 only! We simply don't have the resources to repeat all this work for Construct 2.

Wednesday, September 06, 2017 at 5:52:06 PM
4
grymmjack 2,433 rep

@Ashley - can we access C3?

Wednesday, September 06, 2017 at 6:43:53 PM
6
chadorireborn 59.7k rep
Sorry, this took several weeks to develop, and as we've said before we are focusing all new features on Construct 3 only! We simply don't have the resources to repeat all this work for Construct 2.
quoted from Ashley

If you could finish the Construct 3 SDK. Then surely almost everyone including me will move to Construct 3. The only thing holding us back is plugin support, if we exclude the standalone program version of C3.

I was about to purchase C3 but it stopped me when I've imported my C2 project to C3 because I was missing a few plugins. The main problem is because the C2 plugins I used still can't be ported to C3 since the Construct 3 SDK isn't finished yet.

Wednesday, September 06, 2017 at 7:57:00 PM
4
ReflextionsDev 12.3k rep

Why are edge and safari always so far behind? Good work nevertheless!

Thursday, September 07, 2017 at 12:49:34 AM
3
guimaraf 21.6k rep

Will it be implemented in .mp3 on Construct2?
Since it is an audio format widely supported by browsers.

Thursday, September 07, 2017 at 1:25:50 AM
3
Lordshiva1948 40.6k rep

Thanks Ashley

Thursday, September 07, 2017 at 10:49:57 AM
3
LaurenceBedford 8,689 rep

Thanks Ashley!

Thursday, September 07, 2017 at 5:47:53 PM
1
jharma 198 rep

Online UPS, Uninterrupted Power Supply service Company
Pertho Engineers is a growing company of Uninterrupted Power supply services in India. We provides best UPS Services in India like as Online UPS Services, Stabilizer, Line Interactive Services, Online single phase and three phase UPS etc. We at Pertho Engineers provides you at Online UPS Services, Stabilizer, Line Interactive Services, Online single phase and three phase UPS Services at best price ever. call at 91-9871495530.
[Hyperlink removed - users with less than 500 rep cannot post links]

Best UPS Company, ups service

Tuesday, September 12, 2017 at 12:38:33 PM
3
Jackson6 217 rep

[Hyperlink removed - users with less than 500 rep cannot post links]

Sunday, September 17, 2017 at 7:05:09 AM
0
Huemerson 14.9k rep

Gosto muito do C2, e estou tendo dificuldades em migrar para o C3, e ainda com estes detalhes, visando perder projetos feitos em C2 acho que vai demorar um pouco para que os usuários comecem a aceitar a evolução.
Mas a evolução é necessária e temos que nos adaptar.

Obrigado...

Wednesday, September 20, 2017 at 10:37:33 PM

Leave a comment

Everyone is welcome to leave their thoughts! Register a new account or login.