Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Add an asynchronous mixer voice (useful for playing sound effects)
- * \param[in] device The device to add the voice to
- * \param[in] linearInterpolation Whether to use linear interpolation or nearest-neighbor when resampling
- * \param[in] stereo Whether to use stereo or mono for each track
- * \param[in] outputVoiceID The voice to output to (0 for the device itself)
- * \param[in] numTracks The maximum number of tracks that can play at once
- * \return The index of the newly-created voice, or 0 on error (call SDL_GetError() for more info)
- *
- * \remark There is no AsyncRemove function. Instead, use VoiceRemove on the returned voice ID! \n
- * \remark Also, the resulting VoiceSpec is that of the device, EXCEPT for stereo (and format, which will always be AUDIO_F32).
- */
- extern Uint32 kit_kmixerAsyncAdd(kit_kmixerDevice* device,
- SDL_bool linearInterpolation, SDL_bool stereo,
- Uint32 outputVoiceID, Uint32 numTracks);
- /**
- * Play a kit_acodecPCM audio clip asynchronously, with a custom pan, volume, and speed
- * \param[in] device The device that contains the async voice
- * \param[in] voiceID The async voice to query
- * \param[in] pcm The audio clip to queue
- * \param[in] pan The pan setting of the clip (-1.0f -> 1.0f)
- * \param[in] volumeL The left channel's volume, or total volume if mono (>=0.0f)
- * \param[in] volumeR The right channel's volume (>=0.0f; ignored if mono)
- * \param[in] speedMultiplier The speed the clip should play at; 1 for 1x, 1.5 for 1.5x, etc.
- * \return The track that clip was queued, -2 if no free track was found, or -1 on error (call SDL_GetError() for more info)
- *
- * \remark To check for a valid async voice, the first 4 bytes of *userdata are compared to 0x54414455 ("UDAT"). \n
- * This means that even if the voice is invalid, no error will occur if the check is true (so don't do that)!
- * \sa kit_kmixerAsyncPlay
- * \sa kit_kmixerAsyncPlayP
- * \sa kit_kmixerAsyncPlayV
- * \sa kit_kmixerAsyncPlayS
- * \sa kit_kmixerAsyncStopTrack
- * \sa kit_kmixerAsyncStopAllTracks
- */
- extern Uint32 kit_kmixerAsyncPlayPVS(kit_kmixerDevice* device, Uint32 voiceID, kit_acodecPCM* pcm,
- float pan, float volumeL, float volumeR, double speedMultiplier);
- /**
- * Play a kit_acodecPCM audio clip asynchronously
- * \param[in] device The device that contains the async voice
- * \param[in] voiceID The async voice to query
- * \param[in] pcm The audio clip to queue
- * \return The track that clip was queued, -2 if no free track was found, or -1 on error (call SDL_GetError() for more info)
- *
- * \remark (refer to to kit_kmixerAsyncPlayPVS 's remark)
- * \sa kit_kmixerAsyncPlayPVS
- * \sa kit_kmixerAsyncPlayP
- * \sa kit_kmixerAsyncPlayV
- * \sa kit_kmixerAsyncPlayS
- * \sa kit_kmixerAsyncStopTrack
- * \sa kit_kmixerAsyncStopAllTracks
- */
- static inline Uint32 kit_kmixerAsyncPlay(kit_kmixerDevice* device, Uint32 voiceID, kit_acodecPCM* pcm){
- return kit_kmixerAsyncPlayPVS(device, voiceID, pcm, 0.0f, 1.0f,1.0f, 1.0);
- }
- /**
- * Play a kit_acodecPCM audio clip asynchronously, with a custom pan
- * \param[in] device The device that contains the async voice
- * \param[in] voiceID The async voice to query
- * \param[in] pcm The audio clip to queue
- * \param[in] pan The pan setting of the clip (-1.0f -> 1.0f)
- * \return The track that clip was queued, -2 if no free track was found, or -1 on error (call SDL_GetError() for more info)
- *
- * \remark (refer to to kit_kmixerAsyncPlayPVS 's remark)
- * \sa kit_kmixerAsyncPlayPVS
- * \sa kit_kmixerAsyncPlay
- * \sa kit_kmixerAsyncPlayV
- * \sa kit_kmixerAsyncPlayS
- * \sa kit_kmixerAsyncStopTrack
- * \sa kit_kmixerAsyncStopAllTracks
- */
- static inline Uint32 kit_kmixerAsyncPlayP(kit_kmixerDevice* device, Uint32 voiceID, kit_acodecPCM* pcm,
- float pan)
- {
- return kit_kmixerAsyncPlayPVS(device, voiceID, pcm, pan, 1.0f,1.0f, 1.0);
- }
- /**
- * Play a kit_acodecPCM audio clip asynchronously, with a custom volume
- * \param[in] device The device that contains the async voice
- * \param[in] voiceID The async voice to query
- * \param[in] pcm The audio clip to queue
- * \param[in] volumeL The left channel's volume, or total volume if mono (>=0.0f)
- * \param[in] volumeR The right channel's volume (>=0.0f; ignored if mono)
- * \return The track that clip was queued, -2 if no free track was found, or -1 on error (call SDL_GetError() for more info)
- *
- * \remark (refer to to kit_kmixerAsyncPlayPVS 's remark)
- * \sa kit_kmixerAsyncPlayPVS
- * \sa kit_kmixerAsyncPlay
- * \sa kit_kmixerAsyncPlayP
- * \sa kit_kmixerAsyncPlayS
- * \sa kit_kmixerAsyncStopTrack
- * \sa kit_kmixerAsyncStopAllTracks
- */
- static inline Uint32 kit_kmixerAsyncPlayV(kit_kmixerDevice* device, Uint32 voiceID, kit_acodecPCM* pcm,
- float volumeL, float volumeR)
- {
- return kit_kmixerAsyncPlayPVS(device, voiceID, pcm, 0.0f, volumeL,volumeR, 1.0);
- }
- /**
- * Play a kit_acodecPCM audio clip asynchronously, with a custom speed
- * \param[in] device The device that contains the async voice
- * \param[in] voiceID The async voice to query
- * \param[in] pcm The audio clip to queue
- * \param[in] speedMultiplier The speed the clip should play at; 1 for 1x, 1.5 for 1.5x, etc.
- * \return The track that clip was queued, -2 if no free track was found, or -1 on error (call SDL_GetError() for more info)
- *
- * \remark (refer to to kit_kmixerAsyncPlayPVS 's remark)
- * \sa kit_kmixerAsyncPlayPVS
- * \sa kit_kmixerAsyncPlay
- * \sa kit_kmixerAsyncPlayP
- * \sa kit_kmixerAsyncPlayV
- * \sa kit_kmixerAsyncStopTrack
- * \sa kit_kmixerAsyncStopAllTracks
- */
- static inline Uint32 kit_kmixerAsyncPlayS(kit_kmixerDevice* device, Uint32 voiceID, kit_acodecPCM* pcm,
- double speedMultiplier)
- {
- return kit_kmixerAsyncPlayPVS(device, voiceID, pcm, 0.0f, 1.0f,1.0f, speedMultiplier);
- }
- /**
- * Force an async track to stop playing
- * \param[in] device The device that contains the async voice
- * \param[in] voiceID The async voice to query
- * \param[in] trackNum The track to stop
- * \return 0 on success, 1 if track isn't playing anything, or <0 on error (call SDL_GetError() for more info)
- *
- * \remark (refer to to kit_kmixerAsyncPlayPVS 's remark)
- * \sa kit_kmixerAsyncPlayPVS
- * \sa kit_kmixerAsyncPlay
- * \sa kit_kmixerAsyncPlayP
- * \sa kit_kmixerAsyncPlayV
- * \sa kit_kmixerAsyncPlayS
- * \sa kit_kmixerAsyncStopAllTracks
- */
- extern int kit_kmixerAsyncStopTrack(kit_kmixerDevice* device, Uint32 voiceID,
- Uint32 trackNum);
- /**
- * Force all async tracks to stop playing
- * \param[in] device The device that contains the async voice
- * \param[in] voiceID The async voice to query
- * \return 0 on success, or <0 on error (call SDL_GetError() for more info)
- *
- * \remark (refer to to kit_kmixerAsyncPlayPVS 's remark)
- * \sa kit_kmixerAsyncPlayPVS
- * \sa kit_kmixerAsyncPlay
- * \sa kit_kmixerAsyncPlayP
- * \sa kit_kmixerAsyncPlayV
- * \sa kit_kmixerAsyncPlayS
- * \sa kit_kmixerAsyncStopTrack
- */
- extern int kit_kmixerAsyncStopAllTracks(kit_kmixerDevice* device, Uint32 voiceID);
- /**
- * Get the number of tracks actively playing audio clips
- * \param[in] device The device that contains the async voice
- * \param[in] voiceID The async voice to query
- * \return The number of active tracks, or -1 on error (call SDL_GetError() for more info)
- *
- * \remark (refer to to kit_kmixerAsyncPlayPVS 's remark)
- * \sa kit_kmixerAsyncPlayPVS
- * \sa kit_kmixerAsyncGetNumTracks
- * \sa kit_kmixerAsyncGetTrackPlayState
- * \sa kit_kmixerAsyncGetTrackPosition
- */
- extern Uint32 kit_kmixerAsyncGetActiveTracks(kit_kmixerDevice* device, Uint32 voiceID);
- /**
- * Get the total number of tracks of an async voice
- * \param[in] device The device that contains the async voice
- * \param[in] voiceID The async voice to query
- * \return The number of tracks, or -1 on error (call SDL_GetError() for more info)
- *
- * \remark (refer to to kit_kmixerAsyncPlayPVS 's remark)
- * \sa kit_kmixerAsyncPlayPVS
- * \sa kit_kmixerAsyncGetActiveTracks
- * \sa kit_kmixerAsyncGetTrackPlayState
- * \sa kit_kmixerAsyncGetTrackPosition
- */
- extern Uint32 kit_kmixerAsyncGetNumTracks(kit_kmixerDevice* device, Uint32 voiceID);
- /**
- * Get a boolean of whether a given async track is playing or not
- * \param[in] device The device that contains the async voice
- * \param[in] voiceID The async voice to query
- * \param[in] trackNum The track to query
- * \return The aforementioned boolean, or -1 on error (call SDL_GetError() for more info)
- *
- * \remark (refer to to kit_kmixerAsyncPlayPVS 's remark)
- * \sa kit_kmixerAsyncPlayPVS
- * \sa kit_kmixerAsyncGetActiveTracks
- * \sa kit_kmixerAsyncGetNumTracks
- * \sa kit_kmixerAsyncGetTrackPosition
- */
- extern int kit_kmixerAsyncGetTrackPlayState(kit_kmixerDevice* device, Uint32 voiceID,
- Uint32 trackNum);
- /**
- * Get current position of a track's clip, in seconds
- * \param[in] device The device that contains the async voice
- * \param[in] voiceID The async voice to query
- * \param[in] trackNum The track to query
- * \return The current position, or NAN on error (call SDL_GetError() for more info)
- *
- * \remark (refer to to kit_kmixerAsyncPlayPVS 's remark)
- * \sa kit_kmixerAsyncPlayPVS
- * \sa kit_kmixerAsyncGetActiveTracks
- * \sa kit_kmixerAsyncGetNumTracks
- * \sa kit_kmixerAsyncGetTrackPlayState
- */
- extern double kit_kmixerAsyncGetTrackPosition(kit_kmixerDevice* device, Uint32 voiceID,
- Uint32 trackNum);
- /**
- * Set an async track's deltaS value, in units per sample (to be applied to current speed every sample)
- * \param[in] device The device that contains the async voice
- * \param[in] voiceID The async voice to query
- * \param[in] trackNum The track to query
- * \param[in] deltaS The new deltaS value to set the track to
- * \return 0 on success, or -1 on error (call SDL_GetError() for more info)
- *
- * \remark (refer to to kit_kmixerAsyncPlayPVS 's remark)
- * \sa kit_kmixerAsyncPlayPVS
- */
- extern int kit_kmixerAsyncSetTrackDeltaS(kit_kmixerDevice* device, Uint32 voiceID,
- Uint32 trackNum, double deltaS);
- /**
- * Set an async track's deltaS value, in seconds to speed = 0->1 or 1->0 (to be applied to current speed every sample)
- * \param[in] device The device that contains the async voice
- * \param[in] voiceID The async voice to query
- * \param[in] trackNum The track to query
- * \param[in] deltaS_seconds The new deltaS value to set the track to
- * \return 0 on success, or -1 on error (call SDL_GetError() for more info)
- *
- * \remark (refer to to kit_kmixerAsyncPlayPVS 's remark)
- * \sa kit_kmixerAsyncPlayPVS
- */
- static inline int kit_kmixerAsyncSetTrackDeltaS2(kit_kmixerDevice* device, Uint32 voiceID,
- Uint32 trackNum, double deltaS_seconds)
- {
- int freq = device->_spec.freq;
- return kit_kmixerAsyncSetTrackDeltaS(device, voiceID, trackNum, (1.0/deltaS_seconds)/freq);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement