OldSchool Library
Advanced Audio Management

Functions and definitions for advanced audio management in OSLib. More...

Typedefs

typedef int(* oslAudioThreadfunc_t) (int args, void *argp)
 Defines a function type for audio threading.
 

Functions

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

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

Functions and definitions for advanced audio management in OSLib.

Typedef Documentation

◆ oslAudioThreadfunc_t

typedef int(* oslAudioThreadfunc_t) (int args, void *argp)

Defines a function type for audio threading.

Parameters
argsNumber of arguments passed to the thread function.
argpPointer to the argument list.
Returns
Should return 0 on success or a negative error code on failure.

Function Documentation

◆ oslGetSoundChannel()

int oslGetSoundChannel ( OSL_SOUND * s)
extern

Retrieves the channel number on which a specific sound is currently being played.

This function checks the active audio channels and returns the channel number where the specified sound is playing. If the sound is not active on any channel, it returns -1, indicating that the sound is not currently being played.

This is useful for managing audio dynamically within an application, allowing for checks on sound states before making decisions on audio control (such as stopping or altering playback).

Parameters
sPointer to an OSL_SOUND structure representing the sound to check. The sound object should have been initialized and possibly started playing before calling this function.
Returns
The channel number (ranging from 0 to the maximum number of channels minus one) on which the sound is playing, or -1 if the sound is not currently active.

This function can be part of the Advanced Audio Management group, as it provides essential information for advanced audio management tasks.

◆ oslAudioCreateChannel()

int oslAudioCreateChannel ( int i,
int format,
int numSamples,
OSL_SOUND * s )
extern

Creates an audio channel.

Parameters
iChannel index to be created.
formatAudio format for the channel (e.g., OSL_FMT_MONO, OSL_FMT_STEREO).
numSamplesNumber of samples to handle per audio frame.
sPointer to the OSL_SOUND structure associated with the channel.
Returns
Returns 0 on success or a negative error code on failure.

◆ oslAudioRecreateChannel()

int oslAudioRecreateChannel ( int i,
int format,
int numSamples,
OSL_SOUND * s )
extern

Recreates an existing audio channel with new parameters.

Parameters
iChannel index to be recreated.
formatNew audio format for the channel.
numSamplesNew number of samples to handle per audio frame.
sPointer to the OSL_SOUND structure associated with the channel.
Returns
Returns 0 on success or a negative error code on failure.

◆ oslAudioDeleteChannel()

void oslAudioDeleteChannel ( int i)
extern

Deletes an audio channel.

Parameters
iChannel index to be deleted.

◆ oslAudioOutBlocking()

int oslAudioOutBlocking ( unsigned int channel,
unsigned int vol1,
unsigned int vol2,
void * buf )
extern

Outputs audio to a channel, blocking until completion.

Parameters
channelChannel index where audio should be output.
vol1Volume level for the left audio channel.
vol2Volume level for the right audio channel.
bufPointer to the buffer containing audio data to be played.
Returns
Returns the number of samples played.

◆ oslSoundLoopFunc()

int oslSoundLoopFunc ( OSL_SOUND * s,
int voice )
extern

Callback function that loops a sound indefinitely.

This standard callback function is designed to loop a sound. It can be set as the sound end callback for a sound object using oslSetSoundLoop. When the sound reaches the end, this function is invoked to immediately restart it, creating a continuous loop effect.

Parameters
sPointer to the OSL_SOUND structure of the sound that finished playing.
voiceThe channel number on which the sound was playing.
Returns
Always returns 1 to indicate that the sound should continue playing.

Variable Documentation

◆ osl_audioVoices

OSL_AUDIO_VOICE osl_audioVoices[OSL_NUM_AUDIO_CHANNELS]
extern

Array of OSL_AUDIO_VOICE structures, representing each audio channel's current properties.

This array holds information about all active audio voices within the system. Each entry in the array represents a channel and includes properties such as the currently playing sound.