Skip to content

Commit

Permalink
Issue #94: Added a way for MIKMIDISequencer subclasses to modify pars…
Browse files Browse the repository at this point in the history
…ed MIDI commands before they get sent to their destinations.
  • Loading branch information
kris2point0 committed Jun 10, 2015
1 parent a22c679 commit 80eb882
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Source/MIKMIDISequencer.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,23 @@ typedef NS_ENUM(NSInteger, MIKMIDISequencerClickTrackStatus) {
*/
- (void)recordMIDICommand:(MIKMIDICommand *)command;

/**
* Allows subclasses to modify the MIDI commands that are about to be
* scheduled with a destination endpoint.
*
* @param commandsToBeScheduled An array of MIKMIDICommands that are about
* to be scheduled.
*
* @param endpoint The destination endpoint the commands will be sent to after
* they are modified.
*
* @note You should not call this method directly. It is made public solely to
* give subclasses a chance to alter or override any MIDI commands parsed from the
* MIDI sequence before they get sent to their destination endpoint.
*
*/
- (NSArray *)modifiedMIDICommandsFromCommandsToBeScheduled:(NSArray *)commandsToBeScheduled forEndpoint:(MIKMIDIDestinationEndpoint *)endpoint;

#pragma mark - Configuration

/**
Expand Down
4 changes: 4 additions & 0 deletions Source/MIKMIDISequencer.m
Original file line number Diff line number Diff line change
Expand Up @@ -401,12 +401,16 @@ - (void)updateClockWithMusicTimeStamp:(MusicTimeStamp)musicTimeStamp tempo:(Floa

- (void)sendCommands:(NSArray *)commands toDestinationEndpoint:(MIKMIDIDestinationEndpoint *)endpoint
{
commands = [self modifiedMIDICommandsFromCommandsToBeScheduled:commands forEndpoint:endpoint];

NSError *error;
if (commands.count && ![[MIKMIDIDeviceManager sharedDeviceManager] sendCommands:commands toEndpoint:endpoint error:&error]) {
NSLog(@"%@: An error occurred scheduling the commands %@ for destination endpoint %@. %@", NSStringFromClass([self class]), commands, endpoint, error);
}
}

- (NSArray *)modifiedMIDICommandsFromCommandsToBeScheduled:(NSArray *)commandsToBeScheduled forEndpoint:(MIKMIDIDestinationEndpoint *)endpoint { return commandsToBeScheduled; }

#pragma mark - Recording

- (void)startRecording
Expand Down

0 comments on commit 80eb882

Please sign in to comment.