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

The Archive Base Latest Questions

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

I’m using CoreAudio on iOS 5 to play MIDI files. I have everything setup,

  • 0

I’m using CoreAudio on iOS 5 to play MIDI files. I have everything setup, it works, everything’s peachy, except when I want to start over the sequence from the start during the playback.
To do that I naturally call:

    if (MusicPlayerSetTime(musicPlayer, (MusicTimeStamp)0.0) != noErr)
        [NSException raise:@"playMIDI" format:@"Can't reset the player"];

I don’t get any error, but making this call stops the playback altogether, instead of (as is said in the documentation) continuing playing from the new position.
I have tried this also (and many other combinations of the same type):

Boolean isPlaying = NO;
if (MusicPlayerIsPlaying(musicPlayer, &isPlaying) != noErr)
    [NSException raise:@"playMIDI:" format:@"Can't get MusicPlayer play state"];

if (isPlaying) {
    if (MusicPlayerStop(musicPlayer) != noErr)
        [NSException raise:@"playMIDI:" format:@"Can't stop MusicPlayer"];
}

if (MusicPlayerSetSequence(musicPlayer, musicSequence) != noErr)
    [NSException raise:@"playMIDI:" format:@"Can't set sequence for MusicPlayer"];

if (MusicPlayerSetTime(musicPlayer, (MusicTimeStamp)0.0) != noErr)
    [NSException raise:@"playMIDI" format:@"Can't reset the player"];

if (MusicPlayerSetPlayRateScalar(musicPlayer, 1.0) != noErr)
    [NSException raise:@"playMIDI" format:@"Can't set speed"];

if (MusicPlayerStart(musicPlayer) != noErr)
    [NSException raise:@"playMIDI" format:@"Can't start MusicPlayer"];

No joy, same effect.

If I change the MusicSequence however, the new MusicSequence plays fine. So I’ve gone to the extreme of creating two MusicSequence from the same MIDI file and switching from one to the other. No joy, iOS knows I want to play the same file twice and forbids it. I have to wait until the sequence is completely played before I can play it again. Bewildering.

Any idea?

Thanks

  • 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-05T23:12:55+00:00Added an answer on June 5, 2026 at 11:12 pm

    OK, here’s what I think is happening: Core Audio is pull-based, that is, when a unit needs data, it requests it from its source. Now when I reset the time on a MusicPlayer, it’s done at a certain time, say t0. Shortly after, at time t1, the AU Node fed by this MusicPlayer asks for data. The MusicPlayer takes t1 and computes where it falls in its sequence of events. Since it is invariably greater than t0, any event that starts exactly at t0 (e.g. events that starts at MIDI tick 0) are considered played and are thus not played at all. In other words, the first note(s) of the midi files is/are not played.

    Now, since my files are very short and in fact contain only a chord starting at tick 0, none of the notes are played and I get silence.

    Why this isn’t happening when I load a new sequence or start a sequence when it is not already playing is not clear to me…

    Anyway, one possible fix is to: stop the player, set the sequence, set the time to 0 then delay the start of the player by e.g. 25ms. That is not ideal for responsiveness, but it works.

    A slightly more convoluted way to fix this is the following:
    – set up a callback on render on the audio unit the music player is feeding (AudioUnitAddRenderNotify())
    – at the time of the reset of the sequence, don’t reset the time on the player but set a boolean flag
    – in the render callback, if the flag is set, reset the time on the player and unset the flag
    There is no delay introduced and it also works, which tends to validate my interpretation of the problem.

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

Sidebar

Related Questions

I have thousands of HTML files to process using Groovy/Java and I need to
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
I have a French site that I want to parse, but am running into
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
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.