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

  • SEARCH
  • Home
  • 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 7959905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:38:44+00:00 2026-06-04T04:38:44+00:00

I’m working on a music app, so I can’t really approve any latancy. I’m

  • 0

I’m working on a music app, so I can’t really approve any latancy.

I’m using the beloved touchesBegan/Moved/Ended to process my touches.
Everything is going well, and I managed to synthesize a tone(using AudioUnit) and to show up a glow under the finger(using GLKit), and it all works fine if there’s less then 4-7 notes/touches hitting at the same time, then it goes nuts and make the app stuck.

I understood it’s becuase I’m doing lots of work(with the GLKit interface and the interface I made for my synth engine) and I need a way to fix it.

My code is built around like this:



- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    for(UITouch *touch in touches)
    {
        CGPoint lePoint = [touch locationInView:self.view];


        doing some calculataions for synth engine.......
        actually making the sound avilable to play through the interface........

        then I start to create the sprite object for the glow
        attaching it to the nsarray of the shapes
        //rejoycing in the awesomness of the sound


        adding the touch to the active touches array


    }

}

I do the exact reverse in the touchesEnded.

So in my attempts to make it work better I tried using GCD for the GLKit stuff, so that it would happen in asynchronously,
It worked, but at times I got to see a glow staying on screen because it wasn’t in the array when touchesEnded tried to remove it.

So that didn’t work, and I’m kind of clueless, if anybody can help I’d be thankful.

  • 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-06-04T04:38:45+00:00Added an answer on June 4, 2026 at 4:38 am

    Use GCD, but make sure you use a concurrent queue so you can submit all touches simultaneously. If you need to wait for their completion, use dispatch_apply, otherwise just kick them off asynchronously.

    You can not cancel a block once it is scheduled, so you may want to put a check to see if the touch has ended or canceled, and have the block return immediately.

    For example, something like…

    for (UITouch *touch in touches) {
        NSValue *key = [NSValue valueWithPointer:(__bridge void*)touch];
        MyData *data = [dictionary objectForKey:key];
        // set whatever attributes you want in the data for this touch
        // You may want to have a cancel flag in there, so you can set it later...
        CGPoint touchPoint = [touch locationInView:self.view];
        dispatch_async(someConcurrentQueue, ^{
            // If only one thing to do, check the flag at beginning, if it is a long task
            // may want to check it periodically so you cancel as soon as possible.
            if (data.touchHasEnded) return;
        });
    

    An alternative is to have a queue per touch. You create the dispatch queue in touchesBegan, and just toss tasks on it. You can let them all finish, or maybe some of them should just be canceled in touchesEnd.

    For example, if the state has already changed to something else, there may be no sense processing the remaining touches in-between.

    I have done line-smoothing like this.

    Either way, if you are doing intensive processing, you should let the system figure out how to manage it.. just make sure you can terminate what you are doing if appropriate.

    Make sure you mark the state as done, and do not process anything else after touchesEnd… You are, after all, only using a pointer as the key to the dictionary…

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

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I have thousands of HTML files to process using Groovy/Java and I need to
I am using Paperclip to handle profile photo uploads in my app. They upload
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

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.