MIKMIDIClock
Objective-C
@interface MIKMIDIClock : NSObject
Swift
class MIKMIDIClock : NSObject
MIKMIDIClock provides the number of seconds per MIDITimeStamp, as well as the number of MIDITimeStamps per a specified time interval.
Instances of MIKMIDIClock can be used to convert between MIDITimeStamp and MusicTimeStamp.
-
Creates and initializes a new instance of MIKMIDIClock.
Declaration
Objective-C
+ (nonnull instancetype)clock;
Return Value
A new instance of MIKMIDIClock.
-
Internally synchronizes the musicTimeStamp with the midiTimeStamp using the specified tempo. This method must be called for the clock to become ready to use.
Note
When this method is called, historical tempo and timing information more than 1 second old is pruned. At that point, calls to -musicTimeStampForMIDITimeStamp:, -midiTimeStampForMusicTimeStamp:, -tempoAtMIDITimeStamp:, and -tempoAtMusicTimeStamp: with time stamps more than one second older than the time stamps set with this method may not necessarily return accurate information.
See
-unsyncMusicTimeStampsAndTemposFromMIDITimeStampsSee
-isReady
Declaration
Objective-C
- (void)syncMusicTimeStamp:(MusicTimeStamp)musicTimeStamp withMIDITimeStamp:(MIDITimeStamp)midiTimeStamp tempo:(Float64)tempo;
Swift
func syncMusicTimeStamp(_ musicTimeStamp: MusicTimeStamp, withMIDITimeStamp midiTimeStamp: MIDITimeStamp, tempo: Float64)
Parameters
musicTimeStamp
The MusicTimeStamp to synchronize the clock to.
midiTimeStamp
The MIDITimeStamp to synchronize the clock to.
tempo
The beats per minute at which MusicTimeStamps should tick.
-
Internally unsynchronizes the tempo and MusicTimeStamp information with MIDITimeStamps.
See
-syncMusicTimeStamp:withMIDITimeStamp:tempo:See
-isReadyDeclaration
Objective-C
- (void)unsyncMusicTimeStampsAndTemposFromMIDITimeStamps;
Swift
func unsyncMusicTimeStampsAndTemposFromMIDITimeStamps()
-
Converts the specified MIDITimeStamp into the corresponding MusicTimeStamp.
Note
If the clock is not ready this method will return 0.
See
-isReady
Declaration
Objective-C
- (MusicTimeStamp)musicTimeStampForMIDITimeStamp:(MIDITimeStamp)midiTimeStamp;
Swift
func musicTimeStamp(forMIDITimeStamp midiTimeStamp: MIDITimeStamp) -> MusicTimeStamp
Parameters
midiTimeStamp
The MIDITimeStamp to convert into a MusicTimeStamp.
Return Value
The MusicTimeStamp that will occur at the same time as the specified MIDITimeStamp.
-
Converts the specified MusicTimeStamp into the corresponding MIDITimeStamp.
Note
If the clock is not ready this method will return 0.
See
-isReady
Declaration
Objective-C
- (MIDITimeStamp)midiTimeStampForMusicTimeStamp:(MusicTimeStamp)musicTimeStamp;
Swift
func midiTimeStamp(forMusicTimeStamp musicTimeStamp: MusicTimeStamp) -> MIDITimeStamp
Parameters
musicTimeStamp
The MusicTimeStamp to convert into a MIDITimeStamp.
Return Value
The MIDITimeStamp that will occur at the same time as the specified MusicTimeStamp.
-
Converts the specified number of beats in the MusicTimeStamp into the corresponding number of MIDITimeStamps.
Note
If the clock is not ready this method will return 0.
See
-isReady
Declaration
Objective-C
- (MIDITimeStamp)midiTimeStampsPerMusicTimeStamp:(MusicTimeStamp)musicTimeStamp;
Swift
func midiTimeStampsPerMusicTimeStamp(_ musicTimeStamp: MusicTimeStamp) -> MIDITimeStamp
Parameters
musicTimeStamp
The number of beats to convert into MIDITimeStamps.
Return Value
The number of MIDITimeStamps that will occur during the specified number of beats.
-
A readonly copy of the clock that remains synced with this instance.
This clock can be queried and will always return the same tempo and timing information as the clock instance that dispensed the synced clock.
Calling -syncMusicTimeStamp:withMIDITimeStamp:tempo: or -unsyncMusicTimeStampsAndTemposFromMIDITimeStamps on the synced clock has no effect.
Declaration
Objective-C
- (nonnull MIKMIDIClock *)syncedClock;
Swift
func synced() -> MIKMIDIClock
-
Returns the tempo of the clock at the specified MIDITimeStamp.
Note
If the clock is not ready this method will return 0.
See
-isReady
Declaration
Objective-C
- (Float64)tempoAtMIDITimeStamp:(MIDITimeStamp)midiTimeStamp;
Swift
func tempo(atMIDITimeStamp midiTimeStamp: MIDITimeStamp) -> Float64
Parameters
midiTimeStamp
The MIDITimeStamp you would like the clock’s tempo for.
Return Value
The tempo of the clock at the specified MIDITimeStamp.
-
Returns the tempo of the clock at the specified MusicTimeStamp.
Note
If the clock is not ready this method will return 0.
See
-isReady
Declaration
Objective-C
- (Float64)tempoAtMusicTimeStamp:(MusicTimeStamp)musicTimeStamp;
Swift
func tempo(atMusicTimeStamp musicTimeStamp: MusicTimeStamp) -> Float64
Parameters
musicTimeStamp
The MusicTimeStamp you would like the clock’s tempo for.
Return Value
The tempo of the clock at the specified MusicTimeStamp.
-
Whether or not the clock has synchronized MusicTimeStamps and MIDITimeStamps
and is ready to use for getting tempo and timing information.
- - see: --syncMusicTimeStamp:withMIDITimeStamp:tempo: - - see: --unsyncMusicTimeStampsAndTemposFromMIDITimeStamps
Declaration
Objective-C
@property (nonatomic, readonly, getter=isReady) BOOL ready;
Swift
var isReady: Bool { get }
-
The tempo that was set in the last call to -syncMusicTimeStamp:withMIDITimeStamp:tempo: or 0 if the clock is not ready.
If you need earlier tempo information use either -tempoAtMIDITimeStamp: or -tempoAtMusicTimeStamp:
See
-isReadyDeclaration
Objective-C
@property (nonatomic, readonly) Float64 currentTempo;
Swift
var currentTempo: Float64 { get }
-
Deprecated
@deprecated This method is deprecated. Use -[MIKMIDIClock syncMusicTimeStamp:withMIDITimeStamp:tempo:] instead.
Internally synchronizes the musicTimeStamp with the midiTimeStamp using the specified tempo. This method must be called at least once before -musicTimeStampForMIDITimeStamp: and -midiTimeStampForMusicTimeStamp: will return any meaningful values.
Note
When this method is called, historical tempo and timing information more than 1 second old is pruned. At that point, calls to -musicTimeStampForMIDITimeStamp:, -midiTimeStampForMusicTimeStamp:, -tempoAtMIDITimeStamp:, and -tempoAtMusicTimeStamp: with time stamps more than one second older than the time stamps set with this method may not necessarily return accurate information.
See
-musicTimeStampForMIDITimeStamp:
See
-midiTimeStampForMusicTimeStamp:
Declaration
Objective-C
- (void)setMusicTimeStamp:(MusicTimeStamp)musicTimeStamp withTempo:(Float64)tempo atMIDITimeStamp:(MIDITimeStamp)midiTimeStamp;
Swift
func setMusicTimeStamp(_ musicTimeStamp: MusicTimeStamp, withTempo tempo: Float64, atMIDITimeStamp midiTimeStamp: MIDITimeStamp)
Parameters
musicTimeStamp
The MusicTimeStamp to synchronize the clock to.
tempo
The beats per minute at which MusicTimeStamps should tick.
midiTimeStamp
The MIDITimeStamp to synchronize the clock to.
-
Deprecated
@deprecated This method is deprecated. Use MIKMIDIClockSecondsPerMIDITimeStamp() instead.
Returns the number of seconds per each MIDITimeStamp.
Declaration
Objective-C
+ (Float64)secondsPerMIDITimeStamp;
Swift
class func secondsPerMIDITimeStamp() -> Float64
Return Value
Then number of seconds per each MIDITimeStamp.
-
Deprecated
@deprecated This method is deprecated. Use MIKMIDIClockMIDITimeStampsPerTimeInterval() instead.
Returns the number of MIDITimeStamps that would occur during a specified time interval.
Declaration
Objective-C
+ (Float64)midiTimeStampsPerTimeInterval:(NSTimeInterval)timeInterval;
Swift
class func midiTimeStampsPerTimeInterval(_ timeInterval: TimeInterval) -> Float64
Parameters
timeInterval
The number of seconds to convert into number of MIDITimeStamps.
Return Value
The number of MIDITimeStamps that would occur in the specified time interval.