OldSchool Library
|
Provides functionalities for audio playback within OSLib. More...
Macros | |
#define | oslSetSoundEndCallback(s, fct) |
Sets a callback function to be invoked when a sound finishes playing. | |
#define | oslSetSoundLoop(s, loop) |
Sets the looping state of a sound. | |
Enumerations | |
enum | { OSL_FMT_NONE = 0 } |
enum | { OSL_FMT_MASK = 0xff } |
enum | { OSL_FMT_MONO = 0 , OSL_FMT_STEREO = 0x200 , OSL_FMT_STREAM = 0x400 } |
enum | { OSL_FMT_44K = 0 , OSL_FMT_22K = 1 , OSL_FMT_11K = 2 } |
enum | oslInitAudioME_formats { OSL_FMT_AT3 = 1 , OSL_FMT_MP3 = 2 , OSL_FMT_ALL = 3 } |
Functions | |
void | oslPlaySound (OSL_SOUND *s, int voice) |
Plays a sound on a specified channel. | |
void | oslStopSound (OSL_SOUND *s) |
Stops a currently playing sound. | |
void | oslPauseSound (OSL_SOUND *s, int pause) |
Pauses, resumes, or toggles a sound. | |
void | oslDeleteSound (OSL_SOUND *s) |
Deletes a sound, freeing associated memory. | |
void | oslAudioVSync () |
Synchronizes audio streaming with the PSP's power management. | |
Provides functionalities for audio playback within OSLib.
#define oslSetSoundEndCallback | ( | s, | |
fct ) |
Sets a callback function to be invoked when a sound finishes playing.
This macro assigns a user-defined callback function to a sound object, which is called when the sound reaches the end of its playback. The callback can determine whether to stop the sound, continue playback, or start a different sound on the same channel.
s | Pointer to an OSL_SOUND structure for which the callback is to be set. |
fct | Pointer to the callback function that will be called when the sound finishes. The function signature should be: int callback(OSL_SOUND* sound, int voice);
|
This macro facilitates dynamic sound management, allowing for complex audio behavior based on application-specific logic.
#define oslSetSoundLoop | ( | s, | |
loop ) |
Sets the looping state of a sound.
This macro configures whether a sound should loop continuously or stop after playing once. It uses the oslSetSoundEndCallback function to assign a loop control callback. If looping is enabled, the oslSoundLoopFunc function is set as the callback, which automatically restarts the sound when it finishes playing. If looping is disabled, no callback is set, allowing the sound to stop after reaching the end.
s | Pointer to an OSL_SOUND structure representing the sound to configure. |
loop | Boolean value determining the looping behavior:
|
Utilizing this macro simplifies the process of managing sound playback, especially for background music or long-standing audio effects in games and multimedia applications.
anonymous enum |
anonymous enum |
anonymous enum |
Defines the audio output configuration and streaming capabilities for playback in OSLib. These flags are used to set the properties of audio channels and to control how audio data is processed and delivered.
anonymous enum |
|
extern |
Plays a sound on a specified channel.
This function plays a sound on one of the available audio channels, numbered from 0 to 7. If a sound is already playing on the specified channel, it will be stopped and replaced by the new sound. This feature allows up to 8 sounds to be played simultaneously, with each channel capable of handling one sound at a time.
The use of multiple channels enables complex audio scenarios where various sounds do not interfere with each other unless explicitly programmed to do so. For example, background music can be played on one channel, while sound effects like jumps or coin pickups can be managed on others.
s | Pointer to an OSL_SOUND structure representing the sound to be played. |
voice | Channel number on which to play the sound. Valid values are from 0 to 7. |
The example demonstrates managing different sound effects and music tracks, showing how replacing sounds on the same channel can control audio playback dynamically.
|
extern |
Stops a currently playing sound.
This function immediately stops the playback of a specified sound. It is useful for managing audio playback dynamically, allowing you to halt sound effects or music based on game events or user actions. After stopping, the sound can be restarted using oslPlaySound() from the beginning or manipulated further if needed.
s | Pointer to an OSL_SOUND structure representing the sound to stop. The sound must be currently playing; otherwise, the function has no effect. |
This function is part of the Audio Player group, which includes other audio control functions.
|
extern |
Pauses, resumes, or toggles a sound.
This function controls the pause state of a specified sound. It can pause, resume, or toggle the sound's playback based on the 'pause' parameter. This allows for dynamic control over sound playback, useful in various application scenarios such as pausing the game or responding to user interactions.
s | Pointer to an OSL_SOUND structure representing the sound to control. |
pause | Control the sound's playback state:
|
This function is part of the Audio Player group.
|
extern |
Deletes a sound, freeing associated memory.
This function stops any currently playing sound and frees all resources associated with it. It is essential to call this function for every loaded sound when it is no longer needed, to prevent memory leaks and to clean up the audio system resources.
s | Pointer to an OSL_SOUND structure that is to be deleted. If the sound is currently playing, it will be stopped first. |
This function is also part of the Audio Player group.
|
extern |
Synchronizes audio streaming with the PSP's power management.
This function ensures that streamed audio files continue to play seamlessly after the PSP resumes from stand-by mode. It should be called regularly within the game loop to maintain audio playback synchronization, especially when handling streamed audio files.
Including this function in your game loop ensures that audio playback issues do not occur after the PSP resumes from a standby state.