Skip to content

Commit

Permalink
Added maximumLookAheadInterval property to MIKMIDISequencer
Browse files Browse the repository at this point in the history
  • Loading branch information
kris2point0 committed Mar 17, 2016
1 parent c4956d9 commit ac8142b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
9 changes: 9 additions & 0 deletions Source/MIKMIDISequencer.h
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,15 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (nonatomic, readonly) MIDITimeStamp latestScheduledMIDITimeStamp;


/**
* The maximum amount the sequencer will look ahead to schedule MIDI events. (0.05 to 1s).
*
* The default of 0.1s should suffice for most uses. You may however, need a longer time
* if your sequencer needs to playback on iOS while the device is locked.
*/
@property (nonatomic) NSTimeInterval maximumLookAheadInterval;

#pragma mark - Deprecated

/**
Expand Down
8 changes: 7 additions & 1 deletion Source/MIKMIDISequencer.m
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ - (instancetype)initWithSequence:(MIKMIDISequence *)sequence
_createSynthsIfNeeded = YES;
_processingQueueKey = &_processingQueueKey;
_processingQueueContext = &_processingQueueContext;
_maximumLookAheadInterval = 0.1;
}
return self;
}
Expand Down Expand Up @@ -275,7 +276,7 @@ - (void)stopWithDispatchToProcessingQueue:(BOOL)dispatchToProcessingQueue

- (void)processSequenceStartingFromMIDITimeStamp:(MIDITimeStamp)fromMIDITimeStamp
{
MIDITimeStamp toMIDITimeStamp = MIKMIDIGetCurrentTimeStamp() + MIKMIDIClockMIDITimeStampsPerTimeInterval(0.1);
MIDITimeStamp toMIDITimeStamp = MIKMIDIGetCurrentTimeStamp() + MIKMIDIClockMIDITimeStampsPerTimeInterval(self.maximumLookAheadInterval);
if (toMIDITimeStamp < fromMIDITimeStamp) return;
MIKMIDIClock *clock = self.clock;

Expand Down Expand Up @@ -820,6 +821,11 @@ - (void)setSequence:(MIKMIDISequence *)sequence
}
}

- (void)setMaximumLookAheadInterval:(NSTimeInterval)maximumLookAheadInterval
{
_maximumLookAheadInterval = MIN(MAX(maximumLookAheadInterval, 0.05), 1.0);
}

#pragma mark - Deprecated

- (void)setDestinationEndpoint:(MIKMIDIDestinationEndpoint *)endpoint forTrack:(MIKMIDITrack *)track
Expand Down

0 comments on commit ac8142b

Please sign in to comment.