Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7016339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:46:18+00:00 2026-05-27T22:46:18+00:00

We’ve built a drumcomputer app for iPad to play along with live music (on

  • 0

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.

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

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.

Could that be the problem or might it be something else like a delay in the delivery of touch events?

UPDATE:

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.

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.

Any ideas on how to do that? Setting kAudioUnitProperty_MaximumFramesPerSlice doesn’t seem to work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:46:19+00:00Added an answer on May 27, 2026 at 10:46 pm

    I solved the latency problem by specifying the preferred hardware I/O buffer duration, as stated in the Audio Session Cookbook

    NSTimeInterval preferredBufferDuration = 0.005;
    [audioSession setPreferredIOBufferDuration:preferredBufferDuration error:&audioSessionError];
    
    if (audioSessionError != nil) 
    {
        NSLog (@"Error setting preferred buffer duration.");
        return;
    }
    

    By setting the buffer duration to 0.005, your application will only have to supply 256 bytes (at 44Khz) on each cycle. This (obviously) reduces the latency from 0.02 to 0.005, but audio will have to be produced at a faster rate.

    The iPad 2 is perfectly able to cope with this speed, even when the IO is read from disk. The first generation iPad is not fast enough unfortunately (with and without disk IO) so I hope I can find some way to distinguish the two and give the iPad 1 a bit more latency for better performance.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am writing an app with both english and french support. The app requests
I am using Paperclip to handle profile photo uploads in my app. They upload
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.