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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:24:22+00:00 2026-05-27T12:24:22+00:00

My CoreMIDI connection on iOS is apparently fast enough to handle ANYTHING that hits

  • 0

My CoreMIDI connection on iOS is apparently fast enough to handle ANYTHING that hits it… if I’m just doing some simple object creation and NSLog. In the UI, I don’t have time to handle everything that comes in. The UI would blow up, or just finish processing too late.

However, I need to do real processing and UI display in response to CoreMIDI inputs. What I’d like is to process the latest messages every, say, 1ms or 2ms. I’ve been doing this with a collection that gets emptied by a timer-fired method every 1ms (processFromServerAsync). One problem is that some messages might fall through the cracks, I think, if I grab and substitute:

NSDictionary *queueCopy = [self.queue copy];
// here the dictionary could get messages not in the queue copy!
self.queue = [NSMutableDictionary dictionary];

I realize that I could handle this by synchronizing with a lock, which is easy to screw up:

-(NSMutableDictionary *)messageQueue {
    @synchronized(self) {
        if (!messageQueue_)
            self.messageQueue = [NSMutableDictionary dictionary];
        return messageQueue_;
    }
}

-(NSDictionary*)clearMessageQueueAndReturnCopy {
    @synchronized(self) {
        if (!messageQueue_)
            return [NSDictionary dictionary];
        NSDictionary *retVal = [messageQueue_ copy];
        self.messageQueue = [NSMutableDictionary dictionary];
        return retVal;
    }
}

However, I’m not convinced that I’m even handling this in the correct way. How is throttling typically done (even outside of Obj-C)? I surely cannot process all those messages in the UI nor the program.

  • 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-27T12:24:23+00:00Added an answer on May 27, 2026 at 12:24 pm

    There are some well-established patterns for throttling streams of incoming data. This comes up a lot in finance, where you might have a data feed throwing 100K messages/sec at a system.

    You employ a sliding window mechanism to discard redundant messages while ensuring that the client has the latest possible copy of the data. You set your window up over some time period (a few milliseconds) then set up a queue for each data stream (meaning a particular CC, midi note etc.) You start a global timer when the first message comes in. You send that message to the client immediately. If anything else comes in during the window you push it to its queue. The queue has just one entry – the latest value – so you overwrite the queued value with each subsequent update. When the timer ticks (the window is over) you send the latest message out to the client. Then, you send the next message out as soon as it comes in, start a new window and repeat. This gives a reasonable balance between swamping the client and avoiding aliasing of update intervals to the timer window. Aliasing is less of an issue with 1-2ms intervals so a cruder rigid timer approach might work for you.

    The critical thing is ensuring that you have separate windows for each data stream. You can’t risk overwriting or ignoring, say, a note off because a control change came in. One timer, one single-entry queue per Midi message number.

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

Sidebar

Related Questions

Here is an extremely simple CoreMIDI OS X application that sends MIDI data. The
I am not entirely sure of how these associations work. iOS implements CoreMIDI. Ok.
I am just getting started again with Mac development. I am using CoreMIDI which
I have a C++ eclipse project that I would like to easily compile In
Faced with two errors. This code worked in iOS 4 and 5, but after
I am working on a project that uses RtMidi ( http://www.music.mcgill.ca/~gary/rtmidi/ ). I can
Are there any opensource options for iOS/Android score following of MIDI files? I think
I'm adding OSC capability to my music drum pad type app for iOS. I'm
I want to know how I can receive MIDI tempo (bpm) from host running
I wish to include this in my cpp file: #include <boost/lambda/lambda.hpp> For my Makefile

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.