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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:54:33+00:00 2026-06-05T00:54:33+00:00

I have a program for iPad iOS 5 that reads in a MIDI and

  • 0

I have a program for iPad iOS 5 that reads in a MIDI and then displays the notes on a keyboard in time with the music. It works fine but I am attempting to add a “Repeat Section” function where it would repeat a section from timestamp A to timestamp B over and over again.

I have been able to get the timestamps to work as the bounds of my repeat section but I am having trouble getting the repetion to work properly. When I try and repeat a section, I don’t get my keyboard animation anymore. I have a feeling this problem is going to require hyperthreading but I’m not sure. I’ve outlined what I’d like to do below in pseudocode.

//Start Repeat Method
while (the repeat switch is toggled) {
     Stop music player.

     Set music player to the start point of the repeat.

     while (the current play point is before the end point of the repeat) {
          Check the current play point.
     }
}
//End Repeat Method

So basically, what I want to do is to have a method triggered when a user hits a switch that will be called over and over until they switch it off. In the method, it will stop the player, set it to the start of the repeat, play the repeat until it sees it’s at the end of the repeat, and then start the method over again.

I didn’t think this part was going to be as tricky as it has been. Another problem I have is that when I hook this up to a switch, it doesn’t allow me to switch it off, it just goes forever.

Thanks in advance for the advice.

**EDIT

Here is what I have so far. It allows me to loop my section but my animations are being displayed and I can’t interact with the UI and I have to terminate the program with the stop button in Xcode.

- (IBAction)playRepeat:(id)sender {
     if (repeatToggle.on) {
          MusicPlayerStop(player);
          playerIsPlaying = NO;

          MusicPlayerSetTime(player, sequenceRepeatStartTime);
          moviePlayerViewController.moviePlayer.currentPlaybackTime = rollRepeatStartTime;

          MusicPlayerStart(player);
          [moviePlayerViewController.moviePlayer play];
          playerIsPlaying = YES;

          float difference = rollRepeatEndTime - rollRepeatStartTime;
          [NSThread sleepForTimeInterval:difference];

          MusicPlayerStop(player);
          playerIsPlaying = NO;
          [moviePlayerViewController.moviePlayer pause];

          [self playRepeat:sender];
     }
     else if (!repeatToggle.on) {
          MusicPlayerStop(player);
          playerIsPlaying = NO;
     }
}
  • 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-05T00:54:36+00:00Added an answer on June 5, 2026 at 12:54 am

    Your while loop would exhaust the CPU, because it keeps running and waits for nothing.
    Putting this in separated thread might help, but you would need locking mechanism if your player is not thread-safe.

    Not that without the notification from the player itself, it would be hard to repeat it at the correct time. You should check if your MIDI player supports any notification or delegate callback that you can use for getting notified when the play reach the point you specified.

    Anyway, I would provide the way out that might be adequate for you. You can use timer to check on the player, maybe every 100ms by doing something like this.

    -(void) repeatCheck {
        if (the repeat switch is ON) {
            if (the current play point is NOT before the end point of the repeat) {
                Stop music player.
                Set music player to the start point of the repeat.
            }
        }
        [self performSelector:_cmd withObject:nil afterDelay:0.1];
    }
    
    -(IBAction) repeatSwitchToggled {
        if (the repeat switch is ON) {
            [self repeatCheck];
        }
        else {
            [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(repeatCheck) object:nil];
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program that reads approximately 2million rows from a database into a
I have program that constantly query a mysql server. Each time I access the
I have a csv file that is utf-16 containing Tamil characters and displays fine
A have a iOS-project that I send to my iPad. But when I'm trying
I have a ios program for iPad. It is used 2 view, A view
I have a calendar program that I am trying to convert to iPad (using
I have program that sends a file to a printer using 'lpr' command. I
I have program, that has structure defined like this: struct foo { int magic;
I have program that I want to test on clean Windows installation. For now
I have program that has a variable that should never change. However, somehow, it

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.