Fireset
Loading...
Searching...
No Matches
Audio

2D positional sound using OpenAL. More...

Classes

struct  FsSound
 Represents a loaded sound buffer. More...
struct  FsSoundSource
 Represents a sound source in 2D space. More...

Functions

FsSound fsSoundLoad (const char *filename)
 Loads a sound from file.
void fsSoundFree (FsSound *sound)
 Frees a loaded sound.
FsSoundSource fsSoundSourceCreate (FsVec2 position, bool looping)
 Creates a new sound source.
void fsSoundSourcePlay (FsSound *sound, FsSoundSource *source, float volume)
 Plays a sound on a source.
void fsSoundSourceStop (FsSoundSource *source)
 Stops a sound source.
void fsSoundSourceFree (FsSoundSource *source)
 Frees a sound source.
void fsSoundSourceHandle (int count, FsSoundSource *sources)
 Updates multiple sound sources.
void fsSoundListenerSetPosition (FsVec2 position)
 Sets the audio listener position.

Detailed Description

2D positional sound using OpenAL.

Function Documentation

◆ fsSoundFree()

void fsSoundFree ( FsSound * sound)

Frees a loaded sound.

Frees the sample memory and resets the FsSound structure.

Parameters
soundPointer to the FsSound to free.

◆ fsSoundListenerSetPosition()

void fsSoundListenerSetPosition ( FsVec2 position)

Sets the audio listener position.

Defines the position of the audio listener in 2D space. This position is used by the audio system to calculate positional sound effects such as attenuation and panning.

Parameters
positionListener position in world space.
Note
Internally maps the 2D position to OpenAL using Z = 0.

◆ fsSoundLoad()

FsSound fsSoundLoad ( const char * filename)

Loads a sound from file.

Loads a sound file using libsndfile and generates an OpenAL buffer.

Parameters
filenamePath to the audio file.
Returns
FsSound structure containing audio data and buffer.

◆ fsSoundSourceCreate()

FsSoundSource fsSoundSourceCreate ( FsVec2 position,
bool looping )

Creates a new sound source.

Initializes a FsSoundSource at a given position.

Parameters
position2D position of the source.
loopingShould the source loop when played.
Returns
FsSoundSource initialized but not playing.

◆ fsSoundSourceFree()

void fsSoundSourceFree ( FsSoundSource * source)

Frees a sound source.

Stops playback and deletes the OpenAL source.

Parameters
sourcePointer to the FsSoundSource to free.

◆ fsSoundSourceHandle()

void fsSoundSourceHandle ( int count,
FsSoundSource * sources )

Updates multiple sound sources.

Handles playback state, looping, and stopping for an array of sources.

Parameters
countNumber of sources in the array.
sourcesArray of FsSoundSource to handle.

◆ fsSoundSourcePlay()

void fsSoundSourcePlay ( FsSound * sound,
FsSoundSource * source,
float volume )

Plays a sound on a source.

Binds the sound to the source, sets volume, looping, and plays it.

Parameters
soundPointer to the loaded FsSound.
sourcePointer to the FsSoundSource.
volumeVolume in percentage (0–100).

◆ fsSoundSourceStop()

void fsSoundSourceStop ( FsSoundSource * source)

Stops a sound source.

Stops playback if the source is currently playing.

Parameters
sourcePointer to the FsSoundSource to stop.