StevEngine
StevEngine is a customizable C++ game engine.
Loading...
Searching...
No Matches
StevEngine::Audio::AudioSystem Class Reference

Main audio system for handling sound playback and management. More...

#include <audio/AudioSystem.hpp>

Public Member Functions

void Init ()
 Initialize the audio system.
 
void Play (Emitter *emitter)
 Play an audio emitter.
 
void PlayBackground (std::string path, bool loop=true, double volume=1)
 Play background music.
 
void Stop (int channel)
 Stop audio on a specific channel.
 
void StopBackground ()
 Stop currently playing background music.
 
void SDLCALL ChannelCompleted (int channel)
 Channel finished callback.
 
void SetSoundsVolume (double volume)
 Set volume for sound effects.
 
double GetSoundsVolume () const
 
void SetMusicVolume (double volume)
 Set volume for background music.
 
double GetMusicVolume () const
 
std::vector< const char * > GetAudioDevices ()
 Get list of available audio output devices.
 
void SetAudioDevice (const char *device)
 Set active audio output device.
 
const char * GetActiveAudioDevice () const
 

Detailed Description

Main audio system for handling sound playback and management.

The AudioSystem manages all audio output including sound effects and music. It handles device selection, volume control, and playback of both one-shot and looping sounds through SDL_mixer.

Member Function Documentation

◆ ChannelCompleted()

void SDLCALL StevEngine::Audio::AudioSystem::ChannelCompleted ( int channel)

Channel finished callback.

Parameters
channelThe channel that finished playing

Called by SDL_mixer when a sound finishes playing

◆ GetAudioDevices()

std::vector< const char * > StevEngine::Audio::AudioSystem::GetAudioDevices ( )

Get list of available audio output devices.

Returns
Vector of audio device names

◆ Init()

void StevEngine::Audio::AudioSystem::Init ( )

Initialize the audio system.

Sets up SDL_mixer, loads available audio devices, and initializes default volume levels and audio format settings.

◆ Play()

void StevEngine::Audio::AudioSystem::Play ( Emitter * emitter)

Play an audio emitter.

Parameters
emitterThe audio emitter component to play

Plays the sound associated with the given emitter. If the emitter is already playing, it will be stopped and restarted.

◆ PlayBackground()

void StevEngine::Audio::AudioSystem::PlayBackground ( std::string path,
bool loop = true,
double volume = 1 )

Play background music.

Parameters
pathPath to the audio file
loopWhether to loop the music
volumeVolume level from 0.0 to 1.0

Loads and plays music from the specified file. Previous music will be stopped automatically.

◆ SetAudioDevice()

void StevEngine::Audio::AudioSystem::SetAudioDevice ( const char * device)

Set active audio output device.

Parameters
deviceName of audio device to use, or NULL for default

Changes the audio output device. The current device will be closed and audio reinitialized with the new device.

◆ SetMusicVolume()

void StevEngine::Audio::AudioSystem::SetMusicVolume ( double volume)

Set volume for background music.

Parameters
volumeVolume level from 0.0 to 1.0

Sets the master volume level for background music. Volume changes are saved to settings.

◆ SetSoundsVolume()

void StevEngine::Audio::AudioSystem::SetSoundsVolume ( double volume)

Set volume for sound effects.

Parameters
volumeVolume level from 0.0 to 1.0

Sets the master volume level for all sound effects. Volume changes are saved to settings.

◆ Stop()

void StevEngine::Audio::AudioSystem::Stop ( int channel)

Stop audio on a specific channel.

Parameters
channelThe channel ID to stop

The documentation for this class was generated from the following files: