MusicPlayer vol3 -MusicPlayer-

2011/11/26

MusicPlayer についての内容 ※間違いが含まれている場合があるので注意

NewMusicPlayer

/*! @function NewMusicPlayer @abstract Create a new music player @discussion A music player is used to play a sequence back. This call is used to create a player When a sequence is to be played by a player, it can play to either an AUGraph, a MIDI Destination or a mixture/combination of both. @param outPlayer the newly created player */ extern OSStatus NewMusicPlayer( MusicPlayer *outPlayer) __OSX_AVAILABLE_STARTING(__MAC_10_0,__IPHONE_5_0);

MusicPlayer は シーケンスを演奏する為に使われる。 この呼び出しは、新規 MusicPlayer の作成で利用。 シーケンスがプレイヤーで再生されるとき、「AUGraph」もしくは、「MIDI Destination とMixture/Combination」の両方のいずれかで再生可能。

DisposeMusicPlayer

/*!
    @function   DisposeMusicPlayer
    @abstract   Dispose a music player
    @param      inPlayer    the player to dispose
*/
extern OSStatus
DisposeMusicPlayer(     MusicPlayer     inPlayer)                               __OSX_AVAILABLE_STARTING(__MAC_10_0,__IPHONE_5_0);

MusicPlayer の処分をする。

MusicPlayerSetSequence

/*!
    @function   MusicPlayerSetSequence
    @abstract   Set the sequence for the player to play
    @discussion A Sequence cannot be set on a player while it is playing. Setting a sequence
                will overide the currently set sequence.
    @param      inPlayer    the player
    @param      inSequence  the sequence for the player to play
*/
extern OSStatus
MusicPlayerSetSequence( MusicPlayer     inPlayer,
                        MusicSequence   inSequence)                             __OSX_AVAILABLE_STARTING(__MAC_10_0,__IPHONE_5_0);

MusicPlayer に シーケンスを設定する。

MusicPlayerGetSequence

/*!
    @function   MusicPlayerGetSequence
    @abstract   Get the sequence attached to a player
    @discussion If the player does not have a sequence set, this will return the _NoSequence error
    @param      inPlayer    the player
    @param      outSequence the sequence currently set on the player
 
*/
extern OSStatus
MusicPlayerGetSequence( MusicPlayer     inPlayer,
                        MusicSequence   *outSequence)                           __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_5_0);

MusicPlayer の シーケンスを取得する。

MusicPlayerGetSequence

[cpp]
/*! @function MusicPlayerSetTime @abstract Set the current time on the player @discussion The Get and Set Time calls take a specification of time as beats. This positions the player to the specified time based on the currently set sequence. No range checking on the time value is done. This can be set on a playing player (in which case playing will be resumed from the new time). @param inPlayer the player @param inTime the new time value */ extern OSStatus MusicPlayerSetTime( MusicPlayer inPlayer, MusicTimeStamp inTime) __OSX_AVAILABLE_STARTING(__MAC_10_0,__IPHONE_5_0); MusicPlayer に MusicTimeStamp を設定する。

MusicPlayerGetTime

/*!
    @function   MusicPlayerGetTime
    @abstract   Get the current time of the player
    @discussion The Get and Set Time calls take a specification of time as beats. This retrieves the player's
                current time. If it is playing this time is the time of the player at the time the call was made. 
    @param      inPlayer    the player
    @param      outTime     the current time value
*/
extern OSStatus
MusicPlayerGetTime(     MusicPlayer     inPlayer,
                        MusicTimeStamp  *outTime)                               __OSX_AVAILABLE_STARTING(__MAC_10_0,__IPHONE_5_0);

MusicPlayer から MusicTimeStamp を取得する。

MusicPlayerGetHostTimeForBeats

/*!
    @function   MusicPlayerGetHostTimeForBeats
    @abstract   Returns the host time that will be (or was) played at the specified beat.
    @discussion This call is only valid if the player is playing and will return an error if the player is not playing
                or if the starting position of the player (its "starting beat") was after the specified beat.
                For general translation of beats to time in a sequence, see the MusicSequence calls for beat<->seconds.
                
                The call uses the player's sequence's tempo map to translate a beat time from the starting time and beat
                of the player.
    @param      inPlayer    the player
    @param      inBeats     the specified beat-time value
    @param      outHostTime the corresponding host time
*/
extern OSStatus
MusicPlayerGetHostTimeForBeats( MusicPlayer     inPlayer,
                                MusicTimeStamp  inBeats,
                                UInt64 *        outHostTime)                    __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_5_0);

MusicPlayer に拍数(MusicTimeStamp)を設定して、ホストタイムを取得する。

MusicPlayerGetBeatsForHostTime

/*!
    @function   MusicPlayerGetBeatsForHostTime
    @abstract   Returns the beat that will be (or was) played at the specified host time. 
    @discussion This call is only valid if the player is playing and will return an error if the player is not playing
                or if the starting time of the player was after the specified host time.
                For general translation of beats to time in a sequence, see the MusicSequence calls for beat<->seconds.
                
                The call uses the player's sequence's tempo map to retrieve a beat time from the starting and specified host time. 
                
    @param      inPlayer    the player
    @param      inHostTime  the specified host time value
    @param      outBeats    the corresponding beat time
*/
extern OSStatus
MusicPlayerGetBeatsForHostTime( MusicPlayer     inPlayer,
                                UInt64          inHostTime,
                                MusicTimeStamp *outBeats)                       __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_5_0);

MusicPlayer にホストタイムを設定して、拍数(MusicTimeStamp)を取得する。

MusicPlayerPreroll

/*!
    @function   MusicPlayerPreroll
    @abstract   Prepare the player for playing
    @discussion Allows the player to prepare its state so that starting is has a lower latency. If a player is started without
                being prerolled, the player will pre-roll itself and then start.
    @param      inPlayer    the player
*/
extern OSStatus
MusicPlayerPreroll(     MusicPlayer     inPlayer)                               __OSX_AVAILABLE_STARTING(__MAC_10_0,__IPHONE_5_0);

MusicPlayer の再生の準備をする。 再生する準備ができたプレイヤーは、ローレイテンシーを実現できる。 プリロールされずにスタートした場合、プレイヤーは自分自身をプリロールしてそれからスタートするかもしれない。

MusicPlayerStart

/*!
    @function   MusicPlayerStart
    @abstract   Start the player
    @discussion If the player has not been prerolled, it will pre-roll itself and then start.
    @param      inPlayer    the player
*/
extern OSStatus
MusicPlayerStart(       MusicPlayer     inPlayer)                               __OSX_AVAILABLE_STARTING(__MAC_10_0,__IPHONE_5_0);

MusicPlayer を再生する。

MusicPlayerStop

/*!
    @function   MusicPlayerStop
    @abstract   Stop the player
    @param      inPlayer    the player
*/
extern OSStatus
MusicPlayerStop(        MusicPlayer     inPlayer)                               __OSX_AVAILABLE_STARTING(__MAC_10_0,__IPHONE_5_0);

MusicPlayer を停止する。

MusicPlayerIsPlaying

// 
/*!
    @function   MusicPlayerIsPlaying
    @abstract   Returns the playing state of the player. "Is it playing?"
    @discussion This call returns a non-zero value in outIsPlaying if the player has been
                started and not stopped. It may have "played" past the events of the attached
                MusicSequence, but it is still considered to be playing (and its time value increasing)
                until it is explicitly stopped
    @param      inPlayer        the player
    @param      outIsPlaying    false if not, true (non-zero) if is playing
*/
extern OSStatus
MusicPlayerIsPlaying(   MusicPlayer     inPlayer,
                        Boolean *       outIsPlaying)                           __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_5_0);

MusicPlayer が再生中か判断する。

MusicPlayerSetPlayRateScalar

/*!
    @function   MusicPlayerSetPlayRateScalar
    @abstract   Scale the playback rate of the player
    @param      inPlayer    the player
    @param      inScaleRate a scalar that will be applied to the playback rate. If 2, playback is twice as fast, if
                0.5 it is half as fast. As a scalar, the value must be greater than zero.
*/
extern OSStatus
MusicPlayerSetPlayRateScalar(   MusicPlayer     inPlayer,
                                Float64         inScaleRate)                    __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_5_0);

MusicPlayer の再生スピードを変える。 inScaleRate が2なら2倍、0.5なら半分の速さとなる。 inScaleRate は必ず 0 より大きい値にする。

MusicPlayerGetPlayRateScalar

/*!
    @function   MusicPlayerGetPlayRateScalar
    @abstract   Get the playback rate scalar of the player
    @param      inPlayer        the player
    @param      outScaleRate    the current scalar being applied to the player. Default value is 1.0
*/
extern OSStatus
MusicPlayerGetPlayRateScalar(   MusicPlayer     inPlayer,
                                Float64 *       outScaleRate)                   __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_5_0);

MusicPlayer の再生スピードを取得する。