Unstable Audio Latency (Audio: Play Sound)

0 favourites
  • 4 posts
From the Asset Store
Grenade Sound Library contains: 135 sounds 50 grenade sounds and 85 surface sounds
  • I'm working on an update for my APP "Easy Chords Studio", in which I've build a so called arpeggiator.

    This ARP is nothing more than playing notes after each other with a certain delay (determined by the BPM)

    I'm running into a audio latency / delay issue when using the default audio plugin in Construct 2.

    (the sounds are played after very noticeble different delays instead of a stable delay)

    Basicly, this is what I do in the construct code:

    AUDIO : Play Sound

    SYSTEM: Wait 0.1875 seconds

    AUDIO : Play Sound

    SYSTEM: Wait 0.1875 seconds

    AUDIO : Play Sound

    SYSTEM: Wait 0.1875 seconds

    AUDIO : Play Sound

    SYSTEM: Wait 0.1875 seconds

    ETC ...

    Running the app in preview mode in browser sounds smooth.

    But running the APP on actual devices, things get messed up in the timing.

    (Exported the project to XDK using cordova and build for both iOS and Android)

    Logging the time difference after each play shows a quite stable playback:

    But the actual delay (measured by recording back the audio output and analysing it) varies way more.

    Delay took: 198ms (actual delay: 246ms)

    Delay took: 202ms (actual delay: 246ms)

    Delay took: 203ms (actual delay: 161ms)

    Delay took: 201ms (actual delay: 243ms)

    Delay took: 203ms (actual delay: 161ms)

    Already tried stopping all sounds after each delay, so no polophony, but unfortunatly the same result.

    And yes, preloading of sounds is enabled in this project

    Is there a way I can make, at least the delays between the notes the same?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The problem with audio scheduling is right now you can only start audio playback in events, which run at 60 FPS (every 16.6ms) under good conditions. Even on desktop since 1875ms does not divide in to 16.6ms, it will not be able to schedule those sounds at exactly the right time. If the framerate is low, e.g. 30 FPS, the problem gets worse. The solution is to allow scheduling playback at a time in the future, which the Web Audio API can do sample-accurately, so the sound kicks in exactly when you want it, even between frames. I'll look in to adding this in a beta release some time...

  • Thanks Ashley for the technical explanation, I'll do some additional testing with this knowledge on various devices.

    I'm very curious if keeping the delay divisible to the current frame rate will make the ARP run (more) steady

    Really looking forward to have this scheduled playback in Construct!

  • The new audio feature "Schedule next play" which is available in Construct 2 r225, seems to nail this problem.

    Audio timing is (nearly) perfect on various devices (which support advanced audio)

    Thanks again Ashley !

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