Regarding WebAudio Implementation

0 favourites
  • 12 posts
  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • Ashley, do you know if there is possibility to set the audio latency? That would be very useful at optimization.

  • 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 )

  • 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.

  • 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.

    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.

  • 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.

  • 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.

    EDIT@ 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.

  • 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.

    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 = <img src="smileys/smiley18.gif" border="0" align="middle" />

  • 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...

    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... :(

  • 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...

    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... :(

    Ashley After some more testing, I see that the preview of Node Webkit has this problem. However, if I exported my same project into stand alone node webkit first, then launch the .exe, all sounds seem to play correctly.

    What are the differences between preview version and standalone version?   Like are the audio engine treated the same way or the preview version has some quicker method for launching the preview?

  • It's a known bug and appears to be a networking issue in Chrome that only affects preview. After export audio should work correctly.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)