Skip to content

Commit

Permalink
Issue #99: Made MIKMIDITrack's offset property use an instance variab…
Browse files Browse the repository at this point in the history
…le in addition to using MUsicTrack property.
  • Loading branch information
Andrew Madsen committed Mar 8, 2016
1 parent 44b2b58 commit f05760c
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions Source/MIKMIDITrack.m
Original file line number Diff line number Diff line change
Expand Up @@ -616,19 +616,31 @@ - (NSInteger)trackNumber
return (NSInteger)trackNumber;
}

@synthesize offset = _offset;

- (MusicTimeStamp)offset
{
MusicTimeStamp offset = 0;
UInt32 offsetLength = sizeof(offset);
OSStatus err = MusicTrackGetProperty(self.musicTrack, kSequenceTrackProperty_OffsetTime, &offset, &offsetLength);
if (err) NSLog(@"MusicTrackGetProperty() failed with error %@ in %s.", @(err), __PRETTY_FUNCTION__);
return offset;
if (_offset != 0) return _offset;

if (self.musicTrack) {
MusicTimeStamp offset = 0;
UInt32 offsetLength = sizeof(offset);
OSStatus err = MusicTrackGetProperty(self.musicTrack, kSequenceTrackProperty_OffsetTime, &offset, &offsetLength);
if (err) NSLog(@"MusicTrackGetProperty() failed with error %@ in %s.", @(err), __PRETTY_FUNCTION__);
return offset;
} else {
return 0;
}
}

- (void)setOffset:(MusicTimeStamp)offset
{
OSStatus err = MusicTrackSetProperty(self.musicTrack, kSequenceTrackProperty_OffsetTime, &offset, sizeof(offset));
if (err) NSLog(@"MusicTrackSetProperty() failed with error %@ in %s.", @(err), __PRETTY_FUNCTION__);
_offset = offset;

if (self.musicTrack) {
OSStatus err = MusicTrackSetProperty(self.musicTrack, kSequenceTrackProperty_OffsetTime, &offset, sizeof(offset));
if (err) NSLog(@"MusicTrackSetProperty() failed with error %@ in %s.", @(err), __PRETTY_FUNCTION__);
}
}

@synthesize muted = _muted;
Expand Down

0 comments on commit f05760c

Please sign in to comment.