forked from mixedinkey-opensource/MIKMIDI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMIKMIDISequence.m
583 lines (471 loc) · 18.5 KB
/
MIKMIDISequence.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
//
// MIKMIDISequence.m
// MIDI Files Testbed
//
// Created by Andrew Madsen on 5/21/14.
// Copyright (c) 2014 Mixed In Key. All rights reserved.
//
#import "MIKMIDISequence.h"
#import <AudioToolbox/AudioToolbox.h>
#import "MIKMIDITrack.h"
#import "MIKMIDITrack_Protected.h"
#import "MIKMIDITempoEvent.h"
#import "MIKMIDIMetaTimeSignatureEvent.h"
#import "MIKMIDIDestinationEndpoint.h"
#import "MIKMIDISequence+MIKMIDIPrivate.h"
#import "MIKMIDISequencer+MIKMIDIPrivate.h"
#import "MIKMIDIErrors.h"
#if !__has_feature(objc_arc)
#error MIKMIDISequence.m must be compiled with ARC. Either turn on ARC for the project or set the -fobjc-arc flag for MIKMIDISequence.m in the Build Phases for this target
#endif
void * MIKMIDISequenceKVOContext = &MIKMIDISequenceKVOContext;
const MusicTimeStamp MIKMIDISequenceLongestTrackLength = -1;
@interface MIKMIDISequence ()
{
//MIKMIDISequencer *_sequencer;
}
@property (nonatomic, weak) MIKMIDISequencer *sequencer; // RRC2Soft -> We had a memory leak here!
@property (nonatomic) MusicSequence musicSequence;
@property (nonatomic, strong) MIKMIDITrack *tempoTrack;
@property (nonatomic, strong) NSMutableArray *internalTracks;
@property (nonatomic) MusicTimeStamp lengthDefinedByTracks;
@end
@implementation MIKMIDISequence
#pragma mark - Lifecycle
+ (instancetype)sequence
{
return [[self alloc] init];
}
- (instancetype)init
{
MusicSequence sequence;
OSStatus err = NewMusicSequence(&sequence);
if (err) {
NSLog(@"NewMusicSequence() failed with error %@ in %s.", @(err), __PRETTY_FUNCTION__);
return nil;
}
return [self initWithMusicSequence:sequence error:NULL];
}
+ (instancetype)sequenceWithFileAtURL:(NSURL *)fileURL error:(NSError **)error;
{
return [[self alloc] initWithFileAtURL:fileURL convertMIDIChannelsToTracks:NO error:error];
}
+ (instancetype)sequenceWithFileAtURL:(NSURL *)fileURL convertMIDIChannelsToTracks:(BOOL)convertMIDIChannelsToTracks error:(NSError **)error
{
return [[self alloc] initWithFileAtURL:fileURL convertMIDIChannelsToTracks:convertMIDIChannelsToTracks error:error];
}
- (instancetype)initWithFileAtURL:(NSURL *)fileURL error:(NSError **)error;
{
return [self initWithFileAtURL:fileURL convertMIDIChannelsToTracks:NO error:error];
}
- (instancetype)initWithFileAtURL:(NSURL *)fileURL convertMIDIChannelsToTracks:(BOOL)convertMIDIChannelsToTracks error:(NSError **)error
{
NSData *data = [NSData dataWithContentsOfURL:fileURL options:0 error:error];
if (!data) return nil;
return [self initWithData:data convertMIDIChannelsToTracks:convertMIDIChannelsToTracks error:error];
}
+ (instancetype)sequenceWithData:(NSData *)data error:(NSError **)error
{
return [[self alloc] initWithData:data convertMIDIChannelsToTracks:NO error:error];
}
+ (instancetype)sequenceWithData:(NSData *)data convertMIDIChannelsToTracks:(BOOL)convertMIDIChannelsToTracks error:(NSError **)error
{
return [[self alloc] initWithData:data convertMIDIChannelsToTracks:convertMIDIChannelsToTracks error:error];
}
- (instancetype)initWithData:(NSData *)data error:(NSError **)error
{
return [self initWithData:data convertMIDIChannelsToTracks:NO error:error];
}
- (instancetype)initWithData:(NSData *)data convertMIDIChannelsToTracks:(BOOL)convertMIDIChannelsToTracks error:(NSError **)error
{
error = error ?: &(NSError *__autoreleasing){ nil };
MusicSequence sequence;
OSStatus err = NewMusicSequence(&sequence);
if (err) {
NSLog(@"NewMusicSequence() failed with error %@ in %s.", @(err), __PRETTY_FUNCTION__);
*error = [NSError errorWithDomain:NSOSStatusErrorDomain code:err userInfo:nil];
return nil;
}
MusicSequenceLoadFlags flags = convertMIDIChannelsToTracks ? kMusicSequenceLoadSMF_ChannelsToTracks : 0;
err = MusicSequenceFileLoadData(sequence, (__bridge CFDataRef)data, kMusicSequenceFile_MIDIType, flags);
if (err) {
NSLog(@"MusicSequenceFileLoadData() failed with error %@ in %s.", @(err), __PRETTY_FUNCTION__);
*error = [NSError errorWithDomain:NSOSStatusErrorDomain code:err userInfo:nil];
return nil;
}
return [self initWithMusicSequence:sequence error:error];
}
+ (instancetype)sequenceWithMusicSequence:(MusicSequence)musicSequence error:(NSError **)error
{
return [[self alloc] initWithMusicSequence:musicSequence error:error];
}
- (instancetype)initWithMusicSequence:(MusicSequence)musicSequence error:(NSError **)error
{
error = error ? error : &(NSError *__autoreleasing){ nil };
if (self = [super init]) {
OSStatus err = MusicSequenceSetUserCallback(musicSequence, MIKSequenceCallback, (__bridge void *)self);
if (err) {
NSLog(@"MusicSequenceSetUserCallback() failed with error %@ in %s.", @(err), __PRETTY_FUNCTION__);
*error = [NSError errorWithDomain:NSOSStatusErrorDomain code:err userInfo:nil];
return nil;
}
self.musicSequence = musicSequence;
MusicTrack tempoTrack;
err = MusicSequenceGetTempoTrack(musicSequence, &tempoTrack);
if (err) {
NSLog(@"MusicSequenceGetTempoTrack() failed with error %@ in %s.", @(err), __PRETTY_FUNCTION__);
*error = [NSError errorWithDomain:NSOSStatusErrorDomain code:err userInfo:nil];
return nil;
}
self.tempoTrack = [MIKMIDITrack trackWithSequence:self musicTrack:tempoTrack];
UInt32 numTracks = 0;
err = MusicSequenceGetTrackCount(musicSequence, &numTracks);
if (err) {
NSLog(@"MusicSequenceGetTrackCount() failed with error %@ in %s.", @(err), __PRETTY_FUNCTION__);
*error = [NSError errorWithDomain:NSOSStatusErrorDomain code:err userInfo:nil];
return nil;
}
NSMutableArray *tracks = [NSMutableArray arrayWithCapacity:numTracks];
for (UInt32 i = 0; i < numTracks; i++) {
MusicTrack musicTrack;
err = MusicSequenceGetIndTrack(musicSequence, i, &musicTrack);
if (err){
NSLog(@"MusicSequenceGetIndTrack() failed with error %@ in %s.", @(err), __PRETTY_FUNCTION__);
*error = [NSError errorWithDomain:NSOSStatusErrorDomain code:err userInfo:nil];
return nil;
}
[tracks addObject:[MIKMIDITrack trackWithSequence:self musicTrack:musicTrack]];
}
self.internalTracks = tracks;
self.length = MIKMIDISequenceLongestTrackLength;
}
return self;
}
- (void)dealloc
{
NSArray *tracks = self.internalTracks;
self.internalTracks = nil; // Unregister for KVO
[self setCallBackBlock:^(MIKMIDITrack *t, MusicTimeStamp ts, const MusicEventUserData *ud, MusicTimeStamp ts2, MusicTimeStamp ts3) {}];
for (MIKMIDITrack *track in tracks) {
OSStatus err = MusicSequenceDisposeTrack(_musicSequence, track.musicTrack);
if (err) NSLog(@"MusicSequenceDisposeTrack() failed with error %@ in %s.", @(err), __PRETTY_FUNCTION__);
}
OSStatus err = DisposeMusicSequence(_musicSequence);
if (err) NSLog(@"DisposeMusicSequence() failed with error %@ in %s.", @(err), __PRETTY_FUNCTION__);
}
#pragma mark - Sequencer Synchronization
- (void)dispatchSyncToSequencerProcessingQueueAsNeeded:(void (^)())block
{
if (!block) return;
MIKMIDISequencer *sequencer = self.sequencer;
if (sequencer) {
[sequencer dispatchSyncToProcessingQueueAsNeeded:block];
} else {
block();
}
}
#pragma mark - Adding and Removing Tracks
- (MIKMIDITrack *)addTrackWithError:(NSError **)error
{
__block MIKMIDITrack *track = nil;
error = error ?: &(NSError *__autoreleasing){ nil };
[self dispatchSyncToSequencerProcessingQueueAsNeeded:^{
MusicTrack musicTrack;
OSStatus err = MusicSequenceNewTrack(self.musicSequence, &musicTrack);
if (err) {
NSLog(@"MusicSequenceNewTrack() failed with error %@ in %s.", @(err), __PRETTY_FUNCTION__);
NSError *underlyingError = [NSError errorWithDomain:NSOSStatusErrorDomain code:err userInfo:nil];
NSDictionary *userInfo = @{NSUnderlyingErrorKey : underlyingError};
*error = [NSError MIKMIDIErrorWithCode:MIKMIDISequenceAddTrackFailedErrorCode userInfo:userInfo];
return;
};
track = [MIKMIDITrack trackWithSequence:self musicTrack:musicTrack];
[self insertObject:track inInternalTracksAtIndex:[self.internalTracks count]];
}];
return track;
}
- (MIKMIDITrack *)addTrack
{
return [self addTrackWithError:NULL];
}
- (BOOL)removeTrack:(MIKMIDITrack *)track
{
if (!track) return NO;
__block BOOL success = NO;
[self dispatchSyncToSequencerProcessingQueueAsNeeded:^{
OSStatus err = MusicSequenceDisposeTrack(self.musicSequence, track.musicTrack);
if (err) return NSLog(@"MusicSequenceDisposeTrack() failed with error %@ in %s.", @(err), __PRETTY_FUNCTION__);
NSInteger index = [self.internalTracks indexOfObject:track];
if (index != NSNotFound) [self removeObjectFromInternalTracksAtIndex:index];
success = YES;
}];
return success;
}
#pragma mark - File Saving
- (BOOL)writeToURL:(NSURL *)fileURL error:(NSError *__autoreleasing *)error
{
return [self.dataValue writeToURL:fileURL options:NSDataWritingAtomic error:error];
}
#pragma mark - Callback
static void MIKSequenceCallback(void *inClientData, MusicSequence inSequence, MusicTrack inTrack, MusicTimeStamp inEventTime, const MusicEventUserData *inEventData, MusicTimeStamp inStartSliceBeat, MusicTimeStamp inEndSliceBeat)
{
MIKMIDISequence *self = (__bridge MIKMIDISequence *)inClientData;
if (!self.callBackBlock) return;
UInt32 trackIndex;
OSStatus err = MusicSequenceGetTrackIndex(inSequence, inTrack, &trackIndex);
if (err) {
NSLog(@"MusicSequenceGetTrackIndex() failed with error %@ in %s.", @(err), __PRETTY_FUNCTION__);
return;
}
MIKMIDITrack *track = self.tracks[trackIndex];
if (track && self.callBackBlock) {
self.callBackBlock(track, inEventTime, inEventData, inStartSliceBeat, inEndSliceBeat);
}
}
#pragma mark - Looping
- (MusicTimeStamp)equivalentTimeStampForLoopedTimeStamp:(MusicTimeStamp)loopedTimeStamp
{
MusicTimeStamp length = self.length;
if (loopedTimeStamp > length) {
NSInteger numTimesLooped = (NSInteger)(loopedTimeStamp / length);
loopedTimeStamp -= (length * numTimesLooped);
}
return loopedTimeStamp;
}
#pragma mark - Tempo
- (NSArray *)tempoEvents
{
return [self.tempoTrack eventsOfClass:[MIKMIDITempoEvent class] fromTimeStamp:0 toTimeStamp:kMusicTimeStamp_EndOfTrack];
}
- (BOOL)setOverallTempo:(Float64)bpm
{
NSArray *timeSignatureEvents = [self timeSignatureEvents];
[self.tempoTrack removeAllEvents];
if ([self.tempoTrack.events count]) return NO;
[self.tempoTrack addEvents:timeSignatureEvents];
return [self setTempo:bpm atTimeStamp:0];
}
- (BOOL)setTempo:(Float64)bpm atTimeStamp:(MusicTimeStamp)timeStamp
{
[self.tempoTrack addEvent:[MIKMIDITempoEvent tempoEventWithTimeStamp:timeStamp tempo:bpm]];
return YES;
}
- (Float64)tempoAtTimeStamp:(MusicTimeStamp)timeStamp
{
__block Float64 tempo = 0;
[self dispatchSyncToSequencerProcessingQueueAsNeeded:^{
NSArray *events;
if (timeStamp < 0) {
events = [self.tempoTrack eventsOfClass:[MIKMIDITempoEvent class] fromTimeStamp:0 toTimeStamp:0];
} else {
events = [self.tempoTrack eventsOfClass:[MIKMIDITempoEvent class] fromTimeStamp:0 toTimeStamp:timeStamp];
}
tempo = [[events lastObject] bpm];
}];
return tempo;
}
#pragma mark - Time Signature
- (NSArray *)timeSignatureEvents
{
return [self.tempoTrack eventsOfClass:[MIKMIDIMetaTimeSignatureEvent class] fromTimeStamp:0 toTimeStamp:kMusicTimeStamp_EndOfTrack];
}
- (BOOL)setOverallTimeSignature:(MIKMIDITimeSignature)signature
{
NSArray *tempoEvents = [self tempoEvents];
[self.tempoTrack removeAllEvents];
if ([self.tempoTrack.events count]) return NO;
[self.tempoTrack addEvents:tempoEvents];
return [self setTimeSignature:signature atTimeStamp:0];
}
- (BOOL)setTimeSignature:(MIKMIDITimeSignature)signature atTimeStamp:(MusicTimeStamp)timeStamp
{
MIKMutableMIDIMetaTimeSignatureEvent *event = [[MIKMutableMIDIMetaTimeSignatureEvent alloc] init];
event.timeStamp = timeStamp;
event.numerator = signature.numerator;
event.denominator = signature.denominator;
event.metronomePulse = (UInt8)self.tempoTrack.timeResolution;
event.thirtySecondsPerQuarterNote = 8;
[self.tempoTrack addEvent:event];
return YES;
}
- (MIKMIDITimeSignature)timeSignatureAtTimeStamp:(MusicTimeStamp)timeStamp
{
MIKMIDITimeSignature result = {4, 4};
NSArray *events;
if (timeStamp < 0) {
events = [self.tempoTrack eventsOfClass:[MIKMIDIMetaTimeSignatureEvent class] fromTimeStamp:0 toTimeStamp:0];
} else {
events = [self.tempoTrack eventsOfClass:[MIKMIDIMetaTimeSignatureEvent class] fromTimeStamp:0 toTimeStamp:timeStamp];
}
MIKMIDIMetaTimeSignatureEvent *event = [events lastObject];
if (event) {
result.numerator = event.numerator;
result.denominator = event.denominator;
}
return result;
}
#pragma mark - Description
- (NSString *)description
{
return [NSString stringWithFormat:@"%@ tempo track: %@ tracks: %@", [super description], self.tempoTrack, self.tracks];
}
#pragma mark - KVO
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if (context != MIKMIDISequenceKVOContext) {
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
return;
}
if ([self.internalTracks containsObject:object] &&
([keyPath isEqualToString:@"length"] || [keyPath isEqualToString:@"offset"])) {
[self updateLengthDefinedByTracks];
}
}
- (void)updateLengthDefinedByTracks
{
MusicTimeStamp length = 0;
for (MIKMIDITrack *track in self.tracks) {
MusicTimeStamp trackLength = track.length + track.offset;
if (trackLength > length) length = trackLength;
}
self.lengthDefinedByTracks = length;
}
#pragma mark - Properties
- (void)setInternalTracks:(NSMutableArray *)internalTracks
{
if (internalTracks != _internalTracks) {
for (MIKMIDITrack *track in _internalTracks) {
[track removeObserver:self forKeyPath:@"length"];
[track removeObserver:self forKeyPath:@"offset"];
}
_internalTracks = internalTracks;
for (MIKMIDITrack *track in _internalTracks) {
[track addObserver:self forKeyPath:@"length" options:NSKeyValueObservingOptionInitial context:MIKMIDISequenceKVOContext];
[track addObserver:self forKeyPath:@"offset" options:NSKeyValueObservingOptionInitial context:MIKMIDISequenceKVOContext];
}
}
}
- (void)insertObject:(MIKMIDITrack *)track inInternalTracksAtIndex:(NSUInteger)index
{
if (!track) return;
[self willChange:NSKeyValueChangeInsertion valuesAtIndexes:[NSIndexSet indexSetWithIndex:index] forKey:@"tracks"];
[self.internalTracks insertObject:track atIndex:index];
[self didChange:NSKeyValueChangeInsertion valuesAtIndexes:[NSIndexSet indexSetWithIndex:index] forKey:@"tracks"];
[track addObserver:self forKeyPath:@"length" options:NSKeyValueObservingOptionInitial context:MIKMIDISequenceKVOContext];
[track addObserver:self forKeyPath:@"offset" options:NSKeyValueObservingOptionInitial context:MIKMIDISequenceKVOContext];
}
- (void)removeObjectFromInternalTracksAtIndex:(NSUInteger)index
{
if (index >= [self.internalTracks count]) return;
MIKMIDITrack *track = self.internalTracks[index];
[self willChange:NSKeyValueChangeRemoval valuesAtIndexes:[NSIndexSet indexSetWithIndex:index] forKey:@"tracks"];
[self.internalTracks removeObjectAtIndex:index];
[self didChange:NSKeyValueChangeRemoval valuesAtIndexes:[NSIndexSet indexSetWithIndex:index] forKey:@"tracks"];
[track removeObserver:self forKeyPath:@"length"];
[track removeObserver:self forKeyPath:@"offset"];
[self updateLengthDefinedByTracks];
}
+ (BOOL)automaticallyNotifiesObserversOfTracks { return NO; }
- (NSArray *)tracks
{
__block NSArray *tracks;
[self dispatchSyncToSequencerProcessingQueueAsNeeded:^{
tracks = self.internalTracks;
}];
return tracks ?: @[];
}
+ (NSSet *)keyPathsForValuesAffectingLength
{
return [NSSet setWithObjects:@"lengthDefinedByTracks", nil];
}
@synthesize length = _length;
- (MusicTimeStamp)length
{
__block MusicTimeStamp length = 0;
[self dispatchSyncToSequencerProcessingQueueAsNeeded:^{
length = (_length == MIKMIDISequenceLongestTrackLength) ? self.lengthDefinedByTracks : _length;
}];
return length;
}
- (void)setLength:(MusicTimeStamp)length
{
[self dispatchSyncToSequencerProcessingQueueAsNeeded:^{
_length = length;
}];
}
+ (NSSet *)keyPathsForValuesAffectingDurationInSeconds
{
return [NSSet setWithObjects:@"length", nil];
}
- (Float64)durationInSeconds
{
Float64 duration = 0;
OSStatus err = MusicSequenceGetSecondsForBeats(self.musicSequence, self.length, &duration);
if (err) NSLog(@"MusicSequenceGetSecondsForBeats() failed with error %@ in %s.", @(err), __PRETTY_FUNCTION__);
return duration;
}
- (NSData *)dataValue
{
CFDataRef data;
OSStatus err = MusicSequenceFileCreateData(self.musicSequence, kMusicSequenceFile_MIDIType, 0, 0, &data);
if (err) {
NSLog(@"MusicSequenceFileCreateData() failed with error %@ in %s.", @(err), __PRETTY_FUNCTION__);
return nil;
}
return (__bridge_transfer NSData *)data;
}
- (MIKMIDISequencer *)sequencer { return _sequencer; }
#pragma mark - Deprecated
+ (instancetype)sequenceWithData:(NSData *)data
{
NSLog(@"%s is deprecated."
"You should update your code to avoid calling this method."
"Use +sequenceWithData:error: instead.", __PRETTY_FUNCTION__);
return [self sequenceWithData:data error:NULL];
}
- (instancetype)initWithData:(NSData *)data
{
NSLog(@"%s is deprecated."
"You should update your code to avoid calling this method."
"Use -initWithData:error: instead.", __PRETTY_FUNCTION__);
return [self initWithData:data error:NULL];
}
- (void)setDestinationEndpoint:(MIKMIDIDestinationEndpoint *)destinationEndpoint
{
NSLog(@"%s is deprecated. You should update your code to avoid calling this method. Use MIKMIDISequencer's API instead.", __PRETTY_FUNCTION__);
for (MIKMIDITrack *track in self.tracks) {
track.destinationEndpoint = destinationEndpoint;
}
}
- (BOOL)getTempo:(Float64 *)bpm atTimeStamp:(MusicTimeStamp)timeStamp
{
static BOOL deprectionMsgShown = NO;
if (!deprectionMsgShown) {
NSLog(@"WARNING: %s has been deprecated. Please use -timeSignatureAtTimeStamp: instead. This message will only be logged once", __PRETTY_FUNCTION__);
deprectionMsgShown = YES;
}
if (!bpm) return NO;
Float64 result = [self tempoAtTimeStamp:timeStamp];
if (result == 0.0) return NO;
*bpm = result;
return YES;
}
- (BOOL)getTimeSignature:(MIKMIDITimeSignature *)signature atTimeStamp:(MusicTimeStamp)timeStamp
{
static BOOL deprectionMsgShown = NO;
if (!deprectionMsgShown) {
NSLog(@"WARNING: %s has been deprecated. Please use -timeSignatureAtTimeStamp: instead. This message will only be logged once", __PRETTY_FUNCTION__);
deprectionMsgShown = YES;
}
if (!signature) return NO;
MIKMIDITimeSignature result = [self timeSignatureAtTimeStamp:timeStamp];
if (result.numerator == 0) return NO;
signature->numerator = result.numerator;
signature->denominator = result.denominator;
return YES;
}
@end
#pragma mark -
@implementation MIKMIDISequence (MIKMIDIPrivate)
- (void)setSequencer:(MIKMIDISequencer *)sequencer { _sequencer = sequencer; }
@end