OldSchool Library 1.5.1
Loading...
Searching...
No Matches
audio.h File Reference

Header file for audio management in OSLib, providing structures and functions for playing various sound formats. More...

Data Structures

struct  OSL_SOUND
 Represents a sound object in OSLib. More...
 
struct  osl_audio_channelinfo
 Channel information for internal system use only. More...
 
struct  OSL_AUDIO_VOICE
 User-facing channel representation, primarily for sound drivers. More...
 

Macros

#define OSL_NUM_AUDIO_CHANNELS   8
 
#define OSL_VOLUME_MAX   0x8000
 
#define oslAudioSetDefaultSampleNumber(num)   (osl_audioDefaultNumSamples = num)
 Sets the default number of samples per audio buffer read.
 
#define oslSetSoundEndCallback(s, fct)   (s->endCallback = (fct))
 Sets a callback function to be invoked when a sound finishes playing.
 
#define oslSetSoundLoop(s, loop)   oslSetSoundEndCallback(s, (loop) ? oslSoundLoopFunc : NULL)
 Sets the looping state of a sound.
 

Typedefs

typedef struct OSL_SOUND OSL_SOUND
 Represents a sound object in OSLib.
 
typedef int(* oslAudioThreadfunc_t) (int args, void *argp)
 Defines a function type for audio threading.
 

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

int oslInitAudio ()
 Initializes the audio system.
 
void oslDeinitAudio ()
 Deinitializes the audio system.
 
void oslInitAudioME (int formats)
 Initializes Media Engine audio support.
 
OSL_SOUND * oslLoadSoundFile (const char *filename, int stream)
 Loads a sound file and determines its format based on the file extension.
 
OSL_SOUND * oslLoadSoundFileWAV (const char *filename, int stream)
 Loads a WAV sound file.
 
OSL_SOUND * oslLoadSoundFileBGM (const char *filename, int stream)
 Loads a BGM sound file.
 
OSL_SOUND * oslLoadSoundFileMOD (const char *filename, int stream)
 Loads a MOD sound file.
 
OSL_SOUND * oslLoadSoundFileMP3 (const char *filename, int stream)
 Loads an MP3 sound file.
 
OSL_SOUND * oslLoadSoundFileAT3 (const char *filename, int stream)
 Loads an AT3 (ATRAC3) sound file.
 
void oslSetModSampleRate (int freq, int stereo, int shift)
 Sets the sample rate for MOD file playback in OSLib.
 
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.
 
int oslGetSoundChannel (OSL_SOUND *s)
 Retrieves the channel number on which a specific sound is currently being played.
 
int oslAudioCreateChannel (int i, int format, int numSamples, OSL_SOUND *s)
 Creates an audio channel.
 
int oslAudioRecreateChannel (int i, int format, int numSamples, OSL_SOUND *s)
 Recreates an existing audio channel with new parameters.
 
void oslAudioDeleteChannel (int i)
 Deletes an audio channel.
 
int oslAudioOutBlocking (unsigned int channel, unsigned int vol1, unsigned int vol2, void *buf)
 Outputs audio to a channel, blocking until completion.
 
int oslSoundLoopFunc (OSL_SOUND *s, int voice)
 Callback function that loops a sound indefinitely.
 

Variables

int osl_audioDefaultNumSamples
 Default number of samples per buffer, initialized to 512.
 
volatile int osl_audioActive [OSL_NUM_AUDIO_CHANNELS]
 Arrays indicating active and busy status of each audio channel.
 
int osl_suspendNumber
 Counter used to manage suspensions in audio playback.
 
OSL_AUDIO_VOICE osl_audioVoices [OSL_NUM_AUDIO_CHANNELS]
 Array of OSL_AUDIO_VOICE structures, representing each audio channel's current properties.
 

Detailed Description

Header file for audio management in OSLib, providing structures and functions for playing various sound formats.