• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: MusicTrack timing and looping issues.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MusicTrack timing and looping issues.


  • Subject: Re: MusicTrack timing and looping issues.
  • From: Aran Mulholland <email@hidden>
  • Date: Fri, 05 Apr 2013 12:23:19 +1100

Yeah thats a good idea, however it won't fix backward compatibility issues, as I am targeting iOS5 I still have to do this stuff anyway.

I don't know if others would agree but I think that the implementation of looping has a flaw. The loop is measured from the end of the track or the last event if kSequenceTrackProperty_TrackLength is not set. In the context of beat generation applications what would be fantastic was if you could specify the start of the loop and the loop length. This would enable multiple loops to be stored in the one MusicTrack. I also think this is more intuitive, measuring loop length from the end of the track is a trifle counterintuitive. 


On Fri, Apr 5, 2013 at 3:27 AM, Douglas Scott <email@hidden> wrote:
File a radar with example code?  Things do get fixed this way, and it certainly makes it easier to keep track (no pun intended) of the work to be done.

-DS

On Apr 4, 2013, at 1:20 AM, Ben wrote:

I am having endless issues with MusicTrack. I am trying to create a drum machine.

1) Looping (MusicTrackLoopInfo): is broken as far as I can tell, if you wish to try and change notes on the fly whilst looping (unless someone can tell me different or has a workaround?). 

2) With the code below I use MusicTrackNewMIDINoteEvent to insert notes at regular interval (0.25, 0.5 etc). But due to the above, this is useless. So instead I tried using MusicTrackNewUserEvent to try and trigger note events from that.
The plan was to pass a timestamp, and fire UserEvent's on every 16th note, and check with an Array if to play a drum sound or not.
However, when played, it is totally out of time and absolutely unusable for triggering drum noises.
Am I right in saying user UserEvent's are not as accurate timing wise as NoteEvent's?

The whole method (midiTest) is called on a separate thread with...
 [NSThread detachNewThreadSelector:@selector(midiTest) toTarget:audioEngine withObject:nil];

I am exasperated by it all! Any ideas?

-(void) midiTest {

    OSStatus result = noErr;
    
    
    [self createAUGraph];
    [self configureAndStartAudioProcessingGraph: self.processingGraph];
    
    // Create a client
    MIDIClientRef virtualMidi;
    result = MIDIClientCreate(CFSTR("Virtual Client"),
                              MyMIDINotifyProc,
                              NULL,
                              &virtualMidi);
    

   
    // Create an endpoint
    MIDIEndpointRef virtualEndpoint;
    result = MIDIDestinationCreate(virtualMidi, (CFStringRef)@"Virtual Destination", MyMIDIReadProc, (__bridge void *)(self), &virtualEndpoint);

    MusicSequence s;
    NewMusicSequence(&s);
    MusicTrack sequenceTrack;
    MusicSequenceNewTrack(s, &sequenceTrack);
    
    NSValue * sequenceStruct = [NSValue value:&s withObjCType:@encode(MusicSequence)];
    [self.musicSequenceArray  addObject: sequenceStruct];
    
    MusicSequenceSetUserCallback(s, UserCallback, NULL);
    MusicPlayer  p;
    NewMusicPlayer(&p);
    MusicSequenceSetMIDIEndpoint(s, virtualEndpoint);
    [self loadPreset];
    MusicPlayerSetSequence(p, s);
     result =  MusicSequenceGetIndTrack(s, 0, &sequenceTrack);
        
    MIDINoteMessage noteMessage;
    noteMessage.channel = 0;
    noteMessage.note = 60;
    noteMessage.velocity = 100;
    noteMessage.releaseVelocity = 0;
    noteMessage.duration = 0.0;
    
      
    int ticksPerBar = 4;
    for (int i = 0; i<(8 *ticksPerBar); i++) {
        
        UserEvent event;
        event.length = 0;
        event.length = sizeof(UserEvent);
        event.playedNote = noteMessage.note;
        event.tStamp = (float)i/ticksPerBar;
        event.message = noteMessage;
          event.player = _samplerUnit;
        event.midiStatus = 144;
        result = MusicTrackNewMIDINoteEvent(sequenceTrack, (float)i/ticksPerBar, &noteMessage);
        //MusicTrackNewUserEvent( sequenceTrack, (float)i/ticksPerBar, (MusicEventUserData *)&event);
    }


    MusicTrackLoopInfo loopInfo = { 8.0f, 0 };
    result = MusicTrackSetProperty(sequenceTrack, kSequenceTrackProperty_LoopInfo, &loopInfo, sizeof(MusicTrackLoopInfo));

    MusicPlayerPreroll(p);
     MusicPlayerStart(p);
     
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)

This email sent to email@hidden


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: MusicTrack timing and looping issues.
      • From: James Maxwell <email@hidden>
References: 
 >Handling App Interruptions - AudioUnit fails to restart (From: Joe White <email@hidden>)
 >MusicTrack timing and looping issues. (From: Ben <email@hidden>)
 >Re: MusicTrack timing and looping issues. (From: Douglas Scott <email@hidden>)

  • Prev by Date: Re: ioMainBuffer invalid?
  • Next by Date: kAudioUnitSubType_Merger on iOS
  • Previous by thread: Re: MusicTrack timing and looping issues.
  • Next by thread: Re: MusicTrack timing and looping issues.
  • Index(es):
    • Date
    • Thread