Regarding WebAudio Implementation

Discussion and feedback on Construct 2

Post » Sun Nov 24, 2013 3:28 pm

Hi,

I am just curious about WebAudio implementation for PC Chrome, and Node Webkit.

1. Is WebAudio using Hardware audio or do they decode audio by software?

2. How many sounds can be played simultaneously before the program starts to have cracking sound? (Or rather, what is the size of audio buffer for playback?) Are these different from machine to machine?

When things get hectic (imagine armies with machine guns, cannons, tanks' engine are charging in for war) and there are so many sounds (about > 50), sounds in C2 become very laggy.

Node Webkit can still recover, after all sounds are played. (took a while but it's unpleasant at all hearing all those sounds cracked up for several seconds)

For Chrome, well, it's still an unfixed bug on Chrome side. keroberos2013-11-24 15:29:11
I got a game that you multiply, breath fire with two heads and brawl foes to oblivion with your clones: http://www.newgrounds.com/portal/view/660664 (use Chrome on Windows for best performance)

My sites:
http://twinblazar.deviantart.com
http://twinblazar.newgrounds.com
https://twitter.com/twinblazar
http://www.pixiv.net/member.php?id=15072448
B
30
S
11
G
11
Posts: 411
Reputation: 8,459

Post » Sun Nov 24, 2013 6:56 pm

Node-webkit effectively is Chrome so it's strange if there are difference. I think it uses software processing (not sure there's anything to be gained from hardware processing audio any more - even phones have multicore processors so can dedicate a CPU core to audio). Buffer sizes are internal details that are probably browser/OS specific. Playing lots of sounds at once will probably clip before it distorts due to the processing load.
Scirra Founder
B
387
S
230
G
88
Posts: 24,251
Reputation: 192,464

Post » Sun Nov 24, 2013 7:08 pm

@Ashley, do you know if there is possibility to set the audio latency? That would be very useful at optimization.
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
86
S
28
G
21
Posts: 1,976
Reputation: 19,306

Post » Sun Nov 24, 2013 8:57 pm

I had a ball breaking a wall, and when it broke several each hit made a sound, my PCs 8 cores played it fine so I didn't notice, but when played on an Iphone browser it apparently tried to layer them out slightly, it was a wildly distorted mess. (break your speaker scary)

I put in an "is playing" test, to prevent the same sound from playing if it was already playing. In it's place it played a crumbling wall (bricks falling) sound which worked great, because it became an indicator that multiple fell.

I would say you need to do tests and plan around that.

(the game isn't public yet, but I hate when people reference something they don't show. CannonBall Bash ) Paradox2013-11-24 21:07:42
B
226
S
60
G
33
Posts: 902
Reputation: 39,989

Post » Mon Nov 25, 2013 12:12 am

Note if you have two sounds both normalised to 0 dBFS and play them both simultaneously, there is a high chance of clipping distortion, and the chance increases the more sounds you layer on. This is a normal result in digital audio. Some systems have built in compressors or limiters to avoid this, but if not you can avoid it by playing back (or mastering sounds at) a lower volume, e.g. -6 dB.
Scirra Founder
B
387
S
230
G
88
Posts: 24,251
Reputation: 192,464

Post » Mon Nov 25, 2013 12:19 am

[QUOTE=Ashley] Note if you have two sounds both normalised to 0 dBFS and play them both simultaneously, there is a high chance of clipping distortion, and the chance increases the more sounds you layer on. This is a normal result in digital audio. Some systems have built in compressors or limiters to avoid this, but if not you can avoid it by playing back (or mastering sounds at) a lower volume, e.g. -6 dB.[/QUOTE]

What the OP is describing really sounds like this (clipping) rather than the computer's inability to process it all. It is a common mistake when people start out with audio. I haven't played with it, but I believe C2 has an audio analyzer. If it does, have a text object show what your maximum volume output is (it is measured in decibels). If it ever exceeds 0db, it is clipping. I generally try to limit audio output to -2db, but it is up to you.C-72013-11-25 00:20:57
B
103
S
38
G
19
Posts: 962
Reputation: 17,986

Post » Mon Nov 25, 2013 2:43 am

@Ashley recall long ago that I reported long music didn't play bug on chrome? Strangely, Node Webkit played all audio just fine without any trouble. It's quite strange that node webkit is essentially... Chrome, but we have different result. Something inside must be different...

@C-7 assume we have a 3 seconds sound effect, try call play that sound 40 times in a loop. It will sound like those sounds are fighting in for the playing buffer. The clipping is very heavy. The game runs fine but those 3 seconds become stretchy and clippy and distorted 20-30 seconds instead.

The paragraph above is just an easy example to express my point.

Practically, what I do right now is to have one sound per tag. If we are to play a sound, I check first whether a tag exists, if so, seek position to 0. Else play the sound. This way, I could avoid the clippy audio trouble.
I got a game that you multiply, breath fire with two heads and brawl foes to oblivion with your clones: http://www.newgrounds.com/portal/view/660664 (use Chrome on Windows for best performance)

My sites:
http://twinblazar.deviantart.com
http://twinblazar.newgrounds.com
https://twitter.com/twinblazar
http://www.pixiv.net/member.php?id=15072448
B
30
S
11
G
11
Posts: 411
Reputation: 8,459

Post » Mon Nov 25, 2013 8:25 am

@keroberos OK, here's a tip: To not clip the sound you need either limiter or compressor. there is no limiter in construct but limiter is a compressor with ratio of 50+. So what you need to do is to set it in the following way: Threshold: -1, Ratio: 50 or more, Attack:1, Release: 1000. The downside is that it only works with advanced audio enabled. ( Knee: don't know how it works in construct as i see that i can set it to some stupid numbers @Ashley how knee works here in c2 compressor? )

So if you can't use compressor, then you've got to remember that same two sounds played at exactly same time will increase the overall volume by 3db. If they are not the same, the volume output varies. Fairly safe bet would be to set all sounds to -5db or -6db at sounds highest picks, but weather you'd rich clipping or not would depend on how many sounds you play simultaneously. Also you can make sound seam louder if you roll over sub from the sample using eq. This way you will get rid of unheard part of the sound, but it will make the sound sound louder without actual increase in volume.

[email protected] I see that filter in advanced audio actions can be used for rolling of parts of frequencies. So set it to high-pass at frequency between 80 and 300hz. Make sure you don't loose any audible information by checking did it change the sound or not. Push it till you hear the change, then lower it slightly. Set Gain to 0, detune to 0.

@Ashley In filter is the Q inverted or not? Many eq's have got inverted Q, which means the higher the number the narrower the band.
megatronx2013-11-25 08:39:17
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
86
S
28
G
21
Posts: 1,976
Reputation: 19,306

Post » Mon Nov 25, 2013 9:15 am

[QUOTE=megatronx]In filter is the Q inverted or not? Many eq's have got inverted Q, which means the higher the number the narrower the band.
[/QUOTE] @megatronx From my long-term tests I can tell that Q is inverted.

Also, from the web audio api documentation (https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html):

knee
    A decibel value representing the range above the threshold where the curve smoothly transitions to the "ratio" portion. Its default value is 30, with a nominal range of 0 to 40.

in short: 40dB = max useful smoothing, 0dB = punch, values outside =
Image
B
24
S
8
G
10
Posts: 1,821
Reputation: 8,279

Post » Sun Dec 01, 2013 3:59 pm

[quote] @Ashley recall long ago that I reported long music didn't play bug on chrome? Strangely, Node Webkit played all audio just fine without any trouble. It's quite strange that node webkit is essentially... Chrome, but we have different result. Something inside must be different...[/quote]

OK, something is up. After I updated to r152 64 bits, Node Webkit starts to have identical results as Chrome. If long music is played, any new sound effect that has not been loaded will not be played... :(
I got a game that you multiply, breath fire with two heads and brawl foes to oblivion with your clones: http://www.newgrounds.com/portal/view/660664 (use Chrome on Windows for best performance)

My sites:
http://twinblazar.deviantart.com
http://twinblazar.newgrounds.com
https://twitter.com/twinblazar
http://www.pixiv.net/member.php?id=15072448
B
30
S
11
G
11
Posts: 411
Reputation: 8,459

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 3 guests