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 406505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:30:10+00:00 2026-05-12T17:30:10+00:00

I am developing an application where the user can tap multiple hit areas which

  • 0

I am developing an application where the user can tap multiple hit areas which produces sounds.
But the result is a little laggy, when multiple sounds start at the same time, the sounds are played with an ugly delay.

I am using AVAudioPlayer instances for each sound.
Is there a better way to play sounds and prevent this lag?

Here’s the code:

#import "MBImageView.h"
#import <AVFoundation/AVFoundation.h>

@implementation MBImageView

-(void)awakeFromNib
{
NSURL* audioFile = [NSURL fileURLWithPath[[NSBundlemainBundle] pathForResource:@"shaker" 
                                               ofType:@"caf"]]; 
    AudioServicesCreateSystemSoundID((CFURLRef)audioFile, &shortSound); 

}

- (id)initWithImage:(UIImage *)image{ 
    return self; 
}

- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{
    AudioServicesPlaySystemSound(shortSound);
}


@end

Regards.

  • 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-12T17:30:11+00:00Added an answer on May 12, 2026 at 5:30 pm

    Most of these sounds (AVAudioPlayer and AudioServices) are playing after your runloop ends. That is, you say play and they get queued for playing, and they don’t start playing immediately.

    If you want lag free sound, you use Audio Unit:

    To provide lowest latency audio,
    especially when doing simultaneous
    input and output (such as for a VoIP
    application), use the I/O unit or the
    Voice Processing I/O unit. See “Audio
    Unit Support in iPhone OS.”

    You may also want to look at Audio Toolbox:

    Use the Audio Toolbox framework to
    play audio with synchronization
    capabilities, access packets of
    incoming audio, parse audio streams,
    convert audio formats, and record
    audio with access to individual
    packets. For details, see Audio
    Toolbox Framework Reference and the
    SpeakHere sample code project.

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

Sidebar

Ask A Question

Stats

  • Questions 217k
  • Answers 217k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I agree that EF objects should not be sent over… May 12, 2026 at 11:19 pm
  • Editorial Team
    Editorial Team added an answer Shouldn't it be: @productpicks = Product.find( :all, :conditions => [… May 12, 2026 at 11:19 pm
  • Editorial Team
    Editorial Team added an answer One solution should be the SpringSecurity (was Acegi Security) approach:… May 12, 2026 at 11:19 pm

Related Questions

I am developing an application where i want i am displaying a dataset in
I am developing an application that remembers the user's preferences as to where the
I am developing an application where i required to run some of the scripts
I am developing an application under Groovy using scafoldig. We are using the Acegi

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.