Note that there are some explanatory texts on larger screens.

plurals
  1. POiPad drumcomputer touch->audio latency
    primarykey
    data
    text
    <p>We've built a drumcomputer app for iPad to play along with live music (on stage or in your bedroom). The setup is pretty basic: you press one of the buttons and the corresponding sample will play. Everything works pretty smoothly, but unfortunately there appears to be a small (though annoying) latency between the moment you put your finger down and the playback of the sound. I've tried to measure the amount of latency (by ear), it seems to be something like 0.05 - 0.1 seconds.</p> <p>The audio playback has been implemented using the AudioToolbox framework (Extended Audio File Services, Audio Units). The sounds are streamed from file, which are stored on the device, to prevent loading times between different soundbanks. Samples are in raw wav format (Linear PCM, 16 bit little-endian signed integer, 2 channels, 44100 Hz), which should be the fastest to process as far as I understand (opposed to something compressed like mp3).</p> <p>I've measured the time between the button press (UIButton touch event) and the delivery of the first frames of the sample to the mixer (through the playback callback). It is quite stable and between 0.02 to 0.03 seconds. To me this seems pretty fast, but it might not be fast enough.</p> <p>Could that be the problem or might it be something else like a delay in the delivery of touch events?</p> <p><strong>UPDATE:</strong></p> <p>As suggested by Till, I've rewritten the loading of the samples. They are now all preloaded into memory, so disk IO is no longer an issue. On top of that I was doing quite a bit of memcpy for an echo effect, I've disabled it and will fix that later with a linked list kind of solution.</p> <p>Though this reduces the latency, button press->playback still measures between 0.005 to 0.02 seconds (but more often like 0.02). This is still noticeable. I'm thinking this might be due to the buffer size of the playback callback, which is currently 1024 bytes. </p> <p>Any ideas on how to do that? Setting kAudioUnitProperty_MaximumFramesPerSlice doesn't seem to work.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload